home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / ROOTDSKS.12 / UMSDOS12 / usr / lib / setup / cpkgtool next >
Encoding:
Text File  |  1995-02-27  |  26.6 KB  |  808 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/linux
  32.  TMP=/mnt/linux/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 | strings | 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.  (cd $TARGET_DIR; tar -xzlpvf - ) < $PACKAGE_DIR/$CURRENT_PACKAGE_NAME.tgz >> $ADM_DIR/packages/$CURRENT_PACKAGE_NAME 2> /dev/null
  433.  chmod 644 $ADM_DIR/packages/$CURRENT_PACKAGE_NAME
  434.  if [ -f $TARGET_DIR/install/doinst.sh ]; then
  435.   # Executing installation script for package $CURRENT_PACKAGE_NAME... 
  436.   (cd $TARGET_DIR; sh $TARGET_DIR/install/doinst.sh -install; )
  437.   cp $TARGET_DIR/install/doinst.sh $ADM_DIR/scripts/$CURRENT_PACKAGE_NAME
  438.   chmod 755 $ADM_DIR/scripts/$CURRENT_PACKAGE_NAME
  439.   # Clean up the mess...
  440.   if [ -d $TARGET_DIR/install ]; then
  441.    (cd $TARGET_DIR/install ; rm -r -f doin* 1> /dev/null 2>&1 )
  442.    rmdir $TARGET_DIR/install 1> /dev/null 2>&1
  443.   fi
  444.  fi
  445.  # Now we reload the shell hash table in case we've added something useful
  446.  # to the command path:
  447.  hash -r
  448.  # Done installing package $CURRENT_PACKAGE_NAME.
  449. }
  450. install_disk() {
  451.  mount_the_source $1
  452.  if [ $? = 1 ]; then
  453.   umount_the_source;
  454.   return 1;
  455.  fi
  456.  CURRENT_DISK_NAME="$1"
  457.  PACKAGE_DIR=$SOURCE_DIR
  458.  if [ "$SOURCE_MOUNTED" = "always" -a ! "$DISK_SETS" = "disk" ]; then
  459.    PACKAGE_DIR=$PACKAGE_DIR/$1
  460.  fi
  461.  touch $TMP/tagfile
  462.  if [ ! "$DISK_SETS" = "disk" ]; then
  463.   if [ -r /tmp/SeTtagext ]; then
  464.    if [ -r $PACKAGE_DIR/tagfile`cat /tmp/SeTtagext` ]; then
  465.     cat $PACKAGE_DIR/tagfile`cat /tmp/SeTtagext` >> $TMP/tagfile
  466.    else
  467.     if [ -r $PACKAGE_DIR/tagfile ]; then
  468.      cat $PACKAGE_DIR/tagfile >> $TMP/tagfile
  469.     fi
  470.    fi
  471.   elif [ -r /tmp/SeTtagpath ]; then
  472.    custom_path=`cat /tmp/SeTtagpath`
  473.    short_path=`basename $PACKAGE_DIR`
  474.    if [ -r $custom_path/$short_path/tagfile ]; then
  475.     cat $custom_path/$short_path/tagfile >> $TMP/tagfile
  476.    else
  477.     if [ -r $PACKAGE_DIR/tagfile ]; then
  478.      cat $PACKAGE_DIR/tagfile >> $TMP/tagfile
  479.     fi
  480.    fi
  481.   elif [ -r $PACKAGE_DIR/tagfile ]; then
  482.    cat $PACKAGE_DIR/tagfile >> $TMP/tagfile
  483.   fi
  484. #
  485. # Execute menus if in QUICK mode:
  486. #
  487.   if [ -r /tmp/SeTQUICK -a -r $PACKAGE_DIR/maketag ]; then
  488.    sh $PACKAGE_DIR/maketag
  489.    if [ -r /tmp/SeTnewtag ]; then
  490.     mv /tmp/SeTnewtag $TMP/tagfile
  491.    fi
  492.   fi
  493.   if [ -r $TMP/tagfile ]; then
  494.    chmod 600 $TMP/tagfile
  495.   fi
  496.  fi
  497.  if [ "$1" = "single_disk" -o -r $PACKAGE_DIR/disk$1 ]; then
  498.   CATALOG_FILE=`basename $PACKAGE_DIR/disk*`;
  499.   if [ -r $PACKAGE_DIR/$CATALOG_FILE -a ! -d $PACKAGE_DIR/$CATALOG_FILE ]; then
  500.    if fgrep CONTENTS: $PACKAGE_DIR/$CATALOG_FILE 1> /dev/null 2>&1 ; then
  501.     # First we check for missing packages...
  502.     for PKGTEST in `fgrep CONTENTS: $PACKAGE_DIR/$CATALOG_FILE | cut -b10- 2> /dev/null` ; do
  503.      if [ ! -r $PACKAGE_DIR/$PKGTEST.tgz ]; then
  504.       cat << EOF > /tmp/tmpmsg
  505.  
  506. WARNING!!!
  507.  
  508. While looking through your index file ($CATALOG_FILE), I 
  509. noticed that you might be missing a package ($PKGTEST.tgz) 
  510. that is supposed to be on this disk (disk $1). You may go
  511. on with the installation if you wish, but if this is a 
  512. crucial file I'm making no promises that your machine will
  513. boot.
  514.  
  515. EOF
  516.       dialog --title "FILE MISSING FROM YOUR DISK" --msgbox \
  517. "`cat /tmp/tmpmsg`" 15 73
  518.      fi
  519.     done # checking for missing packages
  520.     # Now we test for extra packages
  521.     ALLOWED="`fgrep CONTENTS: $PACKAGE_DIR/$CATALOG_FILE | cut -b10- 2> /dev/null`" 
  522.     for PACKAGE_FILENAME in $PACKAGE_DIR/*.tgz; do
  523.      BASE="`basename $PACKAGE_FILENAME .tgz`"
  524.      if echo $ALLOWED | fgrep $BASE 1> /dev/null 2>&1 ; then
  525.       GOOD="yup yup"
  526.      else
  527.       cat << EOF > /tmp/tmpmsg
  528.  
  529. WARNING!!!
  530.  
  531. While looking through your index file ($CATALOG_FILE), I 
  532. noticed that you have this extra package ($BASE.tgz) that
  533. I don't recongnize. Please be sure this package is really
  534. supposed to be here, and is not left over from an old 
  535. version of Slackware. Sometimes this can happen at the 
  536. archive sites.
  537.  
  538. EOF
  539.       dialog --title "EXTRA FILE FOUND ON YOUR DISK" \
  540. --msgbox "`cat /tmp/tmpmsg`" 15 67 
  541.       rm -f /tmp/tmpmsg
  542.      fi
  543.     done 
  544.    fi
  545.    cat $PACKAGE_DIR/$CATALOG_FILE > $ADM_DIR/disk_contents/$CATALOG_FILE
  546.    chmod 644 $ADM_DIR/disk_contents/$CATALOG_FILE
  547.   fi
  548.   for PACKAGE_FILENAME in $PACKAGE_DIR/*.tgz; do
  549.    if [ "$PACKAGE_FILENAME" = "$PACKAGE_DIR/*.tgz" ]; then
  550.     continue;
  551.    fi
  552.    CURRENT_PACKAGE_NAME=`basename $PACKAGE_FILENAME .tgz`
  553.    AddKey=""
  554.    SkipKey=""
  555.    if [ "$ASK" = "tagfiles" ]; then # -a ! "$DISK_SETS" = "disk" ]; then
  556.     if fgrep "$CURRENT_PACKAGE_NAME:" $TMP/tagfile | sed -n '$ p' | fgrep ADD 1> /dev/null 2>&1 ; then
  557.      AddKey="ADD"
  558.     fi
  559.     if fgrep "$CURRENT_PACKAGE_NAME:" $TMP/tagfile | sed -n '$ p' | fgrep SKP 1> /dev/null 2>&1 ; then
  560.      SkipKey="SKIP"
  561.     fi
  562.    elif [ "$ASK" = "never" ]; then
  563.     AddKey="ADD"
  564.    else # ASK must equal always
  565.     ASK="always"
  566.     fi  
  567.    if [ ! "$DISK_SETS" = "disk" ]; then
  568.     if fgrep "$CURRENT_PACKAGE_NAME:" $TMP/tagfile | sed -n '$ p' | fgrep ADD > /dev/null 2> /dev/null ; then
  569.      PRIORITY="[required]"
  570.     elif fgrep "$CURRENT_PACKAGE_NAME:" $TMP/tagfile | sed -n '$ p' | fgrep REC > /dev/null 2> /dev/null ; then
  571.      PRIORITY="[recommended]"
  572.     elif fgrep "$CURRENT_PACKAGE_NAME:" $TMP/tagfile | sed -n '$ p' | fgrep OPT > /dev/null 2> /dev/null ; then
  573.      PRIORITY="[optional]"
  574.     elif fgrep "$CURRENT_PACKAGE_NAME:" $TMP/tagfile | sed -n '$ p' | fgrep SKP > /dev/null 2> /dev/null ; then
  575.      PRIORITY="[skip]"
  576.     else
  577.      PRIORITY="[unknown]"
  578.     fi
  579.    fi
  580.    PACKAGE_SIZE=`filesize $PACKAGE_FILENAME`
  581.    if [ "$AddKey" = "ADD" ]; then
  582.     # echo "Auto-installing package ==>$CURRENT_PACKAGE_NAME<==  Priority: $PRIORITY" > /tmp/tmpmsg
  583.     echo > /tmp/tmpmsg
  584.     # Print out the description text:
  585.     CATALOG_FILE=`basename $PACKAGE_DIR/disk*`;
  586. #    if [ -r $PACKAGE_DIR/$CATALOG_FILE -a ! -d $PACKAGE_DIR/$CATALOG_FILE ]; then
  587. #     fgrep "$CURRENT_PACKAGE_NAME:" $PACKAGE_DIR/$CATALOG_FILE | cut -b11- 1>> /tmp/tmpmsg 2> /dev/null ;
  588. #    else
  589.     for index_file in $PACKAGE_DIR/disk* $PACKAGE_DIR/package_descriptions ; do
  590.      if [ ! "$index_file" = "$PACKAGE_DIR/disk??*" ]; then
  591.       if [ -r "$index_file" ]; then
  592.        cat $index_file | strings | fgrep "$CURRENT_PACKAGE_NAME:" | cut -b11- 1>> /tmp/tmpmsg 2> /dev/null 
  593.       fi
  594.      fi
  595.     done
  596. #    fi
  597.     COMPBYTES="`gzip -l $PACKAGE_DIR/$CURRENT_PACKAGE_NAME.tgz | sed -n '$ p' | cut -b1-9`"
  598.     UNCOMPBYTES="`gzip -l $PACKAGE_DIR/$CURRENT_PACKAGE_NAME.tgz | sed -n '$ p' | cut -b10-19`"
  599.     COMPRESSED="`expr $COMPBYTES / 1024` K"
  600.     UNCOMPRESSED="`expr $UNCOMPBYTES / 1024` K"
  601.     echo "Size: Compressed: $COMPRESSED, uncompressed: $UNCOMPRESSED." >> /tmp/tmpmsg
  602.     if [ ! "$PRIORITY" = "" ]; then
  603.      PMSG="  Priority: $PRIORITY"
  604.     else
  605.      PMSG=""
  606.     fi
  607.     dialog --title "Auto-installing package ==>$CURRENT_PACKAGE_NAME<==$PMSG" --infobox "`cat /tmp/tmpmsg`" 15 75
  608.     rm -f /tmp/tmpmsg
  609.     install_the_current_package;
  610.    elif [ "$SkipKey" != "SKIP" ]; then
  611.     # echo "Package Name: ==>$CURRENT_PACKAGE_NAME<==  Priority: $PRIORITY" > /tmp/tmpmsg
  612.     echo > /tmp/tmpmsg
  613.     CATALOG_FILE=`basename $PACKAGE_DIR/disk*`;
  614.     if [ -r $PACKAGE_DIR/$CATALOG_FILE -a ! -d $PACKAGE_DIR/$CATALOG_FILE ]; then
  615.      fgrep "$CURRENT_PACKAGE_NAME:" $PACKAGE_DIR/$CATALOG_FILE | cut -b11- 1>> /tmp/tmpmsg 2> /dev/null ;
  616.     fi
  617.     COMPBYTES="`gzip -l $PACKAGE_DIR/$CURRENT_PACKAGE_NAME.tgz | sed -n '$ p' | cut -b1-9`"
  618.     UNCOMPBYTES="`gzip -l $PACKAGE_DIR/$CURRENT_PACKAGE_NAME.tgz | sed -n '$ p' | cut -b10-19`"
  619.     COMPRESSED="`expr $COMPBYTES / 1024` K"
  620.     UNCOMPRESSED="`expr $UNCOMPBYTES / 1024` K"
  621.     echo "Size: Compressed: $COMPRESSED, uncompressed: $UNCOMPRESSED." >> /tmp/tmpmsg
  622.     echo >> /tmp/tmpmsg
  623.     echo "Install package $CURRENT_PACKAGE_NAME? " >> /tmp/tmpmsg
  624.     if [ ! "$PRIORITY" = "" ]; then
  625.      PMSG="  Priority: $PRIORITY"
  626.     else
  627.      PMSG=""
  628.     fi
  629.     dialog --title "Package Name: ==>$CURRENT_PACKAGE_NAME<==$PMSG" --menu "`cat /tmp/tmpmsg`" 22 75 1 \
  630. "Yes" "Install package $CURRENT_PACKAGE_NAME" \
  631. "No" "Do not install package $CURRENT_PACKAGE_NAME" \
  632. "Quit" "Abort software installation completely" 2> /tmp/reply
  633.     if [ $? = 1 -o $? = 255 ]; then
  634.      echo "No  " > /tmp/reply
  635.     fi
  636.     REPLY="`cat /tmp/reply`"
  637.     rm -f /tmp/reply /tmp/tmpmsg
  638.     if [ "$REPLY" = "Yes" ]; then
  639.      dialog --title "INSTALLING" --infobox "Installing package $CURRENT_PACKAGE_NAME" 3 50
  640.      install_the_current_package;
  641.     elif [ "$REPLY" = "Quit" ]; then
  642.      umount_the_source;
  643.      chmod 755 $TARGET_DIR
  644.      chmod 1777 $TARGET_DIR/tmp
  645.      exit 1;
  646.     elif [ "$REPLY" = "No" ]; then
  647.      dialog --title "SKIPPING PACKAGE" --infobox "Skipping package $CURRENT_PACKAGE_NAME" 3 50
  648.     fi
  649.    fi
  650.   done
  651.   OUTTAHERE="false"
  652.   if [ -r $PACKAGE_DIR/install.end ]; then
  653.    OUTTAHERE="true"
  654.   fi
  655.   umount_the_source;
  656.   if [ "$OUTTAHERE" = "true" ]; then
  657.    return 1;
  658.   fi
  659.  else
  660.   umount_the_source;
  661.   if [ ! "$SOURCE_MOUNTED" = "always" ]; then
  662.    cat << EOF > /tmp/tmpmsg
  663.  
  664. This does not look like the correct disk. You may either check to
  665. see if you've got the right disk in there ($1) and try again, or 
  666. you may skip the current disk series.
  667.  
  668. EOF
  669.    dialog --title "INCORRECT DISK INSERTED" --menu "`cat /tmp/tmpmsg`" 15 70 2 \
  670. "Retry" "Try to mount disk $1 again" \
  671. "Skip" "Skip this disk series" 2> /tmp/reply
  672.    if [ $? = 1 -o $? = 255 ]; then
  673.     rm -f /tmp/reply /tmp/tmpmsg
  674.     exit
  675.    fi
  676.    REPLY="`cat /tmp/reply`"
  677.    rm -f /tmp/reply /tmp/tmpmsg
  678.    if [ "$REPLY" = "Skip" ]; then
  679.     return 1;
  680.    else
  681.     install_disk $1;
  682.    fi
  683.   else
  684.    cat << EOF > /tmp/tmpmsg
  685. WARNING:
  686.  
  687. Can't find a disk series $SERIES_NAME in the source directory.
  688. Skipping it...
  689.  
  690. EOF
  691.    dialog --title "SELECTED SERIES NOT PRESENT" --msgbox "`cat /tmp/tmpmsg`" 10 65
  692.    rm -f /tmp/tmpmsg
  693.    return 1; 
  694.   fi 
  695.  fi;
  696. }
  697. install_disk_set() { # accepts one argument: the series name in lowercase.
  698.  SERIES_NAME=$1
  699.  CURRENT_DISK_NUMBER="1";
  700.  while [ 0 ]; do
  701.   install_disk $SERIES_NAME$CURRENT_DISK_NUMBER;
  702.   if [ $? = 1 -o $? = 255 ]; then # install.end was found, or the user chose
  703.         # to quit installing packages.
  704.    return 0;
  705.   fi
  706.   CURRENT_DISK_NUMBER=`expr $CURRENT_DISK_NUMBER + 1`
  707.  done;
  708. }
  709. if [ "$DISK_SETS" = "disk" ]; then
  710.  install_disk single_disk;
  711.  ASK="always"
  712. else
  713.  touch $TMP/tagfile
  714.  chmod 600 $TMP/tagfile
  715.  if echo $DISK_SETS | fgrep "#a#" 1> /dev/null 2>&1; then
  716.   A_IS_NEEDED="true"
  717.  else
  718.   A_IS_NEEDED="false"
  719.  fi
  720.  while [ 0 ];
  721.  do
  722.   while [ 0 ]; # strip leading '#'s
  723.   do
  724.    if [ "`echo $DISK_SETS | cut -b1`" = "#" ]; then
  725.     DISK_SETS="`echo $DISK_SETS | cut -b2-`"
  726.    else
  727.     break;
  728.    fi
  729.   done
  730.   if [ "$A_IS_NEEDED" = "true" ]; then
  731.    if [ "$TARGET_DIR" = "/" ]; then
  732.     dialog --title "WARNING: BIG TROUBLE DETECTED" \
  733. --menu " *** WARNING!  Reinstalling your A series to a running system \
  734. is not (yet) a good idea. It is suggested that you do not do this." \
  735. 11 70 3 \
  736. "Abort" "Abort software installation." \
  737. "Ignore" "Ignore warning and reinstall the A series anyway." \
  738. "Skip" "Skip the A series, but continue installing software." 2> /tmp/skip
  739.     if [ $? = 1 -o $? = 255 ]; then
  740.      exit
  741.     fi
  742.     WHATDO="`cat /tmp/skip`" 
  743.     rm -f /tmp/skip
  744.     if [ "$WHATDO" = "Abort" ]; then
  745.      dialog --msgbox "Aborting..." 5 30
  746.      A_IS_NEEDED="false"
  747.      DISK_SETS=""
  748.      continue;
  749.     elif [ "$WHATDO" = "Skip" ]; then
  750.      dialog --msgbox "Skipping A series..." 5 30
  751.      A_IS_NEEDED="false"
  752.      continue;
  753.     elif [ ! "$WHATDO" = "Ignore" ]; then
  754.      continue; # unknown response
  755.     fi
  756.    fi
  757.    cat << EOF > /tmp/tmpmsg
  758.  
  759. --- Installing disk series ==>a<==
  760.  
  761. EOF
  762.    dialog --infobox "`cat /tmp/tmpmsg`" 5 45
  763.    sleep 1
  764.    rm -f /tmp/tmpmsg
  765.    install_disk_set a;
  766.    A_IS_NEEDED="false"
  767.   fi
  768.   count="1"
  769.   if [ "`echo $DISK_SETS | cut -b$count`" = "" ]; then
  770.    break; # we be done here :^)
  771.   else
  772.    count="2"
  773.    while [ 0 ]; do
  774.     if [ "`echo $DISK_SETS | cut -b$count`" = "" -o "`echo $DISK_SETS | cut -b$count`" = "#" ]; then
  775.      count="`expr $count - 1`"
  776.      break;
  777.     else
  778.      count="`expr $count + 1`"
  779.     fi 
  780.    done
  781.   fi 
  782.   diskset="`echo $DISK_SETS | cut -b1-$count`"
  783.   count="`expr $count + 1`"
  784.   DISK_SETS="`echo $DISK_SETS | cut -b$count-`"
  785.   if [ "$diskset" = "a" ]; then
  786.    continue; # we expect this to be done elsewhere
  787.   fi
  788.   cat << EOF > /tmp/tmpmsg
  789.  
  790. Installing disk series ==>$diskset<==
  791.  
  792. EOF
  793.   dialog --infobox "`cat /tmp/tmpmsg`" 5 45
  794.   sleep 1
  795.   rm -f /tmp/tmpmsg
  796.   install_disk_set $diskset; 
  797.  done
  798. fi
  799.  
  800. if [ "$DISK_SETS" = "disk" -o "$CMD_START" = "true" ]; then
  801.  if [ -r $TMP/tagfile ]; then
  802.   rm $TMP/tagfile
  803.  fi
  804.  reset
  805. fi
  806. chmod 755 $TARGET_DIR $TARGET_DIR/var $TARGET_DIR/usr
  807. chmod 1777 $TARGET_DIR/tmp
  808.