-
Notifications
You must be signed in to change notification settings - Fork 3
/
pkg.sh
executable file
·38 lines (26 loc) · 1.01 KB
/
pkg.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
appName="PyThub PyInstaller Desktop"
# MacDeveloperID="3rd Party Mac Developer Installer: Developer Name (XXXX)"
MacDeveloperID="Developer ID Installer: CROGRAM INC. (4LWSS9P873)"
# rm -rf ./build/pkg
mkdir ./build/pkg
appPath=./dist/"$appName".app
pkgPath=./dist/"$appName".pkg
# 生成中间 PKG 文件
pkgbuild --install-location /Applications --component "$appPath" ./build/pkg/intermediate.pkg
cd ./build/pkg
# 创建分发 XML 文件
productbuild --synthesize --package ./intermediate.pkg ./distribution.xml
# 生成最终的 PKG 文件。此 PKG 文件未签名
productbuild --distribution ./distribution.xml --package-path ./intermediate.pkg ./unsigned_final.pkg
if ["$MacDeveloperID" = ""]; then
# 未签名
mv ./unsigned_final.pkg ./final.pkg
else
# 使用 Mac 开发人员 ID 证书对 PKG 文件进行签名
productsign --sign "$MacDeveloperID" ./unsigned_final.pkg ./signed_final.pkg
mv ./signed_final.pkg ./final.pkg
fi
cd -
# rm "$pkgPath"
mv ./build/pkg/final.pkg "$pkgPath"