@@ -61,38 +61,40 @@ WORKDIR /build
6161# -----------------------------------------------------------------------------
6262FROM builder-base AS source-downloader
6363
64- ARG LINUX_VERSION
65- ARG BUSYBOX_VERSION
66- ARG SYSLINUX_VERSION
64+ ARG LINUX_VERSION=master
65+ ARG BUSYBOX_VERSION=master
66+ ARG SYSLINUX_VERSION=6.04-pre1
6767
6868# Create directory structure
69- RUN mkdir -p /build/{initramfs,myiso/isolinux,sources}
69+ RUN mkdir -p /build/initramfs && \
70+ mkdir -p /build/myiso/isolinux && \
71+ mkdir -p /build/sources
7072
7173# Download Linux kernel source
74+ WORKDIR /build/sources
7275RUN --mount=type=cache,target=/build/cache \
73- cd /build/sources && \
7476 if [ ! -f /build/cache/linux/.git/config ]; then \
75- git clone --depth 1 --branch ${LINUX_VERSION} \
77+ git clone --depth 1 \
7678 https://github.com/torvalds/linux.git linux && \
77- cp -r linux /build/cache/; \
79+ cp -r linux /build/cache/linux ; \
7880 else \
79- cp -r /build/cache/linux . ; \
81+ cp -r /build/cache/linux linux ; \
8082 fi
8183
8284# Download BusyBox source
85+ WORKDIR /build/sources
8386RUN --mount=type=cache,target=/build/cache \
84- cd /build/sources && \
8587 if [ ! -f /build/cache/busybox/.git/config ]; then \
86- git clone --depth 1 --branch ${BUSYBOX_VERSION} \
88+ git clone --depth 1 \
8789 https://git.busybox.net/busybox busybox && \
88- cp -r busybox /build/cache/; \
90+ cp -r busybox /build/cache/busybox ; \
8991 else \
90- cp -r /build/cache/busybox . ; \
92+ cp -r /build/cache/busybox busybox ; \
9193 fi
9294
9395# Download and extract Syslinux
94- RUN cd /build/sources && \
95- curl -fsSL -o syslinux.tar.gz \
96+ WORKDIR /build/sources
97+ RUN curl -fsSL -o syslinux.tar.gz \
9698 "https://mirrors.edge.kernel.org/pub/linux/utils/boot/syslinux/Testing/${SYSLINUX_VERSION}/syslinux-${SYSLINUX_VERSION}.tar.gz" && \
9799 tar xzf syslinux.tar.gz && \
98100 rm syslinux.tar.gz && \
@@ -115,7 +117,7 @@ COPY linux.config /build/linux/.config
115117WORKDIR /build/linux
116118RUN make olddefconfig && \
117119 make -j"${BUILD_JOBS:-$(nproc)}" && \
118- strip --strip-debug arch/x86/boot/bzImage 2>/dev/null || true
120+ ( strip --strip-debug arch/x86/boot/bzImage 2>/dev/null || true)
119121
120122# -----------------------------------------------------------------------------
121123# Stage 4: Build BusyBox
@@ -151,6 +153,7 @@ RUN chmod +x /build/initramfs/init
151153
152154# Create initramfs archive
153155WORKDIR /build/initramfs
156+ SHELL ["/bin/bash" , "-o" , "pipefail" , "-c" ]
154157RUN find . -print0 | cpio --null --create --format=newc | gzip -9 > /build/initramfs.cpio.gz
155158
156159# -----------------------------------------------------------------------------
@@ -168,6 +171,7 @@ COPY --from=kernel-builder /build/linux/arch/x86/boot/bzImage /build/myiso/bzIma
168171COPY --from=initramfs-builder /build/initramfs.cpio.gz /build/myiso/initramfs
169172
170173# Copy syslinux bootloader files
174+ WORKDIR /build
171175RUN cp /build/syslinux/bios/core/isolinux.bin /build/myiso/isolinux/ && \
172176 cp /build/syslinux/bios/com32/elflink/ldlinux/ldlinux.c32 /build/myiso/isolinux/
173177
0 commit comments