image-info: read format info before image opening

Read the image information before opening the image. This prepares
for a change where we will use information about the image to
convert it to raw instead of using nbd.
This commit is contained in:
Christian Kellner 2020-07-07 17:41:48 +02:00 committed by Ondřej Budai
parent 44f0ba368f
commit b7a43b5812

View file

@ -288,9 +288,10 @@ def find_esp(partitions):
def analyse_image(image):
subprocess.run(["modprobe", "nbd"], check=True)
report = {}
imgfmt = read_image_format(image)
report = {"image-format": imgfmt}
with nbd_connect(image) as device:
report["image-format"] = read_image_format(image)
report["bootloader"] = read_bootloader_type(device)
report["partition-table"], report["partition-table-id"], report["partitions"] = read_partition_table(device)