Cleaning Ports Tree

Olivier Certner olivier.freebsd at
Fri Apr 16 17:48:20 UTC 2021

>   find  /usr/ports -type d -name work -exec -vrf {} \;
> This second approach is much, much (much) faster, I just want to make
> sure I am not creating nasty side-effects thereby.

It is faster indeed. Even faster, and taking flavors into account:
find /usr/ports -depth 3 -name 'work*' -exec rm -fR "{}" +
(And, you could improve it again by using `xargs -P`).

There are no side-effects. No ports currently overrides do-clean, nor uses the 
pre and post clean targets, which have existed for more than 20 years, and I'm 
willing to bet it's not going to change.

Yasuhiro pointed out some guaranteed advantages of `make clean`, but in fact 
you get point 1 with the above command, and point 2 is usually not really a 
problem (you could wrap the `find` command inside some shell script testing 
for WRKDIRPREFIX, in the case it is not set, and use a simple `rm -fR` when it 
is, after appropriate sanity checks that is; but I don't think this is worth 
the trouble).


Olivier Certner

More information about the freebsd-questions mailing list