1 #!/bin/bash 2 3 ARCH=`uname -p` 4 if [ $ARCH != "sparc" ]; then 5 ARCH=x86 6 fi 7 ALL_PRODUCTS="jds=JDS Common Packages 8 jds-src=Sources for JDS Common Packages 9 gnome=GNOME 2.17 Desktop 10 gnome-src=GNOME 2.17 Source 11 mozilla=Mozilla 1.7 Web Browser 12 mozilla-src=Mozilla Source 13 firefox=Firefox Web Browser 14 firefox-src=Firefox Source 15 thunderbird=Thunderbird Email and News Client 16 thunderbird-src=Thunderbird Source 17 idn 18 idn-src 19 evolution=Evolution Email and Calendar 20 evolution-src=Evolution Source 21 glow=Integrated Collaboration Environment 22 jai=Java Advanced Imaging 23 jai-iio=Java Advanced Imaging 24 java=Java Runtime Environment 25 java-src 26 javaapps=Java Applications 27 javaapps-src=Java Applications Sources 28 java3d 29 jcs 30 jdk=Java Development Kit 31 jdic=Java Desktop Integration Components 32 jdnc=Java Desktop Network Components 33 jinput=Java Controller API 34 joal=Java bindings for OpenAL API 35 jogl=Java bindings for OpenGL API 36 l10n=Globalization Tools 37 l10n-src=Globalization Tools Sources 38 l10nmessages=Localized Messages 39 iiim=Input Method Switcher 40 iiim-src=Input Method Switcher Sources 41 muscle 42 plugins=Third Party Browser Plugins 43 plugins-src 44 scs-client 45 staroffice=StarOffice office suite 46 starsuite=StarSuite office suite 47 so-sdk=StarOffice Software Development Kit 48 updater 49 netbeans 50 javahelp 51 xserver=X.org server 52 nodist=Extra packages for JDS developers 53 nodist-src=Extra sources for JDS developers 54 apoc-daemon=APOC Daemon 55 apoc-daemon-src=APOC Daemon Sources 56 apoc-sol-$ARCH=APOC Configuration Manager 57 apoc-sol-$ARCH-src=APOC Configuration Manager Sources" 58 59 ALL_PATCHDIRS="patches-xserver=X server patches 60 patches-mozilla=Patches required for the Mozilla Web browser 61 patches-gnome=Patches required for the GNOME Desktop" 62 63 PKGADD=/usr/sbin/pkgadd 64 PATCHADD=/usr/sbin/patchadd 65 PKGRM=/usr/sbin/pkgrm 66 PKGINFO=/usr/bin/pkginfo 67 ADMIN=/tmp/.pkg.$$.admin 68 ADMIN_CREATED=no 69 70 MYNAME="$0" 71 MYDIR=`dirname $0` 72 MYDIR=`( cd $MYDIR; pwd )` 73 MYNAME=$(basename $0) 74 MYARGS="$*" 75 LOGFILE=/var/sadm/install/logs/jds-install.log.$$ 76 INFOFILE=$MYDIR/.pkginfo 77 SYSTEM=`uname -s` 78 ARCH=`uname -p` 79 RELEASE=`uname -r` 80 KERNELID=`uname -v` 81 82 # ask "question" variable_name "default answer" 83 ask () { 84 echo -n "$1" 85 if [ ! -z $3 ]; then 86 echo -n " [$3]: " 87 else 88 echo -n ": " 89 fi 90 91 read -e val 92 if [ "x$val" = x ]; then 93 eval "$2=\"$3\"" 94 else 95 eval "$2=\"$val\"" 96 fi 97 } 98 99 # ask_yes_no "question" variable_name "default answer" 100 ask_yes_no () { 101 yes_no_repeat=yes 102 while [ $yes_no_repeat = yes ]; do 103 yes_no_repeat=no 104 ask "${@}" 105 eval "the_ans=\"\$$2\"" 106 echo "$the_ans" | grep -i "^`l10n_print yes`$" > /dev/null 107 if [ $? = 0 ]; then 108 eval "$2=yes" 109 return 110 fi 111 echo "$the_ans" | grep -i "^`l10n_print no`$" > /dev/null 112 if [ $? = 0 ]; then 113 eval "$2=no" 114 return 115 fi 116 l10n_print "Please answer yes or no" 117 yes_no_repeat=yes 118 done 119 } 120 121 get_req () { 122 test -r $INFOFILE && \ 123 grep -i "^$1[ ]*=[ ]*" $INFOFILE | cut -f2 -d= | tr -d ' ' 124 } 125 126 REQ_SYSTEM=`get_req system` 127 REQ_ARCH=`get_req arch` 128 REQ_RELEASE=`get_req release` 129 REQ_KERNELID=`get_req kernelid` 130 131 version_lower () { 132 declare -a version1 133 declare -a version2 134 135 IFS=' ' 136 for n in `echo $1 | sed -e 's/Generic/999999/' | tr -cs "[0-9]" "[ *]"`; do 137 version1=(${version1[*]} $n) 138 done 139 for n in `echo $2 | sed -e 's/Generic/999999/' | tr -cs "[0-9]" "[ *]"`; do 140 version2=(${version2[*]} $n) 141 done 142 143 typeset -i n=0 144 while /bin/true; do 145 if [ -n "${version1[$n]}" ]; then 146 if [ -n "${version2[$n]}" ]; then 147 if [ ${version1[$n]} -lt ${version2[$n]} ]; then 148 return 0 149 else 150 if [ ${version1[$n]} -gt ${version2[$n]} ]; then 151 return 1 152 fi 153 fi 154 else 155 return 1 156 fi 157 else 158 if [ -n "${version2[$n]}" ]; then 159 return 0 160 fi 161 return 1 162 fi 163 typeset n=$n+1 164 done 165 } 166 167 usage () { 168 echo "%s [options]" "$0" 169 l10n_print "Install the Java Desktop System, GNOME 2.17, Solaris Edition" 170 l10n_print " -h, --help display this help" 171 l10n_print " --quiet, -q less verbose operation." 172 l10n_print " --force, -f ignore any errors and continue." 173 l10n_print " --ignore, -i ignore file conflicts and continue." 174 l10n_print " -n non-interactive installation." 175 l10n_print " -R rootdir install into an alternative root directory." 176 l10n_print " -p prod1,prod2,..." 177 l10n_print " select products for installation" 178 l10n_print " -a install all products" 179 l10n_print " --nopatch don't install OS patches" 180 l10n_print " --accept accept the license terms" 181 l10n_print " --tmpdir dir create temporary files in dir instead of /tmp" 182 exit 1 183 } 184 185 QUIET=no 186 FORCE=no 187 IGNORE_CONFLICT=no 188 INTERACTIVE=yes 189 ROOTDIR= 190 PRODUCTS= 191 NO_PATCHES=no 192 BASE_TEMPDIR=/tmp 193 LICENSE_ACCEPTED=yes 194 195 process_options () { 196 while [ $# != 0 ]; do 197 case "$1" in 198 --help | -h ) 199 usage 200 ;; 201 --quiet | -q ) 202 QUIET=yes 203 ;; 204 --force | -f ) 205 FORCE=yes 206 ;; 207 --ignore | -i ) 208 IGNORE_CONFLICT=yes 209 ;; 210 -R ) 211 shift 212 ROOTDIR=$1 213 if [ "x$ROOTDIR" = x ]; then 214 l10n_print "Option %s requires an argument" "-R" 215 usage 216 fi 217 ;; 218 -n ) 219 INTERACTIVE=no 220 ;; 221 -a ) 222 select_all_products 223 unselect_all_srcs 224 unselect_product nodist 225 ;; 226 --accept ) 227 LICENSE_ACCEPTED=yes 228 ;; 229 -p ) 230 shift 231 PRODUCTS="$1" 232 if [ "x$PRODUCTS" = x ]; then 233 l10n_print "Option %s requires an argument" "-R" 234 usage 235 fi 236 ;; 237 --tmpdir ) 238 shift 239 BASE_TEMPDIR="$1" 240 if [ "x$BASE_TEMPDIR" = x ]; then 241 l10n_print "Option %s requires an argument" "--tmpdir" 242 usage 243 fi 244 ;; 245 --nopatch ) 246 NO_PATCHES=yes 247 ;; 248 * ) 249 l10n_print "Error: %s: invalid argument" "$1" 250 usage 251 ;; 252 esac 253 shift 254 done 255 } 256 257 logrun () { 258 status_file=/tmp/.command_status.$$ 259 rm -f $status_file 260 echo "running $*" >> $LOGFILE 261 echo "*** command output follows ***" >> $LOGFILE 262 if [ "x$QUIET" = xno ]; then 263 ( "${@}" 2>&1 ; echo $? > $status_file ) | tee -a $LOGFILE 264 else 265 ( "${@}" 2>&1 ; echo $? > $status_file ) >> $LOGFILE 266 fi 267 echo "*** command output ends ***" >> $LOGFILE 268 status=`cat $status_file` 269 rm -f $status_file 270 return $status 271 } 272 273 backup () { 274 if [ -e "$1" ]; then 275 backup "$1~" 276 l10n_print "Saving file %s as %s~" "$1" "$1" 277 mv "$1" "$1~" || msg_fatal "Failed to back up file %s" "$1" 278 fi 279 } 280 281 clean_up () { 282 if [ "x$ADMIN_CREATED" = xyes ]; then 283 rm -f $ADMIN 284 fi 285 cd / 286 rm -rf $TEMPDIR 287 } 288 289 clean_up_and_abort () { 290 clean_up 291 l10n_print "Interrupted." 292 exit 1 293 } 294 295 TEXTDOMAIN=install-jds 296 l10n_print () { 297 l10n_msg=`TEXTDOMAINDIR="$MYDIR"/.install gettext -d "$TEXTDOMAIN" "$1"` 298 shift 299 printf "$l10n_msg\n" "${@}" 300 } 301 302 msg_fatal () { 303 msg_log "${@}" 304 l10n_print "${@}" 1>&2 305 clean_up 306 exit 1 307 } 308 309 msg_error () { 310 msg_log "${@}" 311 l10n_print "${@}" 1>&2 312 if [ $FORCE = no ]; then 313 if [ "x$INTERACTIVE" = xyes ]; then 314 ask_yes_no "`l10n_print 'Would you like to continue?'`" ans \ 315 `l10n_print "no"` 316 if [ "x$ans" = xno ]; then 317 clean_up 318 exit 1 319 fi 320 WARNINGS=yes 321 else 322 clean_up 323 exit 1 324 fi 325 else 326 WARNINGS=yes 327 fi 328 } 329 330 msg_log () { 331 test -f $LOGFILE || return 332 log_arg1="$1" 333 shift 334 printf "$log_arg1\n" "${@}" >> $LOGFILE 335 } 336 337 WARNINGS=no 338 msg_warning () { 339 l10n_print "${@}" 340 WARNINGS=yes 341 } 342 343 # check_disk_space directory minsize(kB) 344 check_disk_space () { 345 dir_to_check="$ROOTDIR$1" 346 while [ ! -d $dir_to_check ]; do 347 dir_to_check="`dirname $dir_to_check`" 348 done 349 freespace=`df -k "$dir_to_check" | awk '!/Filesystem/ {print $4}'` 350 if [ $freespace -le $2 ]; then 351 return 1 352 fi 353 354 return 0 355 } 356 357 # so_disk_space_check prodname 358 so_disk_space_check () { 359 # Need large tmp area (>=1GB) for StarOffice/StarSuite installation. 360 check_disk_space $TEMPDIR 1048576 || \ 361 msg_error "Your %s directory has less than 1GB free.\nYou need to specify an alternative temp dir with the --tmpdir switch." "$BASE_TEMPDIR" 362 } 363 364 init () { 365 USER_IS_ROOT=0 366 /usr/bin/id | /usr/bin/grep '^uid=0(' > /dev/null 2>&1 367 368 if [ $? != 0 ]; then 369 msg_fatal "Only root can install this product." 370 fi 371 372 if [ $FORCE = no ]; then 373 trap clean_up_and_abort HUP INT TERM 374 else 375 trap clean_up_and_abort HUP INT TERM ERR 376 fi 377 378 trap clean_up QUIT EXIT 379 } 380 381 write_admin () { 382 backup "$ADMIN" 383 ADMIN_CREATED=yes 384 cat > $ADMIN << EOF 385 mail= 386 instance=unique 387 runlevel=nocheck 388 setuid=nocheck 389 action=nocheck 390 partial=quit 391 idepend=nocheck 392 rdepend=nocheck 393 space=quit 394 EOF 395 396 if [ $IGNORE_CONFLICT = no ]; then 397 cat >> $ADMIN << EOF_2 398 conflict=quit 399 EOF_2 400 else 401 cat >> $ADMIN << EOF_3 402 conflict=nocheck 403 EOF_3 404 fi 405 } 406 407 declare -a MOUNT_POINTS 408 declare -a MP_SUMS 409 disk_usage_init () { 410 mps=`df -kl | grep '^/' | awk '{print $6}' | sort -r` 411 IFS=" 412 " 413 typeset -i i=0 414 for mp in $mps; do 415 MOUNT_POINTS[$i]="$mp" 416 MP_SUMS[$i]=0 417 typeset i=$i+1 418 done 419 MOUNT_POINT_COUNT=$i 420 } 421 422 # disk_usage_add <dir> <size> 423 disk_usage_add () { 424 typeset -i i=0 425 while [ $i -lt $MOUNT_POINT_COUNT ]; do 426 mpname=${MOUNT_POINTS[$i]} 427 case $1 in 428 ${mpname}* ) 429 mpsize=${MP_SUMS[$i]} 430 mpsize=`expr $mpsize + $2` 431 MP_SUMS[$i]=$mpsize 432 break 433 ;; 434 esac 435 typeset i=$i+1 436 done 437 } 438 439 disk_usage_check () { 440 typeset -i i=0 441 while [ $i -lt $MOUNT_POINT_COUNT ]; do 442 mpname=${MOUNT_POINTS[$i]} 443 mpsize=${MP_SUMS[$i]} 444 mpsize=`expr $mpsize + $mpsize` 445 if [ $mpsize -gt 0 ]; then 446 check_disk_space $mpname $mpsize || \ 447 msg_error "Your %s filesystem has less than %s kB free\nYou will not be able to install JDS." "$ROOTDIR$mpname" "$mpsize" 448 fi 449 typeset i=$i+1 450 done 451 } 452 453 #install_pkgs <dir> 454 install_product () { 455 ORDERFILE=$MYDIR/$1/.pkgorder 456 if [ -r $ORDERFILE ]; then 457 export IFS=' ' 458 ALL_PKGS=$(echo $(cat $ORDERFILE | sed -e 's/$/.tar.gz/')) 459 else 460 ALL_PKGS=$(cd $MYDIR/$1; find . -name '*.tar.gz' -print -o -name '*.tgz' -print) 461 fi 462 463 if [ -z "$ALL_PKGS" ]; then 464 msg_error "No packages found." 465 return 466 fi 467 468 msg_log "Starting installation of %s at %s" "$1" "`LANG=C LC_ALL=C date`" 469 IFS=' 470 ' 471 472 # Remove old Mozilla 1.x packages. 473 if [ $1 == 'firefox' -o $1 == 'thunderbird' ]; then 474 moz_pkgs="SUNWmozspell 475 SUNWmozpsm 476 SUNWmoznss-devel 477 SUNWmoznss 478 SUNWmoznspr-devel 479 SUNWmozmail 480 SUNWmozjs-debugger 481 SUNWmozilla-devel 482 SUNWmozgm 483 SUNWmozdom-inspector 484 SUNWmozchat 485 SUNWmozilla 486 SUNWmoznspr 487 SUNWmoznav 488 SUNWthunderbird-devel" 489 for moz_pkg in $moz_pkgs; do 490 is_installed "$moz_pkg" && remove_pkg "$moz_pkg" 491 done 492 fi 493 494 # Remove evolution-socs-connect packages as they are incompatible with 495 # evolution-jescs (connector for Java Enterprise System Calendar Server) 496 if [ $1 == 'evolution' ]; then 497 evo_pkgs="SUNWevolution-socs-connect 498 SUNWevolution-socs-connect-share" 499 for evo_pkg in $evo_pkgs; do 500 is_installed "$evo_pkg" && remove_pkg "$evo_pkg" 501 done 502 fi 503 504 logrun mkdir -p $TEMPDIR || \ 505 msg_fatal "ERROR: Failed to create temporary directory %s" "$TEMPDIR" 506 cd $TEMPDIR 507 for pkg in $ALL_PKGS; do 508 if [ ! -r $MYDIR/$1/$pkg ]; then 509 msg_error "ERROR: cannot read file %s" "$pkg" 510 continue 511 fi 512 logrun sh -c "gunzip -c $MYDIR/$1/$pkg | /bin/tar xf -" 513 if [ $? != 0 ]; then 514 msg_error "ERROR: Failed to unpack %s" "$pkg" 515 continue 516 fi 517 pkg0=$(basename $pkg) 518 pkg0=$(echo "$pkg0" | sed -e 's/\.tar.gz$//' -e 's/\.tgz$//') 519 if [ ! -d $pkg0 ]; then 520 msg_error "ERROR: Package %s not found in %s" "$pkg0" "$pkg" 521 continue 522 fi 523 if [ "x$QUIET" = xno ]; then 524 l10n_print "Installing package %s" "$pkg0" 525 fi 526 msg_log "Installing package $pkg0" 527 if [ "x$ROOTDIR" != "x" ]; then 528 logrun $PKGADD -R "$ROOTDIR" -a $ADMIN -n -d $TEMPDIR $pkg0 || \ 529 msg_error "ERROR: Failed to install package %s" "$pkg0" 530 else 531 logrun $PKGADD -a $ADMIN -n -d $TEMPDIR $pkg0 || \ 532 msg_error "ERROR: Failed to install package %s" "$pkg0" 533 fi 534 logrun rm -rf $TEMPDIR/$pkg0 535 done 536 } 537 538 remove_pkg () { 539 if [ "x$QUIET" = xno ]; then 540 l10n_print "Uninstalling %s" "$1" 541 fi 542 msg_log "Uninstalling %s" "$1" 543 if [ "x$ROOTDIR" != x ]; then 544 logrun $PKGRM -R "$ROOTDIR" -a $ADMIN -n "$1"'.*' || \ 545 msg_error "ERROR: Failed to remove package %s" "$1" 546 else 547 logrun $PKGRM -a $ADMIN -n "$1"'.*' || \ 548 msg_error "ERROR: Failed to remove package %s" "$1" 549 fi 550 } 551 552 is_installed () { 553 $PKGINFO -q "$1.*" 554 } 555 556 remove_always () { 557 pkgs_to_remove="`cat $MYDIR/$1/.remove-always`" 558 559 IFS=" 560 " 561 for glob in "$pkgs_to_remove"; do 562 pkgs=$(cd $MYDIR/$1; echo $glob) 563 for pkg in $pkgs; do 564 pkg=`basename $pkg` 565 pkg=`basename $pkg .tar.gz` 566 pkg=`basename $pkg .tgz` 567 is_installed "$pkg" && remove_pkg "$pkg" 568 done 569 done 570 } 571 572 remove_if_older () { 573 pkgs_to_remove="`cat $MYDIR/$1/.remove-if-older`" 574 575 IFS=" 576 " 577 for glob in $pkgs_to_remove; do 578 pkgs=$(cd $MYDIR/$1; echo "$glob") 579 for pkg in $pkgs; do 580 pkg=`basename $pkg .tar.gz` 581 pkg=`basename $pkg .tgz` 582 remove_pkg $pkg 583 done 584 done 585 } 586 587 main_menu () { 588 while /bin/true; do 589 clear 590 echo ",--------------------------------------------------------------------------" 591 echo "| 1) " `l10n_print "Default Installation"` 592 echo "| 2) " `l10n_print "Custom Installation"` 593 echo "|" 594 echo "| X) " `l10n_print "Exit"` 595 echo "|" 596 ask '`---> '"`l10n_print 'Please select:'`" "menu_sel" "1" 597 case $menu_sel in 598 1) 599 if [ "x$PRODUCTS" = x ]; then 600 select_all_products 601 unselect_all_srcs 602 unselect_product nodist 603 fi 604 do_install || return $? 605 break 606 ;; 607 2) 608 custom_menu || return $? 609 ;; 610 x|X) 611 return 2 612 ;; 613 *) 614 l10n_print "Invalid selection" 615 sleep 1 616 esac 617 done 618 return 0 619 } 620 621 custom_menu () { 622 while /bin/true; do 623 clear 624 echo ",--------------------------------------------------------------------------" 625 echo "| 1) " `l10n_print "Install All Products"` 626 echo "| 2) " `l10n_print "Select Products to Install"` 627 if [ ! -z "$PATCHDIRS" ]; then 628 echo "| 3) " `l10n_print "Select Patches to Install"` 629 fi 630 echo "|" 631 echo "| I) " `l10n_print "Start Installation"` 632 echo "| X) " `l10n_print "Exit"` 633 echo "|" 634 ask '`---> '"`l10n_print 'Please select:'`" "menu_sel" "I" 635 case $menu_sel in 636 1) 637 select_all_products 638 unselect_all_srcs 639 unselect_product nodist 640 select_all_patches 641 do_install || return $? 642 return 1 643 ;; 644 2) 645 select_product_menu || return $? 646 ;; 647 3) 648 if [ ! -z "$PATCHDIRS" ]; then 649 select_patchdir_menu || return $? 650 else 651 l10n_print "Invalid selection" 652 sleep 1 653 fi 654 ;; 655 i|I) 656 do_install || return $? 657 return 1 658 ;; 659 x|X) 660 return 2 661 ;; 662 *) 663 l10n_print "Invalid selection" 664 sleep 1 665 esac 666 done 667 return 0 668 } 669 670 so_menu () { 671 while /bin/true; do 672 clear 673 echo ",--------------------------------------------------------------------------" 674 echo "| 1) StarOffice" 675 echo "| 2) StarSuite" 676 echo "|" 677 echo "| X) " `l10n_print "Exit"` 678 echo "|" 679 ask '`---> '"`l10n_print 'Please select:'`" "menu_sel" "1" 680 case $menu_sel in 681 1) 682 unselect_product starsuite 683 return 0 684 ;; 685 2) 686 unselect_product staroffice 687 return 0 688 ;; 689 x|X) 690 return 2 691 ;; 692 *) 693 l10n_print "Invalid selection" 694 sleep 1 695 esac 696 done 697 return 0 698 } 699 700 select_patchdir_menu () { 701 IFS=, 702 while /bin/true; do 703 clear 704 echo ",--------------------------------------------------------------------------" 705 typeset -i N=1 706 707 for pdir in $PATCHDIRS; do 708 pname=`echo "$ALL_PATCHDIRS" | grep "^$pdir=" | cut -f2- -d= | cut -c-60` 709 n=`echo " $N" | sed -e 's/^.*\(..\)$/\1/'` 710 pn=$(echo $pdir | cut -f2 -d-) 711 eval "plist=\"\$ALL_${pn}_PATCHES\"" 712 eval "patch_${N}_list=\"$plist\"" 713 patches_are_selected "$plist" 714 res=$? 715 if [ $res = 0 ]; then 716 echo "| $n) [x] $pname" 717 eval "patch_${N}_selected=1" 718 elif [ $res = 1 ]; then 719 echo "| $n) [:] $pname" 720 eval "patch_${N}_selected=0" 721 else 722 echo "| $n) [ ] $pname" 723 eval "patch_${N}_selected=0" 724 fi 725 typeset N=$N+1 726 done 727 echo "|" 728 echo "| A) " `l10n_print "Select All"` 729 echo "| U) " `l10n_print "Unselect All"` 730 echo "|" 731 echo "| S) " `l10n_print "Select individual patches"` 732 echo "| I) " `l10n_print "Start Installation"` 733 echo "| R) " `l10n_print "Return to previous menu"` 734 echo "| X) " `l10n_print "Exit"` 735 echo "|" 736 ask '`---> '"`l10n_print 'Enter item to select/unselect:'`" "menu_sel" "R" 737 case $menu_sel in 738 i|I) 739 do_install || return $? 740 return 1 741 ;; 742 x|X) 743 return 2 744 ;; 745 r|R) 746 return 0 747 ;; 748 a|A) 749 select_all_patches 750 ;; 751 s|S) 752 select_patch_menu || return $? 753 ;; 754 u|U) 755 PATCHES= 756 ;; 757 *) 758 eval "the_patches=\$patch_${menu_sel}_list" 759 if [ -z "$the_patches" ]; then 760 l10n_print "Invalid selection" 761 sleep 1 762 else 763 eval "is_sel=\$patch_${menu_sel}_selected" 764 if [ "x$is_sel" = x1 ]; then 765 unselect_patches "$the_patches" 766 else 767 select_patches "$the_patches" 768 fi 769 fi 770 esac 771 done 772 } 773 774 PATCH_INFO_LOADED=no 775 load_patch_info () { 776 test "x$PATCH_INFO_LOADED" = "xyes" && return 777 IFS=, 778 for p in $1; do 779 test -z "$p" && continue 780 mkdir -p $TEMPDIR/patchdesc 781 cd $TEMPDIR/patchdesc 782 unzip $MYDIR/$p */README.* > /dev/null 2>&1 783 dummy=`basename $p .zip` 784 pdesc=`grep '^Synopsis:' */README.* | head -1 | cut -f2- -d:` \ 785 > /dev/null 2>&1 786 if [ "x$pdesc" = x ]; then 787 pdesc="Patch $dummy" 788 fi 789 dummy=`echo $dummy | cut -f1 -d-` 790 eval "PATCH_DESC_${dummy}=\"$pdesc\"" 791 cd / 792 rm -rf $TEMPDIR/patchdesc 793 cd $TEMPDIR 794 done 795 PATCH_INFO_LOADED=yes 796 } 797 798 select_patch_menu () { 799 load_patch_info "$ALL_PATCHES" 800 IFS=, 801 while /bin/true; do 802 clear 803 echo ",--------------------------------------------------------------------------" 804 typeset -i N=1 805 806 for ps in $ALL_PATCHES; do 807 test -z "$ps" && continue 808 pbn=`basename $ps` 809 pnum=`basename $pbn .zip` 810 pbn=`echo $pbn | cut -f1 -d-` 811 eval "pname=\$PATCH_DESC_${pbn}" 812 pcat=`echo "$ps" | cut -f1 -d/ | cut -f2 -d-` 813 n=`echo " $N" | sed -e 's/^.*\(..\)$/\1/'` 814 pn=$(echo $pdir | cut -f2 -d-) 815 eval "patch_${N}_name=\"$ps\"" 816 patch_is_selected "$ps" 817 res=$? 818 if [ $res = 0 ]; then 819 echo "| $n) [x] ($pcat) $pnum: $pname" 820 eval "patch_${N}_selected=1" 821 else 822 echo "| $n) [ ] ($pcat) $pnum: $pname" 823 eval "patch_${N}_selected=0" 824 fi 825 typeset N=$N+1 826 done 827 echo "|" 828 echo "| A) " `l10n_print "Select All"` 829 echo "| U) " `l10n_print "Unselect All"` 830 echo "|" 831 echo "| I) " `l10n_print "Start Installation"` 832 echo "| R) " `l10n_print "Return to previous menu"` 833 echo "| X) " `l10n_print "Exit"` 834 echo "|" 835 ask '`---> '"`l10n_print 'Enter item to select/unselect:'`" "menu_sel" "R" 836 case $menu_sel in 837 i|I) 838 do_install || return $? 839 return 1 840 ;; 841 x|X) 842 return 2 843 ;; 844 r|R) 845 return 0 846 ;; 847 a|A) 848 select_all_patches 849 ;; 850 s|S) 851 select_patch_menu || return $? 852 ;; 853 u|U) 854 PATCHES= 855 ;; 856 *) 857 eval "the_patch=\$patch_${menu_sel}_name" 858 if [ -z "$the_patch" ]; then 859 l10n_print "Invalid selection" 860 sleep 1 861 else 862 eval "is_sel=\$patch_${menu_sel}_selected" 863 if [ "x$is_sel" = x1 ]; then 864 unselect_patches "$the_patch" 865 else 866 select_patches "$the_patch" 867 fi 868 fi 869 esac 870 done 871 } 872 873 select_product_menu () { 874 IFS=" 875 " 876 save_PR="$PRODUCTS" 877 select_all_products 878 AP="$PRODUCTS" 879 PRODUCTS="$save_PR" 880 while /bin/true; do 881 clear 882 echo ",--------------------------------------------------------------------------" 883 typeset -i N=1 884 885 for prod in $AP; do 886 prodname=`echo "$ALL_PRODUCTS" | grep "^$prod=" | cut -f2- -d= | cut -c-60` 887 if [ -z "$prodname" ]; then 888 prodname=$prod 889 fi 890 n=`echo " $N" | sed -e 's/^.*\(..\)$/\1/'` 891 eval "prod_${N}_name=\"$prod\"" 892 product_is_selected $prod 893 if [ $? = 0 ]; then 894 echo "| $n) [x] "`l10n_print "$prodname"` 895 eval "prod_${N}_selected=1" 896 else 897 echo "| $n) [ ] "`l10n_print "$prodname"` 898 eval "prod_${N}_selected=0" 899 fi 900 typeset N=$N+1 901 done 902 echo "|" 903 echo "| A) " `l10n_print "Select All"` 904 echo "| U) " `l10n_print "Unselect All"` 905 echo "|" 906 echo "| I) " `l10n_print "Start Installation"` 907 echo "| R) " `l10n_print "Return to previous menu"` 908 echo "| X) " `l10n_print "Exit"` 909 echo "|" 910 ask '`---> '"`l10n_print 'Enter item to select/unselect:'`" "menu_sel" "R" 911 case $menu_sel in 912 i|I) 913 do_install || return $? 914 return 1 915 ;; 916 x|X) 917 return 2 918 ;; 919 r|R) 920 return 0 921 ;; 922 a|A) 923 select_all_products 924 ;; 925 u|U) 926 PRODUCTS= 927 ;; 928 *) 929 eval "the_name=\$prod_${menu_sel}_name" 930 if [ -z "$the_name" ]; then 931 l10n_print "Invalid selection" 932 sleep 1 933 else 934 eval "is_sel=\$prod_${menu_sel}_selected" 935 if [ "x$is_sel" = x1 ]; then 936 unselect_product $the_name 937 else 938 select_product $the_name 939 fi 940 fi 941 esac 942 done 943 } 944 945 install_patch () { 946 mkdir -p $TEMPDIR/patchinst || return 1 947 rm -rf $TEMPDIR/patchinst/* || return 1 948 cd $TEMPDIR/patchinst || return 1 949 unzip $MYDIR/$1 > /dev/null 2>&1 || return 1 950 if [ "x$QUIET" = xno ]; then 951 l10n_print "Installing patch %s" "$1" 952 fi 953 IFS=" " 954 if [ "x$ROOTDIR" = x ]; then 955 logrun $PATCHADD * || return 1 956 else 957 logrun $PATCHADD -R "$ROOTDIR" * || return 1 958 fi 959 rm -rf $TEMPDIR/patchinst/* || return 1 960 cd / 961 } 962 963 do_install_patches () { 964 IFS=, 965 if [ ! -z "$PATCHES" ]; then 966 l10n_print "Installing required patches..." 967 fi 968 for p in $PATCHES; do 969 test -z "$p" && continue 970 # Skip if patch already applied. 971 patchnum=`basename $p .zip` 972 # Remove 'T' t-patch prefix if present. showrev doesn't show it. 973 patchnum=`echo $patchnum | sed 's/^T//'` 974 if [ -z "`showrev -p | awk '{print $2}' | /usr/bin/grep -s $patchnum`" ]; then 975 install_patch $p || \ 976 msg_error "Failed to install patch %s" "$p" 977 fi 978 done 979 } 980 981 do_install () { 982 if [ "x$PRODUCTS" = x -a "x$PATCHES" = x ]; then 983 msg_fatal "No products selected." 984 fi 985 so=ok 986 product_is_selected staroffice && product_is_selected starsuite && \ 987 so=not_ok 988 if [ x$so = xnot_ok ]; then 989 if [ "x$INTERACTIVE" = "xyes" ]; then 990 so_menu || return $? 991 else 992 msg_fatal "You cannot select both StarOffice and StarSuite" 993 fi 994 fi 995 996 l10n_print "Checking for sufficient disk space..." 997 disk_usage_init 998 IFS=, 999 for prod in $PRODUCTS; do 1000 test -z "$prod" && continue 1001 if [ ! -r "$prod/.pkgsize" ]; then 1002 msg_warning "WARNING: disk space usage information missing from directory %s" "$prod" 1003 continue 1004 fi 1005 exec < "$prod/.pkgsize" 1006 while read line; do 1007 the_dir=`echo "$line" | cut -f3- -d' '` 1008 the_size=`echo "$line" | cut -f2 -d' '` 1009 disk_usage_add "$ROOTDIR$the_dir" "$the_size" 1010 done 1011 exec <& 1 1012 done 1013 1014 clear 1015 product_is_selected staroffice && so_disk_space_check StarOffice 1016 product_is_selected starsuite && so_disk_space_check StarSuite 1017 1018 disk_usage_check 1019 1020 l10n_print "Removing older versions of JDS packages..." 1021 1022 l10n_print "Determining package installation order..." 1023 1024 backup $LOGFILE 1025 echo "JDS Installation Log opened at `LANG=C LC_ALL=C date`" > $LOGFILE 1026 1027 do_install_patches 1028 1029 IFS=, 1030 for prod in $PRODUCTS; do 1031 test -z "$prod" && continue 1032 if [ ! -d "$MYDIR/$prod" ]; then 1033 msg_warning "Product %s not found in the install image" "$prod" 1034 continue 1035 fi 1036 prodname=`echo "$ALL_PRODUCTS" | grep "^$prod=" | cut -f2- -d=` 1037 if [ -z "$prodname" ]; then 1038 prodname=$prod 1039 fi 1040 if [ "x$QUIET" = xno ]; then 1041 echo 1042 echo ------------------------------------------------- 1043 fi 1044 lprodname=$(l10n_print "$prodname") 1045 l10n_print "Installing Product \"%s\"" "$lprodname" 1046 if [ -r "$MYDIR/$prod/.remove-always" ]; then 1047 remove_always $prod 1048 fi 1049 # if [ -r "$MYDIR/$prod/.remove-if-older" ]; then 1050 # remove_if_older $prod 1051 # fi 1052 install_product $prod 1053 done 1054 } 1055 1056 product_is_selected () { 1057 echo ",$PRODUCTS," | grep ",$1," > /dev/null 2>&1 1058 } 1059 1060 # Examine LANG variable to determine whether to select StarOffice or StarSuite. 1061 staroffice_or_starsuite() { 1062 if [ -n "$LANG" ] 1063 then 1064 # Japan, China, Taiwan and Korean get StarSuite. 1065 case `echo $LANG | cut -c1,2` in 1066 ja|zh|tw|ko) return 0;; 1067 esac 1068 fi 1069 1070 # If not set assume it is not Asian and therefore use StarOffice. 1071 return 1 1072 } 1073 1074 select_product () { 1075 test -z "$1" && return 1 1076 product_is_selected $1 1077 if [ $? != 0 ]; then 1078 PRODUCTS="$PRODUCTS,$1" 1079 fi 1080 } 1081 1082 unselect_product () { 1083 test -z "$1" && return 1 1084 product_is_selected $1 1085 if [ $? = 0 ]; then 1086 PRODUCTS=`echo ",$PRODUCTS," | sed -e "s/,$1,/,/" -e 's/^,//' -e 's/,$//'` 1087 fi 1088 } 1089 1090 unselect_all_srcs () { 1091 IFS=" 1092 " 1093 for src in `echo "$ALL_PRODUCTS" | grep -- '-src$' | cut -f1 -d=`; do 1094 unselect_product $src 1095 done 1096 for src in `echo "$ALL_PRODUCTS" | grep -- '-src=' | cut -f1 -d=`; do 1097 unselect_product $src 1098 done 1099 } 1100 1101 select_all_products () { 1102 IFS=" 1103 " 1104 PRODUCTS=`echo "$ALL_PRODUCTS" | cut -f1 -d=` 1105 PRODUCTS=`echo $PRODUCTS | sed -e 's/ /,/g'` 1106 IFS=, 1107 for prod in $PRODUCTS; do 1108 test ! -d $MYDIR/$prod && unselect_product $prod 1109 done 1110 1111 # Decide between StarOffice and StarSuite and unselect the other if 1112 # it is selected. 1113 # FIXME: Disable for now as it will not be needed on final media. 1114 # staroffice_or_starsuite 1115 # if [ $? -eq 1 ] 1116 # then 1117 # product_is_selected starsuite && unselect_product starsuite 1118 # else 1119 # product_is_selected staroffice && unselect_product staroffice 1120 # fi 1121 1122 } 1123 1124 find_patches () { 1125 if [ -r "$MYDIR/$1/.patchorder" ]; then 1126 IFS=' 1127 ' 1128 echo `cat "$MYDIR/$1/.patchorder" | sed -e "s%^%$1/%"` | \ 1129 sed -e 's% %,%g' 1130 return 0 1131 fi 1132 dummy=$(cd $MYDIR; echo $1/*.zip) 1133 echo "$dummy" | grep '\*' > /dev/null 1134 if [ $? != 0 ]; then 1135 echo "$dummy" | sed -e 's/ /,/g' 1136 return 0 1137 else 1138 return 1 1139 fi 1140 } 1141 1142 select_all_patches () { 1143 IFS=" 1144 " 1145 PD=`echo "$ALL_PATCHDIRS" | cut -f1 -d=` 1146 PD=`echo $PD | sed -e 's/ /,/g'` 1147 IFS=, 1148 PATCHES= 1149 PATCHDIRS= 1150 for pd in $PD; do 1151 if [ -d $MYDIR/$pd ]; then 1152 dname=`echo "$pd" | cut -f2 -d-` 1153 dummy=`find_patches $pd` && PATCHDIRS="$PATCHDIRS,$pd" && \ 1154 select_patches "$dummy" && \ 1155 eval "ALL_${dname}_PATCHES=\"$dummy\"" 1156 fi 1157 done 1158 PATCHDIRS=`echo "$PATCHDIRS" | cut -c2-` 1159 ALL_PATCHES="$PATCHES" 1160 } 1161 1162 patch_is_selected () { 1163 echo ",$PATCHES," | grep ",$1," > /dev/null 2>&1 1164 } 1165 1166 select_patches () { 1167 test -z "$1" && return 1 1168 IFS=, 1169 for p in $1; do 1170 patch_is_selected $p 1171 if [ $? != 0 ]; then 1172 PATCHES="$PATCHES,$p" 1173 fi 1174 done 1175 } 1176 1177 unselect_patches () { 1178 test -z "$1" && return 1 1179 IFS=, 1180 for p in $1; do 1181 patch_is_selected $p 1182 if [ $? = 0 ]; then 1183 PATCHES=`echo ",$PATCHES," | sed -e "s%,$p,%,%" -e 's%^,%%' -e 's%,$%%'` 1184 fi 1185 done 1186 } 1187 1188 patches_are_selected () { 1189 test -z "$1" && return 2 1190 have_selected=no 1191 have_unselected=no 1192 IFS=, 1193 for p in $1; do 1194 patch_is_selected $p && have_selected=yes || have_unselected=yes 1195 done 1196 if [ "x$have_selected" = xyes -a "x$have_unselected" = xyes ]; then 1197 return 1 1198 fi 1199 if [ "x$have_unselected" = xno ]; then 1200 return 0 1201 fi 1202 return 2 1203 } 1204 1205 disclaimer_screen () { 1206 if [ "x$INTERACTIVE" = xyes ]; then 1207 l10n_print "You are about to install Sun Java Desktop System, GNOME 2.17.\nThis install will replace any old versions of the following\nproducts you may have installed on your system with the newer\nversion included in JDS: GNOME, Mozilla and Java\nMedia Framework. It may also replace the installed version\nof Java 1.4.2 if it is older than the version included in JDS." 1208 fi 1209 } 1210 1211 license_screen () { 1212 lic_file="$MYDIR/license.txt" 1213 if [ ! -z $LC_MESSAGES ] ; then 1214 language_territory_locale=$LC_MESSAGES 1215 elif [ ! -z $LC_ALL ] ; then 1216 language_territory_locale=$LC_ALL 1217 elif [ ! -z $LANG ] ; then 1218 language_territory_locale=$LANG 1219 fi 1220 language_terittory=${language_territory_locale%.*} 1221 language=${language_territory_locale%_*} 1222 1223 if [ -f "$MYDIR/.install/$language_territory_locale/license.txt" ]; then 1224 lic_file="$MYDIR/.install/$language_territory_locale/license.txt" 1225 elif [ -f "$MYDIR/.install/$language_terittory/license.txt" ]; then 1226 lic_file="$MYDIR/.install/$language_terittory/license.txt" 1227 elif [ -f "$MYDIR/.install/$language/license.txt" ]; then 1228 lic_file="$MYDIR/.install/$language/license.txt" 1229 fi 1230 if [ ! -f "$lic_file" ]; then 1231 echo "WARNING: license file missing" 1232 fi 1233 if [ "x$LICENSE_ACCEPTED" = "xyes" ]; then 1234 cat "$lic_file" 1235 return 1236 fi 1237 if [ "x$INTERACTIVE" = xyes ]; then 1238 l10n_print "Before installing you must first accept the following license" 1239 echo 1240 l10n_print "Press [ENTER] to view the license" 1241 read dummy 1242 more "$lic_file" 1243 ask "`l10n_print 'Type \"Accept\" to accept the license\nand install Sun Java Desktop System GNOME 2.17'`" ans_accept 1244 echo "$ans_accept" | grep -i "^`l10n_print 'Accept'`$" > /dev/null 1245 if [ $? != 0 ]; then 1246 l10n_print "Installation aborted" 1247 exit 1 1248 fi 1249 else 1250 l10n_print "In non-interactive mode, you must use the --accept option\nto accept the license terms" 1251 exit 1 1252 fi 1253 } 1254 1255 main () { 1256 init 1257 process_options "${@}" 1258 disclaimer_screen 1259 license_screen 1260 TEMPDIR=${BASE_TEMPDIR}/install_jds_$$.dir 1261 write_admin 1262 if [ "x$NO_PATCHES" != "xyes" ]; then 1263 select_all_patches 1264 fi 1265 if [ "x$INTERACTIVE" = "xyes" ]; then 1266 if [ -z "$PRODUCTS" ]; then 1267 select_all_products 1268 unselect_all_srcs 1269 unselect_product nodist 1270 fi 1271 main_menu || return $? 1272 else 1273 if [ -z "$PRODUCTS" ]; then 1274 select_all_products 1275 unselect_all_srcs 1276 unselect_product nodist 1277 unselect_product starsuite 1278 fi 1279 do_install || return $? 1280 fi 1281 } 1282 1283 if [ -n "$REQ_SYSTEM" -a "$REQ_SYSTEM" != "$SYSTEM" ]; then 1284 l10n_print "This product requires a %s system" "$REQ_SYSTEM" 1285 exit 1 1286 fi 1287 1288 if [ -n "$REQ_ARCH" -a "$REQ_ARCH" != "$ARCH" ]; then 1289 l10n_print "This product requires a %s architecture system" "$REQ_ARCH" 1290 exit 1 1291 fi 1292 1293 if [ -n "$REQ_RELEASE" ]; then 1294 version_lower $RELEASE $REQ_RELEASE 1295 if [ $? = 0 ]; then 1296 l10n_print "This product requires OS release %s or later" "$REQ_RELEASE" 1297 exit 1 1298 fi 1299 fi 1300 1301 if [ "$RELEASE" = "$REQ_RELEASE" -a -n "$REQ_KERNELID" ]; then 1302 version_lower $KERNELID $REQ_KERNELID 1303 if [ $? = 0 ]; then 1304 l10n_print "This product requires OS build %s or later" "$REQ_KERNELID" 1305 l10n_print "" 1306 l10n_print "You may choose to continue the installation and risk that" 1307 l10n_print "some or all of the functionality may not be available." 1308 ask_yes_no "`l10n_print 'Would you like to continue?'`" ans \ 1309 `l10n_print "no"` 1310 if [ "x$ans" = xno ]; then 1311 exit 1 1312 fi 1313 fi 1314 fi 1315 1316 main "${@}" 1317 if [ $? = 2 ]; then 1318 msg_fatal "Installation aborted" 1319 fi 1320 1321 if [ "x$WARNINGS" = xyes ]; then 1322 l10n_print "Completed with warnings. Some packages may not be installed." 1323 else 1324 l10n_print "Successfully installed all packages." 1325 fi 1326 1327 l10n_print "Installation log saved in %s" "$LOGFILE" 1328 1329 echo 1330 l10n_print "You must now reboot your computer before using the Java Desktop System" 1331