Exclude existing files in boot.iso

JIRA: RHELCMP-10811
Fixes: https://pagure.io/pungi/issue/1647
Signed-off-by: Haibo Lin <hlin@redhat.com>
(cherry picked from commit 3175ede38a)
This commit is contained in:
Haibo Lin 2023-03-07 18:00:31 +08:00 committed by Stepan Oksanichenko
parent 5de829d05b
commit 4cd7d39914
Signed by: soksanichenko
GPG Key ID: AB9983172AB1E45B
2 changed files with 22 additions and 5 deletions

View File

@ -5,6 +5,7 @@ from __future__ import print_function
import os import os
import six import six
from collections import namedtuple from collections import namedtuple
from kobo.shortcuts import run
from six.moves import shlex_quote from six.moves import shlex_quote
from .wrappers import iso from .wrappers import iso
@ -119,6 +120,17 @@ def make_jigdo(f, opts):
def write_xorriso_commands(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)) script = os.path.join(opts.script_dir, "xorriso-%s.txt" % id(opts))
with open(script, "w") as f: with open(script, "w") as f:
emit(f, "-indev %s" % opts.boot_iso) emit(f, "-indev %s" % opts.boot_iso)
@ -131,6 +143,8 @@ 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:
continue
emit(f, "-map %s %s" % (fs_path, iso_path)) emit(f, "-map %s %s" % (fs_path, iso_path))
if opts.arch == "ppc64le": if opts.arch == "ppc64le":

View File

@ -260,20 +260,23 @@ def get_isohybrid_cmd(iso_path, arch):
return cmd 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: if xorriso:
return """xorriso -dev %s --find | return """xorriso -dev %s --find |
tail -n+2 | tail -n+2 |
tr -d "'" | tr -d "'" |
cut -c2- | cut -c2- |
sort >> %s.manifest""" % ( sort >> %s""" % (
shlex_quote(iso_name),
shlex_quote(iso_name), shlex_quote(iso_name),
shlex_quote(output_file),
) )
else: else:
return "isoinfo -R -f -i %s | grep -v '/TRANS.TBL$' | sort >> %s.manifest" % ( return "isoinfo -R -f -i %s | grep -v '/TRANS.TBL$' | sort >> %s" % (
shlex_quote(iso_name),
shlex_quote(iso_name), shlex_quote(iso_name),
shlex_quote(output_file),
) )