mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 01:59:07 +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 $@
|
touch $@
|
||||||
|
|
||||||
tmp_linuxkit_bin.tar: $(LINUXKIT_DEPS)
|
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
|
.PHONY: test-cross
|
||||||
test-cross:
|
test-cross:
|
||||||
@ -67,7 +67,7 @@ LOCAL_BUILDMODE?=pie
|
|||||||
endif
|
endif
|
||||||
LOCAL_BUILDMODE?=default
|
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
|
LOCAL_TARGET ?= bin/linuxkit
|
||||||
|
|
||||||
.PHONY: local-check local-build local-test local
|
.PHONY: local-check local-build local-test local
|
||||||
|
@ -7,6 +7,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/linuxkit/linuxkit/src/cmd/linuxkit/version"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
@ -27,12 +29,6 @@ type PkgConfig struct {
|
|||||||
var (
|
var (
|
||||||
defaultLogFormatter = &log.TextFormatter{}
|
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 is the global tool configuration
|
||||||
Config = GlobalConfig{}
|
Config = GlobalConfig{}
|
||||||
)
|
)
|
||||||
@ -49,9 +45,9 @@ func (f *infoFormatter) Format(entry *log.Entry) ([]byte, error) {
|
|||||||
return defaultLogFormatter.Format(entry)
|
return defaultLogFormatter.Format(entry)
|
||||||
}
|
}
|
||||||
|
|
||||||
func version() {
|
func printVersion() {
|
||||||
fmt.Printf("%s version %s\n", filepath.Base(os.Args[0]), Version)
|
fmt.Printf("%s version %s\n", filepath.Base(os.Args[0]), version.Version)
|
||||||
fmt.Printf("commit: %s\n", GitCommit)
|
fmt.Printf("commit: %s\n", version.GitCommit)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +125,7 @@ func main() {
|
|||||||
case "run":
|
case "run":
|
||||||
run(args[1:])
|
run(args[1:])
|
||||||
case "version":
|
case "version":
|
||||||
version()
|
printVersion()
|
||||||
case "help":
|
case "help":
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
default:
|
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