|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -eux |
| 4 | + |
| 5 | +cd "${0%/*}" |
| 6 | + |
| 7 | +cargo build --release --features=pre-6.15 --bin cfsctl --bin composefs-setup-root |
| 8 | + |
| 9 | +cp ../../target/release/cfsctl . |
| 10 | + |
| 11 | +rm -rf tmp/sysroot |
| 12 | +mkdir -p tmp/sysroot/composefs |
| 13 | + |
| 14 | +IMAGE_ID="$(sed s/sha256:// tmp/iid)" |
| 15 | +./cfsctl --repo tmp/sysroot/composefs oci pull containers-storage:"${IMAGE_ID}" |
| 16 | +COMPOSEFS_FSVERITY="$(./cfsctl --repo tmp/sysroot/composefs oci compute-id --bootable "${IMAGE_ID}")" |
| 17 | + |
| 18 | +sudo podman build \ |
| 19 | + -t quay.io/fedora/fedora-bootc-uki:42 \ |
| 20 | + --build-arg=COMPOSEFS_FSVERITY="${COMPOSEFS_FSVERITY}" \ |
| 21 | + -f Containerfile.stage2 \ |
| 22 | + --iidfile=tmp/iid2 |
| 23 | + |
| 24 | +rm -rf tmp/efi |
| 25 | +mkdir -p tmp/efi |
| 26 | +./cfsctl --repo tmp/sysroot/composefs oci pull containers-storage:"${IMAGE_ID}" |
| 27 | +./cfsctl --repo tmp/sysroot/composefs oci compute-id --bootable "${IMAGE_ID}" |
| 28 | +./cfsctl --repo tmp/sysroot/composefs oci prepare-boot "${IMAGE_ID}" --bootdir tmp/efi |
| 29 | + |
| 30 | +# For debugging, add --no-cache to podman command |
| 31 | +# mkdir tmp/internal-sysroot |
| 32 | +# # podman build \ |
| 33 | +# --iidfile=tmp/iid \ |
| 34 | +# -v "${PWD}/tmp/internal-sysroot:/tmp/sysroot:z,U" \ |
| 35 | +# --secret=id=key,src=secureboot/db.key \ |
| 36 | +# --secret=id=cert,src=secureboot/db.crt \ |
| 37 | + |
| 38 | +# See: https://wiki.archlinux.org/title/Unified_Extensible_Firmware_Interface/Secure_Boot |
| 39 | +# Alternative to generate keys for testing: `sbctl create-keys` |
| 40 | +# if [[ ! -d "secureboot" ]]; then |
| 41 | +# echo "Generating test Secure Boot keys" |
| 42 | +# mkdir secureboot |
| 43 | +# pushd secureboot > /dev/null |
| 44 | +# uuidgen --random > GUID.txt |
| 45 | +# openssl req -newkey rsa:4096 -nodes -keyout PK.key -new -x509 -sha256 -days 3650 -subj "/CN=Test Platform Key/" -out PK.crt |
| 46 | +# openssl x509 -outform DER -in PK.crt -out PK.cer |
| 47 | +# openssl req -newkey rsa:4096 -nodes -keyout KEK.key -new -x509 -sha256 -days 3650 -subj "/CN=Test Key Exchange Key/" -out KEK.crt |
| 48 | +# openssl x509 -outform DER -in KEK.crt -out KEK.cer |
| 49 | +# openssl req -newkey rsa:4096 -nodes -keyout db.key -new -x509 -sha256 -days 3650 -subj "/CN=Test Signature Database key/" -out db.crt |
| 50 | +# openssl x509 -outform DER -in db.crt -out db.cer |
| 51 | +# popd > /dev/null |
| 52 | +# fi |
0 commit comments