Skip to content

Commit 344b228

Browse files
committed
Updating github-config
1 parent 7274d29 commit 344b228

1 file changed

Lines changed: 46 additions & 35 deletions

File tree

scripts/.util/tools.sh

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,42 @@ set -o pipefail
66
# shellcheck source=SCRIPTDIR/print.sh
77
source "$(dirname "${BASH_SOURCE[0]}")/print.sh"
88

9+
function util::tools::os() {
10+
case "$(uname)" in
11+
"Darwin")
12+
echo "${1:-darwin}"
13+
;;
14+
15+
"Linux")
16+
echo "linux"
17+
;;
18+
19+
*)
20+
util::print::error "Unknown OS \"$(uname)\""
21+
exit 1
22+
esac
23+
}
24+
25+
function util::tools::arch() {
26+
case "$(uname -m)" in
27+
arm64|aarch64)
28+
echo "arm64"
29+
;;
30+
31+
amd64|x86_64)
32+
if [[ "${1:-}" == "--blank-amd64" ]]; then
33+
echo ""
34+
else
35+
echo "amd64"
36+
fi
37+
;;
38+
39+
*)
40+
util::print::error "Unknown Architecture \"$(uname -m)\""
41+
exit 1
42+
esac
43+
}
44+
945
function util::tools::path::export() {
1046
local dir
1147
dir="${1}"
@@ -37,26 +73,11 @@ function util::tools::jam::install() {
3773
esac
3874
done
3975

40-
local os
41-
case "$(uname)" in
42-
"Darwin")
43-
os="darwin"
44-
;;
45-
46-
"Linux")
47-
os="linux"
48-
;;
49-
50-
*)
51-
echo "Unknown OS \"$(uname)\""
52-
exit 1
53-
esac
54-
5576
mkdir -p "${dir}"
5677
util::tools::path::export "${dir}"
5778

5879
if [[ ! -f "${dir}/jam" ]]; then
59-
local version curl_args
80+
local version curl_args os arch
6081

6182
version="$(jq -r .jam "$(dirname "${BASH_SOURCE[0]}")/tools.json")"
6283

@@ -71,10 +92,12 @@ function util::tools::jam::install() {
7192
curl_args+=("--header" "Authorization: Token ${token}")
7293
fi
7394

74-
7595
util::print::title "Installing jam ${version}"
7696

77-
curl "https://github.com/paketo-buildpacks/jam/releases/download/${version}/jam-${os}" \
97+
os=$(util::tools::os)
98+
arch=$(util::tools::arch)
99+
100+
curl "https://github.com/paketo-buildpacks/jam/releases/download/${version}/jam-${os}-${arch}" \
78101
"${curl_args[@]}"
79102

80103
chmod +x "${dir}/jam"
@@ -107,23 +130,8 @@ function util::tools::pack::install() {
107130
mkdir -p "${dir}"
108131
util::tools::path::export "${dir}"
109132

110-
local os
111-
case "$(uname)" in
112-
"Darwin")
113-
os="macos"
114-
;;
115-
116-
"Linux")
117-
os="linux"
118-
;;
119-
120-
*)
121-
echo "Unknown OS \"$(uname)\""
122-
exit 1
123-
esac
124-
125133
if [[ ! -f "${dir}/pack" ]]; then
126-
local version curl_args
134+
local version curl_args os arch
127135

128136
version="$(jq -r .pack "$(dirname "${BASH_SOURCE[0]}")/tools.json")"
129137

@@ -141,7 +149,10 @@ function util::tools::pack::install() {
141149

142150
util::print::title "Installing pack ${version}"
143151

144-
curl "https://github.com/buildpacks/pack/releases/download/${version}/pack-${version}-${os}.tgz" \
152+
os=$(util::tools::os macos)
153+
arch=$(util::tools::arch --blank-amd64)
154+
155+
curl "https://github.com/buildpacks/pack/releases/download/${version}/pack-${version}-${os}${arch:+-$arch}.tgz" \
145156
"${curl_args[@]}"
146157

147158
tar xzf "${tmp_location}" -C "${dir}"

0 commit comments

Comments
 (0)