createiso: Update possibly changed file on DVD

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ář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2023-03-16 10:10:41 +01:00 committed by lsedlar
parent a71c8e23be
commit e1d7544c2b
2 changed files with 23 additions and 6 deletions

View File

@ -11,6 +11,8 @@ from six.moves import shlex_quote
from .wrappers import iso from .wrappers import iso
from .wrappers.jigdo import JigdoWrapper from .wrappers.jigdo import JigdoWrapper
from .phases.buildinstall import BOOT_CONFIGS, BOOT_IMAGES
CreateIsoOpts = namedtuple( CreateIsoOpts = namedtuple(
"CreateIsoOpts", "CreateIsoOpts",
@ -120,6 +122,7 @@ def make_jigdo(f, opts):
def write_xorriso_commands(opts): def write_xorriso_commands(opts):
# Create manifest for the boot.iso listing all contents
boot_iso_manifest = "%s.manifest" % os.path.join( boot_iso_manifest = "%s.manifest" % os.path.join(
opts.script_dir, os.path.basename(opts.boot_iso) 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 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: 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)) script = os.path.join(opts.script_dir, "xorriso-%s.txt" % id(opts))
with open(script, "w") as f: with open(script, "w") as f:
@ -143,9 +158,10 @@ def write_xorriso_commands(opts):
with open(opts.graft_points) as gp: with open(opts.graft_points) as gp:
for line in gp: for line in gp:
iso_path, fs_path = line.strip().split("=", 1) iso_path, fs_path = line.strip().split("=", 1)
if iso_path in exclude: if iso_path in excluded_files:
continue 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": if opts.arch == "ppc64le":
# This is needed for the image to be bootable. # This is needed for the image to be bootable.

View File

@ -364,6 +364,9 @@ BOOT_CONFIGS = [
"EFI/BOOT/BOOTX64.conf", "EFI/BOOT/BOOTX64.conf",
"EFI/BOOT/grub.cfg", "EFI/BOOT/grub.cfg",
] ]
BOOT_IMAGES = [
"images/efiboot.img",
]
def tweak_configs(path, volid, ks_file, configs=BOOT_CONFIGS, logger=None): 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: if kickstart_file and found_configs:
shutil.copy2(kickstart_file, os.path.join(dst, "ks.cfg")) shutil.copy2(kickstart_file, os.path.join(dst, "ks.cfg"))
images = [ images = [os.path.join(tmp_dir, img) for img in BOOT_IMAGES]
os.path.join(tmp_dir, "images", "efiboot.img"),
]
if found_configs: if found_configs:
for image in images: for image in images:
if not os.path.isfile(image): if not os.path.isfile(image):