ports/55841: [patch] Mk/bsd.port.mk: add routines to use ${PORTSDIR}/MOVED to find moved dependencies.

Clement Laforet sheepkiller at cultdeadsheep.org
Mon Aug 25 08:52:09 UTC 2003


Cleaner rewrite of this patch.
Changelog:
	- Add 2 subroutines FIND-MOVED-DEPENDS and CHECK-MOVED-DEPENDS for better intregation
	  (i.e it's easier to add it to a function) and avoiding duplicate code. [me]
	- Rewrite "make describe" perl code [Sergey Matveychuk]
	- Various fixes [Sergey Matveychuk / me]

Once more, thanks to Sergey Matveychuk <sem at ciam.ru> for his reviews, tests, fixes, perl code and endless patience :)

----

Index: bsd.port.mk
===================================================================
RCS file: /WORK/ports/REPO/ports/Mk/bsd.port.mk,v
retrieving revision 1.462
diff -u -r1.462 bsd.port.mk
--- bsd.port.mk	15 Aug 2003 22:57:58 -0000	1.462
+++ bsd.port.mk	25 Aug 2003 08:41:56 -0000
@@ -920,6 +920,7 @@
 .else
 INDEXFILE?=		INDEX
 .endif
+MOVEDFILE?=		MOVED
 .if defined(USE_BZIP2)
 EXTRACT_SUFX?=			.tar.bz2
 .elif defined(USE_ZIP)
@@ -3731,6 +3732,48 @@
 # Dependency checking
 ################################################################
 
+# Subroutines:
+#   FIND-MOVED-DEPENDS: 
+#			checks in ${PORTSDIR}/${MOVEDFILE} if dependencyhas moved, and if so prints 
+#			its new location silently.
+#   CHECK-MOVED-DEPENDS: 
+#			checks in ${PORTSDIR}/${MOVEDFILE} if dependency has moved, and if so, prints 
+#			its new location verbosely.
+
+FIND-MOVED-DEPENDS= \
+		if [ ! -d $$dir ]; then \
+			newdir=`${EGREP} "^$${dir\#\#${PORTSDIR}/}\|" ${PORTSDIR}/${MOVEDFILE} | \
+			${AWK} -F\| ' $$2 ~ /^[a-z]+/ { print "${PORTSDIR}/" $$2};'`; \
+			if ([ X$${newdir} != "X" ] && [ -d $$newdir ]); then dir=$$newdir; fi; \
+		fi
+
+CHECK-MOVED-DEPENDS= \
+			if [ X$$lib != X ] ; then \
+				missing=$$lib; \
+			elif [ X$$prog != X ] ; then \
+				missing=$$prog; \
+			else \
+				missing="unknow";\
+			fi; \
+			if [ ! -d $$dir ]; then \
+				newdir=`${EGREP} "^$${dir\#\#${PORTSDIR}/}\|" ${PORTSDIR}/${MOVEDFILE} | \
+				${AWK} -F\| ' $$2 ~ /^$$/ {print $$1" has been removed on " $$3 ". reason: "$$4; exit }; \
+				{ print "${PORTSDIR}/" $$2};'` ;\
+				if ( [ `echo "$$newdir" | wc -w` -gt "1" ] ); then \
+					${ECHO_MSG} "     >> $$newdir"; \
+					${ECHO_MSG} "     >> Please inform the maintainer (${MAINTAINER})."; \
+				elif ( [  X$$newdir != "X" ] ) ; then \
+					${ECHO_MSG} "     >> DEPENDENCY HAS MOVED to $$newdir";\
+					${ECHO_MSG} "     >> Please inform the maintainer (${MAINTAINER})"; \
+					if [ -d "$$newdir" ]; then \
+						${ECHO_MSG} "===>    Verifying $$target for $$missing in $$dir"; \
+						dir=$$newdir; \
+					fi; \
+				else \
+						${ECHO_MSG} "     >> Can't find any revelant information in ${PORTSDIR}/${MOVEDFILE}"; \
+				fi;\
+			fi
+
 .if !target(depends)
 depends: extract-depends patch-depends lib-depends misc-depends fetch-depends build-depends run-depends
 
