#!/bin/sh
# @(#)do_post_install  $Revision: 1.53 $  $Date: 1994/01/25 19:39:01 $
# @(#)Copyright(c) 1993,1994 by Rational.
#
#  MODULE SPECIFICATION
#  Name:
#    post_install
#
#  Subsystem:
#    install
#
#  Description:  (for all but Rose)
#    fix up .Rational_Locations for Ada lrm subsystems and model
#    fix up imports
#    fix up compiler key in all switch files
#    run apex set_location, remodel, compile
#  For Rose:
#    Create the configuration files.
#------------------------------------------------------------------------

#------------------------------------------------------------------------
set_home_vars() {
#------------------------------------------------------------------------
#
# Check/set APEX_HOME or ROSE and PROD_HOME.
#
    if [ $feature = rose ]
    then
        if [ -z "$ROSE" ]
        then
            ROSE=`get_var INST_HOMEDIR`
        fi

        if [ -z "$ROSE" ]
        then
            fatal "ROSE must be defined.  Have you run 'install' yet?"
        fi

        if [ ! -d "$ROSE" ]
        then
            fatal "$ROSE not found"
        fi
        PROD_HOME=$ROSE
        return
    fi

    if [ $feature != apex  -a  -z "$APEX_HOME" ]
    then
        if [ $feature = soda ]
        then
            get_yn "Are you installing $product_name to be used with Apex?" yes
            if [ "$result" = no ]
            then
                get_input "Enter SODA_HOME:" `dirname $install_dir`
                SODA_HOME=$result
                export SODA_HOME
                PROD_HOME=$SODA_HOME
                return
            fi
        fi

        while [ -z "$APEX_HOME" ]
        do
            echo "The environment variable APEX_HOME must be set."
            get_input "Enter APEX_HOME:"
            APEX_HOME=$result
            if [ -d "$APEX_HOME" ]
            then
                break
            else
                echo "$APEX_HOME not found"
                exit 1
            fi
        done
        export APEX_HOME
    fi

    case $feature in
        apex )
            default_home=`dirname $install_dir`
            ;;
        asis )
            get_input "Enter APEX_ASIS_HOME:" `dirname $install_dir`
            APEX_ASIS_HOME=$result
            export APEX_ASIS_HOME
            ;;
        soda )
            get_input "Enter SODA_HOME:" `dirname $install_dir`
            SODA_HOME=$result
            export SODA_HOME
            PROD_HOME=$SODA_HOME
            return
            ;;
        rci )
            get_input "Enter APEX_RCI_HOME:" `dirname $install_dir`
            APEX_RCI_HOME=$result
            export APEX_RCI_HOME
            ;;
        testmate )
            get_input "Enter APEX_TM_HOME:" `dirname $install_dir`
            APEX_TM_HOME=$result
            export APEX_TM_HOME
            ;;
    esac

    if [ $feature = apex ]
    then
        canonical_def_home=`cpath $default_home`
        if [ -z "$APEX_HOME" ]
        then
            canonical_APEX_HOME=$canonical_def_home
        else
            canonical_APEX_HOME=`cpath $APEX_HOME`
            if [ "$canonical_APEX_HOME" != "$canonical_def_home" ]
            then
                echo
                echo "APEX_HOME ($APEX_HOME)"
                echo "is not the same as the parent of the install directory"
                echo "($canonical_def_home)"
                echo "APEX_HOME will be set to $canonical_def_home."
                get_yn "Do you want to continue?" yes
                if [ "$result" = no ]
                then
                    exit 1
                fi
                canonical_APEX_HOME=$canonical_def_home
            fi
        fi

        APEX_HOME=$canonical_APEX_HOME
    fi

    case $feature in
            apex ) PROD_HOME=$APEX_HOME ;;
            asis ) PROD_HOME=$APEX_ASIS_HOME ;;
             rci ) PROD_HOME=$APEX_RCI_HOME ;;
        testmate ) PROD_HOME=$APEX_TM_HOME ;;
    esac

    # Make sure that we have PATHs to where we need to run things from
    # and that the appropriate architecture is set.
    # Final path setting stuff... include directories touched by architecture.
    PATH=$APEX_HOME/share/bin:$PATH
    PATH=$APEX_HOME/$ARCH/bin:$APEX_HOME/$ARCH/cots/license:$PATH
}


