Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 03 May 2005 13:27:09 +0400
From:      Denis Peplin <den@FreeBSD.org>
To:        hackers@FreeBSD.org
Subject:   mergemaster improvement (auto-update for not modified files)
Message-ID:  <427743ED.6020200@FreeBSD.org>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------010305040000020703030509
Content-Type: text/plain; charset=KOI8-R
Content-Transfer-Encoding: 7bit

Hello!

The mergemaster with this is test patch (attached)
can auto-update files that was not modified.

It do this by compairing each file with it's CVS
copy. If file was not modified, it can be rewritten.

This dramatically redices amount of files that require
admin's attention.

There is one major problem here:
This can be done in single-user mode only if your
have local CVS repository, because if local CVS is
not exist, anoncvs is used.

Possible solutions:
1. Pre-checkout files in pre-buildworld mode.
2. Setup CVSup collection for subset of required files
(is it possible?), and then keep this small collection
up-to-date locally.
3. Store checksum for every config file installed,
then compare with this checksum on updating.

BTW, tracking checksums can be very useful for
base system too, because checksums can help to do
clean updates (with removal of old files that was not
overwritten).

--------------010305040000020703030509
Content-Type: text/plain;
 name="merge3.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="merge3.diff"

Index: mergemaster.sh
===================================================================
RCS file: /home/ncvs/src/usr.sbin/mergemaster/mergemaster.sh,v
retrieving revision 1.51
diff -u -r1.51 mergemaster.sh
--- mergemaster.sh	7 Mar 2004 10:10:19 -0000	1.51
+++ mergemaster.sh	3 May 2005 09:21:38 -0000
@@ -224,6 +224,15 @@
 #
 TEMPROOT='/var/tmp/temproot'
 
+TEMPCVS=`mktemp -q -d -t $(basename $0)`
+CVS_SKIP=''
+
+# Only one variable for the list of sites. Should be improved.
+CVS_LOGGED_IN=0
+
+CVSLIST=":pserver:anoncvs@anoncvs.jp.FreeBSD.org:/home/ncvs
+	:pserver:anoncvs@anoncvs.fr.FreeBSD.org:/home/ncvs"
+
 # Read /etc/mergemaster.rc first so the one in $HOME can override
 #
 if [ -r /etc/mergemaster.rc ]; then
@@ -871,7 +880,7 @@
     # If the files have the same $Id, delete the one in temproot so the
     # user will have less to wade through if files are left to merge by hand.
     #
-    CVSID1=`grep "[$]${CVS_ID_TAG}:" ${DESTDIR}${COMPFILE#.} 2>/dev/null`
+    CVSID1=`grep "[$]${CVS_ID_TAG}:" ${DESTDIR}${COMPFILE#.} 2>/dev/null` || CVSID1=''
     CVSID2=`grep "[$]${CVS_ID_TAG}:" ${COMPFILE} 2>/dev/null` || CVSID2=none
 
     case "${CVSID2}" in
@@ -879,6 +888,60 @@
       echo " *** Temp ${COMPFILE} and installed have the same CVS Id, deleting"
       rm "${COMPFILE}"
       ;;
+    *)
+      # Checking file for changes against CVS
+      if [ ! -z "${CVSID1}" -a -z "${CVS_SKIP}" ]
+      then
+	CVSFILE=`echo ${CVSID1} | awk '{print $3}' | sed 's/,v$//'`
+	CVSVERSION=`echo ${CVSID1} | awk '{print $4}'`
+	
+	echo " *** Checking ${COMPFILE#.} against CVS"
+	(cd ${TEMPCVS} && cvs -Rq co -r ${CVSVERSION} ${CVSFILE} > /dev/null 2>&1) || \
+	for CVSROOT in ${CVSLIST}
+	do
+	  if [ ${CVS_LOGGED_IN} -eq 0 ]; then
+		  echo " *** Enter 'anoncvs' password below"
+		  cvs -Rqd ${CVSROOT} login && CVS_LOGGED_IN=1
+	  fi
+	  (cd ${TEMPCVS} && cvs -Rqd ${CVSROOT} co -r ${CVSVERSION} ${CVSFILE} > /dev/null 2>&1 && continue)
+	done
+	case "${AUTO_RUN}" in
+	'')
+	  if [ $? -ne 0 ]; then
+	    echo "${COMPFILE} can't be checked against CVS"
+	    echo -n "Do you wish skip CVS checking for remaining files? y or n [y] "
+	    read CVS_SKIP
+
+	    echo "1 $CVS_SKIP 1"
+
+	    case $CVS_SKIP in
+	    [Nn])
+	      CVS_SKIP=''
+	    ;;
+	    *)
+	      CVS_SKIP='y'
+	      echo " *** Skip CVS checking for remaining files"
+	    ;;
+	    esac
+	  fi
+	;;
+	*)
+	  echo " *** Skip CVS checking for remaining files"
+	;;
+	esac
+  
+
+	if diff -q ${DIFF_OPTIONS} "${DESTDIR}${COMPFILE#.}" "${TEMPCVS}/${CVSFILE}" > \
+          /dev/null 2>&1; then
+	  if mm_install "${COMPFILE}"; then
+	    echo " *** ${COMPFILE} installed successfully"
+	  else
+	    echo " *** Problem installing ${COMPFILE}, it will remain to merge by hand"
+	  fi
+        fi
+	rm -f ${TEMPCVS}/${CVSFILE}
+      fi
+    ;;
     esac
     ;;
   esac
@@ -926,6 +989,9 @@
   echo ''
 fi
 
+# How safe it is?
+rm -rf ${TEMPCVS}
+
 case "${AUTO_RUN}" in
 '')
   echo -n "Do you wish to delete what is left of ${TEMPROOT}? [no] "

--------------010305040000020703030509--



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