Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor support for distro/version pattern rules in makefiles #2960

Merged
merged 1 commit into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions agent/containers/images/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
# all-dockerfiles: build all default distro ".repo" and ".Dockerfile" files
#

# Include definition of _DISTROS
include ../utils/utils.mk

# By default we only build images for x86_64 architectures.
_ARCH = x86_64

Expand Down Expand Up @@ -98,18 +101,6 @@ _WORKLOAD_RPMS = fio uperf
# Not intended to be overridden with an environment variable.
_ALL_RPMS = ${_TOOL_RPMS} ${_WORKLOAD_RPMS}

# Compose lists of potential distro-version strings with versions 0-99
# (e.g., `_ALL_centos_VERSIONS` including "centos-7", "centos-8", "centos-9",
# `_ALL_fedora_VERSIONS` including "fedora-32", "fedora-33", and "fedora-34",
# and `_DISTROS` concatenating the contents of all the lists) which will be
# used to drive pattern matching on distro-based target rules.
_DIGITS := 0 1 2 3 4 5 6 7 8 9
_NUMBERS := $(patsubst 0%,%,$(foreach tens,${_DIGITS},$(foreach ones,${_DIGITS},${tens}${ones})))
_ALL_DISTRO_NAMES := centos fedora
_ADV_TMPL = _ALL_${d}_VERSIONS := $(foreach v,${_NUMBERS},${d}-${v}) # template for setting version lists
$(foreach d,${_ALL_DISTRO_NAMES},$(eval $(call _ADV_TMPL, ${d}))) # set _ALL_centos_VERSIONS, etc.
_DISTROS := $(foreach d,${_ALL_DISTRO_NAMES},${_ALL_${d}_VERSIONS})

# By default we only build images for the following distributions.
_DEFAULT_DISTROS = centos-7 centos-8 centos-9 fedora-35

Expand Down
15 changes: 3 additions & 12 deletions jenkins/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
# push-rpmbuild-all: pushes all the default RPM build containers to the registry
#

# Include definition of _DISTROS
include ../utils/utils.mk

# Default list of distributions for which to build containers in which to build RPMs
RPMBUILD_BASEIMAGE_DEFAULTS = \
rhel-9 rhel-8 rhel-7 \
Expand Down Expand Up @@ -47,18 +50,6 @@ PKGMGR = dnf

BRANCH := $(shell cat ./branch.name)

# Compose lists of potential distro-version strings with versions 0-99
# (e.g., `_ALL_centos_VERSIONS` including "centos-7", "centos-8", "centos-9",
# `_ALL_fedora_VERSIONS` including "fedora-32", "fedora-33", and "fedora-34",
# and `_DISTROS` concatenating the contents of all the lists) which will be
# used to drive pattern matching on distro-based target rules.
_DIGITS := 0 1 2 3 4 5 6 7 8 9
_NUMBERS := $(patsubst 0%,%,$(foreach tens,${_DIGITS},$(foreach ones,${_DIGITS},${tens}${ones})))
_ALL_DISTRO_NAMES := centos fedora rhel
_ADV_TMPL = _ALL_${d}_VERSIONS := $(foreach v,${_NUMBERS},${d}-${v}) # template for setting version lists
$(foreach d,${_ALL_DISTRO_NAMES},$(eval $(call _ADV_TMPL, ${d}))) # set _ALL_centos_VERSIONS, etc.
_DISTROS := $(foreach d,${_ALL_DISTRO_NAMES},${_ALL_${d}_VERSIONS})

# For any given target, extract the distribution name and version from the last
# two fields, e.g., image-rpmbuild-rhel-7 would yield values "rhel" and "7" for
# DIST_NAME and DIST_VERSION, respectively.
Expand Down
26 changes: 26 additions & 0 deletions utils/utils.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Utility widgets for makefiles
#
# This file is intended to be included into other makefiles. It provides useful
# devices of various sorts which are applicable to a variety of situations.
dbutenhof marked this conversation as resolved.
Show resolved Hide resolved
#


# Compose lists of potential distro-version strings with versions 0-99
# (e.g., `_ALL_centos_VERSIONS` including "centos-7", "centos-8", "centos-9",
# `_ALL_fedora_VERSIONS` including "fedora-32", "fedora-33", and "fedora-34",
# `_ALL_rhel_VERSIONS` including "rhel-7", "rhel-8", and "rhel-9", and
# `_DISTROS` concatenating the contents of all the lists) which can be used to
# drive pattern matching on distro-based target rules.
_DIGITS := 0 1 2 3 4 5 6 7 8 9
_NUMBERS := $(patsubst 0%,%,$(foreach tens,${_DIGITS},$(foreach ones,${_DIGITS},${tens}${ones})))
_ALL_DISTRO_NAMES := centos fedora rhel
_ADV_TMPL = _ALL_${d}_VERSIONS := $(foreach v,${_NUMBERS},${d}-${v}) # template for setting version lists
$(foreach d,${_ALL_DISTRO_NAMES},$(eval $(call _ADV_TMPL, ${d}))) # set _ALL_centos_VERSIONS, etc.
_DISTROS := $(foreach d,${_ALL_DISTRO_NAMES},${_ALL_${d}_VERSIONS})

# In Make, it is hard to refer to a single blank or space character. This pair
# of definitions does that: create a definition which is literally empty, and
# then use that as a delimiter around a space character, and viola.
_empty:=
_space:= ${_empty} ${_empty}