You are not logged in.
Hi everyone,
I have semi-recently migrated to Arch one peculiar machine of mine that is mainly used as a teaching platform to introduce people to the greatness of the perf profiler, often in remote locations with an unreliable Internet connection. Because of its system-wide profiling/tracing platform nature, this machine should have access to as much debug info as possible. And because of its non-ideal network environment, it should not rely on debuginfod to get it. Instead it should have -debug packages installed the old-fashioned way during those times where it's connected to a reliable network connection.
Knowing this, I added the core-debug and extra-debug repositories from geo.mirror.pkgbuild.com as directed in the Arch wiki, and installed the debug info for all currently installed packages with "paru -Syu $(pacman -Qsq | rg -v -- '-debug$' | sed -e 's/$/-debug/g')". And this part worked mostly fine (sure, a few packages did not have debug info, but that's okay, I can live with that).
However, in the interest of easing future maintenance, I would now like to hook into pacman/libalpm so that whenever I install a non-debug package on this machine in the future, the matching -debug package is also installed if available. And conversely, whenever I remove a package, the matching -debug package is auto-removed.
I thought about writing an Install/Remove PostTransaction libalpm hook for this. But after reading the alpm-hooks man page, I have more questions than answers. For example, it's not clear from this page whether hooks are run once per package or once per transaction (from pacman's behavior, I would expect they are called once per transaction?), nor if they have access to the list of packages that are being added/removed.
Is there some more complete documentation somewhere that I missed? Or can someone more familiar with the underlying machinery give me some pointers here?
Thanks in advance!
Last edited by HadrienG (2025-03-06 14:40:51)
Offline
Yes alpm-hooks are ran once per transaction and you have the NeedsTargets option that will give you the list of matched target packages. What I'm less than sure is whether they should be abused in order to manipulate the following transaction nor start a new transaction themselves.
I'd say if you want to do this a wrapper script is the better option resp. your PostTransaction hook should write a list of matched targets to a file (in /tmp/ or so) which can then be parsed by you to invoke pacman again (when invoking pacman again pacman -Syu --needed will be your friend to not install dupes unnecessarily).
Last edited by V1del (2025-03-06 17:11:28)
Offline
Thanks, I did not think about adding a wrapper script to the mix, and this approach also elegantly answers another question that I was asking myself, which is how to prevent infinite recursion (or deadlock, depending on whether the database lock is released before/after the PostTransaction hook) with a package hook that installs more packages.
I'll give it a try!
Last edited by HadrienG (2025-03-08 06:26:09)
Offline