Ports/Packages Deinstall

Hello,

When I use make deinstall clean inside a port I previously installed, all its dependencies are still installed. I also noticed that some configuration files are not removed after deinstalling.

What is a proper way of installing, and deinstalling (inclusing all configuration files, and dependencies) packages/ports? I would like to keep my system clean, so I hope there is a way to remove every thing that came with a port/package. I want not a single-byte of a port/package on my system after "deinstalling".

TL;DR - How do you fully remove a package/port leaving absolutely nothing?
 
Unfortunately there is no such way as far as I know if I am not wrong. But still you can use sysutils/pkg-cutleaves wich finds installed 'leaf' packages, i.e. packages that are not referenced by any other installed package, and lets you decide for each one if you want to keep or deinstall it.
 
Those dependencies that are left are called leaf ports.

There are small applications/scripts in the ports tree that can remove them (search for "leaf" or "leaves"), e.g. ports-mgmt/pkg_cutleaves.
A word of caution here: these applications can't understand the difference between a "leaf port" and a port you still need but that doesn't depend on any other port, so use them with care. They usually support exclusion lists for such cases.


As for configurations, are you talking about files in system directories such as /usr/local/etc/ or files inside your home directory?

The former should normally be removed when you uninstall the application, unless you modified the file (the uninstallation routines don't remove modified files).

Configuration files inside your home directory are created when you first run the application (as opposed to when you install it).
The installation process is run by the root user whereas configuration files are the property of each user. The uninstallation routines are therefore not responsible of removing them.
 
I'd look into # make deinstall-all but I'd like to stress out that you should be careful here. According to the ports(7) manualpage:

Code:
     deinstall-all    Remove all installed ports with the same PKGORIGIN from
                      the system.
My interpretation would be that if port Y got automatically installed due to an existing dependency in port X this would make X the PKGORIGIN for port Y.

However, that's all it is; just my theory.

Naturally I did look it up before suggesting but all I could find which somewhat hinted at this functionality was this post on the mailinglist.

It's definitely not something I'd try on a production system, but I do think it might be worth looking into.

As to ports and leaf ports and such; one of the reasons ports-mgmt/portmaster has become one of my favourites is that it can also sort all of this out for you. If you issue portmaster -L you'll get a nice list of all your ports where it will divide them in four different sections:
  • Root ports (No dependencies, not depended on)
  • Trunk ports (No dependencies, are depended on)
  • Branch ports (Have dependencies, are depended on)
  • Leaf ports (Have dependencies, not depended on)
This makes it really easy to determine which can be easily discarded.

Which brings me to another point: keep in mind that some ports need others to be present during the build stage but not so much for using them. So if you ever come across a port which keeps re-appearing even though you removed it then this is a very likely cause.

Hope this can help too.

Edit: null-edit & fixed some tags
 
Beastie said:
A word of caution here: these applications can't understand the difference between a "leaf port" and a port you still need but that doesn't depend on any other port, so use them with care. They usually support exclusion lists for such cases.

This is the reason I use ports-mgmt/portmaster and its ports uninstall method "expunge"

Code:
portmaster [-n|y] [-b] [-D|d] -e [I]name/glob of a single port directory in /var/db/pkg[/I]
 
expunge a port using pkg_delete(1), and optionally remove all distfiles. Calls -s after
it is done expunging in case removing the port causes a dependency to no longer be
necessary.


To "auto-remove" your already uninstalled port:
portmaster is a shell script with no other port dependencies.
 
Cherios said:
Hello,

When I use make deinstall clean inside a port I previously installed, all its dependencies are still installed. I also noticed that some configuration files are not removed after deinstalling.

What is a proper way of installing, and deinstalling (inclusing all configuration files, and dependencies) packages/ports? I would like to keep my system clean, so I hope there is a way to remove every thing that came with a port/package. I want not a single-byte of a port/package on my system after "deinstalling".

TL;DR - How do you fully remove a package/port leaving absolutely nothing?

# pkg autoremove
 
Thanks for your comment @nanotek, but keep in mind that it's dangerous to assume that people are using pkg since it isn't officially used right now. It will become the new standard on FreeBSD 10 but right now the pkg_* tools are commonly in effect.
 
Last edited by a moderator:
Well @ShelLuser, there has been no update to the old package repositories in the past five to six months and there has have been official repositories "for FreeBSD 8.3, 8.4, 9.1, 9.2, 10.0 and head" since late October (see the first entry for October 2013).

Plus, people better get used to pkg: it's "The Future" and we're at most one month away from the release of FreeBSD 10 on which the pkg_* tools are not available (if I'm not mistaken).
 
Last edited by a moderator:
Back
Top