feat: 支持多APK与渠道变体,增加自动定位的服务管理CLI

This commit is contained in:
tongtong committed 2026-11-25 16:10:05 +08:00
1 parent 7984785610
commit 87652364bc
33 files changed
+1110 -42

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
//go:build !windows
package main
import (
"os"
"path/filepath"
"syscall"
)
func preserveAccessOwnership(temp, target string) error {
source := target
info, e := os.Stat(source)
if os.IsNotExist(e) {
source = filepath.Dir(target)
info, e = os.Stat(source)
}
if e != nil {
return e
}
if stat, ok := info.Sys().(*syscall.Stat_t); ok {
current, e := os.Stat(temp)
if e != nil {
return e
}
existing := current.Sys().(*syscall.Stat_t)
if existing.Uid != stat.Uid || existing.Gid != stat.Gid {
if e = os.Chown(temp, int(stat.Uid), int(stat.Gid)); e != nil {
return e
}
}
}
mode := os.FileMode(0600)
if source == target {
mode = info.Mode().Perm()
}
return os.Chmod(temp, mode)
}