Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bake_flatcar_image.sh: Bake sysexts into Flatcar OS images #48

Merged
merged 1 commit into from
Feb 26, 2024

Conversation

t-lo
Copy link
Member

@t-lo t-lo commented Feb 21, 2024

This change introduces bake_flatcar_image.sh, a standalone script for creating Flatcar OS images with sysexts (from the bakery and other sources) included.

The script will download a generic Flatcar OS image (version can be specified), copy local sysexts into root or OEM partitions, and create respective symlinks to /etc/extensions.

By default, the script operates on local sysext files. However, the --fetch option may be specified to download sysext(s) from the latest Bakery release.

Optionally, vendor images can be created. If requested, the script will use the Flatcar SDK corresponding to the OS image version to generate vendor images from the generic image.

NOTE that building vendor images requires flatcar/scripts#1682 . To test, apply https://github.com/flatcar/scripts/commit/28070022226970ff3e819516a60721d8648a0f23.diff right after the script checked out the scripts repo (can be done in parallel because the script will spend some time downloading SDK container and OS images before continuing).

How to use

Run the script:

./bake_flatcar_image.sh --fetch wasmtime:wasmtime-17.0.1-x86-64.raw

or

wget https://github.com/flatcar/sysext-bakery/releases/download/latest/wasmtime-17.0.1-x86-64.raw
wget https://github.com/flatcar/sysext-bakery/releases/download/latest/wasmtime.conf
./bake_flatcar_image.sh wasmtime:wasmtime-17.0.1-x86-64.raw

Then loopback-mount flatcar_production_image.bin (partition 9) to verify.

To build a bootable image, use

wget https://github.com/flatcar/scripts/commit/28070022226970ff3e819516a60721d8648a0f23.diff
./bake_flatcar_image.sh --vendor qemu wasmtime:wasmtime-17.0.1-x86-64.raw
# AFTER THE SDK WAS CHECKED OUT, in a separate terminal window, run
cd flatcar-os-image
patch -p1 <../28070022226970ff3e819516a60721d8648a0f23.diff
# after the build concluded, run
chmod 755 flatcar_production_qemu_uefi.sh
bunzip2 flatcar_production_qemu_uefi_image.img.bz2
./flatcar_production_qemu_uefi.sh -nographic -snapshot
# [ ... system boots ...]
wasmtime --version

Testing done

  • Built wasmtime qemu_uefi OS images for x86-64 and arm64, both root and oem partitions, booted and tested wasmtime.
  • Built ami and azure vendor images but didn't test.

@t-lo t-lo requested a review from a team February 21, 2024 10:42
@t-lo t-lo force-pushed the t-lo/add-flatcar-image-baking branch from 6670489 to b5d4788 Compare February 21, 2024 12:12
Signed-off-by: Thilo Fromm <thilofromm@microsoft.com>
@t-lo t-lo force-pushed the t-lo/add-flatcar-image-baking branch from b5d4788 to 866ffed Compare February 21, 2024 12:26
fi

trap "docker container rm --force flatcar-oem-builder" EXIT
COREOS_OFFICIAL=1 ./run_sdk_container -n flatcar-oem-builder \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of building a new image which requires the SDK and thus takes very long time, we could rather download the released vendor image and use qemu-nbd or a temporary qemu-img convert step to modify it directly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't build a new image - it uses the generic image downloaded earlier to create a vendor image. Only the vendor bits are installed, and all of these come from binary packages. It's quite fast.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Also, I'm hesitant to create and to support two different ways of creating vendor images...)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The step with the binary packages may be fast but the setup of the SDK container not. Anyway, not a blocker.

@t-lo t-lo merged commit b2f6986 into main Feb 26, 2024
@t-lo t-lo deleted the t-lo/add-flatcar-image-baking branch February 26, 2024 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants