PROCEDURE rap$create_profile_for_upgrade, crepfu (
  enable_site_classes, esc: list of record
      class_name: name
      job_count: integer
    recend = $optional
  saved_profile, sp: file = $system.scheduling_profile
  status)

" This procedure modifies the active profile to create the proper environment
" for the upgrade.  The active profile is saved on the base profile so the
" site environment prior to the upgrade can be restored after the upgrade is
" complete.

  "$FORMAT=OFF"
  VAR
    local_status    : status
    error_flag      : boolean = false
  VAREND
  "$FORMAT=ON"

  MANAGE_ACTIVE_SCHEDULING

    write_profile r=saved_profile

    change_job_class cn=all eci=false
    change_job_class cn=system il=10 eci=true
    change_job_class cn=maintenance il=10 eci=true
    change_job_class cn=interactive il=1
    IF $specified(enable_site_classes) THEN
      FOR EACH site_class IN enable_site_classes DO
        change_job_class cn=site_class.class_name eci=true ..
              il=site_class.job_count status=local_status
        IF NOT local_status.normal THEN
          IF local_status.condition = jme$object_not_known THEN
            put_line l=' '//..
$status(false, 'ra', rae$invalid_site_class, site_class.class_name)
          ELSE
            EXIT procedure WITH local_status
          IFEND
        IFEND
      FOREND
    IFEND

  QUIT sc=TRUE

PROCEND rap$create_profile_for_upgrade

