From owner-svn-src-user@freebsd.org Mon Oct 26 15:50:41 2015 Return-Path: Delivered-To: svn-src-user@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0CB838375 for ; Mon, 26 Oct 2015 15:50:41 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C90DD1326; Mon, 26 Oct 2015 15:50:40 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9QFodOX017627; Mon, 26 Oct 2015 15:50:39 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9QFodfp017626; Mon, 26 Oct 2015 15:50:39 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201510261550.t9QFodfp017626@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Mon, 26 Oct 2015 15:50:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r290013 - user/cperciva/freebsd-update-build/scripts X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Oct 2015 15:50:41 -0000 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