diff --git a/.gitignore b/.gitignore index ef4a60a..73beec9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,3 @@ - -# Created by https://www.gitignore.io/api/go,intellij - ### Go ### # Binaries for programs and plugins *.exe @@ -10,6 +7,9 @@ /bin/ +### Current Version Resource File ### +/.version + ### Glide Go Vendor Directory ### vendor/ @@ -86,5 +86,3 @@ modules.xml # Sonarlint plugin .idea/sonarlint - -# End of https://www.gitignore.io/api/go,intellij diff --git a/Makefile b/Makefile index a136492..378fbf5 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,14 @@ -PACKAGE = github.com/dekobon/clamav-mirror -DATE ?= $(shell date -u +%FT%T%z) -VERSION ?= $(shell git describe --tags --always --dirty --match=v* 2> /dev/null || \ - cat $(CURDIR)/.version 2> /dev/null || echo v0) -GITHASH ?= $(shell git rev-parse HEAD) - -GOPATH = $(CURDIR)/.gopath~ -BIN = $(GOPATH)/bin -BASE = $(GOPATH)/src/$(PACKAGE) -PKGS = $(or $(PKG),$(shell cd $(BASE) && env GOPATH=$(GOPATH) $(GO) list ./... | grep -v "^$(PACKAGE)/vendor/")) -TESTPKGS = $(shell env GOPATH=$(GOPATH) $(GO) list -f '{{ if or .TestGoFiles .XTestGoFiles }}{{ .ImportPath }}{{ end }}' $(PKGS)) +PACKAGE_ROOT = github.com/dekobon +PACKAGE = $(PACKAGE_ROOT)/clamav-mirror +DATE ?= $(shell date -u +%FT%T%z) +VERSION ?= $(shell cat $(CURDIR)/.version 2> /dev/null || echo unknown) +GITHASH ?= $(shell git rev-parse HEAD) + +GOPATH = $(CURDIR)/.gopath~ +BIN = $(GOPATH)/bin +BASE = $(GOPATH)/src/$(PACKAGE) +PKGS = $(or $(PKG),$(shell cd $(BASE) && env GOPATH=$(GOPATH) $(GO) list ./... | grep -v "^$(PACKAGE)/vendor/")) +TESTPKGS = $(shell env GOPATH=$(GOPATH) $(GO) list -f '{{ if or .TestGoFiles .XTestGoFiles }}{{ .ImportPath }}{{ end }}' $(PKGS)) GO = go GODOC = godoc @@ -19,14 +19,14 @@ V = 0 Q = $(if $(filter 1,$V),,@) M = $(shell printf "\033[34;1m▶\033[0m") -#export GOPATH:=$(GOPATH) +export GOPATH:=$(GOPATH) .PHONY: all all: fmt lint vendor | $(BASE) sigupdate sigserver $(BASE): ; $(info $(M) setting GOPATH…) - @mkdir -p $(GOPATH) - @ln -sf $(CURDIR)/src $(GOPATH)/src + @mkdir -p $(GOPATH)/src/github.com + @ln -sf $(CURDIR)/src/$(PACKAGE_ROOT) $(GOPATH)/src/$(PACKAGE_ROOT) @ln -sf $(CURDIR)/vendor $(GOPATH)/src/vendor # Tools @@ -105,7 +105,7 @@ sigserver: $(info $(M) building sigserver…) @ ## Build sigupdate binary $Q cd $(BASE) && $(GO) build \ -tags release \ - -ldflags '-X main.githash=$(GITHASH) -X main.buildstamp=$(DATE)' \ + -ldflags '-X main.githash=$(GITHASH) -X main.buildstamp=$(DATE) -X main.appversion=$(VERSION)' \ -o $(CURDIR)/bin/sigserver \ $(GOPATH)/src/$(PACKAGE)/sigserver/*.go @@ -113,7 +113,7 @@ sigupdate: $(info $(M) building sigupdate…) @ ## Build sigserver binary $Q cd $(BASE) && $(GO) build \ -tags release \ - -ldflags '-X main.githash=$(GITHASH) -X main.buildstamp=$(DATE)' \ + -ldflags '-X main.githash=$(GITHASH) -X main.buildstamp=$(DATE) -X main.appversion=$(VERSION)' \ -o $(CURDIR)/bin/sigupdate \ $(GOPATH)/src/$(PACKAGE)/sigupdate/*.go diff --git a/src/github.com/dekobon/clamav-mirror/sigserver/sigserver.go b/src/github.com/dekobon/clamav-mirror/sigserver/sigserver.go index 0ae7a11..6be49db 100644 --- a/src/github.com/dekobon/clamav-mirror/sigserver/sigserver.go +++ b/src/github.com/dekobon/clamav-mirror/sigserver/sigserver.go @@ -18,6 +18,7 @@ import ( var githash = "unknown" var buildstamp = "unknown" +var appversion = "unknown" var logger *log.Logger var logFatal *log.Logger diff --git a/src/github.com/dekobon/clamav-mirror/sigupdate/sigupdate.go b/src/github.com/dekobon/clamav-mirror/sigupdate/sigupdate.go index 5555531..c43b2c1 100644 --- a/src/github.com/dekobon/clamav-mirror/sigupdate/sigupdate.go +++ b/src/github.com/dekobon/clamav-mirror/sigupdate/sigupdate.go @@ -29,6 +29,7 @@ import ( var githash = "unknown" var buildstamp = "unknown" +var appversion = "unknown" var logger *log.Logger var logFatal *log.Logger @@ -125,9 +126,10 @@ func parseCliFlags() (bool, string, string, uint16) { if *versionPart { fmt.Println("sigupdate") fmt.Println("") - fmt.Printf("License : MPLv2\n") + fmt.Printf("Version : %v\n", appversion) fmt.Printf("Git Commit Hash: %v\n", githash) fmt.Printf("UTC Build Time : %v\n", buildstamp) + fmt.Printf("License : MPLv2\n") os.Exit(0) }