From c76a1a0efe4fd751447da31b9599da1638b6ad12 Mon Sep 17 00:00:00 2001 From: Florian Weikert Date: Tue, 16 Aug 2022 16:57:07 +0200 Subject: [PATCH] Download correct Bazel binary on Linux We stopped publishing binaries for Ubuntu 14.04 some time ago, and we don't upload Arm64 Linux binaries (yet). Consequently, Bazelisk on Linux should always fetch the regular Ubuntu 18.04 binaries for now. Fixes https://github.com/bazelbuild/bazel/issues/16061 --- platforms/platforms.go | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/platforms/platforms.go b/platforms/platforms.go index 6c6b4e85..7a7f3415 100644 --- a/platforms/platforms.go +++ b/platforms/platforms.go @@ -3,22 +3,41 @@ package platforms import ( "fmt" - semver "github.com/hashicorp/go-version" "log" "runtime" + + semver "github.com/hashicorp/go-version" ) -var platforms = map[string]string{"darwin": "macos", "linux": "ubuntu1404", "windows": "windows"} +type platform struct { + Name string + HasArm64Binary bool +} + +var supportedPlatforms = map[string]*platform{ + "darwin": { + Name: "macos", + HasArm64Binary: true, + }, + "linux": { + Name: "ubuntu1804", + HasArm64Binary: false, + }, + "windows": { + Name: "windows", + HasArm64Binary: true, + }, +} // GetPlatform returns a Bazel CI-compatible platform identifier for the current operating system. // TODO(fweikert): raise an error for unsupported platforms func GetPlatform() string { - platform := platforms[runtime.GOOS] + platform := supportedPlatforms[runtime.GOOS] arch := runtime.GOARCH - if arch == "arm64" { - platform = platform + "_arm64" + if arch == "arm64" && platform.HasArm64Binary { + return platform.Name + "_arm64" } - return platform + return platform.Name } // DetermineExecutableFilenameSuffix returns the extension for binaries on the current operating system.