-
Notifications
You must be signed in to change notification settings - Fork 42
/
common.mk
152 lines (122 loc) · 3.69 KB
/
common.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# SKIP_SQUASH = 0/1
# =================
# If set to '0', images are automatically squashed. '1' disables
# squashing. By default only RHEL containers are squashed.
SHELL := /usr/bin/env bash
ifndef common_dir
common_dir = common
endif
build = $(SHELL) $(common_dir)/build.sh
test = $(SHELL) $(common_dir)/test.sh
shellcheck = $(SHELL) $(common_dir)/run-shellcheck.sh
tag = $(SHELL) $(common_dir)/tag.sh
clean = $(SHELL) $(common_dir)/clean.sh
betka = $(SHELL) $(common_dir)/betka.sh
DG ?= /bin/dg
generator = $(common_dir)/generator.py
# pretty printers
# ---------------
__PROLOG = $(if $(VERBOSE),,@echo " $(1) " $@;)
V_LN = $(call __PROLOG,LN )
V_DG = $(call __PROLOG,DG )
V_DGM = $(call __PROLOG,DGM)
V_CP = $(call __PROLOG,CP )
CDIR = mkdir -p "$$(dirname "$@")" || exit 1 ;
ifeq ($(TARGET),rhel8)
SKIP_SQUASH ?= 1
OS := rhel8
DOCKERFILE ?= Dockerfile.rhel8
else ifeq ($(TARGET),rhel9)
OS := rhel9
DOCKERFILE ?= Dockerfile.rhel9
else ifeq ($(TARGET),fedora)
OS := fedora
DOCKERFILE ?= Dockerfile.fedora
REGISTRY := quay.io/
else ifeq ($(TARGET),c9s)
OS := c9s
DOCKERFILE ?= Dockerfile.c9s
REGISTRY := quay.io/
else
OS := c10s
DOCKERFILE ?= Dockerfile.c10s
REGISTRY := quay.io/
endif
SKIP_SQUASH ?= 1
DOCKER_BUILD_CONTEXT ?= .
SHELLCHECK_FILES ?= .
REGISTRY ?= ""
script_env = \
SKIP_SQUASH=$(SKIP_SQUASH) \
OS=$(OS) \
CLEAN_AFTER=$(CLEAN_AFTER) \
DOCKER_BUILD_CONTEXT=$(DOCKER_BUILD_CONTEXT) \
OPENSHIFT_NAMESPACES="$(OPENSHIFT_NAMESPACES)" \
CUSTOM_REPO="$(CUSTOM_REPO)" \
REGISTRY="$(REGISTRY)"
# TODO: switch to 'build: build-all' once parallel builds are relatively safe
.PHONY: build build-serial build-all
build: build-serial
build-serial:
@$(MAKE) -j1 build-all
build-all: $(VERSIONS)
@for i in $(VERSIONS); do \
test -f $$i/.image-id || continue ; \
echo -n "$(BASE_IMAGE_NAME) $$i => " ; \
cat $$i/.image-id ; \
done
.PHONY: $(VERSIONS)
$(VERSIONS): % : %/root/help.1
VERSION="$@" $(script_env) $(build)
.PHONY: test check
check: test
test: script_env += TEST_MODE=true
# The tests should ideally depend on $IMAGE_ID only, but see PR#19 for more info
# while we need to depend on 'tag' instead of 'build'.
test: tag
VERSIONS="$(VERSIONS)" $(script_env) $(test)
.PHONY: test-openshift-4
test-openshift-4: script_env += TEST_OPENSHIFT_4=true
test-openshift-4: tag
VERSIONS="$(VERSIONS)" BASE_IMAGE_NAME="$(BASE_IMAGE_NAME)" $(script_env) $(test)
.PHONY: test-openshift
test-openshift: script_env += TEST_OPENSHIFT_MODE=true
test-openshift: tag
VERSIONS="$(VERSIONS)" BASE_IMAGE_NAME="$(BASE_IMAGE_NAME)" $(script_env) $(test)
.PHONY: test-openshift-pytest
test-openshift-pytest: script_env += TEST_OPENSHIFT_PYTEST=true
test-openshift-pytest: tag
VERSIONS="$(VERSIONS)" BASE_IMAGE_NAME="$(BASE_IMAGE_NAME)" $(script_env) $(test)
.PHONY: shellcheck
shellcheck:
$(shellcheck) $(SHELLCHECK_FILES)
.PHONY: tag
tag: build
VERSIONS="$(VERSIONS)" $(script_env) $(tag)
.PHOHY: betka
betka:
VERSIONS="$(VERSIONS)" \
DOWNSTREAM_NAME="$(DOWNSTREAM_NAME)" \
DOCKER_IMAGE="$(DOCKER_IMAGE)" \
$(script_env) $(betka)
.PHONY: clean clean-hook clean-images clean-versions
clean: clean-images
@$(MAKE) --no-print-directory clean-hook
clean-images:
$(clean) $(VERSIONS)
clean-versions:
rm -rf $(VERSIONS)
%root/help.1: %README.md
mkdir -p $(@D)
go-md2man -in "$^" -out "$@"
chmod a+r "$@"
generate-all: generate
.PHOHY: generate
generate:
for version in ${VERSIONS} ; do \
if [[ "$$version" == *-minimal ]]; then \
$(generator) -v $$version -m manifest-minimal.yml -s specs/multispec.yml ; \
else \
$(generator) -v $$version -m manifest.yml -s specs/multispec.yml ; \
fi \
done