From 1c10661069292705dce192229c628b769b560f2e Mon Sep 17 00:00:00 2001 From: Tycho Andersen Date: Tue, 9 May 2017 11:13:32 -0600 Subject: [PATCH] collapse kernel build back into one file Signed-off-by: Tycho Andersen --- .../{Dockerfile.build => Dockerfile} | 29 +++++++++++++++---- projects/kernel-config/Dockerfile.config | 12 -------- projects/kernel-config/Dockerfile.source | 21 -------------- projects/kernel-config/Makefile | 28 ++++-------------- 4 files changed, 29 insertions(+), 61 deletions(-) rename projects/kernel-config/{Dockerfile.build => Dockerfile} (68%) delete mode 100644 projects/kernel-config/Dockerfile.config delete mode 100644 projects/kernel-config/Dockerfile.source diff --git a/projects/kernel-config/Dockerfile.build b/projects/kernel-config/Dockerfile similarity index 68% rename from projects/kernel-config/Dockerfile.build rename to projects/kernel-config/Dockerfile index 226d609ab..067c2c0f5 100644 --- a/projects/kernel-config/Dockerfile.build +++ b/projects/kernel-config/Dockerfile @@ -1,10 +1,32 @@ -ARG source=nosuchimage -FROM ${source} AS kernel-build +FROM linuxkit/kernel-compile:1b396c221af673757703258159ddc8539843b02b@sha256:6b32d205bfc6407568324337b707d195d027328dbfec554428ea93e7b0a8299b AS kernel-build ARG KERNEL_VERSION ARG KERNEL_SERIES +ARG ARCH +ARG DEBUG +ENV KERNEL_SOURCE=https://www.kernel.org/pub/linux/kernel/v4.x/linux-${KERNEL_VERSION}.tar.xz + +RUN curl -fsSL -o linux-${KERNEL_VERSION}.tar.xz ${KERNEL_SOURCE} + +RUN cat linux-${KERNEL_VERSION}.tar.xz | tar --absolute-names -xJ && mv /linux-${KERNEL_VERSION} /linux + +RUN mkdir /config +COPY kernel_config.* /config/ +COPY makeconfig.sh /config + +# Apply local patches +COPY patches-${KERNEL_SERIES} /patches WORKDIR /linux +RUN set -e && for patch in /patches/*.patch; do \ + echo "Applying $patch"; \ + patch -p1 < "$patch"; \ + done + +RUN /config/makeconfig.sh ${ARCH} ${KERNEL_SERIES} + +RUN mkdir /out +RUN printf "KERNEL_SOURCE=${KERNEL_SOURCE}\n" > /out/kernel-source-info # Kernel RUN make -j "$(getconf _NPROCESSORS_ONLN)" KCFLAGS="-fno-pie" && \ @@ -38,9 +60,6 @@ RUN DVER=$(basename $(find /tmp/kernel-modules/lib/modules/ -mindepth 1 -maxdept tar cf - -T - | (cd $dir; tar xf -) && \ ( cd /tmp && tar cf /out/kernel-dev.tar usr/src ) -RUN printf "KERNEL_SOURCE=${KERNEL_SOURCE}\n" > /out/kernel-source-info - - FROM linuxkit/toybox-media:eee3dd4d72cd784801e95b1781e6c4f9d8a5e5eb@sha256:7f940e687164ee2676e11c61705c79f7dd2d144ee87ad17a494848a7045f5f53 ENTRYPOINT [] CMD [] diff --git a/projects/kernel-config/Dockerfile.config b/projects/kernel-config/Dockerfile.config deleted file mode 100644 index 0150aa483..000000000 --- a/projects/kernel-config/Dockerfile.config +++ /dev/null @@ -1,12 +0,0 @@ -ARG source=nosuchimage -FROM ${source} - -ARG ARCH -ARG KERNEL_SERIES -ARG DEBUG - -RUN mkdir /config -COPY kernel_config.* /config/ -COPY makeconfig.sh /config - -RUN /config/makeconfig.sh ${ARCH} ${KERNEL_SERIES} diff --git a/projects/kernel-config/Dockerfile.source b/projects/kernel-config/Dockerfile.source deleted file mode 100644 index ba512aa62..000000000 --- a/projects/kernel-config/Dockerfile.source +++ /dev/null @@ -1,21 +0,0 @@ -FROM linuxkit/kernel-compile:1b396c221af673757703258159ddc8539843b02b@sha256:6b32d205bfc6407568324337b707d195d027328dbfec554428ea93e7b0a8299b AS kernel-build - -ARG KERNEL_VERSION -ARG KERNEL_SERIES - -ENV KERNEL_SOURCE=https://www.kernel.org/pub/linux/kernel/v4.x/linux-${KERNEL_VERSION}.tar.xz - -RUN curl -fsSL -o linux-${KERNEL_VERSION}.tar.xz ${KERNEL_SOURCE} - -RUN cat linux-${KERNEL_VERSION}.tar.xz | tar --absolute-names -xJ && mv /linux-${KERNEL_VERSION} /linux - -# Apply local patches -COPY patches-${KERNEL_SERIES} /patches -WORKDIR /linux -RUN set -e && for patch in /patches/*.patch; do \ - echo "Applying $patch"; \ - patch -p1 < "$patch"; \ - done - -RUN mkdir /out -RUN printf "KERNEL_SOURCE=${KERNEL_SOURCE}\n" > /out/kernel-source-info diff --git a/projects/kernel-config/Makefile b/projects/kernel-config/Makefile index 0c79571a5..5e666adaf 100644 --- a/projects/kernel-config/Makefile +++ b/projects/kernel-config/Makefile @@ -12,6 +12,7 @@ HASH?=$(shell git ls-tree HEAD -- ../$(notdir $(CURDIR)) | awk '{print $$3}') # Name on Hub IMAGE:=kernel +ARCH?=$(shell if [ "$$(arch)" = "x86_64" ]]; then echo x86; else $$(arch); fi) .PHONY: check tag push sign # Targets: @@ -33,32 +34,13 @@ sign: # Set $3 to "_dbg", to build debug kernels. This defines targets like # build_4.9.x_dbg and adds "_dbg" to the hub image name. define kernel -.PHONY: source_$(2)$(3) -source_$(2)$(3): - @# XXX: intentionally dropping $(3) here, since the source is the same for - @# both debug and non-debug builds. - docker image inspect linuxkit/$(IMAGE)-source:$(1)$-$(HASH) >/dev/null || \ - docker build -f Dockerfile.source \ - --build-arg KERNEL_VERSION=$(1) \ - --build-arg KERNEL_SERIES=$(2) \ - --no-cache -t linuxkit/$(IMAGE)-source:$(1)$-$(HASH) . - -.PHONY: config_$(2)$(3) -config_$(2)$(3): source_$(2) - docker image inspect linuxkit/$(IMAGE)-config:$(1)$(3)-$(HASH) >/dev/null || \ - docker build -f Dockerfile.config \ - --build-arg KERNEL_SERIES=$(2) \ - --build-arg ARCH=x86 \ - --build-arg DEBUG=$(3) \ - --build-arg source=linuxkit/$(IMAGE)-source:$(1)-$(HASH) \ - --no-cache -t linuxkit/$(IMAGE)-config:$(1)$(3)-$(HASH) . - -build_$(2)$(3): Dockerfile.build Makefile $(wildcard patches-$(2)/*) kernel_config-$(2) kernel_config.debug config_$(2)$(3) +build_$(2)$(3): Dockerfile Makefile $(wildcard patches-$(2)/*) $(wildcard kernel_config.$(2)*) kernel_config.base kernel_config.$(ARCH) docker pull linuxkit/$(IMAGE):$(1)$(3)-$(HASH) || \ - docker build -f Dockerfile.build \ + docker build \ --build-arg KERNEL_VERSION=$(1) \ --build-arg KERNEL_SERIES=$(2) \ - --build-arg source=linuxkit/$(IMAGE)-config:$(1)$(3)-$(HASH) \ + --build-arg ARCH=$(ARCH) \ + --build-arg DEBUG=$(3) \ --no-cache -t linuxkit/$(IMAGE):$(1)$(3)-$(HASH) . push_$(2)$(3): build_$(2)$(3)