Yay: [Feature request] Show packages no longer required by any installed package

Created on 5 Dec 2019  路  5Comments  路  Source: Jguer/yay

Affected Version

yay v9.4.2 - libalpm v12.0.1

Feature request

Show newly orphaned packages after removing/updating packages like yaourt did.
It is very useful, because yay -Yc shows too much packages and it is difficult to spot new orphans. Also soon after package remove/upgrade the user can remove new orphans (or some of them).

Exmaple

After removing qtcreator the qbs, bzr, clazy packages are now orphaned and the user is informed about it.

$ yaourt -R qtcreator
checking dependencies...

Package (1)  Old Version  Net Change 

qtcreator    4.10.2-1     -107.69 MiB

Total Removed Size:  107.69 MiB

:: Do you want to remove these packages? [Y/n] 
:: Processing package changes...
(1/1) removing qtcreator                                                                                                                      [######################################################################################] 100%
:: Running post-transaction hooks...
(1/4) Arming ConditionNeedsUpdate...
(2/4) Updating icon theme caches...
(3/4) Updating icon theme caches...
(4/4) Updating the desktop file MIME type cache...
==> Packages no longer required by any installed package:
    bzr clazy qbs
No database errors have been found!
Discussion Open Feature Request stale

Most helpful comment

The cleanest and most minimal solution is to configure a pacman PostTransaction hook to run on Install, Upgrade and Remove.

Run the steps using sudo

mkdir /etc/pacman.d/hooks
$EDITOR /etc/pacman.d/hooks/orphans.hook

and set the hook.

[Trigger]
Operation = Install
Operation = Upgrade
Operation = Remove
Type = Package
Target = *

[Action]
Description = Checking for orphaned packages...
When = PostTransaction
Exec = /bin/sh -c "/bin/pacman -Qtd | sed 's/^/    /' || exit 0"

All 5 comments

You could run yay -Qdt (or use pacman directly: pacman -Qdt) after you have removed a package, this will list all packages that were "installed as dependencies" AND are "not required by any package".

Or use yay -Rs (or pacman -Rs) when you remove a package, this removes the specified package(s) and "dependencies not required by other packages"

I agree with @HorayNarea on this, if you want to remove only no longer required packages on uninstall, pacman->yay already has an option for that.

Ok, I missed the pacman -Rs (thanks for that), but what about upgrade when package changes its dependencies? It is more convenient to get info after package install/removal than checking for orphans manually after upgrade like yay -Yc or yay -Qdtq. Your thoughts about this?

The cleanest and most minimal solution is to configure a pacman PostTransaction hook to run on Install, Upgrade and Remove.

Run the steps using sudo

mkdir /etc/pacman.d/hooks
$EDITOR /etc/pacman.d/hooks/orphans.hook

and set the hook.

[Trigger]
Operation = Install
Operation = Upgrade
Operation = Remove
Type = Package
Target = *

[Action]
Description = Checking for orphaned packages...
When = PostTransaction
Exec = /bin/sh -c "/bin/pacman -Qtd | sed 's/^/    /' || exit 0"

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mmirate picture mmirate  路  3Comments

bazeeel picture bazeeel  路  4Comments

drrlvn picture drrlvn  路  4Comments

renom picture renom  路  3Comments

GermanG picture GermanG  路  4Comments