Google+

Saturday, November 16, 2019

Create pkg MacOS installer with macos-installer-builder

We are going to create a pkg that copies some files to the /Library directory. We will use the tool macos-installer-builder, which could be downloaded from https://github.com/KosalaHerath/macos-installer-builder

The usage of this tool has been well explained in the github page. The default build-macos-x64.sh script requires two parameters: product name and product version. We are going to modify this script to generate a pkg installer that copies the application files into a fixed directory.

1. copy the application's files into ./application/ folder
2. comment the section in #Argument validation which validates the product name and product version parameters. Since we are not going to use the input parameters.
3. change PRODUCT and VERSION variables to strings.
4. change in function copyBuildDirectory the three commands below #Copy cellery product to /Library/Cellery, \${PRODUCT}/\${VERSION} to the fixed target directory
5. comment createUninstaller command, since I don't use it.
6. add commands in postinstall script, such as changing the permission.

Finally, run bash build-macos-x64.sh to generate the pkg installer.