Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 11 May 2002 18:08:42 +0900
From:      KOMATSU Shinichiro <koma2@jiro.c.u-tokyo.ac.jp>
To:        freebsd-current@FreeBSD.ORG, ports@freebsd.org
Cc:        Riccardo Torrini <riccardo@torrini.org>, Garrett Rooney <rooneg@electricjellyfish.net>
Subject:   bsd.port.mk dependency loop checking patch (Re: Who broke 'make clean' for ports ?)
Message-ID:  <20020511090904.69E5B1949@taro.c.u-tokyo.ac.jp>
In-Reply-To: <20020510173132.GA46688@electricjellyfish.net>
References:  <XFMail.20020510190126.riccardo@torrini.org> <20020510172656.GD13627@dan.emsphone.com> <20020510173132.GA46688@electricjellyfish.net>

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

--IS0zKkzwUGydFO0o
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

(add To: ports@freebsd.org)

From: Garrett Rooney <rooneg@electricjellyfish.net>
Subject: Re: Who broke 'make clean' for ports ?
Date: Sat, May 11, 2002 at 02:31:32AM JST

> there's a circular dependency that was just introduced to gettext.
> gettext now depends on expat, which depends on gmake, which depends on
> gettext.

Recently, I wrote a patch for bsd.port.mk that checks circular dependency.
If a dependency loop is found, it gives you a warning and
does not invoke 'make' process any further.

Someone, please test the patch below.
If no problem is found, I will send-pr(8).

--IS0zKkzwUGydFO0o
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="bsd.port.mk-1.411-loopcheck.patch"

Index: bsd.port.mk
===================================================================
RCS file: /home/ncvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.411
diff -u -u -r1.411 bsd.port.mk
--- bsd.port.mk	27 Apr 2002 11:22:59 -0000	1.411
+++ bsd.port.mk	8 May 2002 17:13:40 -0000
@@ -684,6 +684,16 @@
 .else
 PORTSDIR?=		/usr/ports
 .endif
+.if exists(/bin/realpath)
+PORTSDIR!=		/bin/realpath ${PORTSDIR}
+.else
+PORTSDIR_IS_SYMLINK!=	if [ -L ${PORTSDIR} ]; then echo "yes" ; fi
+. if ${PORTSDIR_IS_SYMLINK} == "yes"
+. error	"PORTSDIR" must not be a symlink
+. endif
+. undef PORTSDIR_IS_SYMLINK
+.endif
+
 LOCALBASE?=		${DESTDIR}/usr/local
 X11BASE?=		${DESTDIR}/usr/X11R6
 LINUXBASE?=		${DESTDIR}/compat/linux
@@ -3068,11 +3078,20 @@
 	@${ALL-DEPENDS-LIST}
 
 ALL-DEPENDS-LIST= \
+	parents="${PARENTS} ${.CURDIR}"; \
 	checked="${PARENT_CHECKED}"; \
-	for dir in $$(${ECHO_CMD} "${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${RUN_DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//') $$(${ECHO_CMD} ${DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/:.*//'); do \
+	for dir in $$( { ${ECHO_CMD} "${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${RUN_DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//' ; ${ECHO_CMD} ${DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/:.*//'; } | sort -u); do \
 		if [ -d $$dir ]; then \
-			if (${ECHO_CMD} $$checked | ${GREP} -qwv "$$dir"); then \
-				child=$$(cd $$dir; ${MAKE} PARENT_CHECKED="$$checked" all-depends-list); \
+			for p in $$parents; do \
+				if [ "$$p" = "$$dir" ]; then \
+					${ECHO_MSG} "Dependency loop:" >&2; \
+					${ECHO_MSG} "${.CURDIR} => $$p" >&2; \
+					${ECHO_MSG} "" >&2; \
+					exit 1;\
+				fi; \
+			done; \
+			if $$( for c in $$checked; do if [ "$$dir" = "$$c" ]; then exit 1; fi ; done ); then \
+				child=$$(cd $$dir; ${MAKE} PARENTS="$$parents" PARENT_CHECKED="$$checked" all-depends-list); \
 				for d in $$child; do ${ECHO_CMD} $$d; done; \
 				${ECHO_CMD} $$dir; \
 				checked="$$dir $$child $$checked"; \
@@ -3155,11 +3174,20 @@
 	if [ "${CHILD_DEPENDS}" ]; then \
 		${ECHO_CMD} "${PKGNAME}	${.CURDIR}"; \
 	fi; \
+	parents="${PARENTS} ${.CURDIR}"; \
 	checked="${PARENT_CHECKED}"; \
-	for dir in $$(${ECHO_CMD} "${LIB_DEPENDS} ${RUN_DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//') $$(${ECHO_CMD} ${DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/:.*//'); do \
+	for dir in $$( { ${ECHO_CMD} "${LIB_DEPENDS} ${RUN_DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//' ; ${ECHO_CMD} ${DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/:.*//'; } | sort -u); do \
 		if [ -d $$dir ]; then \
-			if (${ECHO_CMD} $$checked | ${GREP} -qwv "$$dir"); then \
-				childout=$$(cd $$dir; ${MAKE} CHILD_DEPENDS=yes PARENT_CHECKED="$$checked" package-depends-list); \
+			for p in $$parents; do \
+				if [ "$$p" = "$$dir" ]; then \
+					${ECHO_MSG} "Dependency loop:" >&2; \
+					${ECHO_MSG} "${.CURDIR} => $$p" >&2; \
+					${ECHO_MSG} "" >&2; \
+					exit 1;\
+				fi; \
+			done; \
+			if $$( for c in $$checked; do if [ "$$dir" = "$$c" ]; then exit 1; fi ; done ); then \
+				childout=$$(cd $$dir; ${MAKE} CHILD_DEPENDS=yes PARENTS="$$parents" PARENT_CHECKED="$$checked" package-depends-list); \
 				set -- $$childout; \
 				childname=""; childdir=""; \
 				while [ $$\# != 0 ]; do \
@@ -3173,7 +3201,7 @@
 		else \
 			${ECHO_MSG} "${PKGNAME}: \"$$dir\" non-existent -- dependency list incomplete" >&2; \
 		fi; \
-	done
+	done | sort -u
 
 # Print out package names.
 

--IS0zKkzwUGydFO0o--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




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