PROCEDURE qcp$generate_qcu_deadstart_cat (
 output, o: file = $output
  status)

      VAR
        qcv$system: (XDCL) file = $SYSTEM
      VAREND



IF $file($value(output) open_position) = '$BOI' THEN
   ofile = $string($value(output)) //'.$ASIS'
ELSE
   ofile = $string($value(output))
IFEND

  "$FORMAT=OFF"
  VAR
    name_sou_library: name = sou_library
    name_builtin_library: name = builtin_library
    name_dcfile: name = dcfile
    name_deadstart_catalog: name = deadstart_catalog
    name_deadstart_commands_catalog: name = deadstart_commands
    name_jt_link_map: name = job_template_link_map
    name_link_input_catalog: name = link_input_files
    name_link_output_catalog: name = link_output_files
    name_mf_config_catalog: name = mf_config_files
    name_mf_config_files: name = mf_config_files
    name_non_boot_drivers_catalog: name = non_boot_drivers
    name_non_boot_drivers_file: name = non_boot_drivers
    name_nosve_maintenance_catalog: name = nosve_maintenance
    name_os_version_file: name = os_version
    name_osf$builtin_library: name = osf$builtin_library
    name_osf$sou_library: name = osf$sou_library
    name_physical_config: name = physical_config
    name_physical_configuration: name = physical_configuration
    name_product_files_catalog: name = product_files
    name_prolog_file: name = prolog_file
    name_prolog_library: name = prolog_library
    name_sc_link_map: name = system_core_link_map
    name_site_maintenance_catalog: name = site_os_maintenance
    name_system_debug_table: name = system_debug_table
  VAREND
  "$FORMAT=ON"


  VAR
    bacpf_file: file = $local//$name($unique)
    command_file: file = $local//$name($unique)
    configuration_files_catalog: file
    ignore_status: status
    local_status: status

    name_qcu_maintenance_catalog: name = qcu_maintenance
    name_qcu_log_file: name = qcu_log
    name_qcu_field_maintenance: name = field_maintenance
    name_qcu_state: name = site_modifications
    name_os_version: name = os_version
    name_deadstart_commands: name = deadstart_commands

    new_sou_library: file
    new_builtin_library: file
    new_deadstart_catalog: file
    new_link_output_catalog: file
    new_non_boot_drivers_file: file
    new_version_catalog: file

    nosve_sou_library: file
    nosve_builtin_library: file
    nosve_deadstart_catalog: file
    nosve_link_input_catalog: file
    nosve_maintenance_catalog: file
    nosve_non_boot_drivers_file: file
    nosve_version_file: file

    qcu_maintenance_catalog: file
    qcu_link_input_catalog: file
    qcu_log_file: file
    qcu_state_file: file
    qcu_field_maintenance_catalog: file
    qcu_version_file: file

    site_sou_library: file
    site_builtin_library: file
    site_maintenance_catalog: file
    site_non_boot_drivers_catalog: file

    system_level: name
    text: string
  VAREND
  "$FORMAT=ON"



