kernel: Fix DEBUG builds and add default debug targets/images

Building debug kernels (with additional run time checks and debugging)
was broken a few commits back. This adds back support for building debug
kernels.

In addition, it builds and uploads debug kernels for selected kernel
series (4.9.x LTS and latest stable). The tag for these kernels has
a "_dbg" suffix.

Update documentation.

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
Rolf Neugebauer 2017-05-02 12:04:20 +01:00
parent 5ab5f31e14
commit f44421042e
4 changed files with 32 additions and 24 deletions

View File

@ -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

View File

@ -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

View File

@ -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))

View File

@ -1,6 +1,6 @@
## MOBY DEBUG OPTIONS ##
## LinuxKit DEBUG OPTIONS ##
CONFIG_LOCKDEP=y
CONFIG_FRAME_POINTER=y