简体   繁体   English

在 Mac 上安装软件包时运行 postflight 脚本

[英]Running postflight script when installing a package on Mac

I am trying to build a mac package installer from a script and I want to run postinstall and postflight scripts.我正在尝试从脚本构建 mac 包安装程序,并且我想运行 postinstall 和 postflight 脚本。 My script for building the package looks like this:我用于构建包的脚本如下所示:

pkgbuild --root MyRoot/MyApp.app --identifier com.myapp.MyApp --scripts Scripts --install-location /Applications/MyApp.app MyApp.pkg
productbuild --synthesize --package MyApp.pkg Distribution.xml
productbuild --distribution Distribution.xml --resources Resources --package-path . CompleteInstaller.pkg

I've placed the postinstall script in Scripts and it is being executed successfully.我已将 postinstall 脚本放在 Scripts 中,并且它正在成功执行。 I have a problem with running the postflight script though.但是,我在运行 postflight 脚本时遇到了问题。 It is placed in the Resources directory and doesn't get executed.它被放置在 Resources 目录中并且不会被执行。 Is this not enough to specify the path to it?这还不足以指定它的路径吗? I couldn't find an answer to this question, I'm sorry if I've missed it.我找不到这个问题的答案,如果我错过了,我很抱歉。

PS: My postflight script does nothing special - for now it tries to create a file in the home directory: PS:我的 postflight 脚本没有什么特别的 - 现在它尝试在主目录中创建一个文件:

#!/bin/sh
touch ~/file
exit 0

I am not sure why do you have both postinstall and postflight in a package.我不知道你为什么在一个包中同时包含postinstallpostflight Both are same scripts which must be run after the "copy files" phase of the installation.两者都是相同的脚本,必须在安装的“复制文件”阶段之后运行。 " postflight " name was used in older style packages - bundles. postflight ”名称用于旧式包 - 包。 After the introduction of flat packages, the same script has to be named as " postinstall ".在引入平面包之后,相同的脚本必须命名为“ postinstall ”。 In flat packages, installer treats a file as a postinstall script only if its name is "postinstall", not "postflight" and is present inside " Scripts " directory, not " Resources " directory.在平面包中,只有当文件名为“postinstall”而不是“postflight”并且存在于“ Scripts ”目录而非“ Resources ”目录中时,安装程​​序才会将文件视为安装后脚本。 Probably, this is the reason your script is not being executed.可能这就是您的脚本没有被执行的原因。

You can get some more information regarding scripts used in packages here .您可以在此处获取有关包中使用的脚本的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM