From 7185191736a53773a9dde5ffde7a41af083910db Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Tue, 14 Mar 2017 10:54:01 +0000 Subject: [PATCH] kernel: Add the kernel version to the hub image A given image is pushed to hub twice, once as kernel:..x and once as kernel:..-. The latter is used to decide if a new kernel image is pushed to hub. Most users should use the former to pick up the latest kernel. Signed-off-by: Rolf Neugebauer --- kernel/Makefile | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/kernel/Makefile b/kernel/Makefile index 97d401588..ae500b1a5 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -2,13 +2,34 @@ DEBUG ?= 0 all: bzImage push +# We push the image to hub twice, once with the full kernel version of +# "mobylinux/kernel:..-", +# where "" is a monotonically increasing config number, and as +# "mobylinux/kernel:..x". This version +# number is stored in IMAGE_VERSION. +# +# We expect most users to us the "..x" +# variant as this simply is the latest version of a given major kernel +# version. This version number is stored in IMAGE_MAJOR_VERSION. +# +# For IMAGE_VERSION, the "" must be increased whenever +# the kernel config or the patches change. We don't expect this to +# happen very often as the minor version number gets update quite +# frequently. +# +# IMAGE_VERSION is used to determine if a new image should be pushed to hub. ifdef LTS4.4 KERNEL_VERSION=4.4.53 +IMAGE_VERSION=$(KERNEL_VERSION)-0 +IMAGE_MAJOR_VERSION=4.4.x DEPS=Dockerfile.4.4 Makefile kernel_config kernel_config.debug kernel_config.4.4 patches-4.4 else KERNEL_VERSION=4.9.14 +IMAGE_VERSION=$(KERNEL_VERSION)-0 +IMAGE_MAJOR_VERSION=4.9.x DEPS=Dockerfile Makefile kernel_config kernel_config.debug patches-4.9 endif + kernel.tag: $(DEPS) BUILD=$$( tar cf - $^ | docker build -f $< --build-arg DEBUG=$(DEBUG) --build-arg KERNEL_VERSION=$(KERNEL_VERSION) -q - ) && [ -n "$$BUILD" ] && echo "Built $$BUILD" && echo "$$BUILD" > $@ @@ -19,10 +40,9 @@ bzImage: kernel.tag cp x86_64/kernel-modules.tar kernel.tar cp x86_64/bzImage $@ -.PHONY: push tag +.PHONY: image push tag MEDIA_TOYBOX=mobylinux/toybox-media:0a26fe5f574e444849983f9c4148ef74b3804d55@sha256:5ac38f77b66deb194c9016591b9b096e81fcdc9f7c3e6d01566294a6b4b4ebd2 -SHASUM=alpine:3.5 BASE="$MEDIA_TOYBOX" IMAGE=kernel @@ -32,25 +52,26 @@ default: push Dockerfile.media: printf "FROM $(MEDIA_TOYBOX)\nADD . /\n" > $@ -hash: Dockerfile.media bzImage kernel.tar $(DEPS) +image: Dockerfile.media bzImage kernel.tar $(DEPS) tar cf - $^ | docker build --no-cache -t $(IMAGE):build -f Dockerfile.media - - tar cf - $^ | DOCKER_CONTENT_TRUST=1 docker run --rm -i $(SHASUM) sha1sum | sed 's/ .*//' > $@ -push: hash - docker pull mobylinux/$(IMAGE):$(shell cat hash) || \ - (docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash) && \ - docker push mobylinux/$(IMAGE):$(shell cat hash)) +push: image + docker pull mobylinux/$(IMAGE):$(IMAGE_VERSION) || \ + (docker tag $(IMAGE):build mobylinux/$(IMAGE):$(IMAGE_VERSION) && \ + docker push mobylinux/$(IMAGE):$(IMAGE_VERSION) && \ + docker tag $(IMAGE):build mobylinux/$(IMAGE):$(IMAGE_MAJOR_VERSION) && \ + docker push mobylinux/$(IMAGE):$(IMAGE_MAJOR_VERSION)) docker rmi $(IMAGE):build rm -f hash -tag: hash - docker pull mobylinux/$(IMAGE):$(shell cat hash) || \ - docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash) +tag: image + (docker tag $(IMAGE):build mobylinux/$(IMAGE):$(IMAGE_VERSION) && \ + docker tag $(IMAGE):build mobylinux/$(IMAGE):$(IMAGE_MAJOR_VERSION)) docker rmi $(IMAGE):build rm -f hash .PHONY: clean clean: - rm -rf x86_64 lib usr sbin kernel.tag hash Dockerfile.media bzImage kernel.tar + rm -rf x86_64 lib usr sbin kernel.tag Dockerfile.media bzImage kernel.tar .DELETE_ON_ERROR: