[elbe-devel] [PATCH v2 6/7] initvmaction: Alternative iso extract implementation

Bastian Germann bage at linutronix.de
Tue Dec 20 11:31:29 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 44df1b1674..70d9d3315c 100644
--- a/elbepack/initvmaction.py
+++ b/elbepack/initvmaction.py
@@ -461,7 +461,16 @@ def extract_cdrom(cdrom):
     """
 
     tmp = TmpdirFilesystem()
-    system(f'7z x -o{tmp.path} "{cdrom}" source.xml')
+    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