#! /bin/sh
#
# readtape
#
# Copyright (c) 1988-1993 by Frame Technology Corp. All rights reserved.
# $Id: readtape.it,v 2.7 1994/04/08 22:41:30 lss Exp $
#
#------------------------------------------------------------------------------
# Frame Technology                If you encounter any difficulties with
# 1010 Rincon Circle              this script, contact Frame Tech Support.
# San Jose, CA 95131              internet: comments@frame.com
# (408)433-3311, (800)U4-FRAME
#------------------------------------------------------------------------------

# make sure that we have good stuff on our path
PATH=/bin:/usr/bin:/usr/ucb:`pwd`/.install

# anyone can remove temporary files
umask 022

BASE_SZ=1508
LWSTD_SZ=2639
DOCSENG_SZ=12348
DOCSDEU_SZ=10503
DOCSFRA_SZ=10761
DOCSSVE_SZ=10526
LWPLS_SZ=2964
DICTBRAZ_SZ=513
DICTBRT_SZ=854
DICTCFR_SZ=640
DICTCTL_SZ=1067
DICTDAN_SZ=955
DICTDUT_SZ=1328
DICTENG_SZ=990
DICTFIN_SZ=761
DICTFRN_SZ=992
DICTGRM_SZ=2022
DICTITL_SZ=587
DICTNRW_SZ=899
DICTNYN_SZ=482
DICTPRT_SZ=529
DICTSGR_SZ=2023
DICTSPN_SZ=1035
DICTSWD_SZ=1837
ENGLISH_SZ=1803
DEUTSCH_SZ=1799
FRANCAIS_SZ=1809
SVENSKA_SZ=1793
FDK_SZ=4882
PRODMAN_SZ=15942
sunxmossparc_SZ=10748
sunxms5sparc_SZ=13561
hphpuxm68k_SZ=13091
hphpuxpa_SZ=15848
ibmaixpwr_SZ=13345
sgiirixmips_SZ=14376
FPBASE_SZ=63
FPDOCS_SZ=977
C960sunos_SZ=331
C960suns5_SZ=395
C960ibmaix_SZ=331
C960hppa_SZ=291
C960hpm68k_SZ=251
C960sgiirix_SZ=395
CBBASEsunos_SZ=2535
CBBASEsuns5_SZ=2871
CBBASEibmaix_SZ=2471
CBBASEhppa_SZ=2439
CBBASEhpm68k_SZ=2215
CBBASEsgiirix_SZ=2799
DXFsunos_SZ=387
DXFsuns5_SZ=459
DXFibmaix_SZ=379
DXFhppa_SZ=339
DXFhpm68k_SZ=299
DXFsgiirix_SZ=467
EPSIsunos_SZ=117
EPSIsuns5_SZ=141
EPSIibmaix_SZ=114
EPSIhppa_SZ=113
EPSIhpm68k_SZ=85
EPSIsgiirix_SZ=157
FMIMGsunos_SZ=61
FMIMGsuns5_SZ=72
FMIMGibmaix_SZ=63
FMIMGhppa_SZ=69
FMIMGhpm68k_SZ=51
FMIMGsgiirix_SZ=74
HPGLsunos_SZ=379
HPGLsuns5_SZ=451
HPGLibmaix_SZ=371
HPGLhppa_SZ=323
HPGLhpm68k_SZ=283
HPGLsgiirix_SZ=451
IGESsunos_SZ=827
IGESsuns5_SZ=971
IGESibmaix_SZ=771
IGEShppa_SZ=731
IGEShpm68k_SZ=627
IGESsgiirix_SZ=971
IMGG4sunos_SZ=53
IMGG4suns5_SZ=44
IMGG4ibmaix_SZ=41
IMGG4hppa_SZ=53
IMGG4hpm68k_SZ=36
IMGG4sgiirix_SZ=52
MIFCGMsunos_SZ=437
MIFCGMsuns5_SZ=525
MIFCGMibmaix_SZ=437
MIFCGMhppa_SZ=389
MIFCGMhpm68k_SZ=333
MIFCGMsgiirix_SZ=533
BUILDERENG_SZ=6205
BUILDERFRA_SZ=20
BUILDERDEU_SZ=20
BUILDERSVE_SZ=20
BUILDERLN_SZ=52
MAKERENG_SZ=4791
MAKERFRA_SZ=5376
MAKERDEU_SZ=5869
MAKERSVE_SZ=5731
MAKERLN_SZ=52
VIEWERENG_SZ=500
VIEWERFRA_SZ=734
VIEWERDEU_SZ=719
VIEWERSVE_SZ=712
VIEWERLN_SZ=36
ALLDICT_SZ=17514

