简体   繁体   English

osx-在pkg安装过程中删除文件

[英]osx - remove files as part of pkg installation

Using pkgbuild I create installer for my OSX application. 使用pkgbuild为OSX应用程序创建安装程序。 Is there any way to add extra install step, which will delete some files? 有什么方法可以添加额外的安装步骤,从而删除一些文件? In this particular example - when I run my application it creates new file in directory where binary is located. 在此特定示例中-当我运行我的应用程序时,它将在二进制文件所在的目录中创建新文件。 Installation of new version replaces binary, but leaves that previously created file. 安装新版本将替换二进制文件,但保留先前创建的文件。 I need "fresh start" after installation of new version. 安装新版本后,我需要“重新启动”。

You can add a postinstall script to your package and delete all the files that are not required any more. 您可以将后安装脚本添加到程序包中,然后删除不再需要的所有文件。 Create a shell script and put your code for deleting those files in it. 创建一个shell脚本,并在其中添加用于删除这些文件的代码。 Name that script postinstall (without extension) and put is in a folder named script. 将该脚本命名为postinstall(无扩展名),然后放在名为script的文件夹中。 Create your package with this command: 使用以下命令创建软件包:

/usr/bin/pkgbuild \
    --root "$ROOT_LOCATION" \
    --install-location "$INSTALL_LOCATION" \
    --identifier "$IDENTIFIER" \
    --version "$VERSION" \
    --scripts "scripts" \
    "$NAME.pkg"

when the installer runs the postinstall script it also passes some useful information as the path on which the script is running and so on. 当安装程序运行后安装脚本时,它还会传递一些有用的信息作为脚本运行所在的路径,依此类推。 You can read these information as input arguments $1, $2, ... 您可以将这些信息作为输入参数$ 1,$ 2,...读取。

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

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