From owner-freebsd-ports@FreeBSD.ORG Sun Aug 17 04:56:51 2003 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 429A937B401 for ; Sun, 17 Aug 2003 04:56:51 -0700 (PDT) Received: from cultdeadsheep.org (charon.cultdeadsheep.org [80.65.226.72]) by mx1.FreeBSD.org (Postfix) with ESMTP id 95B0543F85 for ; Sun, 17 Aug 2003 04:56:47 -0700 (PDT) (envelope-from sheepkiller@cultdeadsheep.org) Received: (qmail 88545 invoked from network); 17 Aug 2003 11:56:44 -0000 Received: from unknown (HELO lucifer.cultdeadsheep.org) (192.168.0.2) by goofy.cultdeadsheep.org with SMTP; 17 Aug 2003 11:56:44 -0000 Date: Sun, 17 Aug 2003 13:56:46 +0200 From: Clement Laforet To: ports@FreeBSD.org Message-Id: <20030817135646.37e98624.sheepkiller@cultdeadsheep.org> Organization: tH3 cUlt 0f tH3 d3@d sH33p X-Mailer: Sylpheed version 0.9.4 (GTK+ 1.2.10; i386-portbld-freebsd5.1) X-Face: ._cVVRDn#-2((lnfi^P7CoD4htI$4+#G/G)!w|,}H5yK~%(3-C.JlEYbOjJGFwJkt*7N^%z jYeu[;}]}F"3}l5R'l"X0HbvT^D\Q&%deCo)MayY`);TO Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: RFC: patch for bsd.port.mk to use ${PORTSDIR}/MOVED X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Aug 2003 11:56:51 -0000 Hi, This night I wrote a patch for bsd.port.mk to make it use ${PORTSDIR}/MOVED to find moved dependencies. It was primarily written to make a smooth migration from current 2 levels ports tree to a hypothetic 3 levels ports tree, but it can be used for "transparent" translation from a renamed dependency or a moved port to a new location (if the dependency was deleted you'll have a warn). For the moment the patch is suboptimal and doesn't support double checks (i.e. when a port matches in ${PORTSDIR}/MOVED, and its "translation" is errorneous, it doesn't work, it fails silently). In some cases, like BUILD-DEPENDS-LISTS and RUN-DEPENDS-LIST, I wasn't able to add a check to avoid a useless lookup in ${PORTSDIR}/MOVED. The main advantage of this patch is that it easily keeps (for a short period of time) ports tree consistency. I've tested it mostly with a "test port" which have : 1 "misfiled", 1 deleted and 1 moved RUN_DEPENDS 1 "misfiled", 1 deleted and 1 moved BUILD_DEPENDS 1 "misfiled", 1 deleted and 1 moved LIB_DEPENDS And it seems to work with all this port commands : - all related to RUN-DEPENDS-LIST - all related to ALL-DEPENDS-LIST - all related to BUILD-DEPENDS-LIST - package-depends-list - LIB_DEPENDS (i.e. make depends and port building) - make descride (what a dirty patch !! I'm not a perl guru ;-)) Maybe I forgot some function. Before spamming PR database and portmgr, I would appreciate any comments, ideas, improvements or whatever you want about this patch :-) The patch can also be found here: http://www.cultdeadsheep.org/sheepkiller/FreeBSD/ports-devel/use-movedfile-bsd.port.mk.diff Regards, clem Index: bsd.port.mk =================================================================== RCS file: /WORK/CVS/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 17 Aug 2003 10:31:55 -0000 @@ -920,6 +920,7 @@ .else INDEXFILE?= INDEX .endif +MOVEDFILE?= MOVED .if defined(USE_BZIP2) EXTRACT_SUFX?= .tar.bz2 .elif defined(USE_ZIP) @@ -3839,8 +3840,28 @@ fi; \ if [ $$notfound != 0 ]; then \ ${ECHO_MSG} "===> Verifying $$target for $$lib in $$dir"; \ + direxists=1; \ if [ ! -d "$$dir" ]; then \ - ${ECHO_MSG} " >> No directory for $$lib. Skipping.."; \ + 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 ( [ -d "$$newdir" ] ) ; then \ + dir=$$newdir; \ + ${ECHO_MSG} " >> DEPENDENCY HAS MOVED to $$newdir";\ + ${ECHO_MSG} " >> Please informs the maintainer (${MAINTAINER})"; \ + ${ECHO_MSG} "===> Verifying $$target for $$lib in $$dir"; \ + direxists=0; \ + 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)`; \ @@ -3898,6 +3919,11 @@ 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 \ + if [ ! -d $$dir ] ; then \ + newdir=`${EGREP} "^$${dir\#\#${PORTSDIR}/}\|" ${PORTSDIR}/${MOVEDFILE} | \ + ${AWK} -F\| ' $$2 ~ /^[a-z]+/ { print "${PORTSDIR}/" $$2};'`; \ + [ $${\#newdir} -ge 1 ] && [ -d $$newdir ] && dir=$$newdir; \ + fi; \ if [ -d $$dir ]; then \ if (${ECHO_CMD} $$checked | ${GREP} -qwv "$$dir"); then \ child=$$(cd $$dir; ${MAKE} PARENT_CHECKED="$$checked" all-depends-list); \ @@ -3906,7 +3932,7 @@ checked="$$dir $$child $$checked"; \ fi; \ else \ - ${ECHO_MSG} "${PKGNAME}: \"$$dir\" non-existent -- dependency list incomplete" >&2; \ + ${ECHO_MSG} "${PKGNAME}: \"$$dir\" non-existent -- dependency list incomplete " >&2; \ fi; \ done | sort -u @@ -4011,6 +4037,9 @@ 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 \ + newdir=`${EGREP} "^$${dir\#\#${PORTSDIR}/}\|" ${PORTSDIR}/${MOVEDFILE} | \ + ${AWK} -F\| ' $$2 ~ /^[a-z]+/ { print "${PORTSDIR}/" $$2};'`; \ + [ $${\#newdir} -ge 1 ] && [ -d $$newdir ] && dir=$$newdir; \ if [ -d $$dir ]; then \ ${ECHO_CMD} $$dir; \ else \ @@ -4023,6 +4052,9 @@ 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 \ + newdir=`${EGREP} "^$${dir\#\#${PORTSDIR}/}\|" ${PORTSDIR}/${MOVEDFILE} | \ + ${AWK} -F\| ' $$2 ~ /^$$/ {print "FALSE"; exit}; { print "${PORTSDIR}/" $$2};'`; \ + [ "$$newdir" != "" ] && [ -d $$newdir ] && dir=$$newdir;\ if [ -d $$dir ]; then \ ${ECHO_CMD} $$dir; \ else \ @@ -4053,6 +4085,11 @@ 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); \ + if [ ! -d $$dir ] ; then \ + newdir=`${EGREP} "^$${dir\#\#${PORTSDIR}/}\|" ${PORTSDIR}/${MOVEDFILE} | \ + ${AWK} -F\| ' $$2 ~ /^[a-z]+/ { print "${PORTSDIR}/" $$2};'`; \ + [ $${\#newdir} -ge 1 ] && [ -d $$newdir ] && dir=$$newdir; \ + fi; \ 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,10 +4160,30 @@ my @dirs = @$$i; \ @$$i = (); \ for (@dirs) { \ + my $$portdir = $$_ ; \ + my $$direxists = 1;\ if (-d $$_) { \ - push @$$i, $$_; \ + $$direxists = 0;\ + } else { \ + my $$portsdir="${PORTSDIR}"; \ + $$_ =~ s/$$portsdir\///;\ + my $$newdir = my $$cond = $$_ ; \ + open(MIGRATE,"${PORTSDIR}/${MOVEDFILE}");\ + while () { \ + 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}: \"$$_\" non-existent -- dependency list incomplete\n}; \ + print STDERR qq{${PKGNAME}: \"$$portdir\" non-existent -- dependency list incomplete\n}; \ } \ } \ } \