tools/image-info: support iso
Add the support for ISOs. Mounting then as a loopack device and then accessing the content as a tarball
This commit is contained in:
parent
d0be1ec5a4
commit
0324e02659
1 changed files with 18 additions and 0 deletions
|
|
@ -18,6 +18,7 @@ import time
|
|||
import tempfile
|
||||
import xml.etree.ElementTree
|
||||
import yaml
|
||||
import pathlib
|
||||
import jsonschema
|
||||
|
||||
from collections import OrderedDict
|
||||
|
|
@ -2835,6 +2836,21 @@ def analyse_compressed(path):
|
|||
image = os.path.join(tmpdir, files[0])
|
||||
return analyse_image(image)
|
||||
|
||||
def is_iso(path):
|
||||
return "iso" in pathlib.Path(path).suffix
|
||||
|
||||
|
||||
def analyse_iso(path):
|
||||
with tempfile.TemporaryDirectory(dir="/var/tmp") as tmp:
|
||||
report = None
|
||||
subprocess.run(["mount", "-o", "loop", path, tmp], check=True)
|
||||
try:
|
||||
report = analyse_tarball(os.path.join(tmp, "liveimg.tar.gz"))
|
||||
except Exception as e:
|
||||
print(f"{e}", file=sys.stderr)
|
||||
subprocess.run(["umount", tmp], check=True)
|
||||
return report
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Inspect an image")
|
||||
|
|
@ -2851,6 +2867,8 @@ def main():
|
|||
report = analyse_tarball(target)
|
||||
elif is_compressed(target):
|
||||
report = analyse_compressed(target)
|
||||
elif is_iso(target):
|
||||
report = analyse_iso(target)
|
||||
else:
|
||||
report = analyse_image(target)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue