mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-19 09:16:29 +00:00
linuxkit: move version info to subpackage
Will avoid circular includes when I reference from pkglib too. Signed-off-by: Ian Campbell <ijc@docker.com>
This commit is contained in:
parent
d4451e4652
commit
13adecbc3e
4
Makefile
4
Makefile
@ -50,7 +50,7 @@ bin/linuxkit: tmp_linuxkit_bin.tar
|
||||
touch $@
|
||||
|
||||
tmp_linuxkit_bin.tar: $(LINUXKIT_DEPS)
|
||||
tar cf - -C src/cmd/linuxkit . | docker run --rm --net=none --log-driver=none -i $(CROSS) $(GO_COMPILE) --package github.com/linuxkit/linuxkit/src/cmd/linuxkit --ldflags "-X main.GitCommit=$(GIT_COMMIT) -X main.Version=$(VERSION)" -o bin/linuxkit > $@
|
||||
tar cf - -C src/cmd/linuxkit . | docker run --rm --net=none --log-driver=none -i $(CROSS) $(GO_COMPILE) --package github.com/linuxkit/linuxkit/src/cmd/linuxkit --ldflags "-X github.com/linuxkit/linuxkit/src/cmd/linuxkit/version.GitCommit=$(GIT_COMMIT) -X github.com/linuxkit/linuxkit/src/cmd/linuxkit/version.Version=$(VERSION)" -o bin/linuxkit > $@
|
||||
|
||||
.PHONY: test-cross
|
||||
test-cross:
|
||||
@ -67,7 +67,7 @@ LOCAL_BUILDMODE?=pie
|
||||
endif
|
||||
LOCAL_BUILDMODE?=default
|
||||
|
||||
LOCAL_LDFLAGS += -s -w -extldflags \"-static\" -X main.GitCommit=$(GIT_COMMIT) -X main.Version=$(VERSION)
|
||||
LOCAL_LDFLAGS += -s -w -extldflags \"-static\" -X github.com/linuxkit/linuxkit/src/cmd/linuxkit/version.GitCommit=$(GIT_COMMIT) -X github.com/linuxkit/linuxkit/src/cmd/linuxkit/version.Version=$(VERSION)
|
||||
LOCAL_TARGET ?= bin/linuxkit
|
||||
|
||||
.PHONY: local-check local-build local-test local
|
||||
|
@ -7,6 +7,8 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/linuxkit/linuxkit/src/cmd/linuxkit/version"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
@ -27,12 +29,6 @@ type PkgConfig struct {
|
||||
var (
|
||||
defaultLogFormatter = &log.TextFormatter{}
|
||||
|
||||
// Version is the human-readable version
|
||||
Version = "unknown"
|
||||
|
||||
// GitCommit hash, set at compile time
|
||||
GitCommit = "unknown"
|
||||
|
||||
// Config is the global tool configuration
|
||||
Config = GlobalConfig{}
|
||||
)
|
||||
@ -49,9 +45,9 @@ func (f *infoFormatter) Format(entry *log.Entry) ([]byte, error) {
|
||||
return defaultLogFormatter.Format(entry)
|
||||
}
|
||||
|
||||
func version() {
|
||||
fmt.Printf("%s version %s\n", filepath.Base(os.Args[0]), Version)
|
||||
fmt.Printf("commit: %s\n", GitCommit)
|
||||
func printVersion() {
|
||||
fmt.Printf("%s version %s\n", filepath.Base(os.Args[0]), version.Version)
|
||||
fmt.Printf("commit: %s\n", version.GitCommit)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
@ -129,7 +125,7 @@ func main() {
|
||||
case "run":
|
||||
run(args[1:])
|
||||
case "version":
|
||||
version()
|
||||
printVersion()
|
||||
case "help":
|
||||
flag.Usage()
|
||||
default:
|
||||
|
9
src/cmd/linuxkit/version/version.go
Normal file
9
src/cmd/linuxkit/version/version.go
Normal file
@ -0,0 +1,9 @@
|
||||
package version
|
||||
|
||||
var (
|
||||
// Version is the human-readable version
|
||||
Version = "unknown"
|
||||
|
||||
// GitCommit hash, set at compile time
|
||||
GitCommit = "unknown"
|
||||
)
|
Loading…
Reference in New Issue
Block a user