mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00: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
5
cmd/cli/cgo.go
Normal file
5
cmd/cli/cgo.go
Normal file
@@ -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.
|
||||
func upgradeUrl(baseUrl string) string {
|
||||
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 != "" {
|
||||
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)
|
||||
if runtime.GOOS == "windows" {
|
||||
dlUrl += ".exe"
|
||||
|
||||
5
cmd/cli/nocgo.go
Normal file
5
cmd/cli/nocgo.go
Normal file
@@ -0,0 +1,5 @@
|
||||
//go:build !cgo
|
||||
|
||||
package cli
|
||||
|
||||
const cgoEnabled = false
|
||||
Reference in New Issue
Block a user