diff --git a/kernel/Dockerfile b/kernel/Dockerfile index 1916e29a1..392fcdea6 100644 --- a/kernel/Dockerfile +++ b/kernel/Dockerfile @@ -1,4 +1,4 @@ -FROM linuxkit/alpine:87a0cd10449d72f374f950004467737dbf440630 AS kernel-build +FROM linuxkit/alpine:a120ad6aead3fe583eaa20e9b75a05ac1b3487da AS kernel-build RUN apk add \ argp-standalone \ automake \ diff --git a/kernel/Dockerfile.kconfig b/kernel/Dockerfile.kconfig new file mode 100644 index 000000000..b9721483a --- /dev/null +++ b/kernel/Dockerfile.kconfig @@ -0,0 +1,36 @@ +FROM linuxkit/alpine:a120ad6aead3fe583eaa20e9b75a05ac1b3487da AS kernel-build +RUN apk add \ + argp-standalone \ + build-base \ + curl \ + diffutils \ + ncurses-dev \ + tar \ + xz + +ARG KERNEL_VERSIONS + +# There is no simple way to copy directories with wild cards as needed +# for patches-*. Copy the entire dir instead. +COPY / / + +# Unpack kernels (download if not present) +RUN for VERSION in ${KERNEL_VERSIONS}; do \ + 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} && \ + tar xf sources/linux-${VERSION}.tar.xz; \ + done + +# Apply patches to all kernels and move config files into place +RUN for VERSION in ${KERNEL_VERSIONS}; do \ + SERIES=${VERSION%.*}.x && \ + cd /linux-${VERSION} && \ + for patch in /patches-${SERIES}/*.patch; do \ + echo "Applying $patch" && \ + patch -p1 < "$patch"; \ + done && \ + mv /kernel_config-${SERIES}-x86_64 arch/x86/configs/x86_64_defconfig && \ + mv /kernel_config-${SERIES}-aarch64 arch/arm64/configs/defconfig; \ + done + +ENTRYPOINT ["/bin/sh"] diff --git a/kernel/Makefile b/kernel/Makefile index ea8ff46f4..9a57ffefb 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -49,6 +49,8 @@ COMMIT_LABEL=--label org.opencontainers.image.revision=$(REPO_COMMIT) endif LABELS=$(REPO_LABEL) $(COMMIT_LABEL) +KERNEL_VERSIONS= + .PHONY: check tag push # Targets: # fetch: Downloads the kernel sources into ./sources @@ -76,6 +78,7 @@ define kernel ifeq ($(3),) sources/linux-$(1).tar.xz: Makefile | sources curl -fsSLo sources/linux-$(1).tar.xz https://www.kernel.org/pub/linux/kernel/v4.x/linux-$(1).tar.xz +KERNEL_VERSIONS+=$(1) endif build_$(2)$(3): Dockerfile Makefile $(wildcard patches-$(2)/*) $(wildcard kernel_config-$(2)*) kernel_config.debug | sources @@ -133,3 +136,9 @@ endef $(eval $(call kernel,4.9.44,4.9.x)) $(eval $(call kernel,4.9.44,4.9.x,_dbg)) $(eval $(call kernel,4.4.83,4.4.x)) + +# Target for kernel config +kconfig: | sources + docker build --no-cache -f Dockerfile.kconfig \ + --build-arg KERNEL_VERSIONS="$(KERNEL_VERSIONS)" \ + -t linuxkit/kconfig .