[elbe-devel] [PATCH 6/7] initvmaction: Alternative iso extract implementation
Bastian Germann
bage at linutronix.de
Wed Nov 2 19:28:18 CET 2022
7z may not be available on a system. Implement the ISO extraction in
initvmaction based on pycdlib as an alternative.
Signed-off-by: Bastian Germann <bage at linutronix.de>
---
elbepack/initvmaction.py | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/elbepack/initvmaction.py b/elbepack/initvmaction.py
index 95bc3fdda8..bf3cb46eb5 100644
--- a/elbepack/initvmaction.py
+++ b/elbepack/initvmaction.py
@@ -465,7 +465,16 @@ def extract_cdrom(cdrom):
"""
tmp = TmpdirFilesystem()
- system('7z x -o%s "%s" source.xml' % (tmp.path, cdrom))
+ in_iso_name = "source.xml"
+ try:
+ import pycdlib
+ iso = pycdlib.PyCdlib()
+ iso.open(cdrom)
+ extracted = os.path.join(tmp.path, in_iso_name)
+ iso.get_file_from_iso(extracted, iso_path=f'/{in_iso_name.upper()};1')
+ iso.close()
+ except ImportError:
+ system(f'7z x -o{tmp.path} "{cdrom}" {in_iso_name}')
print("", file=sys.stderr)
--
2.30.2
More information about the elbe-devel
mailing list