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 Sep 24, 2021
1 parent 1217309 commit c84c898
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 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 @@ -571,15 +573,27 @@ boot
'-no-emul-boot']

# Define inputs and outputs
genisoargs += ['-o', tmpisofile, tmpisoroot]
genisoargs_final = genisoargs + ['-o', tmpisofile, tmpisoroot]

run_verbose(genisoargs)
if args.miniso:
miniso_data = os.path.join(tmpisoroot, "miniso.dat")
with open(miniso_data, 'wb') as f:
f.truncate(16 * 1024)

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'])

# We've already created a file in the ISO with initrd_ignition_padding
# bytes of zeroes. Find the byte offset of that file within the ISO
Expand Down Expand Up @@ -654,6 +668,13 @@ boot

if basearch != "s390x":
tweak_system_area(tmpisofile)
if args.miniso:
tweak_system_area(f'{tmpisofile}.minimal')

if args.miniso:
# this consumes the minimal image
run_verbose(['coreos-installer', 'iso', 'extract', 'pack-minimal',
tmpisofile, f'{tmpisofile}.minimal', "--consume"])

buildmeta['images'].update({
'live-iso': {
Expand Down

0 comments on commit c84c898

Please sign in to comment.