#------------------------------------------------------------------------
set_apex_base() {
#------------------------------------------------------------------------
#
# Set APEX_BASE
#
    separator
    fmt_mesg "This script needs to know where the base layer and model
              subsystems are installed to proceed. (i.e. the Rational Base
              Library Directory)"
    
    if [ -n "$APEX_BASE" ]
    then
        # Compare APEX_BASE to prod_base
        if [ "`cpath $APEX_BASE`"  !=  "`cpath $prod_base`" ]
        then
            fmt_mesg "The environment variable APEX_BASE is set and is
                      different from the value provided to the install script:"
            echo "APEX_BASE:     $APEX_BASE"
            echo "install value: $prod_base"
    
            fmt_mesg "It is important that the directory provide access to the
                      installed subsystems."
        fi
    fi
    
    def_prod_base=$prod_base
    while true
    do
        get_input "Rational Base Library Directory:" "$def_prod_base"
        prod_base=$result
        if [ -z "$prod_base" ]
        then
            error "There is no default pathname.  You must input a path to
                   the Rational Base Library Directory."
            continue
        fi
    
        if [ ! -d $prod_base ]
        then
            error "The pathname input must be a directory name."
            continue
        fi
    
        if [ ! -d $prod_base/ada ]
        then
            error "Cannot find ada directory under $prod_base.
                   Check pathname.  If pathname is correct, product
                   may not be installed properly."
            continue
        fi
    
        if [ ! -d $prod_base/ada/model.ss ]
        then
            error "Cannot find ada/model.ss directory under $prod_base.
                   Check pathname.  If pathname is correct, product may
                   not be installed properly."
            continue
        fi
    
        break
    done
    
    APEX_BASE=$prod_base
    echo "Base Library Directory: $APEX_BASE"
}


#------------------------------------------------------------------------
set_apex_locking() {
#------------------------------------------------------------------------
#
# Set APEX_LOCKING before patching apexinit.
#

    fmt_mesg "Apex can automatically recover abandoned file locks that were
        acquired by a process no longer running another machine. To do this,
        Apex must be able to run a 'remote' command that checks process
        existence on that other machine.  There are several options for how
        this can be done:"

    echo "
    No_Remote: don't attempt such lock recoveries
    Rsh:       use the 'rsh' remote shell command
    On:        use the 'on' command (recommended)"

    fmt_mesg "For further information about the APEX_LOCKING switch, refer
        to the Installation Guide."

    while true
    do
        fmt_mesg "What form of remote process existence testing should be
            the default for Apex users?"
        get_input "No_Remote, Rsh, or" On

        case $result in
            ON|On|on )
                result=On
                break
                ;;
            [Nn]o* )
                result=No_Remote
                break
                ;;
            [Rr]sh )
                result=Rsh
                break
                ;;
            * )
                echo "You must select one of No_Remote, Rsh, or On"
                ;;
        esac
    done

    APEX_LOCKING="Remote=>$result"
    return $?
}


#------------------------------------------------------------------------
tell_about_steps() {
#------------------------------------------------------------------------
#
# args: Extra steps to tell the installer about
#       patch: if necessary to patch config file(s).
#       testmate: Fix up TestMate data objects
#

    separator

    fmt_mesg "This part of the installation process will do the final steps
              needed to get the $product_name product up and running.  It will:"

    n=1
    for step in $* $view_steps
    do
        case $step in
            ranlib )
                echo "
    $n) Run ranlib over $product_name libraries."
                ;;
            patch )
                echo "
    $n) Patch the init script for your local configuration."
                ;;
         testmate )
                echo "
    $n) Fix up TestMate data objects."
                ;;
            set_location )
                echo "
    $n) Fix the .Rational_Location pointers for the Ada subsystems."
                ;;
            remodel )
                echo "
    $n) Fix up the imports and switches for the Ada base views."
                ;;
            compile )
                echo "
    $n) Compile, the base and model views."
                ;;
            freeze )
                echo "
    $n) Freeze the base and model views."
                ;;
        esac
        n=`expr $n + 1`
    done

    press_cr
}


