Skip to content

Commit 4569f27

Browse files
committed
build.make: fix push-multiarch ambiguity
"make push-multiarch" matched both push-multiarch and push-%. This seems to be none-deterministic and in at least one repo (external-provisioner), make picked the wildcard rule which then failed because there is no "multiarch" command. This ambiguity gets resolved by instantiating the wildcard rules only for existing commands. The advantage also is that "make push-no-such-command" will fail with an obvious "No rule to make target 'push-no-such-command'" instead of attempting to build the command.
1 parent 17dde9e commit 4569f27

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

build.make

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ BUILD_PLATFORMS =
7171

7272
# This builds each command (= the sub-directories of ./cmd) for the target platform(s)
7373
# defined by BUILD_PLATFORMS.
74-
build-%: check-go-version-go
74+
$(CMDS:%=build-%): build-%: check-go-version-go
7575
mkdir -p bin
7676
echo '$(BUILD_PLATFORMS)' | tr ';' '\n' | while read -r os arch suffix; do \
7777
if ! (set -x; CGO_ENABLED=0 GOOS="$$os" GOARCH="$$arch" go build $(GOFLAGS_VENDOR) -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o "./bin/$*$$suffix" ./cmd/$*); then \
@@ -80,10 +80,10 @@ build-%: check-go-version-go
8080
fi; \
8181
done
8282

83-
container-%: build-%
83+
$(CMDS:%=container-%): container-%: build-%
8484
docker build -t $*:latest -f $(shell if [ -e ./cmd/$*/Dockerfile ]; then echo ./cmd/$*/Dockerfile; else echo Dockerfile; fi) --label revision=$(REV) .
8585

86-
push-%: container-%
86+
$(CMDS:%=push-%): push-%: container-%
8787
set -ex; \
8888
push_image () { \
8989
docker tag $*:latest $(IMAGE_NAME):$$tag; \
@@ -120,7 +120,7 @@ DOCKER_BUILDX_CREATE_ARGS ?=
120120
# BUILD_PLATFORMS determines which individual images are included in the multiarch image.
121121
# PULL_BASE_REF must be set to 'master', 'release-x.y', or a tag name, and determines
122122
# the tag for the resulting multiarch image.
123-
push-multiarch-%: check-pull-base-ref build-%
123+
$(CMDS:%=push-multiarch-%): push-multiarch-%: check-pull-base-ref build-%
124124
set -ex; \
125125
DOCKER_CLI_EXPERIMENTAL=enabled; \
126126
export DOCKER_CLI_EXPERIMENTAL; \

0 commit comments

Comments
 (0)