X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=docker%2Fbuild.mk;h=2f7d398b2ea9715a35f9e776e0de2b19627699c7;hb=6b937d0dc0f36596c9bc1ef8766ba7363451458d;hp=dde61fe8650bdac0b3511916a3339e11df04a2fd;hpb=9e3249539861ecb37bb83aea9a9a8d9830e353da;p=validation.git diff --git a/docker/build.mk b/docker/build.mk index dde61fe..2f7d398 100644 --- a/docker/build.mk +++ b/docker/build.mk @@ -14,15 +14,27 @@ # limitations under the License. # ############################################################################## - # declare the variables -REGISTRY ?= # TBD -NAME ?= akraino_validation +REGISTRY ?= akraino +NAME ?= validation TAG_PRE ?= $(notdir $(CURDIR)) TAG_VER ?= latest DOCKERFILE ?= Dockerfile +WORK_DIR ?= $(CURDIR) MTOOL ?= $(dir $(realpath $(lastword $(MAKEFILE_LIST))))/manifest-tool +# git submodule & patch locations for upstream patching before build +GIT_ROOT := $(shell git rev-parse --show-toplevel) +GIT_DIR := $(shell git rev-parse --git-dir) +PATCH_DIR := $(shell pwd)/patches +AKRAINO_TAG := akraino-validation +SHELL = /bin/sh +PATCHES = $(shell find $(PATCH_DIR) $(PATCH_DIR)/$$(uname -m) \ + -maxdepth 1 -name '*.patch' 2> /dev/null) + +export GIT_COMMITTER_NAME?=Akraino Validation +export GIT_COMMITTER_EMAIL?=validation@akraino.org + # get the architecture of the host HOST_ARCH = amd64 ifeq ($(shell uname -m), aarch64) @@ -34,7 +46,8 @@ $(MTOOL): sudo chmod +x $@ .PHONY: .build -.build: +.build:: + cd $(WORK_DIR) && \ docker build \ -t $(REGISTRY)/$(NAME):$(TAG_PRE)-$(HOST_ARCH)-$(TAG_VER) \ -f $(DOCKERFILE) \ @@ -50,3 +63,31 @@ $(MTOOL): --platforms linux/amd64,linux/arm64 \ --template $(REGISTRY)/$(NAME):$(TAG_PRE)-ARCH-$(TAG_VER) \ --target $(REGISTRY)/$(NAME):$(TAG_PRE)-$(TAG_VER) + +.submodules_init: + cd $(GIT_ROOT) && git submodule update --init 2>/dev/null; \ + touch $@ + +.submodules_patched: .submodules_init $(PATCHES) + $(MAKE) .submodules_clean + @cd $(GIT_ROOT) && git submodule -q foreach ' \ + if [ $$name = $$(basename $(TAG_PRE)) ] && [ -n "$(PATCHES)" ]; then \ + git tag $(AKRAINO_TAG)-upstream && \ + git checkout -q -b akraino-validation && \ + echo "`tput setaf 2`-- patching $$name`tput sgr0`";\ + git am -3 --ignore-whitespace --patch-format=mbox \ + --committer-date-is-author-date $(PATCHES) && \ + git tag $(AKRAINO_TAG) || exit 1; \ + fi'; \ + touch $@ + +.PHONY: .submodules_clean +.submodules_clean: + @cd $(GIT_ROOT) && git submodule -q foreach ' \ + git am -q --abort > /dev/null 2>&1; \ + git checkout -q -f $(AKRAINO_TAG)-upstream > /dev/null 2>&1; \ + git branch -q -D akraino-validation > /dev/null 2>&1; \ + git tag | grep $(AKRAINO_TAG) | xargs git tag -d > /dev/null 2>&1; \ + git reset -q --hard HEAD; \ + git clean -xdff' + @rm -f .submodules_patched