On Tue, Aug 4, 2009 at 12:14 PM, Darrin
Chandler<dwchand...@stilyagin.com> wrote:
> On Tue, Aug 04, 2009 at 11:30:44AM -0400, Luis Useche wrote:
>> On Tue, Aug 4, 2009 at 11:20 AM, Bret S. Lambert<bret.lamb...@gmail.com> 
>> wrote:
>> > pkg_delete `pkg_info -t` will almost do what you're looking for ;)
>>
>> The problem with this command is that it will remove packages
>> installed for the end user. In my case, for instance, "pkg_info -t"
>> list zsh, vim, subversion and other.
>
> Brett gave you the pieces and this is UNIX, so it's just a tiny bit more
> work...
>
> # pkg_info -t | cut -d' ' -f1 > pkgs.before
> # pkg_delete <whatever>
> # pkg_info -t | cut -d' ' -f1 > pkgs.after
> # pkg_delete $(comm -13 pkgs.before pkgs.after)
>

I guess your idea with this script is to find the differences between
the lists of packages with no dependents before and after deleting the
package <whatever>.

This is really close but it is not there quite yet. Even with this
script, there could be situations where you end up deleting things you
don't want. For instance, let say you install xfce. After some time,
you decided to install some package X that depend on xfce and other
library L used only by X. When using your script, it will remove not
only L but also xfce (which you did not want to remove because you
installed it manually).

Besides, there is another problem with the script. If you imagine the
packages installed in the system as a tree of dependencies, you can
see that your script will only remove two levels of the branch you
want to delete. Example: X depends on Y that depends on Z: X -> Y ->
Z. In your script, X and Y will be removed but Z will not.

It seems like an additional information should be added to the package
database. A bit indicating if the package was installed manually by
the user (admin?) or not. Then, the package can only be deleted if the
the user explicitly say so as oppose to "automatic deletion as
dependency".

Any other suggestion?

Luis Useche
use...@gmail.com

Reply via email to