Skip to content

Commit f76b1d0

Browse files
authored
fetch binary built for oldest macOS version (#51)
It looks like Homebrew builds binaries for the three latest versions of macOS (for both amd64 and arm64). Currently it looks like the fetch-envoy script may end up downloading any one of the three available binaries for a specific architecture. Let's update this script so that it will choose the binary built for the oldest available macOS version, as that should provide the widest compatibility. We can do this by first fetching the multi-platform manifest, filtering by OS and architecture, and then finding the minimum OS version. (Note that the OS version is a text string like "macOS 12.6". Comparing these strings may not be totally correct in general, but I think it should give a correct result while the major version still has two digits.)
1 parent b960489 commit f76b1d0

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

scripts/fetch-envoy

+13-21
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,19 @@ extract_envoy_from_homebrew() {
4545
_version="${_envoy_tag:1}"
4646
_tmp_dir="$(mktemp -d 2>/dev/null || mktemp -d -t 'tmp_dir')"
4747

48-
if [ "$_arch" == "arm64" ]; then
49-
(
50-
cd "$_tmp_dir"
51-
oras pull "ghcr.io/homebrew/core/envoy:${_version}" --platform "darwin/arm64"
52-
tar --extract \
53-
--file envoy--*.bottle.tar.gz \
54-
--directory . \
55-
--strip-components=3 \
56-
"envoy/${_version}/bin/envoy"
57-
)
58-
else
59-
(
60-
cd "$_tmp_dir"
61-
oras pull ghcr.io/homebrew/core/envoy:"${_version}" --platform "darwin/amd64"
62-
tar --extract \
63-
--file envoy--*.bottle.tar.gz \
64-
--directory . \
65-
--strip-components=3 \
66-
"envoy/${_version}/bin/envoy"
67-
)
68-
fi
48+
(
49+
cd "$_tmp_dir"
50+
_digest=$(oras manifest fetch "ghcr.io/homebrew/core/envoy:${_version}" |
51+
jq -r ".manifests |
52+
map(select(.platform | contains({os: \"$_os\", architecture: \"$_arch\"}))) |
53+
min_by(.platform[\"os.version\"]) | .digest")
54+
oras pull "ghcr.io/homebrew/core/envoy:${_version}@${_digest}"
55+
tar --extract \
56+
--file envoy--*.bottle.tar.gz \
57+
--directory . \
58+
--strip-components=3 \
59+
"envoy/${_version}/bin/envoy"
60+
)
6961
mv -f "$_tmp_dir/envoy" "$_bin_dir/envoy-$_os-$_arch"
7062
}
7163

0 commit comments

Comments
 (0)