【问题标题】:Running postflight script when installing a package on Mac在 Mac 上安装包时运行 postflight 脚本
【发布时间】:2023-03-20 19:40:02
【问题描述】:

我正在尝试从脚本构建 mac 包安装程序,并且我想运行 postinstall 和 postflight 脚本。我构建包的脚本如下所示:

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

我已将安装后脚本放在 Scripts 中,它正在成功执行。不过,我在运行 postflight 脚本时遇到问题。它被放置在 Resources 目录中并且不会被执行。这还不足以指定它的路径吗?我找不到这个问题的答案,如果我错过了,我很抱歉。

PS:我的 postflight 脚本没有什么特别的 - 现在它尝试在主目录中创建一个文件:

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

【问题讨论】:

  • 这怎么可能与错字“Scirpts”一起使用?!

标签: macos installation packagemaker productbuild pkgbuild


【解决方案1】:

我不确定你为什么在一个包中同时拥有postinstallpostflight。两者都是相同的脚本,必须在安装的“复制文件”阶段之后运行。 “postflight”名称用于旧式包 - 捆绑包。 引入扁平包后,相同的脚本必须命名为“postinstall”。 在平面包中,安装程序仅当文件名为“postinstall”而不是“postflight”并且存在于“Scripts”目录而非“Resources”目录中时,才会将其视为安装后脚本。 可能这就是你的脚本没有被执行的原因。

您可以获取有关包中使用的脚本here 的更多信息。

【讨论】:

  • 我已经像以前一样尝试使用 post_install 了将近一个小时 :) 非常感谢 :)
  • 不错的帖子@Vikram Singh
  • 额外提示:我的脚本似乎命名正确,但它们不起作用。直到我注意到他们的扩展名 .command 被 MacOS 隐藏。一旦我删除了 .command,一切都很好。
猜你喜欢
  • 2013-03-17
  • 2011-01-06
  • 2022-10-05
  • 1970-01-01
  • 1970-01-01
  • 2017-02-01
  • 2018-05-28
  • 2013-12-24
  • 2021-04-14
相关资源
最近更新 更多