forked from TrueCloudLab/rclone
build: add build tag noselfupdate
Allow downstream packaging to build rclone without selfupdate command: $ go build -tags noselfupdate Fixes #5187
This commit is contained in:
parent
7df57cd625
commit
9eab258ffb
12 changed files with 37 additions and 2 deletions
|
@ -553,7 +553,7 @@ func Main() {
|
||||||
setupRootCommand(Root)
|
setupRootCommand(Root)
|
||||||
AddBackendFlags()
|
AddBackendFlags()
|
||||||
if err := Root.Execute(); err != nil {
|
if err := Root.Execute(); err != nil {
|
||||||
if strings.HasPrefix(err.Error(), "unknown command") {
|
if strings.HasPrefix(err.Error(), "unknown command") && selfupdateEnabled {
|
||||||
Root.PrintErrf("You could use '%s selfupdate' to get latest features.\n\n", Root.CommandPath())
|
Root.PrintErrf("You could use '%s selfupdate' to get latest features.\n\n", Root.CommandPath())
|
||||||
}
|
}
|
||||||
log.Fatalf("Fatal error: %v", err)
|
log.Fatalf("Fatal error: %v", err)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// +build !noselfupdate
|
||||||
|
|
||||||
package selfupdate
|
package selfupdate
|
||||||
|
|
||||||
// Note: "|" will be replaced by backticks in the help string below
|
// Note: "|" will be replaced by backticks in the help string below
|
||||||
|
|
11
cmd/selfupdate/noselfupdate.go
Normal file
11
cmd/selfupdate/noselfupdate.go
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
// +build noselfupdate
|
||||||
|
|
||||||
|
package selfupdate
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/rclone/rclone/lib/buildinfo"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
buildinfo.Tags = append(buildinfo.Tags, "noselfupdate")
|
||||||
|
}
|
|
@ -1,3 +1,5 @@
|
||||||
|
// +build !noselfupdate
|
||||||
|
|
||||||
package selfupdate
|
package selfupdate
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// +build !noselfupdate
|
||||||
|
|
||||||
package selfupdate
|
package selfupdate
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// +build !noselfupdate
|
||||||
|
|
||||||
package selfupdate
|
package selfupdate
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
// +build !windows,!plan9,!js
|
// +build !windows,!plan9,!js
|
||||||
|
// +build !noselfupdate
|
||||||
|
|
||||||
package selfupdate
|
package selfupdate
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
// +build plan9 js
|
// +build plan9 js
|
||||||
|
// +build !noselfupdate
|
||||||
|
|
||||||
package selfupdate
|
package selfupdate
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
// +build windows
|
// +build windows
|
||||||
|
// +build !noselfupdate
|
||||||
|
|
||||||
package selfupdate
|
package selfupdate
|
||||||
|
|
||||||
|
|
5
cmd/selfupdate_disabled.go
Normal file
5
cmd/selfupdate_disabled.go
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
// +build noselfupdate
|
||||||
|
|
||||||
|
package cmd
|
||||||
|
|
||||||
|
const selfupdateEnabled = false
|
7
cmd/selfupdate_enabled.go
Normal file
7
cmd/selfupdate_enabled.go
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
// +build !noselfupdate
|
||||||
|
|
||||||
|
package cmd
|
||||||
|
|
||||||
|
// This constant must be in the `cmd` package rather than `cmd/selfupdate`
|
||||||
|
// to prevent build failure due to dependency loop.
|
||||||
|
const selfupdateEnabled = true
|
|
@ -5,8 +5,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Tags contains slice of build tags
|
// Tags contains slice of build tags.
|
||||||
// The `cmount` tag is added by cmd/cmount/mount.go only if build is static.
|
// The `cmount` tag is added by cmd/cmount/mount.go only if build is static.
|
||||||
|
// The `noselfupdate` tag is added by cmd/selfupdate/noselfupdate.go
|
||||||
// Other tags including `cgo` are detected in this package.
|
// Other tags including `cgo` are detected in this package.
|
||||||
var Tags []string
|
var Tags []string
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue