Skip to content

Commit a7f95e7

Browse files
grub-cc: Download from fedora-eln
Instead of downloading the rpm from Koji, which would probably be GC'd in the future, use a separate build stage to download the rpm from fedora-eln:latest. Since we don't have a generic grub-cc-efi rpm, we have to match on architecture. Currently only supported for x64 and aarch64 as ppcle64 and s390x don't have an ESP Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1 parent 9d562ef commit a7f95e7

2 files changed

Lines changed: 42 additions & 8 deletions

File tree

Dockerfile

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,32 @@ RUN --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp \
5353
/run/packaging/enable-compose-repos
5454
RUN --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp /usr/libexec/bootc-base-imagectl build-rootfs --manifest=standard /target-rootfs
5555

56+
# Get the latest GrubCC binary
57+
FROM quay.io/fedora/eln:latest AS grub-cc-download
58+
RUN --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp <<EOF
59+
set -eux
60+
61+
# There isn't a generic grub2-efi-cc package that DNF can automatically resolve
62+
case "$(uname -m)" in
63+
x86_64)
64+
dnf download grub2-efi-x64-cc
65+
;;
66+
aarch64)
67+
dnf download grub2-efi-aa64-cc
68+
;;
69+
*)
70+
echo "Unsupported architecture: $(uname -m)" >&2
71+
exit 1
72+
;;
73+
esac
74+
75+
mv ./*.rpm grub-cc.rpm
76+
77+
EOF
78+
5679
FROM scratch as fetch
5780
COPY --from=target-base /target-rootfs/ /
81+
COPY --from=grub-cc-download /grub-cc.rpm /var/grub-cc.rpm
5882
# SKIP_CONFIGS=1 skips LBIs, test kargs, and install configs (for FCOS testing)
5983
ARG SKIP_CONFIGS
6084
ARG boot_type
@@ -91,19 +115,23 @@ RUN --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp \
91115
dnf install -y "${pkgs_to_install[@]}"
92116
fi
93117

118+
# Currently dnf installs grub-cc at /usr/lib/efi/grub2/1:2.12-60.eln156/EFI/eln/cc/grubx64-cc.efi
119+
# which is less than ideal because:
120+
# - the "cc" subdirectory
121+
# - no support for installing grub-cc in bootupd
122+
#
123+
# So we move the binary to /usr/lib/grub-cc/grub-cc.efi so we have a predictale location from which
124+
# we can copy the EFI binary to the ESP
94125
if [[ "$bootloader" == "grub-cc" ]]; then
95-
# We have this until we get grub-cc support in bootupd
96-
arch=$(uname -m)
97-
curl -L -o /var/grub-cc.rpm "https://kojipkgs.fedoraproject.org/packages/grub2/2.12/59.eln156/x86_64/grub2-efi-x64-cc-2.12-59.eln156.${arch}.rpm"
98126
mkdir /var/grub-cc
99127
rpm2archive /var/grub-cc.rpm | tar -xvz -C /var/grub-cc
100128
file=$(find /var/grub-cc -name '*.efi')
101-
mkdir /usr/lib/grub-cc
102-
cp $file /usr/lib/grub-cc
103-
rm -rvf /var/grub-cc
104-
rm -rvf /var/grub-cc.rpm
129+
mkdir -p /usr/lib/grub-cc
130+
cp "$file" /usr/lib/grub-cc/grub-cc.efi
105131
fi
106132

133+
rm -rvf /var/grub-cc
134+
rm -rvf /var/grub-cc.rpm
107135
EOF
108136

109137
# Note we don't do any customization here yet

crates/lib/src/bootc_composefs/boot.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1405,9 +1405,15 @@ pub(crate) async fn setup_composefs_boot(
14051405
.remove_file_optional("grub.cfg")
14061406
.context("Removing grub.cfg")?;
14071407

1408+
let final_name = match std::env::consts::ARCH {
1409+
"x86_64" => "grubx64.efi",
1410+
"aarch64" => "grubaa64-cc.efi",
1411+
arch => anyhow::bail!("GrubCC not supported for: {arch}"),
1412+
};
1413+
14081414
mounted_root
14091415
.dir()
1410-
.copy("usr/lib/grub-cc/grubx64-cc.efi", &efis_dir, "grubx64.efi")
1416+
.copy("usr/lib/grub-cc/grub-cc.efi", &efis_dir, final_name)
14111417
.context("Copying grub-cc binary")?;
14121418
}
14131419
} else {

0 commit comments

Comments
 (0)