Skip to content

Commit

Permalink
mkksiso: Add support for adding an anaconda updates.img
Browse files Browse the repository at this point in the history
Anaconda supports an updates.img file that can be used to assist in
development, the files in it are added to the boot.iso's rootfs before
Anaconda is started.

Use `mkksiso --updates /path/to/updates.img` to add the image to the
iso. It can be used by itself or in combination with other options.

It would be great way to avoid requirement for HTTP server for local
development.
  • Loading branch information
jkonecny12 authored and bcl committed Feb 2, 2024
1 parent a88fcaf commit 0829a51
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/bin/mkksiso
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def CheckDiscinfo(path):
raise RuntimeError("iso arch does not match the host arch.")


def MakeKickstartISO(input_iso, output_iso, ks="", add_paths=None,
def MakeKickstartISO(input_iso, output_iso, ks="", updates_image="", add_paths=None,
cmdline="", rm_args="", new_volid="", implantmd5=True,
skip_efi=False):
"""
Expand Down Expand Up @@ -511,7 +511,12 @@ def MakeKickstartISO(input_iso, output_iso, ks="", add_paths=None,
for p in add_paths:
cmd.extend(["-map", p, os.path.basename(p)])

if CheckBigFiles(add_paths):
# include updates image which will be automatically loaded when on correct place
if updates_image:
cmd.extend(["-map", updates_image, "updates/updates.img"])

check_paths = add_paths if not updates_image else add_paths + [updates_image]
if CheckBigFiles(check_paths):
if "-as" not in cmd:
cmd.extend(["-as", "mkisofs"])
cmd.extend(["-iso-level", "3"])
Expand Down Expand Up @@ -555,6 +560,8 @@ def setup_arg_parser():
help="Do not run implantisomd5 on the ouput iso")
parser.add_argument("--ks", type=os.path.abspath, metavar="KICKSTART",
help="Optional kickstart to add to the ISO")
parser.add_argument("-u", "--updates", type=os.path.abspath, metavar="IMAGE",
help="Optional updates image to add to the ISO")
parser.add_argument("-V", "--volid", dest="volid", help="Set the ISO volume id, defaults to input's", default=None)
parser.add_argument("--skip-mkefiboot", action="store_true", dest="skip_efi",
help="Skip running mkefiboot")
Expand Down Expand Up @@ -599,14 +606,14 @@ def main():
log.error("Use either --ks KICKSTART or positional KICKSTART but not both")
errors = True

if not any([args.ks or args.ks_pos, args.add_paths, args.cmdline, args.rm_args, args.volid]):
log.error("Nothing to do - pass one or more of --ks, --add, --cmdline, --rm-args, --volid")
if not any([args.ks or args.ks_pos, args.updates, args.add_paths, args.cmdline, args.rm_args, args.volid]):
log.error("Nothing to do - pass one or more of --ks, --updates, --add, --cmdline, --rm-args, --volid")
errors = True

if errors:
raise RuntimeError("Problems running %s" % sys.argv[0])

MakeKickstartISO(args.input_iso, args.output_iso, args.ks or args.ks_pos,
MakeKickstartISO(args.input_iso, args.output_iso, args.ks or args.ks_pos, args.updates,
args.add_paths, args.cmdline, args.rm_args,
args.volid, args.no_md5sum, args.skip_efi)
except RuntimeError as e:
Expand Down
17 changes: 17 additions & 0 deletions tests/mkksiso/test_mkksiso.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,20 @@ def test_MakeKickstartISO(self):

# Read the modified config file(s) and compare to result file
check_cfg_results(self, tmpdir, self.configs)

def test_MakeKickstartISO_updates(self):
"""
Test if updates image is stored in the ISO correctly.
"""

self.out_iso = tempfile.mktemp(prefix="mkksiso-")

with tempfile.NamedTemporaryFile() as mocked_updates:
open(mocked_updates.name, "wb").close()

MakeKickstartISO(self.test_iso, self.out_iso, updates_image=mocked_updates.name, skip_efi=True)

with tempfile.TemporaryDirectory(prefix="mkksiso-") as tmpdir:
ExtractISOFiles(self.out_iso, ["updates/updates.img"], tmpdir)

self.assertTrue(os.path.exists(os.path.join(tmpdir, "updates/updates.img")))

0 comments on commit 0829a51

Please sign in to comment.