buildextend-live: add --miniso switch
This switch enables the new minimal ISO packing feature (see
https://github.com/coreos/coreos-installer/pull/559).
Once a coreos-installer version with miniso support is present in RHCOS
and FCOS, we can make it unconditional and drop the switch. For now,
this will allow testing in the coreos-installer upstream CI.
@@ -51,6 +51,8 @@ parser.add_argument("--fast", action='store_true', default=False,
help="Reduce compression for development (FCOS only)")
parser.add_argument("--force", action='store_true', default=False,
help="Overwrite previously generated installer")
+parser.add_argument("--miniso", action='store_true', default=False,
+ help="Enable minimal ISO packing (temporary)")
args = parser.parse_args()
# Identify the builds and target the latest build if none provided
@@ -120,6 +122,9 @@ for d in (tmpdir, tmpisoroot, tmpisocoreos, tmpisoimages, tmpisoimagespxe,
# 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
@@ -581,15 +586,28 @@ boot
fh.write('\n')
# Define inputs and outputs
- genisoargs += ['-o', tmpisofile, tmpisoroot]
+ genisoargs_final = genisoargs + ['-o', tmpisofile, tmpisoroot]
+
+ if args.miniso:
+ miniso_data = os.path.join(tmpisocoreos, "miniso.dat")
+ with open(miniso_data, 'wb') as f:
+ f.truncate(miniso_data_file_size)
- run_verbose(genisoargs)
+ run_verbose(genisoargs_final)
# Add MBR, and GPT with ESP, for x86_64 BIOS/UEFI boot when ISO is
# copied to a USB stick
if basearch == "x86_64":
run_verbose(['/usr/bin/isohybrid', '--uefi', tmpisofile])
+ if args.miniso:
+ genisoargs_minimal = genisoargs + ['-o', f'{tmpisofile}.minimal', tmpisoroot]
+ os.unlink(iso_rootfs)
+ os.unlink(miniso_data)
+ run_verbose(genisoargs_minimal)
+ if basearch == "x86_64":
+ run_verbose(['/usr/bin/isohybrid', '--uefi', f'{tmpisofile}.minimal'])
+
isoinfo = run_verbose(['isoinfo', '-lR', '-i', tmpisofile],
stdout=subprocess.PIPE, text=True).stdout
@@ -660,6 +678,11 @@ boot
isofh.write(struct.pack(INITRDFMT, b'coreiso+', offset, ignition_img_size))
print(f'Embedded {ignition_img_size} bytes Ignition config space at {offset}')
+ if args.miniso:
+ # this consumes the minimal image
+ run_verbose(['coreos-installer', 'iso', 'extract', 'pack-minimal-iso',
+ tmpisofile, f'{tmpisofile}.minimal', "--consume"])
+
buildmeta['images'].update({
'live-iso': {
'path': iso_name,
