#!/bin/sh
#set -x
# usage:        fcleanpe.sh
#
# abstract:     Final 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
#		any remaining old 5.x files. In most cases there is
#		nothing to do since icleanpe.sh was called at an earlier
#               time and handles the cleaning.
#
# 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 routine must be called using a . (period)
#
# Copyright (c) 1994-1998 by The MathWorks, Inc.
# $Revision: 1.18 $  $Date: 1998/11/11 23:43:51 $
#----------------------------------------------------------------------------
#
    startpath=`/bin/pwd`
    cd $MATLAB
#
# 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
#--------------------------------------------------------------------
                ;;
	    *)
		:
		;;
	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
