= ptrcnull.me =
writeups and other stuff

How to use Alpine Linux commit hooks


  • Create directory /etc/apk/commit_hooks.d
  • Put your executable files in there
  • First argument passed to your script is the stage (pre-commit/post-commit)

Example hook


if ! mount | grep -q '/boot/efi'; then
	mount /boot/efi

if [[ "$1" == "post-commit" ]]; then
	cp /boot/initramfs-lts /boot/efi/alpine/initramfs-lts
	cp /boot/vmlinuz-lts /boot/efi/alpine/vmlinuz-lts


I use Gummiboot as my bootloader, which can boot Linux kernel images directly from the EFI partition. Alpine packages don’t care about EFI though, they just put the stuff in /boot directly. (I mean, the official wiki just says “manually copy them to /boot/efi/”, which works but I tend to forget about it)

I didn’t want to mount EFI as /boot, so I decided that creating a commit hook would be the easiest way of hotfixing that issue (not ideal, as it runs with every apk commit, but feasible for my use).