scriptname=`basename $0`
vendor=$1
tarfile=$2

VERSION="4.0.3P"
PRODID="Version 4.0.3P1a (Sun X/Motif) Wed Feb  9 17:54:00 PDT 1994"
PRODVERS="Frame Products"
TAROPTIONS="-xfp"
BS=20
THISHOST=`uname -n`
THISMACH=`.install/fmarch`
DOBASE=1
FPDOBASE=1
INCLUDED=${INCLUDED:-"BASE LWSTD"}
UILANGUAGES="ENGLISH FRANCAIS DEUTSCH SVENSKA"
langcount="`echo $UILANGUAGES | wc -w`"
PRODUCTS="BUILDER MAKER VIEWER"
prodcount="`echo $PRODUCTS | wc -w `"
BINARIES="sunxm.os.sparc sunxm.s5.sparc hp.hpux.m68k hp.hpux.pa ibm.aix.pwr sgi.irix.mips"
bincount="`echo $BINARIES | wc -w`"
FONTS="LWPLS"

DISKUSE=${DISKUSE:-$BASE_SZ}

finalmsg=.install/fmfinalmsg
longdesc=.install/fmlongdesc
zz=0C-3-01-01-4
yy=0D-3-01-01-4
history=.install/history
config=.install/fmconfig
tempfile=/tmp/rt.$$
tempfile2=/tmp/rt2.$$


##
## Exit statuses
##
okay=0
nohost=1
nodevice=2
rewind=3
userabort=4

cc="\c"; nn=
test "`echo -n X`" = 'X' && {
   cc= ; nn=-n
}

fm_ask()
{
   answer=undefined
   until [ "$answer" = "$1" -o "$answer" = "$2" ]; do
      echo $nn "$3 ($1/$2)[$1]: " $cc
      read answer
      [ "$answer" = "" ] && answer=$1
   done
   [ $answer = $1 ]
}

fm_ans()
{
   [ "$1" = "y" -a "$2" -eq 0 ] && return 0
   [ "$1" = "n" -a "$2" -ne 0 ] && return 0
   return 1
}


echo "
Installing Frame Products from Frame Technology Corporation.

Frame provides many options in its products, including the option to:
   - Run on Sun Sparc (SunOS/Solaris), HP 9000 Series 300/400/700/800,
     IBM RS6000 and SGI (Indigo/Indy) Workstations
   - Use Frame's multilingual features (in the International version)
   - Use the 35 LaserWriter Plus compatible fonts
   - Load optional sample documents and online manuals

This script asks you which options you want to install. If you
choose not to install some options, this script will install only
the files you need, saving disk space.

You can also use this script to extract the files from the
cd at a later time.

When this script asks you questions, a default answer 
is shown in brackets next to the question.  To use the 
default answer, press Return in response to the question. 
Otherwise, type one of the other suggested responses. 
"
fm_ask y n "Would you like to continue?" || {
   echo `date` $PRODVERS installation aborted by user. >> $history 2> /dev/null
   exit 1
}

[ -d ./.fminit2.0.ps -a ! -d ./fminit ] && {
      echo "
$scriptname: You have an older version of Frame software in this
directory.  Please install this version in a different directory.
"
      exit 1
}

