image-info: cover situation when /boot is on a separate partition

Some images with ESP, e.g. the `rhel-ec2-aarch64`, have the `/boot` on
a separate partition. `image-info` currently produces traceback on such
images, e.g.:

Traceback (most recent call last):
  File "/home/thozza/devel/osbuild-composer/./tools/image-info", line 1997, in <module>
    main()
  File "/home/thozza/devel/osbuild-composer/./tools/image-info", line 1991, in main
    report = analyse_image(target)
  File "/home/thozza/devel/osbuild-composer/./tools/image-info", line 1863, in analyse_image
    append_partitions(report, device, loctl)
  File "/home/thozza/devel/osbuild-composer/./tools/image-info", line 1849, in append_partitions
    append_filesystem(report, tree)
  File "/home/thozza/devel/osbuild-composer/./tools/image-info", line 1809, in append_filesystem
    with open(f"{tree}/grub2/grubenv") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp3i__6m1w/grub2/grubenv'

The reason is that `grub2/grubenv` on the `/boot` partition is a symlink
to `../efi/EFI/redhat/grubenv`. However the `efi` directory on the
`/boot` partition is empty and the ESP must be mounted to it for the
expected path to exist.

Modify `image-info` to mount the ESP to `efi` directory if it exists on
the inspected partition.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
This commit is contained in:
Tomas Hozza 2021-07-12 17:18:00 +02:00 committed by Tomas Hozza
parent c53283f5e9
commit a9ecf5a839

View file

@ -1845,6 +1845,10 @@ def append_partitions(report, device, loctl):
if esp and os.path.exists(f"{tree}/boot/efi"):
with mount_at(devices[esp_id], f"{tree}/boot/efi", options=['umask=077']):
append_filesystem(report, tree)
# situation when /boot is on a separate partition
elif esp and os.path.exists(f"{tree}/efi"):
with mount_at(devices[esp_id], f"{tree}/efi", options=['umask=077']):
append_filesystem(report, tree)
else:
append_filesystem(report, tree)