Postinstall scripts
From RockWiki
As of late August 2005 ROCK has support for postinstall and postremove scripts. These are scripts that are executed after a package has been installed (as opposed to after the package has been built). This can for example be used to create ssh-keys after the openssh package has been installed and things like that.
Creating Postinstall Script
To create a postinstall script for a package, simply create a file called postinstall.sh in the package directory (for example: rock-src/package/blindcoder/dgamelaunch/postinstall.sh) and it will be copied to the proper location. The usual ROCK Substitutions apply.
Within the script you have the following helper functions available:
- is_installed() and is_removed()
These functions exlicitly check if a specific file exists (is installed) or does not exist (is removed), respectively.
- any_installed() and any_removed()
These functions accept a grep pattern as their argument and return true if any files from the postinstall or postremove logs that match this pattern are installed or removed, respectively.
- all_installed() and all_removed()
These functions also accept a grep pattern and return all files from the postinstall or postremove logs that match this pattern and are installed or removed, respectively.
Examples:
if any_installed ".*\.so"; then echo "dynamic libraries installed, run ldconfig!" fi
if any_removed ".*\.so"; then echo "dynamic libraries removed, run ldconfig!" fi
If any files ending in .so got installed or removed the user will be reminded to run ldconfig.
all_installed ".*" | while read M; do echo "Installed: $M"; done
all_removed ".*" | while read M; do echo "Removed: $M"; done
All installed and all removed files will be listed.
For more examples you can look through the rock-src/package/*/*/postinstall.sh scripts.