[ -d ./fminit ] && {
   VERFILENAME=`echo ./.VERSION* 2> /dev/null`
   INSTVERSION=4.0.3P
   
   [ -r $VERFILENAME ] || {
      echo "`pwd` contains improperly installed Frame software."
      echo "No update is possible."
      echo "`date` Bizarre install directory.  Installation aborted." >> $history 2> /dev/null
      exit 1
   }

   [ -r .install/versions ] && {
      id="`grep -i "$PRODVERS" .install/versions | sed -e '2,$d'`"
      echo "$id" | grep "$INSTVERSION" > /dev/null 2>&1
      if [ $? -eq 0 ]; then
	 echo "The Frame Products files are already installed."
	 fm_ask y n "Would you like to add options to this installation?" || {
	    echo "Installation aborted. Nothing installed."
	    echo `date` Installation aborted by user. >> $history 2> /dev/null
	    exit 1
	 }
	 INCLUDED=""; DISKUSE=0; DOBASE=0
      else
	 echo "
The version string for the product you are trying to install does not
match with the one that is installed.  Please choose a different
directory to perform this installation."
	 exit 1
      fi
   }
}

##
## Issue a message based on whether we think we are doing an original
## install or an upgrade/incremental
##
[ $DOBASE -eq 1 ] && sed -n "/^<BASE/,/^>/p" $longdesc | grep -v '[<>]'
[ $DOBASE -ne 1 ] && sed -n "/^<INCREMENTAL/,/^>/p" $longdesc | grep -v '[<>]'

echo "
Do you want to install:
"
for bin in $BINARIES
do
   name=`echo $bin | sed 's/\.//g'`
   use="\$${name}_SZ"
   use="`eval echo $use`"
   case $name in
          sunxmossparc)
             desc="Frame Products binaries for Sun Sparc (SunOS 4.1.x)";;
          sunxms5sparc)
             desc="Frame Products binaries for Sun Sparc (Solaris)";;
          hphpuxm68k)
             desc="Frame Products binaries for HP Series 300 and 400";;
          hphpuxpa)
             desc="Frame Products binaries for HP Series 700 and 800";;
	  ibmaixpwr)
	     desc="Frame Products binaries for IBM RS6000";;
	  sgiirixmips)
	     desc="Frame Products binaries for SGI Indigo/Indy";;
   esac

   # Only ask if the candidate binary isn't already on the INCLUDED list.
   echo "$INCLUDED" | grep $bin > /dev/null 2>&1 || {
      status=0
      # Only ask if there is more than one bin or we are doing an incremental.
      [ $bincount -gt 1 -o $DOBASE -eq 0 ] && {
	 def=y; alt=n
	 usestring="$use Kbytes"
	 [ -r .install/$name.x ] && {
	    usestring="Already Installed"
	    def=n; alt=y; use=0
	 }
	 # Print information from the longdesc file about this fileset
	 sed -n "/^<$bin/,/^>/p" $longdesc | grep -v '[<>]'
	 # Now ask the user.
	 fm_ask $def $alt "$desc ($usestring)"
	 fm_ans $def $?
	 status=$?
      }

      # Include the fileset if the user if we want it
      [ $status -eq 0 ] && {
	 INCLUDED="$INCLUDED $bin"
	 DISKUSE=`expr $DISKUSE + $use`
      }
   }
done

