Pacman hooks of host can break chroot creation
Right now we do not set HookDir
in the pacman
configs, thus it uses the default hook directory /etc/pacman.d/hooks
.
For example in extra.conf
:
https://gitlab.archlinux.org/archlinux/devtools/-/blob/f31ea3a48ebea33f85bcd682c72848cadebb7ad1/config/pacman/extra.conf#L17
Because HookDir
is not relative to the chroot directory, this means we're executing the hosts' hooks inside the new chroot we're creating, which can break if hooks have dependencies that are not satisfied.
See https://bugs.archlinux.org/task/49347
To reproduce: Add any hook in your /etc/pacman.d/hooks
with an Depends=
on a package that will not be present in the new chroot. Then try to create a new chroot. pacman
will try and fail to execute the hook:
$ extra-x86_64-build -c
==> Creating chroot for [extra] (x86_64)...
==> Creating install root at /var/lib/archbuild/extra-x86_64/root
==> Installing packages to /var/lib/archbuild/extra-x86_64/root
[...]
error: unable to run hook example.hook: could not satisfy dependencies
error: failed to commit transaction (failed to run transaction hooks)
Errors occurred, no packages were upgraded.
==> ERROR: Failed to install packages to new root
==> ERROR: Failed to install all packages
==> ERROR: Aborting...
To resolve this, we could probably set HookDir
to an empty directory in all our pacman
configs to ensure there are no hooks to be executed. Tested that locally and that seems to work, though I'm not sure if that will have unintended side-effects.
EDIT: Changed example to use -c
so we're reproducing with a clean chroot.