From d07f517a90c337f58a238ed67d4e599c0173ed73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Thu, 16 Mar 2023 10:10:41 +0100 Subject: [PATCH] createiso: Update possibly changed file on DVD MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There's no good way of detecting if buildinstall phase tweaked boot configuration (and efiboot.img). We should update those files in the DVD just to be sure. The .discinfo file is always different and needs to be updated. Relates: https://pagure.io/pungi/issue/1647 JIRA: RHELCMP-10811 Signed-off-by: Lubomír Sedlář (cherry picked from commit e1d7544c2b1d10d36f1f4d00a1882cad5dce9d25) --- pungi/createiso.py | 22 +++++++++++++++++++--- pungi/phases/buildinstall.py | 7 ++++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/pungi/createiso.py b/pungi/createiso.py index 5dcf4799..c9520d3d 100644 --- a/pungi/createiso.py +++ b/pungi/createiso.py @@ -11,6 +11,8 @@ from six.moves import shlex_quote from .wrappers import iso from .wrappers.jigdo import JigdoWrapper +from .phases.buildinstall import BOOT_CONFIGS, BOOT_IMAGES + CreateIsoOpts = namedtuple( "CreateIsoOpts", @@ -120,6 +122,7 @@ def make_jigdo(f, opts): def write_xorriso_commands(opts): + # Create manifest for the boot.iso listing all contents boot_iso_manifest = "%s.manifest" % os.path.join( opts.script_dir, os.path.basename(opts.boot_iso) ) @@ -128,8 +131,20 @@ def write_xorriso_commands(opts): opts.boot_iso, opts.use_xorrisofs, output_file=boot_iso_manifest ) ) + # Find which files may have been updated by pungi. This only includes a few + # files from tweaking buildinstall and .discinfo metadata. There's no good + # way to detect whether the boot config files actually changed, so we may + # be updating files in the ISO with the same data. + UPDATEABLE_FILES = set(BOOT_IMAGES + BOOT_CONFIGS + [".discinfo"]) + updated_files = set() + excluded_files = set() with open(boot_iso_manifest) as f: - exclude = set(line.lstrip("/").rstrip("\n") for line in f) + for line in f: + path = line.lstrip("/").rstrip("\n") + if path in UPDATEABLE_FILES: + updated_files.add(path) + else: + excluded_files.add(path) script = os.path.join(opts.script_dir, "xorriso-%s.txt" % id(opts)) with open(script, "w") as f: @@ -143,9 +158,10 @@ def write_xorriso_commands(opts): with open(opts.graft_points) as gp: for line in gp: iso_path, fs_path = line.strip().split("=", 1) - if iso_path in exclude: + if iso_path in excluded_files: continue - emit(f, "-map %s %s" % (fs_path, iso_path)) + cmd = "-update" if iso_path in updated_files else "-map" + emit(f, "%s %s %s" % (cmd, fs_path, iso_path)) if opts.arch == "ppc64le": # This is needed for the image to be bootable. diff --git a/pungi/phases/buildinstall.py b/pungi/phases/buildinstall.py index e6110618..b9d2e5fc 100644 --- a/pungi/phases/buildinstall.py +++ b/pungi/phases/buildinstall.py @@ -364,6 +364,9 @@ BOOT_CONFIGS = [ "EFI/BOOT/BOOTX64.conf", "EFI/BOOT/grub.cfg", ] +BOOT_IMAGES = [ + "images/efiboot.img", +] def tweak_configs(path, volid, ks_file, configs=BOOT_CONFIGS, logger=None): @@ -443,9 +446,7 @@ def tweak_buildinstall( if kickstart_file and found_configs: shutil.copy2(kickstart_file, os.path.join(dst, "ks.cfg")) - images = [ - os.path.join(tmp_dir, "images", "efiboot.img"), - ] + images = [os.path.join(tmp_dir, img) for img in BOOT_IMAGES] if found_configs: for image in images: if not os.path.isfile(image):