##
## Keep looping until we have at least one UI selected
##
selectui=no
while [ $selectui = no ]
do
   # If we are doing an incremental, we can assume that a UI has already
   # been installed.
   [ $DOBASE = 0 ] && selectui=yes
   for lang in $UILANGUAGES
   do
      ## Fileset size consists of the size of the language fileset
      ## plus the size of the corresponding dictionaries
      shortlang=`echo $lang | sed 's/\(...\).*/\1/'`
      use="\$${lang}_SZ"
      use="`eval echo $use`"
      dict="`dictname $lang`"
      dictuse=0
      dictvar="\$${lang}_SZ"
      dictvar="`eval echo $dictvar`"
      dictuse=`expr $dictuse + $dictvar`
      use=`expr $use + $dictuse`

      # Only ask if we don't already have it on the INCLUDED list
      echo "$INCLUDED" | grep $lang > /dev/null 2>&1 || {
	 status=0
	 [ $langcount -gt 1 -o $DOBASE -eq 0 ] && {
	    def=y; alt=n
	    desc="`getdesc $lang`"
	    usestring="$use Kbytes"
	    [ -r .install/$lang.x ] && {
	       usestring="Already Installed"
	       def=n; alt=y; use=0
	    }
	    sed -n "/^<$lang/,/^>/p" $longdesc | grep -v '[<>]'
	    fm_ask $def $alt "$desc ($usestring)"
	    fm_ans $def $?
	    status=$?
	 }
	 
	 [ $status -eq 0 ] && {
	    selectui=yes
	    INCLUDED="$INCLUDED $lang"
	    DISKUSE=`expr $DISKUSE + $use`
	    for i in $dict
	    do
	       INCLUDED="$INCLUDED $i"
	    done
	 }
      }

      # Don't ask for product and support filesets for languages not chosen
      echo "$INCLUDED" | grep $lang > /dev/null 2>&1 && {
      selectprod=no
      while [ $selectprod = no ]
      do
	 [ $DOBASE = 0 ] && selectprod=yes
	 for product in $PRODUCTS
	 do
	    # this check is needed because there are no localiized Builders
	    # on this cd
	    [ ! "${shortlang}" = "ENG" -a "${product}" = "BUILDER" ] && continue
	    use="\$${product}${shortlang}_SZ"
	    use="`eval echo $use`"
	    status=0
	    [ $prodcount -gt 1 -o $DOBASE -eq 0 ] && {
	       desc="`getdesc $product$shortlang`"
	       usestring="$use Kbytes"
	       def=y; alt=n
	       [ -r .install/${product}${shortlang}.x ] && {
		  usestring="Already Installed"
		  def=n; alt=y; use=0
	       }
	       sed -n "/^<$product$shortlang/,/^>/p" $longdesc | grep -v '[<>]'
	       fm_ask $def $alt "$desc ($usestring)"
	       fm_ans $def $?
	       status=$?
	    }
	    [ $status = 0 ] && {
	       selectprod=yes
	       INCLUDED="$INCLUDED $product$shortlang ${product}LN"
	       DISKUSE=`expr $DISKUSE + $use`
	    }
	 done
      done

      use="\$DOCS${shortlang}_SZ"
      use="`eval echo $use`"
      def=y ; alt=n
      usestring="$use Kbytes"
      [ -r .install/DOCS${shortlang}.x ] && {
	 usestring="Already Installed"
	 def=n; alt=y; use=0
      }
      desc="`getdesc DOCS$shortlang`"
      sed -n "/^<DOCS$shortlang/,/^>/p" $longdesc | grep -v '[<>]'
      fm_ask $def $alt "$desc ($usestring)"
      fm_ans $def $?  && {
	 INCLUDED="$INCLUDED DOCS$shortlang"
	 DISKUSE=`expr $DISKUSE + $use`
      }
      }
   done
done

# Install the on-line copies of the printed maker docs

use="$PRODMAN_SZ"
def=y; alt=n
usestring="$use Kbytes"
[ -r .install/PRODMAN.x ] && {
   usestring="Already Installed"
   def=n; alt=y; use=0
}
echo 
sed -n "/^<PRODMAN/,/^>/p" $longdesc | grep -v '[<>]'
fm_ask $def $alt "The Printed Manuals for FrameMaker ($usestring)"
fm_ans $def $? && {
	INCLUDED="$INCLUDED PRODMAN"
	DISKUSE=`expr $DISKUSE + $use`
}


doemall=false
echo
sed -n "/^<DICTIONARIES/,/^>/p" $longdesc | grep -v '[<>]'
fm_ask y n "The International Dictionaries and Thesauruses" && {
   list=`/bin/ls .install/DICT*.x 2> /dev/null | sed -e '2,$d'`
   [ -z "$list" ] && {
      sed -n "/^<ALLDICT/,/^>/p" $longdesc | grep -v '[<>]'
      fm_ask y n "All the dictionaries and thesauruses ($ALLDICT_SZ Kbytes)" && {
	 doemall=true
	 DISKUSE=`expr $DISKUSE + $ALLDICT_SZ`
      }
   }
   for i in `cat $config`
   do
      echo $i | grep "^set:DICT" > /dev/null 2>&1 || continue

      name=`echo $i | awk -F: '{ print $2 }'`
      [ $doemall = true ] && {
         INCLUDED="$INCLUDED $name"
         continue
      }
      echo $INCLUDED | grep $name > /dev/null 2>&1 && continue
      def=y; alt=n
      use="\$${name}_SZ"
      use="`eval echo $use`"
      desc="`getdesc $name`"
      usestring="$use Kbytes"
      [ -r .install/$name.x ] && {
	 usestring="Already Installed"
	 def=n; alt=y; use=0
      }
      fm_ask $def $alt "	$desc ($usestring)"
      fm_ans $def $?  && {
	 INCLUDED="$INCLUDED $name"
	 DISKUSE=`expr $DISKUSE + $use`
      }
   done
}

