diff --git a/Makefile b/Makefile index d4ec624..66ab07f 100755 --- a/Makefile +++ b/Makefile @@ -19,8 +19,9 @@ MAC_DIR ?= "openceci-darwin-$(VER).$(ARCH)" ## declare flags MOD = github.com/luscis/openlan/pkg/libol -LDFLAGS += -X $(MOD).Date=$(shell date +%FT%T%z) +LDFLAGS += -X $(MOD).Date=$(shell date +%F) LDFLAGS += -X $(MOD).Version=$(VER) +LDFLAGS += -X $(MOD).Commit=$(shell git rev-parse --short HEAD) build: test pkg @@ -95,6 +96,9 @@ docker-deb: docker-bin ## build image for debian docker-bin: docker exec openlan_builder bash -c "cd /opt/openlan && make linux-bin" +docker-tar: + docker exec openlan_builder bash -c "cd /opt/openlan && make linux-tar" + docker: docker-deb ## build docker images docker-builder: builder ## create a builder @@ -124,13 +128,13 @@ linux-ceci: linux-proxy: GOOS=linux GOARCH=$(ARCH) go build -mod=vendor -ldflags "$(LDFLAGS)" -o $(BD)/openlan-proxy ./cmd/proxy -linux-gzip: install ## build linux packages +linux-tar: install ## build linux packages @rm -rf $(LIN_DIR).tar.gz tar -cf $(LIN_DIR).tar $(LIN_DIR) && mv $(LIN_DIR).tar $(BD) @rm -rf $(LIN_DIR) gzip -f $(BD)/$(LIN_DIR).tar -linux-bin: linux-gzip ## build linux install binary +linux-bin: update linux-tar ## build linux install binary @cat $(SD)/dist/rootfs/var/openlan/script/install.sh > $(BD)/$(LIN_DIR).bin && \ echo "__ARCHIVE_BELOW__:" >> $(BD)/$(LIN_DIR).bin && \ cat $(BD)/$(LIN_DIR).tar.gz >> $(BD)/$(LIN_DIR).bin && \ diff --git a/cmd/api/v5/version.go b/cmd/api/v5/version.go index 5cf3aab..6c0333b 100755 --- a/cmd/api/v5/version.go +++ b/cmd/api/v5/version.go @@ -22,7 +22,8 @@ func (v Version) Url(prefix, name string) string { func (v Version) Tmpl() string { return `Version : {{ .Version }} -Build at : {{ .Date}} +Build at : {{ .Date }} +Commit id: {{ .Commit }} Expire at: {{ .Expire }} ` } diff --git a/cmd/switch/main_linux.go b/cmd/switch/main_linux.go index d33b8e5..5b73ba7 100755 --- a/cmd/switch/main_linux.go +++ b/cmd/switch/main_linux.go @@ -12,6 +12,8 @@ func main() { config.Update(c) libol.SetLogger(c.Log.File, c.Log.Verbose) + libol.ShowVersion() + cache.Init(&c.Perf) s := cswitch.NewSwitch(c) libol.PreNotify() diff --git a/pkg/libol/version.go b/pkg/libol/version.go index 5125a6e..9c8c63e 100755 --- a/pkg/libol/version.go +++ b/pkg/libol/version.go @@ -6,7 +6,8 @@ var ( Commit string ) -func init() { - Debug("version is %s", Version) - Debug("built on %s", Date) +func ShowVersion() { + Info("Version is %s", Version) + Info("Built on %s", Date) + Info("Commit id %s", Commit) } diff --git a/pkg/schema/version.go b/pkg/schema/version.go index d9f9e32..e649c1f 100755 --- a/pkg/schema/version.go +++ b/pkg/schema/version.go @@ -5,6 +5,7 @@ import "github.com/luscis/openlan/pkg/libol" type Version struct { Version string `json:"version"` Date string `json:"date"` + Commit string `json:"commit"` Expire string `json:"expire"` } @@ -12,6 +13,7 @@ func NewVersionSchema() Version { return Version{ Version: libol.Version, Date: libol.Date, + Commit: libol.Commit, } }