Skip to content

Commit 44f9705

Browse files
authored
Merge pull request #1356 from buildkite/fix_osx_sed_in_makefile
ensure the SED var is used by inline commands
2 parents 33a8c74 + 8fe6618 commit 44f9705

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Makefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ build/aws-stack.yml:
7474
} else { \
7575
print \
7676
}\
77-
}' templates/aws-stack.yml | sed "s/%v/$(VERSION)/" > $@
77+
}' templates/aws-stack.yml | $(SED) "s/%v/$(VERSION)/" > $@
7878

7979
# -----------------------------------------
8080
# AMI creation with Packer
@@ -116,8 +116,8 @@ build/linux-arm64-ami.txt: packer-linux-arm64.output env-AWS_REGION
116116
grep -Eo "$(AWS_REGION): (ami-.+)" $< | cut -d' ' -f2 | xargs echo -n > $@
117117

118118
# NOTE: make removes the $ escapes, everything else is passed to the shell
119-
CURRENT_AGENT_VERSION_LINUX ?= $(shell sed -En 's/^AGENT_VERSION="?(.+?)"?$$/\1/p' packer/linux/scripts/install-buildkite-agent.sh)
120-
CURRENT_AGENT_VERSION_WINDOWS ?= $(shell sed -En 's/^\$$AGENT_VERSION = "(.+?)"$$/\1/p' packer/windows/scripts/install-buildkite-agent.ps1)
119+
CURRENT_AGENT_VERSION_LINUX ?= $(shell $(SED) -En 's/^AGENT_VERSION="?(.+?)"?$$/\1/p' packer/linux/scripts/install-buildkite-agent.sh)
120+
CURRENT_AGENT_VERSION_WINDOWS ?= $(shell $(SED) -En 's/^\$$AGENT_VERSION = "(.+?)"$$/\1/p' packer/windows/scripts/install-buildkite-agent.ps1)
121121

122122
print-agent-versions:
123123
@echo Linux: $(CURRENT_AGENT_VERSION_LINUX)
@@ -235,9 +235,12 @@ AGENT_VERSION ?= $(shell curl -Lfs "https://buildkite.com/agent/releases/latest?
235235

236236
SED ?= sed
237237
ifeq ($(shell uname), Darwin)
238-
# Use GNU sed, not MacOS sed
239-
# Install with: brew install gsed
238+
# Use GNU sed, not MacOS sed - required for extended regex support
239+
# BSD sed (default on macOS) doesn't support the regex patterns used in this Makefile
240240
SED = gsed
241+
ifeq ($(shell command -v gsed >/dev/null 2>&1 && echo yes || echo no), no)
242+
$(error GNU sed (gsed) is required on macOS but not found. Please install with: brew install gnu-sed)
243+
endif
241244
endif
242245

243246
bump-agent-version:

0 commit comments

Comments
 (0)