for f in $FONTS
do
   use="\$${f}_SZ"
   use="`eval echo $use`"
   status=0
   def=y; alt=n
   desc="`getdesc $f`"
   usestring="$use Kbytes"
   [ -r .install/$f.x ] && {
      usestring="Already Installed"
      def=n; alt=y; use=0
   }
   sed -n "/^<$f/,/^>/p" $longdesc | grep -v '[<>]'
   fm_ask $def $alt "$desc ($usestring)"
   fm_ans $def $?
   status=$?

   [ $status -eq 0 ] && {
      INCLUDED="$INCLUDED $f"
      DISKUSE=`expr $DISKUSE + $use`
   }
done

# Install the FDK

FDK=false
use='$FDK_SZ'
use="`eval echo $use`"
def=y; alt=n
desc="`getdesc FDK`"
usestring="$use Kbytes"
[ -r .install/FDK.x ] && {
   usestring="Already Installed"
   def=n; alt=y; use=0
}
sed -n "/^<FDK/,/^>/p" $longdesc | grep -v '[<>]'
fm_ask $def $alt "$desc ($usestring)"
fm_ans $def $?
[ $? -eq 0 ] && {
   echo $nn "Enter FDK password: " $cc
   read fdkpw
   echo $fdkpw | grep -i $zz > /dev/null 2>&1
   if [ $? -eq 0 ]; then
      echo "FDK password accepted"
      INCLUDED="$INCLUDED FDK"
      DISKUSE=`expr $DISKUSE + $use`
      FDK=true
   else
      echo "Incorrect FDK password.  FDK not installed."
   fi
}


# Install the FilterPak if the user has the password

echo

