From 4cd7d3991498fe8f793d8038c7d840c29b7cf40f Mon Sep 17 00:00:00 2001 From: Haibo Lin Date: Tue, 7 Mar 2023 18:00:31 +0800 Subject: [PATCH] Exclude existing files in boot.iso JIRA: RHELCMP-10811 Fixes: https://pagure.io/pungi/issue/1647 Signed-off-by: Haibo Lin (cherry picked from commit 3175ede38a370482731b03a0c0e461ff758f1243) --- pungi/createiso.py | 14 ++++++++++++++ pungi/wrappers/iso.py | 13 ++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/pungi/createiso.py b/pungi/createiso.py index c857c5fe..5dcf4799 100644 --- a/pungi/createiso.py +++ b/pungi/createiso.py @@ -5,6 +5,7 @@ from __future__ import print_function import os import six from collections import namedtuple +from kobo.shortcuts import run from six.moves import shlex_quote from .wrappers import iso @@ -119,6 +120,17 @@ def make_jigdo(f, opts): def write_xorriso_commands(opts): + boot_iso_manifest = "%s.manifest" % os.path.join( + opts.script_dir, os.path.basename(opts.boot_iso) + ) + run( + iso.get_manifest_cmd( + opts.boot_iso, opts.use_xorrisofs, output_file=boot_iso_manifest + ) + ) + with open(boot_iso_manifest) as f: + exclude = set(line.lstrip("/").rstrip("\n") for line in f) + script = os.path.join(opts.script_dir, "xorriso-%s.txt" % id(opts)) with open(script, "w") as f: emit(f, "-indev %s" % opts.boot_iso) @@ -131,6 +143,8 @@ 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: + continue emit(f, "-map %s %s" % (fs_path, iso_path)) if opts.arch == "ppc64le": diff --git a/pungi/wrappers/iso.py b/pungi/wrappers/iso.py index 3f438f74..0b46ea54 100644 --- a/pungi/wrappers/iso.py +++ b/pungi/wrappers/iso.py @@ -260,20 +260,23 @@ def get_isohybrid_cmd(iso_path, arch): return cmd -def get_manifest_cmd(iso_name, xorriso=False): +def get_manifest_cmd(iso_name, xorriso=False, output_file=None): + if not output_file: + output_file = "%s.manifest" % iso_name + if xorriso: return """xorriso -dev %s --find | tail -n+2 | tr -d "'" | cut -c2- | - sort >> %s.manifest""" % ( - shlex_quote(iso_name), + sort >> %s""" % ( shlex_quote(iso_name), + shlex_quote(output_file), ) else: - return "isoinfo -R -f -i %s | grep -v '/TRANS.TBL$' | sort >> %s.manifest" % ( - shlex_quote(iso_name), + return "isoinfo -R -f -i %s | grep -v '/TRANS.TBL$' | sort >> %s" % ( shlex_quote(iso_name), + shlex_quote(output_file), )