Skip to content

Commit cee822b

Browse files
committed
Self-review
1 parent ce893a2 commit cee822b

File tree

1 file changed

+52
-21
lines changed

1 file changed

+52
-21
lines changed

agent/containers/images/Makefile

Lines changed: 52 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
# Base Makefile for building all images and tagging them
22

3+
# List of external Make targets:
4+
#
5+
# FIXME: Are there any missing from this list? Are there any here which can/should be removed (e.g., the last two)??
6+
#
7+
# These act on all default platforms' containers:
8+
#
9+
# all (default): make all images for all default platforms
10+
# tds: make Tool Data Sink images for all default platforms
11+
# tm: make Tool Meister images for all default platforms
12+
# tag-<TYPE> (e.g., "tag-latest"): apply specified tag to all images for all default platforms
13+
# push: push images for all default platforms with "<git commit hash>" and "v<full RPM version>" tags
14+
# push-<TYPE> (e.g., "push-latest"): push images for all default platforms with specified tag
15+
#
16+
# These act on the indicated distribution's containers:
17+
#
18+
# <DISTRO> (e.g., "fedora-34"): make all images for the requested platform
19+
# <DISTRO>-tds (e.g., "fedora-34-tds"): make the TDS image for the requested platform
20+
# <DISTRO>-tm (e.g., "fedora-34-tds"): make the TDS image for the requested platform
21+
# <DISTRO>-tag-<TYPE> (e.g., "fedora-34-tag-alpha"): apply the specified tag to the distro containers
22+
#
23+
# Utility targets:
24+
#
25+
# clean: remove build artifacts
26+
# pkgmgr-clean: clear the local package manager cache
27+
# all-tags: build all default distro "-tags.lis" files and verify that they are consistent.
28+
# all-dockerfiles: build all default distro ".repo" and ".Dockerfile" files
29+
#
30+
331
# By default we only build images for x86_64 architectures.
432
_ARCH = x86_64
533

@@ -80,7 +108,7 @@ _WORKLOAD_RPMS = fio uperf
80108
# Not intended to be overridden with an environment variable.
81109
_ALL_RPMS = ${_TOOL_RPMS} ${_WORKLOAD_RPMS}
82110

83-
# Compose a lists of all conceivable distro-version strings (e.g.,
111+
# Compose lists of all conceivable distro-version strings (e.g.,
84112
# `_ALL_centos_VERSIONS` including "centos-7", "centos-8", "centos-9",
85113
# `_ALL_fedora_VERSIONS` including "fedora-32", "fedora-33", and "fedora-34",
86114
# and `_DISTROS` containing the contents of all the lists) which will be used
@@ -89,18 +117,18 @@ _DIGITS := 0 1 2 3 4 5 6 7 8 9
89117
_NUMBERS := $(patsubst 0%,%,$(foreach t,${_DIGITS},$(foreach o,${_DIGITS},${t}${o})))
90118
_ALL_DISTRO_NAMES := centos fedora
91119
_ADV_TMPL = _ALL_${d}_VERSIONS := $(foreach v,${_NUMBERS},${d}-${v}) # template for setting version lists
92-
$(foreach d,${_ALL_DISTRO_NAMES},$(eval $(call _ADV_TMPL, $d))) # set _ALL_centos_VERSIONS, etc.
120+
$(foreach d,${_ALL_DISTRO_NAMES},$(eval $(call _ADV_TMPL, ${d}))) # set _ALL_centos_VERSIONS, etc.
93121
_DISTROS := $(foreach d,${_ALL_DISTRO_NAMES},${_ALL_${d}_VERSIONS})
94122

95123
# By default we only build images for the following distributions:
96124
_DEFAULT_DISTROS = centos-8 fedora-33 fedora-34
97125

98126
# By default we won't build the Tool Data Sink and Tool Meister images
99-
all: pkgmgr-clean all-tags $(foreach distro, ${_DEFAULT_DISTROS}, ${distro}-all-tagged)
127+
all: pkgmgr-clean all-tags $(_DEFAULT_DISTROS:%=%-all-tagged)
100128

101-
tds: pkgmgr-clean all-tags $(foreach distro, ${_DEFAULT_DISTROS}, ${distro}-tool-data-sink-tagged)
129+
tds: pkgmgr-clean all-tags $(_DEFAULT_DISTROS:%=%-tool-data-sink-tagged)
102130

103-
tm: pkgmgr-clean all-tags $(foreach distro, ${_DEFAULT_DISTROS}, ${distro}-tool-meister-tagged)
131+
tm: pkgmgr-clean all-tags $(_DEFAULT_DISTROS:%=%-tool-meister-tagged)
104132

