Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 May 2011 15:23:27 +0000 (UTC)
From:      Colin Percival <cperciva@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r221780 - head/usr.sbin/freebsd-update
Message-ID:  <201105111523.p4BFNRCp095325@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201105111523.p4BFNRCp095325>