selfupdate: consider arm version

This commit is contained in:
albertony 2022-10-22 17:24:13 +02:00
parent f92816899c
commit 37db2a0e44

View file

@ -336,11 +336,31 @@ func makeRandomExeName(baseName, extension string) (string, error) {
func downloadUpdate(ctx context.Context, beta bool, version, siteURL, newFile, packageFormat string) error {
osName := runtime.GOOS
arch := runtime.GOARCH
if osName == "darwin" {
osName = "osx"
}
arch := runtime.GOARCH
if arch == "arm" {
// Check the ARM compatibility level of the current CPU.
// We don't know if this matches the rclone binary currently running, it
// could for example be a ARMv6 variant running on a ARMv7 compatible CPU,
// so we will simply pick the best possible variant.
switch buildinfo.GetSupportedGOARM() {
case 7:
// This system can run any binaries built with GOARCH=arm, including GOARM=7.
// Pick the ARMv7 variant of rclone, published with suffix "arm-v7".
arch = "arm-v7"
case 6:
// This system can run binaries built with GOARCH=arm and GOARM=6 or lower.
// Pick the ARMv6 variant of rclone, published with suffix "arm-v6".
arch = "arm-v6"
case 5:
// This system can only run binaries built with GOARCH=arm and GOARM=5.
// Pick the ARMv5 variant of rclone, which also works without hardfloat,
// published with suffix "arm".
arch = "arm"
}
}
archiveFilename := fmt.Sprintf("rclone-%s-%s-%s.%s", version, osName, arch, packageFormat)
archiveURL := fmt.Sprintf("%s/%s/%s", siteURL, version, archiveFilename)
archiveBuf, err := downloadFile(ctx, archiveURL)