Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 May 2007 19:13:13 -0700
From:      Jeremy Lea <reg@FreeBSD.ORG>
To:        Alexander Leidinger <Alexander@Leidinger.net>
Cc:        ports@FreeBSD.ORG
Subject:   Re: Speedup for make clean-depends (and thus make clean)
Message-ID:  <20070521021313.GA63269@flint.openpave.org>
In-Reply-To: <20070520090149.190a919c@deskjail>
References:  <20070520090149.190a919c@deskjail>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

On Sun, May 20, 2007 at 09:01:49AM +0200, Alexander Leidinger wrote:
> I could write such a new target, e.g. limited-clean, which could be used
> with update tools if there's some interest in something like this from
> the author of such a tool.

The patch below should get you going on this.  The first will save a
stat and a make for each port, so it should reduce your time even more,
and the second does the limited-clean.  I've just added little targets
to test them.

One might want to use the logic that 'make clean' does a 'make clean
limited-clean' if NOCLEANDEPENDS is not defined, and 'make clean' if it
is, and leave 'make clean-depends' to do the full clean.

One might want to make a switch like DEPENDS_CLEAN which did a clean
before doing the install in dependency directories, so that stale port
builds were not used.

One might also want to document DEPENDS_CLEAN better so people know that
it can be used like this 'cd /usr/ports/x11/xorg && make
-DNOCLEANDEPENDS -DDEPENDS_CLEAN install clean', and not only will it
clean up like 'make install clean', it will use a lot less disk space... 
(Although DEPENDS_CLEAN is broken in the case of ports which overide
DEPENDS_TARGET via the third depends arguement.  It should be
implemented directly in _INSTALL_DEPENDS)

Regards,
  -Jeremy  

PS. ALL-DEPENDS-LIST has tabs set to 8 not 4 like bsd.port.mk should be. 
I don't think I'm responsible - it's been reimplemented a few times
since I did the first rewrite...  But maybe it was me ;-)

-- 
FreeBSD - Because the best things in life are free...
                                           http://www.freebsd.org/

--- /usr/ports/Mk/bsd.port.mk	Sat May 19 12:57:27 2007
+++ /tmp/bsd.port.mk	Sun May 20 18:07:05 2007
@@ -5050,6 +5050,91 @@
 		L=$$l;							\
 	done
 
+CLEAN-DEPENDS-FULL= \
+	L="${_DEPEND_DIRS}";						\
+	checked="";							\
+	while [ -n "$$L" ]; do						\
+		l="";							\
+		for d in $$L; do					\
+			case $$checked in				\
+			$$d\ *|*\ $$d\ *|*\ $$d)			\
+				continue;;				\
+			esac;						\
+			checked="$$checked $$d";			\
+			if [ ! -d $$d ]; then				\
+				${ECHO_MSG} "${PKGNAME}: \"$$d\" non-existent -- dependency list incomplete" >&2; \
+				continue;				\
+			fi;						\
+			if ! children=$$(cd $$d && ${MAKE} -V WRKDIR -V _DEPEND_DIRS); then \
+				${ECHO_MSG} "${PKGNAME}: \"$$d\" erroneous -- dependency list incomplete" >&2; \
+				continue;				\
+			fi;						\
+			state=0;					\
+			for child in $$children; do			\
+				case $$state in				\
+				0)					\
+					if [ -d $child ]; then 		\
+						${ECHO_CMD} $$d;	\
+					fi;				\
+					state=1;;			\
+				1)					\
+					case "$$checked $$l" in		\
+					$$child\ *|*\ $$child\ *|*\ $$child) \
+						continue;;		\
+					esac;				\
+					l="$$l $$child";;		\
+				esac;					\
+			done;						\
+		done;							\
+		L=$$l;							\
+	done
+
+CLEAN-DEPENDS-QUICK= \
+	L="${_DEPEND_DIRS}";						\
+	checked="";							\
+	while [ -n "$$L" ]; do						\
+		l="";							\
+		for d in $$L; do					\
+			case $$checked in				\
+			$$d\ *|*\ $$d\ *|*\ $$d)			\
+				continue;;				\
+			esac;						\
+			checked="$$checked $$d";			\
+			if [ ! -d $$d ]; then				\
+				${ECHO_MSG} "${PKGNAME}: \"$$d\" non-existent -- dependency list incomplete" >&2; \
+				continue;				\
+			fi;						\
+			if ! children=$$(cd $$d && ${MAKE} -V WRKDIR -V _DEPEND_DIRS); then \
+				${ECHO_MSG} "${PKGNAME}: \"$$d\" erroneous -- dependency list incomplete" >&2; \
+				continue;				\
+			fi;						\
+			state=0;					\
+			for child in $$children; do			\
+				case $$state in				\
+				0)					\
+					if [ ! -d $child ]; then 	\
+						continue;		\
+					fi;				\
+					state=1;			\
+					${ECHO_CMD} $$d;;		\
+				1)					\
+					case "$$checked $$l" in		\
+					$$child\ *|*\ $$child\ *|*\ $$child) \
+						continue;;		\
+					esac;				\
+					l="$$l $$child";;		\
+				esac;					\
+			done;						\
+		done;							\
+		L=$$l;							\
+	done
+
+clean-depends-full:
+	@${CLEAN-DEPENDS-FULL}
+
+clean-depends-quick:
+	@${CLEAN-DEPENDS-QUICK}
+
 .if !target(clean-depends)
 clean-depends:
 	@for dir in $$(${ALL-DEPENDS-LIST}); do \



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070521021313.GA63269>