#------------------------------------------------------------------------
customize_imports() {
#------------------------------------------------------------------------
#
# arg1: view_path
#

    view_path=$1

    echo "    * fixing imports in $view_path"
    sed -e "s#%%APEX_BASE%%/$cur_lang_name#$APEX_BASE/$cur_lang_name#" \
        $view_path/Imports/Description.cfg > /tmp/mp.import_temp
    cp /tmp/mp.import_temp $view_path/Imports/Description.cfg
    /bin/rm -f /tmp/mp.import_temp
}

#------------------------------------------------------------------------
customize_switches() {
#------------------------------------------------------------------------
#
# arg1: view_path
#

    view_path=$1

    echo "    * fixing switches in $view_path"

    # Set CK_HOME -- Home directory where compiler keys are located.
    case $feature in
        asis|posix|testmate )
            # Select the latest version of Apex that works with feature.
            config=$rational_dir/config
            set -- `grep "^$feature.$product_version" $config/version_map`
            shift
            while [ $# -gt 0 ]
            do
                # Make sure this version of Apex is installed.
                if [ -d $rational_dir/releases/$1 ]
                then
                    CK_HOME=$rational_dir/releases/$1
                fi
                shift
            done

            if [ -z "$CK_HOME" ]
            then
                # None found, so try to use APEX_HOME.
                if [ -d $APEX_HOME ]
                then
                    CK_HOME=$APEX_HOME
                else
                    fmt_mesg "Before installing $product_name version
                              $product_version you need to have one of
                              these versions of Rational Apex install:"
                    grep "^$feature.$product_version" $config/version_map |
                    sed -e "s/^$feature.$product_version */    /g"
                    exit 1
                fi
            fi
            ;;

        rci )
            case `basename $ss_path` in
                lrm.ss|model.ss|predefined.ss) CK_HOME=$PROD_HOME ;;
                * ) CK_HOME=$APEX_HOME ;;
            esac
            ;;

        * )
            # All other features and Apex use their own compiler keys.
            CK_HOME=$PROD_HOME
            ;;
    esac

    sed -e \
        "s#COMPILER_KEY: %%APEX_HOME%%/keys#COMPILER_KEY: $CK_HOME/keys#" \
        $view_path/Policy/Switches > /tmp/mp.switches_temp

    cp /tmp/mp.switches_temp $view_path/Policy/Switches

    if [ $feature = posix ]
    then
        sed -e "s?^RUNTIMES: %%APEX_BASE%%/api/?RUNTIMES: $APEX_BASE/api/?" \
            $view_path/Policy/Switches > /tmp/mp.switches_temp
        mv /tmp/mp.switches_temp $view_path/Policy/Switches
    fi

    /bin/rm -f $view_path/.Rational/Compilation/Compiler_Key.times \
        /tmp/mp.switches_temp

    # If the subsystem has switches, eliminate them.  Let Apex use
    # its defaults.
    if [ -w $ss_path/Policy/Switches ]
    then
        cat /dev/null > $ss_path/Policy/Switches
    fi
}

#------------------------------------------------------------------------
customize_view() {
#------------------------------------------------------------------------
#
# arg1: language
# arg2: subsystem_name
# arg3: view_name
#

    ss_path=$APEX_BASE/$1/$2
    view_path=$ss_path/$3

    # Verify if view has been installed.  If not, just return.
    if [ ! -d $view_path ]
    then
        return
    fi

    # Verify if the view has been frozen. If so, we do not want to
    # do any of the view_steps (remodel, compile, freeze, etc.)
    view_properties=$view_path/.Rational/View_Control/View_Properties
    release_kind=`grep "^RELEASE_KIND:" $view_properties`
    if [ "$release_kind" = "RELEASE_KIND: frozen" ]
    then
        echo "!!! This view has been frozen."
        return
    fi

    # If the 'abbr' file is present, read it to determine the directory names
    # that were shortened to fit on the tar tape.  This is to avoid tar's
    # 100 character filename limit.
    if [ -s  $install_dir/abbr ]
    then
        cat $install_dir/abbr | while read short_name long_name
        do
            if [ -d $view_path/$short_name ]
            then
                mv $view_path/$short_name $view_path/$long_name
            fi
        done
    fi

    customize_imports $view_path
    customize_switches $view_path

    SET_LOCATION="$SET_LOCATION
    echo
    echo $APEX_SET_LOCATION $ss_path
    apex $APEX_SET_LOCATION $ss_path"

    REMODEL="$REMODEL $view_path"

    # Freeze view if it is not the model view
    if [ "$2" != model.ss ]
    then
	FREEZE="$FREEZE $view_path"
    fi

    # Do not add model.ss in the list of subsystems to be compiled.
    # It gives errors because it is empty.
    if [ "$2" != model.ss ]
    then
        COMPILE="$COMPILE $view_path"
    fi
}

