From 27e8c1145c2aed6aa20d88ff384e9af27464b8f7 Mon Sep 17 00:00:00 2001 From: Theo Koulouris Date: Thu, 31 Aug 2017 14:31:41 +0100 Subject: [PATCH] Streamlined how Makefile handles okernel versions Signed-off-by: Theo Koulouris --- projects/okernel/Makefile | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/projects/okernel/Makefile b/projects/okernel/Makefile index cd4286de0..21c12cec2 100644 --- a/projects/okernel/Makefile +++ b/projects/okernel/Makefile @@ -1,29 +1,32 @@ -DEBUG ?= 0 - all: image tag -# 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. +IMAGE=okernel +OKERNEL_REPO=https://github.com/linux-okernel/linux-okernel +DEPS=Dockerfile.okernel Makefile kernel_config.okernel Dockerfile.kvmod + +DEBUG ?= 0 ifdef KERNEL ifneq ($(KERNEL),latest) +ifneq (,$(findstring ok-,$(KERNEL))) KERNEL_VERSION=$(KERNEL) -IMAGE_VERSION=$(KERNEL_VERSION)-0 +IMAGE_VERSION=$(KERNEL_VERSION) +LATEST=0 else -KERNEL_VERSION=linux-okernel -IMAGE_VERSION=latest +$(error Error, valid okernel kernel versions begin with "ok-") endif else 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 -IMAGE=okernel -DEPS=Dockerfile.okernel Makefile kernel_config.okernel Dockerfile.kvmod + ifdef HTTP_PROXY PROXY_ARG = --build-arg HTTP_PROXY=$(HTTP_PROXY) @@ -50,7 +53,10 @@ push: image rm -f hash 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 rm -f hash