main_block: ..
  BLOCK



    nosve_maintenance_catalog = qcv$system//name_nosve_maintenance_catalog
    nosve_deadstart_catalog = nosve_maintenance_catalog//name_deadstart_catalog
    nosve_non_boot_drivers_file = nosve_deadstart_catalog//name_non_boot_drivers_file
    nosve_builtin_library = nosve_deadstart_catalog//name_product_files_catalog//name_builtin_library
    nosve_sou_library = nosve_deadstart_catalog//name_product_files_catalog//name_sou_library
    nosve_link_input_catalog = nosve_maintenance_catalog//name_link_input_catalog

    qcu_field_maintenance_catalog = qcv$system//name_qcu_field_maintenance
    qcu_log_file = qcu_field_maintenance_catalog//name_qcu_log_file
    qcu_state_file = qcu_field_maintenance_catalog//name_qcu_state
    qcu_maintenance_catalog = qcv$system//name_qcu_maintenance_catalog
    qcu_link_input_catalog = qcu_maintenance_catalog//name_link_input_catalog
    qcu_version_file = qcu_link_input_catalog//name_os_version

     IF NOT $file(qcu_maintenance_catalog,catalog) THEN
       $system.put_line ' ' o=$fname(ofile//'.$eoi')
       $system.put_line '                        STOP' o=$fname(ofile//'.$eoi')
       $system.put_line '          Material necessary for the generation of ' o=$fname(ofile//'.$eoi')
       $system.put_line '          a new correction system is not available.'   o=$fname(ofile//'.$eoi')
       $system.put_line '          You must issue a INSTALL_FIELD_CORRECTION'     o=$fname(ofile//'.$eoi')
       $system.put_line '          request before attempting to generate a'  o=$fname(ofile//'.$eoi')
       $system.put_line '          new correction system.'       o=$fname(ofile//'.$eoi')
       $system.put_line ' ' o=$fname(ofile//'.$eoi')
       delete_catalog qcu_field_maintenance_catalog cac status=ignore_status
       EXIT_PROC
     IFEND
     IF NOT $file(qcu_field_maintenance_catalog,catalog) THEN
       $system.put_line ' ' o=$fname(ofile//'.$eoi')
       $system.put_line '                        STOP' o=$fname(ofile//'.$eoi')
       $system.put_line '          Material necessary for the generation of ' o=$fname(ofile//'.$eoi')
       $system.put_line '          a new correction system is not available.'   o=$fname(ofile//'.$eoi')
       $system.put_line '          You must issue a INSTALL_FIELD_CORRECTION'     o=$fname(ofile//'.$eoi')
       $system.put_line '          request before attempting to generate a'  o=$fname(ofile//'.$eoi')
       $system.put_line '          new correction system.'       o=$fname(ofile//'.$eoi')
       $system.put_line ' ' o=$fname(ofile//'.$eoi')
       EXIT_PROC
     IFEND

    $system.delete_file f=qcu_state_file status=ignore_status
    get_correction_level ovf=qcu_version_file sl=system_level status=local_status
    EXIT main_block WHEN NOT local_status.normal

    site_maintenance_catalog = qcv$system//name_site_maintenance_catalog
    site_non_boot_drivers_catalog = site_maintenance_catalog//name_non_boot_drivers_catalog
    site_builtin_library = site_maintenance_catalog//name_osf$builtin_library
    site_sou_library = site_maintenance_catalog//name_osf$sou_library

    configuration_files_catalog = site_maintenance_catalog//name_deadstart_commands
    new_version_catalog = qcu_maintenance_catalog//system_level
    new_deadstart_catalog = new_version_catalog//name_deadstart_catalog
    new_link_output_catalog = new_version_catalog//name_link_output_catalog
    new_non_boot_drivers_file = new_deadstart_catalog//name_non_boot_drivers_file
    new_builtin_library = new_deadstart_catalog//name_product_files_catalog//name_builtin_library
    new_sou_library = new_deadstart_catalog//name_product_files_catalog//name_sou_library



  build_dc_block: ..
    BLOCK

      $system.delete_file qcu_log_file status=ignore_status

" initialize the new deadstart catalog - delete the old, create the new.

      $system.delete_catalog c=new_version_catalog do=catalog_and_contents status=ignore_status
COLLECT_TEXT o=command_file until='**' sm='?'
      $system.create_catalog c=new_version_catalog
      $system.create_catalog c=new_deadstart_catalog
      $system.create_catalog c=new_link_output_catalog
**
      $system.include_file f=command_file status=local_status
      $system.delete_file f=command_file status=ignore_status
      EXIT build_dc_block WHEN NOT local_status.normal

      $system.put_line ' ' o=$fname(ofile//'.$eoi')
      $system.put_line '     Begin Generation of the Corrected System' o=$fname(ofile//'.$eoi')
      $system.put_line '              Deadstart Catalog Path is ...' o=qcu_log_file.$EOI
      $system.put_line '      '//$string(new_deadstart_catalog) o=qcu_log_file.$EOI
      $system.put_line ' ' o=qcu_log_file.$EOI


" Move the deadstart catalog from nosve_maintenance to
" qcu_maintenance to use as a base for the new system.

COLLECT_TEXT o=command_file until='**'
  $system.BACKUP_PERMANENT_FILE bf=bacpf_file
    backup_catalog c=nosve_deadstart_catalog
    quit
  $system.RESTORE_PERMANENT_FILE l=$null
    restore_existing_catalog c=nosve_deadstart_catalog ..
                             ncn=new_deadstart_catalog ..
                             bf=bacpf_file
    quit
  $system.BACKUP_PERMANENT_FILE bf=$null
    exclude_highest_cycle number_of_cycles=1
    delete_catalog_content c=new_deadstart_catalog
    quit

**
      $system.include_file f=command_file status=local_status
      $system.delete_file f=command_file status=ignore_status
      $system.delete_file f=bacpf_file status=ignore_status
      EXIT build_dc_block WHEN NOT local_status.normal




"   If there are local changes to the sites builtin_library then
"   combine the site-specified version of the file with the
"   system released version of the file and put the result in
"   the file new_builtin_library.


  IF $file(site_builtin_library permanent) THEN
    $system.put_line ' '
    $system.put_line '      Combining the sites BUILTIN_LIBRARY' o=$fname(ofile//'.$eoi')
    $system.put_line '                               with' o=$fname(ofile//'.$eoi')
    $system.put_line '              the systems BUILTIN_LIBRARY' o=$fname(ofile//'.$eoi')

    $system.put_line 'BUILTIN_LIBRARY'   o=qcu_state_file.$eoi  status=ignore_status

COLLECT_TEXT o=command_file until='**'
  $system.CREATE_OBJECT_LIBRARY
    add_modules l=nosve_builtin_library
    combine_modules l=site_builtin_library
    generate_library l=new_builtin_library
  QUIT
**
    $system.include_file command_file status=local_status
    $system.delete_file command_file status=ignore_status

  IFEND

"   If there are local changes to the sites sou_library then
"   combine the site-specified version of the file with the
"   system released version of the file and put the result in
"   the file new_sou_library.


  IF $file(site_sou_library permanent) THEN
    $system.put_line ' '
    $system.put_line '      Combining the sites SOU_LIBRARY' o=$fname(ofile//'.$eoi')
    $system.put_line '                               with' o=$fname(ofile//'.$eoi')
    $system.put_line '              the systems SOU_LIBRARY' o=$fname(ofile//'.$eoi')

    $system.put_line 'SOU_LIBRARY'   o=qcu_state_file.$eoi  status=ignore_status

COLLECT_TEXT o=command_file until='**'
  $system.CREATE_OBJECT_LIBRARY
    add_modules l=nosve_sou_library
    combine_modules l=site_sou_library
    generate_library l=new_sou_library
  QUIT
**
    $system.include_file command_file status=local_status
    $system.delete_file command_file status=ignore_status

  IFEND


      copy_configuration configuration_files_catalog=configuration_files_catalog ..
            deadstart_catalog=new_deadstart_catalog status=local_status
      EXIT build_dc_block WHEN NOT local_status.normal




      $system.put_line '    Begin link of OS files    ' o=qcu_log_file.$EOI

      link_generated_qcu ..
            nlic=qcu_link_input_catalog slic=site_maintenance_catalog ..
            dc=new_deadstart_catalog loc=new_link_output_catalog ..
            output=$value(output) status=local_status
      EXIT build_dc_block WHEN NOT local_status.normal

      $system.put_line ' Completed link of OS files ' o=qcu_log_file.$eoi



      combine_drivers nnbdf=nosve_non_boot_drivers_file ..
            snbdc=site_non_boot_drivers_catalog ..
            nbdf=new_non_boot_drivers_file status=local_status
      EXIT build_dc_block WHEN NOT local_status.normal
      $system.put_line ' Completed driver combine' o=qcu_log_file.$eoi

      $system.put_line '     End Generation of the Corrected System' o=output
      $system.put_line '                  the ' o=output
      $system.put_line '     New deadstart catalog path is ..' o=output
      $system.put_line '        '//$string(new_deadstart_catalog)  o=output
      $system.put_line ' ' o=output
    BLOCKEND build_dc_block

  BLOCKEND main_block

  EXIT procedure WITH local_status WHEN NOT local_status.normal
  $system.put_line 'Normal completion from gencs' o=qcu_log_file.$eoi

PROCEND qcp$generate_qcu_deadstart_cat
