Skip to content

Commit 169fadb

Browse files
ci: Test grubcc
Create a new Dockerfile with base "fedora-bootc:44" for testing images with both grub and grub-cc present. Currently we don't have a bootc release that allows us to test with grub-cc, so we only test grub installations. This mainly tests backwards compatibility for the following cases - Only one bootloader present and no "default" in metadata - Two bootloaders present with grub as the "default" Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1 parent d74d8ba commit 169fadb

2 files changed

Lines changed: 138 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,33 @@ env:
1818
CARGO_TERM_COLOR: always
1919

2020
jobs:
21-
c9s-bootc-e2e:
21+
bootc-e2e:
2222
strategy:
2323
matrix:
2424
runner:
2525
- ubuntu-24.04
2626
- ubuntu-24.04-arm
27+
grubcc:
28+
- 0
29+
- 1
2730

2831
runs-on: [ "${{ matrix.runner }}" ]
2932

3033
steps:
34+
- name: Setup env
35+
run: |
36+
IMG_NAME=localhost/bootupd-grubcc-${{ matrix.grubcc }}
37+
echo "IMG_NAME=${IMG_NAME}" >> $GITHUB_ENV
38+
39+
if [[ "${{ matrix.grubcc }}" == "1" ]]; then
40+
# we only have grub-cc in feodra (for now)
41+
OS_ID="fedora"
42+
else
43+
OS_ID="centos"
44+
fi
45+
46+
echo "OS_ID=${OS_ID}" >> $GITHUB_ENV
47+
3148
- name: Get a newer podman for heredoc support (from debian testing)
3249
run: |
3350
set -eux
@@ -51,22 +68,34 @@ jobs:
5168
sudo apt update -y
5269
sudo apt install -y podman
5370
54-
- name: build
55-
run: sudo podman build -t localhost/bootupd:latest -f Dockerfile .
71+
- name: build with grubcc=${{ matrix.grubcc }}
72+
run: |
73+
dockerfile=Dockerfile
74+
build_args=()
75+
76+
if [[ "${{ matrix.grubcc }}" == "1" ]]; then
77+
dockerfile=Dockerfile.grubcc
78+
build_args=(--build-arg "grubcc=${{ matrix.grubcc }}")
79+
fi
80+
81+
sudo podman build "${build_args[@]}" . -t "$IMG_NAME" -f "$dockerfile"
5682
5783
- name: bootupctl status in container
5884
run: |
5985
set -xeuo pipefail
60-
sudo podman run --rm -v $PWD:/run/src -w /run/src --privileged localhost/bootupd:latest tests/tests/bootupctl-status-in-bootc.sh
86+
sudo podman run --rm -v $PWD:/run/src -w /run/src --privileged "$IMG_NAME" tests/tests/bootupctl-status-in-bootc.sh
6187
88+
# Make sure grub stuff works with and without grubcc in the container image
89+
# TODO: Test GrubCC installation with composefs after a bootc release includes
90+
# https://github.com/bootc-dev/bootc/pull/2223
6291
- name: bootc install to disk
6392
run: |
6493
set -xeuo pipefail
6594
sudo truncate -s 10G myimage.raw
6695
sudo podman run --rm --privileged -v .:/target --pid=host --security-opt label=disable \
6796
-v /var/lib/containers:/var/lib/containers \
6897
-v /dev:/dev \
69-
localhost/bootupd:latest bootc install to-disk --skip-fetch-check \
98+
"$IMG_NAME" bootc install to-disk --filesystem ext4 --skip-fetch-check \
7099
--disable-selinux --generic-image --via-loopback /target/myimage.raw
71100
# Verify we installed grub.cfg and shim on the disk
72101
sudo losetup -P -f myimage.raw
@@ -80,7 +109,7 @@ jobs:
80109
# Assume aarch64 for now
81110
shim="shimaa64.efi"
82111
fi
83-
sudo ls /mnt/EFI/centos/{grub.cfg,${shim}}
112+
sudo ls /mnt/EFI/$OS_ID/{grub.cfg,${shim}}
84113
sudo umount /mnt
85114
# check /boot/grub2/grub.cfg permission
86115
root_part=$(sudo sfdisk -l -J "${device}" | jq -r '.partitiontable.partitions[] | select(.name == "root").node')
@@ -99,7 +128,7 @@ jobs:
99128
set -xeuo pipefail
100129
sudo podman run --rm -ti --privileged -v /:/target --pid=host --security-opt label=disable \
101130
-v /dev:/dev -v /var/lib/containers:/var/lib/containers \
102-
localhost/bootupd:latest env BOOTC_BOOTLOADER_DEBUG=1 \
131+
"$IMG_NAME" env BOOTC_BOOTLOADER_DEBUG=1 \
103132
bootc install to-filesystem --skip-fetch-check \
104133
--acknowledge-destructive \
105134
--disable-selinux --replace=alongside /target
@@ -113,4 +142,4 @@ jobs:
113142
- name: bootupctl generate-update-metadata
114143
run: |
115144
set -xeuo pipefail
116-
sudo podman run --rm -v $PWD:/run/src -w /run/src --privileged localhost/bootupd:latest tests/tests/generate-update-metadata.sh
145+
sudo podman run --rm -v $PWD:/run/src -w /run/src --privileged "$IMG_NAME" tests/tests/generate-update-metadata.sh