#------------------------------------------------------------------------
add_error_check() {
#------------------------------------------------------------------------
#
# arg1: apex command name
#

    cat <<!
if [ \$? -ne 0 ]
then
    echo "Error in apex $1"
    exit 1
fi
!

}

#------------------------------------------------------------------------
customize_subsystems() {
#------------------------------------------------------------------------
#
# arg1: subsystem
#

    APEX_SET_LOCATION="set_location -replace"
    APEX_REMODEL="remodel -refresh -force"
    APEX_COMPILE="compile"
    APEX_FREEZE="remodel -release_kind frozen"

    SET_LOCATION=
    REMODEL="$APEX_REMODEL"
    COMPILE="$APEX_COMPILE"
    FREEZE="$APEX_FREEZE"

    i=1
    while [ $i -le $layer_count ]
    do
        eval layer_arch=\$layer_${i}_arch
        eval layer_hwarch=\$layer_${i}_hwarch
        eval layer_ver=\$layer_${i}_ver
        view_name=${layer_arch}.${layer_ver}.rel
        eval layer_lang=\$layer_${i}_lang
        eval layer_ss_count=\$layer_${i}_ss_count
        j=1
        while [ $j -le $layer_ss_count ]
        do
            eval ss_name=\$layer_${i}_ss_${j}_name
            if [ -d $APEX_BASE/$layer_lang/$ss_name/$view_name ]
            then
                separator
                if [ "$layer_hwarch" = $ARCH ]
                then
                    echo "Doing subsystem $ss_name view $view_name"
                    echo
                    customize_view "ada" $ss_name $view_name
                else
                    echo "!!! Not doing subsystem $ss_name view $view_name"
                    echo "    The $command script needs to be run on `system_name $layer_hwarch` machine,"
                    echo "    if you have not already done so."
                fi
            fi
            j=`expr $j + 1`
        done
        i=`expr $i + 1`
    done


    apex_script=/tmp/apex_script.$$
    add_cleanup_file $apex_script
    echo "#!/bin/sh" > $apex_script
    chmod +x $apex_script

    for step in $view_steps
    do
	case $step in
            set_location )
                if [ -z "$SET_LOCATION" ]
                then
                    continue  # no view to set location on
                fi

                echo "echo" >> $apex_script
                echo "echo '$SEP'" >> $apex_script
                apex_command="$APEX_SET_LOCATION"
                echo "$SET_LOCATION" >> $apex_script
                ;;

            remodel )
                if [ "$REMODEL" = "$APEX_REMODEL" ]
                then
                    continue  # no view to remodel
                fi

                echo "echo" >> $apex_script
                echo "echo '$SEP'" >> $apex_script
                apex_command="$APEX_REMODEL"
                echo "echo $REMODEL" >> $apex_script
                echo "apex $REMODEL" >> $apex_script
                ;;

            compile )
                if [ "$COMPILE" = "$APEX_COMPILE" ]
                then
                    continue  # no view to compile
                fi

                echo "echo" >> $apex_script
                echo "echo '$SEP'" >> $apex_script
                apex_command="$APEX_COMPILE"
                echo "echo $COMPILE" >> $apex_script
                echo "apex $COMPILE" >> $apex_script
                ;;

            freeze )
                if [ "$FREEZE" = "$APEX_FREEZE" ]
                then
                    continue  # no view to make frozen
                fi

                echo "echo" >> $apex_script
                echo "echo '$SEP'" >> $apex_script
                apex_command="$APEX_FREEZE"
                echo "echo $FREEZE" >> $apex_script
                echo "apex $FREEZE" >> $apex_script
                ;;
        esac

        add_error_check "$apex_command" >> $apex_script

    done

    $APEXINIT -batch -reset $apex_script
}

