apk(8) is the Alpine Linux package manager. Surprisingly, it lacks native logs. In this post we will learn how to work around this limitation.

In a distribution like Arch Linux that uses pacman(8), one would typically find logs in /var/log/pacman.log. You would expect Alpine Linux to follow suit and provide some /var/log/apk.log or similar, however that’s not the case.

Logs are nowhere to be found, even in the apk-* man pages. I double-checked by asking on the #alpine-linux IRC and someone confirmed this is indeed the case, and there’s an (unconfirmed) possibility the next generation of apk may add logging support.

Meanwhile, we will use etckeeper(8) to overcome this limitation.

etckeeper: set-up

etckeeper is

a collection of tools to let /etc be stored in a git, mercurial, bazaar or darcs repository. This lets you use git to review or revert changes that were made to /etc. Or even push the repository elsewhere for backups or cherry-picking configuration changes.

by Joey Hess.

It is available in the Alpine Linux repositories, just install it:

% apk add etckeeper

No configuration is needed, it works out-of-the-box, thanks to a post-install hook to initialize the git repository, and an apk commit hook to update it upon apk package operations.

etckeeper: viewing logs

Just run git log as root. Root privilege is necessary because the git repository is initialized under /etc/etckeeper. Pick your poison:

$ GIT_DIR=/etc/etckeeper doas git log
$ doas git -C /etc/etckeeper log
$ (cd /etc/etckeeper && doas git log)

Here’s what a typical log looks like, courtesy of apk-autoupdate(1)1:

commit f06255c4be4657481082406b2050ecd88e3da768
Author: root <root@localhost.localdomain>
Date:   Tue Jan 11 00:00:24 2022 -0500

    committing changes in /etc after apk run

    Package changes:

  1. Which merely does apk upgrade, automatically. More details here↩︎