Skip to content

Commit a4bc774

Browse files
committed
fix: fix Bazel installation on Linux arm64
1 parent a835d4b commit a4bc774

File tree

6 files changed

+21
-8
lines changed

6 files changed

+21
-8
lines changed

dist/legacy/setup-cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/legacy/setup-cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/modern/setup-cpp.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/modern/setup-cpp.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bazel/bazel.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { execRootSync } from "admina"
1+
import { execRoot } from "admina"
22
import { addAptKeyViaURL, installAptPack } from "setup-apt"
33
import { installBrewPack } from "setup-brew"
4+
import { getDebArch } from "../utils/env/arch.js"
45
import { hasDnf } from "../utils/env/hasDnf.js"
56
import { isArch } from "../utils/env/isArch.js"
67
import { isUbuntu } from "../utils/env/isUbuntu.js"
@@ -24,17 +25,19 @@ export async function setupBazel(version: string, _setupDir: string, _arch: stri
2425
} else if (hasDnf()) {
2526
// https://bazel.build/install/redhat
2627
await setupDnfPack([{ name: "dnf-plugins-core" }])
27-
execRootSync("dnf", ["copr", "enable", "vbatts/bazel"])
28+
await execRoot("dnf", ["copr", "enable", "vbatts/bazel"])
2829
return setupDnfPack([{ name: "bazel4" }])
2930
} else if (isUbuntu()) {
3031
// https://bazel.build/install/ubuntu
3132
const keyFileName = await addAptKeyViaURL({
3233
fileName: "bazel-archive-keyring.gpg",
3334
keyUrl: "https://bazel.build/bazel-release.pub.gpg",
3435
})
35-
execRootSync("bash", [
36+
await execRoot("bash", [
3637
"-c",
37-
`echo "deb [arch=amd64 signed-by=${keyFileName}] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list`,
38+
`echo "deb [arch=${
39+
getDebArch(process.arch)
40+
} signed-by=${keyFileName}] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list`,
3841
])
3942
return installAptPack([{ name: "bazel", version }], true)
4043
}

src/utils/env/arch.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,13 @@ export const armv7 = ["armv7", "armv7a"]
55
export const powerpc64le = ["powerpc64le", "ppc64le"]
66
export const sparc64 = ["sparc64"]
77
export const sparcv9 = ["sparcv9"]
8+
9+
export function getDebArch(arch: string) {
10+
if (arm64.includes(arch)) {
11+
return "arm64"
12+
} else if (x86_64.includes(arch)) {
13+
return "amd64"
14+
} else {
15+
return arch
16+
}
17+
}

0 commit comments

Comments
 (0)