diff --git a/cmd/cli/cgo.go b/cmd/cli/cgo.go new file mode 100644 index 0000000..9979523 --- /dev/null +++ b/cmd/cli/cgo.go @@ -0,0 +1,5 @@ +//go:build cgo + +package cli + +const cgoEnabled = true diff --git a/cmd/cli/cli.go b/cmd/cli/cli.go index 9d01206..016f4ac 100644 --- a/cmd/cli/cli.go +++ b/cmd/cli/cli.go @@ -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" diff --git a/cmd/cli/nocgo.go b/cmd/cli/nocgo.go new file mode 100644 index 0000000..2596d09 --- /dev/null +++ b/cmd/cli/nocgo.go @@ -0,0 +1,5 @@ +//go:build !cgo + +package cli + +const cgoEnabled = false