public static function init()
 {
     self::$flags = 0;
     self::$os_identifier_sha1 = sha1(phodevi::read_property('system', 'vendor-identifier'));
     self::$is_live_cd = 1 << 1;
     self::$no_network_communication = 1 << 2;
     self::$no_openbenchmarking_reporting = 1 << 3;
     self::$user_agreement_skip = 1 << 4;
     self::$skip_md5_checks = 1 << 5;
     self::$remove_test_on_completion = 1 << 6;
     self::$no_phodevi_cache = 1 << 7;
     self::$no_external_dependencies = 1 << 8;
     self::$upload_to_openbenchmarking = 1 << 9;
     switch (self::$os_identifier_sha1) {
         case 'b28d6a7148b34595c5b397dfcf5b12ac7932b3dc':
             // Moscow 2011-04 client
             self::$flags = self::$is_live_cd | self::$no_network_communication | self::$no_openbenchmarking_reporting | self::$user_agreement_skip | self::$skip_md5_checks | self::$remove_test_on_completion;
             break;
     }
     if (pts_client::read_env('NO_FILE_HASH_CHECKS') != false || pts_client::read_env('NO_MD5_CHECKS') != false) {
         self::$flags |= self::$skip_md5_checks;
     }
     if (pts_config::read_bool_config('PhoronixTestSuite/Options/Testing/RemoveTestInstallOnCompletion', 'FALSE')) {
         self::$flags |= self::$remove_test_on_completion;
     }
     if (pts_config::read_bool_config('PhoronixTestSuite/Options/Testing/AlwaysUploadResultsToOpenBenchmarking', 'FALSE')) {
         self::$flags |= self::$upload_to_openbenchmarking;
     }
     if (pts_client::read_env('NO_PHODEVI_CACHE') != false) {
         self::$flags |= self::$no_phodevi_cache;
     }
     if (pts_client::read_env('NO_EXTERNAL_DEPENDENCIES') != false || pts_client::read_env('SKIP_EXTERNAL_DEPENDENCIES') == 1) {
         // NO_EXTERNAL_DEPENDENCIES was deprecated in PTS 3.6 and replaced by more versatile SKIP_EXTERNAL_DEPENDENCIES
         self::$flags |= self::$no_external_dependencies;
     }
 }
 public static function install_dependencies(&$test_profiles)
 {
     // PTS External Dependencies install on distribution
     if (phodevi::is_windows() || phodevi::is_macosx() || pts_flags::no_external_dependencies()) {
         // Windows doesn't use any external dependencies
         return true;
     }
     // Find all the tests that need to be checked
     $tests_to_check = array();
     foreach ($test_profiles as $test_profile) {
         if (!in_array($test_profile, $tests_to_check) && $test_profile->is_supported()) {
             array_push($tests_to_check, $test_profile);
         }
     }
     // Find all of the POSSIBLE test dependencies
     $required_test_dependencies = array();
     foreach ($tests_to_check as &$test_profile) {
         foreach ($test_profile->get_dependencies() as $test_dependency) {
             if (empty($test_dependency)) {
                 continue;
             }
             if (isset($required_test_dependencies[$test_dependency]) == false) {
                 $required_test_dependencies[$test_dependency] = array();
             }
             array_push($required_test_dependencies[$test_dependency], $test_profile);
         }
     }
     if (pts_c::$test_flags & pts_c::skip_tests_with_missing_dependencies) {
         // Remove tests that have external dependencies that aren't satisfied and then return
         $generic_packages_needed = array();
         $required_test_dependencies_copy = $required_test_dependencies;
         $dependencies_to_install = self::check_dependencies_missing_from_system($required_test_dependencies_copy, $generic_packages_needed);
         self::remove_tests_with_missing_dependencies($test_profiles, $generic_packages_needed, $required_test_dependencies);
         return true;
     }
     if (!empty($required_test_dependencies)) {
         // The 'common-dependencies' package is any general non-explicitly-required but nice-to-have packages like mesa-utils for providing glxinfo about the system
         // So if we're going to be installing external dependencies anyways, might as well try to see the common-dependencies are satisfied
         $required_test_dependencies['common-dependencies'] = array();
     }
     // Does the user wish to skip any particular dependencies?
     if (pts_client::read_env('SKIP_EXTERNAL_DEPENDENCIES')) {
         $dependencies_to_skip = explode(',', pts_client::read_env('SKIP_EXTERNAL_DEPENDENCIES'));
         foreach ($dependencies_to_skip as $dependency_name) {
             if (isset($required_test_dependencies[$dependency_name])) {
                 unset($required_test_dependencies[$dependency_name]);
             }
         }
     }
     // Make a copy for use to check at end of process to see if all dependencies were actually found
     $required_test_dependencies_copy = $required_test_dependencies;
     // Find the dependencies that are actually missing from the system
     $dependencies_to_install = self::check_dependencies_missing_from_system($required_test_dependencies);
     // If it's automated and can't install without root, return true if there are no dependencies to do otherwise false
     if (pts_c::$test_flags & pts_c::auto_mode && phodevi::is_root() == false) {
         return count($dependencies_to_install) == 0;
     }
     // Do the actual dependency install process
     if (count($dependencies_to_install) > 0) {
         self::install_packages_on_system($dependencies_to_install);
     }
     // There were some dependencies not supported on this OS or are missing from the distro's XML file
     if (count($required_test_dependencies) > 0 && count($dependencies_to_install) == 0) {
         $exdep_generic_parser = new pts_exdep_generic_parser();
         $to_report = array();
         foreach (array_keys($required_test_dependencies) as $dependency) {
             $dependency_data = $exdep_generic_parser->get_package_data($dependency);
             if ($dependency_data['possible_packages'] != null) {
                 array_push($to_report, $dependency_data['title'] . PHP_EOL . 'Possible Package Names: ' . $dependency_data['possible_packages']);
             }
         }
         if (count($to_report) > 0) {
             echo PHP_EOL . 'Some additional dependencies are required, but they could not be installed automatically for your operating system.' . PHP_EOL . 'Below are the software packages that must be installed.' . PHP_EOL . PHP_EOL;
             foreach ($to_report as $report) {
                 pts_client::$display->generic_heading($report);
             }
             if (pts_c::$test_flags ^ pts_c::batch_mode && pts_c::$test_flags ^ pts_c::auto_mode) {
                 echo 'The above dependencies should be installed before proceeding. Press any key when you\'re ready to continue.';
                 pts_user_io::read_user_input();
                 echo PHP_EOL;
             }
         }
     }
     // Find the dependencies that are still missing from the system
     if (pts_c::$test_flags ^ pts_c::batch_mode && pts_c::$test_flags ^ pts_c::auto_mode && !defined('PHOROMATIC_PROCESS')) {
         $generic_packages_needed = array();
         $required_test_dependencies = $required_test_dependencies_copy;
         $dependencies_to_install = self::check_dependencies_missing_from_system($required_test_dependencies_copy, $generic_packages_needed);
         if (count($generic_packages_needed) > 0) {
             echo PHP_EOL . 'There are dependencies still missing from the system:' . PHP_EOL;
             echo pts_user_io::display_text_list(self::generic_names_to_titles($generic_packages_needed));
             $actions = array('IGNORE' => 'Ignore missing dependencies and proceed with installation.', 'SKIP_TESTS_WITH_MISSING_DEPS' => 'Skip installing the tests with missing dependencies.', 'REATTEMPT_DEP_INSTALL' => 'Re-attempt to install the missing dependencies.', 'QUIT' => 'Quit the current Phoronix Test Suite process.');
             $selected_action = pts_user_io::prompt_text_menu('Missing dependencies action', $actions, false, true);
             switch ($selected_action) {
                 case 'IGNORE':
                     break;
                 case 'SKIP_TESTS_WITH_MISSING_DEPS':
                     // Unset the tests that have dependencies still missing
                     self::remove_tests_with_missing_dependencies($test_profiles, $generic_packages_needed, $required_test_dependencies);
                     break;
                 case 'REATTEMPT_DEP_INSTALL':
                     self::install_packages_on_system($dependencies_to_install);
                     break;
                 case 'QUIT':
                     exit(0);
             }
         }
     }
     return true;
 }