mergemaster.sh revision 114523
152400Sbillf#!/bin/sh
252400Sbillf
352400Sbillf# mergemaster
452400Sbillf
552400Sbillf# Compare files created by /usr/src/etc/Makefile (or the directory
652400Sbillf# the user specifies) with the currently installed copies.
752400Sbillf
8110377Sdougb# Copyright 1998-2003 Douglas Barton
973651Sdougb# DougB@FreeBSD.org
1052400Sbillf
1152495Sbillf# $FreeBSD: head/usr.sbin/mergemaster/mergemaster.sh 114523 2003-05-02 11:07:58Z dougb $
1252400Sbillf
1368507SdougbPATH=/bin:/usr/bin:/usr/sbin
1452400Sbillf
1552400Sbillfdisplay_usage () {
1652533Sbillf  VERSION_NUMBER=`grep "[$]FreeBSD:" $0 | cut -d ' ' -f 4`
1752400Sbillf  echo "mergemaster version ${VERSION_NUMBER}"
18114501Sdougb  echo 'Usage: mergemaster [-scrvahipCP] [-m /path]'
1967949Sdougb  echo '         [-t /path] [-d] [-u N] [-w N] [-D /path]'
2052400Sbillf  echo "Options:"
2152400Sbillf  echo "  -s  Strict comparison (diff every pair of files)"
2252400Sbillf  echo "  -c  Use context diff instead of unified diff"
2352400Sbillf  echo "  -r  Re-run on a previously cleaned directory (skip temproot creation)"
2452400Sbillf  echo "  -v  Be more verbose about the process, include additional checks"
2552400Sbillf  echo "  -a  Leave all files that differ to merge by hand"
2652400Sbillf  echo "  -h  Display more complete help"
2767949Sdougb  echo '  -i  Automatically install files that do not exist in destination directory'
2891193Sdougb  echo '  -p  Pre-buildworld mode, only compares crucial files'
2991193Sdougb  echo '  -C  Compare local rc.conf variables to the defaults'
30114501Sdougb  echo '  -P  Preserve files that are overwritten'
3152400Sbillf  echo "  -m /path/directory  Specify location of source to do the make in"
3252400Sbillf  echo "  -t /path/directory  Specify temp root directory"
3352400Sbillf  echo "  -d  Add date and time to directory name (e.g., /var/tmp/temproot.`date +%m%d.%H.%M`)"
3452400Sbillf  echo "  -u N  Specify a numeric umask"
3552400Sbillf  echo "  -w N  Specify a screen width in columns to sdiff"
3667949Sdougb  echo '  -D /path/directory  Specify the destination directory to install files to'
3752400Sbillf  echo ''
3852400Sbillf}
3952400Sbillf
4052400Sbillfdisplay_help () {
4152400Sbillf  echo "* To specify a directory other than /var/tmp/temproot for the"
4252400Sbillf  echo "  temporary root environment, use -t /path/to/temp/root"
4352400Sbillf  echo "* The -w option takes a number as an argument for the column width"
4467859Sdougb  echo "  of the screen.  The default is 80."
4567949Sdougb  echo '* The -a option causes mergemaster to run without prompting.'
4652400Sbillf}
4752400Sbillf
4858910Salfred# Loop allowing the user to use sdiff to merge files and display the merged
4958910Salfred# file.
5058910Salfredmerge_loop () {
5167850Sdougb  case "${VERBOSE}" in
5267850Sdougb  '') ;;
5367850Sdougb  *)
5467850Sdougb      echo "   *** Type h at the sdiff prompt (%) to get usage help"
5567850Sdougb      ;;
5667850Sdougb  esac
5767850Sdougb  echo ''
5867850Sdougb  MERGE_AGAIN=yes
5967850Sdougb  while [ "${MERGE_AGAIN}" = "yes" ]; do
6067850Sdougb    # Prime file.merged so we don't blat the owner/group id's
6167850Sdougb    cp -p "${COMPFILE}" "${COMPFILE}.merged"
6267850Sdougb    sdiff -o "${COMPFILE}.merged" --text --suppress-common-lines \
6367949Sdougb      --width=${SCREEN_WIDTH:-80} "${DESTDIR}${COMPFILE#.}" "${COMPFILE}"
6467850Sdougb    INSTALL_MERGED=V
6567850Sdougb    while [ "${INSTALL_MERGED}" = "v" -o "${INSTALL_MERGED}" = "V" ]; do
6667850Sdougb      echo ''
6767850Sdougb      echo "  Use 'i' to install merged file"
6867850Sdougb      echo "  Use 'r' to re-do the merge"
6967850Sdougb      echo "  Use 'v' to view the merged file"
7067850Sdougb      echo "  Default is to leave the temporary file to deal with by hand"
7167850Sdougb      echo ''
7267859Sdougb      echo -n "    *** How should I deal with the merged file? [Leave it for later] "
7367859Sdougb      read INSTALL_MERGED
7458910Salfred
7567850Sdougb      case "${INSTALL_MERGED}" in
7667850Sdougb      [iI])
7767850Sdougb        mv "${COMPFILE}.merged" "${COMPFILE}"
7867850Sdougb        echo ''
7967850Sdougb        if mm_install "${COMPFILE}"; then
8067850Sdougb          echo "     *** Merged version of ${COMPFILE} installed successfully"
8167859Sdougb        else
8267850Sdougb          echo "     *** Problem installing ${COMPFILE}, it will remain to merge by hand later"
8367859Sdougb        fi
8467850Sdougb        unset MERGE_AGAIN
8567850Sdougb        ;;
8667850Sdougb      [rR])
8767850Sdougb        rm "${COMPFILE}.merged"
8867859Sdougb        ;;
8967850Sdougb      [vV])
9067850Sdougb        ${PAGER} "${COMPFILE}.merged"
9167850Sdougb        ;;
9267850Sdougb      '')
9367850Sdougb        echo "   *** ${COMPFILE} will remain for your consideration"
9467850Sdougb        unset MERGE_AGAIN
9567850Sdougb        ;;
9667850Sdougb      *)
9767850Sdougb        echo "invalid choice: ${INSTALL_MERGED}"
9867850Sdougb        INSTALL_MERGED=V
9967850Sdougb        ;;
10067850Sdougb      esac
10167850Sdougb    done
10267850Sdougb  done
10358910Salfred}
10458910Salfred
10558910Salfred# Loop showing user differences between files, allow merge, skip or install
10658910Salfred# options
10758910Salfreddiff_loop () {
10858910Salfred
10967850Sdougb  HANDLE_COMPFILE=v
11058910Salfred
11177323Sdougb  while [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "V" -o \
11277323Sdougb    "${HANDLE_COMPFILE}" = "NOT V" ]; do
11367949Sdougb    if [ -f "${DESTDIR}${COMPFILE#.}" -a -f "${COMPFILE}" ]; then
11467850Sdougb      if [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "V" ]; then
11590564Sdougb	echo ''
116109993Sdillon	echo '   ======================================================================   '
117109993Sdillon	echo ''
118109993Sdillon        (
119109993Sdillon          echo "  *** Displaying differences between ${COMPFILE} and installed version:"
120109993Sdillon          echo ''
121110377Sdougb          diff ${DIFF_FLAG} ${DIFF_OPTIONS} "${DESTDIR}${COMPFILE#.}" "${COMPFILE}"
122109993Sdillon        ) | ${PAGER}
123109993Sdillon        echo ''
12467850Sdougb      fi
12567850Sdougb    else
126109993Sdillon      echo ''
12767850Sdougb      echo "  *** There is no installed version of ${COMPFILE}"
12891193Sdougb      echo ''
12967949Sdougb      case "${AUTO_INSTALL}" in
13067949Sdougb      [Yy][Ee][Ss])
13167949Sdougb        echo ''
13267949Sdougb        if mm_install "${COMPFILE}"; then
13367949Sdougb          echo "   *** ${COMPFILE} installed successfully"
13468507Sdougb          echo ''
13567949Sdougb          # Make the list print one file per line
13667949Sdougb          AUTO_INSTALLED_FILES="${AUTO_INSTALLED_FILES}      ${DESTDIR}${COMPFILE#.}
13767949Sdougb"
13867949Sdougb        else
13967949Sdougb          echo "   *** Problem installing ${COMPFILE}, it will remain to merge by hand"
14067949Sdougb        fi
14167949Sdougb        return
14267949Sdougb        ;;
14367949Sdougb      *)
14467949Sdougb        NO_INSTALLED=yes
14567949Sdougb        ;;
14667949Sdougb      esac
14767850Sdougb    fi
14867859Sdougb
14967850Sdougb    echo "  Use 'd' to delete the temporary ${COMPFILE}"
15067850Sdougb    echo "  Use 'i' to install the temporary ${COMPFILE}"
15167850Sdougb    case "${NO_INSTALLED}" in
15267850Sdougb    '')
15377326Sdougb      echo "  Use 'm' to merge the temporary and installed versions"
154109993Sdillon      echo "  Use 'v' to view the diff results again"
15567850Sdougb      ;;
15667850Sdougb    esac
15767850Sdougb    echo ''
15867850Sdougb    echo "  Default is to leave the temporary file to deal with by hand"
15967850Sdougb    echo ''
16067859Sdougb    echo -n "How should I deal with this? [Leave it for later] "
16167859Sdougb    read HANDLE_COMPFILE
16267859Sdougb
16367850Sdougb    case "${HANDLE_COMPFILE}" in
16467850Sdougb    [dD])
16567850Sdougb      rm "${COMPFILE}"
16667850Sdougb      echo ''
16767850Sdougb      echo "   *** Deleting ${COMPFILE}"
16867850Sdougb      ;;
16967850Sdougb    [iI])
17067850Sdougb      echo ''
17167850Sdougb      if mm_install "${COMPFILE}"; then
17267850Sdougb        echo "   *** ${COMPFILE} installed successfully"
17367850Sdougb      else
17467850Sdougb        echo "   *** Problem installing ${COMPFILE}, it will remain to merge by hand"
17567850Sdougb      fi
17667850Sdougb      ;;
17767850Sdougb    [mM])
17867850Sdougb      case "${NO_INSTALLED}" in
17967850Sdougb      '')
18067850Sdougb        # interact with user to merge files
18167850Sdougb        merge_loop
18267850Sdougb        ;;
18367850Sdougb      *)
18467850Sdougb        echo ''
18567850Sdougb        echo "   *** There is no installed version of ${COMPFILE}"
18667850Sdougb        echo ''
18767850Sdougb        HANDLE_COMPFILE="NOT V"
18867850Sdougb        ;;
18967850Sdougb      esac # End of "No installed version of file but user selected merge" test
19067850Sdougb      ;;
19167850Sdougb    [vV])
19267850Sdougb      continue
19367850Sdougb      ;;
19467850Sdougb    '')
19567850Sdougb      echo ''
19667850Sdougb      echo "   *** ${COMPFILE} will remain for your consideration"
19767850Sdougb      ;;
19867850Sdougb    *)
19967850Sdougb      # invalid choice, show menu again.
20067850Sdougb      echo "invalid choice: ${HANDLE_COMPFILE}"
20167850Sdougb      echo ''
20267850Sdougb      HANDLE_COMPFILE="NOT V"
20367850Sdougb      continue
20467850Sdougb      ;;
20567850Sdougb    esac  # End of "How to handle files that are different"
20667859Sdougb  done
20767850Sdougb  unset NO_INSTALLED
20867850Sdougb  echo ''
20967850Sdougb  case "${VERBOSE}" in
21067850Sdougb  '') ;;
21167850Sdougb  *)
21267850Sdougb    sleep 3
21367850Sdougb    ;;
21467850Sdougb  esac
21558910Salfred}
21658910Salfred
21797960Sdougbpress_to_continue () {
21897960Sdougb  local DISCARD
21997960Sdougb  echo -n ' *** Press the [Enter] or [Return] key to continue '
22097960Sdougb  read DISCARD
22197960Sdougb}
22297960Sdougb
22352400Sbillf# Set the default path for the temporary root environment
22452400Sbillf#
22552400SbillfTEMPROOT='/var/tmp/temproot'
22652400Sbillf
22773651Sdougb# Read /etc/mergemaster.rc first so the one in $HOME can override
22873651Sdougb#
22973651Sdougbif [ -r /etc/mergemaster.rc ]; then
23073651Sdougb  . /etc/mergemaster.rc
23173651Sdougbfi
23273651Sdougb
23352400Sbillf# Read .mergemasterrc before command line so CLI can override
23452400Sbillf#
23567949Sdougbif [ -r "$HOME/.mergemasterrc" ]; then
23652400Sbillf  . "$HOME/.mergemasterrc"
23752400Sbillffi
23852400Sbillf
23952400Sbillf# Check the command line options
24052400Sbillf#
241114501Sdougbwhile getopts ":ascrvhipCPm:t:du:w:D:" COMMAND_LINE_ARGUMENT ; do
24252400Sbillf  case "${COMMAND_LINE_ARGUMENT}" in
24352400Sbillf  s)
24452400Sbillf    STRICT=yes
245110377Sdougb    unset DIFF_OPTIONS
24652400Sbillf    ;;
24752400Sbillf  c)
24852400Sbillf    DIFF_FLAG='-c'
24952400Sbillf    ;;
25052400Sbillf  r)
25152400Sbillf    RERUN=yes
25252400Sbillf    ;;
25352400Sbillf  v)
25452400Sbillf    case "${AUTO_RUN}" in
25552400Sbillf    '') VERBOSE=yes ;;
25652400Sbillf    esac
25752400Sbillf    ;;
25852400Sbillf  a)
25952400Sbillf    AUTO_RUN=yes
26052400Sbillf    unset VERBOSE
26152400Sbillf    ;;
26252400Sbillf  h)
26352400Sbillf    display_usage
26452400Sbillf    display_help
26552400Sbillf    exit 0
26652400Sbillf    ;;
26767949Sdougb  i)
26867949Sdougb    AUTO_INSTALL=yes
26967949Sdougb    ;;
27096045Sdougb  C)
27196045Sdougb    COMP_CONFS=yes
27296045Sdougb    ;;
273114501Sdougb  P)
274114501Sdougb    PRESERVE_FILES=yes
275114501Sdougb    ;;
27691193Sdougb  p)
27791193Sdougb    PRE_WORLD=yes
27896045Sdougb    unset COMP_CONFS
27996045Sdougb    unset AUTO_RUN
28091193Sdougb    ;;
28152400Sbillf  m)
28252400Sbillf    SOURCEDIR=${OPTARG}
28352400Sbillf    ;;
28452400Sbillf  t)
28552400Sbillf    TEMPROOT=${OPTARG}
28652400Sbillf    ;;
28752400Sbillf  d)
28852400Sbillf    TEMPROOT=${TEMPROOT}.`date +%m%d.%H.%M`
28952400Sbillf    ;;
29052400Sbillf  u)
29152400Sbillf    NEW_UMASK=${OPTARG}
29252400Sbillf    ;;
29352400Sbillf  w)
29452400Sbillf    SCREEN_WIDTH=${OPTARG}
29552400Sbillf    ;;
29667949Sdougb  D)
29767949Sdougb    DESTDIR=${OPTARG}
29867949Sdougb    ;;
29952400Sbillf  *)
30052400Sbillf    display_usage
30152400Sbillf    exit 1
30252400Sbillf    ;;
30352400Sbillf  esac
30452400Sbillfdone
30552400Sbillf
306114501Sdougb# Don't force the user to set this in the mergemaster rc file
307114501Sdougbif [ -n "${PRESERVE_FILES}" -a -z "${PRESERVE_FILES_DIR}" ]; then
308114501Sdougb  PRESERVE_FILES_DIR=/var/tmp/mergemaster/preserved-files-`date +%y%m%d-%H%M%S`
309114501Sdougbfi
310114501Sdougb
31152400Sbillfecho ''
31252400Sbillf
31352400Sbillf# If the user has a pager defined, make sure we can run it
31452400Sbillf#
31552400Sbillfcase "${DONT_CHECK_PAGER}" in
31652400Sbillf'')
31764467Sbrian  while ! type "${PAGER%% *}" >/dev/null && [ -n "${PAGER}" ]; do
31852400Sbillf    echo " *** Your PAGER environment variable specifies '${PAGER}', but"
31964467Sbrian    echo "     due to the limited PATH that I use for security reasons,"
32067859Sdougb    echo "     I cannot execute it.  So, what would you like to do?"
32152400Sbillf    echo ''
32252400Sbillf    echo "  Use 'e' to exit mergemaster and fix your PAGER variable"
32364467Sbrian    if [ -x /usr/bin/less -o -x /usr/local/bin/less ]; then
32464467Sbrian    echo "  Use 'l' to set PAGER to 'less' for this run"
32552400Sbillf    fi
32652400Sbillf    echo "  Use 'm' to use plain old 'more' as your PAGER for this run"
32752400Sbillf    echo ''
32852400Sbillf    echo "  Default is to use plain old 'more' "
32952400Sbillf    echo ''
33067859Sdougb    echo -n "What should I do? [Use 'more'] "
33167859Sdougb    read FIXPAGER
33267859Sdougb
33352400Sbillf    case "${FIXPAGER}" in
33458910Salfred    [eE])
33552400Sbillf       exit 0
33652400Sbillf       ;;
33758910Salfred    [lL])
33864467Sbrian       if [ -x /usr/bin/less ]; then
33964467Sbrian         PAGER=/usr/bin/less
34064467Sbrian       elif [ -x /usr/local/bin/less ]; then
34158910Salfred         PAGER=/usr/local/bin/less
34264467Sbrian       else
34364467Sbrian         echo ''
34464467Sbrian         echo " *** Fatal Error:"
34564467Sbrian         echo "     You asked to use 'less' as your pager, but I can't"
34664467Sbrian         echo "     find it in /usr/bin or /usr/local/bin"
34764467Sbrian         exit 1
34858910Salfred       fi
34952400Sbillf       ;;
35060420Sbsd    [mM]|'')
35152400Sbillf       PAGER=more
35252400Sbillf       ;;
35358910Salfred    *)
35458910Salfred       echo ''
35558910Salfred       echo "invalid choice: ${FIXPAGER}"
35652400Sbillf    esac
35752400Sbillf    echo ''
35858910Salfred  done
35952400Sbillf  ;;
36052400Sbillfesac
36152400Sbillf
36252400Sbillf# If user has a pager defined, or got assigned one above, use it.
36352400Sbillf# If not, use more.
36452400Sbillf#
36552400SbillfPAGER=${PAGER:-more}
36652400Sbillf
36752400Sbillfif [ -n "${VERBOSE}" -a ! "${PAGER}" = "more" ]; then
36852400Sbillf  echo " *** You have ${PAGER} defined as your pager so we will use that"
36952400Sbillf  echo ''
37052400Sbillf  sleep 3
37152400Sbillffi
37252400Sbillf
37352400Sbillf# Assign the diff flag once so we will not have to keep testing it
37452400Sbillf#
37552400SbillfDIFF_FLAG=${DIFF_FLAG:--u}
37652400Sbillf
37752400Sbillf# Assign the source directory
37852400Sbillf#
37952400SbillfSOURCEDIR=${SOURCEDIR:-/usr/src/etc}
38052400Sbillf
38196045Sdougb# Check the width of the user's terminal
38296045Sdougb#
38396045Sdougbif [ -t 0 ]; then
384110377Sdougb  w=`tput columns`
38596045Sdougb  case "${w}" in
38696045Sdougb  0|'') ;; # No-op, since the input is not valid
38796045Sdougb  *)
38896045Sdougb    case "${SCREEN_WIDTH}" in
38996045Sdougb    '') SCREEN_WIDTH="${w}" ;;
39096045Sdougb    "${w}") ;; # No-op, since they are the same
39196045Sdougb    *)
39296045Sdougb      echo -n "*** You entered ${SCREEN_WIDTH} as your screen width, but stty "
39396045Sdougb      echo "thinks it is ${w}."
39496045Sdougb      echo ''
39596045Sdougb      echo -n "What would you like to use? [${w}] "
39696045Sdougb      read SCREEN_WIDTH
39797380Sdougb      case "${SCREEN_WIDTH}" in
39897380Sdougb      '') SCREEN_WIDTH="${w}" ;;
39997380Sdougb      esac
40096045Sdougb      ;;
40196045Sdougb    esac
40296045Sdougb  esac
40396045Sdougbfi
40496045Sdougb
40573651Sdougb# Define what CVS $Id tag to look for to aid portability.
40673651Sdougb#
40773651SdougbCVS_ID_TAG=FreeBSD
40873651Sdougb
40999152Sdougbdelete_temproot () {
410101362Sdougb  rm -rf "${TEMPROOT}" 2>/dev/null
411101362Sdougb  chflags -R 0 "${TEMPROOT}" 2>/dev/null
412101362Sdougb  rm -rf "${TEMPROOT}" || exit 1
41399152Sdougb}
41499152Sdougb
41552400Sbillfcase "${RERUN}" in
41652400Sbillf'')
41752400Sbillf  # Set up the loop to test for the existence of the
41852400Sbillf  # temp root directory.
41952400Sbillf  #
42052400Sbillf  TEST_TEMP_ROOT=yes
42152400Sbillf  while [ "${TEST_TEMP_ROOT}" = "yes" ]; do
42252400Sbillf    if [ -d "${TEMPROOT}" ]; then
42352400Sbillf      echo "*** The directory specified for the temporary root environment,"
42467859Sdougb      echo "    ${TEMPROOT}, exists.  This can be a security risk if untrusted"
42552400Sbillf      echo "    users have access to the system."
42652400Sbillf      echo ''
42752400Sbillf      case "${AUTO_RUN}" in
42852400Sbillf      '')
42952400Sbillf        echo "  Use 'd' to delete the old ${TEMPROOT} and continue"
43052400Sbillf        echo "  Use 't' to select a new temporary root directory"
43152400Sbillf        echo "  Use 'e' to exit mergemaster"
43252400Sbillf        echo ''
43352400Sbillf        echo "  Default is to use ${TEMPROOT} as is"
43452400Sbillf        echo ''
43567859Sdougb        echo -n "How should I deal with this? [Use the existing ${TEMPROOT}] "
43667859Sdougb        read DELORNOT
43767859Sdougb
43867859Sdougb        case "${DELORNOT}" in
43967859Sdougb        [dD])
44067859Sdougb          echo ''
44167859Sdougb          echo "   *** Deleting the old ${TEMPROOT}"
44267859Sdougb          echo ''
44399152Sdougb          delete_temproot || exit 1
44467859Sdougb          unset TEST_TEMP_ROOT
44552400Sbillf          ;;
44667859Sdougb        [tT])
44767859Sdougb          echo "   *** Enter new directory name for temporary root environment"
44867859Sdougb          read TEMPROOT
44967859Sdougb          ;;
45067859Sdougb        [eE])
45167859Sdougb          exit 0
45267859Sdougb          ;;
45367859Sdougb        '')
45467859Sdougb          echo ''
45567859Sdougb          echo "   *** Leaving ${TEMPROOT} intact"
45667859Sdougb          echo ''
45767859Sdougb          unset TEST_TEMP_ROOT
45867859Sdougb          ;;
45967859Sdougb        *)
46067859Sdougb          echo ''
46167859Sdougb          echo "invalid choice: ${DELORNOT}"
46267859Sdougb          echo ''
46367859Sdougb          ;;
46467859Sdougb        esac
46567859Sdougb        ;;
46652400Sbillf      *)
46777323Sdougb        # If this is an auto-run, try a hopefully safe alternative then
46877323Sdougb        # re-test anyway.
46952400Sbillf        TEMPROOT=/var/tmp/temproot.`date +%m%d.%H.%M.%S`
47052400Sbillf        ;;
47152400Sbillf      esac
47252400Sbillf    else
47352400Sbillf      unset TEST_TEMP_ROOT
47452400Sbillf    fi
47552400Sbillf  done
47652400Sbillf
47752400Sbillf  echo "*** Creating the temporary root environment in ${TEMPROOT}"
47852400Sbillf
47952400Sbillf  if mkdir -p "${TEMPROOT}"; then
48052400Sbillf    echo " *** ${TEMPROOT} ready for use"
48152400Sbillf  fi
48252400Sbillf
48352400Sbillf  if [ ! -d "${TEMPROOT}" ]; then
48452400Sbillf    echo ''
48552400Sbillf    echo "  *** FATAL ERROR: Cannot create ${TEMPROOT}"
48652400Sbillf    echo ''
48752400Sbillf    exit 1
48852400Sbillf  fi
48952400Sbillf
49052400Sbillf  echo " *** Creating and populating directory structure in ${TEMPROOT}"
49152400Sbillf  echo ''
49252400Sbillf
49352400Sbillf  case "${VERBOSE}" in
49452400Sbillf  '') ;;
49552400Sbillf  *)
49697960Sdougb    press_to_continue
49752400Sbillf    ;;
49852400Sbillf  esac
49952400Sbillf
50091193Sdougb  case "${PRE_WORLD}" in
50191193Sdougb  '')
50291193Sdougb    { cd ${SOURCEDIR} &&
50391193Sdougb      case "${DESTDIR}" in
50491193Sdougb      '') ;;
50591193Sdougb      *)
50668507Sdougb      make DESTDIR=${DESTDIR} distrib-dirs
50791193Sdougb        ;;
50891193Sdougb      esac
50991193Sdougb      make DESTDIR=${TEMPROOT} distrib-dirs &&
51091193Sdougb      make MAKEOBJDIRPREFIX=${TEMPROOT}/usr/obj obj &&
51191193Sdougb      make MAKEOBJDIRPREFIX=${TEMPROOT}/usr/obj DESTDIR=${TEMPROOT} \
512105705Sphk          distribution;} ||
51391193Sdougb    { echo '';
51491193Sdougb     echo "  *** FATAL ERROR: Cannot 'cd' to ${SOURCEDIR} and install files to";
51591193Sdougb      echo "      the temproot environment";
51691193Sdougb      echo '';
51791193Sdougb      exit 1;}
51891193Sdougb    ;;
51991193Sdougb  *)
52091193Sdougb    # Only set up files that are crucial to {build|install}world
52191193Sdougb    { mkdir -p ${TEMPROOT}/etc &&
52291193Sdougb      cp -p ${SOURCEDIR}/master.passwd ${TEMPROOT}/etc &&
52391193Sdougb      cp -p ${SOURCEDIR}/group ${TEMPROOT}/etc;} ||
52491193Sdougb    { echo '';
52591193Sdougb      echo '  *** FATAL ERROR: Cannot copy files to the temproot environment';
52691193Sdougb      echo '';
52791193Sdougb      exit 1;}
52891193Sdougb    ;;
52991193Sdougb  esac
53052400Sbillf
53177323Sdougb  # Doing the inventory and removing files that we don't want to compare only
53277323Sdougb  # makes sense if we are not doing a rerun, since we have no way of knowing
53377323Sdougb  # what happened to the files during previous incarnations.
53467949Sdougb  case "${VERBOSE}" in
53567949Sdougb  '') ;;
53667949Sdougb  *)
53767949Sdougb    echo ''
53867949Sdougb    echo ' *** The following files exist only in the installed version of'
53967949Sdougb    echo "     ${DESTDIR}/etc.  In the vast majority of cases these files"
54067949Sdougb    echo '     are necessary parts of the system and should not be deleted.'
54167949Sdougb    echo '     However because these files are not updated by this process you'
54267949Sdougb    echo '     might want to verify their status before rebooting your system.'
54367949Sdougb    echo ''
54497960Sdougb    press_to_continue
545101348Sdougb    diff -qr ${DESTDIR}/etc ${TEMPROOT}/etc | grep "^Only in ${DESTDIR}/etc" | ${PAGER}
54667949Sdougb    echo ''
54797960Sdougb    press_to_continue
54867949Sdougb    ;;
54967949Sdougb  esac
55067949Sdougb
55152534Sbillf  # Avoid comparing the motd if the user specifies it in .mergemasterrc
55252534Sbillf  case "${IGNORE_MOTD}" in
55352534Sbillf  '') ;;
55496045Sdougb  *) rm -f ${TEMPROOT}/etc/motd
55552534Sbillf     ;;
55652534Sbillf  esac
55752534Sbillf
55865115Sben  # Avoid trying to update MAKEDEV if /dev is on a devfs
55968507Sdougb  if /sbin/sysctl vfs.devfs.generation > /dev/null 2>&1 ; then
56091193Sdougb    rm -f ${TEMPROOT}/dev/MAKEDEV ${TEMPROOT}/dev/MAKEDEV.local
56165115Sben  fi
56265115Sben
56352400Sbillf  ;; # End of the "RERUN" test
56452400Sbillfesac
56552400Sbillf
566111901Sdougb# We really don't want to have to deal with files like login.conf.db, pwd.db,
567111901Sdougb# or spwd.db.  Instead, we want to compare the text versions, and run *_mkdb.
568111901Sdougb# Prompt the user to do so below, as needed.
56977478Sdougb#
570111905Sdougbrm -f ${TEMPROOT}/etc/*.db ${TEMPROOT}/etc/passwd
57177478Sdougb
57294196Sdougb# We only need to compare things like freebsd.cf once
57396045Sdougbfind ${TEMPROOT}/usr/obj -type f -delete 2>/dev/null
57494196Sdougb
57552400Sbillf# Get ready to start comparing files
57652400Sbillf
57798084Sdougb# Check umask if not specified on the command line,
57898084Sdougb# and we are not doing an autorun
57952400Sbillf#
58098084Sdougbif [ -z "${NEW_UMASK}" -a -z "${AUTO_RUN}" ]; then
58198084Sdougb  USER_UMASK=`umask`
58252400Sbillf  case "${USER_UMASK}" in
58377335Sdougb  0022|022) ;;
58452400Sbillf  *)
58552400Sbillf    echo ''
58698084Sdougb    echo " *** Your umask is currently set to ${USER_UMASK}.  By default, this script"
58798084Sdougb    echo "     installs all files with the same user, group and modes that"
58898084Sdougb    echo "     they are created with by ${SOURCEDIR}/Makefile, compared to"
58998084Sdougb    echo "     a umask of 022.  This umask allows world read permission when"
59098084Sdougb    echo "     the file's default permissions have it."
59152400Sbillf    echo ''
59298084Sdougb    echo "     No world permissions can sometimes cause problems.  A umask of"
59398084Sdougb    echo "     022 will restore the default behavior, but is not mandatory."
59498084Sdougb    echo "     /etc/master.passwd is a special case.  Its file permissions"
59598084Sdougb    echo "     will be 600 (rw-------) if installed."
59697960Sdougb    echo ''
59798084Sdougb    echo -n "What umask should I use? [${USER_UMASK}] "
59898084Sdougb    read NEW_UMASK
59998084Sdougb
60098084Sdougb    NEW_UMASK="${NEW_UMASK:-$USER_UMASK}"
60152400Sbillf    ;;
60252400Sbillf  esac
60352400Sbillf  echo ''
60498084Sdougbfi
60552400Sbillf
60698084SdougbCONFIRMED_UMASK=${NEW_UMASK:-0022}
60798084Sdougb
60852400Sbillf#
609114501Sdougb# Warn users who still have old rc files
610114501Sdougb#
611114501Sdougbfor file in atm devfs diskless1 diskless2 isdn network network6 pccard \
612114523Sdougb  serial syscons sysctl alpha amd64 i386 ia64 sparc64; do
613114501Sdougb  if [ -f "${DESTDIR}/etc/rc.${file}" ]; then
614114501Sdougb    OLD_RC_PRESENT=1
615114501Sdougb    break
616114501Sdougb  fi
617114501Sdougbdone
618114501Sdougb
619114501Sdougbcase "${OLD_RC_PRESENT}" in
620114501Sdougb1)
62152400Sbillf  echo ''
622114501Sdougb  echo " *** There are elements of the old rc system in ${DESTDIR}/etc/."
62367949Sdougb  echo ''
624114501Sdougb  echo '     While these scripts will not hurt anything, they are not'
625114501Sdougb  echo '     functional on an up to date system, and can be removed.'
62667949Sdougb  echo ''
627114501Sdougb
62852400Sbillf  case "${AUTO_RUN}" in
62952400Sbillf  '')
630114501Sdougb    echo -n 'Move these files to /var/tmp/mergemaster/old_rc? [yes] '
631114501Sdougb    read MOVE_OLD_RC
63267859Sdougb
633114501Sdougb    case "${MOVE_OLD_RC}" in
634114501Sdougb    [nN]*) ;;
63552400Sbillf    *)
636114501Sdougb      mkdir -p /var/tmp/mergemaster/old_rc
637114501Sdougb        for file in atm devfs diskless1 diskless2 isdn network network6 pccard \
638114523Sdougb          serial syscons sysctl alpha amd64 i386 ia64 sparc64; do
639114501Sdougb          if [ -f "${DESTDIR}/etc/rc.${file}" ]; then
640114501Sdougb            mv ${DESTDIR}/etc/rc.${file} /var/tmp/mergemaster/old_rc/
641114501Sdougb          fi
642114501Sdougb        done
643114501Sdougb      echo '  The files have been moved'
644114501Sdougb      press_to_continue
64552400Sbillf      ;;
64652400Sbillf    esac
64752400Sbillf    ;;
64852400Sbillf  *) ;;
64952400Sbillf  esac
650114501Sdougbesac
65152400Sbillf
65298084Sdougb# Use the umask/mode information to install the files
65352400Sbillf# Create directories as needed
65452400Sbillf#
65578490Sdougbdo_install_and_rm () {
656114501Sdougb  case "${PRESERVE_FILES}" in
657114501Sdougb  [Yy][Ee][Ss])
658114501Sdougb    if [ -f "${3}/${2##*/}" ]; then
659114501Sdougb      mkdir -p ${PRESERVE_FILES_DIR}
660114501Sdougb      cp ${3}/${2##*/} ${PRESERVE_FILES_DIR}
661114501Sdougb    fi
662114501Sdougb    ;;
663114501Sdougb  esac
664114501Sdougb
66578490Sdougb  install -m "${1}" "${2}" "${3}" &&
66691193Sdougb  rm -f "${2}"
66778490Sdougb}
66878490Sdougb
66998084Sdougb# 4095 = "obase=10;ibase=8;07777" | bc
67098084Sdougbfind_mode () {
67198084Sdougb  local OCTAL
67298084Sdougb  OCTAL=$(( ~$(echo "obase=10; ibase=8; ${CONFIRMED_UMASK}" | bc) & 4095 &
67398084Sdougb    $(echo "obase=10; ibase=8; $(stat -f "%OMp%OLp" ${1})" | bc) )) 
67498084Sdougb  printf "%04o\n" ${OCTAL}
67598084Sdougb}
67698084Sdougb
67752400Sbillfmm_install () {
67852400Sbillf  local INSTALL_DIR
67952400Sbillf  INSTALL_DIR=${1#.}
68052400Sbillf  INSTALL_DIR=${INSTALL_DIR%/*}
68167949Sdougb
68252400Sbillf  case "${INSTALL_DIR}" in
68352400Sbillf  '')
68452400Sbillf    INSTALL_DIR=/
68552400Sbillf    ;;
68652400Sbillf  esac
68752400Sbillf
68867949Sdougb  if [ -n "${DESTDIR}${INSTALL_DIR}" -a ! -d "${DESTDIR}${INSTALL_DIR}" ]; then
68998084Sdougb    DIR_MODE=`find_mode "${TEMPROOT}/${INSTALL_DIR}"`
69067949Sdougb    install -d -o root -g wheel -m "${DIR_MODE}" "${DESTDIR}${INSTALL_DIR}"
69152400Sbillf  fi
69252400Sbillf
69398084Sdougb  FILE_MODE=`find_mode "${1}"`
69452400Sbillf
69552400Sbillf  if [ ! -x "${1}" ]; then
69652400Sbillf    case "${1#.}" in
69764625Sgshapiro    /etc/mail/aliases)
69852400Sbillf      NEED_NEWALIASES=yes
69952400Sbillf      ;;
70052400Sbillf    /etc/login.conf)
70152400Sbillf      NEED_CAP_MKDB=yes
70252400Sbillf      ;;
70352400Sbillf    /etc/master.passwd)
70478490Sdougb      do_install_and_rm 600 "${1}" "${DESTDIR}${INSTALL_DIR}"
70552400Sbillf      NEED_PWD_MKDB=yes
70652400Sbillf      DONT_INSTALL=yes
70752400Sbillf      ;;
70852400Sbillf    /.cshrc | /.profile)
70977335Sdougb    case "${AUTO_INSTALL}" in
71077335Sdougb    '')
71152400Sbillf      case "${LINK_EXPLAINED}" in
71252400Sbillf      '')
71367859Sdougb        echo "   *** Historically BSD derived systems have had a"
71467859Sdougb        echo "       hard link from /.cshrc and /.profile to"
71567859Sdougb        echo "       their namesakes in /root.  Please indicate"
71667859Sdougb        echo "       your preference below for bringing your"
71767859Sdougb        echo "       installed files up to date."
71852400Sbillf        echo ''
71952400Sbillf        LINK_EXPLAINED=yes
72052400Sbillf        ;;
72152400Sbillf      esac
72252400Sbillf
72352400Sbillf      echo "   Use 'd' to delete the temporary ${COMPFILE}"
72467949Sdougb      echo "   Use 'l' to delete the existing ${DESTDIR}${COMPFILE#.} and create the link"
72552400Sbillf      echo ''
72652400Sbillf      echo "   Default is to leave the temporary file to deal with by hand"
72752400Sbillf      echo ''
72867859Sdougb      echo -n "  How should I handle ${COMPFILE}? [Leave it to install later] "
72967859Sdougb      read HANDLE_LINK
73077335Sdougb      ;;
73177335Sdougb    *)  # Part of AUTO_INSTALL
73277335Sdougb      HANDLE_LINK=l
73377335Sdougb      ;;
73477335Sdougb    esac
73567859Sdougb
73652400Sbillf      case "${HANDLE_LINK}" in
73752400Sbillf      [dD]*)
73852400Sbillf        rm "${COMPFILE}"
73952400Sbillf        echo ''
74052400Sbillf        echo "   *** Deleting ${COMPFILE}"
74152400Sbillf        ;;
74252400Sbillf      [lL]*)
74352400Sbillf        echo ''
74467949Sdougb        rm -f "${DESTDIR}${COMPFILE#.}"
74567949Sdougb        if ln "${DESTDIR}/root/${COMPFILE##*/}" "${DESTDIR}${COMPFILE#.}"; then
74667949Sdougb          echo "   *** Link from ${DESTDIR}${COMPFILE#.} to ${DESTDIR}/root/${COMPFILE##*/} installed successfully"
74752400Sbillf          rm "${COMPFILE}"
74852400Sbillf        else
74967949Sdougb          echo "   *** Error linking ${DESTDIR}${COMPFILE#.} to ${DESTDIR}/root/${COMPFILE##*/}, ${COMPFILE} will remain to install by hand"
75052400Sbillf        fi
75152400Sbillf        ;;
75252400Sbillf      *)
75352400Sbillf        echo "   *** ${COMPFILE} will remain for your consideration"
75452400Sbillf        ;;
75552400Sbillf      esac
75652400Sbillf      DONT_INSTALL=yes
75752400Sbillf      ;;
75852400Sbillf    esac
75952400Sbillf
76052400Sbillf    case "${DONT_INSTALL}" in
76152400Sbillf    '')
76278490Sdougb      do_install_and_rm "${FILE_MODE}" "${1}" "${DESTDIR}${INSTALL_DIR}"
76352400Sbillf      ;;
76452400Sbillf    *)
76552400Sbillf      unset DONT_INSTALL
76652400Sbillf      ;;
76752400Sbillf    esac
76878490Sdougb  else	# File matched -x
76967949Sdougb    case "${1#.}" in
77067949Sdougb    /dev/MAKEDEV)
77167949Sdougb      NEED_MAKEDEV=yes
77267949Sdougb      ;;
77367949Sdougb    esac
77478490Sdougb    do_install_and_rm "${FILE_MODE}" "${1}" "${DESTDIR}${INSTALL_DIR}"
77552400Sbillf  fi
77652400Sbillf  return $?
77752400Sbillf}
77852400Sbillf
77967949Sdougbecho ''
78067949Sdougbecho "*** Beginning comparison"
78167949Sdougbecho ''
78252400Sbillf
78367949Sdougbcd "${TEMPROOT}"
78467949Sdougb
78567949Sdougbif [ -r "${MM_PRE_COMPARE_SCRIPT}" ]; then
78667949Sdougb  . "${MM_PRE_COMPARE_SCRIPT}"
78767949Sdougbfi
78867949Sdougb
78952400Sbillf# Using -size +0 avoids uselessly checking the empty log files created
79052400Sbillf# by ${SOURCEDIR}/Makefile and the device entries in ./dev, but does
79167949Sdougb# check the scripts in ./dev, as we'd like (assuming no devfs of course).
79252400Sbillf#
79352400Sbillffor COMPFILE in `find . -type f -size +0`; do
79467949Sdougb
79567949Sdougb  # First, check to see if the file exists in DESTDIR.  If not, the
79667949Sdougb  # diff_loop function knows how to handle it.
79767949Sdougb  #
79867949Sdougb  if [ ! -e "${DESTDIR}${COMPFILE#.}" ]; then
79977325Sdougb    case "${AUTO_RUN}" in
80077325Sdougb      '')
80177325Sdougb        diff_loop
80277325Sdougb        ;;
80377325Sdougb      *)
80477325Sdougb        case "${AUTO_INSTALL}" in
80577325Sdougb        '')
80677325Sdougb          # If this is an auto run, make it official
80777325Sdougb          echo "   *** ${COMPFILE} will remain for your consideration"
80877325Sdougb          ;;
80977325Sdougb        *)
81077325Sdougb          diff_loop
81177325Sdougb          ;;
81277325Sdougb        esac
81377325Sdougb        ;;
81477325Sdougb    esac # Auto run test
81567949Sdougb    continue
81667949Sdougb  fi
81767949Sdougb
81852400Sbillf  case "${STRICT}" in
81952400Sbillf  '' | [Nn][Oo])
82052400Sbillf    # Compare CVS $Id's first so if the file hasn't been modified
82152400Sbillf    # local changes will be ignored.
82252400Sbillf    # If the files have the same $Id, delete the one in temproot so the
82352400Sbillf    # user will have less to wade through if files are left to merge by hand.
82452400Sbillf    #
82573651Sdougb    CVSID1=`grep "[$]${CVS_ID_TAG}:" ${DESTDIR}${COMPFILE#.} 2>/dev/null`
82690564Sdougb    CVSID2=`grep "[$]${CVS_ID_TAG}:" ${COMPFILE} 2>/dev/null` || CVSID2=none
82752400Sbillf
82867949Sdougb    case "${CVSID2}" in
82973651Sdougb    "${CVSID1}")
83067949Sdougb      echo " *** Temp ${COMPFILE} and installed have the same CVS Id, deleting"
83167949Sdougb      rm "${COMPFILE}"
83267949Sdougb      ;;
83367949Sdougb    esac
83452400Sbillf    ;;
83552400Sbillf  esac
83652400Sbillf
83752400Sbillf  # If the file is still here either because the $Ids are different, the
83852400Sbillf  # file doesn't have an $Id, or we're using STRICT mode; look at the diff.
83952400Sbillf  #
84052400Sbillf  if [ -f "${COMPFILE}" ]; then
84152400Sbillf
84252400Sbillf    # Do an absolute diff first to see if the files are actually different.
84352400Sbillf    # If they're not different, delete the one in temproot.
84452400Sbillf    #
845110377Sdougb    if diff -q ${DIFF_OPTIONS} "${DESTDIR}${COMPFILE#.}" "${COMPFILE}" > \
846110377Sdougb      /dev/null 2>&1; then
84752400Sbillf      echo " *** Temp ${COMPFILE} and installed are the same, deleting"
84852400Sbillf      rm "${COMPFILE}"
84952400Sbillf    else
85077323Sdougb      # Ok, the files are different, so show the user where they differ.
85177323Sdougb      # Use user's choice of diff methods; and user's pager if they have one.
85277323Sdougb      # Use more if not.
85367859Sdougb      # Use unified diffs by default.  Context diffs give me a headache. :)
85452400Sbillf      #
85552400Sbillf      case "${AUTO_RUN}" in
85652400Sbillf      '')
85758910Salfred        # prompt user to install/delete/merge changes
85858910Salfred        diff_loop
85952400Sbillf        ;;
86052400Sbillf      *)
86152400Sbillf        # If this is an auto run, make it official
86252400Sbillf        echo "   *** ${COMPFILE} will remain for your consideration"
86352400Sbillf        ;;
86452400Sbillf      esac # Auto run test
86552400Sbillf    fi # Yes, the files are different
86652400Sbillf  fi # Yes, the file still remains to be checked
86752400Sbillfdone # This is for the do way up there at the beginning of the comparison
86852400Sbillf
86952534Sbillfecho ''
87052400Sbillfecho "*** Comparison complete"
87152400Sbillfecho ''
87252400Sbillf
87352400SbillfTEST_FOR_FILES=`find ${TEMPROOT} -type f -size +0 2>/dev/null`
87452400Sbillfif [ -n "${TEST_FOR_FILES}" ]; then
87552400Sbillf  echo "*** Files that remain for you to merge by hand:"
87652400Sbillf  find "${TEMPROOT}" -type f -size +0
87777335Sdougb  echo ''
87852400Sbillffi
87952400Sbillf
88052400Sbillfcase "${AUTO_RUN}" in
88152400Sbillf'')
88267859Sdougb  echo -n "Do you wish to delete what is left of ${TEMPROOT}? [no] "
88367859Sdougb  read DEL_TEMPROOT
88467859Sdougb
88552400Sbillf  case "${DEL_TEMPROOT}" in
88652400Sbillf  [yY]*)
88799152Sdougb    if delete_temproot; then
88852400Sbillf      echo " *** ${TEMPROOT} has been deleted"
88952400Sbillf    else
89052400Sbillf      echo " *** Unable to delete ${TEMPROOT}"
89152400Sbillf    fi
89252400Sbillf    ;;
89352400Sbillf  *)
89452400Sbillf    echo " *** ${TEMPROOT} will remain"
89552400Sbillf    ;;
89652400Sbillf  esac
89752400Sbillf  ;;
89852400Sbillf*) ;;
89952400Sbillfesac
90052400Sbillf
90168153Sdougbcase "${AUTO_INSTALLED_FILES}" in
90268153Sdougb'') ;;
90368153Sdougb*)
90473651Sdougb  case "${AUTO_RUN}" in
90573651Sdougb  '')
90673651Sdougb    (
90773651Sdougb      echo ''
90877323Sdougb      echo '*** You chose the automatic install option for files that did not'
90977323Sdougb      echo '    exist on your system.  The following were installed for you:'
91073651Sdougb      echo "${AUTO_INSTALLED_FILES}"
91173651Sdougb    ) | ${PAGER}
91273651Sdougb    ;;
91373651Sdougb  *)
91468153Sdougb    echo ''
91577323Sdougb    echo '*** You chose the automatic install option for files that did not'
91677323Sdougb    echo '    exist on your system.  The following were installed for you:'
91768153Sdougb    echo "${AUTO_INSTALLED_FILES}"
91873651Sdougb    ;;
91973651Sdougb  esac
92068153Sdougb  ;;
92168153Sdougbesac
92268153Sdougb
92373651Sdougbrun_it_now () {
92473651Sdougb  case "${AUTO_RUN}" in
92573651Sdougb  '')
92673651Sdougb    unset YES_OR_NO
92773651Sdougb    echo ''
92877335Sdougb    echo -n '    Would you like to run it now? y or n [n] '
92973651Sdougb    read YES_OR_NO
93073651Sdougb
93173651Sdougb    case "${YES_OR_NO}" in
93273651Sdougb    y)
93377335Sdougb      echo "    Running ${1}"
93477335Sdougb      echo ''
93573651Sdougb      eval "${1}"
93673651Sdougb      ;;
93777335Sdougb    ''|n)
93877335Sdougb      echo ''
93977335Sdougb      echo "       *** Cancelled"
94077335Sdougb      echo ''
94177335Sdougb      echo "    Make sure to run ${1} yourself"
94277335Sdougb      ;;
94373651Sdougb    *)
94477335Sdougb      echo ''
94577335Sdougb      echo "       *** Sorry, I do not understand your answer (${YES_OR_NO})"
94677335Sdougb      echo ''
94777335Sdougb      echo "    Make sure to run ${1} yourself"
94873651Sdougb    esac
94973651Sdougb    ;;
95073651Sdougb  *) ;;
95173651Sdougb  esac
95273651Sdougb}
95373651Sdougb
95452400Sbillfcase "${NEED_MAKEDEV}" in
95552400Sbillf'') ;;
95652400Sbillf*)
95752400Sbillf  echo ''
95877335Sdougb  echo "*** You installed a new ${DESTDIR}/dev/MAKEDEV script, so make sure that you run"
95977335Sdougb  echo "    'cd ${DESTDIR}/dev && /bin/sh MAKEDEV all' to rebuild your devices"
96077335Sdougb  run_it_now "cd ${DESTDIR}/dev && /bin/sh MAKEDEV all"
96152400Sbillf  ;;
96252400Sbillfesac
96352400Sbillf
96452400Sbillfcase "${NEED_NEWALIASES}" in
96552400Sbillf'') ;;
96652400Sbillf*)
96752400Sbillf  echo ''
96877335Sdougb  if [ -n "${DESTDIR}" ]; then
96977335Sdougb    echo "*** You installed a new aliases file into ${DESTDIR}/etc/mail, but"
97077335Sdougb    echo "    the newaliases command is limited to the directories configured"
97177335Sdougb    echo "    in sendmail.cf.  Make sure to create your aliases database by"
97277335Sdougb    echo "    hand when your sendmail configuration is done."
97377335Sdougb  else
97477335Sdougb    echo "*** You installed a new aliases file, so make sure that you run"
97577335Sdougb    echo "    '/usr/bin/newaliases' to rebuild your aliases database"
97677335Sdougb    run_it_now '/usr/bin/newaliases'
97777335Sdougb  fi
97852400Sbillf  ;;
97952400Sbillfesac
98052400Sbillf
98152400Sbillfcase "${NEED_CAP_MKDB}" in
98252400Sbillf'') ;;
98352400Sbillf*)
98452400Sbillf  echo ''
98552400Sbillf  echo "*** You installed a login.conf file, so make sure that you run"
98677335Sdougb  echo "    '/usr/bin/cap_mkdb ${DESTDIR}/etc/login.conf'"
98777335Sdougb  echo "     to rebuild your login.conf database"
98877335Sdougb  run_it_now "/usr/bin/cap_mkdb ${DESTDIR}/etc/login.conf"
98952400Sbillf  ;;
99052400Sbillfesac
99152400Sbillf
99252400Sbillfcase "${NEED_PWD_MKDB}" in
99352400Sbillf'') ;;
99452400Sbillf*)
99552400Sbillf  echo ''
99652400Sbillf  echo "*** You installed a new master.passwd file, so make sure that you run"
99777335Sdougb  if [ -n "${DESTDIR}" ]; then
99877335Sdougb    echo "    '/usr/sbin/pwd_mkdb -d ${DESTDIR}/etc -p ${DESTDIR}/etc/master.passwd'"
99977335Sdougb    echo "    to rebuild your password files"
100077335Sdougb    run_it_now "/usr/sbin/pwd_mkdb -d ${DESTDIR}/etc -p ${DESTDIR}/etc/master.passwd"
100177335Sdougb  else
100277335Sdougb    echo "    '/usr/sbin/pwd_mkdb -p /etc/master.passwd'"
100377335Sdougb    echo "     to rebuild your password files"
100477335Sdougb    run_it_now '/usr/sbin/pwd_mkdb -p /etc/master.passwd'
100577335Sdougb  fi
100652400Sbillf  ;;
100752400Sbillfesac
100852400Sbillf
100952400Sbillfecho ''
101052400Sbillf
101167949Sdougbif [ -r "${MM_EXIT_SCRIPT}" ]; then
101267949Sdougb  . "${MM_EXIT_SCRIPT}"
101367949Sdougbfi
101467949Sdougb
101591193Sdougbcase "${COMP_CONFS}" in
101691193Sdougb'') ;;
101791193Sdougb*)
101891193Sdougb  . ${DESTDIR}/etc/defaults/rc.conf
101991193Sdougb
102091193Sdougb  (echo ''
102191193Sdougb  echo "*** Comparing conf files: ${rc_conf_files}"
102291193Sdougb
102391193Sdougb  for CONF_FILE in ${rc_conf_files}; do
102491193Sdougb    if [ -r "${DESTDIR}${CONF_FILE}" ]; then
102591193Sdougb      echo ''
102691193Sdougb      echo "*** From ${DESTDIR}${CONF_FILE}"
102791193Sdougb      echo "*** From ${DESTDIR}/etc/defaults/rc.conf"
102891193Sdougb
102991193Sdougb      for RC_CONF_VAR in `grep -i ^[a-z] ${DESTDIR}${CONF_FILE} |
103091193Sdougb        cut -d '=' -f 1`; do
103191193Sdougb        echo ''
103291223Sdougb        grep -w ^${RC_CONF_VAR} ${DESTDIR}${CONF_FILE}
103391223Sdougb        grep -w ^${RC_CONF_VAR} ${DESTDIR}/etc/defaults/rc.conf ||
103491193Sdougb          echo ' * No default variable with this name'
103591193Sdougb      done
103691193Sdougb    fi
103791193Sdougb  done) | ${PAGER}
103891193Sdougb  echo ''
103991193Sdougb  ;;
104091193Sdougbesac
104191193Sdougb
104291193Sdougbcase "${PRE_WORLD}" in
104391193Sdougb'') ;;
104491193Sdougb*)
104591193Sdougb  MAKE_CONF="${SOURCEDIR%etc}share/examples/etc/make.conf"
104691193Sdougb
104791193Sdougb  (echo ''
104891193Sdougb  echo '*** Comparing make variables'
104991193Sdougb  echo ''
105091193Sdougb  echo "*** From ${DESTDIR}/etc/make.conf"
105191193Sdougb  echo "*** From ${MAKE_CONF}"
105291193Sdougb
1053101348Sdougb  for MAKE_VAR in `grep -i ^[a-z] ${DESTDIR}/etc/make.conf | cut -d '=' -f 1`; do
105491193Sdougb    echo ''
105591223Sdougb    grep -w ^${MAKE_VAR} ${DESTDIR}/etc/make.conf
105691223Sdougb    grep -w ^#${MAKE_VAR} ${MAKE_CONF} ||
105791193Sdougb      echo ' * No example variable with this name'
105891193Sdougb  done) | ${PAGER}
105991193Sdougb  ;;
106091193Sdougbesac
106191193Sdougb
106252400Sbillfexit 0
106367850Sdougb
1064