Dockerfile.grubcc

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Build from the current git into a fedora44 container image.
2+
3+
ARG base=quay.io/fedora/fedora-bootc:44
4+
5+
FROM $base as build
6+
# This installs our package dependencies, and we want to cache it independently of the rest.
7+
# Basically we don't want changing a .rs file to blow out the cache of packages.
8+
RUN <<EORUN
9+
set -xeuo pipefail
10+
dnf -y install cargo git openssl-devel
11+
EORUN
12+
# Now copy the source
13+
COPY . /build
14+
WORKDIR /build
15+
# See https://www.reddit.com/r/rust/comments/126xeyx/exploring_the_problem_of_faster_cargo_docker/
16+
# We aren't using the full recommendations there, just the simple bits.
17+
RUN --mount=type=cache,target=/build/target --mount=type=cache,target=/var/roothome \
18+
make && make install-all DESTDIR=/out
19+
20+
21+
# Get the latest GrubCC binary
22+
FROM quay.io/fedora/eln:latest AS grub-cc-download
23+
RUN --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp <<EOF
24+
set -eux
25+
26+
# There isn't a generic grub2-efi-cc package that DNF can automatically resolve
27+
case "$(uname -m)" in
28+
x86_64)
29+
dnf download grub2-efi-x64-cc
30+
;;
31+
aarch64)
32+
dnf download grub2-efi-aa64-cc
33+
;;
34+
*)
35+
echo "Unsupported architecture: $(uname -m)" >&2
36+
exit 1
37+
;;
38+
esac
39+
40+
mv ./*.rpm grub-cc.rpm
41+
42+
EOF
43+
44+
FROM $base
45+
ARG grubcc
46+
# Clean out the default to ensure we're using our updated content
47+
RUN rpm -e bootupd
48+
COPY --from=build /out/ /
49+
COPY --from=grub-cc-download /grub-cc.rpm /var/grub-cc.rpm
50+
# Install bootc from copr
51+
RUN --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp <<EORUN
52+
set -xeuo pipefail
53+
dnf -y install dnf-plugins-core bootc
54+
dnf clean all
55+
rm -rf /var/log
56+
rm -rf /var/lib
57+
rm -rf /var/cache
58+
rm -rf /run/rhsm
59+
rm -rf /tmp/*
60+
EORUN
61+
62+
RUN --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp <<EOF
63+
64+
set -eux
65+
66+
cleanup() {
67+
# Clean up temporary files
68+
rm -rvf /var/grub-cc*
69+
}
70+
71+
if [[ ${grubcc} != 1 ]]; then
72+
cleanup
73+
exit 0
74+
fi
75+
76+
# Extract and install grub-cc at the correct path
77+
mkdir /var/grub-cc
78+
rpm2archive /var/grub-cc.rpm | tar -xvz -C /var/grub-cc
79+
file=$(find /var/grub-cc -name '*.efi')
80+
81+
# Get the EVR from the RPM filename
82+
evr=$(rpm -qp --qf '%{EPOCH}:%{VERSION}-%{RELEASE}' /var/grub-cc.rpm)
83+
84+
. /etc/os-release
85+
86+
# Create the expected directory structure at /usr/lib/efi/grub-cc/<evr>/EFI/fedora/
87+
mkdir -p "/usr/lib/efi/grub-cc/${evr}/EFI/$ID/"
88+
cp "$file" "/usr/lib/efi/grub-cc/${evr}/EFI/$ID/grubx64.efi"
89+
90+
cleanup
91+
92+
# Regenerate metadata
93+
bootupctl backend generate-update-metadata -vvv
94+
95+
# Set grub as default
96+
bootupctl backend set-default-bootloader grub
97+
98+
EOF
99+
100+
# Sanity check this too
101+
RUN bootc container lint --fatal-warnings

0 commit comments

Comments
 (0)