#------------------------------------------------------------------------
no_go () {
#------------------------------------------------------------------------

    separator
    fatal "$* You must run the get_license_info script and start
        the license server before running this script."
    exit 1
}


#------------------------------------------------------------------------
set_arch_os() {
#------------------------------------------------------------------------
#
# arg1: system arch (rs6k,sun4)
#

    case "$1" in
        rs6k)
            arch_os=rs6k_aix
            ;;
        sun4)
            arch_os=sun4_sunos
            ;;
        *)
            arch_os=unknown
            ;;
    esac
}


#------------------------------------------------------------------------
get_model_version() {
#------------------------------------------------------------------------

    set_arch_os $ARCH
    i=1
    while [ $i -le $layer_count ]
    do
        eval layer_name=\$layer_${i}_name
        eval layer_arch=\$layer_${i}_arch
        eval layer_lang=\$layer_${i}_lang
        if [    $layer_name = "model" \
             -a $layer_arch = "$arch_os" \
             -a $layer_lang = "ada" ]
        then
            eval echo \$layer_${i}_ver
            return
        fi
        i=`expr $i + 1`
    done
    echo "unknown"
}

#------------------------------------------------------------------------
get_model_path() {
#------------------------------------------------------------------------
#
# arg1: <architecture>
#

    set_arch_os $1
    echo "$APEX_BASE/ada/model.ss/$arch_os.$model_version.rel"
}


#------------------------------------------------------------------------
run_ranlib() {
#------------------------------------------------------------------------
#
# arg1: on_arch:  architecture
# arg2: sys_name: system name
# arg3: lib_path: library path name
#

    on_arch=$1
    sys_name=$2
    lib_path=$3

    chmod_w=":"

    if [ ! -f $lib_path ]
    then
        return
    fi

    if [ ! -w $lib_path ]
    then
        chmod +w $lib_path
        chmod_w="chmod -w $lib_path"
    fi

    if [ -f $lib_path ]
    then
        if [ "$ARCH" = "$on_arch" ]
        then
            echo "Running ranlib on $lib_path"
            ranlib $lib_path
        else
            fmt_mesg "Need to run ranlib on a $sys_name workstation on:
                $lib_path"
            get_input "$sys_name workstation to run ranlib on:"  none
            if [ "$result" = none ]
            then
                fmt_mesg "You need to login to a $sys_name workstation and
                    run ranlib before using $product_name on a $sys_name."
            else
                rhost=result
                fmt_mesg "rsh $rhost ranlib $lib_path"
                rsh $rhost ranlib $lib_path
            fi
        fi
    fi
    eval $chmod_w
}


#------------------------------------------------------------------------
set_lm_license_file() {
#------------------------------------------------------------------------
#
# SV_LIC_FILE_NAME should be set to the full path of license.dat.
# It is set in the .license_data file.
# Check the .license_data files first and LM_LICENSE_FILE last.
#

    if [ -f $install_dir/.license_data ]
    then
        . $install_dir/.license_data
    elif [ -f $APEX_HOME/install/.license_data ]
    then
        . $APEX_HOME/install/.license_data
    fi

    if [ -z "$SV_LIC_FILE_NAME" ]
    then
        if [ -n "$LM_LICENSE_FILE" ]
        then
            SV_LIC_FILE_NAME=$LM_LICENSE_FILE
        else
            no_go "Cannot find 'get_license_info' data and
                   LM_LICENSE_FILE not set."
        fi
    fi

    if [ ! -f $SV_LIC_FILE_NAME ]
    then
        no_go "License file not found: $SV_LIC_FILE_NAME"
    fi
    LM_LICENSE_FILE=$SV_LIC_FILE_NAME
    export LM_LICENSE_FILE

    echo "License File: $LM_LICENSE_FILE"
    if grep '^FEATURE ' $LM_LICENSE_FILE >/dev/null 2>&1
    then
        :
    else
        no_go "Cannot find FEATURE line in license file.
               Has $vendor given you your license key?"
    fi
}


