Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / common / bin / travis-setup.php
1 <?php
2 /*
3  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14  *
15  * This software consists of voluntary contributions made by many individuals
16  * and is licensed under the LGPL. For more information, see
17  * <http://www.doctrine-project.org>.
18  */
19
20 /**
21  * Install PHP extensions required for testing by Travis CI.
22  *
23  * @author Victor Berchet <victor@suumit.com>
24  * @since 2.2
25  */
26 $installer = new PhpExtensions();
27
28 if (isset($argv[1]) && 'APC' === strtoupper($argv[1])) {
29     $installer->install('apc');
30 } else {
31     $installer->install('xcache');
32 }
33
34 $installer->install('memcache');
35 $installer->install('memcached');
36
37 class PhpExtensions
38 {
39     protected $extensions;
40     protected $phpVersion;
41     protected $iniPath;
42
43     public function __construct()
44     {
45         $this->phpVersion = phpversion();
46         $this->iniPath = php_ini_loaded_file();
47         $this->extensions = array(
48         'memcache' => array(
49             'url'        => 'http://pecl.php.net/get/memcache-2.2.6.tgz',
50             'php_version' => array(),
51             'cfg'         => array('--enable-memcache'),
52             'ini'         => array('extension=memcache.so'),
53         ),
54         'memcached' => array(
55             'url'        => 'http://pecl.php.net/get/memcached-1.0.2.tgz',
56             'php_version' => array(
57                 // memcached 1.0.2 does not build on PHP 5.4
58                 array('<', '5.4'),
59             ),
60             'cfg'         => array(),
61             'ini'         => array('extension=memcached.so'),
62         ),
63         'apc' => array(
64             'url'        => 'http://pecl.php.net/get/APC-3.1.9.tgz',
65             'php_version' => array(
66                 // apc 3.1.9 causes a segfault on PHP 5.4
67                 array('<', '5.4'),
68             ),
69             'cfg'         => array(),
70             'ini'         => array(
71                 'extension=apc.so',
72                 'apc.enabled=1',
73                 'apc.enable_cli=1'
74             ),
75         ),
76         'xcache' => array(
77             'url'        => 'http://xcache.lighttpd.net/pub/Releases/1.2.2/xcache-1.2.2.tar.gz',
78             'php_version' => array(
79                 // xcache does not build with Travis CI (as of 2012-01-09)
80                 array('<', '5'),
81             ),
82             'cfg'         => array('--enable-xcache'),
83             'ini'         => array(
84                 'extension=xcache.so',
85                 'xcache.cacher=false',
86                 'xcache.admin.enable_auth=0',
87                 'xcache.var_size=1M',
88             ),
89         ),
90     );
91     }
92
93     public function install($name)
94     {
95         if (array_key_exists($name, $this->extensions)) {
96             $extension = $this->extensions[$name];
97
98
99             echo "== extension: $name ==\n";
100
101             foreach ($extension['php_version'] as $version) {
102                 if (!version_compare($this->phpVersion, $version[1], $version[0])) {
103                     printf(
104                         "=> not installed, requires a PHP version %s %s (%s installed)\n",
105                         $version[0],
106                         $version[1],
107                         $this->phpVersion
108                     );
109
110                     return;
111                 }
112             }
113
114             $this->system(sprintf("wget %s > /dev/null 2>&1", $extension['url']));
115             $file = basename($extension['url']);
116             $this->system(sprintf("tar -xzf %s > /dev/null 2>&1", $file));
117             $folder = basename($file, ".tgz");
118             $folder = basename($folder, ".tar.gz");
119             $this->system(sprintf(
120                 'sh -c "cd %s && phpize && ./configure %s && make && sudo make install" > /dev/null 2>&1',
121                 $folder,
122                 implode(' ', $extension['cfg'])
123             ));
124             foreach ($extension['ini'] as $ini) {
125                 $this->system(sprintf("echo %s >> %s", $ini, $this->iniPath));
126             }
127             printf("=> installed (%s)\n", $folder);
128         }
129     }
130
131     private function system($cmd)
132     {
133         $ret = 0;
134         system($cmd, $ret);
135         if (0 !== $ret) {
136             printf("=> Command '%s' failed !", $cmd);
137             
138             exit($ret);
139         }
140     }
141 }