How to use install_packages_on_system method of pts_external_dependencies class

Best Phoronix-test-suite code snippet using pts_external_dependencies.install_packages_on_system

pts_external_dependencies.php

Source:pts_external_dependencies.php Github

copy

Full Screen

...127 }128 // Do the actual dependency install process129 if(count($dependencies_to_install) > 0)130 {131 self::install_packages_on_system($dependencies_to_install);132 }133 // There were some dependencies not supported on this OS or are missing from the distro's XML file134 if(count($required_external_dependencies) > 0 && count($dependencies_to_install) == 0)135 {136 $exdep_generic_parser = new pts_exdep_generic_parser();137 $to_report = array();138 foreach(array_keys($required_external_dependencies) as $dependency)139 {140 $dependency_data = $exdep_generic_parser->get_package_data($dependency);141 if($dependency_data['possible_packages'] != null)142 {143 $to_report[] = $dependency_data['title'] . PHP_EOL . 'Possible Package Names: ' . $dependency_data['possible_packages'];144 }145 }146 if(count($to_report) > 0)147 {148 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;149 foreach($to_report as $report)150 {151 pts_client::$display->generic_heading($report);152 }153 if(!$no_prompts)154 {155 echo 'The above dependencies should be installed before proceeding. Press any key when you\'re ready to continue.';156 pts_user_io::read_user_input();157 echo PHP_EOL;158 }159 }160 }161 // Find the dependencies that are still missing from the system162 if(!$no_prompts && !defined('PHOROMATIC_PROCESS'))163 {164 $generic_packages_needed = array();165 $required_external_dependencies = $required_external_dependencies_copy;166 $dependencies_to_install = self::check_dependencies_missing_from_system($required_external_dependencies_copy, $generic_packages_needed);167 if(count($generic_packages_needed) > 0)168 {169 echo PHP_EOL . 'There are dependencies still missing from the system:' . PHP_EOL;170 echo pts_user_io::display_text_list(self::generic_names_to_titles($generic_packages_needed));171 $actions = array(172 'IGNORE' => 'Ignore missing dependencies and proceed with installation.',173 'SKIP_TESTS_WITH_MISSING_DEPS' => 'Skip installing the tests with missing dependencies.',174 'REATTEMPT_DEP_INSTALL' => 'Re-attempt to install the missing dependencies.',175 'QUIT' => 'Quit the current Phoronix Test Suite process.'176 );177 $selected_action = pts_user_io::prompt_text_menu('Missing dependencies action', $actions, false, true);178 switch($selected_action)179 {180 case 'IGNORE':181 break;182 case 'SKIP_TESTS_WITH_MISSING_DEPS':183 // Unset the tests that have dependencies still missing184 self::remove_tests_with_missing_dependencies($test_profiles, $generic_packages_needed, $required_external_dependencies);185 break;186 case 'REATTEMPT_DEP_INSTALL':187 self::install_packages_on_system($dependencies_to_install);188 break;189 case 'QUIT':190 exit(0);191 }192 }193 }194 return true;195 }196 protected static function remove_tests_with_missing_dependencies(&$test_profiles, $generic_packages_needed, $required_test_dependencies)197 {198 foreach($generic_packages_needed as $pkg)199 {200 if(isset($required_test_dependencies[$pkg]))201 {202 foreach($required_test_dependencies[$pkg] as $test_with_this_dependency)203 {204 if(($index = array_search($test_with_this_dependency, $test_profiles)) !== false)205 {206 unset($test_profiles[$index]);207 }208 }209 }210 }211 }212 public static function all_dependency_names()213 {214 $exdep_generic_parser = new pts_exdep_generic_parser();215 return $exdep_generic_parser->get_available_packages();216 }217 public static function all_dependency_titles()218 {219 $dependency_names = self::all_dependency_names();220 return self::generic_names_to_titles($dependency_names);221 }222 public static function missing_dependency_names()223 {224 $all_test_dependencies = array();225 $all_missing_dependencies = array();226 foreach(self::all_dependency_names() as $name)227 {228 $all_test_dependencies[$name] = array();229 }230 self::check_dependencies_missing_from_system($all_test_dependencies, $all_missing_dependencies);231 sort($all_missing_dependencies);232 return $all_missing_dependencies;233 }234 public static function missing_dependency_titles()235 {236 $dependency_names = self::missing_dependency_names();237 return self::generic_names_to_titles($dependency_names);238 }239 public static function installed_dependency_names()240 {241 $installed_test_dependencies = array_diff(self::all_dependency_names(), self::missing_dependency_names());242 sort($installed_test_dependencies);243 return $installed_test_dependencies;244 }245 public static function installed_dependency_titles()246 {247 $dependency_names = self::installed_dependency_names();248 return self::generic_names_to_titles($dependency_names);249 }250 private static function check_dependencies_missing_from_system(&$required_test_dependencies, &$generic_names_of_packages_needed = false)251 {252 $generic_dependencies_parser = new pts_exdep_generic_parser();253 $vendor_dependencies_parser = new pts_exdep_platform_parser(self::vendor_identifier('package-list'));254 $kernel_architecture = phodevi::read_property('system', 'kernel-architecture');255 $needed_os_packages = array();256 foreach($required_test_dependencies as $package => $dependents)257 {258 if($vendor_dependencies_parser->is_package($package))259 {260 $package_data = $vendor_dependencies_parser->get_package_data($package);261 $arch_compliant = empty($package_data['arch_specific']) || in_array($kernel_architecture, $package_data['arch_specific']);262 if(!empty($package_data['file_check']))263 {264 $add_dependency = self::file_missing_check($package_data['file_check']);265 }266 else if($generic_dependencies_parser->is_package($package))267 {268 // If the OS/platform-specific package didn't supply a file check list, obtain it from the generic listing269 $generic_package_data = $generic_dependencies_parser->get_package_data($package);270 $add_dependency = empty($generic_package_data['file_check']) || self::file_missing_check($generic_package_data['file_check']);271 }272 if($add_dependency && $arch_compliant && $package_data['os_package'] != null)273 {274 if(!in_array($package_data['os_package'], $needed_os_packages))275 {276 $needed_os_packages[] = $package_data['os_package'];277 }278 if($generic_names_of_packages_needed !== false && !in_array($package, $generic_names_of_packages_needed))279 {280 $generic_names_of_packages_needed[] = $package;281 }282 }283 else284 {285 unset($required_test_dependencies[$package]);286 }287 }288 }289 if(count($required_test_dependencies) > 0)290 {291 foreach($required_test_dependencies as $i => $dependency)292 {293 $package_data = $generic_dependencies_parser->get_package_data($i);294 $file_present = !empty($package_data['file_check']) && !self::file_missing_check($package_data['file_check']);295 if($file_present)296 {297 unset($required_test_dependencies[$i]);298 }299 }300 }301 return $needed_os_packages;302 }303 private static function check_for_missing_system_files(&$required_system_files)304 {305 $kernel_architecture = phodevi::read_property('system', 'kernel-architecture');306 $needed_os_packages = array();307 foreach(array_keys($required_system_files) as $file)308 {309 $present = false;310 if(is_file($file))311 {312 $present = true;313 }314 if(strpos($file, '.h') !== false && is_file('/usr/includes/' . $file))315 {316 $present = true;317 }318 else if(strpos($file, '.so') !== false && is_file('/usr/lib/' . $file))319 {320 $present = true;321 }322 else323 {324 foreach(array('/usr/bin/', '/bin/', '/usr/sbin') as $possible_path)325 {326 if(is_file($possible_path . $file))327 {328 $present = true;329 break;330 }331 }332 }333 if(!$present)334 {335 $processed_pkgs = self::packages_that_provide($file);336 if(!empty($processed_pkgs))337 {338 foreach($processed_pkgs as $pkg)339 {340 $needed_os_packages[] = $pkg;341 }342 }343 }344 }345 return $needed_os_packages;346 }347 private static function file_missing_check($file_arr)348 {349 // Checks if file is missing350 $file_missing = false;351 if(!is_array($file_arr))352 {353 $file_arr = pts_strings::comma_explode($file_arr);354 }355 foreach($file_arr as $file)356 {357 $file_is_there = false;358 $file = explode('OR', $file);359 for($i = 0; $i < count($file) && $file_is_there == false; $i++)360 {361 $file[$i] = trim($file[$i]);362 if(is_file($file[$i]) || is_dir($file[$i]) || is_link($file[$i]))363 {364 $file_is_there = true;365 }366 else if(isset($file[$i][1]) && $file[$i][0] != '/')367 {368 // See if it's some relative command/path369 if(substr($file[$i], -2) == '.h' || substr($file[$i], -4) == '.hpp')370 {371 // May just be a relative header file to look for...372 $possible_paths = array('/usr/local/include/', '/usr/target/include/', '/usr/include/', '/usr/include/x86_64-linux-gnu/');373 foreach($possible_paths as $path)374 {375 if(is_file($path . $file[$i]) || is_link($path . $file[$i]))376 {377 $file_is_there = true;378 }379 }380 }381 else if(strpos($file[$i], '.so') !== false || substr($file[$i], -2) == '.a')382 {383 // May just be a relative shared library to look for...384 $possible_paths = array('/usr/local/lib/', '/usr/lib/', '/usr/lib64/', '/usr/lib/x86_64-linux-gnu/', '/usr/lib/i386-linux-gnu/', '/usr/lib/arm-linux-gnueabihf/');385 if(getenv('LD_LIBRARY_PATH'))386 {387 foreach(explode(':', getenv('LD_LIBRARY_PATH')) as $path)388 {389 $possible_paths[] = $path . '/';390 }391 }392 foreach($possible_paths as $path)393 {394 if(is_file($path . $file[$i]) || is_link($path . $file[$i]))395 {396 $file_is_there = true;397 }398 }399 }400 else if(strpos($file[$i], '/') === false)401 {402 // May just be a command to look for...403 $possible_paths = array('/usr/local/bin/', '/usr/bin/');404 if(getenv('PATH'))405 {406 foreach(explode(':', getenv('PATH')) as $path)407 {408 $possible_paths[] = $path . '/';409 }410 }411 foreach($possible_paths as $path)412 {413 if(is_file($path . $file[$i]) || is_link($path . $file[$i]))414 {415 $file_is_there = true;416 }417 }418 }419 }420 }421 $file_missing = $file_missing || !$file_is_there;422 }423 return $file_missing;424 }425 private static function install_packages_on_system($os_packages_to_install)426 {427 // Do the actual installing process of packages using the distribution's package management system428 $vendor_install_file = PTS_EXDEP_PATH . 'scripts/install-' . self::vendor_identifier('installer') . '-packages.sh';429 // Rebuild the array index since some OS package XML tags provide multiple package names in a single string430 $os_packages_to_install = explode(' ', implode(' ', $os_packages_to_install));431 if(is_file($vendor_install_file))432 {433 // hook into pts_client::$display here if it's desired434 echo PHP_EOL . 'The following dependencies are needed and will be installed: ' . PHP_EOL . PHP_EOL;435 echo pts_user_io::display_text_list($os_packages_to_install);436 echo PHP_EOL . 'This process may take several minutes.' . PHP_EOL;437 echo shell_exec('sh ' . $vendor_install_file . ' ' . implode(' ', $os_packages_to_install));438 }439 else...