FP=false
usestring=""
def=y; alt=n
[ -r .install/FPBASE.x ] && {
	usestring="(Already Installed)"
	def=n; alt=y
}
fm_ask $def $alt "The Frame FilterPak 4 $usestring"
fm_ans $def $?
[ $? -eq 0 ] && {
   echo $nn "Enter FilterPak password: " $cc
   read fppw
   echo $fppw | grep -i $yy > /dev/null 2>&1
   if [ $? -eq 0 ]; then
      echo "FilterPak password accepted"
      echo "
Installing the Frame FilterPak 4 from Frame Technology Corporation.

You will be asked which additional FilterPak options you want to install. 
If you choose not to install some options, this script will install only 
the files you need, saving you disk space."

#       [ ! -d ./fminit -o ! -d ./.install ] && {
#          pwd
#          echo "
#The Frame FilterPak installation requires that you install over
#an existing Frame Products directory.  This directory does not
#contain the necessary files to install or run the Frame Filter Pak.
#The FilterPak will not be installed.
#"
#          FP=false
#      }
      FP=true
      [ -r .install/FPBASE.x ] && FPDOBASE=0
      [ $FPDOBASE -eq 1 ] && sed -n "/^<FPBASE/,/^>/p" $longdesc | grep -v '[<>]'
      [ $FPDOBASE -ne 1 ] && sed -n "/^<INCREMENTAL/,/^>/p" $longdesc | grep -v '[<>]'

	echo "
Do you wish to install:
"

	rm -f /tmp/fprt.$$
	touch /tmp/fprt.$$

	# figure out which filter binaries to install
	binlist=""
	greplist=""
	sunxmossparc="Filter binaries for Sun Sparc (SunOS 4.1.x)"
	sunxms5sparc="Filter binaries for Sun Sparc (Solaris)"
	hphpuxm68k="Filter binaries for HP series 300 and 400"
	hphpuxpa="Filter binaries for HP series 700 and 800"
	ibmaixpwr="Filter binaries for IBM RS6000"
	sgiirixmips="Filter binaries for SGI Indigo/Indy"

	  use=`expr $FPBASE_SZ + $C960sunos_SZ + $CBBASEsunos_SZ + $DXFsunos_SZ + $EPSIsunos_SZ + $FMIMGsunos_SZ + $HPGLsunos_SZ + $IGESsunos_SZ + $IMGG4sunos_SZ + $MIFCGMsunos_SZ`
	  fm_ask y n "$sunxmossparc ($use Kbytes)"
	  fm_ans y $? && {
	         binlist="sunos"
	         greplist="|sunos"
	  }

          use=`expr $FPBASE_SZ + $C960suns5_SZ + $CBBASEsuns5_SZ + $DXFsuns5_SZ + $EPSIsuns5_SZ + $FMIMGsuns5_SZ + $HPGLsuns5_SZ + $IGESsuns5_SZ + $IMGG4suns5_SZ + $MIFCGMsuns5_SZ`
	  fm_ask y n "$sunxms5sparc ($use Kbytes)"
	  fm_ans y $? && {
	         binlist="$binlist suns5"
		 greplist="$greplist|suns5"
	  }

          use=`expr $FPBASE_SZ + $C960hpm68k_SZ + $CBBASEhpm68k_SZ + $DXFhpm68k_SZ + $EPSIhpm68k_SZ + $FMIMGhpm68k_SZ + $HPGLhpm68k_SZ + $IGEShpm68k_SZ + $IMGG4hpm68k_SZ + $MIFCGMhpm68k_SZ`
	  fm_ask y n "$hphpuxm68k ($use Kbytes)"
	  fm_ans y $? && {
	         binlist="$binlist hpm68k"
		 greplist="$greplist|hpm68k"
	  }

          use=`expr $FPBASE_SZ + $C960hppa_SZ + $CBBASEhppa_SZ + $DXFhppa_SZ + $EPSIhppa_SZ + $FMIMGhppa_SZ + $HPGLhppa_SZ + $IGEShppa_SZ + $IMGG4hppa_SZ + $MIFCGMhppa_SZ`
	  fm_ask y n "$hphpuxpa ($use Kbytes)"
	  fm_ans y $? && {
	         binlist="$binlist hppa"
		 greplist="$greplist|hppa"
	  }

          use=`expr $FPBASE_SZ + $C960ibmaix_SZ + $CBBASEibmaix_SZ + $DXFibmaix_SZ + $EPSIibmaix_SZ + $FMIMGibmaix_SZ + $HPGLibmaix_SZ + $IGESibmaix_SZ + $IMGG4ibmaix_SZ + $MIFCGMibmaix_SZ`
          fm_ask y n "$ibmaixpwr ($use Kbytes)"
          fm_ans y $? && {
                 binlist="$binlist ibmaix"
                 greplist="$greplist|ibmaix"
          }

          use=`expr $FPBASE_SZ + $C960sgiirix_SZ + $CBBASEsgiirix_SZ + $DXFsgiirix_SZ + $EPSIsgiirix_SZ + $FMIMGsgiirix_SZ + $HPGLsgiirix_SZ + $IGESsgiirix_SZ + $IMGG4sgiirix_SZ + $MIFCGMsgiirix_SZ`
          fm_ask y n "$sgiirixmips ($use Kbytes)"
          fm_ans y $? && {
                 binlist="$binlist sgiirix"
                 greplist="$greplist|sgiirix"
          }


        greplist1=`echo $greplist | sed -e 's/|/\(/'`

	## Put FPBASE in install
	grep "FPBASE" $config >> /tmp/fprt.$$
	INCLUDED="$INCLUDED FPBASE"


	for i in $binlist
	do
#		INCLUDED="$INCLUDED CBBASE$i"
		for j in `cat $config`
		do
			echo $j | grep $i >> /tmp/fprt.$$
		done
	done

	for i in `cat /tmp/fprt.$$`
	do
	   echo $i | grep '^set:' > /dev/null 2>&1 || continue
	   name=`echo $i | awk -F: '{ print $2 }'`
	   echo $INCLUDED | grep $name > /dev/null 2>&1 && continue
	   echo $name | grep '[a-z]' > /dev/null 2>&1 && {
	      echo $name | egrep "$greplist1)" > /dev/null 2>&1 || continue
	   }
	   [ $FPDOBASE -eq 1 ] && {
	      grep $name /tmp/fprt.$$ > /dev/null 2>&1
	      [ $? = 0 ] && {
	         INCLUDED="$INCLUDED $name"
	         use="\$${name}_SZ"
	         use="`eval echo $use`"
	         DISKUSE=`expr $DISKUSE + $use`
	         continue
	      }
	   }
	   [ "${name}" = "FPDOCS" -o "${name}" = "FPBASE" ] && continue
	   sed -n "/^<$name/,/^>/p" $longdesc | grep -v '[<>]'
	   def=y; alt=n
	   use="\$${name}_SZ"
	   use="`eval echo $use`"
	   desc="`getdesc $name`"
	   usestring="$use Kbytes"
	   [ -r .install/$name.x ] && {
	      usestring="Already Installed"
	      def=n; alt=y; use=0
	   }
	   fm_ask $def $alt "$desc ($usestring)"
	   fm_ans $def $?  && {
	      INCLUDED="$INCLUDED $name"
	      DISKUSE=`expr $DISKUSE + $use`
	   }
	done

	## Ask if the optional docs should be installed
        sed -n "/^<FPDOCS/,/^>/p" $longdesc | grep -v '[<>]'
        def=y; alt=n
        use="\$FPDOCS_SZ"
        use="`eval echo $use`"
        desc="`getdesc FPDOCS`"
	usestring="$use Kbytes"
        [ -r .install/FPDOCS.x ] && {
                usestring="Already Installed"
                def=n; alt=y; use=0
        }
        fm_ask $def $alt "$desc ($usestring)"
        fm_ans $def $?  && {
                grep "FPDOCS" $config >> /tmp/fprt.$$
		INCLUDED="$INCLUDED FPDOCS"
		DISKUSE=`expr $DISKUSE + $use`
        }

	rm -f /tmp/fprt.$$


   else
      echo "Incorrect FilterPak password.  FilterPak not installed."
   fi
}

