Index: mergemaster.8 =================================================================== RCS file: /home/ncvs/src/usr.sbin/mergemaster/mergemaster.8,v retrieving revision 1.14 diff -u -r1.14 mergemaster.8 --- mergemaster.8 2001/03/05 10:13:21 1.14 +++ mergemaster.8 2001/03/13 19:39:27 @@ -32,7 +32,7 @@ .Nd Merge configuration files, et al during an upgrade .Sh SYNOPSIS .Nm -.Op Fl scrvahi +.Op Fl scrvahiI .Op Fl m Ar /path/to/sources .Op Fl t Ar /path/to/temp/root .Op Fl d @@ -183,6 +183,13 @@ .It Fl i Automatically install any files that do not exist in the destination directory. +.It Fl I +Automatically install any files that are unchanged from the +original version as checked into the FreeBSD CVS repository. +For this to work, the CVSROOT environment variable must be +set to point at a FreeBSD CVS repository. +It is dependent on FreeBSD-specific CVS tags, so without +special care, this will NOT work for self-created repositories. .It Fl m Ar /path/to/sources Specify the path to the directory where you want to do the .Xr make 1 . Index: mergemaster.sh =================================================================== RCS file: /home/ncvs/src/usr.sbin/mergemaster/mergemaster.sh,v retrieving revision 1.17 diff -u -r1.17 mergemaster.sh --- mergemaster.sh 2001/03/05 10:13:21 1.17 +++ mergemaster.sh 2001/03/13 19:32:07 @@ -25,6 +25,9 @@ echo " -a Leave all files that differ to merge by hand" echo " -h Display more complete help" echo ' -i Automatically install files that do not exist in destination directory' + echo ' -I Automatically install files that are not modified since originally' + echo ' installed (based on a CVS repository). This need CVSROOT to point at ' + echo ' a FreeBSD CVS repository (either local or remote.)' 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`)" @@ -103,13 +106,41 @@ # options diff_loop () { + # + # Determine if the file is available in CVS, and if it is, whether it is + # equal to the original as checked out from the CVS repository + # + if [ "${CVSROOT}" != "" ]; then + CVSCO=$(grep '\$FreeBSD:.*\$' "${DESTDIR}${COMPFILE#.}" 2> /dev/null | sed 's|.*\$FreeBSD:\([^\$]*\)\$.*|\1|' | awk "{print \"cvs -d ${CVSROOT} checkout -p -r\" \$2, gensub(/,v\$/, \"\", 1, \$1)}") + fi + if [ "$CVSCO" != "" ]; then + if ! $CVSCO > ${COMPFILE}.origcvs 2> /dev/null; then + rm -f ${COMPFILE}.origcvs + fi + fi + if [ -e ${COMPFILE}.origcvs ] && + diff -q -I'.*\$FreeBSD.*\$.*' ${DESTDIR}${COMPFILE#.} ${COMPFILE}.origcvs \ + > /dev/null; then + EQUAL_TO_CVS=yes + else + EQUAL_TO_CVS=no + fi + rm -f "${COMPFILE}.origcvs" + + # + # Start main loop + # HANDLE_COMPFILE=v while [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "V" -o "${HANDLE_COMPFILE}" = "NOT V" ]; do - if [ -f "${DESTDIR}${COMPFILE#.}" -a -f "${COMPFILE}" ]; then + #if [ -f "${DESTDIR}${COMPFILE#.}" -a -f "${COMPFILE}" -a \( "${AUTO_INSTALL_IF_CVS_EQUAL}" != "yes" -o "${EQUAL_TO_CVS}" != "yes" \) ]; then + if [ -f "${DESTDIR}${COMPFILE#.}" -a -f "${COMPFILE}" ] && [ "${AUTO_INSTALL_IF_CVS_EQUAL}" != "yes" -o "${EQUAL_TO_CVS}" != "yes" ]; then if [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "V" ]; then ( - echo '' + if [ "${EQUAL_TO_CVS}" = "yes" ]; then + echo " *** Installed ${COMPFILE} is equal to original in CVS" + fi + #echo if [ -f "${DESTDIR}${COMPFILE#.}" -a -f "${COMPFILE}" -a \("${AUTO_INSTALL_IF_CVS_EQUAL}" != "yes" -o "${EQUAL_TO_CVS}" != "yes"\) ] echo " *** Displaying differences between ${COMPFILE} and installed version:" echo '' diff "${DIFF_FLAG}" "${DESTDIR}${COMPFILE#.}" "${COMPFILE}" @@ -118,9 +149,13 @@ fi else echo '' - echo " *** There is no installed version of ${COMPFILE}" - case "${AUTO_INSTALL}" in - [Yy][Ee][Ss]) + case $EQUAL_TO_CVS in + yes) echo " *** The installed version is equal to what is in CVS" ;; + *) echo " *** There is no installed version of ${COMPFILE}" ;; + esac + if [ "${AUTO_INSTALL}" = "yes" -o \ + \( "${AUTO_INSTALL_IF_CVS_EQUAL}" = "yes" -a "${EQUAL_TO_CVS}" = "yes" \) ] + then echo '' if mm_install "${COMPFILE}"; then echo " *** ${COMPFILE} installed successfully" @@ -132,11 +167,9 @@ echo " *** Problem installing ${COMPFILE}, it will remain to merge by hand" fi return - ;; - *) + else NO_INSTALLED=yes - ;; - esac + fi fi echo " Use 'd' to delete the temporary ${COMPFILE}" @@ -225,7 +258,7 @@ # Check the command line options # -while getopts ":ascrvhim:t:du:w:D:" COMMAND_LINE_ARGUMENT ; do +while getopts ":ascrvhiIm:t:du:w:D:" COMMAND_LINE_ARGUMENT ; do case "${COMMAND_LINE_ARGUMENT}" in s) STRICT=yes @@ -253,6 +286,9 @@ i) AUTO_INSTALL=yes ;; + I) + AUTO_INSTALL_IF_CVS_EQUAL=yes + ;; m) SOURCEDIR=${OPTARG} ;; @@ -772,15 +808,19 @@ '') ( echo '' - echo '*** You chose the automatic install option for files that did not exist' - echo ' on your system. The following files were installed for you:' + echo '*** You chose an automatic install option, either for files that did' + echo ' not exist on your system, for files that were unchanged from the' + echo ' version that was in CVS, or for both.' + echo ' The following files were installed for you:' echo "${AUTO_INSTALLED_FILES}" ) | ${PAGER} ;; *) echo '' - echo '*** You chose the automatic install option for files that did not exist' - echo ' on your system. The following files were installed for you:' + echo '*** You chose an automatic install option, either for files that did' + echo ' not exist on your system, for files that were unchanged from the' + echo ' version that was in CVS, or for both.' + echo ' The following files were installed for you:' echo "${AUTO_INSTALLED_FILES}" ;; esac