Knowledge Base:Remove obsoleted distfiles

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

Environment
Any Gentoo Linux installation.

Analysis
When Portage needs to download source code archives, it will store these archives in DISTDIR for later use. Portage will never clean up this location by itself; it will wait for a user with root privileges to do so.

Cleaning up the DISTDIR location means that the user should check which source code archives to keep and which to delete.


 * If the system is tight on space and there are no problems in re-downloading the source code archives when necessary, then the entire DISTDIR can be cleaned
 * If the system is tight on space, and the user would rather not re-download source code of packages that are currently installed (in case a rebuild the software is needed the sources will present on the system), then only clean out source code archives that are no longer used by any installed software

Of course, other clean-up strategies might exist as well. The above examples are provided as hypothetical situations.

Resolution
The package provides a utility called  which supports, among other strategies, the following clean-up activities.

Running 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 again (most of these archives are of old ebuilds that have since been removed from the Gentoo ebuild repository).

The  option can be added to make  remove source code archives that do not belong to an installed ebuild. This will remove many more archives while providing a modest safety net, since the archives of installed ebuilds remain available in case rebuilds are needed.

A more drastic approach to save disk space
An other option is to clean the distfiles after every successful merged ebuild, for that you may set the following hook (or install darkelf-features from darkelf overlay):

This clean feature can then be enabled by adding the following line to :

A few useful options
There are several useful options, so be sure to look at them. The  option outputs lots of useful information. For example,  functions as it does with, showing what will happen without actually doing anything. Another nice option that can be used in conjunction with  is. Downloading Java from Oracle is annoying enough the first time; this will keep users from reliving the painful experience of re-downloading source code for their systems... at least until the next release.