需要使用pkgbuild在组件包中重新启动 [英] Requiring restart in component package using pkgbuild

查看:224
本文介绍了需要使用pkgbuild在组件包中重新启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在更新一些构建脚本以使用pkgbuild而不是PackageMaker,但是我没有看到要求重新启动组件包的选项.在PackageMaker中,可以使用以下两种方法之一重新启动:

I'm updating some build scripts to use pkgbuild instead of PackageMaker, but I'm not seeing an option to require restarts on a component package. In PackageMaker, requiring a restart could be done using either of the following two methods:

  • (旧版兼容模式)在Info.plist中,将IFPkgFlagRestartAction设置为RequiredRestart.
  • 在PackageInfo文件中,将pkg-info> postinstall-action设置为重新启动.

我没有看到pkgbuild或其组件包plist的任何类似选项.我了解到,当我们使用productbuild构建发行版时,我们可以选择使用发行版文件的pkg-ref> onConclusion密钥以每个软件包为基础重新启动.但这是现在唯一的方法(不使用PackageMaker)吗?如果是这样,我想知道为什么将这一要求从组件包中移出并转移到依赖于它们的发行版中.在我看来,组件包在可以指定自己的需求时仍然保持模块化.

I don't see any similar options for pkgbuild or its component package plist. I understand that, when we build our distribution using productbuild, we can choose to require a restart on a per-package basis using the distribution file's pkg-ref>onConclusion key. But is this the only way to do this now (without using PackageMaker)? If so, I'm wondering why this requirement was moved out of the component packages and into the distribution that depends on them. In my mind, the component packages remained more modular when they could specify their own requirements.

编辑:如果在结果PackageInfo中设置postinstall-action ="restart",则可以强制重新引导.现在的问题是,如何教pkgbuild自动将其写入PackageInfo文件.

If you set postinstall-action="restart" in the resulting PackageInfo you can force the reboot. Now the question is just how to teach pkgbuild to write that automatically to the PackageInfo-file.

推荐答案

不可能通过参数或component.plist

It is not possible to accomplish this through a parameter or the component.plist

因此,我是通过shell脚本来扩展,编辑和展平该包的:

Therefore I did it by expanding, editing and flattening the package via a shell-script:

#Replace the value of the postinstall-action attribute to restart
echo "Expanding archive ${BDIR}/${NAME}-Installer.pkg"
pkgutil --expand "Installer.pkg" installertmp

echo "Replacing postinstall-action \"none\" with \"restart\""
sed -e 's/postinstall-action=\"none\"/postinstall-action=\"restart\"/' -i '' installertmp/PackageInfo

echo "Flattening archive Installer.pkg"
pkgutil --flatten installertmp "Installer.pkg"

rm -f -r "installertmp"

这篇关于需要使用pkgbuild在组件包中重新启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