From 1addd188060d7521b5655835eaeb856af3796919 Mon Sep 17 00:00:00 2001 From: Russ Magee Date: Sun, 24 May 2020 21:15:28 -0700 Subject: [PATCH] Fixed GOOS=windows MSYSTEM=MSYS install Signed-off-by: Russ Magee --- Makefile | 63 ++++++++++++++++++++------------------------ go.mod | 2 +- go.sum | 2 ++ termmode_windows.go | 8 +++--- xs/mintty_wrapper.sh | 6 +++-- xs/xs.go | 5 +++- 6 files changed, 43 insertions(+), 43 deletions(-) diff --git a/Makefile b/Makefile index 7ea0b32..091d6a6 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ VERSION := 0.8.22 -.PHONY: lint vis clean common client server passwd subpkgs install uninstall reinstall +.PHONY: lint vis clean common client server subpkgs install uninstall reinstall ## Tag version of binaries with build info wrt. ## GO111MODULE(=on) and vendor/ setup vs. $GOPATH pkg builds @@ -26,12 +26,23 @@ BUILDOPTS :=$(BUILDOPTS)"$(GOBUILDOPTS) -ldflags \"-X main.version=$(VERSION)$(M #endif SUBPKGS = logger spinsult xsnet -TOOLS = xspasswd xs xsd +TOOLS = xs xsd SUBDIRS = $(LIBS) $(TOOLS) +ifeq ($(GOOS),) + GOOS=$(shell go env GOOS) +endif + +ifeq ($(GOOS),windows) +ifeq ($(MSYSTEM),MSYS) +WIN_MSYS=1 +endif +endif + + INSTPREFIX = /usr/local -all: common client server passwd +all: common client server clean: @echo "Make: $(MAKE)" @@ -60,21 +71,11 @@ client: common $(MAKE) BUILDOPTS=$(BUILDOPTS) -C xs -ifeq ($(MSYSTEM),) -ifneq ($(GOOS),windows) server: common +ifdef WIN_MSYS + echo "Build of xsd server for Windows not yet supported" $(MAKE) BUILDOPTS=$(BUILDOPTS) -C xsd -else - echo "Cross-build of xsd server for Windows not yet supported" endif -else -server: common - echo "xsd server not (yet) supported on Windows" -endif - - -passwd: common - $(MAKE) BUILDOPTS=$(BUILDOPTS) -C xspasswd vis: @which go-callvis >/dev/null 2>&1; \ @@ -83,38 +84,30 @@ vis: else \ $(MAKE) -C xs vis;\ $(MAKE) -C xsd vis;\ - $(MAKE) -C xspasswd vis; \ fi lint: - $(MAKE) -C xspasswd lint $(MAKE) -C xsd lint $(MAKE) -C xs lint reinstall: uninstall install install: - cp xs/xs $(INSTPREFIX)/bin -ifeq ($(MSYSTEM),) -ifneq ($(GOOS),windows) - cp xsd/xsd xspasswd/xspasswd $(INSTPREFIX)/sbin -else - mv $(INSTPREFIX)/bin/xs $(INSTPREFIX)/bin/_xs + echo "WIN_MSYS:" $(WIN_MSYS) +ifdef WIN_MSYS cp xs/mintty_wrapper.sh $(INSTPREFIX)/bin/xs - echo "Cross-build of xsd server for Windows not yet supported" -endif + cp xs/mintty_wrapper.sh $(INSTPREFIX)/bin/xc + cp xs/xs $(INSTPREFIX)/bin/_xs + cp xs/xs $(INSTPREFIX)/bin/_xc + echo "Install of xsd server for Windows not yet supported" else - echo "Cross-build of xsd server for Windows not yet supported" -endif + cp xs/xs $(INSTPREFIX)/bin cd $(INSTPREFIX)/bin && ln -s xs xc && cd - - +endif uninstall: - rm -f $(INSTPREFIX)/bin/xs $(INSTPREFIX)/bin/xc $(INSTPREFIX)/bin/_xs -ifeq ($(MSYSTEM),) -ifneq ($(GOOS),windows) - rm -f $(INSTPREFIX)/sbin/xsd $(INSTPREFIX)/sbin/xspasswd -else -endif -else + rm -f $(INSTPREFIX)/bin/xs $(INSTPREFIX)/bin/xc \ + $(INSTPREFIX)/bin/_xs $(INSTPREFIX)/bin/_xc +ifndef $(WIN_MSYS) + rm -f $(INSTPREFIX)/sbin/xsd endif diff --git a/go.mod b/go.mod index b0e6d29..6cf9e07 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/pkg/errors v0.9.1 // indirect github.com/templexxx/cpufeat v0.0.0-20180724012125-cef66df7f161 // indirect github.com/templexxx/xor v0.0.0-20191217153810-f85b25db303b // indirect - github.com/tjfoc/gmsm v1.3.0 // indirect + github.com/tjfoc/gmsm v1.3.1 // indirect github.com/xtaci/kcp-go v5.4.20+incompatible golang.org/x/crypto v0.0.0-20200423211502-4bdfaf469ed5 golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f diff --git a/go.sum b/go.sum index 21c90df..f04a5aa 100644 --- a/go.sum +++ b/go.sum @@ -42,6 +42,8 @@ github.com/templexxx/xor v0.0.0-20191217153810-f85b25db303b h1:fj5tQ8acgNUr6O8LE github.com/templexxx/xor v0.0.0-20191217153810-f85b25db303b/go.mod h1:5XA7W9S6mni3h5uvOC75dA3m9CCCaS83lltmc0ukdi4= github.com/tjfoc/gmsm v1.3.0 h1:i7c6Za/IlgBvnGxYpfD7L3TGuaS+v6oGcgq+J9/ecEA= github.com/tjfoc/gmsm v1.3.0/go.mod h1:HaUcFuY0auTiaHB9MHFGCPx5IaLhTUd2atbCFBQXn9w= +github.com/tjfoc/gmsm v1.3.1 h1:+k3IAlF81c31/TllJmIfuCYnjl8ziMdTWGWJcP9J1uo= +github.com/tjfoc/gmsm v1.3.1/go.mod h1:HaUcFuY0auTiaHB9MHFGCPx5IaLhTUd2atbCFBQXn9w= github.com/xtaci/kcp-go v1.0.1 h1:SEZn2Iick6ualQpV8yY9cXdDTgbfBHPIwJl7UvxfxLQ= github.com/xtaci/kcp-go v5.4.20+incompatible h1:TN1uey3Raw0sTz0Fg8GkfM0uH3YwzhnZWQ1bABv5xAg= github.com/xtaci/kcp-go v5.4.20+incompatible/go.mod h1:bN6vIwHQbfHaHtFpEssmWsN45a+AZwO7eyRCmEIbtvE= diff --git a/termmode_windows.go b/termmode_windows.go index 92ec2c3..c8931c9 100644 --- a/termmode_windows.go +++ b/termmode_windows.go @@ -27,7 +27,7 @@ type State struct { // MakeRaw put the terminal connected to the given file descriptor into raw // mode and returns the previous state of the terminal so that it can be // restored. -func MakeRaw(fd int) (*State, error) { +func MakeRaw(fd uintptr) (*State, error) { // This doesn't really work. The exec.Command() runs a sub-shell // so the stty mods don't affect the client process. cmd := exec.Command("stty", "-echo raw") @@ -37,13 +37,13 @@ func MakeRaw(fd int) (*State, error) { // GetState returns the current state of a terminal which may be useful to // restore the terminal after a signal. -func GetState(fd int) (*State, error) { +func GetState(fd uintptr) (*State, error) { return &State{}, nil } // Restore restores the terminal connected to the given file descriptor to a // previous state. -func Restore(fd int, state *State) error { +func Restore(fd uintptr, state *State) error { cmd := exec.Command("stty", "echo cooked") cmd.Run() return nil @@ -52,7 +52,7 @@ func Restore(fd int, state *State) error { // ReadPassword reads a line of input from a terminal without local echo. This // is commonly used for inputting passwords and other sensitive data. The slice // returned does not include the \n. -func ReadPassword(fd int) ([]byte, error) { +func ReadPassword(fd uintptr) ([]byte, error) { return readPasswordLine(passwordReader(fd)) } diff --git a/xs/mintty_wrapper.sh b/xs/mintty_wrapper.sh index cef7de8..9cba8ff 100755 --- a/xs/mintty_wrapper.sh +++ b/xs/mintty_wrapper.sh @@ -28,10 +28,12 @@ cleanup() { stty sane } +me="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")" + if [ ${1}x == "-hx" ]; then - ./hkexsh -h + _${me} -h else stty -echo raw icrnl - ./hkexsh $@ + _${me} $@ fi diff --git a/xs/xs.go b/xs/xs.go index 78a4fbe..f86cb89 100755 --- a/xs/xs.go +++ b/xs/xs.go @@ -722,7 +722,10 @@ func main() { // Find out what program we are (shell or copier) myPath := strings.Split(os.Args[0], string(os.PathSeparator)) - if myPath[len(myPath)-1] != "xc" && myPath[len(myPath)-1] != "xc.exe" { + if myPath[len(myPath)-1] != "xc" && + myPath[len(myPath)-1] != "_xc" && + myPath[len(myPath)-1] != "xc.exe" && + myPath[len(myPath)-1] != "_xc.exe" { // xs accepts a command (-x) but not // a srcpath (-r) or dstpath (-t) flag.StringVar(&cmdStr, "x", "", "run <`command`> (if not specified, run interactive shell)")