echo
echo

case $vendor in
   sun)
      AVAIL=`df . | tr "\12" " " | awk '{ print $11 }'`
      df . ;;
   
   hp)
      AVAIL=`bdf . | tr "\12" " " | awk '{ print $11 }'`
      bdf . ;;
   
   ibm)
      AVAIL=`df . | tr "\12" " " | awk '{ print $12 }'`
      df . ;;

   sgi)
      AVAIL=`df -k . | tr "\12" " " | awk '{ print $11 }'`
      df -k . ;;
esac


echo "
In the configuration you specified, Frame will take up $DISKUSE Kbytes.
You have $AVAIL Kbytes available on this file system."

[ -z "$INCLUDED" ] && {
   echo "
You have not selected anything to install.

Installation aborted.  Nothing installed.
"
   echo `date` Installation aborted because no options were selected. >> $history 2> /dev/null
   exit 1
}
   

[ $AVAIL -lt $DISKUSE ] && {
   echo "
$scriptname: There is not enough room on this file system to install 
the Frame software.  Please make more space and reinstall."
   echo `date` Installation aborted due to lack of disk space. >> $history 2> /dev/null
   exit 1
}


fm_ask y n "
Would you like to continue?" || {
   echo "Installation aborted.  Nothing installed."
   echo `date` Installation aborted by user. >> $history 2> /dev/null
   exit 1
}

# Massage the INCLUDED list for repeated items.

newinclude=`echo $INCLUDED | tr ' ' '\012' | sort 2>/dev/null | uniq`
[ ! -z "$newinclude" ] && INCLUDED=$newinclude


#  Find devices on local machine
# These next 40 lines are needed to figure out which host and device
# on which to install




./.install/extract.$vendor -d $tarfile $INCLUDED

