You are not logged in.
Hi,
Is there anyway to notify the systemd service files included during installation of a package through pacman hook?
Offline
You mean you want to notify the user? Yes, just echo your message from the hook. But you shouldn't. A substantial portion of packages come with service files, this is expected, so there is no reason to go out of your way to announce it.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Sorry if I was not clear in my post. English is not my first language.
What I meant was that when I install a package, I want to see the systemd service files included in the package. I guess that can be achieved by a custom pacman hook script which can display the service files in terminal at the end of installation. I know how a pacman hook script works and how to create one. But I don't know the executable command to display those service files.
Thanks.
Offline
Oh, this should work, but it is completely untested:
[Trigger]
Operation = Install
Operation = Upgrade
Type = Path
Target = usr/lib/systemd/*/*
[Action]
Description = TODO
When = PostTransaction
Exec = sed -n 's/.*\///p'
NeedsTargets
This assumes that all service files are installed under /usr/lib/systemd/*/. I think that this is a reasonable assumption, but if you wanted you could instead change the target, e.g.
Target = *.service
Target = *.socket
# ... etc
Or if you really just want true service files, then just `Target = "*.service"` would be best.
In any case, the NeedsTargets passes all matching paths / files to the Exec line stdin. Then sed just trims everything up to the last / to get the basename.
Alternatively you could use `Exec = basename -a $(cat)`
Last edited by Trilby (2024-07-26 17:46:50)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Oh, this should work, but it is completely untested:
[Trigger] Operation = Install Operation = Upgrade Type = Path Target = usr/lib/systemd/*/* [Action] Description = TODO When = PostTransaction Exec = sed -n 's/.*\///p' NeedsTargets
This assumes that all service files are installed under /usr/lib/systemd/*/. I think that this is a reasonable assumption, but if you wanted you could instead change the target, e.g.
Target = *.service Target = *.socket # ... etc
Or if you really just want true service files, then just `Target = "*.service"` would be best.
In any case, the NeedsTargets passes all matching paths / files to the Exec line stdin. Then sed just trims everything up to the last / to get the basename.
Alternatively you could use `Exec = basename -a $(cat)`
Perfect, thank you so much. That's exactly I was looking for.
Offline