Skip to content

Commit

Permalink
Fix issues related to architecture-namespaced binaries (#26453)
Browse files Browse the repository at this point in the history
This PR fixes a couple of issues introduced when we started releasing
separate amd64 and arm64 versions of our windows and linux binaries:

* Adds the architecture string to the download url in the fleetctl npm
package
* Updates the goreleaser templates to only add the architecture to
non-macos (i.e. windows and linux) packages
* Updates the script that the website uses to download fleetctl

I did a weak test of the fleetctl npm installer by hardcoding what was
returned for my system type and at least verified that the download url
worked. Doing some more checks on VMs now.
  • Loading branch information
sgress454 authored Feb 20, 2025
1 parent aa16261 commit 39e9c0a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
6 changes: 4 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,15 @@ archives:
- id: fleetctl
builds:
- fleetctl
name_template: fleetctl_v{{.Version}}_{{- if eq .Os "darwin" }}macos{{- else }}{{ .Os }}{{ end }}_{{.Arch}}
# Note -- changing this can break GitOps and other workflows that expect these filenames to be deterministic!
name_template: fleetctl_v{{.Version}}_{{- if eq .Os "darwin" }}macos{{- else }}{{ .Os }}_{{.Arch}}{{ end }}
wrap_in_directory: true

- id: fleetctl-zip
builds:
- fleetctl
name_template: fleetctl_v{{.Version}}_{{- if eq .Os "darwin" }}macos{{- else }}{{ .Os }}{{ end }}_{{.Arch}}
# Note -- changing this can break GitOps and other workflows that expect these filenames to be deterministic!
name_template: fleetctl_v{{.Version}}_{{- if eq .Os "darwin" }}macos{{- else }}{{ .Os }}_{{.Arch}}{{ end }}
format: zip
wrap_in_directory: true

Expand Down
5 changes: 3 additions & 2 deletions tools/fleetctl-npm/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { spawnSync } = require("child_process");
const { existsSync, mkdirSync } = require("fs");
const { type } = require("os");
const { join } = require("path");
const { arch } = require("process");

const axios = require("axios");
const { rimrafSync } = require("rimraf");
Expand All @@ -27,9 +28,9 @@ const installDir = join(binDir, strippedVersion);
const platform = (() => {
switch (type()) {
case "Windows_NT":
return "windows";
return `windows_${arch === "arm64" ? "arm64" : "amd64"}`;
case "Linux":
return "linux";
return `linux_${arch === "arm64" ? "arm64" : "amd64"}`;
case "Darwin":
return "macos";
default:
Expand Down
16 changes: 15 additions & 1 deletion website/assets/resources/install-fleetctl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,22 @@ version_gt() {
# Determine operating system (Linux or MacOS)
OS="$(uname -s)"

# Determine architecture (x86_64 or arm64)
ARCH="$(uname -m)"
# Standardize x86_64 to amd64
if [[ $ARCH != "arm64" &&
$ARCH != "aarch64" &&
$ARCH != "aarch64_be" &&
$ARCH != "armv8b" &&
$ARCH != "armv8l"
]];
then
ARCH="amd64";
fi

# Standardize OS name for file download
case "${OS}" in
Linux*) OS='linux' OS_DISPLAY_NAME='Linux';;
Linux*) OS="linux_${ARCH}" OS_DISPLAY_NAME='Linux';;
Darwin*) OS='macos' OS_DISPLAY_NAME='macOS';;
*) echo "Unsupported operating system: ${OS}"; exit 1;;
esac
Expand Down

0 comments on commit 39e9c0a

Please sign in to comment.