Invariably, cleaning up after a building a port gets forgotten and starts to use up disk space. Periodically it should be cleaned. If you have local changes to the ports tree you should make sure they are saved to a safe location.
There is a brute force method to remove all the work/ directories:
# rm -rf /usr/ports/*/*/work
Using the ports Makefile structure:
# cd /usr/ports # make NOCLEANDEPENDS=yes clean
The portupgrade has utilities that can be used for cleaning the ports tree
Clean out all the working directories of the ports tree. (cf. WRKDIRPREFIX):
# portsclean -C Cleaning out /usr/ports/*/*/work... Delete /usr/ports/x11/wrapper/work Delete /usr/ports/print/apsfilter/work done.
Clean out all the distfiles that are not referenced by any port in the ports tree. (cf. DISTDIR)
# portsclean -D Detecting unreferenced distfiles... Delete /usr/ports/distfiles/bc101-0.2.tar.gz Delete /usr/ports/distfiles/beep-1.0.tar.gz
Clean out all the distfiles that are not referenced by any port that is currently installed. (cf. DISTDIR)
# portsclean -DD Detecting unreferenced distfiles... [Updating the pkgdb <format:bdb1_btree> in /var/db/pkg ... - 118 packages found (-0 +11) ........... done] Delete /usr/ports/distfiles/bc101-0.2.tar.gz Delete /usr/ports/distfiles/beep-1.0.tar.gz Delete /usr/ports/distfiles/gnome/gnome-libs-1.4.1.7.tar.bz2 Delete /usr/ports/distfiles/libxml-1.8.17.tar.gz Delete /usr/ports/distfiles/scrollkeeper-0.2.tar.gz Delete /usr/ports/distfiles/vsound-0.5.tar.gz