tools/osbuild-image-info: fail early if fstab isn't found

When the fstab file isn't found, the root_tree will never be set after
being initialised to "" and an exception is raised "The root filesystem
tree is not mounted".  It's a lot clearer if the failure happens closer
to the root cause, which is that fstab wasn't found and there are no
fstab entries to iterate through and find the root filesystem.
This commit is contained in:
Achilleas Koutsou 2025-01-06 21:05:37 +01:00 committed by Tomáš Hozza
parent dc047513b7
commit 10029167db

View file

@ -2630,6 +2630,9 @@ def append_partitions(report, image):
if os.path.exists(f"{tree}/etc/fstab"):
fstab.extend(read_fstab(tree))
break
else:
raise RuntimeError("no fstab file found")
# sort the fstab entries by the mountpoint
fstab = sorted(fstab, key=operator.itemgetter(1))