pachooks - sample hooks for libalpm/pacman
- check-boot - check that /boot is mounted before trying to modify it
- check-suid - print post-install warnings for suid/getcap binaries
- fc-cache - rebuild system font information cache
- info-install, info-remove - update info file database
- mkfontscale-otf, mkfontscale-ttf - update X11 scalable font name files
- mkfontdir-otf, mkfontscale-ttf - update X11 bitmap font name files
- snapshot-pre-snapper, snapshot-post-snapper - take filesystem snapshots
- sync - sync storage caches to reduce the risk of file system corruption
- update-desktop-database - update cache database for .desktop files
Hooks vs Install Scripts
Hooks and scripts each fill a different packaging niche. Install scripts are included directly in the package that runs them and are run immediately prior to installation or removal of the package. Hooks may be provided by any package, not necessarily the one(s) that trigger it, or the user and are run before or after the transaction. Hooks are generally preferable for any tasks that need to be repeated for a number of packages. Any essential tasks (e.g. rebuilding the initramfs after a kernel update) should either be run in a
PreTransaction hook or continue to use an install script due to the risk of post-transaction hooks not running if the transaction is interrupted.
Running hooks in the background
Running hooks in the background is generally discouraged; it prevents alpm from capturing their output and subsequent hooks cannot be sure previous hooks have finished. For long-running processes that produce no output and only modify files/directories that are considered volatile anyway, however, this may be acceptable. In order to run a process in the background, its
stderr file descriptors must be closed or redirected and it must be run inside a forked environment. Using a POSIX-compatible shell, this can be accomplished with:
Exec = /bin/sh -c '<cmd> <&- >&- 2>&1 &'
Exec = /bin/sh -c 'mkdir -p /var/cache/man; mandb --quiet <&- >&- 2>&- &'
COPYRIGHT AND LICENSE
Copyright 2015-2016 Andrew Gregory <email@example.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.