mirror of https://gogs.blitter.com/RLabs/xs
Fixes for xc to work in MSYS2/MINGW
This commit is contained in:
parent
f9a0f282b7
commit
a05e5948b6
27
auth.go
27
auth.go
|
|
@ -215,18 +215,39 @@ func AuthUserByToken(ctx *AuthCtx, username string, connhostname string, auth st
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GroomFsPath(path string) (ret string) {
|
||||||
|
pathRoot := os.Getenv("MINGW_ROOT")
|
||||||
|
if pathRoot != "" {
|
||||||
|
ret = path[len(pathRoot):]
|
||||||
|
ret = strings.ReplaceAll(ret, "\\", "/")
|
||||||
|
} else {
|
||||||
|
ret = path
|
||||||
|
}
|
||||||
|
//fmt.Printf("groomed fspath:%v\n", ret)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func GetTool(tool string) (ret string) {
|
func GetTool(tool string) (ret string) {
|
||||||
ret = "/bin/" + tool
|
cmdSuffix := ""
|
||||||
|
pathRoot := os.Getenv("MINGW_ROOT")
|
||||||
|
|
||||||
|
if pathRoot != "" {
|
||||||
|
cmdSuffix = ".exe"
|
||||||
|
}
|
||||||
|
|
||||||
|
//fmt.Printf("pathRoot:%v cmdSuffix:%v\n", pathRoot, cmdSuffix)
|
||||||
|
|
||||||
|
ret = pathRoot + "/bin/" + tool + cmdSuffix
|
||||||
_, err := os.Stat(ret)
|
_, err := os.Stat(ret)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
ret = "/usr/bin/" + tool
|
ret = pathRoot + "/usr/bin/" + tool + cmdSuffix
|
||||||
_, err = os.Stat(ret)
|
_, err = os.Stat(ret)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
ret = "/usr/local/bin/" + tool
|
ret = pathRoot + "/usr/local/bin/" + tool + cmdSuffix
|
||||||
_, err = os.Stat(ret)
|
_, err = os.Stat(ret)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return ret
|
return ret
|
||||||
|
|
|
||||||
16
xs/xs.go
16
xs/xs.go
|
|
@ -294,7 +294,14 @@ func buildCmdLocalToRemote(copyQuiet bool, copyLimitBPS uint, files string) (cap
|
||||||
|
|
||||||
captureStderr = true
|
captureStderr = true
|
||||||
cmd = xs.GetTool("tar")
|
cmd = xs.GetTool("tar")
|
||||||
args = []string{"-cz", "-f", "/dev/stdout"}
|
//fmt.Printf("GetTool found cmd:%v\n", cmd)
|
||||||
|
/* Explicit -f /dev/stdout doesn't work in MINGW/MSYS64
|
||||||
|
* as '/dev/stdout' doesn't actually appear in the /dev/ filesystem...?
|
||||||
|
* And it appears not to actually be required as without -f stdout is
|
||||||
|
* implied. -rlm 2025-12-07
|
||||||
|
*/
|
||||||
|
//args = []string{"-cz", "-f", "/dev/stdout"}
|
||||||
|
args = []string{"-cz"}
|
||||||
files = strings.TrimSpace(files)
|
files = strings.TrimSpace(files)
|
||||||
// Awesome fact: tar actually can take multiple -C args, and
|
// Awesome fact: tar actually can take multiple -C args, and
|
||||||
// changes to the dest dir *as it sees each one*. This enables
|
// changes to the dest dir *as it sees each one*. This enables
|
||||||
|
|
@ -310,6 +317,7 @@ func buildCmdLocalToRemote(copyQuiet bool, copyLimitBPS uint, files string) (cap
|
||||||
// remote destDir.
|
// remote destDir.
|
||||||
for _, v := range strings.Split(files, " ") {
|
for _, v := range strings.Split(files, " ") {
|
||||||
v, _ = filepath.Abs(v) // #nosec
|
v, _ = filepath.Abs(v) // #nosec
|
||||||
|
v = xs.GroomFsPath(v)
|
||||||
dirTmp, fileTmp := path.Split(v)
|
dirTmp, fileTmp := path.Split(v)
|
||||||
if dirTmp == "" {
|
if dirTmp == "" {
|
||||||
args = append(args, fileTmp)
|
args = append(args, fileTmp)
|
||||||
|
|
@ -322,7 +330,8 @@ func buildCmdLocalToRemote(copyQuiet bool, copyLimitBPS uint, files string) (cap
|
||||||
bandwidthInBytesPerSec := " -L " + fmt.Sprintf("%d", copyLimitBPS)
|
bandwidthInBytesPerSec := " -L " + fmt.Sprintf("%d", copyLimitBPS)
|
||||||
displayOpts := " -pre " //nolint:goconst,nolintlint
|
displayOpts := " -pre " //nolint:goconst,nolintlint
|
||||||
cmd = xs.GetTool("bash")
|
cmd = xs.GetTool("bash")
|
||||||
args = []string{"-c", xs.GetTool("tar") + " -cz -f /dev/stdout "}
|
//args = []string{"-c", xs.GetTool("tar") + " -cz -f /dev/stdout "}
|
||||||
|
args = []string{"-c", xs.GetTool("tar") + " -cz "}
|
||||||
files = strings.TrimSpace(files)
|
files = strings.TrimSpace(files)
|
||||||
// Awesome fact: tar actually can take multiple -C args, and
|
// Awesome fact: tar actually can take multiple -C args, and
|
||||||
// changes to the dest dir *as it sees each one*. This enables
|
// changes to the dest dir *as it sees each one*. This enables
|
||||||
|
|
@ -338,6 +347,7 @@ func buildCmdLocalToRemote(copyQuiet bool, copyLimitBPS uint, files string) (cap
|
||||||
// remote destDir.
|
// remote destDir.
|
||||||
for _, v := range strings.Split(files, " ") {
|
for _, v := range strings.Split(files, " ") {
|
||||||
v, _ = filepath.Abs(v) // #nosec
|
v, _ = filepath.Abs(v) // #nosec
|
||||||
|
v = xs.GroomFsPath(v)
|
||||||
dirTmp, fileTmp := path.Split(v)
|
dirTmp, fileTmp := path.Split(v)
|
||||||
if dirTmp == "" {
|
if dirTmp == "" {
|
||||||
args[1] = args[1] + fileTmp + " "
|
args[1] = args[1] + fileTmp + " "
|
||||||
|
|
@ -386,6 +396,8 @@ func doCopyMode(conn *xsnet.Conn, remoteDest bool, files string, copyQuiet bool,
|
||||||
c.Stderr = os.Stderr
|
c.Stderr = os.Stderr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//fmt.Printf("cmd:%v args:%v\n", cmdName, cmdArgs)
|
||||||
|
|
||||||
// Start the command (no pty)
|
// Start the command (no pty)
|
||||||
err = c.Start() // returns immediately
|
err = c.Start() // returns immediately
|
||||||
/////////////
|
/////////////
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue