PROCEDURE (hidden) rap$install_installation_tape (
  installation_parameters, ip: (VAR) ..
*copy rat$installation_parameters
                                  = $required
  status)


*IF $variable(rav$proc_doc,declared)<>'UNKNOWN'

" PURPOSE:
"   This procedure installs the installation tape and creates the aam files.
"
" NOTES:
"   This routine assumes that packing list path has already been
"   checked to ensure that there will not be a collision when the packing
"   list is loaded.  Thus any error during the packing list load is of
"   unknown cause and it aborts the installation.
"
"   Need to check after each install for status rae$subproducts_failed_install
"
"   The error handling in this routine leaves something to be desired.
"   It should probably use rap$handle_status and do INSS in include files.
"   This, install_deferred_products and perform_installation_option need
"   the error handling modified to now consider that
"   install can return with warning/informative messages and yet have
"   the rest of system initiation continue.
*IFEND


*copy rav$margin

  "$FORMAT=OFF
  VAR
    create_status: status
    ignore_status: status
    local_status: status
    menu_selection: string 0 .. $max_name
    packing_list_loaded: boolean = false
    rav$software_maintenance: (xref) file
    rav$system: (xref) file
    tape_file: file
    temp_packing_list_name: name 1..16 = raf$temporary_pl
    temp_packing_list_path: file
    utility_status: status
    wait_for_operator_response: boolean = false
  VAREND
  "$FORMAT=ON"

  rap$display_message mm=initiation_messages ..
        mn=installing_installation_tape m=rav$margin t=$response ..
        status=ignore_status

  rap$load_installation_tools ip=installation_parameters tp=tape_file ..
        status=local_status
  EXIT procedure WITH local_status WHEN NOT local_status.normal

  inss_block: ..
  BLOCK

  "$ INSTALL_SOFTWARE
      $system.execute_task l=$local.raf$library sp=rap$install_software ..
            status=utility_status
      EXIT inss_block WHEN NOT utility_status.normal

    install_block: ..
      BLOCK

        IF rav$system <> :$system.$system THEN
          change_installation_defaults system_catalog=rav$system
        IFEND
        " Set tape back to the beginning_of_set so LOAD_PACKING_LIST will
        " find the packing list.
        change_tape_label_attributes f=tape_file fsp=bos status=local_status
        EXIT install_block WHEN NOT local_status.normal

        " Load the packing list into a temporary location to avoid possible collision.
        " Any conflicts are worked out when the packing list is moved to its
        " destination.

        temp_packing_list_path = rav$software_maintenance.installation_database//temp_packing_list_name
        $system.delete_file temp_packing_list_path status=ignore_status

        load_packing_list ..
              pl=temp_packing_list_name evsn=installation_parameters.evsn ..
              rvsn=installation_parameters.rvsn status=local_status
        EXIT install_block WHEN NOT local_status.normal

        rap$move_packing_list tplp=temp_packing_list_path ..
              pln=installation_parameters.packing_list status=local_status
        EXIT install_block WHEN NOT local_status.normal

        install_product pl=$name(installation_parameters.packing_list) ..
              p=nosve_installation_boot execute_in_job_of_caller=true ..
              spc=installation_parameters.save_previous_cycles ..
              status=local_status
        IF (NOT local_status.normal) AND ..
              (($condition(local_status.condition) = 'RAE$NO_SOFTWARE_TO_INSTALL') OR ..
               ($condition(local_status.condition) = 'RAE$SUBPRODUCTS_FAILED_INSTALL')) THEN
          $system.put_line l=' '//$strrep(local_status) o=$response
          wait_for_operator_response = TRUE
          local_status.normal = true
        IFEND
        EXIT install_block WHEN NOT local_status.normal

        install_product pl=$name(installation_parameters.packing_list) ..
              p=nosve_initial_software_load ..
              execute_in_job_of_caller=true ..
              spc=installation_parameters.save_previous_cycles ..
              status=local_status
        IF (NOT local_status.normal) AND ..
              (($condition(local_status.condition) = 'RAE$NO_SOFTWARE_TO_INSTALL') OR ..
               ($condition(local_status.condition) = 'RAE$SUBPRODUCTS_FAILED_INSTALL')) THEN
          $system.put_line l=' '//$strrep(local_status) o=$response
          wait_for_operator_response = TRUE
          local_status.normal = true
        IFEND
        EXIT install_block WHEN NOT local_status.normal

      BLOCKEND install_block

    QUIT

  BLOCKEND inss_block

  $system.detach_file f=tape_file status=ignore_status
  $system.detach_file f=$local.raf$library status=ignore_status

  " The operator environment must be recreated before the aam files can be created.

  rap$create_operator_environment

  IF wait_for_operator_response THEN
    rap$press_next
  IFEND

  IF local_status.normal AND utility_status.normal THEN
    rap$create_aam_files status=create_status
    IF NOT create_status.normal THEN
      $system.put_line (' '//$strrep($status(false, 'RA', rae$error_creating_aam_files)) ' '//$strrep(create_status)) ..
            o=$response
      local_status = $status(false, 'RA', rae$errors_occurred_warning, 'RAP$CREATE_AAM_FILES')
    IFEND
    rap$display_message mm=initiation_messages mn=installation_tape_installed m=rav$margin t=$response ..
          status=ignore_status
  IFEND

  EXIT procedure WITH local_status WHEN NOT local_status.normal
  EXIT procedure WITH utility_status WHEN NOT utility_status.normal

PROCEND rap$install_installation_tape
