Esempio n. 1
0
 private static function core_storage_init_process()
 {
     $pso = pts_storage_object::recover_from_file(PTS_CORE_STORAGE);
     if ($pso == false) {
         $pso = new pts_storage_object(true, true);
     }
     // OpenBenchmarking.org - GSID
     $global_gsid = $pso->read_object('global_system_id');
     $global_gsid_e = $pso->read_object('global_system_id_e');
     $global_gsid_p = $pso->read_object('global_system_id_p');
     if (empty($global_gsid) || pts_openbenchmarking::is_valid_gsid_format($global_gsid) == false) {
         // Global System ID for anonymous uploads, etc
         $requested_gsid = true;
         $global_gsid = pts_openbenchmarking_client::request_gsid();
         if (is_array($global_gsid)) {
             $pso->add_object('global_system_id', $global_gsid['gsid']);
             // GSID
             $pso->add_object('global_system_id_p', $global_gsid['gsid_p']);
             // GSID_P
             $pso->add_object('global_system_id_e', $global_gsid['gsid_e']);
             // GSID_E
             pts_define('PTS_GSID', $global_gsid['gsid']);
             pts_define('PTS_GSID_E', $global_gsid['gsid_e']);
         }
     } else {
         if (pts_openbenchmarking::is_valid_gsid_e_format($global_gsid_e) == false || pts_openbenchmarking::is_valid_gsid_p_format($global_gsid_p) == false) {
             pts_define('PTS_GSID', $global_gsid);
             $requested_gsid = false;
             $global_gsid = pts_openbenchmarking_client::retrieve_gsid();
             if (is_array($global_gsid)) {
                 $pso->add_object('global_system_id_p', $global_gsid['gsid_p']);
                 // GSID_P
                 $pso->add_object('global_system_id_e', $global_gsid['gsid_e']);
                 // GSID_E
                 pts_define('PTS_GSID_E', $global_gsid['gsid_e']);
             }
         } else {
             pts_define('PTS_GSID', $global_gsid);
             pts_define('PTS_GSID_E', $global_gsid_e);
             $requested_gsid = false;
         }
     }
     $machine_self_id = $pso->read_object('machine_self_id');
     if (empty($machine_self_id)) {
         $ns = md5('phoronix-test-suite');
         $binary_ns = null;
         for ($i = 0; $i < strlen($ns); $i += 2) {
             $binary_ns .= chr(hexdec($ns[$i] . $ns[$i + 1]));
         }
         $msi_hash = sha1($binary_ns . uniqid(PTS_CORE_VERSION, true) . getenv('USERNAME') . getenv('USER') . getenv('HOSTNAME') . pts_network::get_local_ip());
         $machine_self_id = sprintf('%08s-%04s-%04x-%04x-%12s', substr($msi_hash, 0, 8), substr($msi_hash, 8, 4), hexdec(substr($msi_hash, 12, 4)) & 0xfff | 0x5000, hexdec(substr($msi_hash, 16, 4)) & 0x3fff | 0x8000, substr($msi_hash, 20, 12));
         // machine_self_id is self-generated unique name for Phoromatic/OB purposes in UUIDv5 format
         $pso->add_object('machine_self_id', $machine_self_id);
     }
     pts_define('PTS_MACHINE_SELF_ID', $machine_self_id);
     // Last Run Processing
     $last_core_version = $pso->read_object('last_core_version');
     pts_define('FIRST_RUN_ON_PTS_UPGRADE', $last_core_version != PTS_CORE_VERSION);
     if (FIRST_RUN_ON_PTS_UPGRADE || $pso->read_object('last_php_version') != PTS_PHP_VERSION) {
         // Report any missing/recommended extensions
         self::program_requirement_checks();
     }
     if (FIRST_RUN_ON_PTS_UPGRADE) {
         if ($requested_gsid == false) {
             pts_openbenchmarking_client::update_gsid();
         }
         pts_client::build_temp_cache();
     }
     $pso->add_object('last_core_version', PTS_CORE_VERSION);
     // PTS version last run
     $pso->add_object('last_php_version', PTS_PHP_VERSION);
     // PHP version last run
     //$last_pts_version = $pso->read_object('last_pts_version');
     // do something here with $last_pts_version if you want that information
     $pso->add_object('last_pts_version', PTS_VERSION);
     // PTS version last run
     // Last Run Processing
     $last_run = $pso->read_object('last_run_time');
     pts_define('IS_FIRST_RUN_TODAY', substr($last_run, 0, 10) != date('Y-m-d'));
     $pso->add_object('last_run_time', date('Y-m-d H:i:s'));
     // Time PTS was last run
     pts_define('TIME_SINCE_LAST_RUN', ceil((time() - strtotime($last_run)) / 60));
     // TIME_SINCE_LAST_RUN is in minutes
     // User Agreement Checking
     $agreement_cs = $pso->read_object('user_agreement_cs');
     $pso->add_object('user_agreement_cs', $agreement_cs);
     // User agreement check-sum
     // Phodevi Cache Handling
     $phodevi_cache = $pso->read_object('phodevi_smart_cache');
     if ($phodevi_cache instanceof phodevi_cache && pts_client::read_env('NO_PHODEVI_CACHE') == false) {
         $phodevi_cache = $phodevi_cache->restore_cache(PTS_USER_PATH, PTS_CORE_VERSION);
         phodevi::set_device_cache($phodevi_cache);
         if ($external_phodevi_cache = pts_client::read_env('EXTERNAL_PHODEVI_CACHE')) {
             if (is_dir($external_phodevi_cache) && is_file($external_phodevi_cache . '/core.pt2so')) {
                 $external_phodevi_cache .= '/core.pt2so';
             }
             if (is_file($external_phodevi_cache)) {
                 $external_phodevi_cache = pts_storage_object::force_recover_from_file($external_phodevi_cache);
                 if ($external_phodevi_cache != false) {
                     $external_phodevi_cache = $external_phodevi_cache->read_object('phodevi_smart_cache');
                     $external_phodevi_cache = $external_phodevi_cache->restore_cache(null, PTS_CORE_VERSION);
                     if ($external_phodevi_cache != false) {
                         //unset($external_phodevi_cache['system']['operating-system']);
                         //unset($external_phodevi_cache['system']['vendor-identifier']);
                         phodevi::set_device_cache($external_phodevi_cache);
                     }
                 }
             }
         }
     }
     // Archive to disk
     $pso->save_to_file(PTS_CORE_STORAGE);
 }