holo icon indicating copy to clipboard operation
holo copied to clipboard

Use pacman hooks to apply changes

Open WhyNotHugo opened this issue 2 years ago • 0 comments

Currently, holoscripts get run by basically including this .install script in each package:

#!/bin/sh

post_install() {
  holo apply
}

post_upgrade() {
  holo apply
}

post_remove() {
  holo apply
}

.install scripts are discouraged whenever possible and treated somewhat of a last resort. In this case, it is possible to use a pacman hook (e.g.: in /usr/share/libalpm/hooks) that runs holo apply when a new files are placed into /usr/share/holo/files/ (or updated, or removed). The hook can be provided by the holo package itself, and also allows non-holo packages to just slip in holoscripts and alike.

This would also ensure that holo apply one gets run once per transaction after packages are installed, rather than once per package.

The hook would be quite trivial, and is a bit more of a declarative (rather than imperative) approach. A vague (poorly tested) sample is something like:

[Trigger]
Type = Path
Operation = Install
Operation = Upgrade
Operation = Remove
Target = /usr/share/holo/files/*

[Action]
Description = Applying holoscripts
When = PostTransaction
Exec = /usr/bin/holo apply

I will try and make a PR with this, but would like to hear any thoughts or feedback you may have before further digging into this.

WhyNotHugo avatar Jul 27 '22 13:07 WhyNotHugo