You misunderstood it
Code: Select all
if [ -n "$(qdepends -Q $i)" ]; then \
That's the key part you miss, this check if a package in world has a reverse dependency
Why, because you don't need to try guessing what will be result of depclean on a package that nobody use, it's a condition for depclean.
When you remove app-arch/upx-ucl from your system, you end with dev-libs/ucl no more use by anybody, as such the only logic there is: keep it in world or depclean will catch it.
The problem with this script is that to make you happy, it should have an "else" condition to the qdepends check, that just say "keep it".
And the logic is :
-> check if pck-A have a reverse dep
---> no, no more test need, you already know you must keep it in world, else it's a candidate for depclean (and it's there the script miss a "you must keep it" output)
---> yes? ok, pck-B use it, but does pck-B really need it? (which in real is not checking if pck-B need it, but just see if depclean will agree to remove pck-A
----------> yes, it really need it, so depclean will refuse to remove it -> tell user it could remove pck-A from world because pck-B (in real, you don't who protect it, just that it is protect from depclean) protect it
----------> no, pck-B could use pck-C if pck-A is not there -> tell user to keep pck-A in world, else depclean will remove it because pck-B will be happy with pck-C instead. (again in real you have clue who is ok with that, just that depclean is ok to remove pck-A)
And on your test case, when you do --unmerge app-arch/upx-ucl you are making dev-libs/ucl no more use by anyone as it was only that package that use it in your test case.
The qdepends test fail: dev-libs/ucl is not use by anyone, test end here because you already know you must keep it in world, or depclean will catch it.