-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathcommon.mk
More file actions
171 lines (139 loc) · 4.35 KB
/
common.mk
File metadata and controls
171 lines (139 loc) · 4.35 KB
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# 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
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),rhel10)
OS := rhel10
DOCKERFILE ?= Dockerfile.rhel10
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): copy_md_files
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
test: build
VERSIONS="$(VERSIONS)" $(script_env) $(test)
.PHONY: test-openshift-4
test-openshift-4: script_env += TEST_OPENSHIFT_4=true
test-openshift-4: build
VERSIONS="$(VERSIONS)" BASE_IMAGE_NAME="$(BASE_IMAGE_NAME)" $(script_env) $(test)
.PHONY: test-openshift
test-openshift: script_env += TEST_OPENSHIFT_MODE=true
test-openshift: build
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: build
VERSIONS="$(VERSIONS)" BASE_IMAGE_NAME="$(BASE_IMAGE_NAME)" $(script_env) $(test)
.PHONY: test-pytest
test-pytest: script_env += TEST_PYTEST=true
test-pytest: build
VERSIONS="$(VERSIONS)" BASE_IMAGE_NAME="$(BASE_IMAGE_NAME)" $(script_env) $(test)
.PHONY: shellcheck
shellcheck:
$(shellcheck) $(SHELLCHECK_FILES)
.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: remove_md_files clean-images
@$(MAKE) --no-print-directory clean-hook
clean-images:
$(clean) $(VERSIONS)
clean-versions:
rm -rf $(VERSIONS)
# Copy also all .md files from version directory to the root of
# container images, so that they are available in the image
# Currently there is only README.md, but there may be more in the future
copy_md_files:
@for version in $(VERSIONS); do \
mkdir -p "$$version/root" ; \
if ls $$version/*.md 1> /dev/null 2>&1; then \
cp -v $$version/*.md "$$version/root" ; \
chmod a+r $$version/root/*.md ; \
fi ; \
done
remove_md_files:
@for version in $(VERSIONS); do \
if ls $$version/*.md 1> /dev/null 2>&1; then \
rm -fv $$version/root/*.md ; \
fi ; \
done
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
version-table:
$(common_dir)/generate_version_table.py "$(BASE_IMAGE_NAME)"