From 8d54ee3c0ba5d513ea6b089716fc42547dc6d638 Mon Sep 17 00:00:00 2001 From: Doug Barton Date: Wed, 30 Dec 2009 23:14:03 +0000 Subject: [PATCH] Add some patches contributed by jhb: 1. Don't prompt the user for "-U but no db" error if we're using -a 2. Add an option to delete stale rc.d files automatically if the user has DELETE_STALE_RC_FILES in their rc file. Lack of command line option for this is not an oversight. 3. Add []'s around the terminal $ for the $FreeBSD$ test for -F For one bug raised by jhb I did a more thorough solution: There were a lot of things that "snuck in" between the end of the test for -r and the start of the comparison. One of them is the creation of the mtree db, as pointed out by jhb. Fix this problem more thoroughly by moving the end of the test down to where it should/used to be, right before the comparison. As a result, indent the interloping code to match. --- usr.sbin/mergemaster/mergemaster.sh | 63 +++++++++++++++++------------ 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/usr.sbin/mergemaster/mergemaster.sh b/usr.sbin/mergemaster/mergemaster.sh index 7a33c4d86566..5703bf36e568 100755 --- a/usr.sbin/mergemaster/mergemaster.sh +++ b/usr.sbin/mergemaster/mergemaster.sh @@ -358,7 +358,11 @@ case "${AUTO_UPGRADE}" in echo " Skipping auto-upgrade on this run." echo " It will be created for the next run when this one is complete." echo '' - press_to_continue + case "${AUTO_RUN}" in + '') + press_to_continue + ;; + esac unset AUTO_UPGRADE fi ;; @@ -665,33 +669,34 @@ case "${RERUN}" in for file in ${IGNORE_FILES}; do test -e ${TEMPROOT}/${file} && unlink ${TEMPROOT}/${file} done + + # We really don't want to have to deal with files like login.conf.db, pwd.db, + # or spwd.db. Instead, we want to compare the text versions, and run *_mkdb. + # Prompt the user to do so below, as needed. + # + rm -f ${TEMPROOT}/etc/*.db ${TEMPROOT}/etc/passwd + + # We only need to compare things like freebsd.cf once + find ${TEMPROOT}/usr/obj -type f -delete 2>/dev/null + + # Delete stuff we do not need to keep the mtree database small, + # and to make the actual comparison faster. + find ${TEMPROOT}/usr -type l -delete 2>/dev/null + find ${TEMPROOT} -type f -size 0 -delete 2>/dev/null + find -d ${TEMPROOT} -type d -empty -delete 2>/dev/null + + # Build the mtree database in a temporary location. + MTREENEW=`mktemp -t mergemaster.mtree` + case "${PRE_WORLD}" in + '') mtree -ci -p ${TEMPROOT} -k size,md5digest > ${MTREENEW} 2>/dev/null + ;; + *) # We don't want to mess with the mtree database on a pre-world run or + # when re-scanning a previously-built tree. + ;; + esac ;; # End of the "RERUN" test esac -# We really don't want to have to deal with files like login.conf.db, pwd.db, -# or spwd.db. Instead, we want to compare the text versions, and run *_mkdb. -# Prompt the user to do so below, as needed. -# -rm -f ${TEMPROOT}/etc/*.db ${TEMPROOT}/etc/passwd - -# We only need to compare things like freebsd.cf once -find ${TEMPROOT}/usr/obj -type f -delete 2>/dev/null - -# Delete stuff we do not need to keep the mtree database small, -# and to make the actual comparison faster. -find ${TEMPROOT}/usr -type l -delete 2>/dev/null -find ${TEMPROOT} -type f -size 0 -delete 2>/dev/null -find -d ${TEMPROOT} -type d -empty -delete 2>/dev/null - -# Build the mtree database in a temporary location. -MTREENEW=`mktemp -t mergemaster.mtree` -case "${PRE_WORLD}" in -'') mtree -ci -p ${TEMPROOT} -k size,md5digest > ${MTREENEW} 2>/dev/null - ;; -*) # We don't want to mess with the mtree database on a pre-world run. - ;; -esac - # Get ready to start comparing files # Check umask if not specified on the command line, @@ -965,6 +970,12 @@ if [ -z "${PRE_WORLD}" -a -z "${RERUN}" ]; then esac sleep 2 ;; + *) + if [ -n "${DELETE_STALE_RC_FILES}" ]; then + echo ' *** Deleting ... ' + rm ${STALE_RC_FILES} + echo ' done.' + fi esac ;; esac @@ -1093,7 +1104,7 @@ for COMPFILE in `find . -type f | sort`; do # If the user chose the -F option, test for that before proceeding # if [ -n "$FREEBSD_ID" ]; then - if diff -q -I'[$]FreeBSD:.*$' "${DESTDIR}${COMPFILE#.}" "${COMPFILE}" > \ + if diff -q -I'[$]FreeBSD.*[$]' "${DESTDIR}${COMPFILE#.}" "${COMPFILE}" > \ /dev/null 2>&1; then if mm_install "${COMPFILE}"; then echo "*** Updated revision control Id for ${DESTDIR}${COMPFILE#.}"