diff --git a/docs/kernels.md b/docs/kernels.md index 3caa920f8..5adf7500d 100644 --- a/docs/kernels.md +++ b/docs/kernels.md @@ -15,7 +15,10 @@ image is tagged with the full kernel version plus the hash of the files it was created from (git tree hash of the `./kernel` directory). For convenience, the latest kernel of each stable series is also available under a shorthand tag, e.g. `linuxkit/kernel:4.9.x` -for the latest `4.9` kernel. +for the latest `4.9` kernel. For selected kernels (mostly the LTS +kernels and latest stable kernels) we also compile/push kernels with +additional debugging enabled. The hub images for these kernels have +the `_dbg` suffix in the tag. In addition to the official kernel images, LinuxKit offers the ability to build bootable Linux images with kernels from various diff --git a/kernel/Dockerfile b/kernel/Dockerfile index 47175b551..7cbf93542 100644 --- a/kernel/Dockerfile +++ b/kernel/Dockerfile @@ -2,7 +2,7 @@ FROM linuxkit/kernel-compile:1b396c221af673757703258159ddc8539843b02b@sha256:6b3 ARG KERNEL_VERSION ARG KERNEL_SERIES -ARG DEBUG=0 +ARG DEBUG ENV KERNEL_SOURCE=https://www.kernel.org/pub/linux/kernel/v4.x/linux-${KERNEL_VERSION}.tar.xz @@ -13,7 +13,7 @@ RUN cat linux-${KERNEL_VERSION}.tar.xz | tar --absolute-names -xJ && mv /linux- COPY kernel_config-${KERNEL_SERIES} /linux/arch/x86/configs/x86_64_defconfig COPY kernel_config.debug /linux/debug_config -RUN if [ $DEBUG -ne "0" ]; then \ +RUN if [ -n "${DEBUG}" ]; 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 diff --git a/kernel/Makefile b/kernel/Makefile index 27f529fae..f73c15e67 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -8,8 +8,6 @@ # of the current directory. The build will only rebuild the kernel # image if the git tree hash changed. -# Enable a debug kernel -DEBUG?=0 # Git tree hash of this directory. Override to force build HASH?=$(shell git ls-tree HEAD -- ../$(notdir $(CURDIR)) | awk '{print $$3}') # Name on Hub @@ -28,37 +26,44 @@ sign: # Arguments: # $1: Full kernel version, e.g., 4.9.22 # $2: Kernel "series", e.g., 4.9.x +# $3: Build a debug kernel (used as suffix for image) # This defines targets like: -# tag_4.9.x, push_4.9.x and sign_4.9.x -# and adds them as dependencies to the global targets +# build_4.9.x, push_4.9.x and sign_4.9.x and adds them as dependencies +# to the global targets +# 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 -build_$(2): Dockerfile Makefile $(wildcard patches-$(2)/*) kernel_config-$(2) kernel_config.debug - docker pull linuxkit/$(IMAGE):$(1)-$(HASH) || \ +build_$(2)$(3): Dockerfile Makefile $(wildcard patches-$(2)/*) kernel_config-$(2) kernel_config.debug + docker pull linuxkit/$(IMAGE):$(1)$(3)-$(HASH) || \ docker build \ --build-arg KERNEL_VERSION=$(1) \ --build-arg KERNEL_SERIES=$(2) \ - --no-cache -t linuxkit/$(IMAGE):$(1)-$(HASH) . + --build-arg DEBUG=$(3) \ + --no-cache -t linuxkit/$(IMAGE):$(1)$(3)-$(HASH) . -push_$(2): build_$(2) - docker pull linuxkit/$(IMAGE):$(1)-$(HASH) || \ - (docker push linuxkit/$(IMAGE):$(1)-$(HASH) && \ - docker tag linuxkit/$(IMAGE):$(1)-$(HASH) linuxkit/$(IMAGE):$(2) && \ - docker push linuxkit/$(IMAGE):$(2)) +push_$(2)$(3): build_$(2)$(3) + docker pull linuxkit/$(IMAGE):$(1)$(3)-$(HASH) || \ + (docker push linuxkit/$(IMAGE):$(1)$(3)-$(HASH) && \ + docker tag linuxkit/$(IMAGE):$(1)$(3)-$(HASH) linuxkit/$(IMAGE):$(2)$(3) && \ + docker push linuxkit/$(IMAGE):$(2)$(3)) -sign_$(2): build_$(2) - DOCKER_CONTENT_TRUST=1 docker pull linuxkit/$(IMAGE):$(1)-$(HASH) || \ - (DOCKER_CONTENT_TRUST=1 docker push linuxkit/$(IMAGE):$(1)-$(HASH) && \ - docker tag linuxkit/$(IMAGE):$(1)-$(HASH) linuxkit/$(IMAGE):$(2) && \ - DOCKER_CONTENT_TRUST=1 docker push linuxkit/$(IMAGE):$(2)) +sign_$(2)$(3): build_$(2)$(3) + DOCKER_CONTENT_TRUST=1 docker pull linuxkit/$(IMAGE):$(1)$(3)-$(HASH) || \ + (DOCKER_CONTENT_TRUST=1 docker push linuxkit/$(IMAGE):$(1)$(3)-$(HASH) && \ + docker tag linuxkit/$(IMAGE):$(1)$(3)-$(HASH) linuxkit/$(IMAGE):$(2)$(3) && \ + DOCKER_CONTENT_TRUST=1 docker push linuxkit/$(IMAGE):$(2)$(3)) -build: build_$(2) -push: push_$(2) -sign: sign_$(2) +build: build_$(2)$(3) +push: push_$(2)$(3) +sign: sign_$(2)$(3) endef # # Build Targets +# Debug targets only for latest stable and LTS stable # $(eval $(call kernel,4.10.13,4.10.x)) +$(eval $(call kernel,4.10.13,4.10.x,_dbg)) $(eval $(call kernel,4.9.25,4.9.x)) +$(eval $(call kernel,4.9.25,4.9.x,_dbg)) $(eval $(call kernel,4.4.64,4.4.x)) diff --git a/kernel/kernel_config.debug b/kernel/kernel_config.debug index 17b14daca..00e73d577 100644 --- a/kernel/kernel_config.debug +++ b/kernel/kernel_config.debug @@ -1,6 +1,6 @@ -## MOBY DEBUG OPTIONS ## +## LinuxKit DEBUG OPTIONS ## CONFIG_LOCKDEP=y CONFIG_FRAME_POINTER=y