From 3fbd615f9a3e2625ddc1176deeea70f8f0e9722b Mon Sep 17 00:00:00 2001 From: Justin Cormack Date: Thu, 12 Jan 2017 09:33:12 +0000 Subject: [PATCH] Add an LTS 4.4 kernel This is the same as aufs variant, but without AUFS patches. Looks like GCP may need this, at least initially. Signed-off-by: Justin Cormack --- .datakitci.json | 2 +- Makefile | 3 ++ alpine/kernel/Dockerfile.4.4 | 57 ++++++++++++++++++++++++++++++++++++ alpine/kernel/Makefile | 14 +++++++++ 4 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 alpine/kernel/Dockerfile.4.4 diff --git a/.datakitci.json b/.datakitci.json index 8039df083..417984745 100644 --- a/.datakitci.json +++ b/.datakitci.json @@ -1 +1 @@ -{"variants":["aufs", "aufs4.4"]} +{"variants":["aufs", "aufs4.4", "lts4.4"]} diff --git a/Makefile b/Makefile index 52ed4e6cf..0ac349dc3 100644 --- a/Makefile +++ b/Makefile @@ -55,6 +55,9 @@ endif ifdef AUFS4.4 AUFS_PREFIX=aufs4.4- endif +ifdef LTS4.4 +AUFS_PREFIX=lts4.4- +endif MEDIA_IMAGE=mobylinux/media:$(MEDIA_PREFIX)$(AUFS_PREFIX)$(TAG) INITRD_IMAGE=mobylinux/mobylinux:$(MEDIA_PREFIX)$(AUFS_PREFIX)$(TAG) KERNEL_IMAGE=mobylinux/kernel:$(MEDIA_PREFIX)$(AUFS_PREFIX)$(TAG) diff --git a/alpine/kernel/Dockerfile.4.4 b/alpine/kernel/Dockerfile.4.4 new file mode 100644 index 000000000..19cfeefc9 --- /dev/null +++ b/alpine/kernel/Dockerfile.4.4 @@ -0,0 +1,57 @@ +# Tag: b77cfc4ad0033d4366df830ed697afc7bab458a2 +FROM mobylinux/alpine-build-c@sha256:53739ea6042cb0ac39cf6e262012c1c4224206b2c9b719569fe7efa3a381348c + +ARG KERNEL_VERSION=4.4.41 + +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 + +COPY kernel_config /linux/arch/x86/configs/x86_64_defconfig +COPY kernel_config.debug /linux/debug_config +COPY kernel_config.4.4 /linux/kernel_config.4.4 +RUN cat /linux/kernel_config.4.4 >> /linux/arch/x86/configs/x86_64_defconfig + +ARG DEBUG=0 + +RUN if [ $DEBUG -ne "0" ]; then \ + sed -i 's/CONFIG_PANIC_ON_OOPS=y/# CONFIG_PANIC_ON_OOPS is not set/' /linux/arch/x86/configs/x86_64_defconfig; \ + cat /linux/debug_config >> /linux/arch/x86/configs/x86_64_defconfig; \ + fi + +# Apply local patches +COPY patches-4.4 /patches +RUN cd /linux && \ + set -e && for patch in /patches/*.patch; do \ + echo "Applying $patch"; \ + patch -p1 < "$patch"; \ + done + +RUN cd /linux && \ + make defconfig && \ + make oldconfig && \ + make -j "$(getconf _NPROCESSORS_ONLN)" KCFLAGS="-fno-pie" +RUN cd /linux && \ + make INSTALL_MOD_PATH=/tmp/kernel-modules modules_install && \ + ( DVER=$(basename $(find /tmp/kernel-modules/lib/modules/ -mindepth 1 -maxdepth 1)) && \ + cd /tmp/kernel-modules/lib/modules/$DVER && \ + rm build source && \ + ln -s /usr/src/linux-headers-$DVER build ) && \ + mkdir -p /tmp/kernel-headers/usr && \ + make INSTALL_HDR_PATH=/tmp/kernel-headers/usr headers_install && \ + ( cd /tmp/kernel-headers && tar cf /kernel-headers.tar usr ) && \ + ( cd /tmp/kernel-modules && tar cf /kernel-modules.tar lib ) && \ + cp vmlinux arch/x86_64/boot/bzImage / + +RUN DVER=$(basename $(find /tmp/kernel-modules/lib/modules/ -mindepth 1 -maxdepth 1)) && \ + dir=/tmp/usr/src/linux-headers-$DVER && \ + mkdir -p $dir && \ + cp /linux/.config $dir && \ + cd /linux && \ + cp -a include "$dir" && \ + mkdir -p "$dir"/arch/x86 && cp -a arch/x86/include "$dir"/arch/x86/ && \ + ( cd /tmp && tar cf /kernel-dev.tar usr/src ) + +RUN printf "KERNEL_SOURCE=${KERNEL_SOURCE}\n" > /kernel-source-info diff --git a/alpine/kernel/Makefile b/alpine/kernel/Makefile index b83541396..14d5abe21 100644 --- a/alpine/kernel/Makefile +++ b/alpine/kernel/Makefile @@ -35,6 +35,19 @@ x86_64/vmlinuz64: Dockerfile.aufs kernel_config kernel_config.debug kernel_confi tar xf x86_64/kernel-modules.tar endif else +ifdef LTS4.4 +x86_64/vmlinuz64: Dockerfile.4.4 kernel_config kernel_config.debug kernel_config.4.4 patches-4.4 + mkdir -p x86_64 etc lib usr sbin + BUILD=$$( tar cf - $^ | docker build -f Dockerfile.4.4 --build-arg DEBUG=$(DEBUG) -q - ) && [ -n "$$BUILD" ] && echo "Built $$BUILD" && \ + docker run --rm --net=none --log-driver=none $$BUILD cat /kernel-modules.tar > x86_64/kernel-modules.tar && \ + docker run --rm --net=none --log-driver=none $$BUILD cat /kernel-source-info > etc/kernel-source-info && \ + docker run --rm --net=none --log-driver=none $$BUILD cat /vmlinux > x86_64/vmlinux && \ + docker run --rm --net=none --log-driver=none $$BUILD cat /kernel-headers.tar > x86_64/kernel-headers.tar && \ + docker run --rm --net=none --log-driver=none $$BUILD cat /kernel-dev.tar > x86_64/kernel-dev.tar && \ + docker run --rm --net=none --log-driver=none $$BUILD cat /bzImage > $@ && \ + cp -a patches-4.4 etc/kernel-patches && \ + tar xf x86_64/kernel-modules.tar +else x86_64/vmlinuz64: Dockerfile kernel_config kernel_config.debug patches-4.9 mkdir -p x86_64 etc lib usr sbin BUILD=$$( tar cf - $^ | docker build --build-arg DEBUG=$(DEBUG) -q - ) && [ -n "$$BUILD" ] && echo "Built $$BUILD" && \ @@ -47,6 +60,7 @@ x86_64/vmlinuz64: Dockerfile kernel_config kernel_config.debug patches-4.9 cp -a patches-4.9 etc/kernel-patches && \ tar xf x86_64/kernel-modules.tar endif +endif clean: rm -rf x86_64 lib etc usr sbin