mirror of https://github.com/perkeep/perkeep.git
make.go: preserve executable bit when copying binaries to bin
Change-Id: Ia2c415aaaa2ab5ffa52766f5adfb4f5af7377961
This commit is contained in:
parent
43135068a5
commit
b377055f1f
8
make.go
8
make.go
|
@ -497,6 +497,10 @@ func mirrorDir(src, dst string) (maxMod time.Time, err error) {
|
|||
|
||||
var wantDestFile = make(map[string]bool) // full dest filename => true
|
||||
|
||||
func isExecMode(mode os.FileMode) bool {
|
||||
return (mode & 0111) != 0
|
||||
}
|
||||
|
||||
func mirrorFile(src, dst string) error {
|
||||
wantDestFile[dst] = true
|
||||
sfi, err := os.Stat(src)
|
||||
|
@ -508,6 +512,7 @@ func mirrorFile(src, dst string) error {
|
|||
}
|
||||
dfi, err := os.Stat(dst)
|
||||
if err == nil &&
|
||||
isExecMode(sfi.Mode()) == isExecMode(dfi.Mode()) &&
|
||||
(dfi.Mode()&os.ModeType == 0) &&
|
||||
dfi.Size() == sfi.Size() &&
|
||||
dfi.ModTime().Unix() == sfi.ModTime().Unix() {
|
||||
|
@ -538,6 +543,9 @@ func mirrorFile(src, dst string) error {
|
|||
if err == nil {
|
||||
err = cerr
|
||||
}
|
||||
if err == nil {
|
||||
err = os.Chmod(dst, sfi.Mode())
|
||||
}
|
||||
if err == nil {
|
||||
err = os.Chtimes(dst, sfi.ModTime(), sfi.ModTime())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue