svn commit: r290013 - user/cperciva/freebsd-update-build/scripts

Gleb Smirnoff glebius at FreeBSD.org
Mon Oct 26 15:50:41 UTC 2015


Author: glebius
Date: Mon Oct 26 15:50:39 2015
New Revision: 290013
URL: https://svnweb.freebsd.org/changeset/base/290013

Log:
  New code for applypatches().
  
  - Understands diffs generated by diff(1), not only subversion.
  - Removes empty files after patching.
  - With a patch queue doesn't batch patching and removing,
    instead iterates over queue, and does removals after
    each patch. Slower, but less prone to errors.
  
  Sponsored by:	Nginx, Inc.

Modified:
  user/cperciva/freebsd-update-build/scripts/build.subr

Modified: user/cperciva/freebsd-update-build/scripts/build.subr
==============================================================================
--- user/cperciva/freebsd-update-build/scripts/build.subr	Mon Oct 26 15:43:08 2015	(r290012)
+++ user/cperciva/freebsd-update-build/scripts/build.subr	Mon Oct 26 15:50:39 2015	(r290013)
@@ -397,20 +397,19 @@ extractworld () {
 
 # Apply a list of patches stored in $2 to a world in ${WORKDIR}/$1
 applypatches () {
+	cd ${WORKDIR}/$1/usr/src
 	while read PATCH; do
-		cat ${PATCHDIR}/${PATCH} |
-			( cd ${WORKDIR}/$1/usr/src && patch -p0 )
+		patch -p0 < ${PATCHDIR}/${PATCH}
+		# Remove ".orig" files created by patch(1) and empty files
+		for file in $(awk '$1 ~ /^(Index:|diff)/ { print $NF }' < \
+		    ${PATCHDIR}/${PATCH}); do
+			echo ${file}.orig
+			if [ ! -s ${file} ]; then
+				echo ${file}
+			fi
+		done | xargs rm -f
 	done < $2 2> ${WORKDIR}/$1-patch.log
-
-	# Remove ".orig" files created by patch(1)
-	cat $2 |
-	    lam -s "${PATCHDIR}/" - |
-	    xargs cat |
-	    grep -E '^Index: ' |
-	    cut -f 2 -d ' ' |
-	    lam - -s '.orig' |
-	    sort -u |
-	    ( cd ${WORKDIR}/$1/usr/src && xargs rm )
+	cd -
 }
 
 # In a world at ${WORKDIR}/$1, edit src/sys/conf/newvers.sh to


More information about the svn-src-user mailing list