PROC load_base_1_files, load_base_1_file, loab1f (
  tape_file, tf  : file = $local.tape
  files, file, f : list of key new_prologs_and_epilogs, npae, sitecp_components, sc, ..
                       site_analyst_examples_manual, saem, all, a ..
                 = (new_prologs_and_epilogs sitecp_components)
  status         : var of status = $optional
  )


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

" This is one of several procedures created to simplify the installation process.
" These procedures are kept in the OSF$SITE_COMMAND_LIBRARY and therefore will
" receive minimal support.
"
" The purpose of this procedure is to load the specified files off of the BASE_1
" release tape.  The files are loaded to $NEXT of their actual destination as
" when installed by UPGRADE_SOFTWARE (rings, file permits and storage class may
" not be set correctly).
*IFEND


  create_variable file_destination k=string d=11
  create_variable file_name k=(string $max_name) d=11
  create_variable file_selected k=boolean d=11 v=false
  create_variable ignore_status k=status
  create_variable load_selected_files k=string v=$unique
  create_variable local_status k=status
  create_variable restore_status k=status
  create_variable tape_file k=string v=$string($value(tape_file))
  create_variable tape_vsn k=(string 6) v='NVE003'


  FOR i = 1 TO $set_count(files) DO
    files = $string($value(files, i))
    IF (files = 'NEW_PROLOGS_AND_EPILOGS') OR (files = 'NPAE') OR (files = 'ALL') OR (files = 'A') THEN
      create_catalog $user.prologs_and_epilogs status=ignore_status

      file_name(1) = 'JOB_ACTIVATION_PROLOG'
      file_destination(1) = '$USER.PROLOGS_AND_EPILOGS.JOB_ACTIVATION_PROLOG.$NEXT'
      file_selected(1) = true

      file_name(2) = 'JOB_ACTIVATION_EPILOG'
      file_destination(2) = '$USER.PROLOGS_AND_EPILOGS.JOB_ACTIVATION_EPILOG.$NEXT'
      file_selected(2) = true

      file_name(3) = 'NETWORK_ACTIVATION_PROLOG'
      file_destination(3) = '$USER.PROLOGS_AND_EPILOGS.NETWORK_ACTIVATION_PROLOG.$NEXT'
      file_selected(3) = true

      file_name(4) = 'NETWORK_ACTIVATION_EPILOG'
      file_destination(4) = '$USER.PROLOGS_AND_EPILOGS.NETWORK_ACTIVATION_EPILOG.$NEXT'
      file_selected(4) = true

      file_name(5) = 'SYSTEM_INITIATION_PROLOG'
      file_destination(5) = '$USER.PROLOGS_AND_EPILOGS.SYSTEM_INITIATION_PROLOG.$NEXT'
      file_selected(5) = true

      file_name(6) = 'SYSTEM_INITIATION_EPILOG'
      file_destination(6) = '$USER.PROLOGS_AND_EPILOGS.SYSTEM_INITIATION_EPILOG.$NEXT'
      file_selected(6) = true

      file_name(7) = 'SYSTEM_TERMINATION_PROLOG'
      file_destination(7) = '$USER.PROLOGS_AND_EPILOGS.SYSTEM_TERMINATION_PROLOG.$NEXT'
      file_selected(7) = true
    IFEND
    IF (files = 'SITECP_COMPONENTS') OR (files = 'SC') OR (files = 'ALL') OR (files = 'A') THEN
      create_catalog $user.nosve_maintenance status=ignore_status
      create_catalog $user.nosve_maintenance.deadstart_commands status=ignore_status

      file_name(8) = 'INSTALLATION_DEADSTART_COMMANDS'
      file_destination(8) = '$USER.NOSVE_MAINTENANCE.DEADSTART_COMMANDS.INSTALLATION_DEADSTART_COMMANDS.$NEXT'
      file_selected(8) = true

      file_name(9) = 'SYSTEM_DEADSTART_PROLOG'
      file_destination(9) = '$USER.NOSVE_MAINTENANCE.DEADSTART_COMMANDS.SYSTEM_DEADSTART_PROLOG.$NEXT'
      file_selected(9) = true
    IFEND
    IF (files = 'SITE_ANALYST_EXAMPLES_MANUAL') OR (files = 'SAEM') OR (files = 'ALL') OR (files = 'A') THEN
      create_catalog $user.manuals status=ignore_status
      create_catalog $user.manuals.examples_files status=ignore_status

      file_name(10) = 'SA_EXAMPLES_MANUALS'
      file_destination(10) = '$USER.MANUALS.SITE_ANALYST_EXAMPLES.$NEXT'
      file_selected(10) = true

      file_name(11) = 'SA_EXAMPLES_SOURCE_LIBRARY'
      file_destination(11) = '$USER.MANUALS.EXAMPLES_FILES.SITE_ANALYST_SOURCE_LIBRARY.$NEXT'
      file_selected(11) = true
    IFEND
  FOREND


load_files: ..
  BLOCK

    IF NOT $file($fname(tape_file), assigned) THEN
      put_line '   Mount the BASE_1 tape with VSN NVE003.' o=$response
      request_magnetic_tape f=$fname(tape_file) evsn=tape_vsn r=no status=local_status
      EXIT load_files WHEN NOT local_status.normal
    IFEND

COLLECT_TEXT $fname(load_selected_files//'.$boi') until='END_COLLECT'
  $system.osf$builtin_library.restore_permanent_files l=$job_log
  FOR i = 1 TO $variable(file_selected, upper_bound) DO
    IF file_selected(i) THEN
      put_line ('   Loading '//file_name(i)//' to:', ..
            '      '//$string($fname(file_destination(i)))) o=$response
      restore_file f=$fname($backup_file($fname(tape_file), identifier)//'.'//file_name(i)//'.1') ..
            bf=$fname(tape_file) nfn=$fname(file_destination(i)) status=restore_status
      EXIT WHEN NOT restore_status.normal AND ..
            ($condition(restore_status.condition) <> 'PUE$ERROR_SUMMARY_STATUS')
    IFEND
  FOREND
  quit
END_COLLECT

    include_file $fname(load_selected_files) status=local_status
    detach_file $fname(tape_file) status=ignore_status
    IF local_status.normal AND NOT restore_status.normal AND ..
          ($condition(restore_status.condition) <> 'PUE$ERROR_SUMMARY_STATUS') THEN
      local_status = restore_status
    IFEND

  BLOCKEND load_files

  delete_file $fname(load_selected_files) status=ignore_status

  EXIT_PROC WITH local_status WHEN NOT local_status.normal

PROCEND load_base_1_files
