@@ -318,6 +318,7 @@ def generate_iso():
318
318
print (f'Substituting ISO kernel arguments: { kargs } ' )
319
319
320
320
files_with_karg_embed_areas = {}
321
+ cmdline = ''
321
322
karg_embed_area_length = 0
322
323
# Grab all the contents from the live dir from the configs
323
324
for srcdir , _ , filenames in os .walk (srcdir_prefix ):
@@ -341,6 +342,12 @@ def generate_iso():
341
342
buf = newbuf
342
343
karg_area_end = re .search (r'(#+) COREOS_KARG_EMBED_AREA\n' , buf )
343
344
if karg_area_end is not None :
345
+ file_kargs = buf [karg_area_start .start ():karg_area_end .start ()]
346
+ if len (cmdline ) == 0 :
347
+ cmdline = file_kargs
348
+ elif cmdline != file_kargs :
349
+ raise Exception (f'Default cmdline is different: "{ cmdline } " != "{ file_kargs } "' )
350
+
344
351
length = karg_area_end .start () + len (karg_area_end [1 ]) - karg_area_start .start ()
345
352
files_with_karg_embed_areas [filename ] = karg_area_start .start ()
346
353
if karg_embed_area_length == 0 :
@@ -352,6 +359,9 @@ def generate_iso():
352
359
shutil .copystat (srcfile , dstfile )
353
360
print (f'{ srcfile } -> { dstfile } ' )
354
361
362
+ with open (os .path .join (tmpisoroot , '.cmdline' ), 'w' ) as fh :
363
+ fh .write (cmdline )
364
+
355
365
# These sections are based on lorax templates
356
366
# see https://github.com/weldr/lorax/tree/master/share/templates.d/99-generic
357
367
@@ -526,8 +536,8 @@ def generate_iso():
526
536
# coreos-installer side first
527
537
INITRDFMT = '<8s2Q'
528
538
assert struct .calcsize (INITRDFMT ) == 24
529
- KARGSFMT = f"<8s{ MAX_KARG_FILES + 1 } Q" # +1 for area length
530
- assert struct .calcsize (KARGSFMT ) == 64
539
+ KARGSFMT = f"<8s{ MAX_KARG_FILES + 1 + 1 } Q" # +1 for area length and +1 for offset to default read-only '.cmdline'
540
+ assert struct .calcsize (KARGSFMT ) == 72
531
541
532
542
# Start of the Ignition padding within the ISO
533
543
offset = file_offset_in_iso (isoinfo , ignition_img )
@@ -540,11 +550,14 @@ def generate_iso():
540
550
# Write header at the end of the System Area
541
551
isofh .seek (ISO_SYSTEM_AREA_SIZE - (struct .calcsize (INITRDFMT ) +
542
552
struct .calcsize (KARGSFMT )))
543
- offsets = [0 ] * MAX_KARG_FILES
553
+
554
+ offsets = [0 ] * (MAX_KARG_FILES + 1 ) # +1 for offset to default
555
+ # This is ours default read-only '.cmdline' file, which is used for `coreos-installer iso kargs reset ISO`
556
+ offsets [0 ] = file_offset_in_iso (isoinfo , '.cmdline' )
544
557
545
558
for i , fn in enumerate (files_with_karg_embed_areas ):
546
559
offset_in_file = files_with_karg_embed_areas [fn ]
547
- offsets [i ] = file_offset_in_iso (isoinfo , fn ) + offset_in_file
560
+ offsets [i + 1 ] = file_offset_in_iso (isoinfo , fn ) + offset_in_file
548
561
isofh .write (struct .pack (KARGSFMT , b'corekarg' , karg_embed_area_length , * offsets ))
549
562
# Magic number + offset + length
550
563
isofh .write (struct .pack (INITRDFMT , b'coreiso+' , offset , initrd_ignition_padding ))
0 commit comments