From owner-freebsd-hackers@FreeBSD.ORG Tue May 3 09:27:47 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 97A0A16A4CE for ; Tue, 3 May 2005 09:27:47 +0000 (GMT) Received: from volginfo.ru (ns.volginfo.ru [217.23.84.100]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6CC5443D76 for ; Tue, 3 May 2005 09:27:46 +0000 (GMT) (envelope-from den@FreeBSD.org) Received: from volginfo.ru (localhost.volginfo.ru [127.0.0.1]) by volginfo.ru (Postfix) with ESMTP id 59AE02012 for ; Tue, 3 May 2005 13:28:11 +0400 (MSD) Received: from [192.168.1.32] (llp-13.vistcom.ru [217.23.84.68]) by volginfo.ru (Postfix) with ESMTP id C4347200F for ; Tue, 3 May 2005 13:28:10 +0400 (MSD) Message-ID: <427743ED.6020200@FreeBSD.org> Date: Tue, 03 May 2005 13:27:09 +0400 From: Denis Peplin User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: en-us, en MIME-Version: 1.0 To: hackers@FreeBSD.org X-Enigmail-Version: 0.90.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/mixed; boundary="------------010305040000020703030509" X-Virus-Scanned: ClamAV using ClamSMTP Subject: mergemaster improvement (auto-update for not modified files) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 May 2005 09:27:47 -0000 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--