diff --git a/backend/cmd/packthemed/main.go b/backend/cmd/packthemed/main.go new file mode 100644 index 0000000..9d95d37 --- /dev/null +++ b/backend/cmd/packthemed/main.go @@ -0,0 +1,39 @@ +// 按主题打壳:packtest 固定用 classic 壳,这个工具多了 theme 参数,用来出各套验证界面 +// 用法: packthemed +package main + +import ( + "fmt" + "os" + "path/filepath" + + "verification-platform-backend/internal/protect" +) + +func main() { + if len(os.Args) != 5 { + fmt.Fprintln(os.Stderr, "用法: packthemed ") + os.Exit(2) + } + src, err := os.ReadFile(os.Args[1]) + must(err) + cfg, err := os.ReadFile(os.Args[3]) + must(err) + arch, err := protect.DetectArch(src) + must(err) + theme := protect.NormalizeTheme(os.Args[4]) + + out, info, err := protect.PatchSignedThemed(src, cfg, arch, false, theme) + must(err) + must(os.WriteFile(os.Args[2], out, 0o644)) + + fmt.Printf("%-10s 架构=%s 产物=%s %d 字节 .vfy size=%d\n", + theme, arch, filepath.Base(os.Args[2]), info.OutSize, info.SecSize) +} + +func must(err error) { + if err != nil { + fmt.Fprintln(os.Stderr, "error:", err) + os.Exit(1) + } +}