简体   繁体   English

如何在通过packagemaker shell命令构建的安装程序中包含预安装脚本?

[英]How do you include a preinstall script in an installer built via the packagemaker shell command?

I'm creating an installer via the packagemaker command as part of a script. 我正在通过packagemaker命令创建一个安装程序作为脚本的一部分。 I create the folder hierarchy in stagedRootPath and then use the --root parameter to build the installer. 我在stagedRootPath创建文件夹层次结构,然后使用--root参数构建安装程序。 The problem is that I want to install things in the installing user's home directory, which I don't know when I build the installer. 问题是我想在安装用户的主目录中安装东西,我在构建安装程序时不知道。 I doubt you can have some sort of variables substitution in the install path if you use the --root option. 我怀疑如果使用--root选项,可以在安装路径中进行某种类型的变量替换。

My workaround idea is to have a preflight script creates a symlink to the current user's home directory and install the files through that (ie. ln -s ~ /tmp/home ). 我的解决方法是让预检脚本创建到当前用户主目录的符号链接,并通过该目录安装文件(即ln -s ~ /tmp/home )。 I know how to include a script via the GUI PackageMaker app, but I can't use that as this is part of a script. 我知道如何通过GUI PackageMaker应用程序包含脚本,但我不能使用它,因为这是脚本的一部分。

Is there a way to include it via the command? 有没有办法通过命令包含它? Do I have to use a .pmdoc or can I avoid it? 我必须使用.pmdoc还是可以避免使用它? If I have to use a pmdoc, can I create it programmatically? 如果必须使用pmdoc,可以通过编程方式创建它吗?

Other solutions to installing in the install-time home directory are welcome. 欢迎在安装时主目录中安装其他解决方案。

# my install command
packagemaker --root stagedRootPath -id com.myinstaller --title myInstallerTitle

Turns out you can do this by putting scripts into a folder with the correct names and using the --scripts option. 事实证明,您可以通过将脚本放入具有正确名称的文件夹中并使用--scripts选项来执行此操作。

 preflight
 preinstall    or preupgrade
 postinstall   or postupgrade
 postflight

(More details in the man page .) 手册页中有更多详细信息。)

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

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