mergemaster.sh revision 77478
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 77478 2001-05-30 08:50:10Z 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 # Avoid comparing the motd if the user specifies it in .mergemasterrc 483 case "${IGNORE_MOTD}" in 484 '') ;; 485 *) rm ${TEMPROOT}/etc/motd 486 ;; 487 esac 488 489 # Avoid trying to update MAKEDEV if /dev is on a devfs 490 if /sbin/sysctl vfs.devfs.generation > /dev/null 2>&1 ; then 491 rm ${TEMPROOT}/dev/MAKEDEV ${TEMPROOT}/dev/MAKEDEV.local 492 fi 493 494 ;; # End of the "RERUN" test 495esac 496 497# We really don't want to have to deal with these files, since 498# master.passwd is the real file that should be compared, then 499# the user should run pwd_mkdb if necessary. 500# 501[ -f "${TEMPROOT}/etc/spwd.db" ] && rm "${TEMPROOT}/etc/spwd.db" 502[ -f "${TEMPROOT}/etc/passwd" ] && rm "${TEMPROOT}/etc/passwd" 503[ -f "${TEMPROOT}/etc/pwd.db" ] && rm "${TEMPROOT}/etc/pwd.db" 504 505# Get ready to start comparing files 506 507# Check umask if not specified on the command line, 508# and we are not doing an autorun 509# 510if [ -z "${NEW_UMASK}" -a -z "${AUTO_RUN}" ]; then 511 USER_UMASK=`umask` 512 case "${USER_UMASK}" in 513 0022|022) ;; 514 *) 515 echo '' 516 echo " *** Your umask is currently set to ${USER_UMASK}. By default, this script" 517 echo " installs all files with the same user, group and modes that" 518 echo " they are created with by ${SOURCEDIR}/Makefile, compared to" 519 echo " a umask of 022. This umask allows world read permission when" 520 echo " the file's default permissions have it." 521 echo " No world permissions can sometimes cause problems. A umask of" 522 echo " 022 will restore the default behavior, but is not mandatory." 523 echo " /etc/master.passwd is a special case. Its file permissions" 524 echo " will be 600 (rw-------) if installed." 525 echo '' 526 echo -n "What umask should I use? [${USER_UMASK}] " 527 read NEW_UMASK 528 529 NEW_UMASK="${NEW_UMASK:-$USER_UMASK}" 530 ;; 531 esac 532 echo '' 533fi 534 535CONFIRMED_UMASK=${NEW_UMASK:-0022} 536 537# Warn users who still have ${DESTDIR}/etc/sysconfig 538# 539if [ -e "${DESTDIR}/etc/sysconfig" ]; then 540 echo '' 541 echo " *** There is a sysconfig file on this system in ${DESTDIR}/etc/." 542 echo '' 543 echo ' Starting with FreeBSD version 2.2.2 those settings moved from' 544 echo ' /etc/sysconfig to /etc/rc.conf. If you are upgrading an older' 545 echo ' system make sure that you transfer your settings by hand from' 546 echo ' sysconfig to rc.conf and install the rc.conf file. If you' 547 echo ' have already made this transition, you should consider' 548 echo ' renaming or deleting the sysconfig file.' 549 echo '' 550 case "${AUTO_RUN}" in 551 '') 552 echo -n "Continue with the merge process? [yes] " 553 read CONT_OR_NOT 554 555 case "${CONT_OR_NOT}" in 556 [nN]*) 557 exit 0 558 ;; 559 *) 560 echo " *** Continuing" 561 echo '' 562 ;; 563 esac 564 ;; 565 *) ;; 566 esac 567fi 568 569# Use the umask/mode information to install the files 570# Create directories as needed 571# 572mm_install () { 573 local INSTALL_DIR 574 INSTALL_DIR=${1#.} 575 INSTALL_DIR=${INSTALL_DIR%/*} 576 577 case "${INSTALL_DIR}" in 578 '') 579 INSTALL_DIR=/ 580 ;; 581 esac 582 583 if [ -n "${DESTDIR}${INSTALL_DIR}" -a ! -d "${DESTDIR}${INSTALL_DIR}" ]; then 584 DIR_MODE=`perl -e 'printf "%04o\n", (((stat("$ARGV[0]"))[2] & 07777) &~ \ 585 oct("$ARGV[1]"))' "${TEMPROOT}/${INSTALL_DIR}" "${CONFIRMED_UMASK}"` 586 install -d -o root -g wheel -m "${DIR_MODE}" "${DESTDIR}${INSTALL_DIR}" 587 fi 588 589 FILE_MODE=`perl -e 'printf "%04o\n", (((stat("$ARGV[0]"))[2] & 07777) &~ \ 590 oct("$ARGV[1]"))' "${1}" "${CONFIRMED_UMASK}"` 591 592 if [ ! -x "${1}" ]; then 593 case "${1#.}" in 594 /etc/mail/aliases) 595 NEED_NEWALIASES=yes 596 ;; 597 /etc/login.conf) 598 NEED_CAP_MKDB=yes 599 ;; 600 /etc/master.passwd) 601 install -m 600 "${1}" "${DESTDIR}${INSTALL_DIR}" && 602 [ -f "${1}" ] && rm "${1}" 603 NEED_PWD_MKDB=yes 604 DONT_INSTALL=yes 605 ;; 606 /.cshrc | /.profile) 607 case "${AUTO_INSTALL}" in 608 '') 609 case "${LINK_EXPLAINED}" in 610 '') 611 echo " *** Historically BSD derived systems have had a" 612 echo " hard link from /.cshrc and /.profile to" 613 echo " their namesakes in /root. Please indicate" 614 echo " your preference below for bringing your" 615 echo " installed files up to date." 616 echo '' 617 LINK_EXPLAINED=yes 618 ;; 619 esac 620 621 echo " Use 'd' to delete the temporary ${COMPFILE}" 622 echo " Use 'l' to delete the existing ${DESTDIR}${COMPFILE#.} and create the link" 623 echo '' 624 echo " Default is to leave the temporary file to deal with by hand" 625 echo '' 626 echo -n " How should I handle ${COMPFILE}? [Leave it to install later] " 627 read HANDLE_LINK 628 ;; 629 *) # Part of AUTO_INSTALL 630 HANDLE_LINK=l 631 ;; 632 esac 633 634 case "${HANDLE_LINK}" in 635 [dD]*) 636 rm "${COMPFILE}" 637 echo '' 638 echo " *** Deleting ${COMPFILE}" 639 ;; 640 [lL]*) 641 echo '' 642 rm -f "${DESTDIR}${COMPFILE#.}" 643 if ln "${DESTDIR}/root/${COMPFILE##*/}" "${DESTDIR}${COMPFILE#.}"; then 644 echo " *** Link from ${DESTDIR}${COMPFILE#.} to ${DESTDIR}/root/${COMPFILE##*/} installed successfully" 645 rm "${COMPFILE}" 646 else 647 echo " *** Error linking ${DESTDIR}${COMPFILE#.} to ${DESTDIR}/root/${COMPFILE##*/}, ${COMPFILE} will remain to install by hand" 648 fi 649 ;; 650 *) 651 echo " *** ${COMPFILE} will remain for your consideration" 652 ;; 653 esac 654 DONT_INSTALL=yes 655 ;; 656 esac 657 658 case "${DONT_INSTALL}" in 659 '') 660 install -m "${FILE_MODE}" "${1}" "${DESTDIR}${INSTALL_DIR}" && 661 [ -f "${1}" ] && rm "${1}" 662 ;; 663 *) 664 unset DONT_INSTALL 665 ;; 666 esac 667 else 668 case "${1#.}" in 669 /dev/MAKEDEV) 670 NEED_MAKEDEV=yes 671 ;; 672 esac 673 install -m "${FILE_MODE}" "${1}" "${DESTDIR}${INSTALL_DIR}" && 674 [ -f "${1}" ] && rm "${1}" 675 fi 676 return $? 677} 678 679echo '' 680echo "*** Beginning comparison" 681echo '' 682 683cd "${TEMPROOT}" 684 685if [ -r "${MM_PRE_COMPARE_SCRIPT}" ]; then 686 . "${MM_PRE_COMPARE_SCRIPT}" 687fi 688 689# Using -size +0 avoids uselessly checking the empty log files created 690# by ${SOURCEDIR}/Makefile and the device entries in ./dev, but does 691# check the scripts in ./dev, as we'd like (assuming no devfs of course). 692# 693for COMPFILE in `find . -type f -size +0`; do 694 695 # First, check to see if the file exists in DESTDIR. If not, the 696 # diff_loop function knows how to handle it. 697 # 698 if [ ! -e "${DESTDIR}${COMPFILE#.}" ]; then 699 case "${AUTO_RUN}" in 700 '') 701 diff_loop 702 ;; 703 *) 704 case "${AUTO_INSTALL}" in 705 '') 706 # If this is an auto run, make it official 707 echo " *** ${COMPFILE} will remain for your consideration" 708 ;; 709 *) 710 diff_loop 711 ;; 712 esac 713 ;; 714 esac # Auto run test 715 continue 716 fi 717 718 case "${STRICT}" in 719 '' | [Nn][Oo]) 720 # Compare CVS $Id's first so if the file hasn't been modified 721 # local changes will be ignored. 722 # If the files have the same $Id, delete the one in temproot so the 723 # user will have less to wade through if files are left to merge by hand. 724 # 725 CVSID1=`grep "[$]${CVS_ID_TAG}:" ${DESTDIR}${COMPFILE#.} 2>/dev/null` 726 CVSID2=`grep "[$]${CVS_ID_TAG}:" ${COMPFILE} 2>/dev/null` 727 728 case "${CVSID2}" in 729 "${CVSID1}") 730 echo " *** Temp ${COMPFILE} and installed have the same CVS Id, deleting" 731 rm "${COMPFILE}" 732 ;; 733 esac 734 ;; 735 esac 736 737 # If the file is still here either because the $Ids are different, the 738 # file doesn't have an $Id, or we're using STRICT mode; look at the diff. 739 # 740 if [ -f "${COMPFILE}" ]; then 741 742 # Do an absolute diff first to see if the files are actually different. 743 # If they're not different, delete the one in temproot. 744 # 745 if diff -q "${DESTDIR}${COMPFILE#.}" "${COMPFILE}" > /dev/null 2>&1; then 746 echo " *** Temp ${COMPFILE} and installed are the same, deleting" 747 rm "${COMPFILE}" 748 else 749 # Ok, the files are different, so show the user where they differ. 750 # Use user's choice of diff methods; and user's pager if they have one. 751 # Use more if not. 752 # Use unified diffs by default. Context diffs give me a headache. :) 753 # 754 case "${AUTO_RUN}" in 755 '') 756 # prompt user to install/delete/merge changes 757 diff_loop 758 ;; 759 *) 760 # If this is an auto run, make it official 761 echo " *** ${COMPFILE} will remain for your consideration" 762 ;; 763 esac # Auto run test 764 fi # Yes, the files are different 765 fi # Yes, the file still remains to be checked 766done # This is for the do way up there at the beginning of the comparison 767 768echo '' 769echo "*** Comparison complete" 770echo '' 771 772TEST_FOR_FILES=`find ${TEMPROOT} -type f -size +0 2>/dev/null` 773if [ -n "${TEST_FOR_FILES}" ]; then 774 echo "*** Files that remain for you to merge by hand:" 775 find "${TEMPROOT}" -type f -size +0 776 echo '' 777fi 778 779case "${AUTO_RUN}" in 780'') 781 echo -n "Do you wish to delete what is left of ${TEMPROOT}? [no] " 782 read DEL_TEMPROOT 783 784 case "${DEL_TEMPROOT}" in 785 [yY]*) 786 if rm -rf "${TEMPROOT}"; then 787 echo " *** ${TEMPROOT} has been deleted" 788 else 789 echo " *** Unable to delete ${TEMPROOT}" 790 fi 791 ;; 792 *) 793 echo " *** ${TEMPROOT} will remain" 794 ;; 795 esac 796 ;; 797*) ;; 798esac 799 800case "${AUTO_INSTALLED_FILES}" in 801'') ;; 802*) 803 case "${AUTO_RUN}" in 804 '') 805 ( 806 echo '' 807 echo '*** You chose the automatic install option for files that did not' 808 echo ' exist on your system. The following were installed for you:' 809 echo "${AUTO_INSTALLED_FILES}" 810 ) | ${PAGER} 811 ;; 812 *) 813 echo '' 814 echo '*** You chose the automatic install option for files that did not' 815 echo ' exist on your system. The following were installed for you:' 816 echo "${AUTO_INSTALLED_FILES}" 817 ;; 818 esac 819 ;; 820esac 821 822run_it_now () { 823 case "${AUTO_RUN}" in 824 '') 825 unset YES_OR_NO 826 echo '' 827 echo -n ' Would you like to run it now? y or n [n] ' 828 read YES_OR_NO 829 830 case "${YES_OR_NO}" in 831 y) 832 echo " Running ${1}" 833 echo '' 834 eval "${1}" 835 ;; 836 ''|n) 837 echo '' 838 echo " *** Cancelled" 839 echo '' 840 echo " Make sure to run ${1} yourself" 841 ;; 842 *) 843 echo '' 844 echo " *** Sorry, I do not understand your answer (${YES_OR_NO})" 845 echo '' 846 echo " Make sure to run ${1} yourself" 847 esac 848 ;; 849 *) ;; 850 esac 851} 852 853case "${NEED_MAKEDEV}" in 854'') ;; 855*) 856 echo '' 857 echo "*** You installed a new ${DESTDIR}/dev/MAKEDEV script, so make sure that you run" 858 echo " 'cd ${DESTDIR}/dev && /bin/sh MAKEDEV all' to rebuild your devices" 859 run_it_now "cd ${DESTDIR}/dev && /bin/sh MAKEDEV all" 860 ;; 861esac 862 863case "${NEED_NEWALIASES}" in 864'') ;; 865*) 866 echo '' 867 if [ -n "${DESTDIR}" ]; then 868 echo "*** You installed a new aliases file into ${DESTDIR}/etc/mail, but" 869 echo " the newaliases command is limited to the directories configured" 870 echo " in sendmail.cf. Make sure to create your aliases database by" 871 echo " hand when your sendmail configuration is done." 872 else 873 echo "*** You installed a new aliases file, so make sure that you run" 874 echo " '/usr/bin/newaliases' to rebuild your aliases database" 875 run_it_now '/usr/bin/newaliases' 876 fi 877 ;; 878esac 879 880case "${NEED_CAP_MKDB}" in 881'') ;; 882*) 883 echo '' 884 echo "*** You installed a login.conf file, so make sure that you run" 885 echo " '/usr/bin/cap_mkdb ${DESTDIR}/etc/login.conf'" 886 echo " to rebuild your login.conf database" 887 run_it_now "/usr/bin/cap_mkdb ${DESTDIR}/etc/login.conf" 888 ;; 889esac 890 891case "${NEED_PWD_MKDB}" in 892'') ;; 893*) 894 echo '' 895 echo "*** You installed a new master.passwd file, so make sure that you run" 896 if [ -n "${DESTDIR}" ]; then 897 echo " '/usr/sbin/pwd_mkdb -d ${DESTDIR}/etc -p ${DESTDIR}/etc/master.passwd'" 898 echo " to rebuild your password files" 899 run_it_now "/usr/sbin/pwd_mkdb -d ${DESTDIR}/etc -p ${DESTDIR}/etc/master.passwd" 900 else 901 echo " '/usr/sbin/pwd_mkdb -p /etc/master.passwd'" 902 echo " to rebuild your password files" 903 run_it_now '/usr/sbin/pwd_mkdb -p /etc/master.passwd' 904 fi 905 ;; 906esac 907 908echo '' 909 910if [ -r "${MM_EXIT_SCRIPT}" ]; then 911 . "${MM_EXIT_SCRIPT}" 912fi 913 914exit 0 915 916