Skip to content

Commit

Permalink
buildextend-live: add readonly kargs file for 'coreos-installer iso k…
Browse files Browse the repository at this point in the history
…arg reset'

Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
  • Loading branch information
nikita-dubrovskii committed Oct 27, 2020
1 parent a61e632 commit 912f10f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/cmd-buildextend-live
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ def generate_iso():
kargs = ' '.join(kargs_array)
print(f'Substituting ISO kernel arguments: {kargs}')

default_kargs = ''
files_with_karg_embed_areas = {}
karg_embed_area_length = 0
# Grab all the contents from the live dir from the configs
Expand All @@ -341,6 +342,13 @@ def generate_iso():
buf = newbuf
karg_area_end = re.search(r'(#+) COREOS_KARG_EMBED_AREA\n', buf)
if karg_area_end is not None:
if len(default_kargs) == 0:
default_kargs = buf[karg_area_start.start():karg_area_end.end()]
files_with_karg_embed_areas['.cmdline'] = 0
cmdline = os.path.join(tmpisoroot, '.cmdline')
with open(cmdline, 'w') as fh:
fh.write(default_kargs if len(default_kargs) != 0 else kargs)

length = karg_area_end.start() + len(karg_area_end[1]) - karg_area_start.start()
files_with_karg_embed_areas[filename] = karg_area_start.start()
if karg_embed_area_length == 0:
Expand Down Expand Up @@ -519,15 +527,15 @@ def generate_iso():
ISO_SYSTEM_AREA_SIZE = 32768

# number of karg files we allow for in the format
MAX_KARG_FILES = 6
MAX_KARG_FILES = 7
assert len(files_with_karg_embed_areas) <= MAX_KARG_FILES

# these can really never change without ratcheting on the
# coreos-installer side first
INITRDFMT = '<8s2Q'
assert struct.calcsize(INITRDFMT) == 24
KARGSFMT = f"<8s{MAX_KARG_FILES+1}Q" # +1 for area length
assert struct.calcsize(KARGSFMT) == 64
assert struct.calcsize(KARGSFMT) == 72

# Start of the Ignition padding within the ISO
offset = file_offset_in_iso(isoinfo, ignition_img)
Expand Down

0 comments on commit 912f10f

Please sign in to comment.