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