Creating a Installpackage for mac I have a lot of Programms that i always need to install to a new mac. I wanted to simplify this process through an installpackage. I allready tried Iceberg with some success but have a specific error. What i want to do with iceberg is to unpack all the packages and start a script to install it and delete the packages after. I can make a package that unpacks the packages in my destination but the iceberg Programm wont execute the script i add in postinstall. the script itself works fine when i use it through terminal. the Script i am using is

##!/usr/bin/env bash
sudo installer -pkg /Library/Virtualbox.pkg -target /


iceberg packs the script in the programm but never uses it.
There is an error in the postinstall script. The first line should contain only one hash (#):

#!/usr/bin/env bash


If the .pkg works with installer and Installer.app, then it is a correct package. All other tools are made by third parties and may not support the latest pkg formats and features.

Lacking Permission?

Using sudo in your package script may cause the script to pause forever or instantly fail. How will the sudo command interact with the user to get the super user's credentials?

Remove sudo and make your script test for permission to install before continuing, otherwise print an error and exit:

if [[ $EUID -ne 0 ]]; then
  echo "You must be a root to run this script" 2&gt;&amp;1
  exit 1
fi


It is the responsibility of installer to gain the appropriate authorisation rights and run the package's scripts using those rights. Within your package, specify that it needs administrator rights to ensure this happens.

Logs and Errors

Use the verbose flag with installer to see each step of the installation process and to see errors:

sudo installer -verbose -pkg /Library/Virtualbox.pkg -target /


Apple Package Tools

Installer packages on OS X are typically built with the tools pkgbuild and productbuild. These two Apple tools support pre and post scripts; see the --scripts flag.

AutoPkg

Mac system administrators often use the open source autopkg tool to create packages:


  AutoPkg is an automation framework for OS X software packaging and distribution, oriented towards the tasks one would normally perform manually to prepare third-party software for mass deployment to managed clients.


You may find AutoPkg is a better approach to simplifying the setting up of new Macs.