#========================================================================
# Main
#========================================================================

forbid_root

check_and_set_arch

read_prod_desc

set_home_vars


# Get default base directory from data that the install program wrote
if [ -s $install_dir/.install_defaults ]
then
    . $install_dir/.install_defaults
fi

echo
echo "Post install for version $product_version of the $product_name product."
echo
echo "$product_name home directory: $PROD_HOME"

separator

#------------------------------------------------------------------------
# Check system requirements
#------------------------------------------------------------------------
if [ -x ./check_reqs ]
then
    ./check_reqs -install
    if [ $? -gt 1 ]
    then
        # Abort this script
        echo
        fmt_mesg "Cannot continue until required system parameters
                  have been satisfied."
        exit 1
    fi
fi


#------------------------------------------------------------------------
# Verify license server installation
#------------------------------------------------------------------------
if [ $feature = rose  -o  $feature = soda ]
then
    :
else
    echo "Verifying installation and license server."
    set_lm_license_file

    # Try to start the message server.  If we can't start it, assume that
    # there's no license to be had.
    APEX_MESSAGE_SERVER=`$APEX_HOME/$ARCH/bin/Apex_Message_Server`
    if [ $? -gt 0 ]
    then
        no_go "Cannot get a license.  Has $vendor given you your license key?"
    fi
    export APEX_MESSAGE_SERVER
    echo "Rational Apex licensing appears to be okay."

    # Check layered product license
    if [ $check_license = yes ]
    then
        echo "Verifying $product_name licensing"
        if apex_display -check_license $feature
        then
            echo "$product_name licensing appears to be okay."
        else
            lic_status=$?
            get_yn "Do you want to continue?" no
            if [ "$result" = no ]
            then
                exit $lic_status
            fi
        fi
    fi

    $APEX_HOME/$ARCH/bin/apex_display -shutdown_all
    unset APEX_MESSAGE_SERVER
fi


