You are not logged in.

#1 2024-07-26 16:03:47

rhinjard
Member
Registered: 2022-08-21
Posts: 6

Custom pacman hook to notify systemd service file

Hi,
Is there anyway to notify the systemd service files included during installation of a package through pacman hook?

Offline

#2 2024-07-26 16:36:29

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: Custom pacman hook to notify systemd service file

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

#3 2024-07-26 16:54:21

rhinjard
Member
Registered: 2022-08-21
Posts: 6

Re: Custom pacman hook to notify systemd service file

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

#4 2024-07-26 17:41:52

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: Custom pacman hook to notify systemd service file

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

#5 2024-07-26 18:04:21

rhinjard
Member
Registered: 2022-08-21
Posts: 6

Re: Custom pacman hook to notify systemd service file

Trilby wrote:

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

Board footer

Powered by FluxBB