1 ##############################################################################
2 # Copyright (c) 2019 AT&T, ENEA AB, Nokia and others #
4 # Licensed under the Apache License, Version 2.0 (the "License"); #
5 # you maynot use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
8 # http://www.apache.org/licenses/LICENSE-2.0 #
10 # Unless required by applicable law or agreed to in writing, software #
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT #
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
13 # See the License for the specific language governing permissions and #
14 # limitations under the License. #
15 ##############################################################################
17 # declare the variables
20 TAG_PRE ?= $(notdir $(CURDIR))
22 DOCKERFILE ?= Dockerfile
24 MTOOL ?= $(dir $(realpath $(lastword $(MAKEFILE_LIST))))/manifest-tool
26 # git submodule & patch locations for upstream patching before build
27 GIT_ROOT := $(shell git rev-parse --show-toplevel)
28 GIT_DIR := $(shell git rev-parse --git-dir)
29 PATCH_DIR := $(shell pwd)/patches
30 AKRAINO_TAG := akraino-validation
32 PATCHES = $(shell find $(PATCH_DIR) $(PATCH_DIR)/$$(uname -m) \
33 -maxdepth 1 -name '*.patch' 2> /dev/null)
35 export GIT_COMMITTER_NAME?=Akraino Validation
36 export GIT_COMMITTER_EMAIL?=validation@akraino.org
38 # get the architecture of the host
40 ifeq ($(shell uname -m), aarch64)
45 wget https://github.com/estesp/manifest-tool/releases/download/v0.9.0/manifest-tool-linux-$(HOST_ARCH) -O $@
52 -t $(REGISTRY)/$(NAME):$(TAG_PRE)-$(HOST_ARCH)-$(TAG_VER) \
58 docker push $(REGISTRY)/$(NAME):$(TAG_PRE)-$(HOST_ARCH)-$(TAG_VER)
60 .PHONY: .push_manifest
61 .push_manifest: $(MTOOL)
62 $(MTOOL) push from-args \
64 --platforms linux/amd64,linux/arm64 \
65 --template $(REGISTRY)/$(NAME):$(TAG_PRE)-ARCH-$(TAG_VER) \
66 --target $(REGISTRY)/$(NAME):$(TAG_PRE)-$(TAG_VER)
69 cd $(GIT_ROOT) && git submodule update --init 2>/dev/null; \
72 .submodules_patched: .submodules_init $(PATCHES)
73 $(MAKE) .submodules_clean
74 @cd $(GIT_ROOT) && git submodule -q foreach ' \
75 if [ $$name = $$(basename $(TAG_PRE)) ] && [ -n "$(PATCHES)" ]; then \
76 git tag $(AKRAINO_TAG)-upstream && \
77 git checkout -q -b akraino-validation && \
78 echo "`tput setaf 2`-- patching $$name`tput sgr0`";\
79 git am -3 --ignore-whitespace --patch-format=mbox \
80 --committer-date-is-author-date $(PATCHES) && \
81 git tag $(AKRAINO_TAG) || exit 1; \
85 .PHONY: .submodules_clean
87 @cd $(GIT_ROOT) && git submodule -q foreach ' \
88 git am -q --abort > /dev/null 2>&1; \
89 git checkout -q -f $(AKRAINO_TAG)-upstream > /dev/null 2>&1; \
90 git branch -q -D akraino-validation > /dev/null 2>&1; \
91 git tag | grep $(AKRAINO_TAG) | xargs git tag -d > /dev/null 2>&1; \
92 git reset -q --hard HEAD; \
94 @rm -f .submodules_patched