#------------------------------------------------------------------------
# Patch files that reference installed locations of directories/files.
#------------------------------------------------------------------------
add_cleanup_file /tmp/patch_script.$$
case $feature in
    apex )
        set_apex_base
        if [ -f $APEX_HOME/bin/apexinit ]
        then
            tell_about_steps
        else
            tell_about_steps patch

            echo "Patching $APEX_HOME/bin/apexinit.sh script"
            echo "APEX_BASE=$APEX_BASE" > /tmp/patch_script.$$
            echo "APEX_HOME=$APEX_HOME" >> /tmp/patch_script.$$
            echo "APEX_LICENSE_FILE=$SV_LIC_FILE_NAME" >> /tmp/patch_script.$$

            model_version=`get_model_version`
            if [ "$model_version" = unknown ]
            then
                fatal "No system architecture type matches the model subsystem."
            fi

            model_path_rs6k=`get_model_path rs6k`

            echo "APEX_DEFAULT_MODEL_RS6K=$model_path_rs6k" \
                >> /tmp/patch_script.$$

            model_path_sun4=`get_model_path sun4`
            echo "APEX_DEFAULT_MODEL_SUN4=$model_path_sun4" \
                >> /tmp/patch_script.$$

            set_apex_locking
	    echo APEX_LOCKING=\"$APEX_LOCKING\" >> /tmp/patch_script.$$

            echo
            $install_dir/patch_script \
	        /tmp/patch_script.$$ \
	        $APEX_HOME/bin \
	        $APEX_HOME/bin/apexinit.sh
        fi

	chmod -R a-w $APEX_HOME/share/doc/En_US
	;;

    rci )
        set_apex_base
        if [ -f $APEX_RCI_HOME/bin/rci.init ]
        then
            tell_about_steps
        else
            tell_about_steps patch

            echo "Patching $APEX_RCI_HOME/bin/rci.init.sh script"
            echo "APEX_RCI_HOME=$APEX_RCI_HOME" > /tmp/patch_script.$$

            $install_dir/patch_script \
	        /tmp/patch_script.$$ \
	        $APEX_RCI_HOME/bin \
	        $APEX_RCI_HOME/bin/rci.init.sh
        fi

	chmod -R a-w $APEX_RCI_HOME/share/doc/En_US
	echo "rci.$product_version $APEX_RCI_HOME" > /tmp/lp.start.$$
        ;;

    asis )
        set_apex_base
        if [ -f $APEX_ASIS_HOME/bin/asis.init ]
        then
            tell_about_steps ranlib
	    run_ranlib sun4 Sparc   $PROD_HOME/sun4/lib/libasis.a
	    run_ranlib rs6k RS/6000 $PROD_HOME/rs6k/lib/libasis.a
        else
            tell_about_steps patch ranlib
	    run_ranlib sun4 Sparc   $PROD_HOME/sun4/lib/libasis.a
	    run_ranlib rs6k RS/6000 $PROD_HOME/rs6k/lib/libasis.a

            echo "Patching $APEX_ASIS_HOME/bin/asis.init.sh script"
            echo "APEX_ASIS_HOME=$APEX_ASIS_HOME" > /tmp/patch_script.$$

            $install_dir/patch_script \
	        /tmp/patch_script.$$ \
	        $APEX_ASIS_HOME/bin \
	        $APEX_ASIS_HOME/bin/asis.init.sh
        fi

	chmod -R a-w $APEX_ASIS_HOME/share/doc/En_US
        ;;

    rose )
        if [ -f $install_dir/rose.post_install ]
        then
            . $install_dir/rose.post_install
        fi
        exit 0
        ;;

    soda )
        if [ -f $install_dir/soda.post_install ]
        then
            . $install_dir/soda.post_install
        fi
        exit 0
        ;;

    testmate )
        set_apex_base
        if [ -f $APEX_TM_HOME/bin/testmate.init ]
        then
            tell_about_steps testmate
        else
            tell_about_steps patch testmate

            echo "Patching $APEX_TM_HOME/bin/testmate.init.sh script"
            echo "APEX_TM_HOME=$APEX_TM_HOME" > /tmp/patch_script.$$

            $install_dir/patch_script \
                /tmp/patch_script.$$ \
                $APEX_TM_HOME/bin \
                $APEX_TM_HOME/bin/testmate.init.sh
        fi

        chmod -R a-w $APEX_TM_HOME/share/doc/En_US
        echo "testmate.$product_version $APEX_TM_HOME" > /tmp/lp.start.$$

        if [ -f $install_dir/testmate.post_install ]
        then
            . $install_dir/testmate.post_install
        fi

        ;;

esac

#------------------------------------------------------------------------
# Make sure apexinit is installed properly.
#------------------------------------------------------------------------
if [ -x $APEX_HOME/bin/apexinit ]
then
    if [ -f /tmp/lp.start.$$ ]
    then
        # Tell apexinit to load the layered product's init file.
        add_cleanup_file /tmp/lp.start.$$
        APEXINIT="$APEX_HOME/bin/apexinit -startup /tmp/lp.start.$$"
    else
        APEXINIT=$APEX_HOME/bin/apexinit
    fi
else
    fatal "Cannot find apexinit in $APEX_HOME/bin.
           Check that APEX_HOME is set correctly and that
           Rational Apex installation is complete."
fi

#------------------------------------------------------------------------
# Check for pre_patch scripts
#------------------------------------------------------------------------
if [ -x $install_dir/pre_patch ]
then
    $install_dir/pre_patch
fi

#------------------------------------------------------------------------
# Set location, remodel, compile and freeze subsystems.
#------------------------------------------------------------------------
if customize_subsystems
then :
else
    fatal "Post-installation of the $product_name product failed."
fi


#------------------------------------------------------------------------
# Check for post_patch scripts
#------------------------------------------------------------------------
if [ -x $install_dir/post_patch ]
then
    $install_dir/post_patch
fi

echo "Installation of the $product_name product is complete."

