Skip to content
Newer
Older
100644 327 lines (303 sloc) 9.78 KB
07136ce * new installer rule that does not depend on bash
ssb authored
1 <?php
7ad50d0 Allow us to run even if output buffering is turned on. Up to PHP 5.2.…
dufuz authored
2 while (@ob_end_flush());
ec1b8e9 added missing cvs id tag
sniper authored
3 /* $Id$ */
4
6616c4e remove E_STRICT/E_DEPRECATED explicitly
cellog authored
5 error_reporting(1803);
abf7d7b put UTC as a default timezone to fix the date issue when people run m…
dufuz authored
6
7 if (ini_get('date.timezone') === '' && function_exists('date_default_timezone_set')) {
8 date_default_timezone_set('UTC');
9 }
10
07136ce * new installer rule that does not depend on bash
ssb authored
11 $pear_dir = dirname(__FILE__);
75903af fix fatal error on ref - this now works!
cellog authored
12 ini_set('include_path', '');
c7d916a disable mbstring magic if necessary
cellog authored
13 if (function_exists('mb_internal_encoding')) {
14 mb_internal_encoding('ASCII');
15 }
b4009e3 don't time out after 30 seconds
cellog authored
16 set_time_limit(0);
07136ce * new installer rule that does not depend on bash
ssb authored
17 include_once 'PEAR.php';
18 include_once 'PEAR/Installer.php';
19 include_once 'PEAR/Registry.php';
9d92ca4 major updates to
cellog authored
20 include_once 'PEAR/PackageFile.php';
21 include_once 'PEAR/Downloader/Package.php';
7fbec7b initial update to enable pharring and use 1.4.0 features
cellog authored
22 include_once 'PEAR/Frontend.php';
d5f063e fix bug #2752: installation fails when php is built with an external …
cellog authored
23 $a = true;
2f7d5e7 *REALLY* fix bug #2752: installation fails when php is built with an …
cellog authored
24 if (!PEAR::loadExtension('xml')) {
d5f063e fix bug #2752: installation fails when php is built with an external …
cellog authored
25 $a = false;
26 echo "[PEAR] xml extension is required\n";
27 }
2f7d5e7 *REALLY* fix bug #2752: installation fails when php is built with an …
cellog authored
28 if (!PEAR::loadExtension('pcre')) {
d5f063e fix bug #2752: installation fails when php is built with an external …
cellog authored
29 $a = false;
30 echo "[PEAR] pcre extension is required\n";
31 }
32 if (!$a) {
33 return -1;
34 }
35
5c08991 Use the --with-pear=DIR, --prefix && --layout
cox authored
36 $force = false;
07136ce * new installer rule that does not depend on bash
ssb authored
37 $install_files = array();
5c08991 Use the --with-pear=DIR, --prefix && --layout
cox authored
38 array_shift($argv);
9d92ca4 major updates to
cellog authored
39 $debug = false;
5c08991 Use the --with-pear=DIR, --prefix && --layout
cox authored
40 for ($i = 0; $i < sizeof($argv); $i++) {
41 $arg = $argv[$i];
07136ce * new installer rule that does not depend on bash
ssb authored
42 $bn = basename($arg);
cce16ef Bug #16547 The phar for PEAR installer uses ereg() which is deprecat…
dufuz authored
43 if (preg_match('/package-(.*)\.xml$/', $bn, $matches) ||
44 preg_match('/([A-Za-z0-9_:]+)-.*\.(tar|tgz)$/', $bn, $matches)) {
f6b2e64 typo, need the complete file name not the basenamed one
cox authored
45 $install_files[$matches[1]] = $arg;
c651eb9 @remicollet add long option for readability
remicollet authored
46 } elseif ($arg == '-a' || $arg == '--cache') {
93de674 Request #14556 install-pear-nozlib.phar should get download_dir confi…
dufuz authored
47 $cache_dir = $argv[$i+1];
48 $i++;
5c08991 Use the --with-pear=DIR, --prefix && --layout
cox authored
49 } elseif ($arg == '--force') {
50 $force = true;
4ae4ccf add php_prefix/php_suffix saving. This finally fixes PHP Bug #43857
cellog authored
51 } elseif ($arg == '-dp') {
52 $prefix = $argv[$i+1];
53 $i++;
54 } elseif ($arg == '-ds') {
55 $suffix = $argv[$i+1];
56 $i++;
c651eb9 @remicollet add long option for readability
remicollet authored
57 } elseif ($arg == '-d' || $arg == '--dir') {
5c08991 Use the --with-pear=DIR, --prefix && --layout
cox authored
58 $with_dir = $argv[$i+1];
59 $i++;
c651eb9 @remicollet add long option for readability
remicollet authored
60 } elseif ($arg == '-b' || $arg == '--bin') {
1d6bbde PEAR binaries go where the php bin goes
cox authored
61 $bin_dir = $argv[$i+1];
62 $i++;
c651eb9 @remicollet add long option for readability
remicollet authored
63 } elseif ($arg == '-c' || $arg == '--config') {
6d28295 Implement Request #13927: install-pear.php should have option to set …
timj authored
64 $cfg_dir = $argv[$i+1];
65 $i++;
c651eb9 @remicollet add long option for readability
remicollet authored
66 } elseif ($arg == '-w' || $arg == '--www') {
6d28295 Implement Request #13927: install-pear.php should have option to set …
timj authored
67 $www_dir = $argv[$i+1];
68 $i++;
c651eb9 @remicollet add long option for readability
remicollet authored
69 } elseif ($arg == '-p' || $arg == '--php') {
f146547 add packagingroot option, and use it for INSTALL_ROOT of make install…
cellog authored
70 $php_bin = $argv[$i+1];
71 $i++;
c651eb9 @remicollet add long option for readability
remicollet authored
72 } elseif ($arg == '-o' || $arg == '--download') {
93de674 Request #14556 install-pear-nozlib.phar should get download_dir confi…
dufuz authored
73 $download_dir = $argv[$i+1];
74 $i++;
c651eb9 @remicollet add long option for readability
remicollet authored
75 } elseif ($arg == '-t' || $arg == '--temp') {
93de674 Request #14556 install-pear-nozlib.phar should get download_dir confi…
dufuz authored
76 $temp_dir = $argv[$i+1];
77 $i++;
c651eb9 @remicollet add long option for readability
remicollet authored
78 } elseif ($arg == '-A' || $arg == '--data') {
dcda5e2 @remicollet add option to set data_dir and test_dir
remicollet authored
79 $data_dir = $argv[$i+1];
80 $i++;
c651eb9 @remicollet add long option for readability
remicollet authored
81 } elseif ($arg == '-D' || $arg == '--doc') {
3db1648 @CloCkWeRX Request #18367 Please allow to set doc_dir during install
CloCkWeRX authored
82 $doc_dir = $argv[$i+1];
83 $i++;
c651eb9 @remicollet add long option for readability
remicollet authored
84 } elseif ($arg == '-T' || $arg == '--test') {
dcda5e2 @remicollet add option to set data_dir and test_dir
remicollet authored
85 $test_dir = $argv[$i+1];
86 $i++;
9d92ca4 major updates to
cellog authored
87 } elseif ($arg == '--debug') {
88 $debug = 1;
89 } elseif ($arg == '--extremedebug') {
90 $debug = 2;
07136ce * new installer rule that does not depend on bash
ssb authored
91 }
92 }
93
9d92ca4 major updates to
cellog authored
94 $config = PEAR_Config::singleton();
07136ce * new installer rule that does not depend on bash
ssb authored
95
bc62cc7 die on configuration file error
cellog authored
96 if (PEAR::isError($config)) {
97 $locs = PEAR_Config::getDefaultConfigFiles();
98 die("ERROR: One of $locs[user] or $locs[system] is corrupt, please remove them and try again");
99 }
100
07136ce * new installer rule that does not depend on bash
ssb authored
101 // make sure we use only default values
102 $config_layers = $config->getLayers();
103 foreach ($config_layers as $layer) {
104 if ($layer == 'default') continue;
105 $config->removeLayer($layer);
106 }
5c08991 Use the --with-pear=DIR, --prefix && --layout
cox authored
107 $keys = $config->getKeys();
9d92ca4 major updates to
cellog authored
108 if ($debug) {
109 $config->set('verbose', 5, 'default');
110 } else {
111 $config->set('verbose', 0, 'default');
112 }
1d6bbde PEAR binaries go where the php bin goes
cox authored
113 // PEAR executables
114 if (!empty($bin_dir)) {
115 $config->set('bin_dir', $bin_dir, 'default');
116 }
415e8f4 Implement Request #13375: install-pear.php should have option to set …
timj authored
117
93de674 Request #14556 install-pear-nozlib.phar should get download_dir confi…
dufuz authored
118 // Cache files
119 if (!empty($cache_dir)) {
120 $config->set('cache_dir', $cache_dir, 'default');
121 }
122
415e8f4 Implement Request #13375: install-pear.php should have option to set …
timj authored
123 // Config files
124 if (!empty($cfg_dir)) {
125 $config->set('cfg_dir', $cfg_dir, 'default');
126 }
127
6d28295 Implement Request #13927: install-pear.php should have option to set …
timj authored
128 // Web files
129 if (!empty($www_dir)) {
130 $config->set('www_dir', $www_dir, 'default');
131 }
132
93de674 Request #14556 install-pear-nozlib.phar should get download_dir confi…
dufuz authored
133 // Downloaded files
134 if (!empty($download_dir)) {
135 $config->set('download_dir', $download_dir, 'default');
136 }
137
138 // Temporary files
139 if (!empty($temp_dir)) {
140 $config->set('temp_dir', $temp_dir, 'default');
141 }
142
3db1648 @CloCkWeRX Request #18367 Please allow to set doc_dir during install
CloCkWeRX authored
143 // Documentation files
144 if (!empty($doc_dir)) {
145 $config->set('doc_dir', $doc_dir, 'default');
146 }
147
dcda5e2 @remicollet add option to set data_dir and test_dir
remicollet authored
148 // Data files
149 if (!empty($data_dir)) {
150 $config->set('data_dir', $data_dir, 'default');
151 }
152
153 // Unit tests
154 if (!empty($test_dir)) {
155 $config->set('test_dir', $test_dir, 'default');
156 }
157
5c08991 Use the --with-pear=DIR, --prefix && --layout
cox authored
158 // User supplied a dir prefix
159 if (!empty($with_dir)) {
160 $ds = DIRECTORY_SEPARATOR;
521f579 MFB: - Fix library path problems
derick authored
161 $config->set('php_dir', $with_dir, 'default');
3db1648 @CloCkWeRX Request #18367 Please allow to set doc_dir during install
CloCkWeRX authored
162 if (empty($doc_dir)) {
163 $config->set('doc_dir', $with_dir . $ds . 'doc', 'default');
164 }
dcda5e2 @remicollet add option to set data_dir and test_dir
remicollet authored
165 if (empty($data_dir)) {
166 $config->set('data_dir', $with_dir . $ds . 'data', 'default');
167 }
168 if (empty($test_dir)) {
169 $config->set('test_dir', $with_dir . $ds . 'test', 'default');
170 }
6d28295 Implement Request #13927: install-pear.php should have option to set …
timj authored
171 if (empty($www_dir)) {
172 $config->set('www_dir', $with_dir . $ds . 'htdocs', 'default');
173 }
c0fb600 Fix Bug #13926 install-pear.php does not set cfg_dir if -w option set…
timj authored
174 if (empty($cfg_dir)) {
dc2b64e fix Bug #13257 install-pear.php does not set cfg_dir or www_dir
cellog authored
175 $config->set('cfg_dir', $with_dir . $ds . 'cfg', 'default');
176 }
a6d7f6b add check for writeable cache_dir
cellog authored
177 if (!is_writable($config->get('cache_dir'))) {
178 include_once 'System.php';
179 $cdir = System::mktemp(array('-d', 'pear'));
180 if (PEAR::isError($cdir)) {
181 $ui->outputData("[PEAR] cannot make new temporary directory: " . $cdir);
182 die(1);
183 }
184 $oldcachedir = $config->get('cache_dir');
185 $config->set('cache_dir', $cdir);
186 }
5c08991 Use the --with-pear=DIR, --prefix && --layout
cox authored
187 }
4ae4ccf add php_prefix/php_suffix saving. This finally fixes PHP Bug #43857
cellog authored
188
189 // PHP executable
f146547 add packagingroot option, and use it for INSTALL_ROOT of make install…
cellog authored
190 if (!empty($php_bin)) {
191 $config->set('php_bin', $php_bin);
192 }
4ae4ccf add php_prefix/php_suffix saving. This finally fixes PHP Bug #43857
cellog authored
193
194 // PHP prefix
195 if (isset($prefix)) {
196 if ($prefix != 'a') {
197 if ($prefix[0] == 'a') {
198 $prefix = substr($prefix, 1);
199 }
200 $config->set('php_prefix', $prefix, 'system');
201 }
202 }
203
204 // PHP suffix
205 if (isset($suffix)) {
206 if ($suffix != 'a') {
207 if ($suffix[0] == 'a') {
208 $suffix = substr($suffix, 1);
209 }
210 $config->set('php_suffix', $suffix, 'system');
211 }
212 }
213
9d92ca4 major updates to
cellog authored
214 /* Print PEAR Conf (useful for debuging do NOT REMOVE) */
215 if ($debug) {
216 sort($keys);
217 foreach ($keys as $key) {
75903af fix fatal error on ref - this now works!
cellog authored
218 echo $key . ' ' .
219 $config->getPrompt($key) . ": " . $config->get($key, null, 'default') . "\n";
9d92ca4 major updates to
cellog authored
220 }
221 if ($debug == 2) { // extreme debugging
222 exit;
223 }
5c08991 Use the --with-pear=DIR, --prefix && --layout
cox authored
224 }
225 // end print
07136ce * new installer rule that does not depend on bash
ssb authored
226
68f4921 * support INSTALL_ROOT
ssb authored
227 $php_dir = $config->get('php_dir');
5c08991 Use the --with-pear=DIR, --prefix && --layout
cox authored
228 $options = array();
9d92ca4 major updates to
cellog authored
229 $options['upgrade'] = true;
5c08991 Use the --with-pear=DIR, --prefix && --layout
cox authored
230 $install_root = getenv('INSTALL_ROOT');
68f4921 * support INSTALL_ROOT
ssb authored
231 if (!empty($install_root)) {
f146547 add packagingroot option, and use it for INSTALL_ROOT of make install…
cellog authored
232 $options['packagingroot'] = $install_root;
233 $reg = &new PEAR_Registry($options['packagingroot']);
234 } else {
235 $reg = $config->getRegistry('default');
68f4921 * support INSTALL_ROOT
ssb authored
236 }
237
9d92ca4 major updates to
cellog authored
238 $ui = PEAR_Frontend::singleton('PEAR_Frontend_CLI');
fde9070 fix severely mangled and incorrect implementation of #10182: resoluti…
cellog authored
239 if (PEAR::isError($ui)) {
240 die($ui->getMessage());
241 }
9d92ca4 major updates to
cellog authored
242 $installer = new PEAR_Installer($ui);
243 $pkg = new PEAR_PackageFile($config, $debug);
07136ce * new installer rule that does not depend on bash
ssb authored
244
245 foreach ($install_files as $package => $instfile) {
9d92ca4 major updates to
cellog authored
246 $info = $pkg->fromAnyFile($instfile, PEAR_VALIDATE_INSTALLING);
247 if (PEAR::isError($info)) {
b13bd9e fix the phar generator for install-pear
cellog authored
248 if (is_array($info->getUserInfo())) {
249 foreach ($info->getUserInfo() as $err) {
250 $ui->outputData(sprintf("[PEAR] %s: %s", $package, $err['message']));
251 }
252 }
9d92ca4 major updates to
cellog authored
253 $ui->outputData(sprintf("[PEAR] %s: %s", $package, $info->getMessage()));
254 continue;
255 }
b13bd9e fix the phar generator for install-pear
cellog authored
256 $new_ver = $info->getVersion();
9d92ca4 major updates to
cellog authored
257 $downloaderpackage = new PEAR_Downloader_Package($installer);
258 $err = $downloaderpackage->initialize($instfile);
259 if (PEAR::isError($err)) {
260 $ui->outputData(sprintf("[PEAR] %s: %s", $package, $err->getMessage()));
261 continue;
262 }
07136ce * new installer rule that does not depend on bash
ssb authored
263 if ($reg->packageExists($package)) {
264 $old_ver = $reg->packageInfo($package, 'version');
265 if (version_compare($new_ver, $old_ver, 'gt')) {
9d92ca4 major updates to
cellog authored
266 $installer->setOptions($options);
75903af fix fatal error on ref - this now works!
cellog authored
267 $dp = array($downloaderpackage);
268 $installer->setDownloadedPackages($dp);
9d92ca4 major updates to
cellog authored
269 $err = $installer->install($downloaderpackage, $options);
07136ce * new installer rule that does not depend on bash
ssb authored
270 if (PEAR::isError($err)) {
21c65e7 displayLine() -> outputData()
cox authored
271 $ui->outputData(sprintf("[PEAR] %s: %s", $package, $err->getMessage()));
07136ce * new installer rule that does not depend on bash
ssb authored
272 continue;
273 }
21c65e7 displayLine() -> outputData()
cox authored
274 $ui->outputData(sprintf("[PEAR] %-15s- upgraded: %s", $package, $new_ver));
07136ce * new installer rule that does not depend on bash
ssb authored
275 } else {
5c08991 Use the --with-pear=DIR, --prefix && --layout
cox authored
276 if ($force) {
68f4921 * support INSTALL_ROOT
ssb authored
277 $options['force'] = true;
9d92ca4 major updates to
cellog authored
278 $installer->setOptions($options);
75903af fix fatal error on ref - this now works!
cellog authored
279 $dp = array($downloaderpackage);
280 $installer->setDownloadedPackages($dp);
9d92ca4 major updates to
cellog authored
281 $err = $installer->install($downloaderpackage, $options);
07136ce * new installer rule that does not depend on bash
ssb authored
282 if (PEAR::isError($err)) {
21c65e7 displayLine() -> outputData()
cox authored
283 $ui->outputData(sprintf("[PEAR] %s: %s", $package, $err->getMessage()));
07136ce * new installer rule that does not depend on bash
ssb authored
284 continue;
285 }
21c65e7 displayLine() -> outputData()
cox authored
286 $ui->outputData(sprintf("[PEAR] %-15s- installed: %s", $package, $new_ver));
07136ce * new installer rule that does not depend on bash
ssb authored
287 } else {
21c65e7 displayLine() -> outputData()
cox authored
288 $ui->outputData(sprintf("[PEAR] %-15s- already installed: %s", $package, $old_ver));
07136ce * new installer rule that does not depend on bash
ssb authored
289 }
290 }
291 } else {
68f4921 * support INSTALL_ROOT
ssb authored
292 $options['nodeps'] = true;
9d92ca4 major updates to
cellog authored
293 $installer->setOptions($options);
75903af fix fatal error on ref - this now works!
cellog authored
294 $dp = array($downloaderpackage);
295 $installer->setDownloadedPackages($dp);
9d92ca4 major updates to
cellog authored
296 $err = $installer->install($downloaderpackage, $options);
07136ce * new installer rule that does not depend on bash
ssb authored
297 if (PEAR::isError($err)) {
21c65e7 displayLine() -> outputData()
cox authored
298 $ui->outputData(sprintf("[PEAR] %s: %s", $package, $err->getMessage()));
07136ce * new installer rule that does not depend on bash
ssb authored
299 continue;
300 }
21c65e7 displayLine() -> outputData()
cox authored
301 $ui->outputData(sprintf("[PEAR] %-15s- installed: %s", $package, $new_ver));
07136ce * new installer rule that does not depend on bash
ssb authored
302 }
3fc637c Write the PEAR system config file while installing
cox authored
303 if ($package == 'PEAR') {
304 if (is_file($ufile = $config->getConfFile('user'))) {
305 $ui->outputData('Warning! a PEAR user config file already exists from ' .
306 'a previous PEAR installation at ' .
307 "'$ufile'. You may probably want to remove it.");
308 }
a9b862a Store verbose=1 in config file
cox authored
309 $config->set('verbose', 1, 'default');
a6d7f6b add check for writeable cache_dir
cellog authored
310 if (isset($oldcachedir)) {
311 $config->set('cache_dir', $oldcachedir);
312 }
24c48c9 fix weird warnings in the generated install-pear-phar
cellog authored
313 $data = array();
3fc637c Write the PEAR system config file while installing
cox authored
314 foreach ($config->getKeys() as $key) {
315 $data[$key] = $config->get($key);
316 }
aea523a Made the install of the config honors $INSTALL_ROOT
cox authored
317 $cnf_file = $config->getConfFile('system');
318 if (!empty($install_root)) {
319 $cnf_file = $install_root . DIRECTORY_SEPARATOR . $cnf_file;
320 }
321 $config->writeConfigFile($cnf_file, 'system', $data);
322 $ui->outputData('Wrote PEAR system config file at: ' . $cnf_file);
323 $ui->outputData('You may want to add: ' . $config->get('php_dir') . ' to your php.ini include_path');
3fc637c Write the PEAR system config file while installing
cox authored
324 }
07136ce * new installer rule that does not depend on bash
ssb authored
325 }
5c08991 Use the --with-pear=DIR, --prefix && --layout
cox authored
326 ?>
Something went wrong with that request. Please try again.