PROC rap$apply_all_corrections (
  correction_package, cp: file
  new_ve_deadstart_tape, nvdt: list 1..2 of string 1..6 or ..
        key MT9$800 MT9$1600 MT9$6250 MT18$38000
  apply_option, ao: key all new = new
  file_installation_options, fio: key defer_file_installation dfi ..
        immediate_installation ii = defer_file_installation
  retain_previous_versions, retain_previous_version, rpv: boolean = true
  status)


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

"    The purpose of this request is to install an entire set of
"corrections on a system.  And if so needed generate a new
"deadstart file.
"    This command functions with an empty installation catalog by
"reloading the corresponding product files for the corrections to
"be applied.  The corrections are sorted and applied by product.
"After all the corrections for a specific product have been
"installed the installation catalog contents are deleted.
"   Products that are not currently installed are not corrected.
*IFEND


  create_variable applier k=string v='$LOCAL.'//$unique
  create_variable correction_package k=string v='$USER.'//$unique
  create_variable ignore_status k=status
  create_variable local_status k=status
  create_variable os_changes k=integer
  create_variable standard_processing k=boolean v=on
  create_variable tape_count k=integer


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

"    Verify the input the NEW_VE_DEADSTART_TAPE parameter if
"specified.  Only 1 tape vsn can be given on the
"NEW_VE_DEADSTART_TAPE parameter.
*IFEND


  IF $specified(new_ve_deadstart_tape) THEN
    include_line ..
    'rap$interpret_tape_values '//$parameter(new_ve_deadstart_tape)//' tc=tape_count' status=local_status
    IF local_status.normal AND (tape_count <> 1) THEN
      message = 'NEW_VE_DEADSTART_TAPE'//$char(31)//'only 1'//$char(31)//$strrep(tape_count)
      local_status = $status(FALSE, 'RA', rae$unexpected_tape_count, message)
    IFEND
    EXIT_PROC WITH local_status WHEN NOT local_status.normal
  IFEND


  correction_package = $string($value(correction_package))


apply_corrections: ..
  BLOCK


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

"    Determine if the correction package has an APPLIER.  If so
"processing is turned over to the APPLIER.  The APPLIER can turn
"off standard processing.
*IFEND


    rap$get_correction_applier cp=$fname(correction_package) a=$fname(applier) status=local_status
    IF local_status.normal THEN
      include_file $fname(applier) status=local_status
    ELSEIF $condition(local_status.condition) = 'RAE$APPLIER_NOT_PRESENT' THEN
      local_status.normal = TRUE
    IFEND
    EXIT apply_corrections WHEN NOT local_status.normal


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

"    When standard processing, apply all corrections and generate a
"new nosve deadstart file if there where any corrections to the os
"files.
*IFEND


    IF standard_processing THEN

      command_line = 'rap$process_all_corrections cp=$fname(correction_package)'
      IF $specified(new_ve_deadstart_tape) THEN
        command_line = command_line//' nvdt='//$parameter(new_ve_deadstart_tape)
      IFEND
      command_line = command_line//' ao=$value(apply_option)'
      command_line = command_line//' fio=$value(file_installation_options)'
      command_line = command_line//' rpv=$value(retain_previous_versions)'

      include_command command_line status=local_status
      EXIT apply_corrections WHEN NOT local_status.normal
    IFEND

  BLOCKEND apply_corrections

  IF $file($value(correction_package), permanent) THEN
    detach_file $value(correction_package) status=ignore_status
  IFEND

  EXIT_PROC WITH local_status

PROCEND rap$apply_all_corrections

