mirror of https://gogs.blitter.com/RLabs/xs
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
15
Makefile
15
Makefile
|
@ -4,8 +4,10 @@
|
||||||
MAKEOPTS = $(MAKEOPTS)
|
MAKEOPTS = $(MAKEOPTS)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
GIT_COMMIT := $(shell git rev-list -1 HEAD)
|
||||||
|
VERSION := 0.8.4
|
||||||
#ifeq ($(BUILDOPTS),)
|
#ifeq ($(BUILDOPTS),)
|
||||||
BUILDOPTS = $(BUILDOPTS)
|
BUILDOPTS :=$(BUILDOPTS)" -ldflags \"-X main.version=$(VERSION) -X main.gitCommit=$(GIT_COMMIT)\""
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SUBPKGS = logger spinsult hkexnet
|
SUBPKGS = logger spinsult hkexnet
|
||||||
|
@ -24,27 +26,28 @@ clean:
|
||||||
|
|
||||||
subpkgs:
|
subpkgs:
|
||||||
for d in $(SUBPKGS); do\
|
for d in $(SUBPKGS); do\
|
||||||
$(MAKE) -C $$d all;\
|
$(MAKE) BUILDOPTS=$(BUILDOPTS) -C $$d all;\
|
||||||
done
|
done
|
||||||
|
|
||||||
tools:
|
tools:
|
||||||
for d in $(TOOLS); do\
|
for d in $(TOOLS); do\
|
||||||
$(MAKE) -C $$d all;\
|
$(MAKE) BUILDOPTS=$(BUILDOPTS) -C $$d all;\
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
common:
|
common:
|
||||||
|
go build .
|
||||||
go install .
|
go install .
|
||||||
|
|
||||||
|
|
||||||
client: common
|
client: common
|
||||||
$(MAKE) -C hkexsh
|
$(MAKE) BUILDOPTS=$(BUILDOPTS) -C hkexsh
|
||||||
|
|
||||||
|
|
||||||
ifeq ($(MSYSTEM),)
|
ifeq ($(MSYSTEM),)
|
||||||
ifneq ($(GOOS),windows)
|
ifneq ($(GOOS),windows)
|
||||||
server: common
|
server: common
|
||||||
$(MAKE) -C hkexshd
|
$(MAKE) BUILDOPTS=$(BUILDOPTS) -C hkexshd
|
||||||
else
|
else
|
||||||
echo "Cross-build of hkexshd server for Windows not yet supported"
|
echo "Cross-build of hkexshd server for Windows not yet supported"
|
||||||
endif
|
endif
|
||||||
|
@ -55,7 +58,7 @@ endif
|
||||||
|
|
||||||
|
|
||||||
passwd: common
|
passwd: common
|
||||||
$(MAKE) -C hkexpasswd
|
$(MAKE) BUILDOPTS=$(BUILDOPTS) -C hkexpasswd
|
||||||
|
|
||||||
vis:
|
vis:
|
||||||
@which go-callvis >/dev/null 2>&1; \
|
@which go-callvis >/dev/null 2>&1; \
|
||||||
|
|
|
@ -8,6 +8,3 @@
|
||||||
package hkexsh
|
package hkexsh
|
||||||
|
|
||||||
// common constants for the 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))
|
EXE = $(notdir $(shell pwd))
|
||||||
|
|
||||||
all:
|
all:
|
||||||
go build .
|
go build $(BUILDOPTS) .
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) $(EXE) $(EXE).exe
|
$(RM) $(EXE) $(EXE).exe
|
||||||
|
|
|
@ -21,17 +21,29 @@ import (
|
||||||
"github.com/jameskeane/bcrypt"
|
"github.com/jameskeane/bcrypt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
version string
|
||||||
|
gitCommit string
|
||||||
|
)
|
||||||
|
|
||||||
// nolint: gocyclo
|
// nolint: gocyclo
|
||||||
func main() {
|
func main() {
|
||||||
|
var vopt bool
|
||||||
var pfName string
|
var pfName string
|
||||||
var newpw string
|
var newpw string
|
||||||
var confirmpw string
|
var confirmpw string
|
||||||
var userName string
|
var userName string
|
||||||
|
|
||||||
|
flag.BoolVar(&vopt, "v", false, "show version")
|
||||||
flag.StringVar(&userName, "u", "", "username")
|
flag.StringVar(&userName, "u", "", "username")
|
||||||
flag.StringVar(&pfName, "f", "/etc/hkexsh.passwd", "passwd file")
|
flag.StringVar(&pfName, "f", "/etc/hkexsh.passwd", "passwd file")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if vopt {
|
||||||
|
fmt.Printf("version %s (%s)\n", version, gitCommit)
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
var uname string
|
var uname string
|
||||||
if len(userName) == 0 {
|
if len(userName) == 0 {
|
||||||
log.Println("specify username with -u")
|
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))
|
EXE = $(notdir $(shell pwd))
|
||||||
|
|
||||||
all:
|
all:
|
||||||
|
echo "BUILDOPTS:" $(BUILDOPTS)
|
||||||
go build $(BUILDOPTS) .
|
go build $(BUILDOPTS) .
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|
|
@ -41,6 +41,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
version string
|
||||||
|
gitCommit string // set in -ldflags by build
|
||||||
|
|
||||||
// wg controls when the goroutines handling client I/O complete
|
// wg controls when the goroutines handling client I/O complete
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
// Log defaults to regular syslog output (no -d)
|
// 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
|
// TODO: reduce gocyclo
|
||||||
func main() {
|
func main() {
|
||||||
version := hkexsh.Version
|
|
||||||
var vopt bool
|
var vopt bool
|
||||||
var gopt bool //login via password, asking server to generate authToken
|
var gopt bool //login via password, asking server to generate authToken
|
||||||
var dbg bool
|
var dbg bool
|
||||||
|
@ -723,7 +725,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if vopt {
|
if vopt {
|
||||||
fmt.Printf("version v%s\n", version)
|
fmt.Printf("version %s (%s)\n", version, gitCommit)
|
||||||
exitWithStatus(0)
|
exitWithStatus(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
version string
|
||||||
|
gitCommit string // set in -ldflags by build
|
||||||
|
|
||||||
// Log - syslog output (with no -d)
|
// Log - syslog output (with no -d)
|
||||||
Log *logger.Writer
|
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.
|
// Compare to 'serverp.go' in this directory to see the equivalence.
|
||||||
// TODO: reduce gocyclo
|
// TODO: reduce gocyclo
|
||||||
func main() {
|
func main() {
|
||||||
version := hkexsh.Version
|
|
||||||
|
|
||||||
var vopt bool
|
var vopt bool
|
||||||
var chaffEnabled bool
|
var chaffEnabled bool
|
||||||
var chaffFreqMin uint
|
var chaffFreqMin uint
|
||||||
|
@ -421,7 +422,7 @@ func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if vopt {
|
if vopt {
|
||||||
fmt.Printf("version v%s\n", version)
|
fmt.Printf("version %s (%s)\n", version, gitCommit)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue