mergemaster.sh revision 77323
150477Speter#!/bin/sh
244212Snewton
370711Sobrien# mergemaster
470711Sobrien
570711Sobrien# Compare files created by /usr/src/etc/Makefile (or the directory
6122894Simp# the user specifies) with the currently installed copies.
770711Sobrien
889244Smsmith# Copyright 1998-2001 Douglas Barton
989244Smsmith# DougB@FreeBSD.org
1089244Smsmith
1189244Smsmith# $FreeBSD: head/usr.sbin/mergemaster/mergemaster.sh 77323 2001-05-28 09:07:27Z dougb $
1244212Snewton
1344212SnewtonPATH=/bin:/usr/bin:/usr/sbin
1444212Snewton
1570711Sobriendisplay_usage () {
1644212Snewton  VERSION_NUMBER=`grep "[$]FreeBSD:" $0 | cut -d ' ' -f 4`
1760966Speter  echo "mergemaster version ${VERSION_NUMBER}"
18  echo 'Usage: mergemaster [-scrvahi] [-m /path]'
19  echo '         [-t /path] [-d] [-u N] [-w N] [-D /path]'
20  echo "Options:"
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 "  -m /path/directory  Specify location of source to do the make in"
29  echo "  -t /path/directory  Specify temp root directory"
30  echo "  -d  Add date and time to directory name (e.g., /var/tmp/temproot.`date +%m%d.%H.%M`)"
31  echo "  -u N  Specify a numeric umask"
32  echo "  -w N  Specify a screen width in columns to sdiff"
33  echo '  -D /path/directory  Specify the destination directory to install files to'
34  echo ''
35}
36
37display_help () {
38  echo "* To specify a directory other than /var/tmp/temproot for the"
39  echo "  temporary root environment, use -t /path/to/temp/root"
40  echo "* The -w option takes a number as an argument for the column width"
41  echo "  of the screen.  The default is 80."
42  echo '* The -a option causes mergemaster to run without prompting.'
43}
44
45# Loop allowing the user to use sdiff to merge files and display the merged
46# file.
47merge_loop () {
48  case "${VERBOSE}" in
49  '') ;;
50  *)
51      echo "   *** Type h at the sdiff prompt (%) to get usage help"
52      ;;
53  esac
54  echo ''
55  MERGE_AGAIN=yes
56  while [ "${MERGE_AGAIN}" = "yes" ]; do
57    # Prime file.merged so we don't blat the owner/group id's
58    cp -p "${COMPFILE}" "${COMPFILE}.merged"
59    sdiff -o "${COMPFILE}.merged" --text --suppress-common-lines \
60      --width=${SCREEN_WIDTH:-80} "${DESTDIR}${COMPFILE#.}" "${COMPFILE}"
61    INSTALL_MERGED=V
62    while [ "${INSTALL_MERGED}" = "v" -o "${INSTALL_MERGED}" = "V" ]; do
63      echo ''
64      echo "  Use 'i' to install merged file"
65      echo "  Use 'r' to re-do the merge"
66      echo "  Use 'v' to view the merged file"
67      echo "  Default is to leave the temporary file to deal with by hand"
68      echo ''
69      echo -n "    *** How should I deal with the merged file? [Leave it for later] "
70      read INSTALL_MERGED
71
72      case "${INSTALL_MERGED}" in
73      [iI])
74        mv "${COMPFILE}.merged" "${COMPFILE}"
75        echo ''
76        if mm_install "${COMPFILE}"; then
77          echo "     *** Merged version of ${COMPFILE} installed successfully"
78        else
79          echo "     *** Problem installing ${COMPFILE}, it will remain to merge by hand later"
80        fi
81        unset MERGE_AGAIN
82        ;;
83      [rR])
84        rm "${COMPFILE}.merged"
85        ;;
86      [vV])
87        ${PAGER} "${COMPFILE}.merged"
88        ;;
89      '')
90        echo "   *** ${COMPFILE} will remain for your consideration"
91        unset MERGE_AGAIN
92        ;;
93      *)
94        echo "invalid choice: ${INSTALL_MERGED}"
95        INSTALL_MERGED=V
96        ;;
97      esac
98    done
99  done
100}
101
102# Loop showing user differences between files, allow merge, skip or install
103# options
104diff_loop () {
105
106  HANDLE_COMPFILE=v
107
108  while [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "V" -o \
109    "${HANDLE_COMPFILE}" = "NOT V" ]; do
110    if [ -f "${DESTDIR}${COMPFILE#.}" -a -f "${COMPFILE}" ]; then
111      if [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "V" ]; then
112        (
113          echo ''
114          echo "  *** Displaying differences between ${COMPFILE} and installed version:"
115          echo ''
116          diff "${DIFF_FLAG}" "${DESTDIR}${COMPFILE#.}" "${COMPFILE}"
117        ) | ${PAGER}
118        echo ''
119      fi
120    else
121      echo ''
122      echo "  *** There is no installed version of ${COMPFILE}"
123      case "${AUTO_INSTALL}" in
124      [Yy][Ee][Ss])
125        echo ''
126        if mm_install "${COMPFILE}"; then
127          echo "   *** ${COMPFILE} installed successfully"
128          echo ''
129          # Make the list print one file per line
130          AUTO_INSTALLED_FILES="${AUTO_INSTALLED_FILES}      ${DESTDIR}${COMPFILE#.}
131"
132        else
133          echo "   *** Problem installing ${COMPFILE}, it will remain to merge by hand"
134        fi
135        return
136        ;;
137      *)
138        NO_INSTALLED=yes
139        ;;
140      esac
141    fi
142
143    echo "  Use 'd' to delete the temporary ${COMPFILE}"
144    echo "  Use 'i' to install the temporary ${COMPFILE}"
145    case "${NO_INSTALLED}" in
146    '')
147      echo "  Use 'm' to merge the old and new versions"
148      echo "  Use 'v' to view to differences between the old and new versions again"
149      ;;
150    esac
151    echo ''
152    echo "  Default is to leave the temporary file to deal with by hand"
153    echo ''
154    echo -n "How should I deal with this? [Leave it for later] "
155    read HANDLE_COMPFILE
156
157    case "${HANDLE_COMPFILE}" in
158    [dD])
159      rm "${COMPFILE}"
160      echo ''
161      echo "   *** Deleting ${COMPFILE}"
162      ;;
163    [iI])
164      echo ''
165      if mm_install "${COMPFILE}"; then
166        echo "   *** ${COMPFILE} installed successfully"
167      else
168        echo "   *** Problem installing ${COMPFILE}, it will remain to merge by hand"
169      fi
170      ;;
171    [mM])
172      case "${NO_INSTALLED}" in
173      '')
174        # interact with user to merge files
175        merge_loop
176        ;;
177      *)
178        echo ''
179        echo "   *** There is no installed version of ${COMPFILE}"
180        echo ''
181        HANDLE_COMPFILE="NOT V"
182        ;;
183      esac # End of "No installed version of file but user selected merge" test
184      ;;
185    [vV])
186      continue
187      ;;
188    '')
189      echo ''
190      echo "   *** ${COMPFILE} will remain for your consideration"
191      ;;
192    *)
193      # invalid choice, show menu again.
194      echo "invalid choice: ${HANDLE_COMPFILE}"
195      echo ''
196      HANDLE_COMPFILE="NOT V"
197      continue
198      ;;
199    esac  # End of "How to handle files that are different"
200  done
201  unset NO_INSTALLED
202  echo ''
203  case "${VERBOSE}" in
204  '') ;;
205  *)
206    sleep 3
207    ;;
208  esac
209}
210
211# Set the default path for the temporary root environment
212#
213TEMPROOT='/var/tmp/temproot'
214
215# Read /etc/mergemaster.rc first so the one in $HOME can override
216#
217if [ -r /etc/mergemaster.rc ]; then
218  . /etc/mergemaster.rc
219fi
220
221# Read .mergemasterrc before command line so CLI can override
222#
223if [ -r "$HOME/.mergemasterrc" ]; then
224  . "$HOME/.mergemasterrc"
225fi
226
227# Check the command line options
228#
229while getopts ":ascrvhim:t:du:w:D:" COMMAND_LINE_ARGUMENT ; do
230  case "${COMMAND_LINE_ARGUMENT}" in
231  s)
232    STRICT=yes
233    ;;
234  c)
235    DIFF_FLAG='-c'
236    ;;
237  r)
238    RERUN=yes
239    ;;
240  v)
241    case "${AUTO_RUN}" in
242    '') VERBOSE=yes ;;
243    esac
244    ;;
245  a)
246    AUTO_RUN=yes
247    unset VERBOSE
248    ;;
249  h)
250    display_usage
251    display_help
252    exit 0
253    ;;
254  i)
255    AUTO_INSTALL=yes
256    ;;
257  m)
258    SOURCEDIR=${OPTARG}
259    ;;
260  t)
261    TEMPROOT=${OPTARG}
262    ;;
263  d)
264    TEMPROOT=${TEMPROOT}.`date +%m%d.%H.%M`
265    ;;
266  u)
267    NEW_UMASK=${OPTARG}
268    ;;
269  w)
270    SCREEN_WIDTH=${OPTARG}
271    ;;
272  D)
273    DESTDIR=${OPTARG}
274    ;;
275  *)
276    display_usage
277    exit 1
278    ;;
279  esac
280done
281
282echo ''
283
284# If the user has a pager defined, make sure we can run it
285#
286case "${DONT_CHECK_PAGER}" in
287'')
288  while ! type "${PAGER%% *}" >/dev/null && [ -n "${PAGER}" ]; do
289    echo " *** Your PAGER environment variable specifies '${PAGER}', but"
290    echo "     due to the limited PATH that I use for security reasons,"
291    echo "     I cannot execute it.  So, what would you like to do?"
292    echo ''
293    echo "  Use 'e' to exit mergemaster and fix your PAGER variable"
294    if [ -x /usr/bin/less -o -x /usr/local/bin/less ]; then
295    echo "  Use 'l' to set PAGER to 'less' for this run"
296    fi
297    echo "  Use 'm' to use plain old 'more' as your PAGER for this run"
298    echo ''
299    echo "  Default is to use plain old 'more' "
300    echo ''
301    echo -n "What should I do? [Use 'more'] "
302    read FIXPAGER
303
304    case "${FIXPAGER}" in
305    [eE])
306       exit 0
307       ;;
308    [lL])
309       if [ -x /usr/bin/less ]; then
310         PAGER=/usr/bin/less
311       elif [ -x /usr/local/bin/less ]; then
312         PAGER=/usr/local/bin/less
313       else
314         echo ''
315         echo " *** Fatal Error:"
316         echo "     You asked to use 'less' as your pager, but I can't"
317         echo "     find it in /usr/bin or /usr/local/bin"
318         exit 1
319       fi
320       ;;
321    [mM]|'')
322       PAGER=more
323       ;;
324    *)
325       echo ''
326       echo "invalid choice: ${FIXPAGER}"
327    esac
328    echo ''
329  done
330  ;;
331esac
332
333# If user has a pager defined, or got assigned one above, use it.
334# If not, use more.
335#
336PAGER=${PAGER:-more}
337
338if [ -n "${VERBOSE}" -a ! "${PAGER}" = "more" ]; then
339  echo " *** You have ${PAGER} defined as your pager so we will use that"
340  echo ''
341  sleep 3
342fi
343
344# Assign the diff flag once so we will not have to keep testing it
345#
346DIFF_FLAG=${DIFF_FLAG:--u}
347
348# Assign the source directory
349#
350SOURCEDIR=${SOURCEDIR:-/usr/src/etc}
351
352# Define what CVS $Id tag to look for to aid portability.
353#
354CVS_ID_TAG=FreeBSD
355
356case "${RERUN}" in
357'')
358  # Set up the loop to test for the existence of the
359  # temp root directory.
360  #
361  TEST_TEMP_ROOT=yes
362  while [ "${TEST_TEMP_ROOT}" = "yes" ]; do
363    if [ -d "${TEMPROOT}" ]; then
364      echo "*** The directory specified for the temporary root environment,"
365      echo "    ${TEMPROOT}, exists.  This can be a security risk if untrusted"
366      echo "    users have access to the system."
367      echo ''
368      case "${AUTO_RUN}" in
369      '')
370        echo "  Use 'd' to delete the old ${TEMPROOT} and continue"
371        echo "  Use 't' to select a new temporary root directory"
372        echo "  Use 'e' to exit mergemaster"
373        echo ''
374        echo "  Default is to use ${TEMPROOT} as is"
375        echo ''
376        echo -n "How should I deal with this? [Use the existing ${TEMPROOT}] "
377        read DELORNOT
378
379        case "${DELORNOT}" in
380        [dD])
381          echo ''
382          echo "   *** Deleting the old ${TEMPROOT}"
383          echo ''
384          rm -rf "${TEMPROOT}"
385          unset TEST_TEMP_ROOT
386          ;;
387        [tT])
388          echo "   *** Enter new directory name for temporary root environment"
389          read TEMPROOT
390          ;;
391        [eE])
392          exit 0
393          ;;
394        '')
395          echo ''
396          echo "   *** Leaving ${TEMPROOT} intact"
397          echo ''
398          unset TEST_TEMP_ROOT
399          ;;
400        *)
401          echo ''
402          echo "invalid choice: ${DELORNOT}"
403          echo ''
404          ;;
405        esac
406        ;;
407      *)
408        # If this is an auto-run, try a hopefully safe alternative then
409        # re-test anyway.
410        TEMPROOT=/var/tmp/temproot.`date +%m%d.%H.%M.%S`
411        ;;
412      esac
413    else
414      unset TEST_TEMP_ROOT
415    fi
416  done
417
418  echo "*** Creating the temporary root environment in ${TEMPROOT}"
419
420  if mkdir -p "${TEMPROOT}"; then
421    echo " *** ${TEMPROOT} ready for use"
422  fi
423
424  if [ ! -d "${TEMPROOT}" ]; then
425    echo ''
426    echo "  *** FATAL ERROR: Cannot create ${TEMPROOT}"
427    echo ''
428    exit 1
429  fi
430
431  echo " *** Creating and populating directory structure in ${TEMPROOT}"
432  echo ''
433
434  case "${VERBOSE}" in
435  '') ;;
436  *)
437    echo " *** Press [Enter] or [Return] key to continue"
438    read ANY_KEY
439    unset ANY_KEY
440    ;;
441  esac
442
443  { cd ${SOURCEDIR} &&
444    case "${DESTDIR}" in
445    '') ;;
446    *)
447      make DESTDIR=${DESTDIR} distrib-dirs
448      ;;
449    esac
450    make DESTDIR=${TEMPROOT} distrib-dirs &&
451    make DESTDIR=${TEMPROOT} -DNO_MAKEDEV_RUN distribution;} ||
452  { echo '';
453    echo "  *** FATAL ERROR: Cannot 'cd' to ${SOURCEDIR} and install files to";
454    echo "      the temproot environment";
455    echo '';
456    exit 1;}
457
458  # Doing the inventory and removing files that we don't want to compare only
459  # makes sense if we are not doing a rerun, since we have no way of knowing
460  # what happened to the files during previous incarnations.
461  case "${VERBOSE}" in
462  '') ;;
463  *)
464    echo ''
465    echo ' *** The following files exist only in the installed version of'
466    echo "     ${DESTDIR}/etc.  In the vast majority of cases these files"
467    echo '     are necessary parts of the system and should not be deleted.'
468    echo '     However because these files are not updated by this process you'
469    echo '     might want to verify their status before rebooting your system.'
470    echo ''
471    echo ' *** Press [Enter] or [Return] key to continue'
472    read ANY_KEY
473    unset ANY_KEY
474    diff -qr ${DESTDIR}/etc ${TEMPROOT}/etc | grep "^Only in /etc" | ${PAGER}
475    echo ''
476    echo ' *** Press [Enter] or [Return] key to continue'
477    read ANY_KEY
478    unset ANY_KEY
479    ;;
480  esac
481
482  # We really don't want to have to deal with these files, since
483  # master.passwd is the real file that should be compared, then
484  # the user should run pwd_mkdb if necessary.
485  #
486  rm ${TEMPROOT}/etc/spwd.db ${TEMPROOT}/etc/passwd ${TEMPROOT}/etc/pwd.db
487
488  # Avoid comparing the motd if the user specifies it in .mergemasterrc
489  case "${IGNORE_MOTD}" in
490  '') ;;
491  *) rm ${TEMPROOT}/etc/motd
492     ;;
493  esac
494
495  # Avoid trying to update MAKEDEV if /dev is on a devfs
496  if /sbin/sysctl vfs.devfs.generation > /dev/null 2>&1 ; then
497    rm ${TEMPROOT}/dev/MAKEDEV ${TEMPROOT}/dev/MAKEDEV.local
498  fi
499
500  ;; # End of the "RERUN" test
501esac
502
503# Get ready to start comparing files
504
505# Check umask if not specified on the command line,
506# and we are not doing an autorun
507#
508if [ -z "${NEW_UMASK}" -a -z "${AUTO_RUN}" ]; then
509  USER_UMASK=`umask`
510  case "${USER_UMASK}" in
511  0022) ;;
512  *)
513    echo ''
514    echo " *** Your umask is currently set to ${USER_UMASK}.  By default, this script"
515    echo "     installs all files with the same user, group and modes that"
516    echo "     they are created with by ${SOURCEDIR}/Makefile, compared to"
517    echo "     a umask of 022.  This umask allows world read permission when"
518    echo "     the file's default permissions have it."
519    echo "     No world permissions can sometimes cause problems.  A umask of"
520    echo "     022 will restore the default behavior, but is not mandatory."
521    echo "     /etc/master.passwd is a special case.  Its file permissions"
522    echo "     will be 600 (rw-------) if installed."
523    echo ''
524    echo -n "What umask should I use? [${USER_UMASK}] "
525    read NEW_UMASK
526
527    NEW_UMASK="${NEW_UMASK:-$USER_UMASK}"
528    ;;
529  esac
530  echo ''
531fi
532
533CONFIRMED_UMASK=${NEW_UMASK:-0022}
534
535# Warn users who still have ${DESTDIR}/etc/sysconfig
536#
537if [ -e "${DESTDIR}/etc/sysconfig" ]; then
538  echo ''
539  echo " *** There is a sysconfig file on this system in ${DESTDIR}/etc/."
540  echo ''
541  echo '     Starting with FreeBSD version 2.2.2 those settings moved from'
542  echo '     /etc/sysconfig to /etc/rc.conf.  If you are upgrading an older'
543  echo '     system make sure that you transfer your settings by hand from'
544  echo '     sysconfig to rc.conf and install the rc.conf file.  If you'
545  echo '     have already made this transition, you should consider'
546  echo '     renaming or deleting the sysconfig file.'
547  echo ''
548  case "${AUTO_RUN}" in
549  '')
550    echo -n "Continue with the merge process? [yes] "
551    read CONT_OR_NOT
552
553    case "${CONT_OR_NOT}" in
554    [nN]*)
555      exit 0
556      ;;
557    *)
558      echo "   *** Continuing"
559      echo ''
560      ;;
561    esac
562    ;;
563  *) ;;
564  esac
565fi
566
567# Use the umask/mode information to install the files
568# Create directories as needed
569#
570mm_install () {
571  local INSTALL_DIR
572  INSTALL_DIR=${1#.}
573  INSTALL_DIR=${INSTALL_DIR%/*}
574
575  case "${INSTALL_DIR}" in
576  '')
577    INSTALL_DIR=/
578    ;;
579  esac
580
581  if [ -n "${DESTDIR}${INSTALL_DIR}" -a ! -d "${DESTDIR}${INSTALL_DIR}" ]; then
582    DIR_MODE=`perl -e 'printf "%04o\n", (((stat("$ARGV[0]"))[2] & 07777) &~ \
583      oct("$ARGV[1]"))' "${TEMPROOT}/${INSTALL_DIR}" "${CONFIRMED_UMASK}"`
584    install -d -o root -g wheel -m "${DIR_MODE}" "${DESTDIR}${INSTALL_DIR}"
585  fi
586
587  FILE_MODE=`perl -e 'printf "%04o\n", (((stat("$ARGV[0]"))[2] & 07777) &~ \
588      oct("$ARGV[1]"))' "${1}" "${CONFIRMED_UMASK}"`
589
590  if [ ! -x "${1}" ]; then
591    case "${1#.}" in
592    /etc/mail/aliases)
593      NEED_NEWALIASES=yes
594      ;;
595    /etc/login.conf)
596      NEED_CAP_MKDB=yes
597      ;;
598    /etc/master.passwd)
599      install -m 600 "${1}" "${DESTDIR}${INSTALL_DIR}"
600      NEED_PWD_MKDB=yes
601      DONT_INSTALL=yes
602      ;;
603    /.cshrc | /.profile)
604      case "${LINK_EXPLAINED}" in
605      '')
606        echo "   *** Historically BSD derived systems have had a"
607        echo "       hard link from /.cshrc and /.profile to"
608        echo "       their namesakes in /root.  Please indicate"
609        echo "       your preference below for bringing your"
610        echo "       installed files up to date."
611        echo ''
612        LINK_EXPLAINED=yes
613        ;;
614      esac
615
616      echo "   Use 'd' to delete the temporary ${COMPFILE}"
617      echo "   Use 'l' to delete the existing ${DESTDIR}${COMPFILE#.} and create the link"
618      echo ''
619      echo "   Default is to leave the temporary file to deal with by hand"
620      echo ''
621      echo -n "  How should I handle ${COMPFILE}? [Leave it to install later] "
622      read HANDLE_LINK
623
624      case "${HANDLE_LINK}" in
625      [dD]*)
626        rm "${COMPFILE}"
627        echo ''
628        echo "   *** Deleting ${COMPFILE}"
629        ;;
630      [lL]*)
631        echo ''
632        rm -f "${DESTDIR}${COMPFILE#.}"
633        if ln "${DESTDIR}/root/${COMPFILE##*/}" "${DESTDIR}${COMPFILE#.}"; then
634          echo "   *** Link from ${DESTDIR}${COMPFILE#.} to ${DESTDIR}/root/${COMPFILE##*/} installed successfully"
635          rm "${COMPFILE}"
636        else
637          echo "   *** Error linking ${DESTDIR}${COMPFILE#.} to ${DESTDIR}/root/${COMPFILE##*/}, ${COMPFILE} will remain to install by hand"
638        fi
639        ;;
640      *)
641        echo "   *** ${COMPFILE} will remain for your consideration"
642        ;;
643      esac
644      DONT_INSTALL=yes
645      ;;
646    esac
647
648    case "${DONT_INSTALL}" in
649    '')
650      install -m "${FILE_MODE}" "${1}" "${DESTDIR}${INSTALL_DIR}"
651      ;;
652    *)
653      unset DONT_INSTALL
654      ;;
655    esac
656  else
657    case "${1#.}" in
658    /dev/MAKEDEV)
659      NEED_MAKEDEV=yes
660      ;;
661    esac
662    install -m "${FILE_MODE}" "${1}" "${DESTDIR}${INSTALL_DIR}"
663  fi
664  return $?
665}
666
667echo ''
668echo "*** Beginning comparison"
669echo ''
670
671cd "${TEMPROOT}"
672
673if [ -r "${MM_PRE_COMPARE_SCRIPT}" ]; then
674  . "${MM_PRE_COMPARE_SCRIPT}"
675fi
676
677# Using -size +0 avoids uselessly checking the empty log files created
678# by ${SOURCEDIR}/Makefile and the device entries in ./dev, but does
679# check the scripts in ./dev, as we'd like (assuming no devfs of course).
680#
681for COMPFILE in `find . -type f -size +0`; do
682
683  # First, check to see if the file exists in DESTDIR.  If not, the
684  # diff_loop function knows how to handle it.
685  #
686  if [ ! -e "${DESTDIR}${COMPFILE#.}" ]; then
687    diff_loop
688    continue
689  fi
690
691  case "${STRICT}" in
692  '' | [Nn][Oo])
693    # Compare CVS $Id's first so if the file hasn't been modified
694    # local changes will be ignored.
695    # If the files have the same $Id, delete the one in temproot so the
696    # user will have less to wade through if files are left to merge by hand.
697    #
698    CVSID1=`grep "[$]${CVS_ID_TAG}:" ${DESTDIR}${COMPFILE#.} 2>/dev/null`
699    CVSID2=`grep "[$]${CVS_ID_TAG}:" ${COMPFILE} 2>/dev/null`
700
701    case "${CVSID2}" in
702    "${CVSID1}")
703      echo " *** Temp ${COMPFILE} and installed have the same CVS Id, deleting"
704      rm "${COMPFILE}"
705      ;;
706    esac
707    ;;
708  esac
709
710  # If the file is still here either because the $Ids are different, the
711  # file doesn't have an $Id, or we're using STRICT mode; look at the diff.
712  #
713  if [ -f "${COMPFILE}" ]; then
714
715    # Do an absolute diff first to see if the files are actually different.
716    # If they're not different, delete the one in temproot.
717    #
718    if diff -q "${DESTDIR}${COMPFILE#.}" "${COMPFILE}" > /dev/null 2>&1; then
719      echo " *** Temp ${COMPFILE} and installed are the same, deleting"
720      rm "${COMPFILE}"
721    else
722      # Ok, the files are different, so show the user where they differ.
723      # Use user's choice of diff methods; and user's pager if they have one.
724      # Use more if not.
725      # Use unified diffs by default.  Context diffs give me a headache. :)
726      #
727      case "${AUTO_RUN}" in
728      '')
729        # prompt user to install/delete/merge changes
730        diff_loop
731        ;;
732      *)
733        # If this is an auto run, make it official
734        echo "   *** ${COMPFILE} will remain for your consideration"
735        ;;
736      esac # Auto run test
737    fi # Yes, the files are different
738  fi # Yes, the file still remains to be checked
739done # This is for the do way up there at the beginning of the comparison
740
741echo ''
742echo "*** Comparison complete"
743echo ''
744
745TEST_FOR_FILES=`find ${TEMPROOT} -type f -size +0 2>/dev/null`
746if [ -n "${TEST_FOR_FILES}" ]; then
747  echo "*** Files that remain for you to merge by hand:"
748  find "${TEMPROOT}" -type f -size +0
749fi
750
751case "${AUTO_RUN}" in
752'')
753  echo ''
754  echo -n "Do you wish to delete what is left of ${TEMPROOT}? [no] "
755  read DEL_TEMPROOT
756
757  case "${DEL_TEMPROOT}" in
758  [yY]*)
759    if rm -rf "${TEMPROOT}"; then
760      echo " *** ${TEMPROOT} has been deleted"
761    else
762      echo " *** Unable to delete ${TEMPROOT}"
763    fi
764    ;;
765  *)
766    echo " *** ${TEMPROOT} will remain"
767    ;;
768  esac
769  ;;
770*) ;;
771esac
772
773case "${AUTO_INSTALLED_FILES}" in
774'') ;;
775*)
776  case "${AUTO_RUN}" in
777  '')
778    (
779      echo ''
780      echo '*** You chose the automatic install option for files that did not'
781      echo '    exist on your system.  The following were installed for you:'
782      echo "${AUTO_INSTALLED_FILES}"
783    ) | ${PAGER}
784    ;;
785  *)
786    echo ''
787    echo '*** You chose the automatic install option for files that did not'
788    echo '    exist on your system.  The following were installed for you:'
789    echo "${AUTO_INSTALLED_FILES}"
790    ;;
791  esac
792  ;;
793esac
794
795run_it_now () {
796  case "${AUTO_RUN}" in
797  '')
798    unset YES_OR_NO
799    echo ''
800    echo -n '    Would you like to run it now? [y or n] '
801    read YES_OR_NO
802
803    echo ''
804
805    case "${YES_OR_NO}" in
806    y)
807      echo "      Running ${1}"
808      eval "${1}"
809      ;;
810    *)
811      echo "      Make sure to run ${1} yourself"
812      ;;
813    esac
814    ;;
815  *) ;;
816  esac
817}
818
819case "${NEED_MAKEDEV}" in
820'') ;;
821*)
822  echo ''
823  echo "*** You installed a new /dev/MAKEDEV script, so make sure that you run"
824  echo "    'cd /dev && /bin/sh MAKEDEV all' to rebuild your devices"
825  run_it_now 'cd /dev && /bin/sh MAKEDEV all'
826  ;;
827esac
828
829case "${NEED_NEWALIASES}" in
830'') ;;
831*)
832  echo ''
833  echo "*** You installed a new aliases file, so make sure that you run"
834  echo "    '/usr/bin/newaliases' to rebuild your aliases database"
835  run_it_now '/usr/bin/newaliases'
836  ;;
837esac
838
839case "${NEED_CAP_MKDB}" in
840'') ;;
841*)
842  echo ''
843  echo "*** You installed a login.conf file, so make sure that you run"
844  echo "    '/usr/bin/cap_mkdb /etc/login.conf' to rebuild your login.conf database"
845  run_it_now '/usr/bin/cap_mkdb /etc/login.conf'
846  ;;
847esac
848
849case "${NEED_PWD_MKDB}" in
850'') ;;
851*)
852  echo ''
853  echo "*** You installed a new master.passwd file, so make sure that you run"
854  echo "    '/usr/sbin/pwd_mkdb -p /etc/master.passwd' to rebuild your password files"
855  run_it_now '/usr/sbin/pwd_mkdb -p /etc/master.passwd'
856  ;;
857esac
858
859echo ''
860
861if [ -r "${MM_EXIT_SCRIPT}" ]; then
862  . "${MM_EXIT_SCRIPT}"
863fi
864
865exit 0
866
867