A pkginfo item may optionally contain an installcheck_script. Install ckeck script provides a method for determining if an software item needs to be installed, where providing installs/receipts is inadequate or impractical.

Command-line tools typically installed through port (macports) or Python modules installed using easy_install or pip are prime examples as they provide no easy method for determining their installed version.

An install check_script should be written such that an exit code of 0 indicates that the item is currently not installed and should therefore be installed. All non-zero exit codes indicate that the item is installed.

An example of installcheck_script illustrating a check to determine if the current version of the argparse Python module is installed.

#!/bin/sh# Grab current version of installed python moduleversion="$(python -c 'import argparse;print argparse.__version__' 2>/dev/null)"# Compare with the version we want to installif [ ${version:-0} < 1.2.1 ]; thenexit 0elseexit 1fi

Uninstall Check Script

Optionally, an explicit uninstallcheck_script can be provided to determine whether or not an software item should be removed. In this case, the script with an exit code of 0 indicate that the item is currently installed and that removal should occur. All non-zero exit codes indicate that the item is not installed.