PROCEDURE rap$generate_ve_deadstart_cat (
  configuration_files_catalog, cfc: file = $system.site_os_maintenance.deadstart_commands
  deadstart_catalog_path: (VAR HIDDEN) file = $optional
  status)

*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'
"
"    The purpose of this request is to create a deadstart catalog
"suitable for creating a deadstart tape.  It calls several other
"procedures to accomplish this task.
"
*IFEND


*copyc rav$maids_file_catalog_names

  "$FORMAT=OFF
  VAR
    bacpf_file: file = $local//$name($unique)
    command_file: file = $local//$name($unique)

    ignore_status: status
    local_status: status

    new_builtin_library: file
    new_deadstart_catalog: file
    new_link_output_catalog: file
    new_non_boot_drivers_file: file
    new_sou_library: file
    new_version_catalog: 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_sou_library: file
    nosve_version_file: file

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

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


main_block: ..
  BLOCK


*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'
"    Determine the base (defined by RAV$SYSTEM) for all files and catalogs.
"
"    Get the OS release level.
"
"    Compute values for various catalog and file paths.  Most of these
"    paths are replacements for the values as they used to exist in the
"    installation table.
"
*IFEND

*copyc rav$system_root_variable

    nosve_maintenance_catalog = rav$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
    nosve_version_file = nosve_link_input_catalog//name_os_version_file

    rap$get_system_level ovf=nosve_version_file sl=system_level status=local_status
    EXIT main_block WHEN NOT local_status.normal

    site_maintenance_catalog = rav$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

    new_version_catalog = site_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

    IF $specified(deadstart_catalog_path) THEN
      deadstart_catalog_path = new_deadstart_catalog
    IFEND


  build_dc_block: ..
    BLOCK


*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'
"
"    Create a subcatalog in SITE_OS_MAINTENANCE representing the release
"    level for the deadstart tape being created.  The release level is
"    obtained from the procedure RAM$GET_SYSTEM_LEVEL.  The version catalog
"    which will contain the deadstart catalog and link output catalog is deleted
"    if any thing exists prior to initiating this command.
"
*IFEND


      $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



*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'
"
"  Backup and restore the NOSVE_MAINTENACE version of the deadstart catalog
"  into the SITE_OS_MAINTENANCE version of the deadstart catalog.
"  All low cycles are deleted from the SITE_OS_MAINTENANCE version of
"  the deadstart catalog after the restore has occurred.
"
*IFEND


      $system.put_line l=' Creating '//$string(new_deadstart_catalog) o=$response

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 $variable(wev$proc_doc,declared)<>'UNKNOWN'

"Any site modification to the load modules or procedures in SOU_LIBRARY
"or BUILTIN_LIBRARY must first be combined with the released version of the
"libraries found in the NOSVE_MAINTENANCE catalog.  A site modification exists
"when osf$sou_library or osf$builtin_library is found in the SITE_OS_MAINTENANCE
"catalog.
*IFEND


      rap$combine_builtin_library nbl=nosve_builtin_library ..
            sbl=site_builtin_library bl=new_builtin_library status=local_status
      EXIT build_dc_block WHEN NOT local_status.normal

      rap$combine_sou_library nsl=nosve_sou_library ssl=site_sou_library ..
            sl=new_sou_library status=local_status
      EXIT build_dc_block WHEN NOT local_status.normal


*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'
"   Copy the configuration files, if present, from their site-maintained
"locations (CONFIGURATIONS_FILES_CATALOG) to
"their appropriate locations in the deadstart catalog.
*IFEND


      rap$copy_configuration_files configuration_files_catalog=configuration_files_catalog ..
            deadstart_catalog=new_deadstart_catalog status=local_status
      EXIT build_dc_block WHEN NOT local_status.normal



*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'
"
"    Link the operating system files creating the
"MONITOR_IMAGE, SYSTEM_CORE_IMAGE
"and JOB_IMAGE as output.
*IFEND


      $system.put_line ' Begin linking the OS files ...' o=$response
      rap$link_operating_system_ii ..
            nlic=nosve_link_input_catalog slic=site_maintenance_catalog ..
            dc=new_deadstart_catalog loc=new_link_output_catalog status= local_status
      EXIT build_dc_block WHEN NOT local_status.normal



*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'
"    The PP files are taken from the non_boot_drivers catalog.  All files found
"in this catalog are assumed to be pps suppied by the site
"They are formated with MANAGE_DEADSTART_FILES.
"Those pps that fail formating will be skipped and a
"message will be displayed.
*IFEND


      rap$combine_non_boot_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


"  Display the exact deadstart catalog path just created.

      text = ' Deadstart catalog created: ' // $string(new_deadstart_catalog)
      $system.put_line l=text o=output


    BLOCKEND build_dc_block

  BLOCKEND main_block

  EXIT procedure WITH local_status WHEN NOT local_status.normal


PROCEND rap$generate_ve_deadstart_cat






