Streamlined how Makefile handles okernel versions

Signed-off-by: Theo Koulouris <theo.koulouris@hpe.com>
This commit is contained in:
Theo Koulouris 2017-08-31 14:31:41 +01:00
parent c51f89a600
commit 27e8c1145c

View File

@ -1,29 +1,32 @@
DEBUG ?= 0
all: image tag all: image tag
# For IMAGE_VERSION, the "<n>" must be increased whenever IMAGE=okernel
# the kernel config or the patches change. We don't expect this to OKERNEL_REPO=https://github.com/linux-okernel/linux-okernel
# happen very often as the minor version number gets update quite DEPS=Dockerfile.okernel Makefile kernel_config.okernel Dockerfile.kvmod
# frequently.
# DEBUG ?= 0
# IMAGE_VERSION is used to determine if a new image should be pushed to hub.
ifdef KERNEL ifdef KERNEL
ifneq ($(KERNEL),latest) ifneq ($(KERNEL),latest)
ifneq (,$(findstring ok-,$(KERNEL)))
KERNEL_VERSION=$(KERNEL) KERNEL_VERSION=$(KERNEL)
IMAGE_VERSION=$(KERNEL_VERSION)-0 IMAGE_VERSION=$(KERNEL_VERSION)
LATEST=0
else else
KERNEL_VERSION=linux-okernel $(error Error, valid okernel kernel versions begin with "ok-")
IMAGE_VERSION=latest
endif endif
else else
KERNEL_VERSION=linux-okernel KERNEL_VERSION=linux-okernel
IMAGE_VERSION=latest IMAGE_VERSION=$(shell git ls-remote --tags $(OKERNEL_REPO) ok-\* | awk -F"/" '{print $$3}' | tail -1)
LATEST=1
endif
else
KERNEL_VERSION=linux-okernel
IMAGE_VERSION=$(shell git ls-remote --tags $(OKERNEL_REPO) ok-\* | awk -F"/" '{print $$3}' | tail -1)
LATEST=1
endif endif
IMAGE=okernel
DEPS=Dockerfile.okernel Makefile kernel_config.okernel Dockerfile.kvmod
ifdef HTTP_PROXY ifdef HTTP_PROXY
PROXY_ARG = --build-arg HTTP_PROXY=$(HTTP_PROXY) PROXY_ARG = --build-arg HTTP_PROXY=$(HTTP_PROXY)
@ -50,7 +53,10 @@ push: image
rm -f hash rm -f hash
tag: image tag: image
docker tag $(IMAGE):build $(IMAGE):$(IMAGE_VERSION) docker tag $(IMAGE):build $(IMAGE):$(IMAGE_VERSION)
ifeq (1,$(LATEST))
docker tag $(IMAGE):build $(IMAGE):latest
endif
docker rmi $(IMAGE):build docker rmi $(IMAGE):build
rm -f hash rm -f hash