mirror of
https://github.com/linuxkit/linuxkit.git
synced 2026-04-04 23:12:54 +00:00
...and add straw man implementations of kernel_config.base and kernel_config.x86 as examples. First, splitting the build: to avoid duplication, we split the build into three parts: a "source" stage, a "config" stage, and a "build" stage. The "source" stage allows us to use a cached image, so we don't have to re-download the kernel source every time. The "config" step applies our patches and generates (and checks) the kernel config. I've left this as a separate step for now so that we can build just an image with a config in it, without having to ^C the build. However there's no real reason it needs to be a separate step, assuming that this kernel config design is acceptable. The third step is the actual kernel build. Then there is kernel config management: the bulk of it occurs in makeconfig.sh, with the idea being that we can specify base, arch, and version specific config options as necessary. The config files themselves are lists of options (both positive and negative). We include the negative options, because we want to explicitly turn off things that are on in the default config (e.g. CONFIG_USELIB), and it seems cleaner to do things this way then to have some sort of negative options list. The options files are sorted with the default behavior of the "sort" command, which ignores comment lines, meaning that negative options and positive options are inline with each other. I don't have a strong opinion on whether or not to group all negative options, or whether this default behavior makes sense, so I just left it. Finally, obviously the .base and .x86 files are incomplete. I mostly selected a few options with interesting dependencies or special issues (CONFIG_PANIC_ON_OOPS) with how we manage things, so as to demo how everything would work. It's not really clear to me that there's a good way to generate e.g. kernel_config.base, without a lot of painstaking work (which I'm happy to do if we agree this is a good approach). Signed-off-by: Tycho Andersen <tycho@docker.com>
90 lines
3.3 KiB
Makefile
90 lines
3.3 KiB
Makefile
# This builds the supported LinuxKit kernels. Kernels are wrapped up
|
|
# in a minimal toybox container, which contains the bzImage, a tar
|
|
# ball with modules and the kernel source.
|
|
#
|
|
# Each kernel is pushed to hub twice, once as
|
|
# linuxkit/kernel:<kernel>.<major>.<minor>-<hash> and once as
|
|
# inuxkit/kernel:<kernel>.<major>.x. The <hash> is the git tree hash
|
|
# of the current directory. The build will only rebuild the kernel
|
|
# image if the git tree hash changed.
|
|
|
|
# Git tree hash of this directory. Override to force build
|
|
HASH?=$(shell git ls-tree HEAD -- ../$(notdir $(CURDIR)) | awk '{print $$3}')
|
|
# Name on Hub
|
|
IMAGE:=kernel
|
|
|
|
.PHONY: check tag push sign
|
|
# Targets:
|
|
# build: builds all kernels
|
|
# push: pushes all tagged kernel images to hub
|
|
# sign: sign and push all kernel images to hub
|
|
build:
|
|
push:
|
|
sign:
|
|
|
|
# A template for defining kernel build
|
|
# 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:
|
|
# 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
|
|
.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)
|
|
docker pull linuxkit/$(IMAGE):$(1)$(3)-$(HASH) || \
|
|
docker build -f Dockerfile.build \
|
|
--build-arg KERNEL_VERSION=$(1) \
|
|
--build-arg KERNEL_SERIES=$(2) \
|
|
--build-arg source=linuxkit/$(IMAGE)-config:$(1)$(3)-$(HASH) \
|
|
--no-cache -t linuxkit/$(IMAGE):$(1)$(3)-$(HASH) .
|
|
|
|
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)$(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)$(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.14,4.10.x))
|
|
$(eval $(call kernel,4.10.14,4.10.x,_dbg))
|
|
$(eval $(call kernel,4.9.26,4.9.x))
|
|
$(eval $(call kernel,4.9.26,4.9.x,_dbg))
|
|
$(eval $(call kernel,4.4.66,4.4.x))
|