Skip to content

Commit

Permalink
buildextend-live: add --miniso switch
Browse files Browse the repository at this point in the history
This switch enables the new minimal ISO packing feature (see
coreos/coreos-installer#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.
  • Loading branch information
jlebon committed Oct 1, 2021
1 parent 2849ca5 commit 707919a
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/cmd-buildextend-live
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 707919a

Please sign in to comment.