From d89f823bef579884c4defb50d99074d4b07de6ae Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Fri, 2 Jun 2023 17:03:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=89=88=E6=9C=AC=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E9=80=82=E9=85=8D=20armv7=20(#1236)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/upgrade.go | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/backend/app/service/upgrade.go b/backend/app/service/upgrade.go index 2f0e1e346..c6d9865b3 100644 --- a/backend/app/service/upgrade.go +++ b/backend/app/service/upgrade.go @@ -93,9 +93,13 @@ func (u *UpgradeService) Upgrade(req dto.Upgrade) error { if err := os.MkdirAll(originalDir, os.ModePerm); err != nil { return err } + itemArch, err := loadArch() + if err != nil { + return err + } downloadPath := fmt.Sprintf("%s/%s/%s/release", global.CONF.System.RepoUrl, global.CONF.System.Mode, req.Version) - fileName := fmt.Sprintf("1panel-%s-%s-%s.tar.gz", req.Version, "linux", runtime.GOARCH) + fileName := fmt.Sprintf("1panel-%s-%s-%s.tar.gz", req.Version, "linux", itemArch) _ = settingRepo.Update("SystemStatus", "Upgrading") go func() { if err := fileOp.DownloadFile(downloadPath+"/"+fileName, rootDir+"/"+fileName); err != nil { @@ -237,3 +241,21 @@ func (u *UpgradeService) loadReleaseNotes(path string) (string, error) { } return string(release), nil } + +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("unsupport such arch: arm-%s", std) + default: + return "", fmt.Errorf("unsupport such arch: %s", runtime.GOARCH) + } +}