mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-08-11 03:21:56 +00:00
collapse kernel build back into one file
Signed-off-by: Tycho Andersen <tycho@docker.com>
This commit is contained in:
parent
9cd2f434cf
commit
1c10661069
@ -1,10 +1,32 @@
|
|||||||
ARG source=nosuchimage
|
FROM linuxkit/kernel-compile:1b396c221af673757703258159ddc8539843b02b@sha256:6b32d205bfc6407568324337b707d195d027328dbfec554428ea93e7b0a8299b AS kernel-build
|
||||||
FROM ${source} AS kernel-build
|
|
||||||
|
|
||||||
ARG KERNEL_VERSION
|
ARG KERNEL_VERSION
|
||||||
ARG KERNEL_SERIES
|
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
|
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
|
# Kernel
|
||||||
RUN make -j "$(getconf _NPROCESSORS_ONLN)" KCFLAGS="-fno-pie" && \
|
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 -) && \
|
tar cf - -T - | (cd $dir; tar xf -) && \
|
||||||
( cd /tmp && tar cf /out/kernel-dev.tar usr/src )
|
( 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
|
FROM linuxkit/toybox-media:eee3dd4d72cd784801e95b1781e6c4f9d8a5e5eb@sha256:7f940e687164ee2676e11c61705c79f7dd2d144ee87ad17a494848a7045f5f53
|
||||||
ENTRYPOINT []
|
ENTRYPOINT []
|
||||||
CMD []
|
CMD []
|
@ -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}
|
|
@ -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
|
|
@ -12,6 +12,7 @@
|
|||||||
HASH?=$(shell git ls-tree HEAD -- ../$(notdir $(CURDIR)) | awk '{print $$3}')
|
HASH?=$(shell git ls-tree HEAD -- ../$(notdir $(CURDIR)) | awk '{print $$3}')
|
||||||
# Name on Hub
|
# Name on Hub
|
||||||
IMAGE:=kernel
|
IMAGE:=kernel
|
||||||
|
ARCH?=$(shell if [ "$$(arch)" = "x86_64" ]]; then echo x86; else $$(arch); fi)
|
||||||
|
|
||||||
.PHONY: check tag push sign
|
.PHONY: check tag push sign
|
||||||
# Targets:
|
# Targets:
|
||||||
@ -33,32 +34,13 @@ sign:
|
|||||||
# Set $3 to "_dbg", to build debug kernels. This defines targets like
|
# 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.
|
# build_4.9.x_dbg and adds "_dbg" to the hub image name.
|
||||||
define kernel
|
define kernel
|
||||||
.PHONY: source_$(2)$(3)
|
build_$(2)$(3): Dockerfile Makefile $(wildcard patches-$(2)/*) $(wildcard kernel_config.$(2)*) kernel_config.base kernel_config.$(ARCH)
|
||||||
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)
|
|
||||||
docker pull linuxkit/$(IMAGE):$(1)$(3)-$(HASH) || \
|
docker pull linuxkit/$(IMAGE):$(1)$(3)-$(HASH) || \
|
||||||
docker build -f Dockerfile.build \
|
docker build \
|
||||||
--build-arg KERNEL_VERSION=$(1) \
|
--build-arg KERNEL_VERSION=$(1) \
|
||||||
--build-arg KERNEL_SERIES=$(2) \
|
--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) .
|
--no-cache -t linuxkit/$(IMAGE):$(1)$(3)-$(HASH) .
|
||||||
|
|
||||||
push_$(2)$(3): build_$(2)$(3)
|
push_$(2)$(3): build_$(2)$(3)
|
||||||
|
Loading…
Reference in New Issue
Block a user