#! /bin/sh
#
# usage:        icleanpe.sh
#		icleanpe (when executed from the CDROM)
#
# abstract:     Initial cleaning of the $MATLAB files associated with
#		the piece designated by the value of the environment
#		variable PIECE_PATH. This is ONLY for cleaning out
#		5.x files that must be deleted before taring over them
#		or can't be deleted by looking at the differences between
#		b and .b files.
#
# note(s):      1. If $MATLAB/update/pd/$piece_path/.b exists then there
#		   is nothing to do.
#
#		2. The following variables must exist in the environment
#
#		       MATLAB
#		       PIECE_PATH
#
#		3. This file is sourced by the normal install but executed
#		   by the CDROM install.
#
# Copyright (c) 1994-1998 by The MathWorks, Inc.
# $Revision: 1.25 $  $Date: 1998/11/11 23:43:53 $
#----------------------------------------------------------------------------
#
# Do special things if this is not sourced (run as icleanpe).
#
    if [ "$temp_file4" = "" ]; then
	temp_file4=/tmp/$$a
	temp_file5=/tmp/$$b
	trap "rm -f $temp_file4 $temp_file5 > /dev/null 2>&1; exit 1"  1 2 3 15
	startpath=`/bin/pwd`
	cd $MATLAB
    else
	startpath=`/bin/pwd`
	cd $MATLAB
    fi
#
# 3 header lines at the beginning of the file
#
    cat > $temp_file4 << EOF
#
cd $MATLAB
#
EOF
    if [ ! -f $MATLAB/update/pd/$PIECE_PATH/.b ]; then 
        case "$PIECE_PATH" in
	   install)
#--------------------------------------------------------------------
# 5.3 (R11) and later:
#     Delete any sun4 5.x files from install package. This is necessary
#     because the CD-ROM installer did not install the piece information
#     for this piece prior to 5.3.
#
        echo ./update/bin/sun4 >> $temp_file4 2>/dev/null
	echo ./matlab.lic >> $temp_file4 2>/dev/null
        echo ./startdoc/README.install >> $temp_file4 2>/dev/null
        echo ./startdoc/install.html >> $temp_file4 2>/dev/null
#--------------------------------------------------------------------
		;;
	    toolbox/symbolic/lib)
#--------------------------------------------------------------------
# This will blow the library directory or link to the library
# directory away
#
echo ./toolbox/symbolic/@symlibs >> $temp_file4 2>/dev/null
#--------------------------------------------------------------------
		;;
	    *)
:
		;;
	esac
    fi
#
# Skip over the first 3 lines which are not file/directories
#
    sed -e '4,$s/^/rm -rf /' -e '4,$s%$% > /dev/null 2>\&1%' $temp_file4 > $temp_file5
    chmod +x $temp_file5
#
    . $temp_file5
    cd $startpath
    rm -f $temp_file4 $temp_file5 > /dev/null 2>&1
