You are not logged in.

#1 2022-03-15 18:11:29

Retr0r0cket
Member
From: Sol III
Registered: 2021-11-24
Posts: 27

Issues Regarding Hook to Remove Orphaned Packages

I've been trying to make a hook to remove orphaned packages after any pacman upgrade, install, or removal and while the triggers work correctly, I'm having issues with my actions. When the hook is fired when it executes "/usr/bin/pacman -R $(pacman -Qqtd)", I get "/usr/bin/pacman: invalid option -- ')'" and my only solution that I know that would work is executing yay -Yc instead because I have yay installed, but I'd rather have pacman do the work here because I find the "don't run yay as sudo" output annoying (although it shouldn't cause any issues because it's just orphaned package removal... I think). Any ideas? I've tried getting it to run in bash and that hasn't helped either.

Last edited by Retr0r0cket (2022-03-15 18:15:10)

Offline

#2 2022-03-15 18:35:37

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: Issues Regarding Hook to Remove Orphaned Packages

Post your hook.
But I'd guess that it's because your command has spaces in it and you haven't escaped it properly...
https://man.archlinux.org/man/alpm-hooks.5


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#3 2022-03-15 18:38:16

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,081

Re: Issues Regarding Hook to Remove Orphaned Packages

The Exec line is not a shell and I generally doubt you should manipulate the pacman database while pacman is running/a transaction happening. Make a wrapper script that runs the command afterwards instead.

The literal answer to your question is

/usr/bin/bash -c "pacman -R $(pacman -Qqtd)"

Offline

#4 2022-03-15 18:57:07

Retr0r0cket
Member
From: Sol III
Registered: 2021-11-24
Posts: 27

Re: Issues Regarding Hook to Remove Orphaned Packages

Here's the hook for reference. Ty @Slithery

[Trigger]
Operation = Upgrade
Operation = Install
Operation = Remove
Type = Package
Target = *
[Action]
Description = Removing orphaned packages...
When = PostTransaction
Exec = /usr/bin/pacman -R $(pacman -Qqtd)

Also @V1del works like a charm now ty!

Last edited by Retr0r0cket (2022-03-15 18:59:43)

Offline

#5 2022-03-16 01:53:13

papajoke
Member
From: france
Registered: 2014-10-10
Posts: 42

Re: Issues Regarding Hook to Remove Orphaned Packages

no, at you to create bash(or other) script
hook call this script with

Exec = /etc/pacman.d/scripts/rm_orphans.sh

note

Retr0r0cket wrote:

Operation = Install

useful ? no : you use yay and yay can remove build deps

----------
best is to display only orphans (and if you want, if list is not empty, display also command for remove)

Last edited by papajoke (2022-03-16 02:03:44)


LTS - Fish - Kde - intel M100 - 16Go RAM - ssd

Offline

Board footer

Powered by FluxBB