-
Notifications
You must be signed in to change notification settings - Fork 143
examples: Add bootc UKI & BLS examples #1614
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a1e82f0
examples: Add initial bootc examples (bls & uki)
travier c49fea0
examples/bootc*: Secure Boot support
travier 1ef204d
examples/bootc*: Temporary bootc install scripts
travier 5dbba4a
examples/bootc*: Migrate from cfsctl to bootc internals cfs
jeckersb 8590773
tmt: Add test for bootc examples build scripts
jeckersb 27295cc
examples: move under tmt/tests/
jeckersb 52c1755
Dockerfile: enable initramfs by default
jeckersb 0d578cf
Use ext4 by default when building integration disk image
jeckersb 15b8e14
examples: use "system" bootc binaries
jeckersb 4e9f167
tests: skip initramfs if no composefs in cmdline
jeckersb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| FROM quay.io/fedora/fedora-bootc:42 | ||
| COPY extra / | ||
| COPY bootc /usr/bin | ||
|
|
||
| RUN passwd -d root | ||
|
|
||
| # need to have bootc-initramfs-setup in the initramfs so we need this | ||
| RUN set -x; \ | ||
| kver=$(cd /usr/lib/modules && echo *); \ | ||
| dracut -vf --install "/etc/passwd /etc/group" /usr/lib/modules/$kver/initramfs.img $kver; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -eux | ||
|
|
||
| cd "${0%/*}" | ||
|
|
||
| cp /usr/bin/bootc . | ||
| cp /usr/lib/bootc/initramfs-setup extra/usr/lib/dracut/modules.d/37bootc/bootc-initramfs-setup | ||
|
|
||
| mkdir -p tmp | ||
|
|
||
| podman build \ | ||
| -t quay.io/fedora/fedora-bootc-bls:42 \ | ||
| -f Containerfile \ | ||
| --iidfile=tmp/iid \ | ||
| . |
3 changes: 3 additions & 0 deletions
3
tmt/tests/examples/bootc-bls/extra/usr/lib/dracut/dracut.conf.d/37composefs.conf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # we need to force these in via the initramfs because we don't have modules in | ||
| # the base image | ||
| force_drivers+=" virtio_net vfat " |
34 changes: 34 additions & 0 deletions
34
...s/examples/bootc-bls/extra/usr/lib/dracut/modules.d/37bootc/bootc-initramfs-setup.service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # Copyright (C) 2013 Colin Walters <[email protected]> | ||
| # | ||
| # This library is free software; you can redistribute it and/or | ||
| # modify it under the terms of the GNU Lesser General Public | ||
| # License as published by the Free Software Foundation; either | ||
| # version 2 of the License, or (at your option) any later version. | ||
| # | ||
| # This library is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| # Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public | ||
| # License along with this library. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| [Unit] | ||
| DefaultDependencies=no | ||
| ConditionKernelCommandLine=composefs | ||
| ConditionPathExists=/etc/initrd-release | ||
| After=sysroot.mount | ||
| Requires=sysroot.mount | ||
| Before=initrd-root-fs.target | ||
| Before=initrd-switch-root.target | ||
|
|
||
| OnFailure=emergency.target | ||
| OnFailureJobMode=isolate | ||
|
|
||
| [Service] | ||
| Type=oneshot | ||
| ExecStart=/usr/bin/bootc-initramfs-setup | ||
| StandardInput=null | ||
| StandardOutput=journal | ||
| StandardError=journal+console | ||
| RemainAfterExit=yes |
20 changes: 20 additions & 0 deletions
20
tmt/tests/examples/bootc-bls/extra/usr/lib/dracut/modules.d/37bootc/module-setup.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #!/usr/bin/bash | ||
|
|
||
| check() { | ||
| return 0 | ||
| } | ||
|
|
||
| depends() { | ||
| return 0 | ||
| } | ||
|
|
||
| install() { | ||
| inst \ | ||
| "${moddir}/bootc-initramfs-setup" /usr/bin/bootc-initramfs-setup | ||
| inst \ | ||
| "${moddir}/bootc-initramfs-setup.service" \ | ||
| "${systemdsystemunitdir}/bootc-initramfs-setup.service" | ||
|
|
||
| $SYSTEMCTL -q --root "${initdir}" add-wants \ | ||
| 'initrd-root-fs.target' 'bootc-initramfs-setup.service' | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| FROM quay.io/fedora/fedora-bootc:42 | ||
| COPY extra / | ||
| COPY bootc /usr/bin | ||
|
|
||
| RUN passwd -d root | ||
|
|
||
| # need to have composefs setup root in the initramfs so we need this | ||
| RUN set -x; \ | ||
| kver=$(cd /usr/lib/modules && echo *); \ | ||
| dracut -vf --install "/etc/passwd /etc/group" /usr/lib/modules/$kver/initramfs.img $kver; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| FROM quay.io/fedora/fedora-bootc-base-uki:42 AS base | ||
|
|
||
| FROM base as kernel | ||
|
|
||
| ARG COMPOSEFS_FSVERITY | ||
|
|
||
| RUN --mount=type=secret,id=key \ | ||
| --mount=type=secret,id=cert <<EOF | ||
| set -eux | ||
|
|
||
| mkdir -p /etc/kernel /etc/dracut.conf.d | ||
| echo "console=ttyS0,115200 composefs=${COMPOSEFS_FSVERITY} selinux=1 enforcing=0 systemd.debug_shell=1 root=UUID=6523f8ae-3eb1-4e2a-a05a-18b695ae656f rw" > /etc/kernel/cmdline | ||
|
|
||
| dnf install -y systemd-ukify sbsigntools systemd-boot-unsigned | ||
| kver=$(cd /usr/lib/modules && echo *) | ||
| ukify build \ | ||
| --linux "/usr/lib/modules/$kver/vmlinuz" \ | ||
| --initrd "/usr/lib/modules/$kver/initramfs.img" \ | ||
| --uname="${kver}" \ | ||
| --cmdline "@/etc/kernel/cmdline" \ | ||
| --os-release "@/etc/os-release" \ | ||
| --signtool sbsign \ | ||
| --secureboot-private-key "/run/secrets/key" \ | ||
| --secureboot-certificate "/run/secrets/cert" \ | ||
| --measure \ | ||
| --json pretty \ | ||
| --output "/boot/$kver.efi" | ||
| sbsign \ | ||
| --key "/run/secrets/key" \ | ||
| --cert "/run/secrets/cert" \ | ||
| "/usr/lib/systemd/boot/efi/systemd-bootx64.efi" \ | ||
| --output "/boot/systemd-bootx64.efi" | ||
| EOF | ||
|
|
||
| FROM base as final | ||
|
|
||
| RUN --mount=type=bind,from=kernel,target=/_mount/kernel <<EOF | ||
| kver=$(cd /usr/lib/modules && echo *) | ||
| mkdir -p /boot/EFI/Linux | ||
| # We put the UKI in /boot for now due to composefs verity not being the | ||
| # same due to mtime of /usr/lib/modules being changed | ||
| cp /_mount/kernel/boot/$kver.efi /boot/EFI/Linux/$kver.efi | ||
| EOF | ||
|
|
||
| FROM base as final-final | ||
| COPY --from=final /boot /boot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -eux | ||
|
|
||
| cd "${0%/*}" | ||
|
|
||
| cp /usr/bin/bootc . | ||
| cp /usr/lib/bootc/initramfs-setup extra/usr/lib/dracut/modules.d/37bootc/bootc-initramfs-setup | ||
|
|
||
| mkdir -p tmp | ||
|
|
||
| podman build \ | ||
| -t quay.io/fedora/fedora-bootc-base-uki:42 \ | ||
| -f Containerfile.stage1 \ | ||
| --iidfile=tmp/iid \ | ||
| . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -eux | ||
|
|
||
| cd "${0%/*}" | ||
|
|
||
| cp /usr/bin/bootc . | ||
|
|
||
| rm -rf tmp/sysroot | ||
| mkdir -p tmp/sysroot/composefs | ||
|
|
||
| IMAGE_ID="$(sed s/sha256:// tmp/iid)" | ||
| ./bootc internals cfs --repo tmp/sysroot/composefs oci pull containers-storage:"${IMAGE_ID}" | ||
| COMPOSEFS_FSVERITY="$(./bootc internals cfs --repo tmp/sysroot/composefs oci compute-id --bootable "${IMAGE_ID}")" | ||
|
|
||
| # See: https://wiki.archlinux.org/title/Unified_Extensible_Firmware_Interface/Secure_Boot | ||
| # Alternative to generate keys for testing: `sbctl create-keys` | ||
| if [[ ! -d "secureboot" ]]; then | ||
| echo "Generating test Secure Boot keys" | ||
| mkdir secureboot | ||
| pushd secureboot > /dev/null | ||
| uuidgen --random > GUID.txt | ||
| openssl req -newkey rsa:4096 -nodes -keyout PK.key -new -x509 -sha256 -days 3650 -subj "/CN=Test Platform Key/" -out PK.crt | ||
| openssl x509 -outform DER -in PK.crt -out PK.cer | ||
| openssl req -newkey rsa:4096 -nodes -keyout KEK.key -new -x509 -sha256 -days 3650 -subj "/CN=Test Key Exchange Key/" -out KEK.crt | ||
| openssl x509 -outform DER -in KEK.crt -out KEK.cer | ||
| openssl req -newkey rsa:4096 -nodes -keyout db.key -new -x509 -sha256 -days 3650 -subj "/CN=Test Signature Database key/" -out db.crt | ||
| openssl x509 -outform DER -in db.crt -out db.cer | ||
| popd > /dev/null | ||
| fi | ||
|
|
||
| # For debugging, add --no-cache to podman command | ||
| sudo podman build \ | ||
| -t quay.io/fedora/fedora-bootc-uki:42 \ | ||
| --build-arg=COMPOSEFS_FSVERITY="${COMPOSEFS_FSVERITY}" \ | ||
| -f Containerfile.stage2 \ | ||
| --secret=id=key,src=secureboot/db.key \ | ||
| --secret=id=cert,src=secureboot/db.crt \ | ||
| --iidfile=tmp/iid2 | ||
|
|
||
| rm -rf tmp/efi | ||
| mkdir -p tmp/efi | ||
| ./bootc internals cfs --repo tmp/sysroot/composefs oci pull containers-storage:"${IMAGE_ID}" | ||
| ./bootc internals cfs --repo tmp/sysroot/composefs oci compute-id --bootable "${IMAGE_ID}" | ||
| ./bootc internals cfs --repo tmp/sysroot/composefs oci prepare-boot "${IMAGE_ID}" --bootdir tmp/efi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -eux | ||
|
|
||
| cd "${0%/*}" | ||
|
|
||
| if [[ ! -d "secureboot" ]]; then | ||
| echo "fail" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # See: https://github.com/rhuefi/qemu-ovmf-secureboot | ||
| # $ dnf install -y python3-virt-firmware | ||
| GUID=$(cat secureboot/GUID.txt) | ||
| virt-fw-vars --input "/usr/share/edk2/ovmf/OVMF_VARS_4M.secboot.qcow2" \ | ||
| --secure-boot \ | ||
| --set-pk $GUID "secureboot/PK.crt" \ | ||
| --add-kek $GUID "secureboot/KEK.crt" \ | ||
| --add-db $GUID "secureboot/db.crt" \ | ||
| -o "VARS_CUSTOM.secboot.qcow2.template" |
3 changes: 3 additions & 0 deletions
3
tmt/tests/examples/bootc-uki/extra/usr/lib/dracut/dracut.conf.d/37composefs.conf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # we need to force these in via the initramfs because we don't have modules in | ||
| # the base image | ||
| force_drivers+=" virtio_net vfat " |
34 changes: 34 additions & 0 deletions
34
...s/examples/bootc-uki/extra/usr/lib/dracut/modules.d/37bootc/bootc-initramfs-setup.service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # Copyright (C) 2013 Colin Walters <[email protected]> | ||
| # | ||
| # This library is free software; you can redistribute it and/or | ||
| # modify it under the terms of the GNU Lesser General Public | ||
| # License as published by the Free Software Foundation; either | ||
| # version 2 of the License, or (at your option) any later version. | ||
| # | ||
| # This library is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| # Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public | ||
| # License along with this library. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| [Unit] | ||
| DefaultDependencies=no | ||
| ConditionKernelCommandLine=composefs | ||
| ConditionPathExists=/etc/initrd-release | ||
| After=sysroot.mount | ||
| Requires=sysroot.mount | ||
| Before=initrd-root-fs.target | ||
| Before=initrd-switch-root.target | ||
|
|
||
| OnFailure=emergency.target | ||
| OnFailureJobMode=isolate | ||
|
|
||
| [Service] | ||
| Type=oneshot | ||
| ExecStart=/usr/bin/bootc-initramfs-setup | ||
| StandardInput=null | ||
| StandardOutput=journal | ||
| StandardError=journal+console | ||
| RemainAfterExit=yes |
20 changes: 20 additions & 0 deletions
20
tmt/tests/examples/bootc-uki/extra/usr/lib/dracut/modules.d/37bootc/module-setup.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #!/usr/bin/bash | ||
|
|
||
| check() { | ||
| return 0 | ||
| } | ||
|
|
||
| depends() { | ||
| return 0 | ||
| } | ||
|
|
||
| install() { | ||
| inst \ | ||
| "${moddir}/bootc-initramfs-setup" /usr/bin/bootc-initramfs-setup | ||
| inst \ | ||
| "${moddir}/bootc-initramfs-setup.service" \ | ||
| "${systemdsystemunitdir}/bootc-initramfs-setup.service" | ||
|
|
||
| $SYSTEMCTL -q --root "${initdir}" add-wants \ | ||
| 'initrd-root-fs.target' 'bootc-initramfs-setup.service' | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -eux | ||
|
|
||
| curl http://192.168.122.1:8000/bootc -o bootc | ||
| chmod +x bootc | ||
|
|
||
| IMAGE=quay.io/fedora/fedora-bootc-uki:42 | ||
|
|
||
| # --env RUST_LOG=debug \ | ||
| # --env RUST_BACKTRACE=1 \ | ||
| podman run \ | ||
| --rm --privileged \ | ||
| --pid=host \ | ||
| -v /dev:/dev \ | ||
| -v /var/lib/containers:/var/lib/containers \ | ||
| -v /srv/bootc:/usr/bin/bootc:ro,Z \ | ||
| -v /var/tmp:/var/tmp \ | ||
| --security-opt label=type:unconfined_t \ | ||
| "${IMAGE}" \ | ||
| bootc install to-disk \ | ||
| --composefs-native \ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right now bcvk doesn't allow passing arbitrary flags; we can add that of course, but I do think we should be aiming to move this to an install flag or autodetection instead. |
||
| --boot=uki \ | ||
| --source-imgref="containers-storage:${IMAGE}" \ | ||
| --target-imgref="${IMAGE}" \ | ||
| --target-transport="docker" \ | ||
| /dev/vdb \ | ||
| --filesystem=ext4 \ | ||
| --wipe | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK for now but I think the composefs base image build should override the filesystem type here?
Or hmmm...actually we should fail at
bootc container linttime if the base image specifies a filesystem which is known not to support fsverity probably and it's a sealed image.