#! /bin/sh
#
# readtape
#
# Copyright (c) 1988-1993 by Frame Technology Corp. All rights reserved.
# $Id: readtape.it,v 1.14 1993/08/03 02:02:57 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=1149
LWSTD_SZ=2639
DOCSENG_SZ=12348
DOCSDEU_SZ=10503
DOCSFRA_SZ=10761
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=1796
DEUTSCH_SZ=1780
FRANCAIS_SZ=1790
FDK_SZ=3775
PRODMAN_SZ=15942
sunxmossparc_SZ=9228
sunxms5sparc_SZ=13545
hphpuxm68k_SZ=13083
hphpuxpa_SZ=15840
FPBASE_SZ=63
FPDOCS_SZ=977
C960sunos_SZ=331
C960suns5_SZ=395
C960hppa_SZ=291
C960hpm68k_SZ=251
CBBASEsunos_SZ=2535
CBBASEsuns5_SZ=2871
CBBASEhppa_SZ=2439
CBBASEhpm68k_SZ=2215
DXFsunos_SZ=387
DXFsuns5_SZ=459
DXFhppa_SZ=339
DXFhpm68k_SZ=299
EPSIsunos_SZ=117
EPSIsuns5_SZ=141
EPSIhppa_SZ=113
EPSIhpm68k_SZ=85
FMIMGsunos_SZ=61
FMIMGsuns5_SZ=72
FMIMGhppa_SZ=69
FMIMGhpm68k_SZ=51
HPGLsunos_SZ=379
HPGLsuns5_SZ=451
HPGLhppa_SZ=323
HPGLhpm68k_SZ=283
IGESsunos_SZ=827
IGESsuns5_SZ=971
IGEShppa_SZ=731
IGEShpm68k_SZ=627
IMGG4sunos_SZ=53
IMGG4suns5_SZ=44
IMGG4hppa_SZ=53
IMGG4hpm68k_SZ=36
MIFCGMsunos_SZ=437
MIFCGMsuns5_SZ=525
MIFCGMhppa_SZ=389
MIFCGMhpm68k_SZ=333
BUILDERENG_SZ=6208
BUILDERFRA_SZ=20
BUILDERDEU_SZ=20
BUILDERLN_SZ=44
MAKERENG_SZ=4791
MAKERFRA_SZ=5376
MAKERDEU_SZ=5869
MAKERLN_SZ=44
VIEWERENG_SZ=500
VIEWERFRA_SZ=734
VIEWERDEU_SZ=719
VIEWERLN_SZ=32
ALLDICT_SZ=17514

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

VERSION="4.0.1P1m"
PRODID="Version 4.0.1P1m (Sun X/Motif) Tue Aug  3 03:00:38 PDT 1993"
PRODVERS="Frame Products"
TAROPTIONS="-xfp"
BS=20
THISHOST=`hostname`
THISMACH=`.install/fmarch`
DOBASE=1
FPDOBASE=1
INCLUDED=${INCLUDED:-"BASE LWSTD"}
UILANGUAGES="ENGLISH FRANCAIS DEUTSCH"
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"
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
	and 700/800 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.1P1m
   
   [ -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 "$PRODID" > /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)";;
          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";;
   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"
usestring="$use Kbytes"
echo 
sed -n "/^<PRODMAN/,/^>/p" $longdesc | grep -v '[<>]'
fm_ask y n "The Printed Manuals for FrameMaker ($usestring)"
fm_ans y $? && {
	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)"
	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"

	echo "$INCLUDED" | grep "sunxm.os.sparc" > /dev/null 2>&1 && {
	  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"
	  }
	}

	echo "$INCLUDED" | grep "sunxm.s5.sparc" > /dev/null 2>&1 && {
          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"
	  }
	}

	echo "$INCLUDED" | grep "hp.hpux.m68k" > /dev/null 2>&1 && {
          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"
	  }
	}

	echo "$INCLUDED" | grep "hp.hpux.pa" > /dev/null 2>&1 && {
          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"
	  }
	}

	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"
        }

	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 directories
echo "\
francais Manuels_electroniques
deutsch Online_Handbuecher" | \
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
      [ -h $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


# 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 
