/* Copyright (c) Oracle Corporation 1994.  All Rights Reserved */

/*****************************************************************************
  NAME
    cdesql15.vrf - V3 analysis/product configuration script for the
                   Windows Forms/Reports Developer Tools Database Tables package

  DESCRIPTION
    This script checks dependencies and environment settings for the
    installation of the Windows Forms/Reports Developer Database Tables package.

  OWNER
    Amanda Harrison

  MODIFIED    MM/DD/YY    Reason
*****************************************************************************/

{
    SHARED_ORACLE_COMPLIANT = TRUE;

    {doit = execute("%installer_home%%dir_separator%%operating_system%.vrf");}
    [
        'UNBOUND_VARIABLE:
        {
            required_version = product_version(instver_product);
            temp = explode(required_version,".");
            required_version = implode(list(first(temp),first(rest(temp)),
                                            first(rest(rest(temp))),
                                            first(rest(rest(rest(temp))))),".");
            signal('FAILURE,instantiate(nls("instver_too_early1","The version of the Installer currently running is %%installer_version%%. The installation you  have chosen requires version %%required_version%% or later. Please run version %%required_version%% or later in order to perform this installation.")));
        }
    ]                                                                     /* This FAILURE will cause 3.0.x.x installer to exit gracefully. */


    /******************************************************************************************************
    START MAIN LOGIC
    ******************************************************************************************************/
    if (doit)
    {

        /*****************************
        Set the VRF-INS script ratchet
        ******************************/
        vrf_ratchet = "6.0.0.0.0";

        /*************** 04/22/95 ***********************
        Create a label with the product name, and version
        *************************************************/
        EXECUTE_SCRIPT = "CREATE_LABEL";
        execute("%product_home%%dir_separator%d2kr2vrf.usr");
        /********** End - 04/22/95 **********************/

        /*************************
        Set product name variables
        **************************/
        REQUIRED_PRODUCT     = PLUS_PRODUCT; /* SQL*Plus required for install*/

          /* Setting SQLPATH */
          {
            set_sqlpath = FALSE;
            sqlpath = translate("SQLPATH", "$oracle");
            if (not(exists(sqlpath)))
             signal('UNBOUND_ENVIRONMENT_VARIABLE);
            else
            {
                 if(not(contains(sqlpath,"%ORACLE_HOME%\BROWSE60\SQL")))
                 {
                   sqlpath = "%sqlpath%;%ORACLE_HOME%\BROWSE60\SQL";
                   set_sqlpath = TRUE;
                 }
            }

          }
          [ 'OS_ERROR, 'INVALID_FILE_NAME, 'FILE_NOT_FOUND,
            'PERMISSION_DENIED, 'UNBOUND_ENVIRONMENT_VARIABLE:
          {
             sqlpath = "%sqlpath%;%ORACLE_HOME%\BROWSE60\SQL";
               set_sqlpath = true;
          }
          ]


        /**********************************************************************
        parent_in_control = TRUE ==> the complete product needs to be installed
        parent_in_control = FALSE ==> PARENT called by one of the components
        ***********************************************************************/
        parent_in_control = TRUE;
        if(not(member(selected_products, current_product)))
        {
            child_products = all_child_products(current_product);
            while(not(empty(child_products)))
            {
                next_child = first(child_products);
                child_products = rest(child_products);
                if(member(products_for_installation, next_child))    /* PARENT called by one of the components, no need to add PARENT to the list of products to be installed */
                    parent_in_control = FALSE;
            }
        }
        /**********************************************************************/

        /***************************************************************************
        Initialize total size of files
        ****************************************************************************/
        total_sum = 0;

        /***********************************************
        If PARENT is explicitly called for installation,
        verify all the component products
        ************************************************/
        if(parent_in_control)
        {
            EXECUTE_SCRIPT = "VERIFY_COMPONENTS";
            total_sum = total_sum + execute("%product_home%%dir_separator%d2kr2vrf.usr");
        }
        else
        {
            child_products = all_child_products(current_product);
            selected_components_list = list();
            size_component = 0;

            while(not(empty(child_products)))
            {
                next_child = first(child_products);
                if(member(selected_products, next_child))
                {
                    if(not(member(products_for_installation, next_child)))
                    {
                        size_component = verify(next_child);
                        if(size_component != 0)
                        {
                            add(selected_components_list, next_child);
                            total_sum = total_sum + size_component;
                        }
                    }
                }
                child_products = rest(child_products);
            }
        }

        total_sum = total_sum + sum(deinst);

        /**************************************
        Check if SQL*PLUS needs to be installed
        ***************************************/
        EXECUTE_SCRIPT     = "CHECK_REQUIRED_PRODUCT";
        execute("%product_home%%dir_separator%d2kr2vrf.usr");

        if (install_required_product)
            total_sum = total_sum + verify(REQUIRED_PRODUCT);

        /**************************************
                Return total size of files
        **************************************/
        total_sum = total_sum + sum(sqlb, sql);
        return(total_sum);

        /**********************************************************************/
    }
    else
    {
        refresh_map_file = FALSE;
        return(0);
    }
}
