From owner-svn-src-head@FreeBSD.ORG Wed May 11 15:23:28 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 38CDC1065670; Wed, 11 May 2011 15:23:28 +0000 (UTC) (envelope-from cperciva@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1E1538FC0A; Wed, 11 May 2011 15:23:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p4BFNSTb095327; Wed, 11 May 2011 15:23:28 GMT (envelope-from cperciva@svn.freebsd.org) Received: (from cperciva@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p4BFNRCp095325; Wed, 11 May 2011 15:23:28 GMT (envelope-from cperciva@svn.freebsd.org) Message-Id: <201105111523.p4BFNRCp095325@svn.freebsd.org> From: Colin Percival Date: Wed, 11 May 2011 15:23:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r221780 - head/usr.sbin/freebsd-update X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 May 2011 15:23:28 -0000 Author: cperciva Date: Wed May 11 15:23:27 2011 New Revision: 221780 URL: http://svn.freebsd.org/changeset/base/221780 Log: Make freebsd-update(8) smarter in how it handles $FreeBSD$ tags in configuration files. If the current file differs from the canonical version from the old release only due to differences in the $FreeBSD$ tag (which can happen if the system was installed from source code, depending on how the src tree was checked out) then freebsd-update will treat the file as "unmodified" and silently update it to the "clean" version in the new release. If the only change being made to a configuration file is in the $FreeBSD$ tag (e.g., for any configuration files which have been modified locally, now that we're using SVN and the $FreeBSD$ tag changes when a branch is created), freebsd-update will no longer print the diff and prompt "Does this look reasonable (y/n)?". Nagged by: pgollucci MFC after: 1 month Modified: head/usr.sbin/freebsd-update/freebsd-update.sh Modified: head/usr.sbin/freebsd-update/freebsd-update.sh ============================================================================== --- head/usr.sbin/freebsd-update/freebsd-update.sh Wed May 11 13:40:13 2011 (r221779) +++ head/usr.sbin/freebsd-update/freebsd-update.sh Wed May 11 15:23:27 2011 (r221780) @@ -2254,6 +2254,19 @@ upgrade_oldall_to_oldnew () { mv $2 $3 } +# Helper for upgrade_merge: Return zero true iff the two files differ only +# in the contents of their $FreeBSD$ tags. +samef () { + X=`sed -E 's/\\$FreeBSD.*\\$/\$FreeBSD\$/' < $1 | ${SHA256}` + Y=`sed -E 's/\\$FreeBSD.*\\$/\$FreeBSD\$/' < $2 | ${SHA256}` + + if [ $X = $Y ]; then + return 0; + else + return 1; + fi +} + # From the list of "old" files in $1, merge changes in $2 with those in $3, # and update $3 to reflect the hashes of merged files. upgrade_merge () { @@ -2337,6 +2350,14 @@ upgrade_merge () { # Ask the user to handle any files which didn't merge. while read F; do + # If the installed file differs from the version in + # the old release only due to $FreeBSD$ tag expansion + # then just use the version in the new release. + if samef merge/old/${F} merge/${OLDRELNUM}/${F}; then + cp merge/${RELNUM}/${F} merge/new/${F} + continue + fi + cat <<-EOF The following file could not be merged automatically: ${F} @@ -2351,9 +2372,18 @@ manually... # Ask the user to confirm that he likes how the result # of merging files. while read F; do - # Skip files which haven't changed. - if [ -f merge/new/${F} ] && - cmp -s merge/old/${F} merge/new/${F}; then + # Skip files which haven't changed except possibly + # in their $FreeBSD$ tags. + if [ -f merge/old/${F} ] && [ -f merge/new/${F} ] && + samef merge/old/${F} merge/new/${F}; then + continue + fi + + # Skip files where the installed file differs from + # the old file only due to $FreeBSD$ tags. + if [ -f merge/old/${F} ] && + [ -f merge/${OLDRELNUM}/${F} ] && + samef merge/old/${F} merge/${OLDRELNUM}/${F}; then continue fi