Tool for automated cleaning of ${prefix}/var/distfiles

Ryan Schmidt ryandesign at
Mon Jul 22 12:57:39 PDT 2013

On Jul 22, 2013, at 14:38, Vincent Habchi wrote:

> Right. My question precisely was: why does ‘port uninstall’ not wipe out also this file during deinstallation? Isn’it supposed to do so?

It was never intended to do so, no.

I use this script to clean out old distfiles:

It is far from perfect. It merely declares that distfiles older than a certain period (2 years in this script but you could change it) should be deleted. This means there are both false positives (ports that have not been updated in 2 years) and false negatives (ports that are updated much more frequently than that).

The script also deletes logs older than a month (if you've configured MacPorts to keep logs), and files that were moved out of the way by forcing a port activation.

I think giving MacPorts the ability to delete distfiles that are no longer used would be difficult to implement. After all, any portfile could use any distfile. Ports can override distname and distfiles and also dist_subdir. These values are not kept in the portindex, so to discover them you have to open the portfile. Also, distfiles can vary based on anything, from variants to OS versions or any other criteria that can be programmed into the Portfile in Tcl. Assuming we want to consider only variants, then to delete distfiles that are not needed by any port, you would have to have MacPorts compute the list of distfiles needed by each variant of each port (thus open and load each of the over 9000 portfiles), then traverse the distfiles directory and delete any file not in that large list. There's also patchfiles to consider. (While we usually put patchfiles in the files directory, if the patch is not found there, MacPorts will try to download it from URLs in patch_sites.)

I have thought about improving the housekeeping script to do this, but it would probably be slow to run and would take lots of memory if the list of all distfiles is kept in memory. Or the list could be in a temporary file and searched with grep… 

More information about the macports-dev mailing list