Add guarded UPX exe packing flow
This commit is contained in:
1 parent
11de0f75c7
commit
abcee63776
4 files changed
+251
-1
No files matched your search
@@ -29,6 +29,14 @@ powershell -NoProfile -ExecutionPolicy Bypass -File packaging\pyinstaller\build_
|
||||
|
||||
注意:PyArmor 试用版会在混淆文件头部留下 trial 标记,正式分发前建议购买/配置正式授权后重新打包。
|
||||
|
||||
如果要尝试对根目录 exe 做 UPX 加壳/压缩,可额外加 `-PackExe -UpxDir <UPX目录>`:
|
||||
|
||||
```powershell
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File packaging\pyinstaller\build_windows.ps1 -SkipInstall -Obfuscate -PackExe -UpxDir C:\path\to\upx
|
||||
```
|
||||
|
||||
当前 PyInstaller 生成的 exe 带 `GUARD_CF`,UPX 默认会拒绝压缩。脚本提供 `-PackExeForce` 仅用于实验;验证中它会导致 exe 启动失败并报 `Failed to load Python DLL`,脚本已加入加壳后 smoke 检查,失败会中止打包。正式分发目前建议使用 `-Obfuscate`,不要启用 `-PackExeForce`。
|
||||
|
||||
如果要生成带本地授权的测试包,先生成当前机器的 `license.dat`:
|
||||
|
||||
```powershell
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
param(
|
||||
[string]$Version = "",
|
||||
[switch]$SkipInstall,
|
||||
[switch]$Obfuscate
|
||||
[switch]$Obfuscate,
|
||||
[switch]$PackExe,
|
||||
[switch]$PackExeForce,
|
||||
[string]$UpxDir = ""
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
@@ -85,6 +88,20 @@ if (Test-Path $licensePath) {
|
||||
|
||||
Copy-Item -LiteralPath (Join-Path $Root "README.md") -Destination (Join-Path $DistRoot "README.md") -Force
|
||||
|
||||
if ($PackExe) {
|
||||
$PackArgs = @($DistRoot)
|
||||
if ($UpxDir) {
|
||||
$PackArgs += @("--upx-dir", $UpxDir)
|
||||
}
|
||||
if ($PackExeForce) {
|
||||
$PackArgs += "--force"
|
||||
}
|
||||
python -m tools.exe_packing @PackArgs
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "UPX packing failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
}
|
||||
|
||||
python -m tools.distribution_manifest $DistRoot
|
||||
|
||||
Write-Host "[OK] Portable package: $DistRoot"
|
||||
|
||||
Reference in new issue
Block a user