home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / ROOTDSKS.144 / COLOR144 / usr / lib / setup / cpkgtool next >
Encoding:
Text File  |  1995-02-15  |  27.7 KB  |  846 lines

  1. #!/bin/sh
  2. #
  3. # Copyright 1993, 1994 Patrick Volkerding, Moorhead, Minnesota USA
  4. # All rights reserved.
  5. #
  6. # Redistribution and use of this script, with or without modification, is 
  7. # permitted provided that the following conditions are met:
  8. #
  9. # 1. Redistributions of this script must retain the above copyright
  10. #    notice, this list of conditions and the following disclaimer.
  11. #
  12. #  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  13. #  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
  14. #  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
  15. #  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
  16. #  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17. #  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  18. #  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
  19. #  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
  20. #  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
  21. #  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. #
  23.  
  24. # Wed, 27 Apr 1994 00:06:50 -0700 (PDT)
  25. # Optimization by David Hinds.
  26.  
  27. SOURCE_DIR=/var/adm/mount
  28. umask 000
  29. ASK="tagfiles"
  30. if [ ! -d /usr/sbin ]; then # we must be on the bootdisk
  31.  TARGET_DIR=/mnt
  32.  TMP=/mnt/tmp
  33.  if mount | fgrep "on /mnt" 1> /dev/null 2>&1 ; then # good
  34.   echo > /dev/null
  35.  else # bad
  36.   echo
  37.   echo
  38.   echo "You can't run pkgtool from the rootdisk until you've mounted your Linux"
  39.   echo "partitions beneath /mnt. Here are some examples of this:"
  40.   echo
  41.   echo "If your root partition is /dev/hda1, and is using ext2fs, you would type:"
  42.   echo "mount /dev/hda1 /mnt -t ext2"
  43.   echo
  44.   echo "Then, supposing your /usr partition is /dev/hda2, you must do this:"
  45.   echo "mount /dev/hda2 /mnt/usr -t ext2"
  46.   echo
  47.   echo "Please mount your Linux partitions and then run pkgtool again."
  48.   echo
  49.   exit
  50.  fi
  51.  if [ ! -d $TMP ]; then
  52.   mkdir -p $TMP
  53.   chmod 1777 $TMP
  54.  fi
  55. else
  56.  TARGET_DIR=/
  57.  TMP=/tmp
  58. fi
  59. ADM_DIR=$TARGET_DIR/var/adm
  60. LOG=$TMP/PKGTOOL.REMOVED
  61.  
  62. keep_files() {
  63.  while read FILE ; do
  64.   if [ -f "$TARGET_DIR/$FILE" ]; then
  65.     echo "  --> $FILE was found in another package. Skipping." >> $LOG
  66.   fi
  67.  done
  68.  }
  69.  
  70. keep_links() {
  71.  while read LINK ; do
  72.   echo "Duplicate link. Not executing: $LINK" >> $LOG
  73.  done
  74. }
  75.  
  76. delete_files() {
  77.  while read FILE ; do
  78.   if [ -f "$TARGET_DIR/$FILE" ]; then
  79.     echo "  --> Deleting $FILE" >> $LOG
  80.     rm -f $TARGET_DIR/$FILE
  81.   fi
  82.  done
  83.  }
  84.  
  85. delete_links() {
  86.  while read LINK ; do
  87.   echo "Unique link. Executing: $LINK" >> $LOG
  88.  done
  89. }
  90.  
  91. # Conversion to 'comm' utility by Mark Wisdom.
  92. remove_packages() {
  93.  for package_name in $* 
  94.  do
  95.   if [ -r $ADM_DIR/packages/$package_name ]; then
  96.    dialog --title "PACKAGE REMOVAL IN PROGRESS" --infobox "Removing \
  97. package $package_name. Since each file must be checked \
  98. against the contents of every other installed package to avoid wiping out \
  99. areas of overlap, this process can take quite some time. If you'd like to \
  100. watch the progress, flip over to another virtual console and type 'tail -f \
  101. $TMP/PKGTOOL.REMOVED'." 9 60
  102.    echo "Removing package $package_name:" >> $LOG
  103.    if fgrep "./" $ADM_DIR/packages/$package_name 1> /dev/null 2>&1; then
  104.     TRIGGER=".\/"
  105.    else
  106.     TRIGGER="FILE LIST:"
  107.    fi
  108.    echo "Removing files:" >> $LOG
  109.    sed -n "/$TRIGGER/,/^$/p" < $ADM_DIR/packages/$package_name | sort -u > $TMP/delete_list
  110.    # Pat's new-new && improved pre-removal routine.
  111.    for DIR in $ADM_DIR/removed_packages $ADM_DIR/removed_scripts ; do
  112.     if [ ! -d $DIR ] ; then mkdir -p $DIR ; chmod 755 $DIR ; fi
  113.    done
  114.    mv $ADM_DIR/packages/$package_name $ADM_DIR/removed_packages 1> /dev/null 2>&1
  115.    # Look for duplicated links and leave them in place.
  116.    if [ -r $ADM_DIR/scripts/$package_name ]; then
  117.     cat $ADM_DIR/scripts/$package_name | fgrep 'rm -rf' | sort -u > $TMP/del_link_list
  118.     mv $ADM_DIR/scripts/$package_name $ADM_DIR/removed_scripts 1> /dev/null 2>&1
  119.     cat $ADM_DIR/scripts/* | fgrep 'rm -rf' | sort -u > $TMP/required_links
  120.     comm -12 $TMP/del_link_list $TMP/required_links | keep_links
  121.     comm -23 $TMP/del_link_list $TMP/required_links | delete_links
  122.     comm -23 $TMP/del_link_list $TMP/required_links > $TMP/delscript
  123.     ( cd $TARGET_DIR ; sh $TMP/delscript )
  124.     rm -f $TMP/del_link_list $TMP/required_links $TMP/delscript
  125.    fi
  126.    cat $ADM_DIR/packages/* | sort -u > $TMP/required_files
  127.    comm -12 $TMP/delete_list $TMP/required_files | keep_files
  128.    comm -23 $TMP/delete_list $TMP/required_files | delete_files
  129.    rm -f $TMP/delete_list
  130.    rm -f $TMP/required_files
  131.   else
  132.    echo "No such package: $package_name. Can't remove." >> $LOG
  133.   fi
  134.  done
  135. }
  136.  
  137. # Here, we read the list of arguments passed to the pkgtool script.
  138. if [ $# -gt 0 ]; then # there are arguments to the command
  139.  while [ $# -gt 0 ]; do
  140.   case "$1" in
  141.   "-sets")
  142.    DISK_SETS=`echo $2 | tr "[A-Z]" "[a-z]"` ; shift 2 ;;
  143.   "-source_mounted")
  144.    SOURCE_MOUNTED="always" ; shift 1 ;;
  145.   "-ignore_tagfiles")
  146.    ASK="never" ; shift 1 ;;
  147.   "-source_dir")
  148.    SOURCE_DIR=$2 ; shift 2 ;;
  149.   "-target_dir")
  150.    TARGET_DIR=$2
  151.    ADM_DIR=$TARGET_DIR/var/adm
  152.    shift 2 ;;
  153.   "-source_device")
  154.    SOURCE_DEVICE=$2 ; shift 2 ;;
  155.   esac
  156.  done
  157. else  # there were no arguments, so we'll get the needed information from the
  158.       # user and then go on.
  159.  CMD_START="true"
  160.  rm -f /tmp/SeT*
  161.  while [ 0 ]; do
  162.   dialog --title "Slackware Package Tool (pkgtool version 2.2.0)" \
  163. --menu "\nWelcome to the Slackware package tool.\n\
  164. \nWhich option would you like?\n" 17 74 6 \
  165. "Current" "Install packages from the current directory" \
  166. "Other" "Install packages from some other directory" \
  167. "Floppy" "Install packages from floppy disks" \
  168. "Remove" "Remove packages that are currently installed" \
  169. "View" "View the list of files contained in a package" \
  170. "Exit" "Exit Pkgtool" 2> /tmp/reply
  171.   if [ $? = 1 -o $? = 255 ]; then
  172.    rm -f /tmp/reply
  173.    reset
  174.    exit
  175.   fi
  176.   REPLY="`cat /tmp/reply`"
  177.   rm -f /tmp/reply
  178.   if [ "$REPLY" = "Exit" ]; then
  179.    reset
  180.    exit
  181.   fi
  182.   if [ "$REPLY" = "View" ]; then
  183.    dialog --title "SCANNING" --infobox "Please wait while \
  184. Pkgtool scans your system to determine which packages you have \
  185. installed and prepares a list for you. This will take \
  186. 1.`date +"%S"`E+`date +"%M"` BogoMipSeconds." 7 40
  187.    echo 'dialog --menu "Please select the package you wish to view." 15 55 8 \' > /tmp/viewscr
  188.    ls $ADM_DIR/packages | sed -e 's/.*/"&" "" \\/' >> /tmp/viewscr
  189.    echo "2> /tmp/return" >> /tmp/viewscr
  190.    while [ 0 ]; do
  191.     . /tmp/viewscr
  192.     if [ ! "`cat /tmp/return`" = "" ]; then
  193.      dialog --title "CONTENTS OF PACKAGE: `cat /tmp/return`" --textbox "$ADM_DIR/packages/`cat /tmp/return`" \
  194.      22 74 2> /dev/null
  195.     else
  196.      break 
  197.     fi
  198.    done
  199.    rm -f /tmp/return /tmp/viewscr /tmp/tmpmsg
  200.    chmod 755 /
  201.    chmod 1777 /tmp
  202.    continue
  203.   fi  
  204.   if [ "$REPLY" = "Remove" ]; then
  205.    dialog --title "SCANNING" --infobox "Please wait while Pkgtool scans \
  206. your system to determine  which packages you have installed and prepares \
  207. a list for you. This will take 3.`date +"%S"`E+`date +"%M"` \
  208. BogoMipSeconds." 7 40
  209.    cat << EOF > $TMP/rmscript
  210. dialog --title "SELECT PACKAGES TO REMOVE" --checklist "Please select the \
  211. packages you wish to Remove. Use the \
  212. spacebar to select packages to delete, and the UP/DOWN arrow keys to \
  213. scroll up and down through the entire list." 22 75 13 \\
  214. EOF
  215.    for name in `ls $ADM_DIR/packages` ; do
  216.     BLURB="`sed -n \"/$name:/{s/\\"//g;p;q;}\" $ADM_DIR/packages/$name | cut -b10-45`"
  217.     echo " \"$name\" \"$BLURB\" off \\" >> $TMP/rmscript
  218.    done 
  219.    echo "2> /tmp/return" >> $TMP/rmscript
  220.    cat /dev/null > $LOG
  221.    chmod 700 $TMP/rmscript
  222.    export ADM_DIR;
  223.    $TMP/rmscript
  224.    remove_packages `cat /tmp/return | tr -d "\042"`
  225.    if [ "`cat $TMP/PKGTOOL.REMOVED`" = "" ]; then
  226.     rm -f $TMP/PKGTOOL.REMOVED
  227.    else
  228.     dialog --title "PACKAGE REMOVAL COMPLETE" --msgbox "The packages have been \
  229. removed. A complete log of the files that were removed has been created \
  230. in $TMP: PKGTOOL.REMOVED. Pkgtool does not remove empty directories, so you may \
  231. want to do that yourself." 8 63
  232.    fi
  233.    rm -f $TMP/rmscript /tmp/return /tmp/tmpmsg /tmp/SeT*
  234.    chmod 755 /
  235.    chmod 1777 /tmp
  236.    dialog --clear
  237.    exit
  238.   elif [ "$REPLY" = "Floppy" ]; then
  239.    dialog --title "SELECT FLOPPY DRIVE" --menu "Which floppy drive would \
  240. you like to install from?" \
  241. 11 70 4 \
  242. "/dev/fd0H1440" "1.44 MB first floppy drive" \
  243. "/dev/fd1H1440" "1.44 MB second floppy drive" \
  244. "/dev/fd0h1200" "1.2 MB first floppy drive" \
  245. "/dev/fd1h1200" "1.2 MB second floppy drive" 2> /tmp/wdrive
  246.    if [ $? = 1 ]; then
  247.     dialog --clear
  248.     exit
  249.    fi
  250.    SOURCE_DEVICE="`cat /tmp/wdrive`"
  251.    rm -f /tmp/wdrive 
  252.    cat << EOF > /tmp/tmpmsg
  253.  
  254. Enter the names of any disk sets you would like to install.
  255. Seperate the sets with a space, like this: a b oi x
  256.  
  257. To install packages from one disk, hit [enter] without typing
  258. anything.
  259.  
  260. EOF
  261.    dialog --title "SOFTWARE SELECTION" --inputbox "`cat /tmp/tmpmsg`" 13 70 2> /tmp/sets 
  262.    DISK_SETS="`cat /tmp/sets`"
  263.    rm -f /tmp/sets
  264.    if [ "$DISK_SETS" = "" ]; then
  265.     DISK_SETS="disk"
  266.    else
  267.     DISK_SETS=`echo $DISK_SETS | sed 's/ /#/g'`
  268.     DISK_SETS="#$DISK_SETS"
  269.    fi
  270.    break;
  271.   elif [ "$REPLY" = "Other" ]; then
  272.    dialog --title "SELECT SOURCE DIRECTORY" --inputbox "Please enter the name of the directory that you wish to \
  273. install packages from:" 10 50 2> /tmp/pkgdir
  274.    if [ $? = 1 ]; then
  275.     rm -f /tmp/pkgdir /tmp/SeT*
  276.     reset
  277.     exit
  278.    fi 
  279.    SOURCE_DIR="`cat /tmp/pkgdir`"
  280.    SOURCE_MOUNTED="always"
  281.    DISK_SETS="disk" 
  282.    chmod 755 $TARGET_DIR
  283.    chmod 1777 $TARGET_DIR/tmp
  284.    rm -f /tmp/pkgdir
  285.    if [ ! -d $SOURCE_DIR ]; then
  286.     dialog --title "DIRECTORY NOT FOUND" --msgbox "The directory you want to \
  287. install from ($SOURCE_DIR) \
  288. does not seem to exist. Please check the directory and then try again." \
  289. 10 50
  290.     reset
  291.     exit
  292.    fi
  293.    break;
  294.   else # installing from current directory
  295.    SOURCE_MOUNTED="always"
  296.    SOURCE_DIR="$PWD"
  297.    DISK_SETS="disk" 
  298.    chmod 755 $TARGET_DIR
  299.    chmod 1777 $TARGET_DIR/tmp
  300.    break;
  301.   fi 
  302.  done
  303. fi
  304. if [ "$DISK_SETS" = "disk" ]; then
  305.  ASK="always"
  306. fi
  307.  
  308. for DIR in $ADM_DIR $ADM_DIR/packages $ADM_DIR/scripts $ADM_DIR/disk_contents
  309. do
  310.  if [ ! -d $DIR ]; then mkdir -p $DIR ; chmod 755 $DIR ; fi
  311. done
  312.  
  313. if [ ! -d $ADM_DIR/mount -a ! -L $ADM_DIR/mount ]; then
  314.  mkdir -p $ADM_DIR/mount ; chmod 755 $ADM_DIR/mount
  315. fi
  316.  
  317. mount_the_source() {
  318.  # is the source supposed to be mounted already?
  319.  if [ "$SOURCE_MOUNTED" = "always" ]; then
  320.   # The source should already be mounted, so we test it
  321.   if [ ! -d $SOURCE_DIR ]; then # the directory is missing
  322.    cat << EOF > /tmp/tmpmsg
  323.  
  324. Your source device cannot be accessed properly.
  325.  
  326. Please be sure that it is mounted on /var/adm/mount,
  327. and that the Slackware disks are found in subdirectories 
  328. of $SOURCE_DIR like specified.
  329.  
  330. EOF
  331.    dialog --title "MOUNT ERROR" --msgbox "`cat /tmp/tmpmsg`" 11 67
  332.    rm -f /tmp/tmpmsg
  333.    exit 1;
  334.   fi
  335.   return 0;
  336.  fi
  337.  dialog --title "INSERT DISK" --menu "Please insert disk $1 and \
  338. press ENTER to continue." \
  339. 11 50 3 \
  340. "Continue" "Continue with the installation" \
  341. "Skip" "Skip the current disk series" \
  342. "Quit" "Abort the installation process" 2> /tmp/reply
  343.  if [ $? = 1 -o $? = 255 ]; then
  344.   REPLY="Quit"
  345.  else
  346.   REPLY="`cat /tmp/reply`"
  347.  fi
  348.  rm -f /tmp/reply
  349.  if [ "$REPLY" = "Skip" ]; then
  350.   return 1;
  351.  fi
  352.  if [ "$REPLY" = "Quit" ]; then
  353.    dialog --title "ABORTING" --msgbox "Aborting software installation." 5 50
  354.    chmod 755 $TARGET_DIR
  355.    chmod 1777 $TARGET_DIR/tmp
  356.    exit 1;
  357.  fi;
  358.  # Old line:
  359.  # mount -r -t msdos $SOURCE_DEVICE $SOURCE_DIR
  360.  # New ones: (thanks to Andy Schwierskott!)
  361.  go_on=y
  362.  not_successfull_mounted=1
  363.  while [ "$go_on" = y -a "$not_successfull_mounted" = 1 ]; do
  364.   mount -r -t msdos $SOURCE_DEVICE $SOURCE_DIR
  365.   not_successfull_mounted=$?
  366.   if [ "$not_successfull_mounted" = 1 ]; then
  367.    mount_answer=x
  368.    while [ "$mount_answer" != "y" -a "$mount_answer" != "q" ] ; do
  369.     dialog --title "MOUNT PROBLEM" --menu "Media was not successfully \
  370. mounted! Do you want to \
  371. retry, or quit?" 10 60 2 \
  372. "Yes" "Try to mount the disk again" \
  373. "No" "No, abort." 2> /tmp/mntans
  374.     mount_answer="`cat /tmp/mntans`"
  375.     rm -f /tmp/mntans
  376.     if [ "$mount_answer" = "Yes" ]; then
  377.      mount_answer="y"
  378.     else
  379.      mount_answer="q"
  380.     fi
  381.    done
  382.    go_on=$mount_answer
  383.   fi
  384.  done
  385.  test $not_successfull_mounted = 0
  386. }
  387. umount_the_source() {
  388.  if [ ! "$SOURCE_MOUNTED" = "always" ]; then
  389.   umount $SOURCE_DEVICE 1> /dev/null 2>&1
  390.  fi;
  391. }
  392. # The function below installs the package with the name $CURRENT_PACKAGE_NAME
  393. # and with the DOS file extension .tgz
  394. install_the_current_package() {
  395.  rm -f $ADM_DIR/removed_packages/$CURRENT_PACKAGE_NAME
  396.  rm -f $ADM_DIR/removed_scripts/$CURRENT_PACKAGE_NAME
  397.  echo "PACKAGE NAME:     $CURRENT_PACKAGE_NAME" > $ADM_DIR/packages/$CURRENT_PACKAGE_NAME
  398.  echo "COMPRESSED PACKAGE SIZE:     $COMPRESSED" >> $ADM_DIR/packages/$CURRENT_PACKAGE_NAME
  399.  echo "UNCOMPRESSED PACKAGE SIZE:     $UNCOMPRESSED" >> $ADM_DIR/packages/$CURRENT_PACKAGE_NAME
  400.  BASE_DISK_NAME=`basename $PACKAGE_DIR/disk*`
  401.  echo "PACKAGE LOCATION: $BASE_DISK_NAME" >> $ADM_DIR/packages/$CURRENT_PACKAGE_NAME
  402. # echo "PACKAGE DESCRIPTION:" >> $ADM_DIR/packages/$CURRENT_PACKAGE_NAME
  403. # if [ -r $PACKAGE_DIR/$BASE_DISK_NAME -a ! -d $PACKAGE_DIR/$BASE_DISK_NAME ]; then
  404. #  fgrep "$CURRENT_PACKAGE_NAME:" $PACKAGE_DIR/$BASE_DISK_NAME | uniq >> $ADM_DIR/packages/$CURRENT_PACKAGE_NAME
  405. # fi
  406.  for index_file in $PACKAGE_DIR/disk* $PACKAGE_DIR/package_descriptions ; do
  407.   if [ ! "$index_file" = "$PACKAGE_DIR/disk??*" ]; then
  408.    if [ -r "$index_file" ]; then
  409.     echo "PACKAGE DESCRIPTION:" >> $ADM_DIR/packages/$CURRENT_PACKAGE_NAME
  410.     if cat $index_file | uniq | fgrep "$CURRENT_PACKAGE_NAME:" >> $ADM_DIR/packages/$CURRENT_PACKAGE_NAME 2> /dev/null ; then
  411.      break;
  412.     fi
  413.    fi
  414.   fi
  415.  done
  416.  echo "FILE LIST:" >> $ADM_DIR/packages/$CURRENT_PACKAGE_NAME
  417.  # Pat's new-new pre-install cleanup routine.
  418.  if [ -r $ADM_DIR/scripts/$CURRENT_PACKAGE_NAME -a ! -d $ADM_DIR/scripts/$CURRENT_PACKAGE_NAME ]; then
  419.   cat $ADM_DIR/scripts/$CURRENT_PACKAGE_NAME | fgrep 'rm -rf' | sort -u > $TMP/del_link_list
  420.   if [ ! -d $ADM_DIR/removed_scripts ]; then
  421.    mkdir $ADM_DIR/removed_scripts
  422.   fi
  423.   mv $ADM_DIR/scripts/$CURRENT_PACKAGE_NAME $ADM_DIR/removed_scripts 1> /dev/null 2>&1
  424.   cat $ADM_DIR/scripts/* | fgrep 'rm -rf' | sort -u > $TMP/required_links
  425.   comm -12 $TMP/del_link_list $TMP/required_links | keep_links
  426.   comm -23 $TMP/del_link_list $TMP/required_links | delete_links
  427.   comm -23 $TMP/del_link_list $TMP/required_links > $TMP/delscript
  428.   ( cd $TARGET_DIR ; sh $TMP/delscript )
  429.   rm -f $TMP/del_link_list $TMP/required_links $TMP/delscript $ADM_DIR/scripts/$CURRENT_PACKAGE_NAME
  430.  fi
  431.  # Install the package:
  432.  >$TMP/tar-error
  433.  (cd $TARGET_DIR; tar -xzlpvf - ) < $PACKAGE_DIR/$CURRENT_PACKAGE_NAME.tgz >> $ADM_DIR/packages/$CURRENT_PACKAGE_NAME 2> $TMP/tar-error
  434.  if [ ! "`filesize $TMP/tar-error`" = "0" ]; then # Package may be corrupt
  435.   dialog --title "Error installing package \
  436. $PACKAGE_DIR/$CURRENT_PACKAGE_NAME.tgz" \
  437.    --msgbox "\n\
  438. An error has occured while installing this package.  Setup\n\
  439. will attempt to continue anyway, but this is possibly a \n\
  440. SERIOUS ERROR that may cause you problems later on.  It is\n\
  441. recommended that you make sure the package is not corrupted\n\
  442. and then reinstall.  If you obtained the package via FTP, be\n\
  443. sure to use 'binary' mode for both the transfer and download\n\
  444. of the package.\n\
  445. \n\
  446. Here is the actual error message (if any):\n\
  447. `cat $TMP/tar-error` \n" 19 67
  448.  fi
  449.  chmod 644 $ADM_DIR/packages/$CURRENT_PACKAGE_NAME
  450.  if [ -f $TARGET_DIR/install/doinst.sh ]; then
  451.   # Executing installation script for package $CURRENT_PACKAGE_NAME... 
  452.   (cd $TARGET_DIR; sh $TARGET_DIR/install/doinst.sh -install; )
  453.   cp $TARGET_DIR/install/doinst.sh $ADM_DIR/scripts/$CURRENT_PACKAGE_NAME
  454.   chmod 755 $ADM_DIR/scripts/$CURRENT_PACKAGE_NAME
  455.   # Clean up the mess...
  456.   if [ -d $TARGET_DIR/install ]; then
  457.    (cd $TARGET_DIR/install ; rm -r -f doin* 1> /dev/null 2>&1 )
  458.    rmdir $TARGET_DIR/install 1> /dev/null 2>&1
  459.   fi
  460.  fi
  461.  # Now we reload the shell hash table in case we've added something useful
  462.  # to the command path:
  463.  hash -r
  464.  # Done installing package $CURRENT_PACKAGE_NAME.
  465. }
  466. install_disk() {
  467.  mount_the_source $1
  468.  if [ $? = 1 ]; then
  469.   umount_the_source;
  470.   return 1;
  471.  fi
  472.  CURRENT_DISK_NAME="$1"
  473.  PACKAGE_DIR=$SOURCE_DIR
  474.  if [ "$SOURCE_MOUNTED" = "always" -a ! "$DISK_SETS" = "disk" ]; then
  475.    PACKAGE_DIR=$PACKAGE_DIR/$1
  476.  fi
  477.  
  478.  #
  479.  # look for tagfile for this series and copy into $TMP/tagfile
  480.  #
  481.  touch $TMP/tagfile
  482.  if [ ! "$DISK_SETS" = "disk" ]; then
  483.   if [ -r /tmp/SeTtagext ]; then
  484.    if [ -r $PACKAGE_DIR/tagfile`cat /tmp/SeTtagext` ]; then
  485.     cat $PACKAGE_DIR/tagfile`cat /tmp/SeTtagext` >> $TMP/tagfile
  486.    else
  487.     if [ -r $PACKAGE_DIR/tagfile ]; then
  488.      cat $PACKAGE_DIR/tagfile >> $TMP/tagfile
  489.     fi
  490.    fi
  491.  
  492.   #
  493.   # Do we need to follow a custom path to the tagfiles?
  494.   #
  495.   elif [ -r /tmp/SeTtagpath ]; then
  496.    custom_path=`cat /tmp/SeTtagpath`
  497.    short_path=`basename $PACKAGE_DIR`
  498.  
  499.    # If tagfile exists at the specified custom path, copy it over.
  500.    if [ -r $custom_path/$short_path/tagfile ]; then
  501.     cat $custom_path/$short_path/tagfile >> $TMP/tagfile
  502.  
  503.    else # well, I guess we'll use the default one then.
  504.     if [ -r $PACKAGE_DIR/tagfile ]; then
  505.      cat $PACKAGE_DIR/tagfile >> $TMP/tagfile
  506.     fi
  507.    fi
  508.   #
  509.   # We seem to be testing for this too often... maybe this code should
  510.   # be optimized a little...
  511.   # 
  512.   elif [ -r $PACKAGE_DIR/tagfile ]; then
  513.    cat $PACKAGE_DIR/tagfile >> $TMP/tagfile
  514.   fi
  515.  
  516.   #
  517.   # Execute menus if in QUICK mode:
  518.   #
  519.   if [ -r /tmp/SeTQUICK -a -r $PACKAGE_DIR/maketag ]; then
  520.    sh $PACKAGE_DIR/maketag
  521.    if [ -r /tmp/SeTnewtag ]; then
  522.     mv /tmp/SeTnewtag $TMP/tagfile
  523.    fi
  524.   fi
  525.  
  526.   #
  527.   # Protect tagfile from hacker attack:
  528.   #
  529.   if [ -r $TMP/tagfile ]; then
  530.    chmod 600 $TMP/tagfile
  531.   fi
  532.  
  533.  fi #  ! "$DISK_SETS" = "disk" 
  534.  
  535.  if [ "$1" = "single_disk" -o -r $PACKAGE_DIR/disk$1 ]; then
  536.   CATALOG_FILE=`basename $PACKAGE_DIR/disk*`;
  537.   if [ -r $PACKAGE_DIR/$CATALOG_FILE -a ! -d $PACKAGE_DIR/$CATALOG_FILE ]; then
  538.    if fgrep CONTENTS: $PACKAGE_DIR/$CATALOG_FILE 1> /dev/null 2>&1 ; then
  539.     # First we check for missing packages...
  540.     for PKGTEST in `fgrep CONTENTS: $PACKAGE_DIR/$CATALOG_FILE | cut -b10- 2> /dev/null` ; do
  541.      if [ ! -r $PACKAGE_DIR/$PKGTEST.tgz ]; then
  542.       cat << EOF > /tmp/tmpmsg
  543.  
  544. WARNING!!!
  545.  
  546. While looking through your index file ($CATALOG_FILE), I 
  547. noticed that you might be missing a package ($PKGTEST.tgz) 
  548. that is supposed to be on this disk (disk $1). You may go
  549. on with the installation if you wish, but if this is a 
  550. crucial file I'm making no promises that your machine will
  551. boot.
  552.  
  553. EOF
  554.       dialog --title "FILE MISSING FROM YOUR DISK" --msgbox \
  555. "`cat /tmp/tmpmsg`" 15 73
  556.      fi
  557.     done # checking for missing packages
  558.     # Now we test for extra packages
  559.     ALLOWED="`fgrep CONTENTS: $PACKAGE_DIR/$CATALOG_FILE | cut -b10- 2> /dev/null`" 
  560.     for PACKAGE_FILENAME in $PACKAGE_DIR/*.tgz; do
  561.      BASE="`basename $PACKAGE_FILENAME .tgz`"
  562.      if echo $ALLOWED | fgrep $BASE 1> /dev/null 2>&1 ; then
  563.       GOOD="yup yup"
  564.      else
  565.       cat << EOF > /tmp/tmpmsg
  566.  
  567. WARNING!!!
  568.  
  569. While looking through your index file ($CATALOG_FILE), I 
  570. noticed that you have this extra package ($BASE.tgz) that
  571. I don't recongnize. Please be sure this package is really
  572. supposed to be here, and is not left over from an old 
  573. version of Slackware. Sometimes this can happen at the 
  574. archive sites.
  575.  
  576. EOF
  577.       dialog --title "EXTRA FILE FOUND ON YOUR DISK" \
  578. --msgbox "`cat /tmp/tmpmsg`" 15 67 
  579.       rm -f /tmp/tmpmsg
  580.      fi
  581.     done 
  582.    fi
  583.    cat $PACKAGE_DIR/$CATALOG_FILE > $ADM_DIR/disk_contents/$CATALOG_FILE
  584.    chmod 644 $ADM_DIR/disk_contents/$CATALOG_FILE
  585.   fi
  586.   for PACKAGE_FILENAME in $PACKAGE_DIR/*.tgz; do
  587.    if [ "$PACKAGE_FILENAME" = "$PACKAGE_DIR/*.tgz" ]; then
  588.     continue;
  589.    fi
  590.    CURRENT_PACKAGE_NAME=`basename $PACKAGE_FILENAME .tgz`
  591.    AddKey=""
  592.    SkipKey=""
  593.    if [ "$ASK" = "tagfiles" ]; then # -a ! "$DISK_SETS" = "disk" ]; then
  594.     if fgrep "$CURRENT_PACKAGE_NAME:" $TMP/tagfile | sed -n '$ p' | fgrep ADD 1> /dev/null 2>&1 ; then
  595.      AddKey="ADD"
  596.     fi
  597.     if fgrep "$CURRENT_PACKAGE_NAME:" $TMP/tagfile | sed -n '$ p' | fgrep SKP 1> /dev/null 2>&1 ; then
  598.      SkipKey="SKIP"
  599.     fi
  600.    elif [ "$ASK" = "never" ]; then
  601.     AddKey="ADD"
  602.    else # ASK must equal always
  603.     ASK="always"
  604.     fi  
  605.    if [ ! "$DISK_SETS" = "disk" ]; then
  606.     if fgrep "$CURRENT_PACKAGE_NAME:" $TMP/tagfile | sed -n '$ p' | fgrep ADD > /dev/null 2> /dev/null ; then
  607.      PRIORITY="[required]"
  608.     elif fgrep "$CURRENT_PACKAGE_NAME:" $TMP/tagfile | sed -n '$ p' | fgrep REC > /dev/null 2> /dev/null ; then
  609.      PRIORITY="[recommended]"
  610.     elif fgrep "$CURRENT_PACKAGE_NAME:" $TMP/tagfile | sed -n '$ p' | fgrep OPT > /dev/null 2> /dev/null ; then
  611.      PRIORITY="[optional]"
  612.     elif fgrep "$CURRENT_PACKAGE_NAME:" $TMP/tagfile | sed -n '$ p' | fgrep SKP > /dev/null 2> /dev/null ; then
  613.      PRIORITY="[skip]"
  614.     else
  615.      PRIORITY="[unknown]"
  616.     fi
  617.    fi
  618.    PACKAGE_SIZE=`filesize $PACKAGE_FILENAME`
  619.    if [ "$AddKey" = "ADD" ]; then
  620.     # echo "Auto-installing package ==>$CURRENT_PACKAGE_NAME<==  Priority: $PRIORITY" > /tmp/tmpmsg
  621.     echo > /tmp/tmpmsg
  622.     # Print out the description text:
  623.     CATALOG_FILE=`basename $PACKAGE_DIR/disk*`;
  624. #    if [ -r $PACKAGE_DIR/$CATALOG_FILE -a ! -d $PACKAGE_DIR/$CATALOG_FILE ]; then
  625. #     fgrep "$CURRENT_PACKAGE_NAME:" $PACKAGE_DIR/$CATALOG_FILE | cut -b11- 1>> /tmp/tmpmsg 2> /dev/null ;
  626. #    else
  627.     for index_file in $PACKAGE_DIR/disk* $PACKAGE_DIR/package_descriptions ; do
  628.      if [ ! "$index_file" = "$PACKAGE_DIR/disk??*" ]; then
  629.       if [ -r "$index_file" ]; then
  630.        cat $index_file | fgrep "$CURRENT_PACKAGE_NAME:" | cut -b11- 1>> /tmp/tmpmsg 2> /dev/null 
  631.       fi
  632.      fi
  633.     done
  634. #    fi
  635.     COMPBYTES="`gzip -l $PACKAGE_DIR/$CURRENT_PACKAGE_NAME.tgz | sed -n '$ p' | cut -b1-9`"
  636.     UNCOMPBYTES="`gzip -l $PACKAGE_DIR/$CURRENT_PACKAGE_NAME.tgz | sed -n '$ p' | cut -b10-19`"
  637.     COMPRESSED="`expr $COMPBYTES / 1024` K"
  638.     UNCOMPRESSED="`expr $UNCOMPBYTES / 1024` K"
  639.     echo "Size: Compressed: $COMPRESSED, uncompressed: $UNCOMPRESSED." >> /tmp/tmpmsg
  640.     if [ ! "$PRIORITY" = "" ]; then
  641.      PMSG="  Priority: $PRIORITY"
  642.     else
  643.      PMSG=""
  644.     fi
  645.     dialog --title "Auto-installing package ==>$CURRENT_PACKAGE_NAME<==$PMSG" --infobox "`cat /tmp/tmpmsg`" 15 75
  646.     rm -f /tmp/tmpmsg
  647.     install_the_current_package;
  648.    elif [ "$SkipKey" != "SKIP" ]; then
  649.     # echo "Package Name: ==>$CURRENT_PACKAGE_NAME<==  Priority: $PRIORITY" > /tmp/tmpmsg
  650.     echo > /tmp/tmpmsg
  651.     CATALOG_FILE=`basename $PACKAGE_DIR/disk*`;
  652.     if [ -r $PACKAGE_DIR/$CATALOG_FILE -a ! -d $PACKAGE_DIR/$CATALOG_FILE ]; then
  653.      fgrep "$CURRENT_PACKAGE_NAME:" $PACKAGE_DIR/$CATALOG_FILE | cut -b11- 1>> /tmp/tmpmsg 2> /dev/null ;
  654.     fi
  655.     COMPBYTES="`gzip -l $PACKAGE_DIR/$CURRENT_PACKAGE_NAME.tgz | sed -n '$ p' | cut -b1-9`"
  656.     UNCOMPBYTES="`gzip -l $PACKAGE_DIR/$CURRENT_PACKAGE_NAME.tgz | sed -n '$ p' | cut -b10-19`"
  657.     COMPRESSED="`expr $COMPBYTES / 1024` K"
  658.     UNCOMPRESSED="`expr $UNCOMPBYTES / 1024` K"
  659.     echo "Size: Compressed: $COMPRESSED, uncompressed: $UNCOMPRESSED." >> /tmp/tmpmsg
  660.     echo >> /tmp/tmpmsg
  661.     echo "Install package $CURRENT_PACKAGE_NAME? " >> /tmp/tmpmsg
  662.     if [ ! "$PRIORITY" = "" ]; then
  663.      PMSG="  Priority: $PRIORITY"
  664.     else
  665.      PMSG=""
  666.     fi
  667.     dialog --title "Package Name: ==>$CURRENT_PACKAGE_NAME<==$PMSG" --menu "`cat /tmp/tmpmsg`" 22 75 1 \
  668. "Yes" "Install package $CURRENT_PACKAGE_NAME" \
  669. "No" "Do not install package $CURRENT_PACKAGE_NAME" \
  670. "Quit" "Abort software installation completely" 2> /tmp/reply
  671.     if [ $? = 1 -o $? = 255 ]; then
  672.      echo "No  " > /tmp/reply
  673.     fi
  674.     REPLY="`cat /tmp/reply`"
  675.     rm -f /tmp/reply /tmp/tmpmsg
  676.     if [ "$REPLY" = "Yes" ]; then
  677.      dialog --title "INSTALLING" --infobox "Installing package $CURRENT_PACKAGE_NAME" 3 50
  678.      install_the_current_package;
  679.     elif [ "$REPLY" = "Quit" ]; then
  680.      umount_the_source;
  681.      chmod 755 $TARGET_DIR
  682.      chmod 1777 $TARGET_DIR/tmp
  683.      exit 1;
  684.     elif [ "$REPLY" = "No" ]; then
  685.      dialog --title "SKIPPING PACKAGE" --infobox "Skipping package $CURRENT_PACKAGE_NAME" 3 50
  686.     fi
  687.    fi
  688.   done
  689.   OUTTAHERE="false"
  690.   if [ -r $PACKAGE_DIR/install.end ]; then
  691.    OUTTAHERE="true"
  692.   fi
  693.   umount_the_source;
  694.   if [ "$OUTTAHERE" = "true" ]; then
  695.    return 1;
  696.   fi
  697.  else
  698.   umount_the_source;
  699.   if [ ! "$SOURCE_MOUNTED" = "always" ]; then
  700.    cat << EOF > /tmp/tmpmsg
  701.  
  702. This does not look like the correct disk. You may either check to
  703. see if you've got the right disk in there ($1) and try again, or 
  704. you may skip the current disk series.
  705.  
  706. EOF
  707.    dialog --title "INCORRECT DISK INSERTED" --menu "`cat /tmp/tmpmsg`" 15 70 2 \
  708. "Retry" "Try to mount disk $1 again" \
  709. "Skip" "Skip this disk series" 2> /tmp/reply
  710.    if [ $? = 1 -o $? = 255 ]; then
  711.     rm -f /tmp/reply /tmp/tmpmsg
  712.     exit
  713.    fi
  714.    REPLY="`cat /tmp/reply`"
  715.    rm -f /tmp/reply /tmp/tmpmsg
  716.    if [ "$REPLY" = "Skip" ]; then
  717.     return 1;
  718.    else
  719.     install_disk $1;
  720.    fi
  721.   else
  722.    cat << EOF > /tmp/tmpmsg
  723. WARNING:
  724.  
  725. Can't find a disk series $SERIES_NAME in the source directory.
  726. Skipping it...
  727.  
  728. EOF
  729.    dialog --title "SELECTED SERIES NOT PRESENT" --msgbox "`cat /tmp/tmpmsg`" 10 65
  730.    rm -f /tmp/tmpmsg
  731.    return 1; 
  732.   fi 
  733.  fi;
  734. }
  735. install_disk_set() { # accepts one argument: the series name in lowercase.
  736.  SERIES_NAME=$1
  737.  CURRENT_DISK_NUMBER="1";
  738.  while [ 0 ]; do
  739.   install_disk $SERIES_NAME$CURRENT_DISK_NUMBER;
  740.   if [ $? = 1 -o $? = 255 ]; then # install.end was found, or the user chose
  741.         # to quit installing packages.
  742.    return 0;
  743.   fi
  744.   CURRENT_DISK_NUMBER=`expr $CURRENT_DISK_NUMBER + 1`
  745.  done;
  746. }
  747. if [ "$DISK_SETS" = "disk" ]; then
  748.  install_disk single_disk;
  749.  ASK="always"
  750. else
  751.  touch $TMP/tagfile
  752.  chmod 600 $TMP/tagfile
  753.  if echo $DISK_SETS | fgrep "#a#" 1> /dev/null 2>&1; then
  754.   A_IS_NEEDED="true"
  755.  else
  756.   A_IS_NEEDED="false"
  757.  fi
  758.  while [ 0 ];
  759.  do
  760.   while [ 0 ]; # strip leading '#'s
  761.   do
  762.    if [ "`echo $DISK_SETS | cut -b1`" = "#" ]; then
  763.     DISK_SETS="`echo $DISK_SETS | cut -b2-`"
  764.    else
  765.     break;
  766.    fi
  767.   done
  768.   if [ "$A_IS_NEEDED" = "true" ]; then
  769.    if [ "$TARGET_DIR" = "/" ]; then
  770.     dialog --title "WARNING: BIG TROUBLE DETECTED" \
  771. --menu " *** WARNING!  Reinstalling your A series to a running system \
  772. is not (yet) a good idea. It is suggested that you do not do this." \
  773. 11 70 3 \
  774. "Abort" "Abort software installation." \
  775. "Ignore" "Ignore warning and reinstall the A series anyway." \
  776. "Skip" "Skip the A series, but continue installing software." 2> /tmp/skip
  777.     if [ $? = 1 -o $? = 255 ]; then
  778.      exit
  779.     fi
  780.     WHATDO="`cat /tmp/skip`" 
  781.     rm -f /tmp/skip
  782.     if [ "$WHATDO" = "Abort" ]; then
  783.      dialog --msgbox "Aborting..." 5 30
  784.      A_IS_NEEDED="false"
  785.      DISK_SETS=""
  786.      continue;
  787.     elif [ "$WHATDO" = "Skip" ]; then
  788.      dialog --msgbox "Skipping A series..." 5 30
  789.      A_IS_NEEDED="false"
  790.      continue;
  791.     elif [ ! "$WHATDO" = "Ignore" ]; then
  792.      continue; # unknown response
  793.     fi
  794.    fi
  795.    cat << EOF > /tmp/tmpmsg
  796.  
  797. --- Installing disk series ==>a<==
  798.  
  799. EOF
  800.    dialog --infobox "`cat /tmp/tmpmsg`" 5 45
  801.    sleep 1
  802.    rm -f /tmp/tmpmsg
  803.    install_disk_set a;
  804.    A_IS_NEEDED="false"
  805.   fi
  806.   count="1"
  807.   if [ "`echo $DISK_SETS | cut -b$count`" = "" ]; then
  808.    break; # we be done here :^)
  809.   else
  810.    count="2"
  811.    while [ 0 ]; do
  812.     if [ "`echo $DISK_SETS | cut -b$count`" = "" -o "`echo $DISK_SETS | cut -b$count`" = "#" ]; then
  813.      count="`expr $count - 1`"
  814.      break;
  815.     else
  816.      count="`expr $count + 1`"
  817.     fi 
  818.    done
  819.   fi 
  820.   diskset="`echo $DISK_SETS | cut -b1-$count`"
  821.   count="`expr $count + 1`"
  822.   DISK_SETS="`echo $DISK_SETS | cut -b$count-`"
  823.   if [ "$diskset" = "a" ]; then
  824.    continue; # we expect this to be done elsewhere
  825.   fi
  826.   cat << EOF > /tmp/tmpmsg
  827.  
  828. Installing disk series ==>$diskset<==
  829.  
  830. EOF
  831.   dialog --infobox "`cat /tmp/tmpmsg`" 5 45
  832.   sleep 1
  833.   rm -f /tmp/tmpmsg
  834.   install_disk_set $diskset; 
  835.  done
  836. fi
  837.  
  838. if [ "$DISK_SETS" = "disk" -o "$CMD_START" = "true" ]; then
  839.  if [ -r $TMP/tagfile ]; then
  840.   rm $TMP/tagfile
  841.  fi
  842.  reset
  843. fi
  844. chmod 755 $TARGET_DIR $TARGET_DIR/var $TARGET_DIR/usr
  845. chmod 1777 $TARGET_DIR/tmp
  846.