Pacman Hooks
Hooks run before/after package operations — the mechanism keeping initramfs, GRUB and ACRECOVERY synced automatically.
Where they live
/usr/share/libalpm/hooks/ (shipped) and /etc/pacman.d/hooks/ (yours). Precedence to /etc.
Shipped hooks worth knowing
ls /usr/share/libalpm/hooks/
cat /usr/share/libalpm/hooks/linux.hook
Representative behaviors on AcreetionOS:
-
linux.hook → mkinitcpio -P when kernel files change
-
grub.hook → grub-mkconfig after grub/kernel updates
-
acreetion-recovery-sync → refreshes ACRECOVERY partition kernels (Managing the ACRECOVERY Partition)
-
timeshift-grub → keeps snapshot menu entries current
Anatomy of a hook
/etc/pacman.d/hooks/backup-etc.hook:
[Trigger]
Operation = Install
Operation = Upgrade
Type = Package
Target = *
[Action]
Description = Snapshotting /etc before changes...
When = PreTransaction
Exec = /usr/local/bin/etc-backup.sh
Depends = rsync
When = PreTransaction fires before anything changes — perfect for backups; PostTransaction for rebuilds.