Skip to content

Commit

Permalink
cmd-buildextend-live: Refactor variable declarations and directories …
Browse files Browse the repository at this point in the history
…creation

- Moved variable declarations and directories creation into generate_iso()
  to enhance clarity and maintainability.

Signed-off-by: Renata Ravanelli <[email protected]>
  • Loading branch information
ravanelli committed Oct 29, 2024
1 parent dc48a5f commit 4b076c6
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/cmd-buildextend-live
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,6 @@ name_version = f'{base_name}-{args.build}'
# version which may impede uniqueness.
volid = name_version[0:32]

tmpdir = os.environ.get("FORCE_TMPDIR", f"{workdir}/tmp/buildpost-live")
if os.path.isdir(tmpdir):
shutil.rmtree(tmpdir)

tmpisoroot = os.path.join(tmpdir, 'live')
tmpisocoreos = os.path.join(tmpisoroot, 'coreos')
tmpisoimages = os.path.join(tmpisoroot, 'images')
tmpisoimagespxe = os.path.join(tmpisoimages, 'pxeboot')
tmpisoisolinux = os.path.join(tmpisoroot, 'isolinux')
# contents of initramfs on both PXE and ISO
tmpinitrd_base = os.path.join(tmpdir, 'initrd')
# contents of rootfs image
tmpinitrd_rootfs = os.path.join(tmpdir, 'initrd-rootfs')

for d in (tmpdir, tmpisoroot, tmpisocoreos, tmpisoimages, tmpisoimagespxe,
tmpisoisolinux, tmpinitrd_base, tmpinitrd_rootfs):
os.mkdir(d)

# The kernel requires that uncompressed cpio archives appended to an initrd
# start on a 4-byte boundary. If there's misalignment, it stops unpacking
# and says:
Expand Down Expand Up @@ -221,6 +203,24 @@ def generate_iso():
kargs_file = 'kargs.json'
igninfo_file = 'igninfo.json'

tmpdir = os.environ.get("FORCE_TMPDIR", f"{workdir}/tmp/buildpost-live")
if os.path.isdir(tmpdir):
shutil.rmtree(tmpdir)

tmpisoroot = os.path.join(tmpdir, 'live')
tmpisocoreos = os.path.join(tmpisoroot, 'coreos')
tmpisoimages = os.path.join(tmpisoroot, 'images')
tmpisoimagespxe = os.path.join(tmpisoimages, 'pxeboot')
tmpisoisolinux = os.path.join(tmpisoroot, 'isolinux')
# contents of initramfs on both PXE and ISO
tmpinitrd_base = os.path.join(tmpdir, 'initrd')
# contents of rootfs image
tmpinitrd_rootfs = os.path.join(tmpdir, 'initrd-rootfs')

for d in (tmpdir, tmpisoroot, tmpisocoreos, tmpisoimages, tmpisoimagespxe,
tmpisoisolinux, tmpinitrd_base, tmpinitrd_rootfs):
os.mkdir(d)

tmpisofile = os.path.join(tmpdir, iso_name)

img_metal_obj = buildmeta.get_artifact_meta("metal", unmerged=True)["images"].get("metal")
Expand Down

0 comments on commit 4b076c6

Please sign in to comment.