stagex/packages/grub/Containerfile
2024-04-11 13:09:20 -07:00

48 lines
1.2 KiB
Docker

FROM scratch as base
ENV VERSION=2.06
ENV SRC_HASH=23b64b4c741569f9426ed2e3d0e6780796fca081bee4c99f62aa3f53ae803f5f
ENV SRC_FILE=grub-${VERSION}.tar.gz
ENV SRC_SITE=https://mirrors.kernel.org/gnu/grub/${SRC_FILE}
FROM base as fetch
ADD --checksum=sha256:${SRC_HASH} ${SRC_SITE} ${SRC_FILE}
FROM fetch as build
COPY --from=stagex/busybox . /
COPY --from=stagex/bison . /
COPY --from=stagex/flex . /
COPY --from=stagex/gcc . /
COPY --from=stagex/binutils . /
COPY --from=stagex/make . /
COPY --from=stagex/musl . /
COPY --from=stagex/python . /
COPY --from=stagex/m4 . /
COPY --from=stagex/linux-headers . /
RUN tar -xf ${SRC_FILE}
WORKDIR grub-${VERSION}
RUN --network=none <<-EOF
set -eux
./configure \
--prefix=/usr
make -j "$(nproc)" CFLAGS="-Wno-error"
EOF
FROM build as install
RUN make DESTDIR=/rootfs install
FROM base as test
COPY --from=install /rootfs/. /
COPY --from=stagex/musl . /
COPY --from=stagex/busybox . /
RUN grub-install --version
RUN /bin/sh <<-EOF
set -eux
GRUB_VERSION=\$(echo | grub-install --version)
if [ "grub-install (GRUB) ${VERSION}" != "\$GRUB_VERSION" ]; then
echo "Expected grub version is \$VERSION, but got \$GRUB_VERSION"
exit 1
fi
EOF
FROM stagex/filesystem as package
COPY --from=install /rootfs/. /