Please inform if this is correct process for viewing and removing orphaned packages in EOS:
1.) pacman -Qdt = To see the list of orphaned packages.
2.) sudo pacman -Rs $(pacman -Qdtq) = To remove all the orphans. But this command removes also packages which maybe are used seldom, but nevertheless are still necessary packages for some other packages.
In order to avoid removing still necessary packages indicated by this command by name run at first instead following command:
3.) sudo pacman -D --asexplicit package1 package2 = To mark some packages not to be removed now.
4.) After running the command in 3.) it is OK to run command in 2.) sudo pacman -Rs $(pacman -Qdtq), because now the appointed packages (package1 package 2) which are still in use will not be removed.
ā s, --recursive
Remove each target specified including all of their dependencies, provided that
(A) they are not required by other packages; and (B) they were not explicitly installed by the user.
This operation is recursive and analogous to a backwards --sync operation, and it helps keep a clean system without orphans. If you want to omit condition (B), pass this option twice.
So I think pacman -Rs $(pacman -Qdtq) will not remove any packages that
That is, if they are āhardā dependencies of other packages. In this case they shouldnāt even show as orphans.
But I think it would remove them if they are āoptionalā dependencies of some other packages.
It is good then to review pacman -Qqtd and check if some packages are optional for something else and decide for your self if you want to keep them or not.
If there is a command to check what other packages have the package X as optional dependency, I am not aware of it. However it is possible to check it up here: https://archlinux.org/packages/
I go a different way to get rid of unnecessary dependencies with Yay. But we can compare it.
Temporarily switch terminal output to English
LANG=c
13:45:00^jag@jag-81vr:
~> pacman -Qdt
botan 3.0.0-1
openssl-1.1 1.1.1.t-1
14:23:12^jag@jag-81vr:
~> yay -Qdt
botan 3.0.0-1
openssl-1.1 1.1.1.t-1
14:48:34^jag@jag-81vr:
~> yay -Yc
[sudo] password for jag:
checking dependencies...
Package (1) Old Version Net Change
botan 3.0.0-1 -8.26 MiB
Total Removed Size: 8.26 MiB
:: Do you want to remove these packages? [Y/n] n
-> exit status 1
15:00:58^jag@jag-81vr:
Suppose you have a package X installed in your system and you want to know what other packages might have X as optional dependency.
My question: is there any command to run that list all the packages that have X as optional dependency?
For example ntfs-3g is optional dependency for gparted. Is there any command to run on ntfs-3g which would then output gparted (plus possibly others that might have it as optional dependency)
Of course sudo pacman -R ntfs-3g would tell me exactly that:
As a result of this I will make a following change into my original process: after command sudo pacman -Rs $(pacman -Qdtq) I will add into my process command LANG=C pacman -Qi packageX | grep -E "^Required By|^Optional For" for additional checking if packageX is required or optional. All the rest can remain as in the original process plan. OK ?
In case of no objections Iāll mark this thread as āSolutionā.