Subject: patches to bulk build
To: None <tech-pkg@NetBSD.org>
From: Dan McMahill <dmcmahill@NetBSD.org>
List: tech-pkg
Date: 03/10/2005 17:18:28
--3MwIy2ne0vdjdPXF
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Can someone do a sanity check over this patch?  It works around
the problem where grep on solaris (and maybe others) drops long
lines in input files.  It seems to be working for me on solaris-2.9,
but I'd appreciate comments on a cleaner way to do this.

-Dan

-- 

--3MwIy2ne0vdjdPXF
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diffs

Index: mk/bulk/bsd.bulk-pkg.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bulk/bsd.bulk-pkg.mk,v
retrieving revision 1.74
diff -u -2 -r1.74 bsd.bulk-pkg.mk
--- mk/bulk/bsd.bulk-pkg.mk	27 Jan 2005 17:55:42 -0000	1.74
+++ mk/bulk/bsd.bulk-pkg.mk	10 Mar 2005 21:29:28 -0000
@@ -144,4 +144,6 @@
 _PRESERVE_WRKDIR?=	no
 
+_ESCPATH=	${PKGPATH:C@\/@\\/@g:C@\+@\\+@g:C@\.@\\.@g:Q}
+
 # build the cache files used as part of a full bulk build
 # Note:  we have to install the BULK_PREREQ packages _before_
@@ -298,5 +300,5 @@
 		${ECHO_MSG} "BULK> Cleaning package and its depends" ;\
 		if [ "${USE_BULK_CACHE}" = "yes" ]; then \
-			for pkgdir in ${PKGPATH} `${GREP} "^${PKGPATH} " ${DEPENDSFILE} | ${SED} -e 's;^.*:;;g'`; do \
+			for pkgdir in ${PKGPATH} `${SED} -n -e "/^${_ESCPATH} / s;^[^:]*:;;p" ${DEPENDSFILE}`; do \
 				${DO}       (cd ${PKGSRCDIR}/$$pkgdir && ${MAKE} clean) ; \
 			done ;\
@@ -316,5 +318,7 @@
 					if ${PKG_INFO} -qe $$pkgname ; then \
 						${SHCOMMENT} "Remove only unneeded pkgs" ; \
-						if ${EGREP} "^${PKGPATH} .* $$pkgdir( |$$)" ${DEPENDSFILE} >/dev/null 2>&1; then \
+						pkgdir2=`${ECHO} "$$pkgdir" | ${AWK} '{gsub(/\//,"\\\\/"); gsub(/\+/,"\\\\+"); gsub(/ /,"\\\\ "); gsub(/\./,"\\\\."); print}'` ; \
+						tmp=`${SED} -n -e "/^${_ESCPATH} .* $$pkgdir2 / s;.*;yes;p" ${DEPENDSFILE}` ; \
+						if test "X$$tmp" = "Xyes" ; then \
 							${ECHO_MSG} "BULK> ${PKGNAME} requires installed package $$pkgname ($$pkgdir) to build." ;\
 						else \
@@ -346,5 +350,5 @@
 			${SHCOMMENT} "Install required depends via binarypkgs XXX" ; \
 			${ECHO_MSG} "BULK> Installing packages which are required to build ${PKGNAME}." ;\
-			for pkgdir in `${GREP} "^${PKGPATH} " ${DEPENDSFILE} | ${SED} -e 's;^.*:;;g'` ${BULK_PREREQ} ; do \
+			for pkgdir in `${SED} -n -e "/^${_ESCPATH} / s;^[^:]*;;p" ${DEPENDSFILE}` ${BULK_PREREQ} ; do \
 				pkgname=`${GREP} "^$$pkgdir " ${INDEXFILE} | ${AWK} '{print $$2}'` ; \
 				if [ -z "$$pkgname" ]; then continue ; fi ;\
@@ -397,5 +401,7 @@
 			if [ "${USE_BULK_CACHE}" = "yes" ]; then \
 				${ECHO_MSG} "BULK> Marking all packages which depend upon ${PKGNAME} as broken:"; \
-				for pkgdir in `${GREP} "^${PKGPATH} " ${SUPPORTSFILE} | ${SED} -e 's;^.*:;;g'`; do \
+				tmp=`${SED} -n -e "/^${_ESCPATH} / s;^[^:]*:[ \t]*;;p" ${SUPPORTSFILE}` ; \
+				if test -n "$$tmp" ; then \
+				for pkgdir in $$tmp ; do \
 					pkgname=`${GREP} "^$$pkgdir " ${INDEXFILE} | ${AWK} '{print $$2}'` ;\
 					if [ -z "$$pkgname" ]; then pkgname=unknown ; fi ; \
@@ -423,4 +429,5 @@
 					fi ;\
 				done ;\
+				fi ;\
 			fi ;\
 			nerrors=`${GREP} -c '^\*\*\* Error code' ${BROKENFILE} || true`; \
@@ -435,5 +442,5 @@
 		*)	${ECHO_MSG} "BULK> Cleaning packages and its depends"; \
 		 	if [ "${USE_BULK_CACHE}" = "yes" ]; then	\
-				for pkgdir in ${PKGPATH} `${GREP} "^${PKGPATH} " ${DEPENDSFILE} | ${SED} -e 's;^.*:;;g'`; do \
+				for pkgdir in ${PKGPATH} `${SED} -n -e "/^${_ESCPATH} / s;^[^:]*:;;p" ${DEPENDSFILE}`; do \
 					${DO}       (cd ${PKGSRCDIR}/$$pkgdir && ${MAKE} clean) ; \
 				done;					\

--3MwIy2ne0vdjdPXF--