Full Screen

Full Screen

install_packages_on_system

Using AI Code Generation

copy

Full Screen

1$packages = array('foo', 'bar');2$install = pts_external_dependencies::install_packages_on_system($packages);3if($install)4{5 echo 'Packages installed';6}7{8 echo 'Packages not installed';9}10$packages = array('foo', 'bar');11$install = pts_external_dependencies::install_packages_on_system($packages);12if($install)13{14 echo 'Packages installed';15}16{17 echo 'Packages not installed';18}19$packages = array('foo', 'bar');20$install = pts_external_dependencies::install_packages_on_system($packages);21if($install)22{23 echo 'Packages installed';24}25{26 echo 'Packages not installed';27}28$packages = array('foo', 'bar');29$install = pts_external_dependencies::install_packages_on_system($packages);30if($install)31{32 echo 'Packages installed';33}34{35 echo 'Packages not installed';36}37$packages = array('foo', 'bar');38$install = pts_external_dependencies::install_packages_on_system($packages);39if($install)40{41 echo 'Packages installed';42}43{44 echo 'Packages not installed';45}46$packages = array('foo', 'bar');47$install = pts_external_dependencies::install_packages_on_system($packages);48if($install)49{50 echo 'Packages installed';51}52{53 echo 'Packages not installed';54}55$packages = array('foo', 'bar');56$install = pts_external_dependencies::install_packages_on_system($packages);57if($install)58{59 echo 'Packages installed';60}61{

Full Screen

Full Screen

install_packages_on_system

Using AI Code Generation

copy

Full Screen

1require_once('pts-external-dependencies.php');2$install_packages_on_system = new pts_external_dependencies();3$install_packages_on_system->install_packages_on_system(array('php5'));4require_once('pts-external-dependencies.php');5$install_packages_on_system = new pts_external_dependencies();6$install_packages_on_system->install_packages_on_system(array('php5','php5-cli','php5-gd','php5-mysql','php5-curl','php5-mcrypt','php5-imagick','php5-memcache','php5-memcached','php5-xsl','php5-sqlite','php5-ldap','php5-intl','php5-geoip','php5-xmlrpc','php5-xml','php5-json','php5-odbc','php5-pspell','php5-recode','php5-snmp','php5-tidy','php5-xmlrpc','php5-xsl','php5-zip','php5-mhash','php-pear','php-apc','php5-dev','php5-cgi','php5-fpm','php5-common','php5-curl','php5-gd','php5-geoip','php5-imap','php5-intl','php5-json','php5-ldap','php5-mcrypt','php5-memcache','php5-memcached','php5-mhash','php5-mysql','php5-odbc','php5-pspell','php5-readline','php5-recode','php5-snmp','php5-soap','php5-sqlite','php5-tidy','php5-xmlrpc','php5-xsl','php5-zip','php-pear','php-apc','php5-dev','php5-cgi','php5-fpm','php5-common','php5-curl','php5-gd','php5-geoip','php5-imap','php5-intl','php5-json','php5-ldap','php5-mcrypt','php5-memcache','php5-memcached','php5-mhash','php5-mysql','php5-odbc','php5-pspell','php5-readline','php

Full Screen

Full Screen

install_packages_on_system

Using AI Code Generation

copy

Full Screen

1require_once('pts-external-dependencies.php');2$install = pts_external_dependencies::install_packages_on_system('git', 'ubuntu');3$install = pts_external_dependencies::install_packages_on_system('git', 'apt-get');4$install = pts_external_dependencies::install_packages_on_system('git', 'apt');5require_once('pts-external-dependencies.php');6$install = pts_external_dependencies::install_packages_on_system('git', 'fedora');7$install = pts_external_dependencies::install_packages_on_system('git', 'yum');8$install = pts_external_dependencies::install_packages_on_system('git', 'dnf');9require_once('pts-external-dependencies.php');10$install = pts_external_dependencies::install_packages_on_system('git', 'arch');11$install = pts_external_dependencies::install_packages_on_system('git', 'pacman');12require_once('pts-external-dependencies.php');13$install = pts_external_dependencies::install_packages_on_system('git', 'gentoo');14$install = pts_external_dependencies::install_packages_on_system('git', 'emerge');15require_once('pts-external-dependencies.php');16$install = pts_external_dependencies::install_packages_on_system('git', 'slackware');

Full Screen

Full Screen

install_packages_on_system

Using AI Code Generation

copy

Full Screen

1include_once('pts_external_dependencies.php');2include_once('pts_external_dependencies_manager.php');3$pts_external_dependencies_manager_object = new pts_external_dependencies_manager();4$pts_external_dependencies_manager_object->install_packages_on_system(array('php5','php5-cli','php5-curl','php5-json','php5-mysql','php5-mcrypt','php5-gd','php5-ldap','php5-xmlrpc','php5-intl','php5-xsl','php5-memcache','php5-memcached','php5-imagick','php5-gmp','php5-geoip','php5-cgi','php5-dev','php5-common','php5-curl','php5-gd','php5-imagick','php5-intl','php5-json','php5-ldap','php5-mcrypt','php5-memcache','php5-memcached','php5-mysql','php5-pspell','php5-readline','php5-recode','php5-snmp','php5-sqlite','php5-tidy','php5-xmlrpc','php5-xsl','php-pear','php-apc','php5-dev','php5-gd','php5-geoip','php5-imagick','php5-mcrypt','php5-memcache','php5-memcached','php5-mysql','php5-pspell','php5-tidy','php5-xmlrpc','php5-xsl'));5include_once('pts_external_dependencies.php');6include_once('pts_external_dependencies_manager.php');7$pts_external_dependencies_manager_object = new pts_external_dependencies_manager();8$pts_external_dependencies_manager_object->install_packages_on_system(array('php5','php5-cli','php5-c

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Phoronix-test-suite automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger install_packages_on_system code on LambdaTest Cloud Grid

Execute automation tests with install_packages_on_system on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful