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