@@ -3783,6 +3826,7 @@
 		fi; \
 		if [ $$notfound != 0 ]; then \
 			${ECHO_MSG} "===>    Verifying $$target for $$prog in $$dir"; \
+			${CHECK-MOVED-DEPENDS} ; \
 			if [ ! -d "$$dir" ]; then \
 				${ECHO_MSG} "     >> No directory for $$prog.  Skipping.."; \
 			else \
@@ -3839,6 +3883,7 @@
 		fi; \
 		if [ $$notfound != 0 ]; then \
 			${ECHO_MSG} "===>    Verifying $$target for $$lib in $$dir"; \
+			${CHECK-MOVED-DEPENDS} ; \
 			if [ ! -d "$$dir" ]; then \
 				${ECHO_MSG} "     >> No directory for $$lib.  Skipping.."; \
 			else \
@@ -3898,6 +3943,7 @@
 ALL-DEPENDS-LIST= \
 	checked="${PARENT_CHECKED}"; \
 	for dir in $$(${ECHO_CMD} "${EXTRACT_DEPENDS} ${PATCH_DEPENDS} ${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 \
+		${FIND-MOVED-DEPENDS} ;\
 		if [ -d $$dir ]; then \
 			if (${ECHO_CMD} $$checked | ${GREP} -qwv "$$dir"); then \
 				child=$$(cd $$dir; ${MAKE} PARENT_CHECKED="$$checked" all-depends-list); \
@@ -4011,6 +4057,7 @@
 
 BUILD-DEPENDS-LIST= \
 	for dir in $$(${ECHO_CMD} "${EXTRACT_DEPENDS} ${PATCH_DEPENDS} ${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//' | sort -u) $$(${ECHO_CMD} ${DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/:.*//' | sort -u); do \
+		${FIND-MOVED-DEPENDS} ;\
 		if [ -d $$dir ]; then \
 			${ECHO_CMD} $$dir; \
 		else \
@@ -4023,6 +4070,7 @@
 
 RUN-DEPENDS-LIST= \
 	for dir in $$(${ECHO_CMD} "${LIB_DEPENDS} ${RUN_DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//' | sort -u) $$(${ECHO_CMD} ${DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/:.*//' | sort -u); do \
+		${FIND-MOVED-DEPENDS} ;\
 		if [ -d $$dir ]; then \
 			${ECHO_CMD} $$dir; \
 		else \
@@ -4053,6 +4101,7 @@
 	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 \
 		dir=$$(${REALPATH} $$dir); \
+		${FIND-MOVED-DEPENDS} ;\
 		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); \
@@ -4123,7 +4172,30 @@
 			my @dirs = @$$i; \
 			@$$i = (); \
 			for (@dirs) { \
-				if (-d $$_) { \
+				my $$direxists = 0;\
+ 				if (-d $$_) { \
+					$$direxists = 1;\
+				} else { \
+					s!${PORTSDIR}/!!; \
+					my $$cond=$$_; \
+					open(MIGRATE,"${PORTSDIR}/${MOVEDFILE}");\
+					while (<MIGRATE>) { \
+						if (/^$$cond\|/) { \
+							(my $$origdir, $$newdir, my $$date, my $$reason) = split (/\|/); \
+							if ( $$newdir && -d "${PORTSDIR}/$$newdir" ) { \
+								$$portdir = "${PORTSDIR}/$$newdir"; \
+								print STDERR qq{${PKGNAME}: \"$$origdir\" moved to \"$$portdir\" on $$date}; \
+								$$direxists = 1; \
+							} else { \
+								print STDERR qq{${PKGNAME}: \"$$origdir\" removed on $$date \($$reason\)\n}; \
+								$$portdir = "${PORTSDIR}/$$origdir";\
+								} \
+							} \
+						} \
+				close(MIGRATE); \
+				$$_=$$portdir; \
+				}; \
+				if($$direxists) { \
 					push @$$i, $$_; \
 				} else { \
 					print STDERR qq{${PKGNAME}: \"$$_\" non-existent -- dependency list incomplete\n}; \



More information about the freebsd-ports-bugs mailing list