rough method of cleaning the ports tree

John Nielsen lists at
Tue Dec 18 19:43:24 PST 2007

On Tuesday 18 December 2007, Erich Dollansky wrote:
> after noticing how large my ports tree grows while compiling, I thought
> of simply deleting it and do a CVSup to get a new one after the
> compilation is finished.
> This should be much faster and also should do some kind o
> defragmentation. I simply cannot believe that the huge ports tree will
> still be very well organised after some months.
> What does the list think of this method?

There are at least two better ways of doing this that will take less time 
and not put unnecessary load on the CVS servers.

1) Delete "work" directories after building ports. If you use the "clean" 
make target it will do this automatically. I typically do "make install 
clean" to install the port then delete the work directory in one command. 
Portupgrade and other tools will generally do this as well. If you already 
installed a port you can just do "make clean" to get rid of its work 
directory. If you (suspect that you) have a large number of work 
directories (either because your builds got interrupted or you forgot to 
use the "clean" target) you can do something 
like "find /usr/ports -maxdepth 3 -type d -name work -delete" to get them 
all in one go.

2) Use WRKDIRPREFIX. I set this in my .cshrc, but you can set it manually or 
in whatever file is appropriate for your (root) shell. e.g. after doing 
a "setenv WRKDIRPREFIX /usr/scratch" all of the work directories are 
created under /usr/scratch/usr/ports/<category>/<portname> instead of 
under /usr/ports directly. Whenever I feel like cleaning up I can 
just "rm -r /usr/scratch/usr/ports" without losing anything.

See "man ports" for more information on the port build infrastructure and 
associated make targets and environment variables.

The other thing in the ports collection that tends to take up space is the 
distfiles directory. If you want to delete it wholesale then go ahead 
("rm -r /usr/ports/distfiles"), but it's not uncommon to have multiple 
ports or multiple revisions of the same port use the same distfile(s), so 
you'll end up downloading them again and again. I prefer to use the 
script /usr/ports/Tools/scripts/ Run with a "-f" flag it will 
automatically delete all distfiles no longer referenced by any port in your 
ports tree.



More information about the freebsd-questions mailing list