mergemaster.sh revision 174841
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 8124053Sdougb# Copyright 1998-2004 Douglas Barton 973651Sdougb# DougB@FreeBSD.org 1052400Sbillf 1152495Sbillf# $FreeBSD: head/usr.sbin/mergemaster/mergemaster.sh 174841 2007-12-21 19:34:26Z 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" 36155309Srwatson echo " -A architecture Alternative architecture name to pass to make" 3767949Sdougb echo ' -D /path/directory Specify the destination directory to install files to' 38158149Sgordon echo " -U Attempt to auto upgrade files that have not been user modified." 3952400Sbillf echo '' 4052400Sbillf} 4152400Sbillf 4252400Sbillfdisplay_help () { 4352400Sbillf echo "* To specify a directory other than /var/tmp/temproot for the" 4452400Sbillf echo " temporary root environment, use -t /path/to/temp/root" 4552400Sbillf echo "* The -w option takes a number as an argument for the column width" 4667859Sdougb echo " of the screen. The default is 80." 4767949Sdougb echo '* The -a option causes mergemaster to run without prompting.' 4852400Sbillf} 4952400Sbillf 5058910Salfred# Loop allowing the user to use sdiff to merge files and display the merged 5158910Salfred# file. 5258910Salfredmerge_loop () { 5367850Sdougb case "${VERBOSE}" in 5467850Sdougb '') ;; 5567850Sdougb *) 5667850Sdougb echo " *** Type h at the sdiff prompt (%) to get usage help" 5767850Sdougb ;; 5867850Sdougb esac 5967850Sdougb echo '' 6067850Sdougb MERGE_AGAIN=yes 6167850Sdougb while [ "${MERGE_AGAIN}" = "yes" ]; do 6267850Sdougb # Prime file.merged so we don't blat the owner/group id's 6367850Sdougb cp -p "${COMPFILE}" "${COMPFILE}.merged" 6467850Sdougb sdiff -o "${COMPFILE}.merged" --text --suppress-common-lines \ 6567949Sdougb --width=${SCREEN_WIDTH:-80} "${DESTDIR}${COMPFILE#.}" "${COMPFILE}" 6667850Sdougb INSTALL_MERGED=V 6767850Sdougb while [ "${INSTALL_MERGED}" = "v" -o "${INSTALL_MERGED}" = "V" ]; do 6867850Sdougb echo '' 6967850Sdougb echo " Use 'i' to install merged file" 7067850Sdougb echo " Use 'r' to re-do the merge" 7167850Sdougb echo " Use 'v' to view the merged file" 7267850Sdougb echo " Default is to leave the temporary file to deal with by hand" 7367850Sdougb echo '' 7467859Sdougb echo -n " *** How should I deal with the merged file? [Leave it for later] " 7567859Sdougb read INSTALL_MERGED 7658910Salfred 7767850Sdougb case "${INSTALL_MERGED}" in 7867850Sdougb [iI]) 7967850Sdougb mv "${COMPFILE}.merged" "${COMPFILE}" 8067850Sdougb echo '' 8167850Sdougb if mm_install "${COMPFILE}"; then 8267850Sdougb echo " *** Merged version of ${COMPFILE} installed successfully" 8367859Sdougb else 8467850Sdougb echo " *** Problem installing ${COMPFILE}, it will remain to merge by hand later" 8567859Sdougb fi 8667850Sdougb unset MERGE_AGAIN 8767850Sdougb ;; 8867850Sdougb [rR]) 8967850Sdougb rm "${COMPFILE}.merged" 9067859Sdougb ;; 9167850Sdougb [vV]) 9267850Sdougb ${PAGER} "${COMPFILE}.merged" 9367850Sdougb ;; 9467850Sdougb '') 9567850Sdougb echo " *** ${COMPFILE} will remain for your consideration" 9667850Sdougb unset MERGE_AGAIN 9767850Sdougb ;; 9867850Sdougb *) 9967850Sdougb echo "invalid choice: ${INSTALL_MERGED}" 10067850Sdougb INSTALL_MERGED=V 10167850Sdougb ;; 10267850Sdougb esac 10367850Sdougb done 10467850Sdougb done 10558910Salfred} 10658910Salfred 10758910Salfred# Loop showing user differences between files, allow merge, skip or install 10858910Salfred# options 10958910Salfreddiff_loop () { 11058910Salfred 11167850Sdougb HANDLE_COMPFILE=v 11258910Salfred 11377323Sdougb while [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "V" -o \ 11477323Sdougb "${HANDLE_COMPFILE}" = "NOT V" ]; do 11567949Sdougb if [ -f "${DESTDIR}${COMPFILE#.}" -a -f "${COMPFILE}" ]; then 116158149Sgordon if [ -n "${AUTO_UPGRADE}" ]; then 117158149Sgordon if echo "${CHANGED}" | grep -qsv ${DESTDIR}${COMPFILE#.}; then 118158149Sgordon echo '' 119158149Sgordon echo " *** ${COMPFILE} has not been user modified." 120158149Sgordon echo '' 121158149Sgordon 122158149Sgordon if mm_install "${COMPFILE}"; then 123158149Sgordon echo " *** ${COMPFILE} upgraded successfully" 124158149Sgordon echo '' 125158149Sgordon # Make the list print one file per line 126158149Sgordon AUTO_UPGRADED_FILES="${AUTO_UPGRADED_FILES} ${DESTDIR}${COMPFILE#.} 127158149Sgordon" 128158149Sgordon else 129158149Sgordon echo " *** Problem upgrading ${COMPFILE}, it will remain to merge by hand" 130158149Sgordon fi 131158149Sgordon return 132158149Sgordon fi 133158149Sgordon fi 13467850Sdougb if [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "V" ]; then 13590564Sdougb echo '' 136109993Sdillon echo ' ====================================================================== ' 137109993Sdillon echo '' 138109993Sdillon ( 139109993Sdillon echo " *** Displaying differences between ${COMPFILE} and installed version:" 140109993Sdillon echo '' 141110377Sdougb diff ${DIFF_FLAG} ${DIFF_OPTIONS} "${DESTDIR}${COMPFILE#.}" "${COMPFILE}" 142109993Sdillon ) | ${PAGER} 143109993Sdillon echo '' 14467850Sdougb fi 14567850Sdougb else 146109993Sdillon echo '' 14767850Sdougb echo " *** There is no installed version of ${COMPFILE}" 14891193Sdougb echo '' 14967949Sdougb case "${AUTO_INSTALL}" in 15067949Sdougb [Yy][Ee][Ss]) 15167949Sdougb echo '' 15267949Sdougb if mm_install "${COMPFILE}"; then 15367949Sdougb echo " *** ${COMPFILE} installed successfully" 15468507Sdougb echo '' 15567949Sdougb # Make the list print one file per line 15667949Sdougb AUTO_INSTALLED_FILES="${AUTO_INSTALLED_FILES} ${DESTDIR}${COMPFILE#.} 15767949Sdougb" 15867949Sdougb else 15967949Sdougb echo " *** Problem installing ${COMPFILE}, it will remain to merge by hand" 16067949Sdougb fi 16167949Sdougb return 16267949Sdougb ;; 16367949Sdougb *) 16467949Sdougb NO_INSTALLED=yes 16567949Sdougb ;; 16667949Sdougb esac 16767850Sdougb fi 16867859Sdougb 16967850Sdougb echo " Use 'd' to delete the temporary ${COMPFILE}" 17067850Sdougb echo " Use 'i' to install the temporary ${COMPFILE}" 17167850Sdougb case "${NO_INSTALLED}" in 17267850Sdougb '') 17377326Sdougb echo " Use 'm' to merge the temporary and installed versions" 174109993Sdillon echo " Use 'v' to view the diff results again" 17567850Sdougb ;; 17667850Sdougb esac 17767850Sdougb echo '' 17867850Sdougb echo " Default is to leave the temporary file to deal with by hand" 17967850Sdougb echo '' 18067859Sdougb echo -n "How should I deal with this? [Leave it for later] " 18167859Sdougb read HANDLE_COMPFILE 18267859Sdougb 18367850Sdougb case "${HANDLE_COMPFILE}" in 18467850Sdougb [dD]) 18567850Sdougb rm "${COMPFILE}" 18667850Sdougb echo '' 18767850Sdougb echo " *** Deleting ${COMPFILE}" 18867850Sdougb ;; 18967850Sdougb [iI]) 19067850Sdougb echo '' 19167850Sdougb if mm_install "${COMPFILE}"; then 19267850Sdougb echo " *** ${COMPFILE} installed successfully" 19367850Sdougb else 19467850Sdougb echo " *** Problem installing ${COMPFILE}, it will remain to merge by hand" 19567850Sdougb fi 19667850Sdougb ;; 19767850Sdougb [mM]) 19867850Sdougb case "${NO_INSTALLED}" in 19967850Sdougb '') 20067850Sdougb # interact with user to merge files 20167850Sdougb merge_loop 20267850Sdougb ;; 20367850Sdougb *) 20467850Sdougb echo '' 20567850Sdougb echo " *** There is no installed version of ${COMPFILE}" 20667850Sdougb echo '' 20767850Sdougb HANDLE_COMPFILE="NOT V" 20867850Sdougb ;; 20967850Sdougb esac # End of "No installed version of file but user selected merge" test 21067850Sdougb ;; 21167850Sdougb [vV]) 21267850Sdougb continue 21367850Sdougb ;; 21467850Sdougb '') 21567850Sdougb echo '' 21667850Sdougb echo " *** ${COMPFILE} will remain for your consideration" 21767850Sdougb ;; 21867850Sdougb *) 21967850Sdougb # invalid choice, show menu again. 22067850Sdougb echo "invalid choice: ${HANDLE_COMPFILE}" 22167850Sdougb echo '' 22267850Sdougb HANDLE_COMPFILE="NOT V" 22367850Sdougb continue 22467850Sdougb ;; 22567850Sdougb esac # End of "How to handle files that are different" 22667859Sdougb done 22767850Sdougb unset NO_INSTALLED 22867850Sdougb echo '' 22967850Sdougb case "${VERBOSE}" in 23067850Sdougb '') ;; 23167850Sdougb *) 23267850Sdougb sleep 3 23367850Sdougb ;; 23467850Sdougb esac 23558910Salfred} 23658910Salfred 23797960Sdougbpress_to_continue () { 23897960Sdougb local DISCARD 23997960Sdougb echo -n ' *** Press the [Enter] or [Return] key to continue ' 24097960Sdougb read DISCARD 24197960Sdougb} 24297960Sdougb 24352400Sbillf# Set the default path for the temporary root environment 24452400Sbillf# 24552400SbillfTEMPROOT='/var/tmp/temproot' 24652400Sbillf 247158149Sgordon# Assign the location of the mtree database 248158149Sgordon# 249158149SgordonMTREEDB='/var/db/mergemaster.mtree' 250158149Sgordon 25173651Sdougb# Read /etc/mergemaster.rc first so the one in $HOME can override 25273651Sdougb# 25373651Sdougbif [ -r /etc/mergemaster.rc ]; then 25473651Sdougb . /etc/mergemaster.rc 25573651Sdougbfi 25673651Sdougb 25752400Sbillf# Read .mergemasterrc before command line so CLI can override 25852400Sbillf# 25967949Sdougbif [ -r "$HOME/.mergemasterrc" ]; then 26052400Sbillf . "$HOME/.mergemasterrc" 26152400Sbillffi 26252400Sbillf 26352400Sbillf# Check the command line options 26452400Sbillf# 265158149Sgordonwhile getopts ":ascrvhipCPm:t:du:w:D:A:U" COMMAND_LINE_ARGUMENT ; do 26652400Sbillf case "${COMMAND_LINE_ARGUMENT}" in 267155309Srwatson A) 268155309Srwatson ARCHSTRING='MACHINE_ARCH='${OPTARG} 269155309Srwatson ;; 270158149Sgordon U) 271158149Sgordon AUTO_UPGRADE=yes 272158149Sgordon ;; 27352400Sbillf s) 27452400Sbillf STRICT=yes 275110377Sdougb unset DIFF_OPTIONS 27652400Sbillf ;; 27752400Sbillf c) 27852400Sbillf DIFF_FLAG='-c' 27952400Sbillf ;; 28052400Sbillf r) 28152400Sbillf RERUN=yes 28252400Sbillf ;; 28352400Sbillf v) 28452400Sbillf case "${AUTO_RUN}" in 28552400Sbillf '') VERBOSE=yes ;; 28652400Sbillf esac 28752400Sbillf ;; 28852400Sbillf a) 28952400Sbillf AUTO_RUN=yes 29052400Sbillf unset VERBOSE 29152400Sbillf ;; 29252400Sbillf h) 29352400Sbillf display_usage 29452400Sbillf display_help 29552400Sbillf exit 0 29652400Sbillf ;; 29767949Sdougb i) 29867949Sdougb AUTO_INSTALL=yes 29967949Sdougb ;; 30096045Sdougb C) 30196045Sdougb COMP_CONFS=yes 30296045Sdougb ;; 303114501Sdougb P) 304114501Sdougb PRESERVE_FILES=yes 305114501Sdougb ;; 30691193Sdougb p) 30791193Sdougb PRE_WORLD=yes 30896045Sdougb unset COMP_CONFS 30996045Sdougb unset AUTO_RUN 31091193Sdougb ;; 31152400Sbillf m) 31252400Sbillf SOURCEDIR=${OPTARG} 31352400Sbillf ;; 31452400Sbillf t) 31552400Sbillf TEMPROOT=${OPTARG} 31652400Sbillf ;; 31752400Sbillf d) 31852400Sbillf TEMPROOT=${TEMPROOT}.`date +%m%d.%H.%M` 31952400Sbillf ;; 32052400Sbillf u) 32152400Sbillf NEW_UMASK=${OPTARG} 32252400Sbillf ;; 32352400Sbillf w) 32452400Sbillf SCREEN_WIDTH=${OPTARG} 32552400Sbillf ;; 32667949Sdougb D) 32767949Sdougb DESTDIR=${OPTARG} 32867949Sdougb ;; 32952400Sbillf *) 33052400Sbillf display_usage 33152400Sbillf exit 1 33252400Sbillf ;; 33352400Sbillf esac 33452400Sbillfdone 33552400Sbillf 336114501Sdougb# Don't force the user to set this in the mergemaster rc file 337114501Sdougbif [ -n "${PRESERVE_FILES}" -a -z "${PRESERVE_FILES_DIR}" ]; then 338114501Sdougb PRESERVE_FILES_DIR=/var/tmp/mergemaster/preserved-files-`date +%y%m%d-%H%M%S` 339114501Sdougbfi 340114501Sdougb 341158149Sgordon# Check the for the mtree database in DESTDIR. 342158149Sgordonif [ ! -f ${DESTDIR}${MTREEDB} ]; then 343158149Sgordon echo "*** Unable to find mtree database. Skipping auto-upgrade." 344158149Sgordon unset AUTO_UPGRADE 345158149Sgordonfi 346158149Sgordon 34752400Sbillfecho '' 34852400Sbillf 34952400Sbillf# If the user has a pager defined, make sure we can run it 35052400Sbillf# 35152400Sbillfcase "${DONT_CHECK_PAGER}" in 35252400Sbillf'') 35364467Sbrian while ! type "${PAGER%% *}" >/dev/null && [ -n "${PAGER}" ]; do 35452400Sbillf echo " *** Your PAGER environment variable specifies '${PAGER}', but" 35564467Sbrian echo " due to the limited PATH that I use for security reasons," 35667859Sdougb echo " I cannot execute it. So, what would you like to do?" 35752400Sbillf echo '' 35852400Sbillf echo " Use 'e' to exit mergemaster and fix your PAGER variable" 35964467Sbrian if [ -x /usr/bin/less -o -x /usr/local/bin/less ]; then 36064467Sbrian echo " Use 'l' to set PAGER to 'less' for this run" 36152400Sbillf fi 36252400Sbillf echo " Use 'm' to use plain old 'more' as your PAGER for this run" 36352400Sbillf echo '' 36452400Sbillf echo " Default is to use plain old 'more' " 36552400Sbillf echo '' 36667859Sdougb echo -n "What should I do? [Use 'more'] " 36767859Sdougb read FIXPAGER 36867859Sdougb 36952400Sbillf case "${FIXPAGER}" in 37058910Salfred [eE]) 37152400Sbillf exit 0 37252400Sbillf ;; 37358910Salfred [lL]) 37464467Sbrian if [ -x /usr/bin/less ]; then 37564467Sbrian PAGER=/usr/bin/less 37664467Sbrian elif [ -x /usr/local/bin/less ]; then 37758910Salfred PAGER=/usr/local/bin/less 37864467Sbrian else 37964467Sbrian echo '' 38064467Sbrian echo " *** Fatal Error:" 38164467Sbrian echo " You asked to use 'less' as your pager, but I can't" 38264467Sbrian echo " find it in /usr/bin or /usr/local/bin" 38364467Sbrian exit 1 38458910Salfred fi 38552400Sbillf ;; 38660420Sbsd [mM]|'') 38752400Sbillf PAGER=more 38852400Sbillf ;; 38958910Salfred *) 39058910Salfred echo '' 39158910Salfred echo "invalid choice: ${FIXPAGER}" 39252400Sbillf esac 39352400Sbillf echo '' 39458910Salfred done 39552400Sbillf ;; 39652400Sbillfesac 39752400Sbillf 39852400Sbillf# If user has a pager defined, or got assigned one above, use it. 39952400Sbillf# If not, use more. 40052400Sbillf# 40152400SbillfPAGER=${PAGER:-more} 40252400Sbillf 40352400Sbillfif [ -n "${VERBOSE}" -a ! "${PAGER}" = "more" ]; then 40452400Sbillf echo " *** You have ${PAGER} defined as your pager so we will use that" 40552400Sbillf echo '' 40652400Sbillf sleep 3 40752400Sbillffi 40852400Sbillf 40952400Sbillf# Assign the diff flag once so we will not have to keep testing it 41052400Sbillf# 41152400SbillfDIFF_FLAG=${DIFF_FLAG:--u} 41252400Sbillf 41352400Sbillf# Assign the source directory 41452400Sbillf# 41552400SbillfSOURCEDIR=${SOURCEDIR:-/usr/src/etc} 41652400Sbillf 417158149Sgordon# Check DESTDIR against the mergemaster mtree database to see what 418158149Sgordon# files the user changed from the reference files. 419158149Sgordon# 420158149SgordonCHANGED= 421158149Sgordonif [ -n "${AUTO_UPGRADE}" -a -f "${DESTDIR}${MTREEDB}" ]; then 422158149Sgordon for file in `mtree -eq -f ${DESTDIR}${MTREEDB} -p ${DESTDIR}/ \ 423158149Sgordon 2>/dev/null | awk '($2 == "changed") {print $1}'`; do 424158149Sgordon if [ -f "${DESTDIR}/$file" ]; then 425158149Sgordon CHANGED="${CHANGED} ${DESTDIR}/$file" 426158149Sgordon fi 427158149Sgordon done 428158149Sgordonfi 429158149Sgordon 43096045Sdougb# Check the width of the user's terminal 43196045Sdougb# 43296045Sdougbif [ -t 0 ]; then 433110377Sdougb w=`tput columns` 43496045Sdougb case "${w}" in 43596045Sdougb 0|'') ;; # No-op, since the input is not valid 43696045Sdougb *) 43796045Sdougb case "${SCREEN_WIDTH}" in 43896045Sdougb '') SCREEN_WIDTH="${w}" ;; 43996045Sdougb "${w}") ;; # No-op, since they are the same 44096045Sdougb *) 44196045Sdougb echo -n "*** You entered ${SCREEN_WIDTH} as your screen width, but stty " 44296045Sdougb echo "thinks it is ${w}." 44396045Sdougb echo '' 44496045Sdougb echo -n "What would you like to use? [${w}] " 44596045Sdougb read SCREEN_WIDTH 44697380Sdougb case "${SCREEN_WIDTH}" in 44797380Sdougb '') SCREEN_WIDTH="${w}" ;; 44897380Sdougb esac 44996045Sdougb ;; 45096045Sdougb esac 45196045Sdougb esac 45296045Sdougbfi 45396045Sdougb 45473651Sdougb# Define what CVS $Id tag to look for to aid portability. 45573651Sdougb# 45673651SdougbCVS_ID_TAG=FreeBSD 45773651Sdougb 45899152Sdougbdelete_temproot () { 459101362Sdougb rm -rf "${TEMPROOT}" 2>/dev/null 460101362Sdougb chflags -R 0 "${TEMPROOT}" 2>/dev/null 461101362Sdougb rm -rf "${TEMPROOT}" || exit 1 46299152Sdougb} 46399152Sdougb 46452400Sbillfcase "${RERUN}" in 46552400Sbillf'') 46652400Sbillf # Set up the loop to test for the existence of the 46752400Sbillf # temp root directory. 46852400Sbillf # 46952400Sbillf TEST_TEMP_ROOT=yes 47052400Sbillf while [ "${TEST_TEMP_ROOT}" = "yes" ]; do 47152400Sbillf if [ -d "${TEMPROOT}" ]; then 47252400Sbillf echo "*** The directory specified for the temporary root environment," 47367859Sdougb echo " ${TEMPROOT}, exists. This can be a security risk if untrusted" 47452400Sbillf echo " users have access to the system." 47552400Sbillf echo '' 47652400Sbillf case "${AUTO_RUN}" in 47752400Sbillf '') 47852400Sbillf echo " Use 'd' to delete the old ${TEMPROOT} and continue" 47952400Sbillf echo " Use 't' to select a new temporary root directory" 48052400Sbillf echo " Use 'e' to exit mergemaster" 48152400Sbillf echo '' 48252400Sbillf echo " Default is to use ${TEMPROOT} as is" 48352400Sbillf echo '' 48467859Sdougb echo -n "How should I deal with this? [Use the existing ${TEMPROOT}] " 48567859Sdougb read DELORNOT 48667859Sdougb 48767859Sdougb case "${DELORNOT}" in 48867859Sdougb [dD]) 48967859Sdougb echo '' 49067859Sdougb echo " *** Deleting the old ${TEMPROOT}" 49167859Sdougb echo '' 49299152Sdougb delete_temproot || exit 1 49367859Sdougb unset TEST_TEMP_ROOT 49452400Sbillf ;; 49567859Sdougb [tT]) 49667859Sdougb echo " *** Enter new directory name for temporary root environment" 49767859Sdougb read TEMPROOT 49867859Sdougb ;; 49967859Sdougb [eE]) 50067859Sdougb exit 0 50167859Sdougb ;; 50267859Sdougb '') 50367859Sdougb echo '' 50467859Sdougb echo " *** Leaving ${TEMPROOT} intact" 50567859Sdougb echo '' 50667859Sdougb unset TEST_TEMP_ROOT 50767859Sdougb ;; 50867859Sdougb *) 50967859Sdougb echo '' 51067859Sdougb echo "invalid choice: ${DELORNOT}" 51167859Sdougb echo '' 51267859Sdougb ;; 51367859Sdougb esac 51467859Sdougb ;; 51552400Sbillf *) 51677323Sdougb # If this is an auto-run, try a hopefully safe alternative then 51777323Sdougb # re-test anyway. 51852400Sbillf TEMPROOT=/var/tmp/temproot.`date +%m%d.%H.%M.%S` 51952400Sbillf ;; 52052400Sbillf esac 52152400Sbillf else 52252400Sbillf unset TEST_TEMP_ROOT 52352400Sbillf fi 52452400Sbillf done 52552400Sbillf 52652400Sbillf echo "*** Creating the temporary root environment in ${TEMPROOT}" 52752400Sbillf 52852400Sbillf if mkdir -p "${TEMPROOT}"; then 52952400Sbillf echo " *** ${TEMPROOT} ready for use" 53052400Sbillf fi 53152400Sbillf 53252400Sbillf if [ ! -d "${TEMPROOT}" ]; then 53352400Sbillf echo '' 53452400Sbillf echo " *** FATAL ERROR: Cannot create ${TEMPROOT}" 53552400Sbillf echo '' 53652400Sbillf exit 1 53752400Sbillf fi 53852400Sbillf 53952400Sbillf echo " *** Creating and populating directory structure in ${TEMPROOT}" 54052400Sbillf echo '' 54152400Sbillf 54252400Sbillf case "${VERBOSE}" in 54352400Sbillf '') ;; 54452400Sbillf *) 54597960Sdougb press_to_continue 54652400Sbillf ;; 54752400Sbillf esac 54852400Sbillf 54991193Sdougb case "${PRE_WORLD}" in 55091193Sdougb '') 55191193Sdougb { cd ${SOURCEDIR} && 55291193Sdougb case "${DESTDIR}" in 55391193Sdougb '') ;; 55491193Sdougb *) 555155309Srwatson make DESTDIR=${DESTDIR} ${ARCHSTRING} distrib-dirs 55691193Sdougb ;; 55791193Sdougb esac 558155309Srwatson make DESTDIR=${TEMPROOT} ${ARCHSTRING} distrib-dirs && 559155309Srwatson MAKEOBJDIRPREFIX=${TEMPROOT}/usr/obj make ${ARCHSTRING} obj && 560155309Srwatson MAKEOBJDIRPREFIX=${TEMPROOT}/usr/obj make ${ARCHSTRING} all && 561155309Srwatson MAKEOBJDIRPREFIX=${TEMPROOT}/usr/obj make ${ARCHSTRING} \ 562155309Srwatson DESTDIR=${TEMPROOT} distribution;} || 56391193Sdougb { echo ''; 56491193Sdougb echo " *** FATAL ERROR: Cannot 'cd' to ${SOURCEDIR} and install files to"; 56591193Sdougb echo " the temproot environment"; 56691193Sdougb echo ''; 56791193Sdougb exit 1;} 56891193Sdougb ;; 56991193Sdougb *) 57091193Sdougb # Only set up files that are crucial to {build|install}world 57191193Sdougb { mkdir -p ${TEMPROOT}/etc && 57291193Sdougb cp -p ${SOURCEDIR}/master.passwd ${TEMPROOT}/etc && 57391193Sdougb cp -p ${SOURCEDIR}/group ${TEMPROOT}/etc;} || 57491193Sdougb { echo ''; 57591193Sdougb echo ' *** FATAL ERROR: Cannot copy files to the temproot environment'; 57691193Sdougb echo ''; 57791193Sdougb exit 1;} 57891193Sdougb ;; 57991193Sdougb esac 58052400Sbillf 58177323Sdougb # Doing the inventory and removing files that we don't want to compare only 58277323Sdougb # makes sense if we are not doing a rerun, since we have no way of knowing 58377323Sdougb # what happened to the files during previous incarnations. 58467949Sdougb case "${VERBOSE}" in 58567949Sdougb '') ;; 58667949Sdougb *) 58767949Sdougb echo '' 58867949Sdougb echo ' *** The following files exist only in the installed version of' 58967949Sdougb echo " ${DESTDIR}/etc. In the vast majority of cases these files" 59067949Sdougb echo ' are necessary parts of the system and should not be deleted.' 59167949Sdougb echo ' However because these files are not updated by this process you' 59267949Sdougb echo ' might want to verify their status before rebooting your system.' 59367949Sdougb echo '' 59497960Sdougb press_to_continue 595101348Sdougb diff -qr ${DESTDIR}/etc ${TEMPROOT}/etc | grep "^Only in ${DESTDIR}/etc" | ${PAGER} 59667949Sdougb echo '' 59797960Sdougb press_to_continue 59867949Sdougb ;; 59967949Sdougb esac 60067949Sdougb 60152534Sbillf # Avoid comparing the motd if the user specifies it in .mergemasterrc 60252534Sbillf case "${IGNORE_MOTD}" in 60352534Sbillf '') ;; 60496045Sdougb *) rm -f ${TEMPROOT}/etc/motd 60552534Sbillf ;; 60652534Sbillf esac 60752534Sbillf 60865115Sben # Avoid trying to update MAKEDEV if /dev is on a devfs 60968507Sdougb if /sbin/sysctl vfs.devfs.generation > /dev/null 2>&1 ; then 61091193Sdougb rm -f ${TEMPROOT}/dev/MAKEDEV ${TEMPROOT}/dev/MAKEDEV.local 61165115Sben fi 61265115Sben 61352400Sbillf ;; # End of the "RERUN" test 61452400Sbillfesac 61552400Sbillf 616111901Sdougb# We really don't want to have to deal with files like login.conf.db, pwd.db, 617111901Sdougb# or spwd.db. Instead, we want to compare the text versions, and run *_mkdb. 618111901Sdougb# Prompt the user to do so below, as needed. 61977478Sdougb# 620111905Sdougbrm -f ${TEMPROOT}/etc/*.db ${TEMPROOT}/etc/passwd 62177478Sdougb 62294196Sdougb# We only need to compare things like freebsd.cf once 62396045Sdougbfind ${TEMPROOT}/usr/obj -type f -delete 2>/dev/null 62494196Sdougb 625158149Sgordon# Delete 0 length files to make the mtree database as small as possible. 626158149Sgordonfind ${TEMPROOT} -type f -size 0 -delete 2>/dev/null 627158149Sgordon 628158149Sgordon# Build the mtree database in a temporary location. 629158149Sgordon# TODO: Possibly use mktemp instead for security reasons? 630158149Sgordoncase "${PRE_WORLD}" in 631158149Sgordon'') mtree -ci -p ${TEMPROOT} -k size,md5digest > ${DESTDIR}${MTREEDB}.new 2>/dev/null 632158149Sgordon ;; 633158149Sgordon*) # We don't want to mess with the mtree database on a pre-world run. 634158149Sgordon ;; 635158149Sgordonesac 636158149Sgordon 63752400Sbillf# Get ready to start comparing files 63852400Sbillf 63998084Sdougb# Check umask if not specified on the command line, 64098084Sdougb# and we are not doing an autorun 64152400Sbillf# 64298084Sdougbif [ -z "${NEW_UMASK}" -a -z "${AUTO_RUN}" ]; then 64398084Sdougb USER_UMASK=`umask` 64452400Sbillf case "${USER_UMASK}" in 64577335Sdougb 0022|022) ;; 64652400Sbillf *) 64752400Sbillf echo '' 64898084Sdougb echo " *** Your umask is currently set to ${USER_UMASK}. By default, this script" 64998084Sdougb echo " installs all files with the same user, group and modes that" 65098084Sdougb echo " they are created with by ${SOURCEDIR}/Makefile, compared to" 65198084Sdougb echo " a umask of 022. This umask allows world read permission when" 65298084Sdougb echo " the file's default permissions have it." 65352400Sbillf echo '' 65498084Sdougb echo " No world permissions can sometimes cause problems. A umask of" 65598084Sdougb echo " 022 will restore the default behavior, but is not mandatory." 65698084Sdougb echo " /etc/master.passwd is a special case. Its file permissions" 65798084Sdougb echo " will be 600 (rw-------) if installed." 65897960Sdougb echo '' 65998084Sdougb echo -n "What umask should I use? [${USER_UMASK}] " 66098084Sdougb read NEW_UMASK 66198084Sdougb 66298084Sdougb NEW_UMASK="${NEW_UMASK:-$USER_UMASK}" 66352400Sbillf ;; 66452400Sbillf esac 66552400Sbillf echo '' 66698084Sdougbfi 66752400Sbillf 66898084SdougbCONFIRMED_UMASK=${NEW_UMASK:-0022} 66998084Sdougb 67052400Sbillf# 671114501Sdougb# Warn users who still have old rc files 672114501Sdougb# 673114501Sdougbfor file in atm devfs diskless1 diskless2 isdn network network6 pccard \ 674114523Sdougb serial syscons sysctl alpha amd64 i386 ia64 sparc64; do 675114501Sdougb if [ -f "${DESTDIR}/etc/rc.${file}" ]; then 676114501Sdougb OLD_RC_PRESENT=1 677114501Sdougb break 678114501Sdougb fi 679114501Sdougbdone 680114501Sdougb 681114501Sdougbcase "${OLD_RC_PRESENT}" in 682114501Sdougb1) 68352400Sbillf echo '' 684114501Sdougb echo " *** There are elements of the old rc system in ${DESTDIR}/etc/." 68567949Sdougb echo '' 686114501Sdougb echo ' While these scripts will not hurt anything, they are not' 687114501Sdougb echo ' functional on an up to date system, and can be removed.' 68867949Sdougb echo '' 689114501Sdougb 69052400Sbillf case "${AUTO_RUN}" in 69152400Sbillf '') 692114501Sdougb echo -n 'Move these files to /var/tmp/mergemaster/old_rc? [yes] ' 693114501Sdougb read MOVE_OLD_RC 69467859Sdougb 695114501Sdougb case "${MOVE_OLD_RC}" in 696114501Sdougb [nN]*) ;; 69752400Sbillf *) 698114501Sdougb mkdir -p /var/tmp/mergemaster/old_rc 699114501Sdougb for file in atm devfs diskless1 diskless2 isdn network network6 pccard \ 700114523Sdougb serial syscons sysctl alpha amd64 i386 ia64 sparc64; do 701114501Sdougb if [ -f "${DESTDIR}/etc/rc.${file}" ]; then 702114501Sdougb mv ${DESTDIR}/etc/rc.${file} /var/tmp/mergemaster/old_rc/ 703114501Sdougb fi 704114501Sdougb done 705114501Sdougb echo ' The files have been moved' 706114501Sdougb press_to_continue 70752400Sbillf ;; 70852400Sbillf esac 70952400Sbillf ;; 71052400Sbillf *) ;; 71152400Sbillf esac 712114501Sdougbesac 71352400Sbillf 71498084Sdougb# Use the umask/mode information to install the files 71552400Sbillf# Create directories as needed 71652400Sbillf# 71778490Sdougbdo_install_and_rm () { 718114501Sdougb case "${PRESERVE_FILES}" in 719114501Sdougb [Yy][Ee][Ss]) 720114501Sdougb if [ -f "${3}/${2##*/}" ]; then 721114565Sdougb mkdir -p ${PRESERVE_FILES_DIR}/${2%/*} 722114565Sdougb cp ${3}/${2##*/} ${PRESERVE_FILES_DIR}/${2%/*} 723114501Sdougb fi 724114501Sdougb ;; 725114501Sdougb esac 726114501Sdougb 72778490Sdougb install -m "${1}" "${2}" "${3}" && 72891193Sdougb rm -f "${2}" 72978490Sdougb} 73078490Sdougb 73198084Sdougb# 4095 = "obase=10;ibase=8;07777" | bc 73298084Sdougbfind_mode () { 73398084Sdougb local OCTAL 73498084Sdougb OCTAL=$(( ~$(echo "obase=10; ibase=8; ${CONFIRMED_UMASK}" | bc) & 4095 & 735124053Sdougb $(echo "obase=10; ibase=8; $(stat -f "%OMp%OLp" ${1})" | bc) )) 73698084Sdougb printf "%04o\n" ${OCTAL} 73798084Sdougb} 73898084Sdougb 73952400Sbillfmm_install () { 74052400Sbillf local INSTALL_DIR 74152400Sbillf INSTALL_DIR=${1#.} 74252400Sbillf INSTALL_DIR=${INSTALL_DIR%/*} 74367949Sdougb 74452400Sbillf case "${INSTALL_DIR}" in 74552400Sbillf '') 74652400Sbillf INSTALL_DIR=/ 74752400Sbillf ;; 74852400Sbillf esac 74952400Sbillf 75067949Sdougb if [ -n "${DESTDIR}${INSTALL_DIR}" -a ! -d "${DESTDIR}${INSTALL_DIR}" ]; then 75198084Sdougb DIR_MODE=`find_mode "${TEMPROOT}/${INSTALL_DIR}"` 75267949Sdougb install -d -o root -g wheel -m "${DIR_MODE}" "${DESTDIR}${INSTALL_DIR}" 75352400Sbillf fi 75452400Sbillf 75598084Sdougb FILE_MODE=`find_mode "${1}"` 75652400Sbillf 75752400Sbillf if [ ! -x "${1}" ]; then 75852400Sbillf case "${1#.}" in 75964625Sgshapiro /etc/mail/aliases) 76052400Sbillf NEED_NEWALIASES=yes 76152400Sbillf ;; 76252400Sbillf /etc/login.conf) 76352400Sbillf NEED_CAP_MKDB=yes 76452400Sbillf ;; 76552400Sbillf /etc/master.passwd) 76678490Sdougb do_install_and_rm 600 "${1}" "${DESTDIR}${INSTALL_DIR}" 76752400Sbillf NEED_PWD_MKDB=yes 76852400Sbillf DONT_INSTALL=yes 76952400Sbillf ;; 77052400Sbillf /.cshrc | /.profile) 77177335Sdougb case "${AUTO_INSTALL}" in 77277335Sdougb '') 77352400Sbillf case "${LINK_EXPLAINED}" in 77452400Sbillf '') 77567859Sdougb echo " *** Historically BSD derived systems have had a" 77667859Sdougb echo " hard link from /.cshrc and /.profile to" 77767859Sdougb echo " their namesakes in /root. Please indicate" 77867859Sdougb echo " your preference below for bringing your" 77967859Sdougb echo " installed files up to date." 78052400Sbillf echo '' 78152400Sbillf LINK_EXPLAINED=yes 78252400Sbillf ;; 78352400Sbillf esac 78452400Sbillf 78552400Sbillf echo " Use 'd' to delete the temporary ${COMPFILE}" 78667949Sdougb echo " Use 'l' to delete the existing ${DESTDIR}${COMPFILE#.} and create the link" 78752400Sbillf echo '' 78852400Sbillf echo " Default is to leave the temporary file to deal with by hand" 78952400Sbillf echo '' 79067859Sdougb echo -n " How should I handle ${COMPFILE}? [Leave it to install later] " 79167859Sdougb read HANDLE_LINK 79277335Sdougb ;; 79377335Sdougb *) # Part of AUTO_INSTALL 79477335Sdougb HANDLE_LINK=l 79577335Sdougb ;; 79677335Sdougb esac 79767859Sdougb 79852400Sbillf case "${HANDLE_LINK}" in 79952400Sbillf [dD]*) 80052400Sbillf rm "${COMPFILE}" 80152400Sbillf echo '' 80252400Sbillf echo " *** Deleting ${COMPFILE}" 80352400Sbillf ;; 80452400Sbillf [lL]*) 80552400Sbillf echo '' 80667949Sdougb rm -f "${DESTDIR}${COMPFILE#.}" 80767949Sdougb if ln "${DESTDIR}/root/${COMPFILE##*/}" "${DESTDIR}${COMPFILE#.}"; then 80867949Sdougb echo " *** Link from ${DESTDIR}${COMPFILE#.} to ${DESTDIR}/root/${COMPFILE##*/} installed successfully" 80952400Sbillf rm "${COMPFILE}" 81052400Sbillf else 81167949Sdougb echo " *** Error linking ${DESTDIR}${COMPFILE#.} to ${DESTDIR}/root/${COMPFILE##*/}, ${COMPFILE} will remain to install by hand" 81252400Sbillf fi 81352400Sbillf ;; 81452400Sbillf *) 81552400Sbillf echo " *** ${COMPFILE} will remain for your consideration" 81652400Sbillf ;; 81752400Sbillf esac 81852400Sbillf DONT_INSTALL=yes 81952400Sbillf ;; 82052400Sbillf esac 82152400Sbillf 82252400Sbillf case "${DONT_INSTALL}" in 82352400Sbillf '') 82478490Sdougb do_install_and_rm "${FILE_MODE}" "${1}" "${DESTDIR}${INSTALL_DIR}" 82552400Sbillf ;; 82652400Sbillf *) 82752400Sbillf unset DONT_INSTALL 82852400Sbillf ;; 82952400Sbillf esac 83078490Sdougb else # File matched -x 83167949Sdougb case "${1#.}" in 83267949Sdougb /dev/MAKEDEV) 83367949Sdougb NEED_MAKEDEV=yes 83467949Sdougb ;; 83567949Sdougb esac 83678490Sdougb do_install_and_rm "${FILE_MODE}" "${1}" "${DESTDIR}${INSTALL_DIR}" 83752400Sbillf fi 83852400Sbillf return $? 83952400Sbillf} 84052400Sbillf 841174841Sdougbif [ ! -d "${TEMPROOT}" ]; then 842174841Sdougb echo "*** FATAL ERROR: The temproot directory (${TEMPROOT})" 843174841Sdougb echo ' has disappeared!' 844174841Sdougb echo '' 845174841Sdougb exit 1 846174841Sdougbfi 847174841Sdougb 84867949Sdougbecho '' 84967949Sdougbecho "*** Beginning comparison" 85067949Sdougbecho '' 85152400Sbillf 852124136Sdougb# Pre-world does not populate /etc/rc.d. 853124053Sdougb# It is very possible that a previous run would have deleted files in 854124053Sdougb# ${TEMPROOT}/etc/rc.d, thus creating a lot of false positives. 855124136Sdougbif [ -z "${PRE_WORLD}" -a -z "${RERUN}" ]; then 856124053Sdougb echo " *** Checking ${DESTDIR}/etc/rc.d for stale files" 857124053Sdougb echo '' 858124053Sdougb cd "${DESTDIR}/etc/rc.d" && 859124053Sdougb for file in *; do 860124053Sdougb if [ ! -e "${TEMPROOT}/etc/rc.d/${file}" ]; then 861124053Sdougb STALE_RC_FILES="${STALE_RC_FILES} ${file}" 862124053Sdougb fi 863124053Sdougb done 864124053Sdougb case "${STALE_RC_FILES}" in 865126718Sdougb ''|' *') 866124053Sdougb echo ' *** No stale files found' 867124053Sdougb ;; 868124053Sdougb *) 869124053Sdougb echo " *** The following files exist in ${DESTDIR}/etc/rc.d but not in" 870124053Sdougb echo " ${TEMPROOT}/etc/rc.d/:" 871124053Sdougb echo '' 872124053Sdougb echo "${STALE_RC_FILES}" 873124053Sdougb echo '' 874124053Sdougb echo ' The presence of stale files in this directory can cause the' 875124053Sdougb echo ' dreaded unpredictable results, and therefore it is highly' 876124053Sdougb echo ' recommended that you delete them.' 877124053Sdougb case "${AUTO_RUN}" in 878124053Sdougb '') 879124053Sdougb echo '' 880153604Sdougb echo -n ' *** Delete them now? [n] ' 881124053Sdougb read DELETE_STALE_RC_FILES 882124053Sdougb case "${DELETE_STALE_RC_FILES}" in 883153604Sdougb [yY]) 884124053Sdougb echo ' *** Deleting ... ' 885124053Sdougb rm ${STALE_RC_FILES} 886124053Sdougb echo ' done.' 887124053Sdougb ;; 888153604Sdougb *) 889153604Sdougb echo ' *** Files will not be deleted' 890153604Sdougb ;; 891124053Sdougb esac 892124053Sdougb sleep 2 893124053Sdougb ;; 894124053Sdougb esac 895124053Sdougb ;; 896124053Sdougb esac 897124053Sdougb echo '' 898124136Sdougbfi 899124053Sdougb 90067949Sdougbcd "${TEMPROOT}" 90167949Sdougb 90267949Sdougbif [ -r "${MM_PRE_COMPARE_SCRIPT}" ]; then 90367949Sdougb . "${MM_PRE_COMPARE_SCRIPT}" 90467949Sdougbfi 90567949Sdougb 90652400Sbillf# Using -size +0 avoids uselessly checking the empty log files created 90752400Sbillf# by ${SOURCEDIR}/Makefile and the device entries in ./dev, but does 90867949Sdougb# check the scripts in ./dev, as we'd like (assuming no devfs of course). 90952400Sbillf# 91052400Sbillffor COMPFILE in `find . -type f -size +0`; do 91167949Sdougb 91267949Sdougb # First, check to see if the file exists in DESTDIR. If not, the 91367949Sdougb # diff_loop function knows how to handle it. 91467949Sdougb # 91567949Sdougb if [ ! -e "${DESTDIR}${COMPFILE#.}" ]; then 91677325Sdougb case "${AUTO_RUN}" in 91777325Sdougb '') 91877325Sdougb diff_loop 91977325Sdougb ;; 92077325Sdougb *) 92177325Sdougb case "${AUTO_INSTALL}" in 92277325Sdougb '') 92377325Sdougb # If this is an auto run, make it official 92477325Sdougb echo " *** ${COMPFILE} will remain for your consideration" 92577325Sdougb ;; 92677325Sdougb *) 92777325Sdougb diff_loop 92877325Sdougb ;; 92977325Sdougb esac 93077325Sdougb ;; 93177325Sdougb esac # Auto run test 93267949Sdougb continue 93367949Sdougb fi 93467949Sdougb 93552400Sbillf case "${STRICT}" in 93652400Sbillf '' | [Nn][Oo]) 93752400Sbillf # Compare CVS $Id's first so if the file hasn't been modified 93852400Sbillf # local changes will be ignored. 93952400Sbillf # If the files have the same $Id, delete the one in temproot so the 94052400Sbillf # user will have less to wade through if files are left to merge by hand. 94152400Sbillf # 94273651Sdougb CVSID1=`grep "[$]${CVS_ID_TAG}:" ${DESTDIR}${COMPFILE#.} 2>/dev/null` 94390564Sdougb CVSID2=`grep "[$]${CVS_ID_TAG}:" ${COMPFILE} 2>/dev/null` || CVSID2=none 94452400Sbillf 94567949Sdougb case "${CVSID2}" in 94673651Sdougb "${CVSID1}") 94767949Sdougb echo " *** Temp ${COMPFILE} and installed have the same CVS Id, deleting" 94867949Sdougb rm "${COMPFILE}" 94967949Sdougb ;; 95067949Sdougb esac 95152400Sbillf ;; 95252400Sbillf esac 95352400Sbillf 95452400Sbillf # If the file is still here either because the $Ids are different, the 95552400Sbillf # file doesn't have an $Id, or we're using STRICT mode; look at the diff. 95652400Sbillf # 95752400Sbillf if [ -f "${COMPFILE}" ]; then 95852400Sbillf 95952400Sbillf # Do an absolute diff first to see if the files are actually different. 96052400Sbillf # If they're not different, delete the one in temproot. 96152400Sbillf # 962110377Sdougb if diff -q ${DIFF_OPTIONS} "${DESTDIR}${COMPFILE#.}" "${COMPFILE}" > \ 963110377Sdougb /dev/null 2>&1; then 96452400Sbillf echo " *** Temp ${COMPFILE} and installed are the same, deleting" 96552400Sbillf rm "${COMPFILE}" 96652400Sbillf else 96777323Sdougb # Ok, the files are different, so show the user where they differ. 96877323Sdougb # Use user's choice of diff methods; and user's pager if they have one. 96977323Sdougb # Use more if not. 97067859Sdougb # Use unified diffs by default. Context diffs give me a headache. :) 97152400Sbillf # 97252400Sbillf case "${AUTO_RUN}" in 97352400Sbillf '') 97458910Salfred # prompt user to install/delete/merge changes 97558910Salfred diff_loop 97652400Sbillf ;; 97752400Sbillf *) 97852400Sbillf # If this is an auto run, make it official 97952400Sbillf echo " *** ${COMPFILE} will remain for your consideration" 98052400Sbillf ;; 98152400Sbillf esac # Auto run test 98252400Sbillf fi # Yes, the files are different 98352400Sbillf fi # Yes, the file still remains to be checked 98452400Sbillfdone # This is for the do way up there at the beginning of the comparison 98552400Sbillf 98652534Sbillfecho '' 98752400Sbillfecho "*** Comparison complete" 988158149Sgordon 989158149Sgordonif [ -f "${DESTDIR}${MTREEDB}.new" ]; then 990158149Sgordon echo "*** Saving mtree database for future upgrades" 991158149Sgordon mv -f ${DESTDIR}${MTREEDB}.new ${DESTDIR}${MTREEDB} 2>/dev/null 992158149Sgordonfi 993158149Sgordon 99452400Sbillfecho '' 99552400Sbillf 99652400SbillfTEST_FOR_FILES=`find ${TEMPROOT} -type f -size +0 2>/dev/null` 99752400Sbillfif [ -n "${TEST_FOR_FILES}" ]; then 99852400Sbillf echo "*** Files that remain for you to merge by hand:" 99952400Sbillf find "${TEMPROOT}" -type f -size +0 100077335Sdougb echo '' 100152400Sbillffi 100252400Sbillf 100352400Sbillfcase "${AUTO_RUN}" in 100452400Sbillf'') 100567859Sdougb echo -n "Do you wish to delete what is left of ${TEMPROOT}? [no] " 100667859Sdougb read DEL_TEMPROOT 100767859Sdougb 100852400Sbillf case "${DEL_TEMPROOT}" in 100952400Sbillf [yY]*) 101099152Sdougb if delete_temproot; then 101152400Sbillf echo " *** ${TEMPROOT} has been deleted" 101252400Sbillf else 101352400Sbillf echo " *** Unable to delete ${TEMPROOT}" 101452400Sbillf fi 101552400Sbillf ;; 101652400Sbillf *) 101752400Sbillf echo " *** ${TEMPROOT} will remain" 101852400Sbillf ;; 101952400Sbillf esac 102052400Sbillf ;; 102152400Sbillf*) ;; 102252400Sbillfesac 102352400Sbillf 102468153Sdougbcase "${AUTO_INSTALLED_FILES}" in 102568153Sdougb'') ;; 102668153Sdougb*) 102773651Sdougb case "${AUTO_RUN}" in 102873651Sdougb '') 102973651Sdougb ( 103073651Sdougb echo '' 103177323Sdougb echo '*** You chose the automatic install option for files that did not' 103277323Sdougb echo ' exist on your system. The following were installed for you:' 103373651Sdougb echo "${AUTO_INSTALLED_FILES}" 103473651Sdougb ) | ${PAGER} 103573651Sdougb ;; 103673651Sdougb *) 103768153Sdougb echo '' 103877323Sdougb echo '*** You chose the automatic install option for files that did not' 103977323Sdougb echo ' exist on your system. The following were installed for you:' 104068153Sdougb echo "${AUTO_INSTALLED_FILES}" 104173651Sdougb ;; 104273651Sdougb esac 104368153Sdougb ;; 104468153Sdougbesac 104568153Sdougb 1046158149Sgordoncase "${AUTO_UPGRADED_FILES}" in 1047158149Sgordon'') ;; 1048158149Sgordon*) 1049158149Sgordon case "${AUTO_RUN}" in 1050158149Sgordon '') 1051158149Sgordon ( 1052158149Sgordon echo '' 1053158149Sgordon echo '*** You chose the automatic upgrade option for files that you did' 1054158149Sgordon echo ' not alter on your system. The following were upgraded for you:' 1055158149Sgordon echo "${AUTO_UPGRADED_FILES}" 1056158149Sgordon ) | ${PAGER} 1057158149Sgordon ;; 1058158149Sgordon *) 1059158149Sgordon echo '' 1060158149Sgordon echo '*** You chose the automatic upgrade option for files that you did' 1061158149Sgordon echo ' not alter on your system. The following were upgraded for you:' 1062158149Sgordon echo "${AUTO_UPGRADED_FILES}" 1063158149Sgordon ;; 1064158149Sgordon esac 1065158149Sgordon ;; 1066158149Sgordonesac 1067158149Sgordon 106873651Sdougbrun_it_now () { 106973651Sdougb case "${AUTO_RUN}" in 107073651Sdougb '') 107173651Sdougb unset YES_OR_NO 107273651Sdougb echo '' 107377335Sdougb echo -n ' Would you like to run it now? y or n [n] ' 107473651Sdougb read YES_OR_NO 107573651Sdougb 107673651Sdougb case "${YES_OR_NO}" in 107773651Sdougb y) 107877335Sdougb echo " Running ${1}" 107977335Sdougb echo '' 108073651Sdougb eval "${1}" 108173651Sdougb ;; 108277335Sdougb ''|n) 108377335Sdougb echo '' 108477335Sdougb echo " *** Cancelled" 108577335Sdougb echo '' 108677335Sdougb echo " Make sure to run ${1} yourself" 108777335Sdougb ;; 108873651Sdougb *) 108977335Sdougb echo '' 109077335Sdougb echo " *** Sorry, I do not understand your answer (${YES_OR_NO})" 109177335Sdougb echo '' 109277335Sdougb echo " Make sure to run ${1} yourself" 109373651Sdougb esac 109473651Sdougb ;; 109573651Sdougb *) ;; 109673651Sdougb esac 109773651Sdougb} 109873651Sdougb 109952400Sbillfcase "${NEED_MAKEDEV}" in 110052400Sbillf'') ;; 110152400Sbillf*) 110252400Sbillf echo '' 110377335Sdougb echo "*** You installed a new ${DESTDIR}/dev/MAKEDEV script, so make sure that you run" 110477335Sdougb echo " 'cd ${DESTDIR}/dev && /bin/sh MAKEDEV all' to rebuild your devices" 110577335Sdougb run_it_now "cd ${DESTDIR}/dev && /bin/sh MAKEDEV all" 110652400Sbillf ;; 110752400Sbillfesac 110852400Sbillf 110952400Sbillfcase "${NEED_NEWALIASES}" in 111052400Sbillf'') ;; 111152400Sbillf*) 111252400Sbillf echo '' 111377335Sdougb if [ -n "${DESTDIR}" ]; then 111477335Sdougb echo "*** You installed a new aliases file into ${DESTDIR}/etc/mail, but" 111577335Sdougb echo " the newaliases command is limited to the directories configured" 111677335Sdougb echo " in sendmail.cf. Make sure to create your aliases database by" 111777335Sdougb echo " hand when your sendmail configuration is done." 111877335Sdougb else 111977335Sdougb echo "*** You installed a new aliases file, so make sure that you run" 112077335Sdougb echo " '/usr/bin/newaliases' to rebuild your aliases database" 112177335Sdougb run_it_now '/usr/bin/newaliases' 112277335Sdougb fi 112352400Sbillf ;; 112452400Sbillfesac 112552400Sbillf 112652400Sbillfcase "${NEED_CAP_MKDB}" in 112752400Sbillf'') ;; 112852400Sbillf*) 112952400Sbillf echo '' 113052400Sbillf echo "*** You installed a login.conf file, so make sure that you run" 113177335Sdougb echo " '/usr/bin/cap_mkdb ${DESTDIR}/etc/login.conf'" 113277335Sdougb echo " to rebuild your login.conf database" 113377335Sdougb run_it_now "/usr/bin/cap_mkdb ${DESTDIR}/etc/login.conf" 113452400Sbillf ;; 113552400Sbillfesac 113652400Sbillf 113752400Sbillfcase "${NEED_PWD_MKDB}" in 113852400Sbillf'') ;; 113952400Sbillf*) 114052400Sbillf echo '' 114152400Sbillf echo "*** You installed a new master.passwd file, so make sure that you run" 114277335Sdougb if [ -n "${DESTDIR}" ]; then 114377335Sdougb echo " '/usr/sbin/pwd_mkdb -d ${DESTDIR}/etc -p ${DESTDIR}/etc/master.passwd'" 114477335Sdougb echo " to rebuild your password files" 114577335Sdougb run_it_now "/usr/sbin/pwd_mkdb -d ${DESTDIR}/etc -p ${DESTDIR}/etc/master.passwd" 114677335Sdougb else 114777335Sdougb echo " '/usr/sbin/pwd_mkdb -p /etc/master.passwd'" 114877335Sdougb echo " to rebuild your password files" 114977335Sdougb run_it_now '/usr/sbin/pwd_mkdb -p /etc/master.passwd' 115077335Sdougb fi 115152400Sbillf ;; 115252400Sbillfesac 115352400Sbillf 115452400Sbillfecho '' 115552400Sbillf 115667949Sdougbif [ -r "${MM_EXIT_SCRIPT}" ]; then 115767949Sdougb . "${MM_EXIT_SCRIPT}" 115867949Sdougbfi 115967949Sdougb 116091193Sdougbcase "${COMP_CONFS}" in 116191193Sdougb'') ;; 116291193Sdougb*) 116391193Sdougb . ${DESTDIR}/etc/defaults/rc.conf 116491193Sdougb 116591193Sdougb (echo '' 116691193Sdougb echo "*** Comparing conf files: ${rc_conf_files}" 116791193Sdougb 116891193Sdougb for CONF_FILE in ${rc_conf_files}; do 116991193Sdougb if [ -r "${DESTDIR}${CONF_FILE}" ]; then 117091193Sdougb echo '' 117191193Sdougb echo "*** From ${DESTDIR}${CONF_FILE}" 117291193Sdougb echo "*** From ${DESTDIR}/etc/defaults/rc.conf" 117391193Sdougb 117491193Sdougb for RC_CONF_VAR in `grep -i ^[a-z] ${DESTDIR}${CONF_FILE} | 117591193Sdougb cut -d '=' -f 1`; do 117691193Sdougb echo '' 117791223Sdougb grep -w ^${RC_CONF_VAR} ${DESTDIR}${CONF_FILE} 117891223Sdougb grep -w ^${RC_CONF_VAR} ${DESTDIR}/etc/defaults/rc.conf || 117991193Sdougb echo ' * No default variable with this name' 118091193Sdougb done 118191193Sdougb fi 118291193Sdougb done) | ${PAGER} 118391193Sdougb echo '' 118491193Sdougb ;; 118591193Sdougbesac 118691193Sdougb 118791193Sdougbcase "${PRE_WORLD}" in 118891193Sdougb'') ;; 118991193Sdougb*) 119091193Sdougb MAKE_CONF="${SOURCEDIR%etc}share/examples/etc/make.conf" 119191193Sdougb 119291193Sdougb (echo '' 119391193Sdougb echo '*** Comparing make variables' 119491193Sdougb echo '' 119591193Sdougb echo "*** From ${DESTDIR}/etc/make.conf" 119691193Sdougb echo "*** From ${MAKE_CONF}" 119791193Sdougb 1198101348Sdougb for MAKE_VAR in `grep -i ^[a-z] ${DESTDIR}/etc/make.conf | cut -d '=' -f 1`; do 119991193Sdougb echo '' 120091223Sdougb grep -w ^${MAKE_VAR} ${DESTDIR}/etc/make.conf 120191223Sdougb grep -w ^#${MAKE_VAR} ${MAKE_CONF} || 120291193Sdougb echo ' * No example variable with this name' 120391193Sdougb done) | ${PAGER} 120491193Sdougb ;; 120591193Sdougbesac 120691193Sdougb 120752400Sbillfexit 0 120867850Sdougb 1209