From 0b6f1a72b6195fcca535a3c1db0346fb9fc801cc Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Thu, 15 Jun 2017 10:24:28 -0700 Subject: [PATCH] kernel: Build a perf package for 4.11/4.9 kernels Extract the perf binary from the kernel package and create a new perf package for each kernel. The perf package uses the same tags as the kernel package and only contains the perf binary under /usr/bin. The perf package can be added to the init section or included as a stage in a multi-stage build for other packages. Signed-off-by: Rolf Neugebauer --- kernel/Dockerfile.perf | 10 ++++++++++ kernel/Makefile | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 kernel/Dockerfile.perf diff --git a/kernel/Dockerfile.perf b/kernel/Dockerfile.perf new file mode 100644 index 000000000..5f08e7a97 --- /dev/null +++ b/kernel/Dockerfile.perf @@ -0,0 +1,10 @@ +# This Dockerfile extracts the perf utility from a kernel package and +# places it into a scratch image +ARG IMAGE +FROM ${IMAGE} AS kernel + +FROM scratch +ENTRYPOINT [] +CMD [] +WORKDIR / +COPY --from=kernel /perf /usr/bin/perf diff --git a/kernel/Makefile b/kernel/Makefile index e86dee2b0..98c8ad04f 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,18 +1,23 @@ # 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. +# in a scratch container, which contains the bzImage, a tar +# ball with modules, the kernel sourcs, and in some case, the perf binary. # # Each kernel is pushed to hub twice, once as # linuxkit/kernel:..- and once as # inuxkit/kernel:..x. The is the git tree hash # of the current directory. The build will only rebuild the kernel # image if the git tree hash changed. +# +# For some kernels we also build a separate package containing the perf utility +# which is specific to a given kernel. perf packages are tagged the same way +# kernel packages. # Git tree hash of this directory. Override to force build HASH?=$(shell git ls-tree HEAD -- ../$(notdir $(CURDIR)) | awk '{print $$3}') # Name and Org on Hub ORG?=linuxkit IMAGE:=kernel +IMAGE_PERF:=kernel-perf .PHONY: check tag push sign # Targets: @@ -57,6 +62,31 @@ sign_$(2)$(3): build_$(2)$(3) build: build_$(2)$(3) push: push_$(2)$(3) sign: sign_$(2)$(3) + +ifneq ($(2), 4.4.x) +build_perf_$(2)$(3): build_$(2)$(3) + docker pull $(ORG)/$(IMAGE_PERF):$(1)$(3)-$(HASH) || \ + docker build -f Dockerfile.perf \ + --build-arg IMAGE=$(ORG)/$(IMAGE):$(1)$(3)-$(HASH) \ + --no-cache --network=none -t $(ORG)/$(IMAGE_PERF):$(1)$(3)-$(HASH) . + +push_perf_$(2)$(3): build_perf_$(2)$(3) + docker pull $(ORG)/$(IMAGE_PERF):$(1)$(3)-$(HASH) || \ + (docker push $(ORG)/$(IMAGE_PERF):$(1)$(3)-$(HASH) && \ + docker tag $(ORG)/$(IMAGE_PERF):$(1)$(3)-$(HASH) $(ORG)/$(IMAGE_PERF):$(2)$(3) && \ + docker push $(ORG)/$(IMAGE_PERF):$(2)$(3)) + +sign_perf_$(2)$(3): build_perf_$(2)$(3) + DOCKER_CONTENT_TRUST=1 docker pull $(ORG)/$(IMAGE_PERF):$(1)$(3)-$(HASH) || \ + (DOCKER_CONTENT_TRUST=1 docker push $(ORG)/$(IMAGE_PERF):$(1)$(3)-$(HASH) && \ + docker tag $(ORG)/$(IMAGE_PERF):$(1)$(3)-$(HASH) $(ORG)/$(IMAGE_PERF):$(2)$(3) && \ + DOCKER_CONTENT_TRUST=1 docker push $(ORG)/$(IMAGE_PERF):$(2)$(3)) + +build: build_perf_$(2)$(3) +push: push_perf_$(2)$(3) +sign: sign_perf_$(2)$(3) +endif + endef #