Mergemaster Request (RE: mergemaster tips)

Doug Barton DougB at FreeBSD.org
Sun Apr 20 16:51:26 PDT 2003


On Mon, 21 Apr 2003, Marc Schneiders wrote:

> On Sun, 20 Apr 2003, at 15:22 [=GMT-0700], Doug Barton wrote:
>
> > Ok, can you give me an example of something that you don't understand? I
> > tried to be quite thorough in the man page,
>
> And you are. I just read it for the first time after using mergemaster
> for 3 or 4 years, and I learned a lot.

Well that's good news I suppose. :)

> I thought this was clever, but I now see this isn't good enough. I do
> not want to get an archive, in addition to normal backups, of a
> complete 10 MB /etc directory each time I upgrade.

10 megs!?! Holy code bloat Batman! What the heck do you have in there?
Mine is only 1.3 megs, and that's just because I'm a bit sloppy about
having extra rcNG stuff lying around.

> So here is the feature request: Is it possible to have a new option in
> mergemaster:
>
> -b (path)	Make a backup of every file that mergemaster
> 		overwrites, whether on user input or automatically.
> 		Mergemaster writes the files in a directory with a
> 		timestamp name (YYYYMMDD-HHMMSS) under the path
> 		indicated.
>
> This would give us an archive of the config changes on the machine.

Very interesting idea. Try the attached patch and let me know what you
think. I used -P for "preserve," because I like the semantics better. This
is all subject to change since I just whipped this up, but it should be
enough for you to play with.

Doug

-- 

    This .signature sanitized for your protection
-------------- next part --------------
Index: mergemaster.sh
===================================================================
RCS file: /home/ncvs/src/usr.sbin/mergemaster/mergemaster.sh,v
retrieving revision 1.6.2.17
diff -u -r1.6.2.17 mergemaster.sh
--- mergemaster.sh	10 Mar 2003 06:55:48 -0000	1.6.2.17
+++ mergemaster.sh	20 Apr 2003 23:47:32 -0000
@@ -15,7 +15,7 @@
 display_usage () {
   VERSION_NUMBER=`grep "[$]FreeBSD:" $0 | cut -d ' ' -f 4`
   echo "mergemaster version ${VERSION_NUMBER}"
-  echo 'Usage: mergemaster [-scrvahipC] [-m /path]'
+  echo 'Usage: mergemaster [-scrvahipCP] [-m /path]'
   echo '         [-t /path] [-d] [-u N] [-w N] [-D /path]'
   echo "Options:"
   echo "  -s  Strict comparison (diff every pair of files)"
@@ -27,6 +27,7 @@
   echo '  -i  Automatically install files that do not exist in destination directory'
   echo '  -p  Pre-buildworld mode, only compares crucial files'
   echo '  -C  Compare local rc.conf variables to the defaults'
+  echo '  -P  Preserve files that are overwritten'
   echo "  -m /path/directory  Specify location of source to do the make in"
   echo "  -t /path/directory  Specify temp root directory"
   echo "  -d  Add date and time to directory name (e.g., /var/tmp/temproot.`date +%m%d.%H.%M`)"
@@ -237,7 +238,7 @@
 
 # Check the command line options
 #
-while getopts ":ascrvhipCm:t:du:w:D:" COMMAND_LINE_ARGUMENT ; do
+while getopts ":ascrvhipCPm:t:du:w:D:" COMMAND_LINE_ARGUMENT ; do
   case "${COMMAND_LINE_ARGUMENT}" in
   s)
     STRICT=yes
@@ -269,6 +270,10 @@
   C)
     COMP_CONFS=yes
     ;;
+  P)
+    PRESERVE_FILES=yes
+    PRESERVE_FILES_DIR=/var/tmp/mergemaster-preserved-files-`date +%y%m%d-%H%M%S`
+    ;;
   p)
     PRE_WORLD=yes
     unset COMP_CONFS
@@ -627,6 +632,15 @@
 # Create directories as needed
 #
 do_install_and_rm () {
+  case "${PRESERVE_FILES}" in
+  [Yy][Ee][Ss])
+    if [ -f "${3}/${2##*/}" ]; then
+      mkdir -p ${PRESERVE_FILES_DIR}
+      cp ${3}/${2##*/} ${PRESERVE_FILES_DIR}
+    fi
+    ;;
+  esac
+
   install -m "${1}" "${2}" "${3}" &&
   rm -f "${2}"
 }


More information about the freebsd-stable mailing list