Hooks can be used in order to change the runtime behaviour of the package manager. There are a variety of package hooks, mostly self explanatory:
Run just before the build script is run
Run after the build script is run successfully
Run if the build script fails
Run before the test script is run
Run if the test script fails
Run before a package is installed for each package
Run after a package is installed for each package
Run after all given packages are installed
Run before a package is removed for each package
Run after a package is removed for each package
Run after all given packages are removed
Run before all repositories are fetched
Run after all repositories are fetched
Run after a tarball for a package is created
In order to use hooks, you will need to set the ‘CPT_HOOK’ variable pointing to your hook file. Your hook file MUST be a POSIX shell script as its contents are sourced by the package manager.
The hook is given 3 variables when it is executed. Those are:
$TYPEThe type of the hook, (‘pre-build’, ‘post-build’, etc.)
$PKGThe package that ‘cpt’ is currently working on. Can be null.
$DESTThe destination of the operation. Can be null.