status=$?
[ $status -ne 0 ] && {
   case $status in 
      $nohost) 
	 echo "Cannot connect to $host.  Installation aborted.  Nothing installed."
	 echo `date` $PRODVERS installation aborted because of bad remote host connection. >> $history 2> /dev/null ;;

      $nodevice) 
	 echo "$device is not readable.  Installation aborted.  Nothing installed."
	 echo `date` $PRODVERS installation aborted because of bad device. >> $history 2> /dev/null ;;

      $userabort) 
	 echo "Installation aborted.  Nothing installed."
	 echo `date` $PRODVERS installation aborted by user. >> $history 2> /dev/null ;;

      *) 
	 echo "Installation terminated for an unknown reason.  Try again."
	 echo `date` $PRODVERS installation aborted for an unknown reason. >> $history 2> /dev/null
   esac
   exit 1
}

if [ -r .install/LWPLS.x ]; then
   (cd ./fminit/fontdir; rm -f fontlist; ln -s fontlist.lwp fontlist)
else
   (cd ./fminit/fontdir; rm -f fontlist; ln -s fontlist.lw fontlist)
fi

# fix the release notes link
for i in ./fminit/*/OnlineManuals ; do
        case "`ls $i/rnotes.* 2>/dev/null`" in
        "")
                echo "Error: Missing release notes ($i/rnotes.<date> file)." ;;
        *)
                (
                        cd $i
                        rm -f ReleaseNotes
                        ln -s `ls -r rnotes.* 2>/dev/null | sed 1q` ReleaseNotes
                ) ;;
        esac
done

# fix the release notes link in the francais and deutsch and svenska directories
echo "\
francais Manuels_electroniques
deutsch Online_Handbuecher
svenska Handboksfiler" | \
while read lang dir ; do
   [ -d fminit/$lang ] && {
      mkdir fminit/$lang/$dir >/dev/null 2>&1
      rm -f fminit/$lang/$dir/ReleaseNotes
      ln -s ../../usenglish/OnlineManuals/ReleaseNotes fminit/$lang/$dir/ReleaseNotes
   }
done

# get rid of unwanted bin directories
for i in $BINARIES ; do
	f=0
	for j in bin/$i/* ; do
	   [ -f $j ] && { f=1; break; }
	done
   [ $f -eq 0 ] && {
      rm -rf bin/$i
      for k in .install/*LN.x ; do
         sed '/\/'"$i"'\//d' $k > $k.$$
         mv $k.$$ $k
      done
   }
done

# set directory permissions
mkdir fminit/tmp > /dev/null 2>&1
chmod 777 fminit/tmp fminit/groupsettings > /dev/null 2>&1

for i in $INCLUDED
do
   rmdir $i > /dev/null 2>&1
done

[ $FDK = true ] && sh .install/fdku

[ $FP = true ] && {
	[ -x ./bin/scripts/fpsffxinstall ] && {
		echo "Updating configuration files for FilterPak 4..."
		./bin/scripts/fpsffxinstall > /dev/null 2>&1
	}
}

[ "`.install/fmarch`" = "sunxm.os.sparc" ] && {
	ranlib -t fdk/lib/sunxm.os.sparc/lib*.a > /dev/null 2>&1
}

# Fix permissions on fm_fls binaries
chmod 4755 ./bin/*.*.*/fm_fls

# Fix the .install/versions file
 
x=`sed -n -e '1p' .VERSION`
y=`sed -n -e '2p' .VERSION`
z=`sed -n -e '3,$p' .VERSION | tr '\012' '!'`
 
rm -f $tempfile
echo "$x $y$z" > $tempfile
[ -r .install/versions ] && {
   tr '\012' '!' < .install/versions >> $tempfile2
   sed 's/!!*$/!/' < $tempfile2 >> $tempfile
   rm -f $tempfile2
}

rm -f .install/versions
sort $tempfile 2> /dev/null | uniq | tr '!' '\012' > .install/versions
rm -f $tempfile
cat $finalmsg

echo `date` $PRODVERS installation of filesets:$INCLUDED succeeded. >> $history 2> /dev/null 
