Skip to content

Commit a4cbd3e

Browse files
Update approach to handling boot resources
Drop the hidden "meta" layer approach where we try to preserve the image without the boot resources and move to a model where we explicitly delete the /boot directory if it exists. This makes creating images a lot cleaner and more natural, shown by the cleanup in the examples. At the same time we also add support for finding resources from the locations that they're present in bootc images: /usr/lib/modules in versioned subdirectories with vmlinuz and initramfs.img. Add some example "simple" writer code that can write the boot resources to a given directory. We deal with the /usr/lib/modules cases by converting them into Type #1 boot entries and writing them as such. Other consumers of this API might want to do other things, such as producing grub entries, etc. Overhaul the cfsctl oci prepare-boot command to use the new stuff. Fixes #35 Fixes #21 Signed-off-by: Allison Karlitskaya <[email protected]>
1 parent 4ba21a2 commit a4cbd3e

18 files changed

+553
-133
lines changed

examples/bls/Containerfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,5 @@ RUN --mount=type=cache,target=/var/cache/libdnf5 <<EOF
1616
systemctl enable systemd-networkd
1717
passwd -d root
1818
mkdir /sysroot
19-
mkdir /composefs-meta
20-
mv /boot /composefs-meta
21-
mkdir /boot
2219
EOF
2320
COPY cfsctl /usr/bin
24-
RUN true # hack to get an extra layer

examples/bls/Containerfile.arch

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,5 @@ RUN <<EOF
2222
systemctl enable systemd-networkd systemd-resolved sshd
2323
passwd -d root
2424
mkdir /sysroot
25-
mkdir /composefs-meta
26-
mv /boot /composefs-meta
27-
mkdir /boot
2825
EOF
2926
COPY cfsctl /usr/bin
30-
RUN true

examples/bls/Containerfile.rawhide

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,5 @@ RUN --mount=type=cache,target=/var/cache/libdnf5 <<EOF
1616
systemctl enable systemd-networkd
1717
passwd -d root
1818
mkdir /sysroot
19-
mkdir /composefs-meta
20-
mv /boot /composefs-meta
21-
mkdir /boot
2219
EOF
2320
COPY cfsctl /usr/bin
24-
RUN true # hack to get an extra layer

examples/bls/Containerfile.rhel9

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,5 @@ RUN --mount=type=cache,target=/var/cache/dnf <<EOF
2323
systemctl enable tmp.mount
2424
passwd -d root
2525
mkdir /sysroot
26-
mkdir /composefs-meta
27-
mv /boot /composefs-meta
28-
mkdir /boot
2926
EOF
3027
COPY cfsctl /usr/bin
31-
RUN true # hack to get an extra layer

examples/bls/Containerfile.ubuntu

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,5 @@ RUN <<EOF
3434
systemctl enable systemd-networkd systemd-resolved
3535
passwd -d root
3636
mkdir /sysroot
37-
mkdir /composefs-meta
38-
mv /boot /composefs-meta
39-
mkdir /boot
4037
EOF
4138
COPY cfsctl /usr/bin
42-
RUN true

examples/bls/build

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,9 @@ podman build \
4949
.
5050

5151
BASE_ID="$(sed s/sha256:// tmp/base.iid)"
52-
${CFSCTL} oci pull containers-storage:${BASE_ID}
53-
BASE_IMAGE_FSVERITY="$(${CFSCTL} oci compute-id --bootable "${BASE_ID}")"
54-
${CFSCTL} oci prepare-boot "${BASE_ID}" --bootdir tmp/efi
5552

56-
OPTIONS="console=ttyS0,115200 composefs=${BASE_IMAGE_FSVERITY} rw"
57-
BLE="$(echo tmp/efi/loader/entries/*.conf)"
58-
test -f "${BLE}"
59-
if grep '^options ' "${BLE}"; then
60-
sed -i "s|^options .*$|\0 ${OPTIONS}|" "${BLE}"
61-
else
62-
echo "options ${OPTIONS}" >> "${BLE}"
63-
fi
64-
sed -i 's@ /boot/@ /@' "${BLE}"
53+
${CFSCTL} oci pull containers-storage:${BASE_ID}
54+
${CFSCTL} oci prepare-boot "${BASE_ID}" --bootdir tmp/efi --cmdline console=ttyS0,115200 --entry-id=example --cmdline rw
6555

6656
../common/install-systemd-boot
6757
../common/make-image "${os}-bls-efi.qcow2"

examples/uki/Containerfile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,5 @@ RUN --mount=type=cache,target=/var/cache/libdnf5 <<EOF
5252
dnf --setopt keepcache=1 install -y kernel btrfs-progs systemd-boot-unsigned systemd-ukify
5353
EOF
5454

55-
# This could (better?) be done from cfsctl...
5655
FROM base AS bootable
57-
COPY --from=kernel /boot /composefs-meta/boot
58-
# https://github.com/containers/buildah/issues/5950
59-
RUN --mount=type=tmpfs,target=/run \
60-
rm -rf /composefs-meta
56+
COPY --from=kernel /boot /boot

examples/uki/Containerfile.arch

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,5 @@ RUN <<EOF
3131
mkinitcpio -p linux
3232
EOF
3333

34-
# This could (better?) be done from cfsctl...
3534
FROM base AS bootable
36-
COPY --from=kernel /boot /composefs-meta/boot
37-
# https://github.com/containers/buildah/issues/5950
38-
RUN --mount=type=tmpfs,target=/run \
39-
rm -rf /composefs-meta
35+
COPY --from=kernel /boot /boot

examples/uki/build

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ ${PODMAN_BUILD} \
5454

5555
FINAL_ID="$(sed s/sha256:// tmp/final.iid)"
5656
${CFSCTL} oci pull containers-storage:"${FINAL_ID}"
57-
FINAL_IMAGE_FSVERITY="$(${CFSCTL} oci compute-id --bootable "${FINAL_ID}")"
58-
59-
## IMPORTANT: the filesystems of the base and final images are identical
60-
test "${BASE_IMAGE_FSVERITY}" = "${FINAL_IMAGE_FSVERITY}"
6157
${CFSCTL} oci prepare-boot "${FINAL_ID}" --bootdir tmp/efi
6258

6359
../common/install-systemd-boot

examples/unified-secureboot/Containerfile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,5 @@ RUN --mount=type=cache,target=/var/cache/libdnf5 \
4444
dnf --setopt keepcache=1 install -y kernel btrfs-progs systemd-boot-unsigned systemd-ukify sbsigntools
4545
EOF
4646

47-
# This could (better?) be done from cfsctl...
4847
FROM base AS bootable
49-
COPY --from=kernel /boot /composefs-meta/boot
50-
# https://github.com/containers/buildah/issues/5950
51-
RUN --mount=type=tmpfs,target=/run \
52-
rm -rf /composefs-meta
48+
COPY --from=kernel /boot /boot

0 commit comments

Comments
 (0)