diff --git a/iso/empanadas/empanadas/util/iso_utils.py b/iso/empanadas/empanadas/util/iso_utils.py index cfbb623..756f1da 100644 --- a/iso/empanadas/empanadas/util/iso_utils.py +++ b/iso/empanadas/empanadas/util/iso_utils.py @@ -771,6 +771,7 @@ class IsoBuild: if not os.path.exists(lorax_path): self.log.error(Color.FAIL + 'Lorax not found at all. This is considered fatal.') + # do we need to do a hard exit here? raise SystemExit() grafts = self._generate_graft_points( @@ -779,7 +780,12 @@ class IsoBuild: self.iso_map['images'][y]['repos'], reposcan=reposcan ) - self._extra_iso_local_config(a, y, grafts, work_root, volname) + try: + self._extra_iso_local_config(a, y, grafts, work_root) + except ValueError as exc: + self.log.error(Color.FAIL + f'An error occured while configuring extra ISO build {exc}') + self.log.error(Color.FAIL + f'Error: {exc}') + continue if self.extra_iso_mode == 'local': self._extra_iso_local_run(a, y, work_root) @@ -799,7 +805,7 @@ class IsoBuild: self._extra_iso_podman_run(arches_to_build, images_to_build_podman, work_root) - def _extra_iso_local_config(self, arch, image, grafts, work_root, volname): + def _extra_iso_local_config(self, arch, image, grafts, work_root): """ Local ISO build configuration - This generates the configuration for both mock and podman entries @@ -839,12 +845,15 @@ class IsoBuild: if self.updated_image: datestamp = '-' + self.updated_image_date - volid = f'{self.shortname}-{self.major_version}-{self.minor_version}{rclevel}-{arch}-{volname}' + volid = Idents.get_vol_id(boot_iso) isoname = f'{self.shortname}-{self.release}{rclevel}{datestamp}-{arch}-{image}.iso' generic_isoname = f'{self.shortname}-{arch}-{image}.iso' latest_isoname = f'{self.shortname}-{self.major_version}-latest-{arch}-{image}.iso' required_pkgs = self.iso_map['lorax']['required_pkgs'] + if not volid: + raise ValueError('Volume ID could not be determined') + lorax_pkg_cmd = '/usr/bin/dnf install {} -y {}'.format( ' '.join(required_pkgs), log_path_command @@ -882,6 +891,8 @@ class IsoBuild: 'iso_level': self.iso_map['iso_level'], } + self.log.info(Color.INFO + f'boot.iso volume name: {volid}') + # Generate a xorriso compatible dialog with open(grafts) as xp: xorpoint = xp.read() diff --git a/iso/empanadas/empanadas/util/shared.py b/iso/empanadas/empanadas/util/shared.py index fb053dc..79db257 100644 --- a/iso/empanadas/empanadas/util/shared.py +++ b/iso/empanadas/empanadas/util/shared.py @@ -13,6 +13,7 @@ import boto3 import xmltodict import productmd.treeinfo import productmd.composeinfo +import pycdlib import empanadas import kobo.shortcuts from empanadas.common import Color @@ -24,8 +25,13 @@ class ArchCheck: archfile = { 'x86_64': [ 'isolinux/vmlinuz', + 'images/efiboot.img', + 'images/eltorito.img', 'images/grub.conf', - 'EFI/BOOT/BOOTX64.EFI' + 'images/install.img', + 'boot/grub2/grub.cfg', + 'EFI/BOOT/BOOTX64.EFI', + 'EFI/BOOT/grub.cfg' ], 'aarch64': [ 'EFI/BOOT/BOOTAA64.EFI' @@ -1337,10 +1343,21 @@ class Idents: return False @staticmethod - def get_vol_id(opts): + def get_vol_id(i): """ - Gets a volume ID + Gets a volume ID of a given ISO """ + iso = pycdlib.PyCdlib() + try: + iso.open(i) + except pycdlib.pycdlibexception.PyCdlibInvalidISO as exc: + print(exc) + return False + + pvd = iso.pvd + volume_id = pvd.volume_identifier.decode('UTF-8').strip() + iso.close() + return volume_id class Syncs: """ diff --git a/iso/empanadas/poetry.lock b/iso/empanadas/poetry.lock index a58e0d2..40b2eb8 100644 --- a/iso/empanadas/poetry.lock +++ b/iso/empanadas/poetry.lock @@ -206,6 +206,17 @@ files = [ {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, ] +[[package]] +name = "file-magic" +version = "0.4.1" +description = "Python front end for libmagic(3)" +optional = false +python-versions = ">=2.7" +files = [ + {file = "file-magic-0.4.1.tar.gz", hash = "sha256:a91d1483117f7ed48cd0238ad9be36b04824d57e9c38ea7523113989e81b9c53"}, + {file = "file_magic-0.4.1-py3-none-any.whl", hash = "sha256:cb9496a1656baf75cadd771479f63b53081095e968d0be72b9b7a7ed538e4fb8"}, +] + [[package]] name = "gitdb" version = "4.0.11" @@ -443,6 +454,17 @@ files = [ {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, ] +[[package]] +name = "pycdlib" +version = "1.14.0" +description = "Pure python ISO manipulation library" +optional = false +python-versions = "*" +files = [ + {file = "pycdlib-1.14.0-py2.py3-none-any.whl", hash = "sha256:a905827335f0066af3fd416c5cf9b1f29dffaf4d0914b714555213d1809f38d4"}, + {file = "pycdlib-1.14.0.tar.gz", hash = "sha256:8ec306b31d9c850f28c5fda52438d904edd1e8fcf862c5ffd756272efac9f422"}, +] + [[package]] name = "pytest" version = "5.4.3" @@ -695,4 +717,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.0" python-versions = ">=3.9,<4" -content-hash = "331e1b11d9e6285ee16d66f8658ca7df0d247054f27a9de1e560fd017d86bb73" +content-hash = "60742cc3e07d8fe7b8bbe48db7be51cb2b5e09c194eedb0c4aef064f2d2c5eba" diff --git a/iso/empanadas/pyproject.toml b/iso/empanadas/pyproject.toml index 1752c3d..e646d94 100644 --- a/iso/empanadas/pyproject.toml +++ b/iso/empanadas/pyproject.toml @@ -18,6 +18,8 @@ requests = "^2.32.2" kobo = "^0.37.0" attrs = "^24.2.0" GitPython = ">=3.1.30" +file-magic = ">=0.4.0" +pycdlib = ">=1.14.0" [tool.poetry.dev-dependencies] pytest = "~5"