Date: Sun, 17 Aug 2003 13:56:46 +0200 From: Clement Laforet <sheepkiller@cultdeadsheep.org> To: ports@FreeBSD.org Subject: RFC: patch for bsd.port.mk to use ${PORTSDIR}/MOVED Message-ID: <20030817135646.37e98624.sheepkiller@cultdeadsheep.org>
next in thread | raw e-mail | index | archive | help
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 (<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}: \"$$_\" non-existent -- dependency list incomplete\n}; \ + print STDERR qq{${PKGNAME}: \"$$portdir\" non-existent -- dependency list incomplete\n}; \ } \ } \ } \
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030817135646.37e98624.sheepkiller>