105133
#+
106134
# For the following rule patterns, the "%" represents the "distribution" name,
@@ -112,15 +140,18 @@ tm: pkgmgr-clean all-tags $(foreach distro, ${_DEFAULT_DISTROS}, ${distro}-tool-
112140
# See https://www.gnu.org/software/make/manual/make.html#Automatic-Variables
113141
#-
114142

115-
%: DIST_NAME = $(wordlist 1, 1, $(subst -, ,$*))
116-
%: DIST_VERSION = $(wordlist 2, 2, $(subst -, ,$*))
117-
118143
# We also offer targets per distribution target
119144
${_DISTROS}: %: pkgmgr-clean %-all-tagged
120145

121-
%-tds: pkgmgr-clean %-tool-data-sink-tagged
146+
$(_DISTROS:%=%-tds): %-tds: pkgmgr-clean %-tool-data-sink-tagged
122147

123-
%-tm: pkgmgr-clean %-tool-meister-tagged
148+
$(_DISTROS:%=%-tm): %-tm: pkgmgr-clean %-tool-meister-tagged
149+
150+
# For any given target, extract the distribution name and version from the
151+
# first two fields, e.g., fedora-35-tds would yield values "fedora" and "35"
152+
# for DIST_NAME and DIST_VERSION, respectively.
153+
%: DIST_NAME = $(wordlist 1, 1, $(subst -, ,$*))
154+
%: DIST_VERSION = $(wordlist 2, 2, $(subst -, ,$*))
124155

125156

126157
# Tagging targets
@@ -131,18 +162,18 @@ ${_DISTROS}: %: pkgmgr-clean %-all-tagged
131162
#
132163
# See the `tagit` script for details.
133164
_TAG_TYPES = latest alpha beta major major-minor
134-
tag-%: $(foreach distro, ${_DEFAULT_DISTROS}, ${distro}-tag-%)
165+
$(_TAG_TYPES:%=tag-%): tag-%: $(_DEFAULT_DISTROS:%=%-tag-%)
135166

136167

137168
#+
138169
# Push targets
139170
#-
140171

141172
# Push images with "<git commit hash>" and "v<full RPM version>" tags.
142-
push: $(foreach distro, ${_DEFAULT_DISTROS}, ${distro}-push)
173+
push: $(_DEFAULT_DISTROS:%=%-push)
143174

144175
# Push images with a specific tag (see the `tag-%` target).
145-
push-%: $(foreach distro, ${_DEFAULT_DISTROS}, ${distro}-push-%)
176+
$(_TAG_TYPES:%=push-%): push-%: $(_DEFAULT_DISTROS:%=%-push-%)
146177

147178

148179
#+
@@ -182,7 +213,7 @@ push-%: $(foreach distro, ${_DEFAULT_DISTROS}, ${distro}-push-%)
182213

183214
# Add an additional dependency for centos-%-tools targets (this .repo file is
184215
# not required on Fedora).
185-
$(foreach d,${_ALL_centos_VERSIONS},${d}-tools): centos-%-tools: centos-%-prometheus.repo
216+
$(_ALL_centos_VERSIONS:%=%-tools): centos-%-tools: centos-%-prometheus.repo
186217

187218
%-tools: %-base-tagged %-tools.Dockerfile %-pcp.repo %-tags.lis
188219
./build-image tools $* $*-tags.lis
@@ -216,7 +247,7 @@ define _PUSH_RULE
216247
./push ${IMAGE_REPO} $$* $(1)
217248
endef
218249

219-
$(foreach tagtype,${_TAG_TYPES},$(eval $(call _PUSH_RULE,$tagtype))) # Define rules
250+
$(foreach tagtype,${_TAG_TYPES},$(eval $(call _PUSH_RULE,${tagtype}))) # Define rules
220251

221252
%-push: %-tags.lis
222253
./push ${IMAGE_REPO} $*
@@ -228,12 +259,14 @@ $(foreach tagtype,${_TAG_TYPES},$(eval $(call _PUSH_RULE,$tagtype))) # Define r
228259
# of "v<Major>.<Minor>-latest".
229260
#-
230261

262+
#$(_DISTROS:%=%-tag-$(1)):
263+
231264
define _TAG_RULE
232265
%-tag-$(1): %-tags.lis
233266
./tagit $$* $(1)$(if $(findstring major,$(1)),-latest)
234267
endef
235268

236-
$(foreach tagtype,${_TAG_TYPES},$(eval $(call _TAG_RULE,$tagtype))) # Define rules
269+
$(foreach tagtype,${_TAG_TYPES},$(eval $(call _TAG_RULE,${tagtype}))) # Define rules
237270

238271
# Build the tags file for the given distribution.
239272
%-tags.lis:
@@ -272,14 +305,12 @@ fedora-%-base.Dockerfile: Dockerfile.base.j2
272305

273306
# Helper target to build each distro's ".repo" and ".Dockerfile"
274307
all-dockerfiles: \
275-
$(foreach distro, \
276-
${_DEFAULT_DISTROS}, \
277-
${distro}-base.Dockerfile ${distro}-tools.Dockerfile \
278-
${distro}-workloads.Dockerfile ${distro}-all.Dockerfile)
308+
$(_DEFAULT_DISTROS:%=%-base.Dockerfile) $(_DEFAULT_DISTROS:%=%-tools.Dockerfile) \
309+
$(_DEFAULT_DISTROS:%=%-workloads.Dockerfile) $(_DEFAULT_DISTROS:%=%-all.Dockerfile)
279310

280311
# Helper target to build each distro's "-tags.lis" file and verify they
281312
# are consistent.
282-
all-tags: pkgmgr-clean $(foreach distro, ${_DEFAULT_DISTROS}, ${distro}-tags.lis)
313+
all-tags: pkgmgr-clean $(_DEFAULT_DISTROS:%=%-tags.lis)
283314
./verify-tags *-tags.lis
284315

285316
%-pbench.repo: %-pbench.yml ${_PBENCH_REPO_TEMPLATE}

0 commit comments

Comments
 (0)