mergemaster.sh revision 98084
1142140Snjl#!/bin/sh
2142140Snjl
3142140Snjl# mergemaster
4142140Snjl
5142140Snjl# Compare files created by /usr/src/etc/Makefile (or the directory
6142140Snjl# the user specifies) with the currently installed copies.
7142140Snjl
8142140Snjl# Copyright 1998-2002 Douglas Barton
9142140Snjl# DougB@FreeBSD.org
10142140Snjl
11142140Snjl# $FreeBSD: head/usr.sbin/mergemaster/mergemaster.sh 98084 2002-06-10 07:16:42Z dougb $
12142140Snjl
13142140SnjlPATH=/bin:/usr/bin:/usr/sbin
14142140Snjl
15142140Snjldisplay_usage () {
16142140Snjl  VERSION_NUMBER=`grep "[$]FreeBSD:" $0 | cut -d ' ' -f 4`
17142140Snjl  echo "mergemaster version ${VERSION_NUMBER}"
18142140Snjl  echo 'Usage: mergemaster [-scrvahipC] [-m /path]'
19142140Snjl  echo '         [-t /path] [-d] [-u N] [-w N] [-D /path]'
20142140Snjl  echo "Options:"
21142140Snjl  echo "  -s  Strict comparison (diff every pair of files)"
22142140Snjl  echo "  -c  Use context diff instead of unified diff"
23142140Snjl  echo "  -r  Re-run on a previously cleaned directory (skip temproot creation)"
24142140Snjl  echo "  -v  Be more verbose about the process, include additional checks"
25142140Snjl  echo "  -a  Leave all files that differ to merge by hand"
26142140Snjl  echo "  -h  Display more complete help"
27142140Snjl  echo '  -i  Automatically install files that do not exist in destination directory'
28142140Snjl  echo '  -p  Pre-buildworld mode, only compares crucial files'
29142140Snjl  echo '  -C  Compare local rc.conf variables to the defaults'
30142140Snjl  echo "  -m /path/directory  Specify location of source to do the make in"
31142140Snjl  echo "  -t /path/directory  Specify temp root directory"
32142140Snjl  echo "  -d  Add date and time to directory name (e.g., /var/tmp/temproot.`date +%m%d.%H.%M`)"
33142140Snjl  echo "  -u N  Specify a numeric umask"
34142140Snjl  echo "  -w N  Specify a screen width in columns to sdiff"
35143902Snjl  echo '  -D /path/directory  Specify the destination directory to install files to'
36142140Snjl  echo ''
37142140Snjl}
38142140Snjl
39142140Snjldisplay_help () {
40142140Snjl  echo "* To specify a directory other than /var/tmp/temproot for the"
41182048Sjhb  echo "  temporary root environment, use -t /path/to/temp/root"
42185341Sjkim  echo "* The -w option takes a number as an argument for the column width"
43142140Snjl  echo "  of the screen.  The default is 80."
44177040Sjhb  echo '* The -a option causes mergemaster to run without prompting.'
45142140Snjl}
46193530Sjkim
47193530Sjkim# Loop allowing the user to use sdiff to merge files and display the merged
48144630Snjl# file.
49144630Snjlmerge_loop () {
50144630Snjl  case "${VERBOSE}" in
51142140Snjl  '') ;;
52142140Snjl  *)
53142140Snjl      echo "   *** Type h at the sdiff prompt (%) to get usage help"
54142140Snjl      ;;
55142140Snjl  esac
56142140Snjl  echo ''
57142140Snjl  MERGE_AGAIN=yes
58142140Snjl  while [ "${MERGE_AGAIN}" = "yes" ]; do
59142140Snjl    # Prime file.merged so we don't blat the owner/group id's
60142140Snjl    cp -p "${COMPFILE}" "${COMPFILE}.merged"
61142140Snjl    sdiff -o "${COMPFILE}.merged" --text --suppress-common-lines \
62142140Snjl      --width=${SCREEN_WIDTH:-80} "${DESTDIR}${COMPFILE#.}" "${COMPFILE}"
63142140Snjl    INSTALL_MERGED=V
64143902Snjl    while [ "${INSTALL_MERGED}" = "v" -o "${INSTALL_MERGED}" = "V" ]; do
65142140Snjl      echo ''
66142140Snjl      echo "  Use 'i' to install merged file"
67142140Snjl      echo "  Use 'r' to re-do the merge"
68142140Snjl      echo "  Use 'v' to view the merged file"
69185341Sjkim      echo "  Default is to leave the temporary file to deal with by hand"
70142140Snjl      echo ''
71143902Snjl      echo -n "    *** How should I deal with the merged file? [Leave it for later] "
72142140Snjl      read INSTALL_MERGED
73142140Snjl
74142140Snjl      case "${INSTALL_MERGED}" in
75143902Snjl      [iI])
76143902Snjl        mv "${COMPFILE}.merged" "${COMPFILE}"
77182048Sjhb        echo ''
78143902Snjl        if mm_install "${COMPFILE}"; then
79142140Snjl          echo "     *** Merged version of ${COMPFILE} installed successfully"
80142140Snjl        else
81142140Snjl          echo "     *** Problem installing ${COMPFILE}, it will remain to merge by hand later"
82142140Snjl        fi
83142140Snjl        unset MERGE_AGAIN
84142140Snjl        ;;
85142140Snjl      [rR])
86142140Snjl        rm "${COMPFILE}.merged"
87142140Snjl        ;;
88158446Snjl      [vV])
89158446Snjl        ${PAGER} "${COMPFILE}.merged"
90142140Snjl        ;;
91158446Snjl      '')
92142140Snjl        echo "   *** ${COMPFILE} will remain for your consideration"
93185341Sjkim        unset MERGE_AGAIN
94158446Snjl        ;;
95185341Sjkim      *)
96142140Snjl        echo "invalid choice: ${INSTALL_MERGED}"
97182201Sjhb        INSTALL_MERGED=V
98182201Sjhb        ;;
99199273Smav      esac
100199273Smav    done
101142140Snjl  done
102142140Snjl}
103142140Snjl
104142140Snjl# Loop showing user differences between files, allow merge, skip or install
105142140Snjl# options
106142140Snjldiff_loop () {
107142140Snjl
108142140Snjl  HANDLE_COMPFILE=v
109142140Snjl
110177296Sphk  while [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "V" -o \
111142140Snjl    "${HANDLE_COMPFILE}" = "NOT V" ]; do
112142140Snjl    if [ -f "${DESTDIR}${COMPFILE#.}" -a -f "${COMPFILE}" ]; then
113212721Smav      if [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "V" ]; then
114142140Snjl	echo ''
115143902Snjl	echo '   ======================================================================   '
116143902Snjl	echo ''
117142140Snjl        (
118142140Snjl          echo ''
119143902Snjl          echo "  *** Displaying differences between ${COMPFILE} and installed version:"
120212721Smav          echo ''
121212721Smav          diff "${DIFF_FLAG}" "${DESTDIR}${COMPFILE#.}" "${COMPFILE}"
122212721Smav        ) | ${PAGER}
123142140Snjl        echo ''
124143902Snjl      fi
125142140Snjl    else
126142140Snjl      echo ''
127142140Snjl      echo "  *** There is no installed version of ${COMPFILE}"
128142140Snjl      echo ''
129142140Snjl      case "${AUTO_INSTALL}" in
130142140Snjl      [Yy][Ee][Ss])
131142140Snjl        echo ''
132142140Snjl        if mm_install "${COMPFILE}"; then
133142140Snjl          echo "   *** ${COMPFILE} installed successfully"
134143902Snjl          echo ''
135142140Snjl          # Make the list print one file per line
136142140Snjl          AUTO_INSTALLED_FILES="${AUTO_INSTALLED_FILES}      ${DESTDIR}${COMPFILE#.}
137142140Snjl"
138142140Snjl        else
139142140Snjl          echo "   *** Problem installing ${COMPFILE}, it will remain to merge by hand"
140142140Snjl        fi
141142140Snjl        return
142142140Snjl        ;;
143142140Snjl      *)
144143902Snjl        NO_INSTALLED=yes
145142140Snjl        ;;
146142140Snjl      esac
147142140Snjl    fi
148142140Snjl
149142140Snjl    echo "  Use 'd' to delete the temporary ${COMPFILE}"
150142140Snjl    echo "  Use 'i' to install the temporary ${COMPFILE}"
151142140Snjl    case "${NO_INSTALLED}" in
152142140Snjl    '')
153142140Snjl      echo "  Use 'm' to merge the temporary and installed versions"
154143902Snjl      echo "  Use 'v' to view the diff results again"
155142140Snjl      ;;
156142140Snjl    esac
157142140Snjl    echo ''
158142140Snjl    echo "  Default is to leave the temporary file to deal with by hand"
159142140Snjl    echo ''
160142140Snjl    echo -n "How should I deal with this? [Leave it for later] "
161142140Snjl    read HANDLE_COMPFILE
162142140Snjl
163143902Snjl    case "${HANDLE_COMPFILE}" in
164142140Snjl    [dD])
165142140Snjl      rm "${COMPFILE}"
166142140Snjl      echo ''
167142140Snjl      echo "   *** Deleting ${COMPFILE}"
168142140Snjl      ;;
169142140Snjl    [iI])
170142140Snjl      echo ''
171142140Snjl      if mm_install "${COMPFILE}"; then
172143902Snjl        echo "   *** ${COMPFILE} installed successfully"
173142140Snjl      else
174142140Snjl        echo "   *** Problem installing ${COMPFILE}, it will remain to merge by hand"
175142140Snjl      fi
176142140Snjl      ;;
177142140Snjl    [mM])
178142140Snjl      case "${NO_INSTALLED}" in
179142140Snjl      '')
180142140Snjl        # interact with user to merge files
181142140Snjl        merge_loop
182142140Snjl        ;;
183143902Snjl      *)
184142140Snjl        echo ''
185142140Snjl        echo "   *** There is no installed version of ${COMPFILE}"
186142140Snjl        echo ''
187142140Snjl        HANDLE_COMPFILE="NOT V"
188142140Snjl        ;;
189142140Snjl      esac # End of "No installed version of file but user selected merge" test
190142140Snjl      ;;
191142140Snjl    [vV])
192142140Snjl      continue
193143902Snjl      ;;
194142140Snjl    '')
195142140Snjl      echo ''
196142140Snjl      echo "   *** ${COMPFILE} will remain for your consideration"
197142140Snjl      ;;
198142140Snjl    *)
199142140Snjl      # invalid choice, show menu again.
200142140Snjl      echo "invalid choice: ${HANDLE_COMPFILE}"
201142140Snjl      echo ''
202143902Snjl      HANDLE_COMPFILE="NOT V"
203142140Snjl      continue
204142140Snjl      ;;
205142140Snjl    esac  # End of "How to handle files that are different"
206142140Snjl  done
207142140Snjl  unset NO_INSTALLED
208142140Snjl  echo ''
209142140Snjl  case "${VERBOSE}" in
210142140Snjl  '') ;;
211143902Snjl  *)
212142140Snjl    sleep 3
213142140Snjl    ;;
214142140Snjl  esac
215142140Snjl}
216142140Snjl
217142140Snjlpress_to_continue () {
218142140Snjl  local DISCARD
219142140Snjl  echo -n ' *** Press the [Enter] or [Return] key to continue '
220142140Snjl  read DISCARD
221142140Snjl}
222212721Smav
223142140Snjl# Set the default path for the temporary root environment
224143902Snjl#
225142140SnjlTEMPROOT='/var/tmp/temproot'
226142140Snjl
227142140Snjl# Read /etc/mergemaster.rc first so the one in $HOME can override
228142140Snjl#
229142140Snjlif [ -r /etc/mergemaster.rc ]; then
230142140Snjl  . /etc/mergemaster.rc
231142140Snjlfi
232142140Snjl
233142140Snjl# Read .mergemasterrc before command line so CLI can override
234142140Snjl#
235142140Snjlif [ -r "$HOME/.mergemasterrc" ]; then
236143902Snjl  . "$HOME/.mergemasterrc"
237142140Snjlfi
238142140Snjl
239142140Snjl# Check the command line options
240142140Snjl#
241142140Snjlwhile getopts ":ascrvhipCm:t:du:w:D:" COMMAND_LINE_ARGUMENT ; do
242142140Snjl  case "${COMMAND_LINE_ARGUMENT}" in
243142140Snjl  s)
244142140Snjl    STRICT=yes
245142140Snjl    ;;
246142140Snjl  c)
247142140Snjl    DIFF_FLAG='-c'
248143902Snjl    ;;
249142140Snjl  r)
250142140Snjl    RERUN=yes
251142140Snjl    ;;
252142140Snjl  v)
253142140Snjl    case "${AUTO_RUN}" in
254142140Snjl    '') VERBOSE=yes ;;
255142140Snjl    esac
256142140Snjl    ;;
257142140Snjl  a)
258142140Snjl    AUTO_RUN=yes
259142140Snjl    unset VERBOSE
260143902Snjl    ;;
261142140Snjl  h)
262142140Snjl    display_usage
263142140Snjl    display_help
264142140Snjl    exit 0
265142140Snjl    ;;
266142140Snjl  i)
267142140Snjl    AUTO_INSTALL=yes
268142140Snjl    ;;
269142140Snjl  C)
270142140Snjl    COMP_CONFS=yes
271142140Snjl    ;;
272143902Snjl  p)
273142140Snjl    PRE_WORLD=yes
274142140Snjl    unset COMP_CONFS
275142140Snjl    unset AUTO_RUN
276142140Snjl    ;;
277142140Snjl  m)
278142140Snjl    SOURCEDIR=${OPTARG}
279142140Snjl    ;;
280142140Snjl  t)
281142140Snjl    TEMPROOT=${OPTARG}
282142140Snjl    ;;
283142140Snjl  d)
284143902Snjl    TEMPROOT=${TEMPROOT}.`date +%m%d.%H.%M`
285142140Snjl    ;;
286142140Snjl  u)
287142140Snjl    NEW_UMASK=${OPTARG}
288142140Snjl    ;;
289142140Snjl  w)
290142140Snjl    SCREEN_WIDTH=${OPTARG}
291142140Snjl    ;;
292142140Snjl  D)
293142140Snjl    DESTDIR=${OPTARG}
294142140Snjl    ;;
295142140Snjl  *)
296143902Snjl    display_usage
297142140Snjl    exit 1
298142140Snjl    ;;
299142140Snjl  esac
300142140Snjldone
301142140Snjl
302142140Snjlecho ''
303142140Snjl
304142140Snjl# If the user has a pager defined, make sure we can run it
305142140Snjl#
306142140Snjlcase "${DONT_CHECK_PAGER}" in
307142140Snjl'')
308143902Snjl  while ! type "${PAGER%% *}" >/dev/null && [ -n "${PAGER}" ]; do
309142140Snjl    echo " *** Your PAGER environment variable specifies '${PAGER}', but"
310142140Snjl    echo "     due to the limited PATH that I use for security reasons,"
311142140Snjl    echo "     I cannot execute it.  So, what would you like to do?"
312142140Snjl    echo ''
313142140Snjl    echo "  Use 'e' to exit mergemaster and fix your PAGER variable"
314142140Snjl    if [ -x /usr/bin/less -o -x /usr/local/bin/less ]; then
315142140Snjl    echo "  Use 'l' to set PAGER to 'less' for this run"
316142140Snjl    fi
317142140Snjl    echo "  Use 'm' to use plain old 'more' as your PAGER for this run"
318142140Snjl    echo ''
319142140Snjl    echo "  Default is to use plain old 'more' "
320143902Snjl    echo ''
321142140Snjl    echo -n "What should I do? [Use 'more'] "
322142140Snjl    read FIXPAGER
323142140Snjl
324142140Snjl    case "${FIXPAGER}" in
325142140Snjl    [eE])
326142140Snjl       exit 0
327142140Snjl       ;;
328142140Snjl    [lL])
329142140Snjl       if [ -x /usr/bin/less ]; then
330142140Snjl         PAGER=/usr/bin/less
331143902Snjl       elif [ -x /usr/local/bin/less ]; then
332142140Snjl         PAGER=/usr/local/bin/less
333142140Snjl       else
334142140Snjl         echo ''
335142140Snjl         echo " *** Fatal Error:"
336142140Snjl         echo "     You asked to use 'less' as your pager, but I can't"
337142140Snjl         echo "     find it in /usr/bin or /usr/local/bin"
338142140Snjl         exit 1
339142140Snjl       fi
340142140Snjl       ;;
341142140Snjl    [mM]|'')
342143902Snjl       PAGER=more
343142140Snjl       ;;
344142140Snjl    *)
345142140Snjl       echo ''
346142140Snjl       echo "invalid choice: ${FIXPAGER}"
347142140Snjl    esac
348142140Snjl    echo ''
349142140Snjl  done
350142140Snjl  ;;
351142140Snjlesac
352142140Snjl
353143902Snjl# If user has a pager defined, or got assigned one above, use it.
354142140Snjl# If not, use more.
355142140Snjl#
356142140SnjlPAGER=${PAGER:-more}
357142140Snjl
358142140Snjlif [ -n "${VERBOSE}" -a ! "${PAGER}" = "more" ]; then
359142140Snjl  echo " *** You have ${PAGER} defined as your pager so we will use that"
360142140Snjl  echo ''
361142140Snjl  sleep 3
362142140Snjlfi
363142140Snjl
364143902Snjl# Assign the diff flag once so we will not have to keep testing it
365142140Snjl#
366142140SnjlDIFF_FLAG=${DIFF_FLAG:--u}
367142140Snjl
368142140Snjl# Assign the source directory
369142140Snjl#
370142140SnjlSOURCEDIR=${SOURCEDIR:-/usr/src/etc}
371142140Snjl
372142140Snjl# Check the width of the user's terminal
373142140Snjl#
374143902Snjlif [ -t 0 ]; then
375142140Snjl  w=$(stty -a | sed -ne 's/.* \([0-9][0-9]*\) columns.*/\1/p')
376142140Snjl  case "${w}" in
377142140Snjl  0|'') ;; # No-op, since the input is not valid
378142140Snjl  *)
379142140Snjl    case "${SCREEN_WIDTH}" in
380142140Snjl    '') SCREEN_WIDTH="${w}" ;;
381142140Snjl    "${w}") ;; # No-op, since they are the same
382142140Snjl    *)
383142140Snjl      echo -n "*** You entered ${SCREEN_WIDTH} as your screen width, but stty "
384143902Snjl      echo "thinks it is ${w}."
385142140Snjl      echo ''
386142140Snjl      echo -n "What would you like to use? [${w}] "
387142140Snjl      read SCREEN_WIDTH
388142140Snjl      case "${SCREEN_WIDTH}" in
389142140Snjl      '') SCREEN_WIDTH="${w}" ;;
390142140Snjl      esac
391142140Snjl      ;;
392142140Snjl    esac
393142140Snjl  esac
394143902Snjlfi
395142140Snjl
396142140Snjl# Define what CVS $Id tag to look for to aid portability.
397142140Snjl#
398142140SnjlCVS_ID_TAG=FreeBSD
399142140Snjl
400142140Snjlcase "${RERUN}" in
401142140Snjl'')
402142140Snjl  # Set up the loop to test for the existence of the
403142140Snjl  # temp root directory.
404143902Snjl  #
405142140Snjl  TEST_TEMP_ROOT=yes
406142140Snjl  while [ "${TEST_TEMP_ROOT}" = "yes" ]; do
407142140Snjl    if [ -d "${TEMPROOT}" ]; then
408142140Snjl      echo "*** The directory specified for the temporary root environment,"
409142140Snjl      echo "    ${TEMPROOT}, exists.  This can be a security risk if untrusted"
410142140Snjl      echo "    users have access to the system."
411142140Snjl      echo ''
412142140Snjl      case "${AUTO_RUN}" in
413142140Snjl      '')
414143902Snjl        echo "  Use 'd' to delete the old ${TEMPROOT} and continue"
415142140Snjl        echo "  Use 't' to select a new temporary root directory"
416142140Snjl        echo "  Use 'e' to exit mergemaster"
417142140Snjl        echo ''
418142140Snjl        echo "  Default is to use ${TEMPROOT} as is"
419142140Snjl        echo ''
420142140Snjl        echo -n "How should I deal with this? [Use the existing ${TEMPROOT}] "
421142140Snjl        read DELORNOT
422142140Snjl
423142140Snjl        case "${DELORNOT}" in
424143902Snjl        [dD])
425142140Snjl          echo ''
426142140Snjl          echo "   *** Deleting the old ${TEMPROOT}"
427142140Snjl          echo ''
428142140Snjl          rm -rf "${TEMPROOT}"
429142140Snjl          unset TEST_TEMP_ROOT
430142140Snjl          ;;
431142140Snjl        [tT])
432142140Snjl          echo "   *** Enter new directory name for temporary root environment"
433142140Snjl          read TEMPROOT
434143902Snjl          ;;
435142140Snjl        [eE])
436142140Snjl          exit 0
437142140Snjl          ;;
438142140Snjl        '')
439142140Snjl          echo ''
440142140Snjl          echo "   *** Leaving ${TEMPROOT} intact"
441142140Snjl          echo ''
442142140Snjl          unset TEST_TEMP_ROOT
443142140Snjl          ;;
444143902Snjl        *)
445142140Snjl          echo ''
446142140Snjl          echo "invalid choice: ${DELORNOT}"
447142140Snjl          echo ''
448142140Snjl          ;;
449142140Snjl        esac
450142140Snjl        ;;
451142140Snjl      *)
452142140Snjl        # If this is an auto-run, try a hopefully safe alternative then
453143902Snjl        # re-test anyway.
454142140Snjl        TEMPROOT=/var/tmp/temproot.`date +%m%d.%H.%M.%S`
455142140Snjl        ;;
456142140Snjl      esac
457142140Snjl    else
458142140Snjl      unset TEST_TEMP_ROOT
459142140Snjl    fi
460142140Snjl  done
461142140Snjl
462143902Snjl  echo "*** Creating the temporary root environment in ${TEMPROOT}"
463142140Snjl
464142140Snjl  if mkdir -p "${TEMPROOT}"; then
465142140Snjl    echo " *** ${TEMPROOT} ready for use"
466142140Snjl  fi
467142140Snjl
468142140Snjl  if [ ! -d "${TEMPROOT}" ]; then
469142140Snjl    echo ''
470142140Snjl    echo "  *** FATAL ERROR: Cannot create ${TEMPROOT}"
471143902Snjl    echo ''
472142140Snjl    exit 1
473142140Snjl  fi
474142140Snjl
475142140Snjl  echo " *** Creating and populating directory structure in ${TEMPROOT}"
476142140Snjl  echo ''
477142140Snjl
478142140Snjl  case "${VERBOSE}" in
479142140Snjl  '') ;;
480155996Scperciva  *)
481155996Scperciva    press_to_continue
482155996Scperciva    ;;
483155996Scperciva  esac
484155996Scperciva
485155996Scperciva  case "${PRE_WORLD}" in
486155996Scperciva  '')
487155996Scperciva    { cd ${SOURCEDIR} &&
488155996Scperciva      case "${DESTDIR}" in
489155996Scperciva      '') ;;
490155996Scperciva      *)
491155996Scperciva      make DESTDIR=${DESTDIR} distrib-dirs
492155996Scperciva        ;;
493155996Scperciva      esac
494155996Scperciva      make DESTDIR=${TEMPROOT} distrib-dirs &&
495155996Scperciva      make MAKEOBJDIRPREFIX=${TEMPROOT}/usr/obj obj &&
496155996Scperciva      make MAKEOBJDIRPREFIX=${TEMPROOT}/usr/obj DESTDIR=${TEMPROOT} \
497155996Scperciva          -DNO_MAKEDEV_RUN distribution;} ||
498155996Scperciva    { echo '';
499155996Scperciva     echo "  *** FATAL ERROR: Cannot 'cd' to ${SOURCEDIR} and install files to";
500155996Scperciva      echo "      the temproot environment";
501155996Scperciva      echo '';
502155996Scperciva      exit 1;}
503155996Scperciva    ;;
504155996Scperciva  *)
505155996Scperciva    # Only set up files that are crucial to {build|install}world
506155996Scperciva    { mkdir -p ${TEMPROOT}/etc &&
507143902Snjl      cp -p ${SOURCEDIR}/master.passwd ${TEMPROOT}/etc &&
508142140Snjl      cp -p ${SOURCEDIR}/group ${TEMPROOT}/etc;} ||
509142140Snjl    { echo '';
510142140Snjl      echo '  *** FATAL ERROR: Cannot copy files to the temproot environment';
511142140Snjl      echo '';
512142140Snjl      exit 1;}
513142140Snjl    ;;
514142140Snjl  esac
515142140Snjl
516142140Snjl  # Doing the inventory and removing files that we don't want to compare only
517142140Snjl  # makes sense if we are not doing a rerun, since we have no way of knowing
518142140Snjl  # what happened to the files during previous incarnations.
519155996Scperciva  case "${VERBOSE}" in
520155996Scperciva  '') ;;
521155996Scperciva  *)
522155996Scperciva    echo ''
523155996Scperciva    echo ' *** The following files exist only in the installed version of'
524155996Scperciva    echo "     ${DESTDIR}/etc.  In the vast majority of cases these files"
525155996Scperciva    echo '     are necessary parts of the system and should not be deleted.'
526155996Scperciva    echo '     However because these files are not updated by this process you'
527155996Scperciva    echo '     might want to verify their status before rebooting your system.'
528155996Scperciva    echo ''
529155996Scperciva    press_to_continue
530155996Scperciva    diff -qr ${DESTDIR}/etc ${TEMPROOT}/etc | grep "^Only in /etc" | ${PAGER}
531155996Scperciva    echo ''
532155996Scperciva    press_to_continue
533155996Scperciva    ;;
534155996Scperciva  esac
535155996Scperciva
536155996Scperciva  # Avoid comparing the motd if the user specifies it in .mergemasterrc
537155996Scperciva  case "${IGNORE_MOTD}" in
538155996Scperciva  '') ;;
539155996Scperciva  *) rm -f ${TEMPROOT}/etc/motd
540155996Scperciva     ;;
541155996Scperciva  esac
542155996Scperciva
543155996Scperciva  # Avoid trying to update MAKEDEV if /dev is on a devfs
544155996Scperciva  if /sbin/sysctl vfs.devfs.generation > /dev/null 2>&1 ; then
545155996Scperciva    rm -f ${TEMPROOT}/dev/MAKEDEV ${TEMPROOT}/dev/MAKEDEV.local
546155996Scperciva  fi
547155996Scperciva
548155996Scperciva  ;; # End of the "RERUN" test
549155996Scpercivaesac
550155996Scperciva
551155996Scperciva# We really don't want to have to deal with these files, since
552155996Scperciva# master.passwd is the real file that should be compared, then
553155996Scperciva# the user should run pwd_mkdb if necessary.
554155996Scperciva#
555155996Scpercivarm -f ${TEMPROOT}/etc/spwd.db ${TEMPROOT}/etc/passwd ${TEMPROOT}/etc/pwd.db
556155996Scperciva
557155996Scperciva# We only need to compare things like freebsd.cf once
558155996Scpercivafind ${TEMPROOT}/usr/obj -type f -delete 2>/dev/null
559155996Scperciva
560155996Scperciva# Get ready to start comparing files
561155996Scperciva
562155996Scperciva# Check umask if not specified on the command line,
563155996Scperciva# and we are not doing an autorun
564155996Scperciva#
565155996Scpercivaif [ -z "${NEW_UMASK}" -a -z "${AUTO_RUN}" ]; then
566155996Scperciva  USER_UMASK=`umask`
567155996Scperciva  case "${USER_UMASK}" in
568155996Scperciva  0022|022) ;;
569155996Scperciva  *)
570155996Scperciva    echo ''
571155996Scperciva    echo " *** Your umask is currently set to ${USER_UMASK}.  By default, this script"
572155996Scperciva    echo "     installs all files with the same user, group and modes that"
573155996Scperciva    echo "     they are created with by ${SOURCEDIR}/Makefile, compared to"
574155996Scperciva    echo "     a umask of 022.  This umask allows world read permission when"
575155996Scperciva    echo "     the file's default permissions have it."
576155996Scperciva    echo ''
577155996Scperciva    echo "     No world permissions can sometimes cause problems.  A umask of"
578155996Scperciva    echo "     022 will restore the default behavior, but is not mandatory."
579155996Scperciva    echo "     /etc/master.passwd is a special case.  Its file permissions"
580155996Scperciva    echo "     will be 600 (rw-------) if installed."
581155996Scperciva    echo ''
582155996Scperciva    echo -n "What umask should I use? [${USER_UMASK}] "
583155996Scperciva    read NEW_UMASK
584155996Scperciva
585155996Scperciva    NEW_UMASK="${NEW_UMASK:-$USER_UMASK}"
586155996Scperciva    ;;
587155996Scperciva  esac
588155996Scperciva  echo ''
589155996Scpercivafi
590155996Scperciva
591155996ScpercivaCONFIRMED_UMASK=${NEW_UMASK:-0022}
592155996Scperciva
593155996Scperciva# Warn users who still have ${DESTDIR}/etc/sysconfig
594155996Scperciva#
595155996Scpercivaif [ -e "${DESTDIR}/etc/sysconfig" ]; then
596155996Scperciva  echo ''
597155996Scperciva  echo " *** There is a sysconfig file on this system in ${DESTDIR}/etc/."
598155996Scperciva  echo ''
599155996Scperciva  echo '     Starting with FreeBSD version 2.2.2 those settings moved from'
600155996Scperciva  echo '     /etc/sysconfig to /etc/rc.conf.  If you are upgrading an older'
601155996Scperciva  echo '     system make sure that you transfer your settings by hand from'
602155996Scperciva  echo '     sysconfig to rc.conf and install the rc.conf file.  If you'
603155996Scperciva  echo '     have already made this transition, you should consider'
604155996Scperciva  echo '     renaming or deleting the sysconfig file.'
605155996Scperciva  echo ''
606155996Scperciva  case "${AUTO_RUN}" in
607155996Scperciva  '')
608155996Scperciva    echo -n "Continue with the merge process? [yes] "
609155996Scperciva    read CONT_OR_NOT
610155996Scperciva
611155996Scperciva    case "${CONT_OR_NOT}" in
612155996Scperciva    [nN]*)
613155996Scperciva      exit 0
614155996Scperciva      ;;
615155996Scperciva    *)
616155996Scperciva      echo "   *** Continuing"
617155996Scperciva      echo ''
618155996Scperciva      ;;
619155996Scperciva    esac
620155996Scperciva    ;;
621155996Scperciva  *) ;;
622155996Scperciva  esac
623155996Scpercivafi
624155996Scperciva
625155996Scperciva# Use the umask/mode information to install the files
626155996Scperciva# Create directories as needed
627155996Scperciva#
628155996Scpercivado_install_and_rm () {
629155996Scperciva  install -m "${1}" "${2}" "${3}" &&
630155996Scperciva  rm -f "${2}"
631155996Scperciva}
632155996Scperciva
633155996Scperciva# 4095 = "obase=10;ibase=8;07777" | bc
634155996Scpercivafind_mode () {
635155996Scperciva  local OCTAL
636155996Scperciva  OCTAL=$(( ~$(echo "obase=10; ibase=8; ${CONFIRMED_UMASK}" | bc) & 4095 &
637155996Scperciva    $(echo "obase=10; ibase=8; $(stat -f "%OMp%OLp" ${1})" | bc) )) 
638155996Scperciva  printf "%04o\n" ${OCTAL}
639155996Scperciva}
640155996Scperciva
641155996Scpercivamm_install () {
642155996Scperciva  local INSTALL_DIR
643155996Scperciva  INSTALL_DIR=${1#.}
644155996Scperciva  INSTALL_DIR=${INSTALL_DIR%/*}
645155996Scperciva
646155996Scperciva  case "${INSTALL_DIR}" in
647155996Scperciva  '')
648155996Scperciva    INSTALL_DIR=/
649155996Scperciva    ;;
650155996Scperciva  esac
651155996Scperciva
652155996Scperciva  if [ -n "${DESTDIR}${INSTALL_DIR}" -a ! -d "${DESTDIR}${INSTALL_DIR}" ]; then
653155996Scperciva    DIR_MODE=`find_mode "${TEMPROOT}/${INSTALL_DIR}"`
654155996Scperciva    install -d -o root -g wheel -m "${DIR_MODE}" "${DESTDIR}${INSTALL_DIR}"
655155996Scperciva  fi
656155996Scperciva
657155996Scperciva  FILE_MODE=`find_mode "${1}"`
658155996Scperciva
659155996Scperciva  if [ ! -x "${1}" ]; then
660155996Scperciva    case "${1#.}" in
661155996Scperciva    /etc/mail/aliases)
662155996Scperciva      NEED_NEWALIASES=yes
663155996Scperciva      ;;
664155996Scperciva    /etc/login.conf)
665155996Scperciva      NEED_CAP_MKDB=yes
666155996Scperciva      ;;
667155996Scperciva    /etc/master.passwd)
668155996Scperciva      do_install_and_rm 600 "${1}" "${DESTDIR}${INSTALL_DIR}"
669155996Scperciva      NEED_PWD_MKDB=yes
670155996Scperciva      DONT_INSTALL=yes
671155996Scperciva      ;;
672155996Scperciva    /.cshrc | /.profile)
673155996Scperciva    case "${AUTO_INSTALL}" in
674155996Scperciva    '')
675155996Scperciva      case "${LINK_EXPLAINED}" in
676155996Scperciva      '')
677155996Scperciva        echo "   *** Historically BSD derived systems have had a"
678155996Scperciva        echo "       hard link from /.cshrc and /.profile to"
679155996Scperciva        echo "       their namesakes in /root.  Please indicate"
680155996Scperciva        echo "       your preference below for bringing your"
681155996Scperciva        echo "       installed files up to date."
682143902Snjl        echo ''
683142140Snjl        LINK_EXPLAINED=yes
684142140Snjl        ;;
685142140Snjl      esac
686142140Snjl
687142140Snjl      echo "   Use 'd' to delete the temporary ${COMPFILE}"
688142140Snjl      echo "   Use 'l' to delete the existing ${DESTDIR}${COMPFILE#.} and create the link"
689142140Snjl      echo ''
690142140Snjl      echo "   Default is to leave the temporary file to deal with by hand"
691143902Snjl      echo ''
692142140Snjl      echo -n "  How should I handle ${COMPFILE}? [Leave it to install later] "
693142140Snjl      read HANDLE_LINK
694142140Snjl      ;;
695142140Snjl    *)  # Part of AUTO_INSTALL
696142140Snjl      HANDLE_LINK=l
697142140Snjl      ;;
698142140Snjl    esac
699142140Snjl
700158446Snjl      case "${HANDLE_LINK}" in
701158446Snjl      [dD]*)
702158446Snjl        rm "${COMPFILE}"
703158446Snjl        echo ''
704158446Snjl        echo "   *** Deleting ${COMPFILE}"
705158446Snjl        ;;
706158446Snjl      [lL]*)
707158446Snjl        echo ''
708158446Snjl        rm -f "${DESTDIR}${COMPFILE#.}"
709158446Snjl        if ln "${DESTDIR}/root/${COMPFILE##*/}" "${DESTDIR}${COMPFILE#.}"; then
710158446Snjl          echo "   *** Link from ${DESTDIR}${COMPFILE#.} to ${DESTDIR}/root/${COMPFILE##*/} installed successfully"
711158446Snjl          rm "${COMPFILE}"
712158446Snjl        else
713158446Snjl          echo "   *** Error linking ${DESTDIR}${COMPFILE#.} to ${DESTDIR}/root/${COMPFILE##*/}, ${COMPFILE} will remain to install by hand"
714158446Snjl        fi
715158446Snjl        ;;
716158446Snjl      *)
717158446Snjl        echo "   *** ${COMPFILE} will remain for your consideration"
718158446Snjl        ;;
719158446Snjl      esac
720158446Snjl      DONT_INSTALL=yes
721158446Snjl      ;;
722158446Snjl    esac
723158446Snjl
724158446Snjl    case "${DONT_INSTALL}" in
725158446Snjl    '')
726158446Snjl      do_install_and_rm "${FILE_MODE}" "${1}" "${DESTDIR}${INSTALL_DIR}"
727158446Snjl      ;;
728158446Snjl    *)
729158446Snjl      unset DONT_INSTALL
730158446Snjl      ;;
731158446Snjl    esac
732158446Snjl  else	# File matched -x
733158446Snjl    case "${1#.}" in
734158446Snjl    /dev/MAKEDEV)
735158446Snjl      NEED_MAKEDEV=yes
736158446Snjl      ;;
737158446Snjl    esac
738158446Snjl    do_install_and_rm "${FILE_MODE}" "${1}" "${DESTDIR}${INSTALL_DIR}"
739158446Snjl  fi
740158446Snjl  return $?
741158446Snjl}
742158446Snjl
743158446Snjlecho ''
744158446Snjlecho "*** Beginning comparison"
745158446Snjlecho ''
746158446Snjl
747158446Snjlcd "${TEMPROOT}"
748158446Snjl
749158446Snjlif [ -r "${MM_PRE_COMPARE_SCRIPT}" ]; then
750158446Snjl  . "${MM_PRE_COMPARE_SCRIPT}"
751158446Snjlfi
752158446Snjl
753158446Snjl# Using -size +0 avoids uselessly checking the empty log files created
754158446Snjl# by ${SOURCEDIR}/Makefile and the device entries in ./dev, but does
755158446Snjl# check the scripts in ./dev, as we'd like (assuming no devfs of course).
756158446Snjl#
757158446Snjlfor COMPFILE in `find . -type f -size +0`; do
758158446Snjl
759158446Snjl  # First, check to see if the file exists in DESTDIR.  If not, the
760158446Snjl  # diff_loop function knows how to handle it.
761158446Snjl  #
762158446Snjl  if [ ! -e "${DESTDIR}${COMPFILE#.}" ]; then
763158446Snjl    case "${AUTO_RUN}" in
764158446Snjl      '')
765158446Snjl        diff_loop
766158446Snjl        ;;
767158446Snjl      *)
768158446Snjl        case "${AUTO_INSTALL}" in
769158446Snjl        '')
770158446Snjl          # If this is an auto run, make it official
771158446Snjl          echo "   *** ${COMPFILE} will remain for your consideration"
772158446Snjl          ;;
773158446Snjl        *)
774158446Snjl          diff_loop
775158446Snjl          ;;
776158446Snjl        esac
777158446Snjl        ;;
778158446Snjl    esac # Auto run test
779158446Snjl    continue
780158446Snjl  fi
781158446Snjl
782158446Snjl  case "${STRICT}" in
783158446Snjl  '' | [Nn][Oo])
784158446Snjl    # Compare CVS $Id's first so if the file hasn't been modified
785158446Snjl    # local changes will be ignored.
786158446Snjl    # If the files have the same $Id, delete the one in temproot so the
787158446Snjl    # user will have less to wade through if files are left to merge by hand.
788158446Snjl    #
789158446Snjl    CVSID1=`grep "[$]${CVS_ID_TAG}:" ${DESTDIR}${COMPFILE#.} 2>/dev/null`
790158446Snjl    CVSID2=`grep "[$]${CVS_ID_TAG}:" ${COMPFILE} 2>/dev/null` || CVSID2=none
791158446Snjl
792158446Snjl    case "${CVSID2}" in
793158446Snjl    "${CVSID1}")
794158446Snjl      echo " *** Temp ${COMPFILE} and installed have the same CVS Id, deleting"
795158446Snjl      rm "${COMPFILE}"
796158446Snjl      ;;
797158446Snjl    esac
798158446Snjl    ;;
799158446Snjl  esac
800158446Snjl
801158446Snjl  # If the file is still here either because the $Ids are different, the
802158446Snjl  # file doesn't have an $Id, or we're using STRICT mode; look at the diff.
803158446Snjl  #
804158446Snjl  if [ -f "${COMPFILE}" ]; then
805158446Snjl
806158446Snjl    # Do an absolute diff first to see if the files are actually different.
807158446Snjl    # If they're not different, delete the one in temproot.
808158446Snjl    #
809158446Snjl    if diff -q "${DESTDIR}${COMPFILE#.}" "${COMPFILE}" > /dev/null 2>&1; then
810158446Snjl      echo " *** Temp ${COMPFILE} and installed are the same, deleting"
811158446Snjl      rm "${COMPFILE}"
812158446Snjl    else
813158446Snjl      # Ok, the files are different, so show the user where they differ.
814158446Snjl      # Use user's choice of diff methods; and user's pager if they have one.
815158446Snjl      # Use more if not.
816158446Snjl      # Use unified diffs by default.  Context diffs give me a headache. :)
817158446Snjl      #
818158446Snjl      case "${AUTO_RUN}" in
819158446Snjl      '')
820158446Snjl        # prompt user to install/delete/merge changes
821158446Snjl        diff_loop
822158446Snjl        ;;
823158446Snjl      *)
824158446Snjl        # If this is an auto run, make it official
825158446Snjl        echo "   *** ${COMPFILE} will remain for your consideration"
826158446Snjl        ;;
827143902Snjl      esac # Auto run test
828142140Snjl    fi # Yes, the files are different
829142140Snjl  fi # Yes, the file still remains to be checked
830142140Snjldone # This is for the do way up there at the beginning of the comparison
831142140Snjl
832142140Snjlecho ''
833142140Snjlecho "*** Comparison complete"
834142140Snjlecho ''
835142140Snjl
836142140SnjlTEST_FOR_FILES=`find ${TEMPROOT} -type f -size +0 2>/dev/null`
837142140Snjlif [ -n "${TEST_FOR_FILES}" ]; then
838142140Snjl  echo "*** Files that remain for you to merge by hand:"
839142140Snjl  find "${TEMPROOT}" -type f -size +0
840142140Snjl  echo ''
841142140Snjlfi
842142140Snjl
843142140Snjlcase "${AUTO_RUN}" in
844142140Snjl'')
845142140Snjl  echo -n "Do you wish to delete what is left of ${TEMPROOT}? [no] "
846142140Snjl  read DEL_TEMPROOT
847142140Snjl
848142140Snjl  case "${DEL_TEMPROOT}" in
849142140Snjl  [yY]*)
850142140Snjl    if rm -rf "${TEMPROOT}"; then
851142140Snjl      echo " *** ${TEMPROOT} has been deleted"
852142140Snjl    else
853142140Snjl      echo " *** Unable to delete ${TEMPROOT}"
854142140Snjl    fi
855142140Snjl    ;;
856142140Snjl  *)
857142140Snjl    echo " *** ${TEMPROOT} will remain"
858142140Snjl    ;;
859142140Snjl  esac
860142140Snjl  ;;
861142140Snjl*) ;;
862155996Scpercivaesac
863155996Scperciva
864142140Snjlcase "${AUTO_INSTALLED_FILES}" in
865155996Scperciva'') ;;
866155996Scperciva*)
867155996Scperciva  case "${AUTO_RUN}" in
868155996Scperciva  '')
869155996Scperciva    (
870155996Scperciva      echo ''
871155996Scperciva      echo '*** You chose the automatic install option for files that did not'
872155996Scperciva      echo '    exist on your system.  The following were installed for you:'
873155996Scperciva      echo "${AUTO_INSTALLED_FILES}"
874155996Scperciva    ) | ${PAGER}
875155996Scperciva    ;;
876155996Scperciva  *)
877155996Scperciva    echo ''
878155996Scperciva    echo '*** You chose the automatic install option for files that did not'
879155996Scperciva    echo '    exist on your system.  The following were installed for you:'
880155996Scperciva    echo "${AUTO_INSTALLED_FILES}"
881155996Scperciva    ;;
882155996Scperciva  esac
883142140Snjl  ;;
884142140Snjlesac
885158446Snjl
886158446Snjlrun_it_now () {
887158446Snjl  case "${AUTO_RUN}" in
888158446Snjl  '')
889158446Snjl    unset YES_OR_NO
890158446Snjl    echo ''
891158446Snjl    echo -n '    Would you like to run it now? y or n [n] '
892158446Snjl    read YES_OR_NO
893158446Snjl
894158446Snjl    case "${YES_OR_NO}" in
895158446Snjl    y)
896158446Snjl      echo "    Running ${1}"
897158446Snjl      echo ''
898185341Sjkim      eval "${1}"
899142140Snjl      ;;
900142140Snjl    ''|n)
901142140Snjl      echo ''
902144630Snjl      echo "       *** Cancelled"
903142140Snjl      echo ''
904142140Snjl      echo "    Make sure to run ${1} yourself"
905142140Snjl      ;;
906143902Snjl    *)
907143902Snjl      echo ''
908158446Snjl      echo "       *** Sorry, I do not understand your answer (${YES_OR_NO})"
909182048Sjhb      echo ''
910143902Snjl      echo "    Make sure to run ${1} yourself"
911142140Snjl    esac
912142140Snjl    ;;
913142140Snjl  *) ;;
914142140Snjl  esac
915176649Srpaulo}
916176649Srpaulo
917142140Snjlcase "${NEED_MAKEDEV}" in
918142140Snjl'') ;;
919142140Snjl*)
920142140Snjl  echo ''
921142140Snjl  echo "*** You installed a new ${DESTDIR}/dev/MAKEDEV script, so make sure that you run"
922142140Snjl  echo "    'cd ${DESTDIR}/dev && /bin/sh MAKEDEV all' to rebuild your devices"
923142140Snjl  run_it_now "cd ${DESTDIR}/dev && /bin/sh MAKEDEV all"
924142140Snjl  ;;
925142140Snjlesac
926142140Snjl
927142140Snjlcase "${NEED_NEWALIASES}" in
928142140Snjl'') ;;
929142140Snjl*)
930144630Snjl  echo ''
931144630Snjl  if [ -n "${DESTDIR}" ]; then
932144630Snjl    echo "*** You installed a new aliases file into ${DESTDIR}/etc/mail, but"
933144630Snjl    echo "    the newaliases command is limited to the directories configured"
934142140Snjl    echo "    in sendmail.cf.  Make sure to create your aliases database by"
935142140Snjl    echo "    hand when your sendmail configuration is done."
936142140Snjl  else
937142140Snjl    echo "*** You installed a new aliases file, so make sure that you run"
938142140Snjl    echo "    '/usr/bin/newaliases' to rebuild your aliases database"
939142140Snjl    run_it_now '/usr/bin/newaliases'
940142140Snjl  fi
941142140Snjl  ;;
942142140Snjlesac
943142140Snjl
944142140Snjlcase "${NEED_CAP_MKDB}" in
945142140Snjl'') ;;
946144630Snjl*)
947144630Snjl  echo ''
948144630Snjl  echo "*** You installed a login.conf file, so make sure that you run"
949144630Snjl  echo "    '/usr/bin/cap_mkdb ${DESTDIR}/etc/login.conf'"
950219046Sjkim  echo "     to rebuild your login.conf database"
951219046Sjkim  run_it_now "/usr/bin/cap_mkdb ${DESTDIR}/etc/login.conf"
952219046Sjkim  ;;
953219046Sjkimesac
954219046Sjkim
955144630Snjlcase "${NEED_PWD_MKDB}" in
956144630Snjl'') ;;
957144630Snjl*)
958142140Snjl  echo ''
959142140Snjl  echo "*** You installed a new master.passwd file, so make sure that you run"
960142140Snjl  if [ -n "${DESTDIR}" ]; then
961144630Snjl    echo "    '/usr/sbin/pwd_mkdb -d ${DESTDIR}/etc -p ${DESTDIR}/etc/master.passwd'"
962142140Snjl    echo "    to rebuild your password files"
963142140Snjl    run_it_now "/usr/sbin/pwd_mkdb -d ${DESTDIR}/etc -p ${DESTDIR}/etc/master.passwd"
964142140Snjl  else
965142140Snjl    echo "    '/usr/sbin/pwd_mkdb -p /etc/master.passwd'"
966142140Snjl    echo "     to rebuild your password files"
967142140Snjl    run_it_now '/usr/sbin/pwd_mkdb -p /etc/master.passwd'
968185341Sjkim  fi
969185341Sjkim  ;;
970142140Snjlesac
971142140Snjl
972158446Snjlecho ''
973177040Sjhb
974158446Snjlif [ -r "${MM_EXIT_SCRIPT}" ]; then
975177040Sjhb  . "${MM_EXIT_SCRIPT}"
976142140Snjlfi
977142140Snjl
978142625Snjlcase "${COMP_CONFS}" in
979142625Snjl'') ;;
980142625Snjl*)
981142625Snjl  . ${DESTDIR}/etc/defaults/rc.conf
982181691Sjhb
983144630Snjl  (echo ''
984142140Snjl  echo "*** Comparing conf files: ${rc_conf_files}"
985142140Snjl
986142140Snjl  for CONF_FILE in ${rc_conf_files}; do
987142140Snjl    if [ -r "${DESTDIR}${CONF_FILE}" ]; then
988142140Snjl      echo ''
989142140Snjl      echo "*** From ${DESTDIR}${CONF_FILE}"
990142140Snjl      echo "*** From ${DESTDIR}/etc/defaults/rc.conf"
991142140Snjl
992142140Snjl      for RC_CONF_VAR in `grep -i ^[a-z] ${DESTDIR}${CONF_FILE} |
993212721Smav        cut -d '=' -f 1`; do
994241885Seadler        echo ''
995241885Seadler        grep -w ^${RC_CONF_VAR} ${DESTDIR}${CONF_FILE}
996241885Seadler        grep -w ^${RC_CONF_VAR} ${DESTDIR}/etc/defaults/rc.conf ||
997142140Snjl          echo ' * No default variable with this name'
998142140Snjl      done
999142140Snjl    fi
1000142140Snjl  done) | ${PAGER}
1001142140Snjl  echo ''
1002142140Snjl  ;;
1003142140Snjlesac
1004142140Snjl
1005142140Snjlcase "${PRE_WORLD}" in
1006142140Snjl'') ;;
1007142140Snjl*)
1008142140Snjl  MAKE_CONF="${SOURCEDIR%etc}share/examples/etc/make.conf"
1009142140Snjl
1010142140Snjl  (echo ''
1011142140Snjl  echo '*** Comparing make variables'
1012143902Snjl  echo ''
1013143902Snjl  echo "*** From ${DESTDIR}/etc/make.conf"
1014142140Snjl  echo "*** From ${MAKE_CONF}"
1015142140Snjl
1016142140Snjl  for MAKE_VAR in `grep -i ^[a-z] /etc/make.conf | cut -d '=' -f 1`; do
1017142140Snjl    echo ''
1018142140Snjl    grep -w ^${MAKE_VAR} ${DESTDIR}/etc/make.conf
1019142140Snjl    grep -w ^#${MAKE_VAR} ${MAKE_CONF} ||
1020142140Snjl      echo ' * No example variable with this name'
1021142140Snjl  done) | ${PAGER}
1022142140Snjl  ;;
1023142140Snjlesac
1024142140Snjl
1025142140Snjlexit 0
1026142140Snjl
1027142140Snjl