Time to abandon recursive pulling of dependencies?

Stephen Montgomery-Smith stephen at math.missouri.edu
Wed May 16 21:01:58 UTC 2007


Ok chaps, I think I have it.

This involves no recursive calls of make.  Furthermore the dependencies 
it creates are the real dependencies on your system, not what ports 
thinks it should be, because it gets all the information from 
/var/db/pkg.  On my system it takes a second or two to register a port - 
it takes about the same amount of time whether it has few dependencies 
or many, except when there are zero dependencies, when it takes no time 
at all.

If I get some positive feedback on this one, I'll submit a PR.  You can 
try it out by typing "make actual-package-depends" as opposed to "make 
package-depends."

Stephen

-------------- next part --------------
--- bsd.port.mk-orig	Mon May 14 09:28:42 2007
+++ bsd.port.mk	Wed May 16 15:51:44 2007
@@ -2387,7 +2387,7 @@
 DISABLE_CONFLICTS=	YES
 .endif
 .if !defined(PKG_ARGS)
-PKG_ARGS=		-v -c -${COMMENT:Q} -d ${DESCR} -f ${TMPPLIST} -p ${PREFIX} -P "`cd ${.CURDIR} && ${MAKE} package-depends | ${GREP} -v -E ${PKG_IGNORE_DEPENDS} | ${SORT} -u`" ${EXTRA_PKG_ARGS} $${_LATE_PKG_ARGS}
+PKG_ARGS=		-v -c -${COMMENT:Q} -d ${DESCR} -f ${TMPPLIST} -p ${PREFIX} -P "`cd ${.CURDIR} && ${MAKE} actual-package-depends | ${GREP} -v -E ${PKG_IGNORE_DEPENDS} | ${SORT} -u`" ${EXTRA_PKG_ARGS} $${_LATE_PKG_ARGS}
 .if !defined(NO_MTREE)
 PKG_ARGS+=		-m ${MTREE_FILE}
 .endif
@@ -5216,10 +5216,46 @@
 		fi; \
 	done
 
+ACTUAL-PACKAGE-DEPENDS?= \
+	if [ "${_LIB_RUN_DEPENDS}" != "  " ]; then \
+		origins=$$(for pkgname in ${PKG_DBDIR}/*; do \
+			if [ -e $$pkgname/+CONTENTS ]; then \
+				basename $$pkgname; \
+				${SED} -n -e "s/@comment ORIGIN://p" $$pkgname/+CONTENTS; \
+			fi; \
+		done); \
+		pkgs=$$(for dir in ${_LIB_RUN_DEPENDS:C,[^:]*:([^:]*):?.*,\1,}; do \
+			dir=`dirname $$dir | xargs basename`/`basename $$dir`; \
+			set -- $$origins; \
+			while [ $$\# != 0 ]; do \
+				if [ $$dir = $$2 ]; then \
+					${ECHO_CMD} $$1; \
+					if [ -e ${PKG_DBDIR}/$$1/+CONTENTS ]; then \
+						${SED} -n -e "s/@pkgdep //p" ${PKG_DBDIR}/$$1/+CONTENTS; \
+					fi; \
+				fi; \
+				shift 2; \
+			done; \
+		done | sort -u); \
+		for pkgname in $$pkgs; do \
+			set -- $$origins; \
+			while [ $$\# != 0 ]; do \
+				if [ $$pkgname = $$1 ]; then \
+					${ECHO_CMD} $$1:$$2; \
+					break; \
+				fi; \
+				shift 2; \
+			done; \
+		done; \
+	fi
+
 # Print out package names.
 
 package-depends:
 	@${PACKAGE-DEPENDS-LIST} | ${AWK} '{print $$1":"$$3}'
+
+actual-package-depends:
+	@${ACTUAL-PACKAGE-DEPENDS}
 
 # Build packages for port and dependencies
 


More information about the freebsd-ports mailing list