FROM linuxkit/alpine:d307c8a386fa3f32cddda9409b9687e191cdd6f1 AS kernel-build RUN apk add \ argp-standalone \ build-base \ curl \ diffutils \ libarchive-tools \ ncurses-dev \ xz ARG KERNEL_VERSIONS COPY / / # Unpack kernels (download if not present) RUN set -e && \ for VERSION in ${KERNEL_VERSIONS}; do \ echo "Downloading/Unpacking $VERSION" && \ KERNEL_SOURCE=https://www.kernel.org/pub/linux/kernel/v4.x/linux-${VERSION}.tar.xz && \ [ -f sources/linux-${VERSION}.tar.xz ] || curl -fSLo sources/linux-${VERSION}.tar.xz ${KERNEL_SOURCE} && \ bsdtar xf sources/linux-${VERSION}.tar.xz; \ done # Apply patches to all kernels and move config files into place RUN set -e && \ for VERSION in ${KERNEL_VERSIONS}; do \ SERIES=${VERSION%.*}.x && \ echo "Patching $VERSION $SERIES" && \ cd /linux-${VERSION} && \ if [ -d /patches-${SERIES} ]; then \ for patch in /patches-${SERIES}/*.patch; do \ echo "Applying $patch" && \ patch -p1 < "$patch"; \ done; \ fi && \ mv /config-${SERIES}-x86_64 arch/x86/configs/x86_64_defconfig && \ mv /config-${SERIES}-aarch64 arch/arm64/configs/defconfig; \ done ENTRYPOINT ["/bin/sh"]