對於有類似問題的其他人,正確的答案是你不能使用productbuild來做到這一點,但你可以使用pkgbuild。
我爲App Store productbuild生成步驟是這樣的:
productbuild --component "{mystoreapp.app/}" /Applications --sign "{signing identity}" "{mystorepkg.pkg}"
的PKGBUILD相應的包裝命令如下:
pkgbuild --component "{mymodifiedapp.app/}" --sign "{signing identity}" --ownership preserve --scripts "{path/to/my/scripts}" --identifier {com.yourcompany.yourapp} --version "{versionNumber}" --install-location /Applications "{mymodifiedpkg.pkg}"
注意簽署是可選在這裏,因爲它會在店外散發。其中{路徑/要/我的/腳本}有一個文件名爲它postinstall
,看起來像這樣:
#this function creates a directory if it doesn't exist
create_directory() {
if [[ ! -d "$1" ]]
then
if [[ ! -L "$1" ]]
then
echo "directory $1 doesn't exist. Creating now"
mkdir "$1"
echo "directory $1 created"
else
echo "directory $1 exists"
fi
fi
}
#this function gives all users read and write (and execute) access to the directory
fix_dir_permissions() {
chmod 777 "$1"
}
baseDirName="/Library/Application Support/{your app name bere}"
subDirs[0]="$baseDirName/{sub dir here}"
#create base directory
create_directory "$baseDirName"
#create all subdirectories and give permissions
for subDir in "${subDirs[@]}"
do
create_directory "$subDir"
fix_dir_permissions "$subDir"
done
exit 0
這個腳本後,將運行安裝已經結束,將創建應用程序的支持目錄,以及任何您需要的子目錄並更改它們的權限,以便所有用戶都可以訪問它們。