/* Copyright (c) Oracle Corporation 1992.  All Rights Reserved */

/*****************************************************************************
  NAME
    orainst.ins - Windows V3 Installer Installation Script

  DESCRIPTION
    This script installs the Windows Oracle Installer.

  OWNER
    Dan Galatin

  MODIFIED   MM/DD/YY REASON
    dgalatin 07/29/94 Blow away all old oi<lang>.res files from DBS.
    dgalatin 07/25/94 Added windows.shd to the backup files list.
    dgalatin 07/22/94 Changed to fix bug #226821.
    jicohen 10/23/92 Created.
*****************************************************************************/

{
  if (doit)
    {
      ui_product(product_label);

      inst_dir = "%oracle_home%\ORAINST";
      backup_dir = "%inst_dir%\backup";
      backup_marker = "%inst_dir%\backup.mk";
      if (exists(backup_marker))
	{
	  /* at this point, backup files are not valid */
	  remove_file(backup_marker);
	  a_list = list("WINDOWS.AVF", "WINDOWS.VRF", "WINDOWS.PVF",
			"WINDOWS.INS", "WINDOWS.DEI", "WINDOWS.PIN",
			"WINDOWS.SHD","PATH.VRF", "MAKEDIR.VRF");
	  {
	    while (not(empty(a_list))) 
	      {
		the_file = first(a_list);
		a_list = rest(a_list);
		remove_file("%backup_dir%\%the_file%");
	      }
	    remove_directory(backup_dir);
	  } [ 'default: continue(); ]
	}

      /* Remove any resource files from %oracle_home%\DBS */

      old_resources = files("%oracle_home%\DBS\OI*.RES");

      while (not(empty(old_resources)))
        {
          the_file = first(old_resources);
          remove_file(the_file);
          old_resources = rest(old_resources);
        }

      ui_action(instantiate(installing_executables));
      copy(exec);

      ui_action(instantiate(installing_resources));
      copy(res);

      ui_action(instantiate(installing_scripts));
      copy(script);
      copy(deinstl);

      { copy(user,user_subgroup); }
      ['FILE_NOT_FOUND: continue();]

      ui_action(recording_name);

      {
        {
	  if (exists("%oracle_home%\dbs\oi%nls_abbreviation%.res"))
            save_customer_name(the_customer_name,
			       "%oracle_home%\dbs\oi%nls_abbreviation%.res");
        }
	  [ 'WRITE_PROTECTED: signal('WRITE_ERROR); ]
      }
	[ 'WRITE_ERROR: signal('FAILURE,instantiate(recording_name_error1)); ]

      {
	{
	  if (nls_abbreviation != "us")
	    save_customer_name(the_customer_name,
			       "%oracle_home%\dbs\oius.res");
	}
	  [ 'WRITE_PROTECTED: signal('WRITE_ERROR); ]
      }
	[ 'WRITE_ERROR: signal('FAILURE,instantiate(recording_name_error2)); ]


      register(current_product);
      reference(current_product);
    }
  
  if ((bootstrap) && (product_location(current_product) == ""))
    {
      if (autoexec_modified)
	signal('failure,autoexec_changed_message);
      else if ((doit) || (version_status == 'reinstall))
        {
	  information_dialog(success_message,success_content,success_help); 
	  modify("BOOT","%oracle_home%\BIN\WINST.EXE",".\BOOT.ORA");
        }
    }
      [ 'CANCEL: continue(); ]
}
