Discussion:
Cleaning Ports Tree
Tim Daneliuk via freebsd-questions
2021-04-15 20:37:08 UTC
Permalink
I am aware that one can do this to clean the ports tree:

cd /usr/ports
make clean

However, this is very slow. Is there any reason not to do this instead:

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.
Yasuhiro Kimura
2021-04-15 20:57:22 UTC
Permalink
From: Tim Daneliuk via freebsd-questions <freebsd-***@freebsd.org>
Subject: Cleaning Ports Tree
Date: Thu, 15 Apr 2021 15:37:08 -0500
Post by Tim Daneliuk via freebsd-questions
cd /usr/ports
make clean
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.
1. If a port is flavorized, default working directory is
/usr/ports/category/portname/work-(flavor name). and above command
don't remove it. `make clean` works fine whether or not a port is
flavorized.

2. `make clean` works fine even if WRKDIRPREFIX is set. You need not
aware where real working directory is.

---
Yasuhiro Kimura
Dewayne Geraghty
2021-04-15 21:05:04 UTC
Permalink
Post by Tim Daneliuk via freebsd-questions
cd /usr/ports
make clean
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.
_______________________________________________
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
I've done a similar thing since 2003 without ill effects. For
completeness I also have (in make.conf):

WRKDIRPREFIX=/var/ports # when I perform a rebuild, I simply delete the
subdirs
DISTDIR=/distfiles # so all the distfiles are in one place
PACKAGES=/packages # same for the outputs.

It also allows the use of multiple devices.
Tim Daneliuk via freebsd-questions
2021-04-15 22:02:40 UTC
Permalink
Post by Dewayne Geraghty
Post by Tim Daneliuk via freebsd-questions
cd /usr/ports
make clean
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.
I've done a similar thing since 2003 without ill effects. For
WRKDIRPREFIX=/var/ports # when I perform a rebuild, I simply delete the
subdirs
DISTDIR=/distfiles # so all the distfiles are in one place
PACKAGES=/packages # same for the outputs.
It also allows the use of multiple devices.
This is actually even cleaner. A simple rm -rf /var/ports cleanses the system ...
Olivier Certner
2021-04-16 17:48:10 UTC
Permalink
Hi,
Post by Tim Daneliuk via freebsd-questions
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).

Regards.
--
Olivier Certner
Mario Lobo
2021-04-16 17:55:07 UTC
Permalink
Post by Olivier Certner
Hi,
Post by Tim Daneliuk via freebsd-questions
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.
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).
Regards.
--
Olivier Certner
_______________________________________________
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "
ports-mgmt/portupgrade has a utility (portsclean) that does exactly that
among other things, like cleaning unreferenced distfiles, and more.
--
Mario Lobo
http://www.mallavoodoo.com.br
FreeBSD since version 2.2.8 [not Pro-Audio.... YET!!]
Loading...