From 8ce066a9d473435926ae22c1ecc39a281021fccf Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Thu, 7 Mar 2024 11:05:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E8=BF=87=E7=A8=8B=E4=B8=AD=E7=9A=84=E6=9E=B6=E6=9E=84=E5=88=A4?= =?UTF-8?q?=E6=96=AD=20(#4102)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/upgrade.go | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/backend/app/service/upgrade.go b/backend/app/service/upgrade.go index cab53b30e..2339fe0dd 100644 --- a/backend/app/service/upgrade.go +++ b/backend/app/service/upgrade.go @@ -7,7 +7,6 @@ import ( "net/http" "os" "path" - "runtime" "strings" "time" @@ -250,19 +249,24 @@ func (u *UpgradeService) loadReleaseNotes(path string) (string, error) { } func loadArch() (string, error) { - switch runtime.GOARCH { - case "amd64", "ppc64le", "s390x", "arm64": - return runtime.GOARCH, nil - case "arm": - std, err := cmd.Exec("uname -m") - if err != nil { - return "", fmt.Errorf("std: %s, err: %s", std, err.Error()) - } - if std == "armv7l\n" { - return "armv7", nil - } - return "", fmt.Errorf("unsupported such arch: arm-%s", std) - default: - return "", fmt.Errorf("unsupported such arch: %s", runtime.GOARCH) + std, err := cmd.Exec("uname -a") + if err != nil { + return "", fmt.Errorf("std: %s, err: %s", std, err.Error()) + } + if strings.Contains(std, "x86_64") { + return "amd64", nil + } + if strings.Contains(std, "arm64") || strings.Contains(std, "aarch64") { + return "arm64", nil + } + if strings.Contains(std, "armv7l") { + return "armv7", nil + } + if strings.Contains(std, "ppc64le") { + return "ppc64le", nil + } + if strings.Contains(std, "s390x") { + return "s390x", nil } + return "", fmt.Errorf("unsupported such arch: %s", std) }