diff options
author | cperciva <cperciva@FreeBSD.org> | 2011-05-11 15:23:27 +0000 |
---|---|---|
committer | cperciva <cperciva@FreeBSD.org> | 2011-05-11 15:23:27 +0000 |
commit | f436e25c59c208e30412c56aa0650dbe9121581d (patch) | |
tree | a33459650e2951a42fe85a318b204402a8ebe3d6 /usr.sbin | |
parent | 51b81d320e892f9941dfcac2cd98b55afcbf079f (diff) | |
download | FreeBSD-src-f436e25c59c208e30412c56aa0650dbe9121581d.zip FreeBSD-src-f436e25c59c208e30412c56aa0650dbe9121581d.tar.gz |
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
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/freebsd-update/freebsd-update.sh | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/usr.sbin/freebsd-update/freebsd-update.sh b/usr.sbin/freebsd-update/freebsd-update.sh index 0247e38..8dca87d 100644 --- a/usr.sbin/freebsd-update/freebsd-update.sh +++ b/usr.sbin/freebsd-update/freebsd-update.sh @@ -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 |