Bug 86310 - [patch] all-depends-list target of bsd.port.mk is buggy
[patch] all-depends-list target of bsd.port.mk is buggy
Status: Closed FIXED
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s)
Latest
Any Any
: Normal Affects Only Me
Assigned To: portmgr
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2005-09-18 22:10 UTC by Mikhail T.
Modified: 2006-02-23 15:52 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mikhail T. 2005-09-18 22:10:00 UTC
	The all-depends-list target in bsd.port.mk is inefficient and
	error-prone. Depending on circumstances, it may, for example,
	fail to add teTeX to the list (because teTeX-base is usually
	visited first).

	It can also fail due to a very long (or circular) list of
	dependencies, and even when successful will use a lot of stack
	invoking make recursively.

	Similar targets (like package-depends-list) have the same
	problem.

Fix: 

The patch below fixes only all-depends-list for now. I may be
	able to fix others too. It also helps find, which dependant
	directories had errors (such as unresolved RCS-merges).

	I posted this patch to ports@ and nobody objected (predictably).
	I also rebuilt my own machine with it -- everything built.

--- bsd.port.mk	28 Aug 2005 18:47:56 -0000	1.516
+++ bsd.port.mk	18 Sep 2005 21:02:50 -0000
@@ -4464,23 +4470,40 @@
 # Dependency lists: both build and runtime, recursive.  Print out directory names.
 
+_DEPENDS=${EXTRACT_DEPENDS} ${PATCH_DEPENDS} ${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${RUN_DEPENDS}
+_DEPEND_DIRS=	${_DEPENDS:C,^[^:]*:([^:]*),\1,} ${DEPENDS:C,:.*,,}
+
 all-depends-list:
-.if defined(EXTRACT_DEPENDS) || defined(PATCH_DEPENDS) || defined(FETCH_DEPENDS) || defined(BUILD_DEPENDS) || defined(LIB_DEPENDS) || defined(RUN_DEPENDS) || defined(DEPENDS)
 	@${ALL-DEPENDS-LIST}
-.endif
 
 ALL-DEPENDS-LIST= \
-	checked="${PARENT_CHECKED}"; \
-	for dir in $$(${ECHO_CMD} "${EXTRACT_DEPENDS} ${PATCH_DEPENDS} ${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${RUN_DEPENDS}" | ${SED} -e 'y/ /\n/' | ${CUT} -f 2 -d ':') $$(${ECHO_CMD} ${DEPENDS} | ${SED} -e 'y/ /\n/' | ${CUT} -f 1 -d ':'); do \
-		if [ -d $$dir ]; then \
-			if (${ECHO_CMD} $$checked | ${GREP} -qwv "$$dir"); then \
-				child=$$(cd $$dir; ${MAKE} PARENT_CHECKED="$$checked" all-depends-list); \
-				for d in $$child; do ${ECHO_CMD} $$d; done; \
-				${ECHO_CMD} $$dir; \
-				checked="$$dir $$child $$checked"; \
-			fi; \
-		else \
-			${ECHO_MSG} "${PKGNAME}: \"$$dir\" non-existent -- dependency list incomplete" >&2; \
-		fi; \
-	done | ${SORT} -u
+	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;						\
+			${ECHO_CMD} $$d;				\
+			if ! children=$$(${MAKE} -C $$d -V _DEPEND_DIRS); then\
+				${ECHO_MSG} "${PKGNAME}: \"$$d\" erroneous -- dependency list incomplete" >&2; \
+				continue;				\
+			fi;						\
+			for child in $$children; do			\
+				case "$$checked $$l" in			\
+				$$child\ *|*\ $$child\ *|*\ $$child)	\
+					continue;;			\
+				esac;					\
+				l="$$l $$child";			\
+			done;						\
+		done;							\
+		L=$$l;							\
+	done
 
 .if !target(clean-depends)
How-To-Repeat: 
	Try `cd /usr/ports/x11/kde3; time make all-depends-list'. While
	it is running, try `ps -ax | fgrep -c make'.
Comment 1 Thierry Thomas freebsd_committer 2005-09-18 22:16:03 UTC
Responsible Changed
From-To: freebsd-ports-bugs->portmgr


Assign to maintainer.
Comment 2 Mark Linimon freebsd_committer 2005-12-19 01:30:44 UTC
State Changed
From-To: open->analyzed

Accepted for testing on the cluster.
Comment 3 Mark Linimon freebsd_committer 2006-01-21 19:50:05 UTC
State Changed
From-To: analyzed->closed

Committed, thanks.
Comment 4 Mark Linimon freebsd_committer 2006-02-03 02:20:55 UTC
State Changed
From-To: closed->analyzed

Reopened to indicate a revised patch to this is being tested on the cluster.
Comment 5 sem 2006-02-13 07:03:16 UTC
Just for history.

The revised patch can be found here:
http://lists.freebsd.org/mailman/htdig/freebsd-ports/2006-January/029123.html

-- 
Sem.
Comment 6 Mark Linimon freebsd_committer 2006-02-14 04:42:27 UTC
State Changed
From-To: analyzed->feedback

Patch committed.  Is this problem now completely solved?
Comment 7 Mark Linimon freebsd_committer 2006-02-23 15:52:16 UTC
State Changed
From-To: feedback->closed

I have not heard otherwise, so I am claiming that we have solved this problem.