提交 7d7cadfe 编写于 作者: yanghye's avatar yanghye

energy command-line tools: 优化 install CEF框架可选择系统架构

上级 0d120130
......@@ -14,7 +14,9 @@ package autoupdate
import (
"crypto/tls"
"encoding/json"
"fmt"
"github.com/energye/energy/v2/cmd/internal"
"github.com/energye/energy/v2/cmd/internal/consts"
"github.com/energye/liblclbinres"
"io/ioutil"
"net/http"
......@@ -67,7 +69,7 @@ func check() {
client := &http.Client{Timeout: 5 * time.Second, Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}}
request, err := http.NewRequest("GET", internal.CheckUpgradeURL, nil)
request, err := http.NewRequest("GET", consts.CheckUpgradeURL, nil)
if err != nil {
println("energy check update http.NewRequest error:", err.Error())
return
......@@ -111,6 +113,36 @@ func LibLCLName(version, buildSupportOSArch string) (string, bool) {
return internal.LibLCLName(version, buildSupportOSArch)
}
// 命名规则 OS+[ARCH]+BIT+[GTK2]
// ARCH: 非必需, ARM 时填写, AMD为空
// GTK2: 非必需, GTK2(Linux CEF 106) 时填写, 非Linux或GTK3时为空
func liblclOS(version, buildSupportOSArch string) (string, bool) {
archs := strings.Split(buildSupportOSArch, ",")
var goarch string
if c.Install.OS.IsWindows() && c.Install.Arch.Is386() {
goarch = "32" // windows32 = > windows386
} else {
goarch = string(c.Install.Arch)
}
noSuport := fmt.Sprintf("%v %v", c.Install.OS, goarch)
var isSupport = func(goarch string) bool {
for _, v := range archs {
if goarch == v {
return true
}
}
return false
}
if name, isOld := liblclName(c, version, cef); isOld {
if name == "" {
return noSuport, false
}
return name, true
} else {
return name, isSupport(name)
}
}
// Version comparison, returns true if the current version is smaller than the remote version
func compare(current, origin string) (bool, int) {
cmajor, cminor, crevision := versionConvert(current)
......
......@@ -141,11 +141,11 @@ func upxInstallPathName(c *command.Config) string {
}
func nsisIsInstall() bool {
return consts.IsWindows && runtime.GOARCH != "arm64"
return consts.IsWindows && !consts.IsARM64
}
func upxIsInstall() bool {
return (consts.IsWindows && runtime.GOARCH != "arm64") || (consts.IsLinux)
return (consts.IsWindows && !consts.IsARM64) || (consts.IsLinux)
}
// 检查当前环境
......
......@@ -16,14 +16,13 @@ import (
progressbar "github.com/energye/energy/v2/cmd/internal/progress-bar"
"github.com/energye/energy/v2/cmd/internal/tools"
"path/filepath"
"runtime"
)
func installNSIS(c *command.Config) (string, func()) {
if !c.Install.INSIS {
return "", nil
}
if consts.IsWindows && runtime.GOARCH != "arm64" {
if consts.IsWindows && !consts.IsARM64 {
// 下载并安装配置NSIS
s := nsisInstallPathName(c) // 安装目录
version := consts.NSISDownloadVersion
......
......@@ -19,14 +19,13 @@ import (
"github.com/energye/energy/v2/cmd/internal/tools"
"os"
"path/filepath"
"runtime"
)
func installUPX(c *command.Config) (string, func()) {
if !c.Install.IUPX {
return "", nil
}
if (consts.IsWindows && runtime.GOARCH != "arm64") || (consts.IsLinux) {
if (consts.IsWindows && !consts.IsARM64) || (consts.IsLinux) {
s := upxInstallPathName(c) // 安装目录
if !tools.IsExist(s) {
os.MkdirAll(s, 0755)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册