yay v9.4.2 - libalpm v12.0.1
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).
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!
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.
Most helpful comment
The cleanest and most minimal solution is to configure a
pacmanPostTransactionhook to run onInstall,UpgradeandRemove.Run the steps using
sudoand set the hook.