5 # Compare files created by /usr/src/etc/Makefile (or the directory
6 # the user specifies) with the currently installed copies.
8 # Copyright 1998-2009 Douglas Barton
13 PATH=/bin:/usr/bin:/usr/sbin
16 VERSION_NUMBER=`grep "[$]FreeBSD:" $0 | cut -d ' ' -f 4`
17 echo "mergemaster version ${VERSION_NUMBER}"
18 echo 'Usage: mergemaster [-scrvahipFCPU]'
19 echo ' [-m /path] [-t /path] [-d] [-u N] [-w N] [-A arch] [-D /path]'
21 echo " -s Strict comparison (diff every pair of files)"
22 echo " -c Use context diff instead of unified diff"
23 echo " -r Re-run on a previously cleaned directory (skip temproot creation)"
24 echo " -v Be more verbose about the process, include additional checks"
25 echo " -a Leave all files that differ to merge by hand"
26 echo " -h Display more complete help"
27 echo ' -i Automatically install files that do not exist in destination directory'
28 echo ' -p Pre-buildworld mode, only compares crucial files'
29 echo ' -F Install files that differ only by revision control Id ($FreeBSD)'
30 echo ' -C Compare local rc.conf variables to the defaults'
31 echo ' -P Preserve files that are overwritten'
32 echo " -U Attempt to auto upgrade files that have not been user modified"
34 echo " -m /path/directory Specify location of source to do the make in"
35 echo " -t /path/directory Specify temp root directory"
36 echo " -d Add date and time to directory name (e.g., /var/tmp/temproot.`date +%m%d.%H.%M`)"
37 echo " -u N Specify a numeric umask"
38 echo " -w N Specify a screen width in columns to sdiff"
39 echo " -A architecture Alternative architecture name to pass to make"
40 echo ' -D /path/directory Specify the destination directory to install files to'
45 echo "* To specify a directory other than /var/tmp/temproot for the"
46 echo " temporary root environment, use -t /path/to/temp/root"
47 echo "* The -w option takes a number as an argument for the column width"
48 echo " of the screen. The default is 80."
49 echo '* The -a option causes mergemaster to run without prompting.'
52 # Loop allowing the user to use sdiff to merge files and display the merged
58 echo " *** Type h at the sdiff prompt (%) to get usage help"
63 while [ "${MERGE_AGAIN}" = "yes" ]; do
64 # Prime file.merged so we don't blat the owner/group id's
65 cp -p "${COMPFILE}" "${COMPFILE}.merged"
66 sdiff -o "${COMPFILE}.merged" --text --suppress-common-lines \
67 --width=${SCREEN_WIDTH:-80} "${DESTDIR}${COMPFILE#.}" "${COMPFILE}"
69 while [ "${INSTALL_MERGED}" = "v" -o "${INSTALL_MERGED}" = "V" ]; do
71 echo " Use 'i' to install merged file"
72 echo " Use 'r' to re-do the merge"
73 echo " Use 'v' to view the merged file"
74 echo " Default is to leave the temporary file to deal with by hand"
76 echo -n " *** How should I deal with the merged file? [Leave it for later] "
79 case "${INSTALL_MERGED}" in
81 mv "${COMPFILE}.merged" "${COMPFILE}"
83 if mm_install "${COMPFILE}"; then
84 echo " *** Merged version of ${COMPFILE} installed successfully"
86 echo " *** Problem installing ${COMPFILE}, it will remain to merge by hand later"
91 rm "${COMPFILE}.merged"
94 ${PAGER} "${COMPFILE}.merged"
97 echo " *** ${COMPFILE} will remain for your consideration"
101 echo "invalid choice: ${INSTALL_MERGED}"
109 # Loop showing user differences between files, allow merge, skip or install
115 while [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "V" -o \
116 "${HANDLE_COMPFILE}" = "NOT V" ]; do
117 if [ -f "${DESTDIR}${COMPFILE#.}" -a -f "${COMPFILE}" ]; then
118 if [ -n "${AUTO_UPGRADE}" ]; then
119 if echo "${CHANGED}" | grep -qsv ${DESTDIR}${COMPFILE#.}; then
121 echo " *** ${COMPFILE} has not been user modified."
124 if mm_install "${COMPFILE}"; then
125 echo " *** ${COMPFILE} upgraded successfully"
127 # Make the list print one file per line
128 AUTO_UPGRADED_FILES="${AUTO_UPGRADED_FILES} ${DESTDIR}${COMPFILE#.}
131 echo " *** Problem upgrading ${COMPFILE}, it will remain to merge by hand"
136 if [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "V" ]; then
138 echo ' ====================================================================== '
141 echo " *** Displaying differences between ${COMPFILE} and installed version:"
143 diff ${DIFF_FLAG} ${DIFF_OPTIONS} "${DESTDIR}${COMPFILE#.}" "${COMPFILE}"
149 echo " *** There is no installed version of ${COMPFILE}"
151 case "${AUTO_INSTALL}" in
154 if mm_install "${COMPFILE}"; then
155 echo " *** ${COMPFILE} installed successfully"
157 # Make the list print one file per line
158 AUTO_INSTALLED_FILES="${AUTO_INSTALLED_FILES} ${DESTDIR}${COMPFILE#.}
161 echo " *** Problem installing ${COMPFILE}, it will remain to merge by hand"
171 echo " Use 'd' to delete the temporary ${COMPFILE}"
172 echo " Use 'i' to install the temporary ${COMPFILE}"
173 case "${NO_INSTALLED}" in
175 echo " Use 'm' to merge the temporary and installed versions"
176 echo " Use 'v' to view the diff results again"
180 echo " Default is to leave the temporary file to deal with by hand"
182 echo -n "How should I deal with this? [Leave it for later] "
185 case "${HANDLE_COMPFILE}" in
189 echo " *** Deleting ${COMPFILE}"
193 if mm_install "${COMPFILE}"; then
194 echo " *** ${COMPFILE} installed successfully"
196 echo " *** Problem installing ${COMPFILE}, it will remain to merge by hand"
200 case "${NO_INSTALLED}" in
202 # interact with user to merge files
207 echo " *** There is no installed version of ${COMPFILE}"
209 HANDLE_COMPFILE="NOT V"
211 esac # End of "No installed version of file but user selected merge" test
218 echo " *** ${COMPFILE} will remain for your consideration"
221 # invalid choice, show menu again.
222 echo "invalid choice: ${HANDLE_COMPFILE}"
224 HANDLE_COMPFILE="NOT V"
227 esac # End of "How to handle files that are different"
239 press_to_continue () {
241 echo -n ' *** Press the [Enter] or [Return] key to continue '
245 # Set the default path for the temporary root environment
247 TEMPROOT='/var/tmp/temproot'
249 # Read /etc/mergemaster.rc first so the one in $HOME can override
251 if [ -r /etc/mergemaster.rc ]; then
252 . /etc/mergemaster.rc
255 # Read .mergemasterrc before command line so CLI can override
257 if [ -r "$HOME/.mergemasterrc" ]; then
258 . "$HOME/.mergemasterrc"
261 # Assign the location of the mtree database
263 MTREEDB=${MTREEDB:-/var/db}
264 MTREEFILE="${MTREEDB}/mergemaster.mtree"
266 # Check the command line options
268 while getopts ":ascrvhipCPm:t:du:w:D:A:FU" COMMAND_LINE_ARGUMENT ; do
269 case "${COMMAND_LINE_ARGUMENT}" in
271 ARCHSTRING='TARGET_ARCH='${OPTARG}
290 case "${AUTO_RUN}" in
324 TEMPROOT=${TEMPROOT}.`date +%m%d.%H.%M`
330 SCREEN_WIDTH=${OPTARG}
342 # Don't force the user to set this in the mergemaster rc file
343 if [ -n "${PRESERVE_FILES}" -a -z "${PRESERVE_FILES_DIR}" ]; then
344 PRESERVE_FILES_DIR=/var/tmp/mergemaster/preserved-files-`date +%y%m%d-%H%M%S`
347 # Check for the mtree database in DESTDIR
348 case "${AUTO_UPGRADE}" in
349 '') ;; # If the option is not set no need to run the test or warn the user
351 if [ ! -f "${DESTDIR}${MTREEFILE}" ]; then
353 echo "*** Unable to find mtree database. Skipping auto-upgrade."
361 if [ -e "${DESTDIR}/etc/fstab" ]; then
362 if grep -q nodev ${DESTDIR}/etc/fstab; then
364 echo "*** You have the deprecated 'nodev' option in ${DESTDIR}/etc/fstab."
365 echo " This can prevent the filesystem from being mounted on reboot."
366 echo " Please update your fstab before continuing."
367 echo " See fstab(5) for more information."
375 # If the user has a pager defined, make sure we can run it
377 case "${DONT_CHECK_PAGER}" in
380 while ! type "${PAGER%% *}" >/dev/null; do
381 echo " *** Your PAGER environment variable specifies '${PAGER}', but"
382 echo " due to the limited PATH that I use for security reasons,"
383 echo " I cannot execute it. So, what would you like to do?"
385 echo " Use 'e' to exit mergemaster and fix your PAGER variable"
386 if [ -x /usr/bin/less -o -x /usr/local/bin/less ]; then
387 echo " Use 'l' to set PAGER to 'less' for this run"
389 echo " Use 'm' to use plain old 'more' as your PAGER for this run"
391 echo " Default is to use plain old 'more' "
393 echo -n "What should I do? [Use 'more'] "
396 case "${FIXPAGER}" in
401 if [ -x /usr/bin/less ]; then
403 elif [ -x /usr/local/bin/less ]; then
404 PAGER=/usr/local/bin/less
407 echo " *** Fatal Error:"
408 echo " You asked to use 'less' as your pager, but I can't"
409 echo " find it in /usr/bin or /usr/local/bin"
418 echo "invalid choice: ${FIXPAGER}"
423 if [ -n "${PAGER}" ]; then
429 # If user has a pager defined, or got assigned one above, use it.
434 if [ -n "${VERBOSE}" -a ! "${PAGER}" = "more" ]; then
435 echo " *** You have ${PAGER} defined as your pager so we will use that"
440 # Assign the diff flag once so we will not have to keep testing it
442 DIFF_FLAG=${DIFF_FLAG:--u}
444 # Assign the source directory
446 SOURCEDIR=${SOURCEDIR:-/usr/src}
447 if [ ! -f ${SOURCEDIR}/Makefile.inc1 -a \
448 -f ${SOURCEDIR}/../Makefile.inc1 ]; then
449 echo " *** The source directory you specified (${SOURCEDIR})"
450 echo " will be reset to ${SOURCEDIR}/.."
453 SOURCEDIR=${SOURCEDIR}/..
456 # Setup make to use system files from SOURCEDIR
457 MM_MAKE="make ${ARCHSTRING} -m ${SOURCEDIR}/share/mk"
459 # Check DESTDIR against the mergemaster mtree database to see what
460 # files the user changed from the reference files.
463 if [ -n "${AUTO_UPGRADE}" -a -f "${DESTDIR}${MTREEFILE}" ]; then
464 for file in `mtree -eq -f ${DESTDIR}${MTREEFILE} -p ${DESTDIR}/ \
465 2>/dev/null | awk '($2 == "changed") {print $1}'`; do
466 if [ -f "${DESTDIR}/$file" ]; then
467 CHANGED="${CHANGED} ${DESTDIR}/$file"
472 # Check the width of the user's terminal
477 0|'') ;; # No-op, since the input is not valid
479 case "${SCREEN_WIDTH}" in
480 '') SCREEN_WIDTH="${w}" ;;
481 "${w}") ;; # No-op, since they are the same
483 echo -n "*** You entered ${SCREEN_WIDTH} as your screen width, but stty "
484 echo "thinks it is ${w}."
486 echo -n "What would you like to use? [${w}] "
488 case "${SCREEN_WIDTH}" in
489 '') SCREEN_WIDTH="${w}" ;;
496 # Define what CVS $Id tag to look for to aid portability.
501 rm -rf "${TEMPROOT}" 2>/dev/null
502 chflags -R 0 "${TEMPROOT}" 2>/dev/null
503 rm -rf "${TEMPROOT}" || exit 1
508 # Set up the loop to test for the existence of the
509 # temp root directory.
512 while [ "${TEST_TEMP_ROOT}" = "yes" ]; do
513 if [ -d "${TEMPROOT}" ]; then
514 echo "*** The directory specified for the temporary root environment,"
515 echo " ${TEMPROOT}, exists. This can be a security risk if untrusted"
516 echo " users have access to the system."
518 case "${AUTO_RUN}" in
520 echo " Use 'd' to delete the old ${TEMPROOT} and continue"
521 echo " Use 't' to select a new temporary root directory"
522 echo " Use 'e' to exit mergemaster"
524 echo " Default is to use ${TEMPROOT} as is"
526 echo -n "How should I deal with this? [Use the existing ${TEMPROOT}] "
529 case "${DELORNOT}" in
532 echo " *** Deleting the old ${TEMPROOT}"
534 delete_temproot || exit 1
538 echo " *** Enter new directory name for temporary root environment"
546 echo " *** Leaving ${TEMPROOT} intact"
552 echo "invalid choice: ${DELORNOT}"
558 # If this is an auto-run, try a hopefully safe alternative then
560 TEMPROOT=/var/tmp/temproot.`date +%m%d.%H.%M.%S`
568 echo "*** Creating the temporary root environment in ${TEMPROOT}"
570 if mkdir -p "${TEMPROOT}"; then
571 echo " *** ${TEMPROOT} ready for use"
574 if [ ! -d "${TEMPROOT}" ]; then
576 echo " *** FATAL ERROR: Cannot create ${TEMPROOT}"
581 echo " *** Creating and populating directory structure in ${TEMPROOT}"
591 case "${PRE_WORLD}" in
597 ${MM_MAKE} DESTDIR=${DESTDIR} distrib-dirs
600 od=${TEMPROOT}/usr/obj
601 ${MM_MAKE} DESTDIR=${TEMPROOT} distrib-dirs &&
602 MAKEOBJDIRPREFIX=$od ${MM_MAKE} _obj SUBDIR_OVERRIDE=etc &&
603 MAKEOBJDIRPREFIX=$od ${MM_MAKE} everything SUBDIR_OVERRIDE=etc &&
604 MAKEOBJDIRPREFIX=$od ${MM_MAKE} DESTDIR=${TEMPROOT} distribution;} ||
606 echo " *** FATAL ERROR: Cannot 'cd' to ${SOURCEDIR} and install files to";
607 echo " the temproot environment";
612 # Only set up files that are crucial to {build|install}world
613 { mkdir -p ${TEMPROOT}/etc &&
614 cp -p ${SOURCEDIR}/etc/master.passwd ${TEMPROOT}/etc &&
615 cp -p ${SOURCEDIR}/etc/group ${TEMPROOT}/etc;} ||
617 echo ' *** FATAL ERROR: Cannot copy files to the temproot environment';
623 # Doing the inventory and removing files that we don't want to compare only
624 # makes sense if we are not doing a rerun, since we have no way of knowing
625 # what happened to the files during previous incarnations.
630 echo ' *** The following files exist only in the installed version of'
631 echo " ${DESTDIR}/etc. In the vast majority of cases these files"
632 echo ' are necessary parts of the system and should not be deleted.'
633 echo ' However because these files are not updated by this process you'
634 echo ' might want to verify their status before rebooting your system.'
637 diff -qr ${DESTDIR}/etc ${TEMPROOT}/etc | grep "^Only in ${DESTDIR}/etc" | ${PAGER}
643 # Avoid comparing the motd if the user specifies it in .mergemasterrc
644 # Compatibility shim to be removed in FreeBSD 9.x
645 case "${IGNORE_MOTD}" in
647 *) IGNORE_FILES="${IGNORE_FILES} /etc/motd"
649 echo "*** You have the IGNORE_MOTD option set in your mergemaster rc file."
650 echo " This option is deprecated in favor of the IGNORE_FILES option."
651 echo " Please update your rc file accordingly."
657 # Avoid comparing the following user specified files
658 for file in ${IGNORE_FILES}; do
659 test -e ${TEMPROOT}/${file} && unlink ${TEMPROOT}/${file}
661 ;; # End of the "RERUN" test
664 # We really don't want to have to deal with files like login.conf.db, pwd.db,
665 # or spwd.db. Instead, we want to compare the text versions, and run *_mkdb.
666 # Prompt the user to do so below, as needed.
668 rm -f ${TEMPROOT}/etc/*.db ${TEMPROOT}/etc/passwd
670 # We only need to compare things like freebsd.cf once
671 find ${TEMPROOT}/usr/obj -type f -delete 2>/dev/null
673 # Delete 0 length files to make the mtree database as small as possible.
674 find ${TEMPROOT} -type f -size 0 -delete 2>/dev/null
676 # Build the mtree database in a temporary location.
677 MTREENEW=`mktemp -t mergemaster.mtree`
678 case "${PRE_WORLD}" in
679 '') mtree -ci -p ${TEMPROOT} -k size,md5digest > ${MTREENEW} 2>/dev/null
681 *) # We don't want to mess with the mtree database on a pre-world run.
685 # Get ready to start comparing files
687 # Check umask if not specified on the command line,
688 # and we are not doing an autorun
690 if [ -z "${NEW_UMASK}" -a -z "${AUTO_RUN}" ]; then
692 case "${USER_UMASK}" in
696 echo " *** Your umask is currently set to ${USER_UMASK}. By default, this script"
697 echo " installs all files with the same user, group and modes that"
698 echo " they are created with by ${SOURCEDIR}/etc/Makefile, compared to"
699 echo " a umask of 022. This umask allows world read permission when"
700 echo " the file's default permissions have it."
702 echo " No world permissions can sometimes cause problems. A umask of"
703 echo " 022 will restore the default behavior, but is not mandatory."
704 echo " /etc/master.passwd is a special case. Its file permissions"
705 echo " will be 600 (rw-------) if installed."
707 echo -n "What umask should I use? [${USER_UMASK}] "
710 NEW_UMASK="${NEW_UMASK:-$USER_UMASK}"
716 CONFIRMED_UMASK=${NEW_UMASK:-0022}
719 # Warn users who still have old rc files
721 for file in atm devfs diskless1 diskless2 isdn network network6 pccard \
722 serial syscons sysctl alpha amd64 i386 ia64 sparc64; do
723 if [ -f "${DESTDIR}/etc/rc.${file}" ]; then
729 case "${OLD_RC_PRESENT}" in
732 echo " *** There are elements of the old rc system in ${DESTDIR}/etc/."
734 echo ' While these scripts will not hurt anything, they are not'
735 echo ' functional on an up to date system, and can be removed.'
738 case "${AUTO_RUN}" in
740 echo -n 'Move these files to /var/tmp/mergemaster/old_rc? [yes] '
743 case "${MOVE_OLD_RC}" in
746 mkdir -p /var/tmp/mergemaster/old_rc
747 for file in atm devfs diskless1 diskless2 isdn network network6 pccard \
748 serial syscons sysctl alpha amd64 i386 ia64 sparc64; do
749 if [ -f "${DESTDIR}/etc/rc.${file}" ]; then
750 mv ${DESTDIR}/etc/rc.${file} /var/tmp/mergemaster/old_rc/
753 echo ' The files have been moved'
762 # Use the umask/mode information to install the files
763 # Create directories as needed
766 echo "*** FATAL ERROR: Unable to install ${1} to ${2}"
771 do_install_and_rm () {
772 case "${PRESERVE_FILES}" in
774 if [ -f "${3}/${2##*/}" ]; then
775 mkdir -p ${PRESERVE_FILES_DIR}/${2%/*}
776 cp ${3}/${2##*/} ${PRESERVE_FILES_DIR}/${2%/*}
781 if [ ! -d "${3}/${2##*/}" ]; then
782 if install -m ${1} ${2} ${3}; then
785 install_error ${2} ${3}
788 install_error ${2} ${3}
792 # 4095 = "obase=10;ibase=8;07777" | bc
795 OCTAL=$(( ~$(echo "obase=10; ibase=8; ${CONFIRMED_UMASK}" | bc) & 4095 &
796 $(echo "obase=10; ibase=8; $(stat -f "%OMp%OLp" ${1})" | bc) ))
797 printf "%04o\n" ${OCTAL}
803 INSTALL_DIR=${INSTALL_DIR%/*}
805 case "${INSTALL_DIR}" in
811 if [ -n "${DESTDIR}${INSTALL_DIR}" -a ! -d "${DESTDIR}${INSTALL_DIR}" ]; then
812 DIR_MODE=`find_mode "${TEMPROOT}/${INSTALL_DIR}"`
813 install -d -o root -g wheel -m "${DIR_MODE}" "${DESTDIR}${INSTALL_DIR}"
816 FILE_MODE=`find_mode "${1}"`
818 if [ ! -x "${1}" ]; then
827 do_install_and_rm 600 "${1}" "${DESTDIR}${INSTALL_DIR}"
832 case "${AUTO_INSTALL}" in
834 case "${LINK_EXPLAINED}" in
836 echo " *** Historically BSD derived systems have had a"
837 echo " hard link from /.cshrc and /.profile to"
838 echo " their namesakes in /root. Please indicate"
839 echo " your preference below for bringing your"
840 echo " installed files up to date."
846 echo " Use 'd' to delete the temporary ${COMPFILE}"
847 echo " Use 'l' to delete the existing ${DESTDIR}${COMPFILE#.} and create the link"
849 echo " Default is to leave the temporary file to deal with by hand"
851 echo -n " How should I handle ${COMPFILE}? [Leave it to install later] "
854 *) # Part of AUTO_INSTALL
859 case "${HANDLE_LINK}" in
863 echo " *** Deleting ${COMPFILE}"
867 rm -f "${DESTDIR}${COMPFILE#.}"
868 if ln "${DESTDIR}/root/${COMPFILE##*/}" "${DESTDIR}${COMPFILE#.}"; then
869 echo " *** Link from ${DESTDIR}${COMPFILE#.} to ${DESTDIR}/root/${COMPFILE##*/} installed successfully"
872 echo " *** Error linking ${DESTDIR}${COMPFILE#.} to ${DESTDIR}/root/${COMPFILE##*/}, ${COMPFILE} will remain to install by hand"
876 echo " *** ${COMPFILE} will remain for your consideration"
883 case "${DONT_INSTALL}" in
885 do_install_and_rm "${FILE_MODE}" "${1}" "${DESTDIR}${INSTALL_DIR}"
891 else # File matched -x
892 do_install_and_rm "${FILE_MODE}" "${1}" "${DESTDIR}${INSTALL_DIR}"
897 if [ ! -d "${TEMPROOT}" ]; then
898 echo "*** FATAL ERROR: The temproot directory (${TEMPROOT})"
899 echo ' has disappeared!'
905 echo "*** Beginning comparison"
908 # Pre-world does not populate /etc/rc.d.
909 # It is very possible that a previous run would have deleted files in
910 # ${TEMPROOT}/etc/rc.d, thus creating a lot of false positives.
911 if [ -z "${PRE_WORLD}" -a -z "${RERUN}" ]; then
912 echo " *** Checking ${DESTDIR}/etc/rc.d for stale files"
914 cd "${DESTDIR}/etc/rc.d" &&
916 if [ ! -e "${TEMPROOT}/etc/rc.d/${file}" ]; then
917 STALE_RC_FILES="${STALE_RC_FILES} ${file}"
920 case "${STALE_RC_FILES}" in
922 echo ' *** No stale files found'
925 echo " *** The following files exist in ${DESTDIR}/etc/rc.d but not in"
926 echo " ${TEMPROOT}/etc/rc.d/:"
928 echo "${STALE_RC_FILES}"
930 echo ' The presence of stale files in this directory can cause the'
931 echo ' dreaded unpredictable results, and therefore it is highly'
932 echo ' recommended that you delete them.'
933 case "${AUTO_RUN}" in
936 echo -n ' *** Delete them now? [n] '
937 read DELETE_STALE_RC_FILES
938 case "${DELETE_STALE_RC_FILES}" in
940 echo ' *** Deleting ... '
945 echo ' *** Files will not be deleted'
958 if [ -r "${MM_PRE_COMPARE_SCRIPT}" ]; then
959 . "${MM_PRE_COMPARE_SCRIPT}"
962 # Using -size +0 avoids uselessly checking the empty log files created
963 # by ${SOURCEDIR}/etc/Makefile and the device entries in ./dev, but does
964 # check the scripts in ./dev, as we'd like (assuming no devfs of course).
966 for COMPFILE in `find . -type f -size +0`; do
968 # First, check to see if the file exists in DESTDIR. If not, the
969 # diff_loop function knows how to handle it.
971 if [ ! -e "${DESTDIR}${COMPFILE#.}" ]; then
972 case "${AUTO_RUN}" in
977 case "${AUTO_INSTALL}" in
979 # If this is an auto run, make it official
980 echo " *** ${COMPFILE} will remain for your consideration"
993 # Compare CVS $Id's first so if the file hasn't been modified
994 # local changes will be ignored.
995 # If the files have the same $Id, delete the one in temproot so the
996 # user will have less to wade through if files are left to merge by hand.
998 CVSID1=`grep "[$]${CVS_ID_TAG}:" ${DESTDIR}${COMPFILE#.} 2>/dev/null`
999 CVSID2=`grep "[$]${CVS_ID_TAG}:" ${COMPFILE} 2>/dev/null` || CVSID2=none
1003 echo " *** Temp ${COMPFILE} and installed have the same CVS Id, deleting"
1010 # If the file is still here either because the $Ids are different, the
1011 # file doesn't have an $Id, or we're using STRICT mode; look at the diff.
1013 if [ -f "${COMPFILE}" ]; then
1015 # Do an absolute diff first to see if the files are actually different.
1016 # If they're not different, delete the one in temproot.
1018 if diff -q ${DIFF_OPTIONS} "${DESTDIR}${COMPFILE#.}" "${COMPFILE}" > \
1019 /dev/null 2>&1; then
1020 echo " *** Temp ${COMPFILE} and installed are the same, deleting"
1023 # Ok, the files are different, so show the user where they differ.
1024 # Use user's choice of diff methods; and user's pager if they have one.
1026 # Use unified diffs by default. Context diffs give me a headache. :)
1028 # If the user chose the -F option, test for that before proceeding
1030 if [ -n "$FREEBSD_ID" ]; then
1031 if diff -q -I'[$]FreeBSD:.*$' "${DESTDIR}${COMPFILE#.}" "${COMPFILE}" > \
1032 /dev/null 2>&1; then
1033 if mm_install "${COMPFILE}"; then
1034 echo "*** Updated revision control Id for ${DESTDIR}${COMPFILE#.}"
1036 echo "*** Problem installing ${COMPFILE}, it will remain to merge by hand later"
1041 case "${AUTO_RUN}" in
1043 # prompt user to install/delete/merge changes
1047 # If this is an auto run, make it official
1048 echo " *** ${COMPFILE} will remain for your consideration"
1050 esac # Auto run test
1051 fi # Yes, the files are different
1052 fi # Yes, the file still remains to be checked
1053 done # This is for the for way up there at the beginning of the comparison
1056 echo "*** Comparison complete"
1058 if [ -f "${MTREENEW}" ]; then
1059 echo "*** Saving mtree database for future upgrades"
1060 test -e "${DESTDIR}${MTREEFILE}" && unlink ${DESTDIR}${MTREEFILE}
1061 mv ${MTREENEW} ${DESTDIR}${MTREEFILE}
1066 TEST_FOR_FILES=`find ${TEMPROOT} -type f -size +0 2>/dev/null`
1067 if [ -n "${TEST_FOR_FILES}" ]; then
1068 echo "*** Files that remain for you to merge by hand:"
1069 find "${TEMPROOT}" -type f -size +0
1073 case "${AUTO_RUN}" in
1075 echo -n "Do you wish to delete what is left of ${TEMPROOT}? [no] "
1078 case "${DEL_TEMPROOT}" in
1080 if delete_temproot; then
1081 echo " *** ${TEMPROOT} has been deleted"
1083 echo " *** Unable to delete ${TEMPROOT}"
1087 echo " *** ${TEMPROOT} will remain"
1094 case "${AUTO_INSTALLED_FILES}" in
1097 case "${AUTO_RUN}" in
1101 echo '*** You chose the automatic install option for files that did not'
1102 echo ' exist on your system. The following were installed for you:'
1103 echo "${AUTO_INSTALLED_FILES}"
1108 echo '*** You chose the automatic install option for files that did not'
1109 echo ' exist on your system. The following were installed for you:'
1110 echo "${AUTO_INSTALLED_FILES}"
1116 case "${AUTO_UPGRADED_FILES}" in
1119 case "${AUTO_RUN}" in
1123 echo '*** You chose the automatic upgrade option for files that you did'
1124 echo ' not alter on your system. The following were upgraded for you:'
1125 echo "${AUTO_UPGRADED_FILES}"
1130 echo '*** You chose the automatic upgrade option for files that you did'
1131 echo ' not alter on your system. The following were upgraded for you:'
1132 echo "${AUTO_UPGRADED_FILES}"
1139 case "${AUTO_RUN}" in
1143 echo -n ' Would you like to run it now? y or n [n] '
1146 case "${YES_OR_NO}" in
1148 echo " Running ${1}"
1154 echo " *** Cancelled"
1156 echo " Make sure to run ${1} yourself"
1160 echo " *** Sorry, I do not understand your answer (${YES_OR_NO})"
1162 echo " Make sure to run ${1} yourself"
1169 case "${NEED_NEWALIASES}" in
1173 if [ -n "${DESTDIR}" ]; then
1174 echo "*** You installed a new aliases file into ${DESTDIR}/etc/mail, but"
1175 echo " the newaliases command is limited to the directories configured"
1176 echo " in sendmail.cf. Make sure to create your aliases database by"
1177 echo " hand when your sendmail configuration is done."
1179 echo "*** You installed a new aliases file, so make sure that you run"
1180 echo " '/usr/bin/newaliases' to rebuild your aliases database"
1181 run_it_now '/usr/bin/newaliases'
1186 case "${NEED_CAP_MKDB}" in
1190 echo "*** You installed a login.conf file, so make sure that you run"
1191 echo " '/usr/bin/cap_mkdb ${DESTDIR}/etc/login.conf'"
1192 echo " to rebuild your login.conf database"
1193 run_it_now "/usr/bin/cap_mkdb ${DESTDIR}/etc/login.conf"
1197 case "${NEED_PWD_MKDB}" in
1201 echo "*** You installed a new master.passwd file, so make sure that you run"
1202 if [ -n "${DESTDIR}" ]; then
1203 echo " '/usr/sbin/pwd_mkdb -d ${DESTDIR}/etc -p ${DESTDIR}/etc/master.passwd'"
1204 echo " to rebuild your password files"
1205 run_it_now "/usr/sbin/pwd_mkdb -d ${DESTDIR}/etc -p ${DESTDIR}/etc/master.passwd"
1207 echo " '/usr/sbin/pwd_mkdb -p /etc/master.passwd'"
1208 echo " to rebuild your password files"
1209 run_it_now '/usr/sbin/pwd_mkdb -p /etc/master.passwd'
1216 if [ -r "${MM_EXIT_SCRIPT}" ]; then
1217 . "${MM_EXIT_SCRIPT}"
1220 case "${COMP_CONFS}" in
1223 . ${DESTDIR}/etc/defaults/rc.conf
1226 echo "*** Comparing conf files: ${rc_conf_files}"
1228 for CONF_FILE in ${rc_conf_files}; do
1229 if [ -r "${DESTDIR}${CONF_FILE}" ]; then
1231 echo "*** From ${DESTDIR}${CONF_FILE}"
1232 echo "*** From ${DESTDIR}/etc/defaults/rc.conf"
1234 for RC_CONF_VAR in `grep -i ^[a-z] ${DESTDIR}${CONF_FILE} |
1235 cut -d '=' -f 1`; do
1237 grep -w ^${RC_CONF_VAR} ${DESTDIR}${CONF_FILE}
1238 grep -w ^${RC_CONF_VAR} ${DESTDIR}/etc/defaults/rc.conf ||
1239 echo ' * No default variable with this name'
1247 case "${PRE_WORLD}" in
1250 MAKE_CONF="${SOURCEDIR}/share/examples/etc/make.conf"
1253 echo '*** Comparing make variables'
1255 echo "*** From ${DESTDIR}/etc/make.conf"
1256 echo "*** From ${MAKE_CONF}"
1258 for MAKE_VAR in `grep -i ^[a-z] ${DESTDIR}/etc/make.conf | cut -d '=' -f 1`; do
1260 grep -w ^${MAKE_VAR} ${DESTDIR}/etc/make.conf
1261 grep -w ^#${MAKE_VAR} ${MAKE_CONF} ||
1262 echo ' * No example variable with this name'