Skip to content

Commit

Permalink
cmd-buildextend-live: Move constants to file top level and standardiz…
Browse files Browse the repository at this point in the history
…e naming

- Rename `ignition_img_size` to `IGNITION_IMG_SIZE`
and `miniso_data_file_size` to `MINISO_DATA_FILE_SIZE`
for consistent naming convention;
- Move these definitions to the top level for better visibility and maintainability

Signed-off-by: Renata Ravanelli <[email protected]>
  • Loading branch information
ravanelli committed Oct 29, 2024
1 parent 4f5e7f7 commit dc48a5f
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/cmd-buildextend-live
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ from cosalib.cmdlib import runcmd, sha256sum_file
from cosalib.cmdlib import import_ostree_commit, get_basearch, ensure_glob
from cosalib.meta import GenericBuildMeta

# Size of file used to embed an Ignition config within a CPIO.
IGNITION_IMG_SIZE = 256 * 1024

# Size of the file used to embed miniso data.
MINISO_DATA_FILE_SIZE = 16 * 1024

live_exclude_kargs = set([
'$ignition_firstboot', # unsubstituted variable in grub config
'console', # no serial console by default on ISO
Expand Down Expand Up @@ -110,13 +116,6 @@ for d in (tmpdir, tmpisoroot, tmpisocoreos, tmpisoimages, tmpisoimagespxe,
tmpisoisolinux, tmpinitrd_base, tmpinitrd_rootfs):
os.mkdir(d)

# Size of file used to embed an Ignition config within a CPIO.
ignition_img_size = 256 * 1024

# Size of the file used to embed miniso data.
miniso_data_file_size = 16 * 1024


# 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 @@ -289,7 +288,7 @@ def generate_iso():
# handled lower down
if basearch != 's390x':
with open(os.path.join(tmpisoimages, 'ignition.img'), 'wb') as fdst:
fdst.write(bytes(ignition_img_size))
fdst.write(bytes(IGNITION_IMG_SIZE))
igninfo_json = {'file': 'images/ignition.img'}

# Generate JSON file that lists OS features available to
Expand Down Expand Up @@ -512,7 +511,7 @@ def generate_iso():
assert initramfs_size % 4 == 0

# combine kernel, initramfs and cmdline using the mk-s390image tool
os.truncate(iso_initramfs, initramfs_size + ignition_img_size)
os.truncate(iso_initramfs, initramfs_size + IGNITION_IMG_SIZE)
runcmd(['/usr/bin/mk-s390image',
kernel_dest,
os.path.join(tmpisoimages, 'cdboot.img'),
Expand All @@ -538,7 +537,7 @@ def generate_iso():
igninfo_json = {
'file': 'images/cdboot.img',
'offset': offset + initramfs_size,
'length': ignition_img_size,
'length': IGNITION_IMG_SIZE,
}

# kargs are part of 'images/cdboot.img' blob
Expand Down Expand Up @@ -707,7 +706,7 @@ boot

miniso_data = os.path.join(tmpisocoreos, "miniso.dat")
with open(miniso_data, 'wb') as f:
f.truncate(miniso_data_file_size)
f.truncate(MINISO_DATA_FILE_SIZE)

if args.fixture:
# Replace or delete anything irrelevant to coreos-installer
Expand Down

0 comments on commit dc48a5f

Please sign in to comment.