|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -euxo pipefail |
| 4 | + |
| 5 | +bootc_project="/srv/bootc" |
| 6 | +IMAGE="quay.io/fedora/fedora-bootc-bls:42" |
| 7 | + |
| 8 | +if [[ "$PWD" != "$bootc_project/examples" ]]; then |
| 9 | + echo "Run this command from $bootc_project/examples" |
| 10 | + exit 1 |
| 11 | +fi |
| 12 | + |
| 13 | +umount -R ./mnt || true |
| 14 | +losetup --detach-all || true |
| 15 | + |
| 16 | +rm -rf ./test.img |
| 17 | +truncate -s 15G test.img |
| 18 | + |
| 19 | +BOOTFS_UUID="96d15588-3596-4b3c-adca-a2ff7279ea63" |
| 20 | +ROOTFS_UUID="910678ff-f77e-4a7d-8d53-86f2ac47a823" |
| 21 | + |
| 22 | +cat > buf <<EOF |
| 23 | + label: gpt |
| 24 | + label-id: $(uuidgen) |
| 25 | + size=1024MiB, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, name="EFI-SYSTEM" |
| 26 | + size=1024MiB, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, name="boot" |
| 27 | + type=4f68bce3-e8cd-4db1-96e7-fbcaf984b709, name="root" |
| 28 | +EOF |
| 29 | + |
| 30 | +losetup /dev/loop0 test.img |
| 31 | +sfdisk --wipe=always /dev/loop0 < buf |
| 32 | + |
| 33 | +# To make sure kernel updates |
| 34 | +partx --update /dev/loop0 |
| 35 | + |
| 36 | +mkfs.fat /dev/loop0p1 |
| 37 | +mkfs.ext4 /dev/loop0p2 -L boot -U $BOOTFS_UUID |
| 38 | +mkfs.ext4 /dev/loop0p3 -O verity -L root -U $ROOTFS_UUID |
| 39 | + |
| 40 | +mkdir -p ./mnt |
| 41 | + |
| 42 | +mount /dev/loop0p3 ./mnt |
| 43 | +mkdir ./mnt/boot |
| 44 | + |
| 45 | +# --generic-image \ |
| 46 | +podman run --rm --net=host --privileged --pid=host \ |
| 47 | + --security-opt label=type:unconfined_t \ |
| 48 | + --env RUST_LOG=debug \ |
| 49 | + -v /dev:/dev \ |
| 50 | + -v $bootc_project/target/release/bootc:/usr/bin/bootc:ro,Z \ |
| 51 | + -v /var/lib/containers:/var/lib/containers \ |
| 52 | + -v $bootc_project/examples/mnt:/var/mnt \ |
| 53 | + "$IMAGE" \ |
| 54 | + /usr/bin/bootc install to-filesystem \ |
| 55 | + --composefs-native \ |
| 56 | + --bootloader=systemd \ |
| 57 | + --source-imgref "containers-storage:$IMAGE" \ |
| 58 | + /var/mnt |
| 59 | + |
| 60 | +mount /dev/loop0p1 ./mnt |
| 61 | +cp systemd-bootx64.efi ./mnt/EFI/fedora/grubx64.efi |
| 62 | +echo "timeout 5" > ./mnt//loader/loader.conf |
| 63 | +# ignition.firstboot ignition.platform.id=qemu |
| 64 | +sed -i "s;options ;options console=tty0 console=ttyS0,115000n selinux=1 enforcing=0 audit=0 ;" ./mnt/loader/entries/bootc-composefs-1.conf |
| 65 | + |
| 66 | +umount -R ./mnt |
| 67 | +losetup -d /dev/loop0 |
0 commit comments