mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-05-27 12:52:27 +02:00
cmd/cli: support nocgo version for upgrade command
linux/amd64 have the nocgo binary to support system where standard libc missing. If the current binary is a nocgo version, "ctrld upgrade" command must honor the nocgo setting and download the right binary.
This commit is contained in:
committed by
Cuong Manh Le
parent
8ccaeeab60
commit
dc433f8dc9
@@ -0,0 +1,5 @@
|
|||||||
|
//go:build cgo
|
||||||
|
|
||||||
|
package cli
|
||||||
|
|
||||||
|
const cgoEnabled = true
|
||||||
@@ -1739,9 +1739,14 @@ func goArm() string {
|
|||||||
// upgradeUrl returns the url for downloading new ctrld binary.
|
// upgradeUrl returns the url for downloading new ctrld binary.
|
||||||
func upgradeUrl(baseUrl string) string {
|
func upgradeUrl(baseUrl string) string {
|
||||||
dlPath := fmt.Sprintf("%s-%s/ctrld", runtime.GOOS, runtime.GOARCH)
|
dlPath := fmt.Sprintf("%s-%s/ctrld", runtime.GOOS, runtime.GOARCH)
|
||||||
|
// Use arm version set during build time, v5 binary can be run on higher arm version system.
|
||||||
if armVersion := goArm(); armVersion != "" {
|
if armVersion := goArm(); armVersion != "" {
|
||||||
dlPath = fmt.Sprintf("%s-%sv%s/ctrld", runtime.GOOS, runtime.GOARCH, armVersion)
|
dlPath = fmt.Sprintf("%s-%sv%s/ctrld", runtime.GOOS, runtime.GOARCH, armVersion)
|
||||||
}
|
}
|
||||||
|
// linux/amd64 has nocgo version, to support systems that missing some libc (like openwrt).
|
||||||
|
if !cgoEnabled && runtime.GOOS == "linux" && runtime.GOARCH == "amd64" {
|
||||||
|
dlPath = fmt.Sprintf("%s-%s-nocgo/ctrld", runtime.GOOS, runtime.GOARCH)
|
||||||
|
}
|
||||||
dlUrl := fmt.Sprintf("%s/%s", baseUrl, dlPath)
|
dlUrl := fmt.Sprintf("%s/%s", baseUrl, dlPath)
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
dlUrl += ".exe"
|
dlUrl += ".exe"
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
//go:build !cgo
|
||||||
|
|
||||||
|
package cli
|
||||||
|
|
||||||
|
const cgoEnabled = false
|
||||||
Reference in New Issue
Block a user