Knowledge Base:Remove obsoleted distfiles

Synopsis
The DISTDIR location hosts all the source code archives ever downloaded by the system. Unless the files are properly removed when not needed anymore, the storage occupied by this location will continue to grow. Regular clean-up of this location is not done automatically by Portage though.

Environment
Any Gentoo Linux installation

Analysis
When Portage needs to download source code archives, it will store these archives in DISTDIR for later use. However, Portage never cleans up this location by itself.

Cleaning up the DISTDIR location means that you should check which source code archives you want to keep.
 * If you are tight on space but have no problems in redownloading the source code archives when necessary, you can just clean out all files
 * If you are tight on space but would rather not redownload source code of packages that are currently installed (so in case you need to rebuild the software, it doesn't need to redownload it), you should clean out those source code archives not used by any installed software anymore

Of course, other clean-up strategies might exist as well.

Resolution
The package provides an application called eclean-dist which supports, amongst other strategies, the following clean-up activities:

Just running eclean-dist will remove the source code archives that do not belong to any available ebuild anymore. This is a safe approach since these sources are very unlikely to be needed ever (most of these archives are of old ebuilds that have since been removed from the tree).

You can add the --destructive option to have eclean-dist remove the source code archives that do not belong to an installed ebuild. This will remove many more sources, but is still not that troublesome since the source code archives of installed ebuilds remain available in case you need to rebuild an installed ebuild.

A Few Useful Options
There are several useful options, so have a look at them. the --help option is very well done. For example, --pretend functions as it does with emerge, showing what will happen without actually doing anything. Another useful option that can be used in conjunction with --destructive is --fetch-restricted. Downloading Java from Oracle is annoying enough the first time; this will keep you from reliving it, at least until the next release.