Skip to content
This repository
Newer
Older
100644 130 lines (117 sloc) 3.341 kb
616b0ed4 » mehlah
2012-02-13 Install php extensions necessary for Travis build
1 #!/usr/bin/env php
2 <?php
d324c630 » davidpersson
2012-04-16 Adding docblock in CI depends script.
3 /**
4 * Lithium: the most rad php framework
5 *
6 * @copyright Copyright 2012, Union of RAD (http://union-of-rad.org)
7 * @license http://opensource.org/licenses/bsd-license.php The BSD License
8 */
616b0ed4 » mehlah
2012-02-13 Install php extensions necessary for Travis build
9
10 if (isset($argv[1]) && 'APC' === strtoupper($argv[1])) {
7c237798 » davidpersson
2012-04-16 Making CI depends script class static.
11 PhpExtensions::install('apc');
616b0ed4 » mehlah
2012-02-13 Install php extensions necessary for Travis build
12 } else {
7c237798 » davidpersson
2012-04-16 Making CI depends script class static.
13 PhpExtensions::install('xcache');
616b0ed4 » mehlah
2012-02-13 Install php extensions necessary for Travis build
14 }
7c237798 » davidpersson
2012-04-16 Making CI depends script class static.
15 PhpExtensions::install('mongo');
616b0ed4 » mehlah
2012-02-13 Install php extensions necessary for Travis build
16
d324c630 » davidpersson
2012-04-16 Adding docblock in CI depends script.
17 /**
18 * Class to install native PHP extensions mainly
19 * for preparing test runs.
20 */
855d8a0b » mehlah
2012-02-13 Remove memcache from needed extensions + minor fixes
21 class PhpExtensions {
77a5b643 » davidpersson
2012-04-16 Adding new line above first inner class dockblock.
22
c210573e » davidpersson
2012-04-16 Restructuring CI depends script, adding docblocks.
23 /**
24 * Holds build, configure and install instructions for PHP extensions.
25 *
1217042a » davidpersson
2012-04-16 Refactoring retrieval of ini path in CI depends script; adding docblock.
26 * @var array Extensions to build keyed by extension name.
c210573e » davidpersson
2012-04-16 Restructuring CI depends script, adding docblocks.
27 */
7c237798 » davidpersson
2012-04-16 Making CI depends script class static.
28 protected static $_extensions = array(
c210573e » davidpersson
2012-04-16 Restructuring CI depends script, adding docblocks.
29 'memcached' => array(
30 'url' => 'http://pecl.php.net/get/memcached-2.0.1.tgz',
31 'require' => array(),
32 'configure' => array(),
33 'ini' => array(
34 'extension=memcached.so'
35 )
36 ),
37 'apc' => array(
38 'url' => 'http://pecl.php.net/get/APC-3.1.10.tgz',
39 'require' => array(),
40 'configure' => array(),
41 'ini' => array(
42 'extension=apc.so',
43 'apc.enabled=1',
44 'apc.enable_cli=1'
45 )
46 ),
47 'xcache' => array(
48 'url' => 'http://xcache.lighttpd.net/pub/Releases/1.3.2/xcache-1.3.2.tar.gz',
49 'require' => array(
50 'php' => array('<', '5.4')
51 ),
52 'configure' => array('--enable-xcache'),
53 'ini' => array(
54 'extension=xcache.so',
55 'xcache.cacher=false',
56 'xcache.admin.enable_auth=0',
57 'xcache.var_size=1M'
58 )
59 ),
60 'mongo' => array(
61 'url' => 'http://pecl.php.net/get/mongo-1.2.7.tgz',
62 'require' => array(),
63 'configure' => array(),
64 'ini' => array(
65 'extension=mongo.so'
66 )
67 )
68 );
616b0ed4 » mehlah
2012-02-13 Install php extensions necessary for Travis build
69
c210573e » davidpersson
2012-04-16 Restructuring CI depends script, adding docblocks.
70 /**
1217042a » davidpersson
2012-04-16 Refactoring retrieval of ini path in CI depends script; adding docblock.
71 * Install extension by given name.
c210573e » davidpersson
2012-04-16 Restructuring CI depends script, adding docblocks.
72 *
1217042a » davidpersson
2012-04-16 Refactoring retrieval of ini path in CI depends script; adding docblock.
73 * Uses configration retrieved as per `php_ini_loaded_file()`.
d747f8c4 » davidpersson
2012-04-09 Applying basic coding standards conventions to CI script.
74 *
1217042a » davidpersson
2012-04-16 Refactoring retrieval of ini path in CI depends script; adding docblock.
75 * @see http://php.net/php_ini_loaded_file
76 * @param string $name The name of the extension to install.
d747f8c4 » davidpersson
2012-04-09 Applying basic coding standards conventions to CI script.
77 * @return void
78 */
7c237798 » davidpersson
2012-04-16 Making CI depends script class static.
79 public static function install($name) {
83150292 » davidpersson
2012-04-16 Refactoring CI depends script.
80 if (!isset(static::$_extensions[$name])) {
81 return;
82 }
83 $extension = static::$_extensions[$name];
84 echo $name;
616b0ed4 » mehlah
2012-02-13 Install php extensions necessary for Travis build
85
83150292 » davidpersson
2012-04-16 Refactoring CI depends script.
86 if (isset($extension['require']['php'])) {
87 $version = $extension['require']['php'];
7327c995 » davidpersson
2012-04-16 Use PHP_VERSION instead of `phpversion()` in CI depends script.
88
83150292 » davidpersson
2012-04-16 Refactoring CI depends script.
89 if (!version_compare(PHP_VERSION, $version[1], $version[0])) {
90 $message = " => not installed, requires a PHP version %s %s (%s installed)\n";
91 printf($message, $version[0], $version[1], PHP_VERSION);
92 return;
4374b0f6 » mehlah
2012-02-16 Refactor for a cleaner code
93 }
83150292 » davidpersson
2012-04-16 Refactoring CI depends script.
94 }
616b0ed4 » mehlah
2012-02-13 Install php extensions necessary for Travis build
95
83150292 » davidpersson
2012-04-16 Refactoring CI depends script.
96 static::_system(sprintf('wget %s > /dev/null 2>&1', $extension['url']));
97 $file = basename($extension['url']);
d747f8c4 » davidpersson
2012-04-09 Applying basic coding standards conventions to CI script.
98
83150292 » davidpersson
2012-04-16 Refactoring CI depends script.
99 static::_system(sprintf('tar -xzf %s > /dev/null 2>&1', $file));
100 $folder = basename($file, '.tgz');
101 $folder = basename($folder, '.tar.gz');
d747f8c4 » davidpersson
2012-04-09 Applying basic coding standards conventions to CI script.
102
83150292 » davidpersson
2012-04-16 Refactoring CI depends script.
103 $message = 'sh -c "cd %s && phpize && ./configure %s ';
104 $message .= '&& make && sudo make install" > /dev/null 2>&1';
105 static::_system(sprintf($message, $folder, implode(' ', $extension['configure'])));
d747f8c4 » davidpersson
2012-04-09 Applying basic coding standards conventions to CI script.
106
83150292 » davidpersson
2012-04-16 Refactoring CI depends script.
107 foreach ($extension['ini'] as $ini) {
108 static::_system(sprintf("echo %s >> %s", $ini, php_ini_loaded_file()));
4374b0f6 » mehlah
2012-02-16 Refactor for a cleaner code
109 }
83150292 » davidpersson
2012-04-16 Refactoring CI depends script.
110 printf("=> installed (%s)\n", $folder);
4374b0f6 » mehlah
2012-02-16 Refactor for a cleaner code
111 }
616b0ed4 » mehlah
2012-02-13 Install php extensions necessary for Travis build
112
d324c630 » davidpersson
2012-04-16 Adding docblock in CI depends script.
113 /**
114 * Executes given command, reports and exits in case it fails.
115 *
116 * @param string $command The command to execute.
117 * @return void
118 */
7c237798 » davidpersson
2012-04-16 Making CI depends script class static.
119 protected static function _system($command) {
d747f8c4 » davidpersson
2012-04-09 Applying basic coding standards conventions to CI script.
120 $return = 0;
121 system($command, $return);
122
123 if (0 !== $return) {
124 printf("=> Command '%s' failed !", $command);
125 exit($return);
4374b0f6 » mehlah
2012-02-16 Refactor for a cleaner code
126 }
127 }
616b0ed4 » mehlah
2012-02-13 Install php extensions necessary for Travis build
128 }
129
130 ?>
Something went wrong with that request. Please try again.