build forkapp OK
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,5 @@
|
|||||||
|
|
||||||
forkapp/forkapp
|
forkapp/forkapp
|
||||||
tools/forkapp
|
tools/forkapp
|
||||||
|
forkapp/forkapp.exe
|
||||||
|
tools/forkapp.exe
|
||||||
|
|||||||
5
forkapp/build.sh
Executable file
5
forkapp/build.sh
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -a -ldflags '-s -w -extldflags "-static"' -o forkapp
|
||||||
|
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -trimpath -a -ldflags '-s -w -extldflags "-static"' -o forkapp.exe
|
||||||
|
|
||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"syscall"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ChangePathFunc func(srcFile, dstFile string) string
|
type ChangePathFunc func(srcFile, dstFile string) string
|
||||||
@@ -23,12 +22,7 @@ func CopyDirectory(scrDir, dest string, overwrite bool, changePathFn ChangePathF
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var statOk bool
|
ostat := fileInfo.Sys()
|
||||||
stat, ok := fileInfo.Sys().(*syscall.Stat_t)
|
|
||||||
if ok {
|
|
||||||
statOk = true
|
|
||||||
}
|
|
||||||
|
|
||||||
destPath := filepath.Join(dest, entry.Name())
|
destPath := filepath.Join(dest, entry.Name())
|
||||||
destPath = changePathFn(sourcePath, destPath)
|
destPath = changePathFn(sourcePath, destPath)
|
||||||
|
|
||||||
@@ -50,10 +44,9 @@ func CopyDirectory(scrDir, dest string, overwrite bool, changePathFn ChangePathF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if statOk {
|
err = chown(destPath, ostat)
|
||||||
if err := os.Lchown(destPath, int(stat.Uid), int(stat.Gid)); err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fInfo, err := entry.Info()
|
fInfo, err := entry.Info()
|
||||||
|
|||||||
19
forkapp/copydir_linux.go
Normal file
19
forkapp/copydir_linux.go
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
//go:build linux
|
||||||
|
// +build linux
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
func chown(destPath string, ostat interface{}) error {
|
||||||
|
stat, ok := ostat.(*syscall.Stat_t)
|
||||||
|
if ok {
|
||||||
|
if err := os.Lchown(destPath, int(stat.Uid), int(stat.Gid)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
8
forkapp/copydir_other.go
Normal file
8
forkapp/copydir_other.go
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
//go:build !linux
|
||||||
|
// +build !linux
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
func chown(destPath string, ostat interface{}) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user