build forkapp OK
This commit is contained in:
parent
bb7e05ef25
commit
fcd7f7200c
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
||||
|
||||
forkapp/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"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
type ChangePathFunc func(srcFile, dstFile string) string
|
||||
@ -23,12 +22,7 @@ func CopyDirectory(scrDir, dest string, overwrite bool, changePathFn ChangePathF
|
||||
return err
|
||||
}
|
||||
|
||||
var statOk bool
|
||||
stat, ok := fileInfo.Sys().(*syscall.Stat_t)
|
||||
if ok {
|
||||
statOk = true
|
||||
}
|
||||
|
||||
ostat := fileInfo.Sys()
|
||||
destPath := filepath.Join(dest, entry.Name())
|
||||
destPath = changePathFn(sourcePath, destPath)
|
||||
|
||||
@ -50,10 +44,9 @@ func CopyDirectory(scrDir, dest string, overwrite bool, changePathFn ChangePathF
|
||||
}
|
||||
}
|
||||
|
||||
if statOk {
|
||||
if err := os.Lchown(destPath, int(stat.Uid), int(stat.Gid)); err != nil {
|
||||
return err
|
||||
}
|
||||
err = chown(destPath, ostat)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
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
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user