mirror of
https://gogs.blitter.com/RLabs/xs
synced 2024-08-14 10:26:42 +00:00
Added make-controlled version, gitCommit (thanks to https://preslav.me/2019/07/09/adding-version-information-to-go-binaries/
This commit is contained in:
parent
2087aab2d5
commit
06854f7a03
7 changed files with 31 additions and 15 deletions
15
Makefile
15
Makefile
|
@ -4,8 +4,10 @@
|
|||
MAKEOPTS = $(MAKEOPTS)
|
||||
#endif
|
||||
|
||||
GIT_COMMIT := $(shell git rev-list -1 HEAD)
|
||||
VERSION := 0.8.4
|
||||
#ifeq ($(BUILDOPTS),)
|
||||
BUILDOPTS = $(BUILDOPTS)
|
||||
BUILDOPTS :=$(BUILDOPTS)" -ldflags \"-X main.version=$(VERSION) -X main.gitCommit=$(GIT_COMMIT)\""
|
||||
#endif
|
||||
|
||||
SUBPKGS = logger spinsult hkexnet
|
||||
|
@ -24,27 +26,28 @@ clean:
|
|||
|
||||
subpkgs:
|
||||
for d in $(SUBPKGS); do\
|
||||
$(MAKE) -C $$d all;\
|
||||
$(MAKE) BUILDOPTS=$(BUILDOPTS) -C $$d all;\
|
||||
done
|
||||
|
||||
tools:
|
||||
for d in $(TOOLS); do\
|
||||
$(MAKE) -C $$d all;\
|
||||
$(MAKE) BUILDOPTS=$(BUILDOPTS) -C $$d all;\
|
||||
done
|
||||
|
||||
|
||||
common:
|
||||
go build .
|
||||
go install .
|
||||
|
||||
|
||||
client: common
|
||||
$(MAKE) -C hkexsh
|
||||
$(MAKE) BUILDOPTS=$(BUILDOPTS) -C hkexsh
|
||||
|
||||
|
||||
ifeq ($(MSYSTEM),)
|
||||
ifneq ($(GOOS),windows)
|
||||
server: common
|
||||
$(MAKE) -C hkexshd
|
||||
$(MAKE) BUILDOPTS=$(BUILDOPTS) -C hkexshd
|
||||
else
|
||||
echo "Cross-build of hkexshd server for Windows not yet supported"
|
||||
endif
|
||||
|
@ -55,7 +58,7 @@ endif
|
|||
|
||||
|
||||
passwd: common
|
||||
$(MAKE) -C hkexpasswd
|
||||
$(MAKE) BUILDOPTS=$(BUILDOPTS) -C hkexpasswd
|
||||
|
||||
vis:
|
||||
@which go-callvis >/dev/null 2>&1; \
|
||||
|
|
|
@ -8,6 +8,3 @@
|
|||
package hkexsh
|
||||
|
||||
// common constants for the HKExSh
|
||||
|
||||
// Version string returned by tools
|
||||
const Version = "0.8.4 (NO WARRANTY)"
|
||||
|
|
|
@ -4,7 +4,7 @@ EXTPKGS = bytes,errors,flag,fmt,internal,io,log,net,os,path,runtime,time,strings
|
|||
EXE = $(notdir $(shell pwd))
|
||||
|
||||
all:
|
||||
go build .
|
||||
go build $(BUILDOPTS) .
|
||||
|
||||
clean:
|
||||
$(RM) $(EXE) $(EXE).exe
|
||||
|
|
|
@ -21,17 +21,29 @@ import (
|
|||
"github.com/jameskeane/bcrypt"
|
||||
)
|
||||
|
||||
var (
|
||||
version string
|
||||
gitCommit string
|
||||
)
|
||||
|
||||
// nolint: gocyclo
|
||||
func main() {
|
||||
var vopt bool
|
||||
var pfName string
|
||||
var newpw string
|
||||
var confirmpw string
|
||||
var userName string
|
||||
|
||||
flag.BoolVar(&vopt, "v", false, "show version")
|
||||
flag.StringVar(&userName, "u", "", "username")
|
||||
flag.StringVar(&pfName, "f", "/etc/hkexsh.passwd", "passwd file")
|
||||
flag.Parse()
|
||||
|
||||
if vopt {
|
||||
fmt.Printf("version %s (%s)\n", version, gitCommit)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
var uname string
|
||||
if len(userName) == 0 {
|
||||
log.Println("specify username with -u")
|
||||
|
|
|
@ -4,6 +4,7 @@ EXTPKGS = bytes,errors,flag,fmt,internal,io,log,net,os,path,runtime,time,strings
|
|||
EXE = $(notdir $(shell pwd))
|
||||
|
||||
all:
|
||||
echo "BUILDOPTS:" $(BUILDOPTS)
|
||||
go build $(BUILDOPTS) .
|
||||
|
||||
clean:
|
||||
|
|
|
@ -41,6 +41,9 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
version string
|
||||
gitCommit string // set in -ldflags by build
|
||||
|
||||
// wg controls when the goroutines handling client I/O complete
|
||||
wg sync.WaitGroup
|
||||
// Log defaults to regular syslog output (no -d)
|
||||
|
@ -592,7 +595,6 @@ func sendSessionParams(conn io.Writer /* *hkexnet.Conn*/, rec *hkexsh.Session) (
|
|||
|
||||
// TODO: reduce gocyclo
|
||||
func main() {
|
||||
version := hkexsh.Version
|
||||
var vopt bool
|
||||
var gopt bool //login via password, asking server to generate authToken
|
||||
var dbg bool
|
||||
|
@ -723,7 +725,7 @@ func main() {
|
|||
}
|
||||
|
||||
if vopt {
|
||||
fmt.Printf("version v%s\n", version)
|
||||
fmt.Printf("version %s (%s)\n", version, gitCommit)
|
||||
exitWithStatus(0)
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
version string
|
||||
gitCommit string // set in -ldflags by build
|
||||
|
||||
// Log - syslog output (with no -d)
|
||||
Log *logger.Writer
|
||||
)
|
||||
|
@ -401,8 +404,6 @@ func GenAuthToken(who string, connhost string) string {
|
|||
// Compare to 'serverp.go' in this directory to see the equivalence.
|
||||
// TODO: reduce gocyclo
|
||||
func main() {
|
||||
version := hkexsh.Version
|
||||
|
||||
var vopt bool
|
||||
var chaffEnabled bool
|
||||
var chaffFreqMin uint
|
||||
|
@ -421,7 +422,7 @@ func main() {
|
|||
flag.Parse()
|
||||
|
||||
if vopt {
|
||||
fmt.Printf("version v%s\n", version)
|
||||
fmt.Printf("version %s (%s)\n", version, gitCommit)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue