From sheepkiller@cultdeadsheep.org  Thu Aug 21 09:59:09 2003
Return-Path: <sheepkiller@cultdeadsheep.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 5F45016A4C0
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 21 Aug 2003 09:59:09 -0700 (PDT)
Received: from cultdeadsheep.org (charon.cultdeadsheep.org [80.65.226.72])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 73FD143FA3
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 21 Aug 2003 09:59:07 -0700 (PDT)
	(envelope-from sheepkiller@cultdeadsheep.org)
Received: (qmail 80123 invoked from network); 21 Aug 2003 16:59:05 -0000
Received: from unknown (HELO lucifer.cultdeadsheep.org) (192.168.0.2)
  by goofy.cultdeadsheep.org with SMTP; 21 Aug 2003 16:59:05 -0000
Received: by lucifer.cultdeadsheep.org (sSMTP sendmail emulation); Thu, 21 Aug 2003 18:58:52 +0200
Message-Id: <20030821165907.73FD143FA3@mx1.FreeBSD.org>
Date: Thu, 21 Aug 2003 18:58:52 +0200
From: "Clement Laforet" <sheepkiller@cultdeadsheep.org>
Reply-To: Clement Laforet <sheepkiller@cultdeadsheep.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc: Clement Laforet <sheepkiller@cultdeadsheep.org>
Subject: [patch] Mk/bsd.port.mk: add routines to use ${PORTSDIR}/MOVED to find moved dependencies.
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         55841
>Category:       ports
>Synopsis:       [patch] Mk/bsd.port.mk: add routines to use ${PORTSDIR}/MOVED to find moved dependencies.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    portmgr
>State:          suspended
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Aug 21 10:00:31 PDT 2003
>Closed-Date:    
>Last-Modified:  Fri May 25 02:52:16 GMT 2007
>Originator:     Clement Laforet
>Release:        FreeBSD 5.1-CURRENT i386
>Organization:
cotds.org
>Environment:
System: FreeBSD lucifer.cultdeadsheep.org 5.1-CURRENT FreeBSD 5.1-CURRENT #1: Mon Aug 18 15:22:08 CEST 2003 clement@lucifer.cultdeadsheep.org:/usr/obj/usr/src/sys/LUCIFER i386


	
>Description:
        When a port is removed, renamed, moved or split, dependencies can be broken for a while.
        Usually Kris INDEX checker notifies ports@ that ports tree is broken, but optionnal knobs
        are ignored by make describe, so some dependency can remain broken until someone notifies it.
        First patch [1] prevents ports tree from being broken by obsolete dependencies changes, and then
        keeps its consistency. It uses MOVED file to find the new location.

        Second patch [2] just adds a verbose output to "make describe" for Kris INDEX checker.

>How-To-Repeat:
	N/A.
>Fix:

	

[1]
--- USE_MOVEDFILE-bsd.ports.mk.diff begins here ---
Index: bsd.port.mk
===================================================================
RCS file: /TESTBSD/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	21 Aug 2003 10:31:02 -0000
@@ -920,6 +920,7 @@
 .else
 INDEXFILE?=		INDEX
 .endif
+MOVEDFILE?=		MOVED
 .if defined(USE_BZIP2)
 EXTRACT_SUFX?=			.tar.bz2
 .elif defined(USE_ZIP)
@@ -3783,6 +3784,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,8 +3841,30 @@
 		fi; \
 		if [ $$notfound != 0 ]; then \
 			${ECHO_MSG} "===>    Verifying $$target for $$lib in $$dir"; \
-			if [ ! -d "$$dir" ]; then \
-				${ECHO_MSG} "     >> No directory for $$lib.  Skipping.."; \
+			direxists=1; \
+			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 informs the maintainer (${MAINTAINER})"; \
+				elif ( [  X$$newdir != "X" ] ) ; then \
+					dir=$$newdir; \
+					${ECHO_MSG} "     >> DEPENDENCY HAS MOVED to $$newdir";\
+					${ECHO_MSG} "     >> Please inform the maintainer (${MAINTAINER})"; \
+					if [ -d "$$newdir" ]; then \
+						${ECHO_MSG} "===>    Verifying $$target for $$lib in $$dir"; \
+						direxists=0; \
+					fi; \
+				else \
+						${ECHO_MSG} "     >> Can't find any informations in ${PORTSDIR}/${MOVEDFILE}"; \
+				fi;\
+			else \
+				direxists=0; \
+			fi; \
+			if [ ! "$$direxists" -eq "0" ]; then \
+				${ECHO_MSG} "     >> No directory for $$lib.  Skipping..."; \
 			else \
 				if [ X${USE_PACKAGE_DEPENDS} != "X" ]; then \
 					subpkgfile=`(cd $$dir; ${MAKE} $$depends_args -V PKGFILE)`; \
@@ -3891,6 +3915,12 @@
 .endif
 
 # Dependency lists: both build and runtime, recursive.  Print out directory names.
+CHECK-MOVED-DEPENDS= \
+		if [ ! -d $$dir ]; then \
+			newdir=`${EGREP} "^$${dir\#\#${PORTSDIR}/}\|" ${PORTSDIR}/${MOVEDFILE} | \
+			${AWK} -F\| ' $$2 ~ /^[a-z]+/ { print "${PORTSDIR}/" $$2};'`; \
+			[ X$${newdir} != "X" ] && [ -d $$newdir ] && dir=$$newdir; \
+		fi
 
 all-depends-list:
 	@${ALL-DEPENDS-LIST}
@@ -3898,6 +3928,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 \
+		${CHECK-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 +4042,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 \
+		${CHECK-MOVED-DEPENDS} ;\
 		if [ -d $$dir ]; then \
 			${ECHO_CMD} $$dir; \
 		else \
@@ -4023,6 +4055,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 \
+		${CHECK-MOVED-DEPENDS} ;\
 		if [ -d $$dir ]; then \
 			${ECHO_CMD} $$dir; \
 		else \
@@ -4053,6 +4086,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); \
+		${CHECK-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,12 +4157,32 @@
 			my @dirs = @$$i; \
 			@$$i = (); \
 			for (@dirs) { \
-				if (-d $$_) { \
-					push @$$i, $$_; \
+				my $$portdir = $$_ ; \
+				my $$direxists = 1;\
+ 				if (-d $$_) { \
+					$$direxists = 0;\
 				} else { \
-					print STDERR qq{${PKGNAME}: \"$$_\" non-existent -- dependency list incomplete\n}; \
-				} \
-			} \
+					my $$portsdir="${PORTSDIR}"; \
+					$$_ =~ s/$$portsdir\///;\
+					my $$newdir = my $$cond = $$_ ; \
+					open(MIGRATE,"${PORTSDIR}/${MOVEDFILE}");\
+					while (<MIGRATE>) { \
+						if (/^$$cond\|/) { \
+							(my $$origdir, $$newdir, my $$date, my $$reason) = split (/\|/); \
+							if ( -d "$$portsdir/$$newdir" && ( $$newdir ne "")) { \
+								$$portdir = "$$portsdir/$$newdir"; \
+								$$direxists = 0;\
+							} \
+						} \
+					}\
+					close(MIGRATE);\
+				}\
+				if ($$direxists eq "0") { \
+					push @$$i, $$portdir;\
+ 				} else { \
+					print STDERR qq{${PKGNAME}: \"$$portdir\" non-existent -- dependency list incomplete\n}; \
+ 				} \
+ 			} \
 		} \
 		for (@bdirs, @mdirs) { \
 			$$x{$$_} = 1; \
--- USE_MOVEDFILE-bsd.ports.mk.diff ends here ---


[2]
--- add-make-describe-warn.diff begins here ---
--- bsd.port.mk.old	Thu Aug 21 15:54:12 2003
+++ bsd.port.mk	Thu Aug 21 15:58:14 2003
@@ -4171,6 +4171,7 @@
 							(my $$origdir, $$newdir, my $$date, my $$reason) = split (/\|/); \
 							if ( -d "$$portsdir/$$newdir" && ( $$newdir ne "")) { \
 								$$portdir = "$$portsdir/$$newdir"; \
+								print STDERR qq{${PKGNAME}: \"$$origdir\" moved to \"$$newdir\" on $$date\n}; \
 								$$direxists = 0;\
 							} \
 						} \
--- add-make-describe-warn.diff ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->portmgr  
Responsible-Changed-By: krion 
Responsible-Changed-When: Thu Aug 21 10:49:27 PDT 2003 
Responsible-Changed-Why:  
portmgr territory 

http://www.freebsd.org/cgi/query-pr.cgi?pr=55841 

From: Clement Laforet <sheepkiller@cultdeadsheep.org>
To: FreeBSD-gnats-submit@FreeBSD.org, freebsd-ports-bugs@FreeBSD.org
Cc:  
Subject: Re: ports/55841: [patch] Mk/bsd.port.mk: add routines to use
 ${PORTSDIR}/MOVED to find moved dependencies.
Date: Mon, 25 Aug 2003 10:51:26 +0200

 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@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}; \
State-Changed-From-To: open->suspended 
State-Changed-By: linimon 
State-Changed-When: Fri May 25 02:51:10 UTC 2007 
State-Changed-Why:  
The underlying problem is that MOVED doesn't have enough fields in it 
to really specify the information that you would need to follow here. 
So, while this is a good idea, it needs further thought, patches, and 
testing for backwards compatibility. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=55841 
>Unformatted:
