Subject: direct vs indirect package installation/deletion
To: NetBSD tech-pkg <>
From: Marton Fabo <>
List: tech-pkg
Date: 12/22/2002 03:15:44
I was reading around the pkg_delete manual, specifically the section 
about -R and deleting all the packages that are required by the given 
one, and the following idea came to my mind.

It may be possible that package A (to be deleted) depends on package B, 
whose only installed depending package is A, but actually B was 
installed directly by the administrator, as opposed to automatically by 
the pkg system to fulfill A's requirement. This would mean that actually 
not only package A depends on B, but the user of the system also.

Obviously, the -R option to pkg_delete is to deinstall anything whose 
sole purpose was to fulfill the requirements of a package to be deleted, 
and thus those packages would become unused otherwise. But in the above 
situation, package B is required directly by the user also, not only 
package A, but it would still be deleted in the course of cleaning up 
after A. This is inconvenient.

All in all, it may be desirable to have the pkg system mark packages 
that were directly installed by the user (as opposed to automatically as 
a dependency), so that while purging packages believed to become unused 
with pkg_delete -R, those packages would be preserved.

Just as a first idea, a possible way could be to add a special entry in 
+REQUIRED_BY, indicating the user being directly interested in the 
package in question. This would automatically prevent pkg_delete -R from 
auto-deleting it, (because it only deletes packages that would have no 
more dependent packages left). In contrary, when directly deleting the 
package in question, then this entry in +REQUIRED_BY would first be 
removed if found, and then attempt be made to have it removed.

This method would have the further advantage that when the admin would 
try to delete a package that has depending packages, then by first 
having the above mentioned entry removed from +REQUIRED_BY, and failing 
only then because of the remaining depending packages, the system would 
automatically remark that the user doesn't directly want the presence of 
the package in question, thus a subsequent recursive deletion would 
remove it, as expected.

Of course, any other implementation would do also.