Subversion Repositories Applications.gtt

Rev

Rev 94 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 94 Rev 187
Line 2... Line 2...
2
/**
2
/**
3
 * PEAR_Downloader_Package
3
 * PEAR_Downloader_Package
4
 *
4
 *
5
 * PHP versions 4 and 5
5
 * PHP versions 4 and 5
6
 *
6
 *
7
 * LICENSE: This source file is subject to version 3.0 of the PHP license
-
 
8
 * that is available through the world-wide-web at the following URI:
-
 
9
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
-
 
10
 * the PHP License and are unable to obtain it through the web, please
-
 
11
 * send a note to license@php.net so we can mail you a copy immediately.
-
 
12
 *
-
 
13
 * @category   pear
7
 * @category   pear
14
 * @package    PEAR
8
 * @package    PEAR
15
 * @author     Greg Beaver <cellog@php.net>
9
 * @author     Greg Beaver <cellog@php.net>
16
 * @copyright  1997-2006 The PHP Group
10
 * @copyright  1997-2009 The Authors
17
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
11
 * @license    http://opensource.org/licenses/bsd-license.php New BSD License
18
 * @version    CVS: $Id: Package.php,v 1.104 2007/01/14 21:11:54 cellog Exp $
-
 
19
 * @link       http://pear.php.net/package/PEAR
12
 * @link       http://pear.php.net/package/PEAR
20
 * @since      File available since Release 1.4.0a1
13
 * @since      File available since Release 1.4.0a1
21
 */
14
 */
-
 
15
 
22
/**
16
/**
23
 * Error code when parameter initialization fails because no releases
17
 * Error code when parameter initialization fails because no releases
24
 * exist within preferred_state, but releases do exist
18
 * exist within preferred_state, but releases do exist
25
 */
19
 */
26
define('PEAR_DOWNLOADER_PACKAGE_STATE', -1003);
20
define('PEAR_DOWNLOADER_PACKAGE_STATE', -1003);
27
/**
21
/**
-
 
22
 * Error code when parameter initialization fails because no releases
-
 
23
 * exist that will work with the existing PHP version
-
 
24
 */
-
 
25
define('PEAR_DOWNLOADER_PACKAGE_PHPVERSION', -1004);
-
 
26
 
-
 
27
/**
28
 * Coordinates download parameters and manages their dependencies
28
 * Coordinates download parameters and manages their dependencies
29
 * prior to downloading them.
29
 * prior to downloading them.
30
 *
30
 *
31
 * Input can come from three sources:
31
 * Input can come from three sources:
32
 *
32
 *
Line 45... Line 45...
45
 * not supported, PEAR installer version is not supported, or non-PECL extensions are not
45
 * not supported, PEAR installer version is not supported, or non-PECL extensions are not
46
 * installed.
46
 * installed.
47
 * @category   pear
47
 * @category   pear
48
 * @package    PEAR
48
 * @package    PEAR
49
 * @author     Greg Beaver <cellog@php.net>
49
 * @author     Greg Beaver <cellog@php.net>
50
 * @copyright  1997-2006 The PHP Group
50
 * @copyright  1997-2009 The Authors
51
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
51
 * @license    http://opensource.org/licenses/bsd-license.php New BSD License
52
 * @version    Release: 1.5.1
52
 * @version    Release: 1.10.1
53
 * @link       http://pear.php.net/package/PEAR
53
 * @link       http://pear.php.net/package/PEAR
54
 * @since      Class available since Release 1.4.0a1
54
 * @since      Class available since Release 1.4.0a1
55
 */
55
 */
56
class PEAR_Downloader_Package
56
class PEAR_Downloader_Package
57
{
57
{
Line 108... Line 108...
108
    /**
108
    /**
109
     * If this package is invoked with Package#group, this variable will be true
109
     * If this package is invoked with Package#group, this variable will be true
110
     */
110
     */
111
    var $_explicitGroup = false;
111
    var $_explicitGroup = false;
112
    /**
112
    /**
113
     * Package type local|url|xmlrpc
113
     * Package type local|url
114
     * @var string
114
     * @var string
115
     */
115
     */
116
    var $_type;
116
    var $_type;
117
    /**
117
    /**
118
     * Contents of package.xml, if downloaded from a remote channel
118
     * Contents of package.xml, if downloaded from a remote channel
Line 127... Line 127...
127
    var $_validated = false;
127
    var $_validated = false;
Line 128... Line 128...
128
 
128
 
129
    /**
129
    /**
130
     * @param PEAR_Downloader
130
     * @param PEAR_Downloader
131
     */
131
     */
132
    function PEAR_Downloader_Package(&$downloader)
132
    function __construct(&$downloader)
133
    {
133
    {
134
        $this->_downloader = &$downloader;
134
        $this->_downloader = &$downloader;
135
        $this->_config = &$this->_downloader->config;
135
        $this->_config = &$this->_downloader->config;
136
        $this->_registry = &$this->_config->getRegistry();
136
        $this->_registry = &$this->_config->getRegistry();
Line 155... Line 155...
155
     * @return bool|PEAR_Error
155
     * @return bool|PEAR_Error
156
     */
156
     */
157
    function initialize($param)
157
    function initialize($param)
158
    {
158
    {
159
        $origErr = $this->_fromFile($param);
159
        $origErr = $this->_fromFile($param);
160
        if (!$this->_valid) {
160
        if ($this->_valid) {
-
 
161
            return true;
-
 
162
        }
-
 
163
 
161
            $options = $this->_downloader->getOptions();
164
        $options = $this->_downloader->getOptions();
162
            if (isset($options['offline'])) {
165
        if (isset($options['offline'])) {
163
                if (PEAR::isError($origErr)) {
166
            if (PEAR::isError($origErr) && !isset($options['soft'])) {
-
 
167
                foreach ($origErr->getUserInfo() as $userInfo) {
164
                    if (!isset($options['soft'])) {
168
                    if (isset($userInfo['message'])) {
165
                        $this->_downloader->log(0, $origErr->getMessage());
169
                        $this->_downloader->log(0, $userInfo['message']);
166
                    }
170
                    }
167
                }
171
                }
-
 
172
 
168
                return PEAR::raiseError('Cannot download non-local package "' . $param . '"');
173
                $this->_downloader->log(0, $origErr->getMessage());
169
            }
174
            }
-
 
175
 
-
 
176
            return PEAR::raiseError('Cannot download non-local package "' . $param . '"');
-
 
177
        }
-
 
178
 
170
            $err = $this->_fromUrl($param);
179
        $err = $this->_fromUrl($param);
-
 
180
        if (PEAR::isError($err) || !$this->_valid) {
-
 
181
            if ($this->_type == 'url') {
-
 
182
                if (PEAR::isError($err) && !isset($options['soft'])) {
-
 
183
                    $this->_downloader->log(0, $err->getMessage());
-
 
184
                }
-
 
185
 
-
 
186
                return PEAR::raiseError("Invalid or missing remote package file");
-
 
187
            }
-
 
188
 
-
 
189
            $err = $this->_fromString($param);
171
            if (PEAR::isError($err) || !$this->_valid) {
190
            if (PEAR::isError($err) || !$this->_valid) {
172
                if ($this->_type == 'url') {
-
 
173
                    if (PEAR::isError($err)) {
191
                if (PEAR::isError($err) && $err->getCode() == PEAR_DOWNLOADER_PACKAGE_STATE) {
174
                        if (!isset($options['soft'])) {
-
 
175
                            $this->_downloader->log(0, $err->getMessage());
-
 
176
                        }
-
 
177
                    }
-
 
178
                    return PEAR::raiseError("Invalid or missing remote package file");
192
                    return false; // instruct the downloader to silently skip
179
                }
193
                }
180
                $err = $this->_fromString($param);
-
 
181
                if (PEAR::isError($err) || !$this->_valid) {
-
 
182
                    if (PEAR::isError($err) &&
-
 
183
                          $err->getCode() == PEAR_DOWNLOADER_PACKAGE_STATE) {
-
 
184
                        return false; // instruct the downloader to silently skip
-
 
185
                    }
-
 
-
 
194
 
186
                    if (isset($this->_type) && $this->_type == 'local' &&
195
                if (isset($this->_type) && $this->_type == 'local' && PEAR::isError($origErr)) {
187
                          PEAR::isError($origErr)) {
-
 
188
                        if (is_array($origErr->getUserInfo())) {
196
                    if (is_array($origErr->getUserInfo())) {
189
                            foreach ($origErr->getUserInfo() as $err) {
197
                        foreach ($origErr->getUserInfo() as $err) {
190
                                if (is_array($err)) {
198
                            if (is_array($err)) {
191
                                    $err = $err['message'];
199
                                $err = $err['message'];
192
                                }
200
                            }
-
 
201
 
193
                                if (!isset($options['soft'])) {
202
                            if (!isset($options['soft'])) {
194
                                    $this->_downloader->log(0, $err);
203
                                $this->_downloader->log(0, $err);
195
                                }
-
 
196
                            }
204
                            }
197
                        }
205
                        }
198
                        if (!isset($options['soft'])) {
-
 
199
                            $this->_downloader->log(0, $origErr->getMessage());
-
 
200
                        }
-
 
201
                        if (is_array($param)) {
-
 
202
                            $param = $this->_registry->parsedPackageNameToString($param,
-
 
203
                                true);
-
 
204
                        }
-
 
205
                        return PEAR::raiseError(
-
 
206
                            "Cannot initialize '$param', invalid or missing package file");
-
 
207
                    }
206
                    }
208
                    if (PEAR::isError($err)) {
-
 
-
 
207
 
209
                        if (!isset($options['soft'])) {
208
                    if (!isset($options['soft'])) {
210
                            $this->_downloader->log(0, $err->getMessage());
209
                        $this->_downloader->log(0, $origErr->getMessage());
211
                        }
-
 
212
                    }
210
                    }
-
 
211
 
213
                    if (is_array($param)) {
212
                    if (is_array($param)) {
214
                        $param = $this->_registry->parsedPackageNameToString($param, true);
213
                        $param = $this->_registry->parsedPackageNameToString($param, true);
215
                    }
214
                    }
-
 
215
 
-
 
216
                    if (!isset($options['soft'])) {
-
 
217
                        $this->_downloader->log(2, "Cannot initialize '$param', invalid or missing package file");
-
 
218
                    }
-
 
219
 
-
 
220
                    // Passing no message back - already logged above
216
                    return PEAR::raiseError(
221
                    return PEAR::raiseError();
-
 
222
                }
-
 
223
 
-
 
224
                if (PEAR::isError($err) && !isset($options['soft'])) {
-
 
225
                    $this->_downloader->log(0, $err->getMessage());
-
 
226
                }
-
 
227
 
-
 
228
                if (is_array($param)) {
-
 
229
                    $param = $this->_registry->parsedPackageNameToString($param, true);
-
 
230
                }
-
 
231
 
-
 
232
                if (!isset($options['soft'])) {
217
                        "Cannot initialize '$param', invalid or missing package file");
233
                    $this->_downloader->log(2, "Cannot initialize '$param', invalid or missing package file");
218
                }
234
                }
-
 
235
 
-
 
236
                // Passing no message back - already logged above
-
 
237
                return PEAR::raiseError();
219
            }
238
            }
220
        }
239
        }
-
 
240
 
221
        return true;
241
        return true;
222
    }
242
    }
Line 223... Line 243...
223
 
243
 
224
    /**
244
    /**
Line 228... Line 248...
228
    function &download()
248
    function &download()
229
    {
249
    {
230
        if (isset($this->_packagefile)) {
250
        if (isset($this->_packagefile)) {
231
            return $this->_packagefile;
251
            return $this->_packagefile;
232
        }
252
        }
-
 
253
 
233
        if (isset($this->_downloadURL['url'])) {
254
        if (isset($this->_downloadURL['url'])) {
234
            $this->_isvalid = false;
255
            $this->_isvalid = false;
235
            $info = $this->getParsedPackage();
256
            $info = $this->getParsedPackage();
236
            foreach ($info as $i => $p) {
257
            foreach ($info as $i => $p) {
237
                $info[$i] = strtolower($p);
258
                $info[$i] = strtolower($p);
238
            }
259
            }
-
 
260
 
239
            $err = $this->_fromUrl($this->_downloadURL['url'],
261
            $err = $this->_fromUrl($this->_downloadURL['url'],
240
                $this->_registry->parsedPackageNameToString($this->_parsedname, true));
262
                $this->_registry->parsedPackageNameToString($this->_parsedname, true));
241
            $newinfo = $this->getParsedPackage();
263
            $newinfo = $this->getParsedPackage();
242
            foreach ($newinfo as $i => $p) {
264
            foreach ($newinfo as $i => $p) {
243
                $newinfo[$i] = strtolower($p);
265
                $newinfo[$i] = strtolower($p);
244
            }
266
            }
-
 
267
 
245
            if ($info != $newinfo) {
268
            if ($info != $newinfo) {
246
                do {
269
                do {
247
                    if ($info['package'] == 'pecl.php.net' && $newinfo['package'] == 'pear.php.net') {
270
                    if ($info['channel'] == 'pecl.php.net' && $newinfo['channel'] == 'pear.php.net') {
248
                        $info['package'] = 'pear.php.net';
271
                        $info['channel'] = 'pear.php.net';
249
                        if ($info == $newinfo) {
272
                        if ($info == $newinfo) {
250
                            // skip the channel check if a pecl package says it's a PEAR package
273
                            // skip the channel check if a pecl package says it's a PEAR package
251
                            break;
274
                            break;
252
                        }
275
                        }
253
                    }
276
                    }
-
 
277
                    if ($info['channel'] == 'pear.php.net' && $newinfo['channel'] == 'pecl.php.net') {
-
 
278
                        $info['channel'] = 'pecl.php.net';
-
 
279
                        if ($info == $newinfo) {
-
 
280
                            // skip the channel check if a pecl package says it's a PEAR package
-
 
281
                            break;
-
 
282
                        }
-
 
283
                    }
-
 
284
 
254
                    return PEAR::raiseError('CRITICAL ERROR: We are ' .
285
                    return PEAR::raiseError('CRITICAL ERROR: We are ' .
255
                        $this->_registry->parsedPackageNameToString($info) . ', but the file ' .
286
                        $this->_registry->parsedPackageNameToString($info) . ', but the file ' .
256
                        'downloaded claims to be ' .
287
                        'downloaded claims to be ' .
257
                        $this->_registry->parsedPackageNameToString($this->getParsedPackage()));
288
                        $this->_registry->parsedPackageNameToString($this->getParsedPackage()));
258
                } while (false);
289
                } while (false);
259
            }
290
            }
-
 
291
 
260
            if (PEAR::isError($err) || !$this->_valid) {
292
            if (PEAR::isError($err) || !$this->_valid) {
261
                return $err;
293
                return $err;
262
            }
294
            }
263
        }
295
        }
-
 
296
 
264
        $this->_type = 'local';
297
        $this->_type = 'local';
265
        return $this->_packagefile;
298
        return $this->_packagefile;
266
    }
299
    }
Line 267... Line 300...
267
 
300
 
Line 273... Line 306...
273
    function &getDownloader()
306
    function &getDownloader()
274
    {
307
    {
275
        return $this->_downloader;
308
        return $this->_downloader;
276
    }
309
    }
Line 277... Line 310...
277
 
310
 
278
    function getType() 
311
    function getType()
279
    {
312
    {
280
        return $this->_type;
313
        return $this->_type;
Line 281... Line 314...
281
    }
314
    }
Line 291... Line 324...
291
            if (!extension_loaded("zlib") || isset($options['nocompress'])) {
324
            if (!extension_loaded("zlib") || isset($options['nocompress'])) {
292
                $ext = '.tar';
325
                $ext = '.tar';
293
            } else {
326
            } else {
294
                $ext = '.tgz';
327
                $ext = '.tgz';
295
            }
328
            }
-
 
329
 
296
            PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
330
            PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
297
            $err = $this->_fromUrl($dep['uri'] . $ext);
331
            $err = $this->_fromUrl($dep['uri'] . $ext);
298
            PEAR::popErrorHandling();
332
            PEAR::popErrorHandling();
299
            if (PEAR::isError($err)) {
333
            if (PEAR::isError($err)) {
300
                if (!isset($options['soft'])) {
334
                if (!isset($options['soft'])) {
301
                    $this->_downloader->log(0, $err->getMessage());
335
                    $this->_downloader->log(0, $err->getMessage());
302
                }
336
                }
-
 
337
 
303
                return PEAR::raiseError('Invalid uri dependency "' . $dep['uri'] . $ext . '", ' .
338
                return PEAR::raiseError('Invalid uri dependency "' . $dep['uri'] . $ext . '", ' .
304
                    'cannot download');
339
                    'cannot download');
305
            }
340
            }
306
        } else {
341
        } else {
307
            $this->_parsedname =
342
            $this->_parsedname =
Line 312... Line 347...
312
                );
347
                );
313
            if (!isset($dep['nodefault'])) {
348
            if (!isset($dep['nodefault'])) {
314
                $this->_parsedname['group'] = 'default'; // download the default dependency group
349
                $this->_parsedname['group'] = 'default'; // download the default dependency group
315
                $this->_explicitGroup = false;
350
                $this->_explicitGroup = false;
316
            }
351
            }
-
 
352
 
317
            $this->_rawpackagefile = $dep['raw'];
353
            $this->_rawpackagefile = $dep['raw'];
318
        }
354
        }
319
    }
355
    }
Line 320... Line 356...
320
 
356
 
321
    function detectDependencies($params)
357
    function detectDependencies($params)
322
    {
358
    {
323
        $options = $this->_downloader->getOptions();
359
        $options = $this->_downloader->getOptions();
324
        if (isset($options['downloadonly'])) {
360
        if (isset($options['downloadonly'])) {
325
            return;
361
            return;
-
 
362
        }
326
        }
363
 
327
        if (isset($options['offline'])) {
364
        if (isset($options['offline'])) {
328
            $this->_downloader->log(3, 'Skipping dependency download check, --offline specified');
365
            $this->_downloader->log(3, 'Skipping dependency download check, --offline specified');
329
            return;
366
            return;
-
 
367
        }
330
        }
368
 
331
        $pname = $this->getParsedPackage();
369
        $pname = $this->getParsedPackage();
332
        if (!$pname) {
370
        if (!$pname) {
333
            return;
371
            return;
-
 
372
        }
334
        }
373
 
335
        $deps = $this->getDeps();
374
        $deps = $this->getDeps();
336
        if (!$deps) {
375
        if (!$deps) {
337
            return;
376
            return;
-
 
377
        }
338
        }
378
 
339
        if (isset($deps['required'])) { // package.xml 2.0
379
        if (isset($deps['required'])) { // package.xml 2.0
340
            return $this->_detect2($deps, $pname, $options, $params);
-
 
341
        } else {
-
 
342
            return $this->_detect1($deps, $pname, $options, $params);
380
            return $this->_detect2($deps, $pname, $options, $params);
-
 
381
        }
-
 
382
 
343
        }
383
        return $this->_detect1($deps, $pname, $options, $params);
Line 344... Line 384...
344
    }
384
    }
345
 
385
 
346
    function setValidated()
386
    function setValidated()
Line 354... Line 394...
354
    }
394
    }
Line 355... Line 395...
355
 
395
 
356
    /**
396
    /**
357
     * Remove packages to be downloaded that are already installed
397
     * Remove packages to be downloaded that are already installed
358
     * @param array of PEAR_Downloader_Package objects
-
 
359
     * @static
398
     * @param array of PEAR_Downloader_Package objects
360
     */
399
     */
361
    function removeInstalled(&$params)
400
    public static function removeInstalled(&$params)
362
    {
401
    {
363
        if (!isset($params[0])) {
402
        if (!isset($params[0])) {
364
            return;
403
            return;
-
 
404
        }
365
        }
405
 
366
        $options = $params[0]->_downloader->getOptions();
406
        $options = $params[0]->_downloader->getOptions();
367
        if (!isset($options['downloadonly'])) {
407
        if (!isset($options['downloadonly'])) {
-
 
408
            foreach ($params as $i => $param) {
-
 
409
                $package = $param->getPackage();
368
            foreach ($params as $i => $param) {
410
                $channel = $param->getChannel();
369
                // remove self if already installed with this version
411
                // remove self if already installed with this version
370
                // this does not need any pecl magic - we only remove exact matches
412
                // this does not need any pecl magic - we only remove exact matches
371
                if ($param->_installRegistry->packageExists($param->getPackage(), $param->getChannel())) {
413
                if ($param->_installRegistry->packageExists($package, $channel)) {
372
                    if (version_compare($param->_installRegistry->packageInfo($param->getPackage(), 'version',
414
                    $packageVersion = $param->_installRegistry->packageInfo($package, 'version', $channel);
373
                          $param->getChannel()), $param->getVersion(), '==')) {
415
                    if (version_compare($packageVersion, $param->getVersion(), '==')) {
374
                        if (!isset($options['force'])) {
416
                        if (!isset($options['force']) && !isset($options['packagingroot'])) {
375
                            $info = $param->getParsedPackage();
417
                            $info = $param->getParsedPackage();
376
                            unset($info['version']);
418
                            unset($info['version']);
377
                            unset($info['state']);
419
                            unset($info['state']);
378
                            if (!isset($options['soft'])) {
420
                            if (!isset($options['soft'])) {
379
                                $param->_downloader->log(1, 'Skipping package "' .
421
                                $param->_downloader->log(1, 'Skipping package "' .
380
                                    $param->getShortName() .
422
                                    $param->getShortName() .
381
                                    '", already installed as version ' .
-
 
382
                                    $param->_installRegistry->packageInfo($param->getPackage(),
-
 
383
                                        'version', $param->getChannel()));
423
                                    '", already installed as version ' . $packageVersion);
384
                            }
424
                            }
385
                            $params[$i] = false;
425
                            $params[$i] = false;
386
                        }
426
                        }
387
                    } elseif (!isset($options['force']) && !isset($options['upgrade']) &&
427
                    } elseif (!isset($options['force']) && !isset($options['upgrade']) &&
388
                          !isset($options['soft'])) {
428
                          !isset($options['soft']) && !isset($options['packagingroot'])) {
389
                        $info = $param->getParsedPackage();
429
                        $info = $param->getParsedPackage();
390
                        $param->_downloader->log(1, 'Skipping package "' .
430
                        $param->_downloader->log(1, 'Skipping package "' .
391
                            $param->getShortName() .
431
                            $param->getShortName() .
392
                            '", already installed as version ' .
-
 
393
                            $param->_installRegistry->packageInfo($param->getPackage(), 'version',
-
 
394
                                $param->getChannel()));
432
                            '", already installed as version ' . $packageVersion);
395
                        $params[$i] = false;
433
                        $params[$i] = false;
396
                    }
434
                    }
397
                }
435
                }
398
            }
436
            }
-
 
437
        }
399
        }
438
 
400
        PEAR_Downloader_Package::removeDuplicates($params);
439
        PEAR_Downloader_Package::removeDuplicates($params);
Line 401... Line 440...
401
    }
440
    }
402
 
441
 
Line 414... Line 453...
414
                            continue;
453
                            continue;
415
                        }
454
                        }
416
                        $ret = $this->_detect2Dep($dep, $pname, 'required', $params);
455
                        $ret = $this->_detect2Dep($dep, $pname, 'required', $params);
417
                        if (is_array($ret)) {
456
                        if (is_array($ret)) {
418
                            $this->_downloadDeps[] = $ret;
457
                            $this->_downloadDeps[] = $ret;
-
 
458
                        } elseif (PEAR::isError($ret) && !isset($options['soft'])) {
-
 
459
                            $this->_downloader->log(0, $ret->getMessage());
419
                        }
460
                        }
420
                    }
461
                    }
421
                } else {
462
                } else {
422
                    $dep = $deps['required'][$packagetype];
463
                    $dep = $deps['required'][$packagetype];
423
                    if (!isset($dep['conflicts'])) {
464
                    if (!isset($dep['conflicts'])) {
424
                        // skip any package that this package conflicts with
465
                        // skip any package that this package conflicts with
425
                        $ret = $this->_detect2Dep($dep, $pname, 'required', $params);
466
                        $ret = $this->_detect2Dep($dep, $pname, 'required', $params);
426
                        if (is_array($ret)) {
467
                        if (is_array($ret)) {
427
                            $this->_downloadDeps[] = $ret;
468
                            $this->_downloadDeps[] = $ret;
-
 
469
                        } elseif (PEAR::isError($ret) && !isset($options['soft'])) {
-
 
470
                            $this->_downloader->log(0, $ret->getMessage());
428
                        }
471
                        }
429
                    }
472
                    }
430
                }
473
                }
431
            }
474
            }
-
 
475
 
432
            // get optional dependency group, if any
476
            // get optional dependency group, if any
433
            if (isset($deps['optional'][$packagetype])) {
477
            if (isset($deps['optional'][$packagetype])) {
434
                $skipnames = array();
478
                $skipnames = array();
435
                if (!isset($deps['optional'][$packagetype][0])) {
479
                if (!isset($deps['optional'][$packagetype][0])) {
436
                    $deps['optional'][$packagetype] = array($deps['optional'][$packagetype]);
480
                    $deps['optional'][$packagetype] = array($deps['optional'][$packagetype]);
437
                }
481
                }
-
 
482
 
438
                foreach ($deps['optional'][$packagetype] as $dep) {
483
                foreach ($deps['optional'][$packagetype] as $dep) {
439
                    $skip = false;
484
                    $skip = false;
440
                    if (!isset($options['alldeps'])) {
485
                    if (!isset($options['alldeps'])) {
441
                        $dep['package'] = $dep['name'];
486
                        $dep['package'] = $dep['name'];
442
                        if (!isset($options['soft'])) {
487
                        if (!isset($options['soft'])) {
Line 449... Line 494...
449
                        }
494
                        }
450
                        $skipnames[] = $this->_registry->parsedPackageNameToString($dep, true);
495
                        $skipnames[] = $this->_registry->parsedPackageNameToString($dep, true);
451
                        $skip = true;
496
                        $skip = true;
452
                        unset($dep['package']);
497
                        unset($dep['package']);
453
                    }
498
                    }
-
 
499
 
454
                    if (!($ret = $this->_detect2Dep($dep, $pname, 'optional', $params))) {
500
                    $ret = $this->_detect2Dep($dep, $pname, 'optional', $params);
-
 
501
                    if (PEAR::isError($ret) && !isset($options['soft'])) {
-
 
502
                        $this->_downloader->log(0, $ret->getMessage());
-
 
503
                    }
-
 
504
 
-
 
505
                    if (!$ret) {
455
                        $dep['package'] = $dep['name'];
506
                        $dep['package'] = $dep['name'];
456
                        $skip = count($skipnames) ?
507
                        $skip = count($skipnames) ?
457
                            $skipnames[count($skipnames) - 1] : '';
508
                            $skipnames[count($skipnames) - 1] : '';
458
                        if ($skip ==
509
                        if ($skip ==
459
                              $this->_registry->parsedPackageNameToString($dep, true)) {
510
                              $this->_registry->parsedPackageNameToString($dep, true)) {
460
                            array_pop($skipnames);
511
                            array_pop($skipnames);
461
                        }
512
                        }
462
                    }
513
                    }
-
 
514
 
463
                    if (!$skip && is_array($ret)) {
515
                    if (!$skip && is_array($ret)) {
464
                        $this->_downloadDeps[] = $ret;
516
                        $this->_downloadDeps[] = $ret;
465
                    }
517
                    }
466
                }
518
                }
-
 
519
 
467
                if (count($skipnames)) {
520
                if (count($skipnames)) {
468
                    if (!isset($options['soft'])) {
521
                    if (!isset($options['soft'])) {
469
                        $this->_downloader->log(1, 'Did not download optional dependencies: ' .
522
                        $this->_downloader->log(1, 'Did not download optional dependencies: ' .
470
                            implode(', ', $skipnames) .
523
                            implode(', ', $skipnames) .
471
                            ', use --alldeps to download automatically');
524
                            ', use --alldeps to download automatically');
472
                    }
525
                    }
473
                }
526
                }
474
            }
527
            }
-
 
528
 
475
            // get requested dependency group, if any
529
            // get requested dependency group, if any
476
            $groupname = $this->getGroup();
530
            $groupname = $this->getGroup();
477
            $explicit = $this->_explicitGroup;
531
            $explicit  = $this->_explicitGroup;
478
            if (!$groupname) {
532
            if (!$groupname) {
479
                if ($this->canDefault()) {
533
                if (!$this->canDefault()) {
480
                    $groupname = 'default'; // try the default dependency group
-
 
481
                } else {
-
 
482
                    continue;
534
                    continue;
483
                }
535
                }
-
 
536
 
-
 
537
                $groupname = 'default'; // try the default dependency group
484
            }
538
            }
-
 
539
 
485
            if ($groupnotfound) {
540
            if ($groupnotfound) {
486
                continue;
541
                continue;
487
            }
542
            }
-
 
543
 
488
            if (isset($deps['group'])) {
544
            if (isset($deps['group'])) {
489
                if (isset($deps['group']['attribs'])) {
545
                if (isset($deps['group']['attribs'])) {
490
                    if (strtolower($deps['group']['attribs']['name']) == strtolower($groupname)) {
546
                    if (strtolower($deps['group']['attribs']['name']) == strtolower($groupname)) {
491
                        $group = $deps['group'];
547
                        $group = $deps['group'];
492
                    } elseif ($explicit) {
548
                    } elseif ($explicit) {
493
                        if (!isset($options['soft'])) {
549
                        if (!isset($options['soft'])) {
494
                            $this->_downloader->log(0, 'Warning: package "' .
550
                            $this->_downloader->log(0, 'Warning: package "' .
495
                                $this->_registry->parsedPackageNameToString($pname, true) .
551
                                $this->_registry->parsedPackageNameToString($pname, true) .
496
                                '" has no dependency ' . 'group named "' . $groupname . '"');
552
                                '" has no dependency ' . 'group named "' . $groupname . '"');
497
                        }
553
                        }
-
 
554
 
498
                        $groupnotfound = true;
555
                        $groupnotfound = true;
499
                        continue;
556
                        continue;
500
                    }
557
                    }
501
                } else {
558
                } else {
502
                    $found = false;
559
                    $found = false;
Line 504... Line 561...
504
                        if (strtolower($group['attribs']['name']) == strtolower($groupname)) {
561
                        if (strtolower($group['attribs']['name']) == strtolower($groupname)) {
505
                            $found = true;
562
                            $found = true;
506
                            break;
563
                            break;
507
                        }
564
                        }
508
                    }
565
                    }
-
 
566
 
509
                    if (!$found) {
567
                    if (!$found) {
510
                        if ($explicit) {
568
                        if ($explicit) {
511
                            if (!isset($options['soft'])) {
569
                            if (!isset($options['soft'])) {
512
                                $this->_downloader->log(0, 'Warning: package "' .
570
                                $this->_downloader->log(0, 'Warning: package "' .
513
                                    $this->_registry->parsedPackageNameToString($pname, true) .
571
                                    $this->_registry->parsedPackageNameToString($pname, true) .
514
                                    '" has no dependency ' . 'group named "' . $groupname . '"');
572
                                    '" has no dependency ' . 'group named "' . $groupname . '"');
515
                            }
573
                            }
516
                        }
574
                        }
-
 
575
 
517
                        $groupnotfound = true;
576
                        $groupnotfound = true;
518
                        continue;
577
                        continue;
519
                    }
578
                    }
520
                }
579
                }
521
            }
580
            }
522
            if (isset($group)) {
-
 
-
 
581
 
523
                if (isset($group[$packagetype])) {
582
            if (isset($group) && isset($group[$packagetype])) {
524
                    if (isset($group[$packagetype][0])) {
583
                if (isset($group[$packagetype][0])) {
525
                        foreach ($group[$packagetype] as $dep) {
584
                    foreach ($group[$packagetype] as $dep) {
526
                            $ret = $this->_detect2Dep($dep, $pname, 'dependency group "' .
585
                        $ret = $this->_detect2Dep($dep, $pname, 'dependency group "' .
527
                                $group['attribs']['name'] . '"', $params);
-
 
528
                            if (is_array($ret)) {
-
 
529
                                $this->_downloadDeps[] = $ret;
-
 
530
                            }
-
 
531
                        }
-
 
532
                    } else {
-
 
533
                        $ret = $this->_detect2Dep($group[$packagetype], $pname,
-
 
534
                            'dependency group "' .
-
 
535
                            $group['attribs']['name'] . '"', $params);
586
                            $group['attribs']['name'] . '"', $params);
536
                        if (is_array($ret)) {
587
                        if (is_array($ret)) {
537
                            $this->_downloadDeps[] = $ret;
588
                            $this->_downloadDeps[] = $ret;
-
 
589
                        } elseif (PEAR::isError($ret) && !isset($options['soft'])) {
-
 
590
                            $this->_downloader->log(0, $ret->getMessage());
538
                        }
591
                        }
539
                    }
592
                    }
-
 
593
                } else {
-
 
594
                    $ret = $this->_detect2Dep($group[$packagetype], $pname,
-
 
595
                        'dependency group "' .
-
 
596
                        $group['attribs']['name'] . '"', $params);
-
 
597
                    if (is_array($ret)) {
-
 
598
                        $this->_downloadDeps[] = $ret;
-
 
599
                    } elseif (PEAR::isError($ret) && !isset($options['soft'])) {
-
 
600
                        $this->_downloader->log(0, $ret->getMessage());
-
 
601
                    }
540
                }
602
                }
541
            }
603
            }
542
        }
604
        }
543
    }
605
    }
Line 544... Line 606...
544
 
606
 
545
    function _detect2Dep($dep, $pname, $group, $params)
607
    function _detect2Dep($dep, $pname, $group, $params)
546
    {
608
    {
547
        if (isset($dep['conflicts'])) {
609
        if (isset($dep['conflicts'])) {
548
            return true;
610
            return true;
-
 
611
        }
549
        }
612
 
550
        $options = $this->_downloader->getOptions();
613
        $options = $this->_downloader->getOptions();
551
        if (isset($dep['uri'])) {
614
        if (isset($dep['uri'])) {
552
            return array('uri' => $dep['uri'], 'dep' => $dep);;
615
            return array('uri' => $dep['uri'], 'dep' => $dep);;
-
 
616
        }
553
        }
617
 
554
        $testdep = $dep;
618
        $testdep = $dep;
555
        $testdep['package'] = $dep['name'];
619
        $testdep['package'] = $dep['name'];
556
        if (PEAR_Downloader_Package::willDownload($testdep, $params)) {
620
        if (PEAR_Downloader_Package::willDownload($testdep, $params)) {
557
            $dep['package'] = $dep['name'];
621
            $dep['package'] = $dep['name'];
Line 561... Line 625...
561
                    $this->_registry->parsedPackageNameToString($dep, true) .
625
                    $this->_registry->parsedPackageNameToString($dep, true) .
562
                    '", will be installed');
626
                    '", will be installed');
563
            }
627
            }
564
            return false;
628
            return false;
565
        }
629
        }
-
 
630
 
566
        $options = $this->_downloader->getOptions();
631
        $options = $this->_downloader->getOptions();
567
        PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
632
        PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
568
        if ($this->_explicitState) {
633
        if ($this->_explicitState) {
569
            $pname['state'] = $this->_explicitState;
634
            $pname['state'] = $this->_explicitState;
570
        }
635
        }
571
        $url =
636
 
572
            $this->_downloader->_getDepPackageDownloadUrl($dep, $pname);
637
        $url = $this->_downloader->_getDepPackageDownloadUrl($dep, $pname);
573
        if (PEAR::isError($url)) {
638
        if (PEAR::isError($url)) {
574
            PEAR::popErrorHandling();
639
            PEAR::popErrorHandling();
575
            return $url;
640
            return $url;
576
        }
641
        }
-
 
642
 
577
        $dep['package'] = $dep['name'];
643
        $dep['package'] = $dep['name'];
578
        $ret = $this->_analyzeDownloadURL($url, 'dependency', $dep, $params, $group == 'optional' &&
644
        $ret = $this->_analyzeDownloadURL($url, 'dependency', $dep, $params, $group == 'optional' &&
579
            !isset($options['alldeps']), true);
645
            !isset($options['alldeps']), true);
580
        PEAR::popErrorHandling();
646
        PEAR::popErrorHandling();
581
        if (PEAR::isError($ret)) {
647
        if (PEAR::isError($ret)) {
582
            if (!isset($options['soft'])) {
648
            if (!isset($options['soft'])) {
583
                $this->_downloader->log(0, $ret->getMessage());
649
                $this->_downloader->log(0, $ret->getMessage());
584
            }
650
            }
-
 
651
 
585
            return false;
652
            return false;
586
        } else {
653
        }
-
 
654
 
587
            // check to see if a dep is already installed and is the same or newer
655
        // check to see if a dep is already installed and is the same or newer
588
            if (!isset($dep['min']) && !isset($dep['max']) && !isset($dep['recommended'])) {
656
        if (!isset($dep['min']) && !isset($dep['max']) && !isset($dep['recommended'])) {
589
                $oper = 'has';
657
            $oper = 'has';
590
            } else {
658
        } else {
591
                $oper = 'gt';
659
            $oper = 'gt';
592
            }
660
        }
-
 
661
 
593
            // do not try to move this before getDepPackageDownloadURL
662
        // do not try to move this before getDepPackageDownloadURL
594
            // we can't determine whether upgrade is necessary until we know what
663
        // we can't determine whether upgrade is necessary until we know what
595
            // version would be downloaded
664
        // version would be downloaded
596
            if (!isset($options['force']) && $this->isInstalled($ret, $oper)) {
665
        if (!isset($options['force']) && $this->isInstalled($ret, $oper)) {
597
                $version = $this->_installRegistry->packageInfo($dep['name'], 'version',
666
            $version = $this->_installRegistry->packageInfo($dep['name'], 'version', $dep['channel']);
598
                    $dep['channel']);
-
 
599
                $dep['package'] = $dep['name'];
667
            $dep['package'] = $dep['name'];
600
                if (!isset($options['soft'])) {
668
            if (!isset($options['soft'])) {
601
                    $this->_downloader->log(3, $this->getShortName() . ': Skipping ' . $group .
669
                $this->_downloader->log(3, $this->getShortName() . ': Skipping ' . $group .
602
                        ' dependency "' .
670
                    ' dependency "' .
603
                    $this->_registry->parsedPackageNameToString($dep, true) .
671
                $this->_registry->parsedPackageNameToString($dep, true) .
604
                        '" version ' . $url['version'] . ', already installed as version ' .
672
                    '" version ' . $url['version'] . ', already installed as version ' .
605
                        $version);
673
                    $version);
606
                }
-
 
607
                return false;
-
 
608
            }
674
            }
-
 
675
 
-
 
676
            return false;
609
        }
677
        }
-
 
678
 
610
        if (isset($dep['nodefault'])) {
679
        if (isset($dep['nodefault'])) {
611
            $ret['nodefault'] = true;
680
            $ret['nodefault'] = true;
612
        }
681
        }
-
 
682
 
613
        return $ret;
683
        return $ret;
614
    }
684
    }
Line 615... Line 685...
615
 
685
 
616
    function _detect1($deps, $pname, $options, $params)
686
    function _detect1($deps, $pname, $options, $params)
617
    {
687
    {
618
        $this->_downloadDeps = array();
688
        $this->_downloadDeps = array();
619
        $skipnames = array();
689
        $skipnames = array();
620
        foreach ($deps as $dep) {
690
        foreach ($deps as $dep) {
621
            $nodownload = false;
691
            $nodownload = false;
622
            if ($dep['type'] == 'pkg') {
692
            if (isset ($dep['type']) && $dep['type'] === 'pkg') {
623
                $dep['channel'] = 'pear.php.net';
693
                $dep['channel'] = 'pear.php.net';
624
                $dep['package'] = $dep['name'];
694
                $dep['package'] = $dep['name'];
625
                switch ($dep['rel']) {
695
                switch ($dep['rel']) {
626
                    case 'not' :
696
                    case 'not' :
Line 649... Line 719...
649
                                $this->_registry->parsedPackageNameToString($dep, true) .
719
                                $this->_registry->parsedPackageNameToString($dep, true) .
650
                                '", is already installed');
720
                                '", is already installed');
651
                            continue 2;
721
                            continue 2;
652
                        }
722
                        }
653
                }
723
                }
-
 
724
 
654
                PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
725
                PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
655
                if ($this->_explicitState) {
726
                if ($this->_explicitState) {
656
                    $pname['state'] = $this->_explicitState;
727
                    $pname['state'] = $this->_explicitState;
657
                }
728
                }
658
                $url =
-
 
-
 
729
 
659
                    $this->_downloader->_getDepPackageDownloadUrl($dep, $pname);
730
                $url = $this->_downloader->_getDepPackageDownloadUrl($dep, $pname);
660
                $chan = 'pear.php.net';
731
                $chan = 'pear.php.net';
661
                if (PEAR::isError($url)) {
732
                if (PEAR::isError($url)) {
662
                    // check to see if this is a pecl package that has jumped
733
                    // check to see if this is a pecl package that has jumped
663
                    // from pear.php.net to pecl.php.net channel
734
                    // from pear.php.net to pecl.php.net channel
664
                    if (!class_exists('PEAR_Dependency2')) {
735
                    if (!class_exists('PEAR_Dependency2')) {
665
                        require_once 'PEAR/Dependency2.php';
736
                        require_once 'PEAR/Dependency2.php';
666
                    }
737
                    }
-
 
738
 
667
                    $newdep = PEAR_Dependency2::normalizeDep($dep);
739
                    $newdep = PEAR_Dependency2::normalizeDep($dep);
668
                    $newdep = $newdep[0];
740
                    $newdep = $newdep[0];
669
                    $newdep['channel'] = 'pecl.php.net';
741
                    $newdep['channel'] = 'pecl.php.net';
670
                    $chan = 'pecl.php.net';
742
                    $chan = 'pecl.php.net';
671
                    $url =
-
 
672
                        $this->_downloader->_getDepPackageDownloadUrl($newdep, $pname);
743
                    $url = $this->_downloader->_getDepPackageDownloadUrl($newdep, $pname);
673
                    $obj = &$this->_installRegistry->getPackage($dep['name']);
744
                    $obj = &$this->_installRegistry->getPackage($dep['name']);
674
                    if (PEAR::isError($url)) {
745
                    if (PEAR::isError($url)) {
675
                        PEAR::popErrorHandling();
746
                        PEAR::popErrorHandling();
676
                        if ($obj !== null && $this->isInstalled($obj, $dep['rel'])) {
747
                        if ($obj !== null && $this->isInstalled($obj, $dep['rel'])) {
677
                            $group = (!isset($dep['optional']) || $dep['optional'] == 'no') ?
748
                            $group = (!isset($dep['optional']) || $dep['optional'] == 'no') ?
Line 692... Line 763...
692
                            }
763
                            }
693
                            continue;
764
                            continue;
694
                        } else {
765
                        } else {
695
                            if (isset($dep['optional']) && $dep['optional'] == 'yes') {
766
                            if (isset($dep['optional']) && $dep['optional'] == 'yes') {
696
                                $this->_downloader->log(2, $this->getShortName() .
767
                                $this->_downloader->log(2, $this->getShortName() .
697
                                    ': Skipping ' . $group
-
 
698
                                    . ' dependency "' .
768
                                    ': Skipping optional dependency "' .
699
                                    $this->_registry->parsedPackageNameToString($dep, true) .
769
                                    $this->_registry->parsedPackageNameToString($dep, true) .
700
                                    '", no releases exist');
770
                                    '", no releases exist');
701
                                continue;
771
                                continue;
702
                            } else {
772
                            } else {
703
                                return $url;
773
                                return $url;
704
                            }
774
                            }
705
                        }
775
                        }
706
                    }
776
                    }
707
                }
777
                }
-
 
778
 
708
                PEAR::popErrorHandling();
779
                PEAR::popErrorHandling();
709
                if (!isset($options['alldeps'])) {
780
                if (!isset($options['alldeps'])) {
710
                    if (isset($dep['optional']) && $dep['optional'] == 'yes') {
781
                    if (isset($dep['optional']) && $dep['optional'] == 'yes') {
711
                        if (!isset($options['soft'])) {
782
                        if (!isset($options['soft'])) {
712
                            $this->_downloader->log(3, 'Notice: package "' .
783
                            $this->_downloader->log(3, 'Notice: package "' .
Line 721... Line 792...
721
                                array('channel' => $chan, 'package' =>
792
                                array('channel' => $chan, 'package' =>
722
                                $dep['name']), true);
793
                                $dep['name']), true);
723
                        $nodownload = true;
794
                        $nodownload = true;
724
                    }
795
                    }
725
                }
796
                }
-
 
797
 
726
                if (!isset($options['alldeps']) && !isset($options['onlyreqdeps'])) {
798
                if (!isset($options['alldeps']) && !isset($options['onlyreqdeps'])) {
727
                    if (!isset($dep['optional']) || $dep['optional'] == 'no') {
799
                    if (!isset($dep['optional']) || $dep['optional'] == 'no') {
728
                        if (!isset($options['soft'])) {
800
                        if (!isset($options['soft'])) {
729
                            $this->_downloader->log(3, 'Notice: package "' .
801
                            $this->_downloader->log(3, 'Notice: package "' .
730
                                $this->getShortName() .
802
                                $this->getShortName() .
Line 738... Line 810...
738
                                array('channel' => $chan, 'package' =>
810
                                array('channel' => $chan, 'package' =>
739
                                $dep['name']), true);
811
                                $dep['name']), true);
740
                        $nodownload = true;
812
                        $nodownload = true;
741
                    }
813
                    }
742
                }
814
                }
-
 
815
 
743
                // check to see if a dep is already installed
816
                // check to see if a dep is already installed
744
                // do not try to move this before getDepPackageDownloadURL
817
                // do not try to move this before getDepPackageDownloadURL
745
                // we can't determine whether upgrade is necessary until we know what
818
                // we can't determine whether upgrade is necessary until we know what
746
                // version would be downloaded
819
                // version would be downloaded
747
                if (!isset($options['force']) && $this->isInstalled(
820
                if (!isset($options['force']) && $this->isInstalled(
Line 749... Line 822...
749
                    $group = (!isset($dep['optional']) || $dep['optional'] == 'no') ?
822
                    $group = (!isset($dep['optional']) || $dep['optional'] == 'no') ?
750
                        'required' :
823
                        'required' :
751
                        'optional';
824
                        'optional';
752
                    $dep['package'] = $dep['name'];
825
                    $dep['package'] = $dep['name'];
753
                    if (isset($newdep)) {
826
                    if (isset($newdep)) {
754
                        $version = $this->_installRegistry->packageInfo($newdep['name'], 'version',
827
                        $version = $this->_installRegistry->packageInfo($newdep['name'], 'version', $newdep['channel']);
755
                            $newdep['channel']);
-
 
756
                    } else {
828
                    } else {
757
                        $version = $this->_installRegistry->packageInfo($dep['name'], 'version');
829
                        $version = $this->_installRegistry->packageInfo($dep['name'], 'version');
758
                    }
830
                    }
-
 
831
 
759
                    $dep['version'] = $url['version'];
832
                    $dep['version'] = $url['version'];
760
                    if (!isset($options['soft'])) {
833
                    if (!isset($options['soft'])) {
761
                        $this->_downloader->log(3, $this->getShortName() . ': Skipping ' . $group .
834
                        $this->_downloader->log(3, $this->getShortName() . ': Skipping ' . $group .
762
                            ' dependency "' .
835
                            ' dependency "' .
763
                            $this->_registry->parsedPackageNameToString($dep, true) .
836
                            $this->_registry->parsedPackageNameToString($dep, true) .
764
                            '", already installed as version ' . $version);
837
                            '", already installed as version ' . $version);
765
                    }
838
                    }
-
 
839
 
766
                    $skip = count($skipnames) ?
840
                    $skip = count($skipnames) ?
767
                        $skipnames[count($skipnames) - 1] : '';
841
                        $skipnames[count($skipnames) - 1] : '';
768
                    if ($skip ==
842
                    if ($skip ==
769
                          $this->_registry->parsedPackageNameToString($dep, true)) {
843
                          $this->_registry->parsedPackageNameToString($dep, true)) {
770
                        array_pop($skipnames);
844
                        array_pop($skipnames);
771
                    }
845
                    }
-
 
846
 
772
                    continue;
847
                    continue;
773
                }
848
                }
-
 
849
 
774
                if ($nodownload) {
850
                if ($nodownload) {
775
                    continue;
851
                    continue;
776
                }
852
                }
-
 
853
 
777
                PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
854
                PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
778
                if (isset($newdep)) {
855
                if (isset($newdep)) {
779
                    $dep = $newdep;
856
                    $dep = $newdep;
780
                }
857
                }
-
 
858
 
781
                $dep['package'] = $dep['name'];
859
                $dep['package'] = $dep['name'];
782
                $ret = $this->_analyzeDownloadURL($url, 'dependency', $dep, $params,
860
                $ret = $this->_analyzeDownloadURL($url, 'dependency', $dep, $params,
783
                    isset($dep['optional']) && $dep['optional'] == 'yes' &&
861
                    isset($dep['optional']) && $dep['optional'] == 'yes' &&
784
                    !isset($options['alldeps']), true);
862
                    !isset($options['alldeps']), true);
785
                PEAR::popErrorHandling();
863
                PEAR::popErrorHandling();
Line 787... Line 865...
787
                    if (!isset($options['soft'])) {
865
                    if (!isset($options['soft'])) {
788
                        $this->_downloader->log(0, $ret->getMessage());
866
                        $this->_downloader->log(0, $ret->getMessage());
789
                    }
867
                    }
790
                    continue;
868
                    continue;
791
                }
869
                }
-
 
870
 
792
                $this->_downloadDeps[] = $ret;
871
                $this->_downloadDeps[] = $ret;
793
            }
872
            }
794
        }
873
        }
-
 
874
 
795
        if (count($skipnames)) {
875
        if (count($skipnames)) {
796
            if (!isset($options['soft'])) {
876
            if (!isset($options['soft'])) {
797
                $this->_downloader->log(1, 'Did not download dependencies: ' .
877
                $this->_downloader->log(1, 'Did not download dependencies: ' .
798
                    implode(', ', $skipnames) .
878
                    implode(', ', $skipnames) .
799
                    ', use --alldeps or --onlyreqdeps to download automatically');
879
                    ', use --alldeps or --onlyreqdeps to download automatically');
Line 821... Line 901...
821
        return $this->_registry->parsedPackageNameToString(array('channel' => $this->getChannel(),
901
        return $this->_registry->parsedPackageNameToString(array('channel' => $this->getChannel(),
822
            'package' => $this->getPackage()), true);
902
            'package' => $this->getPackage()), true);
823
    }
903
    }
Line 824... Line 904...
824
 
904
 
825
    function getParsedPackage()
905
    function getParsedPackage()
826
    {   
906
    {
827
        if (isset($this->_packagefile) || isset($this->_parsedname)) {
907
        if (isset($this->_packagefile) || isset($this->_parsedname)) {
828
            return array('channel' => $this->getChannel(),
908
            return array('channel' => $this->getChannel(),
829
                'package' => $this->getPackage(),
909
                'package' => $this->getPackage(),
830
                'version' => $this->getVersion());
910
                'version' => $this->getVersion());
-
 
911
        }
831
        }
912
 
832
        return false;
913
        return false;
Line 833... Line 914...
833
    }
914
    }
834
 
915
 
835
    function getDownloadURL()
916
    function getDownloadURL()
836
    {
917
    {
Line 837... Line 918...
837
        return $this->_downloadURL;
918
        return $this->_downloadURL;
838
    }
919
    }
839
 
-
 
840
    function canDefault()
920
 
841
    {
921
    function canDefault()
842
        if (isset($this->_downloadURL)) {
-
 
843
            if (isset($this->_downloadURL['nodefault'])) {
922
    {
-
 
923
        if (isset($this->_downloadURL) && isset($this->_downloadURL['nodefault'])) {
844
                return false;
924
            return false;
845
            }
925
        }
Line 846... Line 926...
846
        }
926
 
847
        return true;
927
        return true;
848
    }
928
    }
849
 
929
 
850
    function getPackage()
930
    function getPackage()
851
    {
931
    {
852
        if (isset($this->_packagefile)) {
-
 
853
            return $this->_packagefile->getPackage();
-
 
854
        } elseif (isset($this->_downloadURL['info'])) {
932
        if (isset($this->_packagefile)) {
-
 
933
            return $this->_packagefile->getPackage();
-
 
934
        } elseif (isset($this->_downloadURL['info'])) {
855
            return $this->_downloadURL['info']->getPackage();
935
            return $this->_downloadURL['info']->getPackage();
Line 856... Line 936...
856
        } else {
936
        }
857
            return false;
937
 
858
        }
938
        return false;
Line 865... Line 945...
865
    {
945
    {
866
        if (isset($this->_packagefile)) {
946
        if (isset($this->_packagefile)) {
867
            return $this->_packagefile->isSubpackage($pf);
947
            return $this->_packagefile->isSubpackage($pf);
868
        } elseif (isset($this->_downloadURL['info'])) {
948
        } elseif (isset($this->_downloadURL['info'])) {
869
            return $this->_downloadURL['info']->isSubpackage($pf);
949
            return $this->_downloadURL['info']->isSubpackage($pf);
870
        } else {
-
 
871
            return false;
-
 
872
        }
950
        }
-
 
951
 
-
 
952
        return false;
873
    }
953
    }
Line 874... Line 954...
874
 
954
 
875
    function getPackageType()
955
    function getPackageType()
876
    {
956
    {
877
        if (isset($this->_packagefile)) {
957
        if (isset($this->_packagefile)) {
878
            return $this->_packagefile->getPackageType();
958
            return $this->_packagefile->getPackageType();
879
        } elseif (isset($this->_downloadURL['info'])) {
959
        } elseif (isset($this->_downloadURL['info'])) {
880
            return $this->_downloadURL['info']->getPackageType();
-
 
881
        } else {
-
 
882
            return false;
960
            return $this->_downloadURL['info']->getPackageType();
-
 
961
        }
-
 
962
 
883
        }
963
        return false;
Line 884... Line 964...
884
    }
964
    }
885
 
965
 
886
    function isBundle()
966
    function isBundle()
887
    {
967
    {
888
        if (isset($this->_packagefile)) {
-
 
889
            return $this->_packagefile->getPackageType() == 'bundle';
-
 
890
        } else {
968
        if (isset($this->_packagefile)) {
-
 
969
            return $this->_packagefile->getPackageType() == 'bundle';
-
 
970
        }
891
            return false;
971
 
Line 892... Line 972...
892
        }
972
        return false;
893
    }
973
    }
894
 
974
 
895
    function getPackageXmlVersion()
975
    function getPackageXmlVersion()
896
    {
976
    {
897
        if (isset($this->_packagefile)) {
977
        if (isset($this->_packagefile)) {
898
            return $this->_packagefile->getPackagexmlVersion();
-
 
899
        } elseif (isset($this->_downloadURL['info'])) {
-
 
900
            return $this->_downloadURL['info']->getPackagexmlVersion();
978
            return $this->_packagefile->getPackagexmlVersion();
-
 
979
        } elseif (isset($this->_downloadURL['info'])) {
-
 
980
            return $this->_downloadURL['info']->getPackagexmlVersion();
901
        } else {
981
        }
Line 902... Line 982...
902
            return '1.0';
982
 
903
        }
983
        return '1.0';
904
    }
984
    }
905
 
985
 
906
    function getChannel()
986
    function getChannel()
907
    {
987
    {
908
        if (isset($this->_packagefile)) {
-
 
909
            return $this->_packagefile->getChannel();
-
 
910
        } elseif (isset($this->_downloadURL['info'])) {
988
        if (isset($this->_packagefile)) {
-
 
989
            return $this->_packagefile->getChannel();
-
 
990
        } elseif (isset($this->_downloadURL['info'])) {
911
            return $this->_downloadURL['info']->getChannel();
991
            return $this->_downloadURL['info']->getChannel();
Line 912... Line 992...
912
        } else {
992
        }
913
            return false;
993
 
914
        }
994
        return false;
915
    }
995
    }
916
 
996
 
917
    function getURI()
997
    function getURI()
918
    {
-
 
919
        if (isset($this->_packagefile)) {
-
 
920
            return $this->_packagefile->getURI();
998
    {
-
 
999
        if (isset($this->_packagefile)) {
-
 
1000
            return $this->_packagefile->getURI();
921
        } elseif (isset($this->_downloadURL['info'])) {
1001
        } elseif (isset($this->_downloadURL['info'])) {
Line 922... Line 1002...
922
            return $this->_downloadURL['info']->getURI();
1002
            return $this->_downloadURL['info']->getURI();
923
        } else {
1003
        }
924
            return false;
1004
 
925
        }
1005
        return false;
926
    }
1006
    }
927
 
1007
 
928
    function getVersion()
-
 
929
    {
-
 
930
        if (isset($this->_packagefile)) {
1008
    function getVersion()
-
 
1009
    {
-
 
1010
        if (isset($this->_packagefile)) {
931
            return $this->_packagefile->getVersion();
1011
            return $this->_packagefile->getVersion();
Line 932... Line 1012...
932
        } elseif (isset($this->_downloadURL['version'])) {
1012
        } elseif (isset($this->_downloadURL['version'])) {
933
            return $this->_downloadURL['version'];
1013
            return $this->_downloadURL['version'];
934
        } else {
1014
        }
935
            return false;
1015
 
936
        }
1016
        return false;
937
    }
1017
    }
938
 
-
 
939
    function isCompatible($pf)
-
 
940
    {
1018
 
-
 
1019
    function isCompatible($pf)
-
 
1020
    {
941
        if (isset($this->_packagefile)) {
1021
        if (isset($this->_packagefile)) {
Line 942... Line 1022...
942
            return $this->_packagefile->isCompatible($pf);
1022
            return $this->_packagefile->isCompatible($pf);
943
        } elseif (isset($this->_downloadURL['info'])) {
1023
        } elseif (isset($this->_downloadURL['info'])) {
944
            return $this->_downloadURL['info']->isCompatible($pf);
1024
            return $this->_downloadURL['info']->isCompatible($pf);
Line 954... Line 1034...
954
 
1034
 
955
    function getGroup()
1035
    function getGroup()
956
    {
1036
    {
957
        if (isset($this->_parsedname['group'])) {
1037
        if (isset($this->_parsedname['group'])) {
958
            return $this->_parsedname['group'];
-
 
959
        } else {
-
 
960
            return '';
1038
            return $this->_parsedname['group'];
-
 
1039
        }
-
 
1040
 
961
        }
1041
        return '';
Line 962... Line 1042...
962
    }
1042
    }
963
 
1043
 
964
    function isExtension($name)
1044
    function isExtension($name)
965
    {
1045
    {
966
        if (isset($this->_packagefile)) {
1046
        if (isset($this->_packagefile)) {
967
            return $this->_packagefile->isExtension($name);
1047
            return $this->_packagefile->isExtension($name);
968
        } elseif (isset($this->_downloadURL['info'])) {
1048
        } elseif (isset($this->_downloadURL['info'])) {
969
			if ($this->_downloadURL['info']->getPackagexmlVersion() == '2.0') {
1049
            if ($this->_downloadURL['info']->getPackagexmlVersion() == '2.0') {
970
				return $this->_downloadURL['info']->getProvidesExtension() == $name;
-
 
971
			} else {
1050
                return $this->_downloadURL['info']->getProvidesExtension() == $name;
972
				return false;
-
 
973
			}
1051
            }
974
        } else {
1052
 
-
 
1053
            return false;
-
 
1054
        }
975
            return false;
1055
 
Line 976... Line 1056...
976
        }
1056
        return false;
977
    }
1057
    }
978
 
1058
 
979
    function getDeps()
1059
    function getDeps()
980
    {
1060
    {
981
        if (isset($this->_packagefile)) {
1061
        if (isset($this->_packagefile)) {
982
            $ver = $this->_packagefile->getPackagexmlVersion();
-
 
983
            if (version_compare($ver, '2.0', '>=')) {
-
 
984
                return $this->_packagefile->getDeps(true);
1062
            $ver = $this->_packagefile->getPackagexmlVersion();
-
 
1063
            if (version_compare($ver, '2.0', '>=')) {
-
 
1064
                return $this->_packagefile->getDeps(true);
985
            } else {
1065
            }
986
                return $this->_packagefile->getDeps();
1066
 
987
            }
1067
            return $this->_packagefile->getDeps();
988
        } elseif (isset($this->_downloadURL['info'])) {
1068
        } elseif (isset($this->_downloadURL['info'])) {
989
            $ver = $this->_downloadURL['info']->getPackagexmlVersion();
-
 
990
            if (version_compare($ver, '2.0', '>=')) {
-
 
991
                return $this->_downloadURL['info']->getDeps(true);
1069
            $ver = $this->_downloadURL['info']->getPackagexmlVersion();
992
            } else {
-
 
-
 
1070
            if (version_compare($ver, '2.0', '>=')) {
993
                return $this->_downloadURL['info']->getDeps();
1071
                return $this->_downloadURL['info']->getDeps(true);
994
            }
1072
            }
-
 
1073
 
-
 
1074
            return $this->_downloadURL['info']->getDeps();
995
        } else {
1075
        }
Line 996... Line 1076...
996
            return array();
1076
 
997
        }
1077
        return array();
998
    }
1078
    }
Line 1025... Line 1105...
1025
                if ($this->getChannel() != '__uri') {
1105
                if ($this->getChannel() != '__uri') {
1026
                    return false;
1106
                    return false;
1027
                }
1107
                }
1028
                return $param['uri'] == $this->getURI();
1108
                return $param['uri'] == $this->getURI();
1029
            }
1109
            }
-
 
1110
 
1030
            $package = isset($param['package']) ? $param['package'] :
1111
            $package = isset($param['package']) ? $param['package'] : $param['info']->getPackage();
1031
                $param['info']->getPackage();
-
 
1032
            $channel = isset($param['channel']) ? $param['channel'] :
1112
            $channel = isset($param['channel']) ? $param['channel'] : $param['info']->getChannel();
1033
                $param['info']->getChannel();
-
 
1034
            if (isset($param['rel'])) {
1113
            if (isset($param['rel'])) {
1035
                if (!class_exists('PEAR_Dependency2')) {
1114
                if (!class_exists('PEAR_Dependency2')) {
1036
                    require_once 'PEAR/Dependency2.php';
1115
                    require_once 'PEAR/Dependency2.php';
1037
                }
1116
                }
-
 
1117
 
1038
                $newdep = PEAR_Dependency2::normalizeDep($param);
1118
                $newdep = PEAR_Dependency2::normalizeDep($param);
1039
                $newdep = $newdep[0];
1119
                $newdep = $newdep[0];
1040
            } elseif (isset($param['min'])) {
1120
            } elseif (isset($param['min'])) {
1041
                $newdep = $param;
1121
                $newdep = $param;
1042
            }
1122
            }
1043
        }
1123
        }
-
 
1124
 
1044
        if (isset($newdep)) {
1125
        if (isset($newdep)) {
1045
            if (!isset($newdep['min'])) {
1126
            if (!isset($newdep['min'])) {
1046
                $newdep['min'] = '0';
1127
                $newdep['min'] = '0';
1047
            }
1128
            }
-
 
1129
 
1048
            if (!isset($newdep['max'])) {
1130
            if (!isset($newdep['max'])) {
1049
                $newdep['max'] = '100000000000000000000';
1131
                $newdep['max'] = '100000000000000000000';
1050
            }
1132
            }
-
 
1133
 
1051
            // use magic to support pecl packages suddenly jumping to the pecl channel
1134
            // use magic to support pecl packages suddenly jumping to the pecl channel
1052
            // we need to support both dependency possibilities
1135
            // we need to support both dependency possibilities
1053
            if ($channel == 'pear.php.net' && $this->getChannel() == 'pecl.php.net') {
1136
            if ($channel == 'pear.php.net' && $this->getChannel() == 'pecl.php.net') {
1054
                if ($package == $this->getPackage()) {
1137
                if ($package == $this->getPackage()) {
1055
                    $channel = 'pecl.php.net';
1138
                    $channel = 'pecl.php.net';
Line 1058... Line 1141...
1058
            if ($channel == 'pecl.php.net' && $this->getChannel() == 'pear.php.net') {
1141
            if ($channel == 'pecl.php.net' && $this->getChannel() == 'pear.php.net') {
1059
                if ($package == $this->getPackage()) {
1142
                if ($package == $this->getPackage()) {
1060
                    $channel = 'pear.php.net';
1143
                    $channel = 'pear.php.net';
1061
                }
1144
                }
1062
            }
1145
            }
-
 
1146
 
1063
            return (strtolower($package) == strtolower($this->getPackage()) &&
1147
            return (strtolower($package) == strtolower($this->getPackage()) &&
1064
                $channel == $this->getChannel() &&
1148
                $channel == $this->getChannel() &&
1065
                version_compare($newdep['min'], $this->getVersion(), '<=') &&
1149
                version_compare($newdep['min'], $this->getVersion(), '<=') &&
1066
                version_compare($newdep['max'], $this->getVersion(), '>='));
1150
                version_compare($newdep['max'], $this->getVersion(), '>='));
1067
        }
1151
        }
-
 
1152
 
1068
        // use magic to support pecl packages suddenly jumping to the pecl channel
1153
        // use magic to support pecl packages suddenly jumping to the pecl channel
1069
        if ($channel == 'pecl.php.net' && $this->getChannel() == 'pear.php.net') {
1154
        if ($channel == 'pecl.php.net' && $this->getChannel() == 'pear.php.net') {
1070
            if (strtolower($package) == strtolower($this->getPackage())) {
1155
            if (strtolower($package) == strtolower($this->getPackage())) {
1071
                $channel = 'pear.php.net';
1156
                $channel = 'pear.php.net';
1072
            }
1157
            }
1073
        }
1158
        }
-
 
1159
 
1074
        if (isset($param['version'])) {
1160
        if (isset($param['version'])) {
1075
            return (strtolower($package) == strtolower($this->getPackage()) &&
1161
            return (strtolower($package) == strtolower($this->getPackage()) &&
1076
                $channel == $this->getChannel() &&
1162
                $channel == $this->getChannel() &&
1077
                $param['version'] == $this->getVersion());
1163
                $param['version'] == $this->getVersion());
1078
        } else {
-
 
1079
            return strtolower($package) == strtolower($this->getPackage()) &&
-
 
1080
                $channel == $this->getChannel();
-
 
1081
        }
1164
        }
-
 
1165
 
-
 
1166
        return strtolower($package) == strtolower($this->getPackage()) &&
-
 
1167
            $channel == $this->getChannel();
1082
    }
1168
    }
Line 1083... Line 1169...
1083
 
1169
 
1084
    function isInstalled($dep, $oper = '==')
1170
    function isInstalled($dep, $oper = '==')
1085
    {
1171
    {
1086
        if (!$dep) {
1172
        if (!$dep) {
1087
            return false;
1173
            return false;
-
 
1174
        }
1088
        }
1175
 
1089
        if ($oper != 'ge' && $oper != 'gt' && $oper != 'has' && $oper != '==') {
1176
        if ($oper != 'ge' && $oper != 'gt' && $oper != 'has' && $oper != '==') {
1090
            return false;
1177
            return false;
-
 
1178
        }
1091
        }
1179
 
1092
        if (is_object($dep)) {
1180
        if (is_object($dep)) {
1093
            $package = $dep->getPackage();
1181
            $package = $dep->getPackage();
1094
            $channel = $dep->getChannel();
1182
            $channel = $dep->getChannel();
1095
            if ($dep->getURI()) {
1183
            if ($dep->getURI()) {
Line 1109... Line 1197...
1109
            } else {
1197
            } else {
1110
                $channel = $dep['info']->getChannel();
1198
                $channel = $dep['info']->getChannel();
1111
                $package = $dep['info']->getPackage();
1199
                $package = $dep['info']->getPackage();
1112
            }
1200
            }
1113
        }
1201
        }
-
 
1202
 
1114
        $options = $this->_downloader->getOptions();
1203
        $options = $this->_downloader->getOptions();
1115
        $test = $this->_installRegistry->packageExists($package, $channel);
1204
        $test    = $this->_installRegistry->packageExists($package, $channel);
1116
        if (!$test && $channel == 'pecl.php.net') {
1205
        if (!$test && $channel == 'pecl.php.net') {
1117
            // do magic to allow upgrading from old pecl packages to new ones
1206
            // do magic to allow upgrading from old pecl packages to new ones
1118
            $test = $this->_installRegistry->packageExists($package, 'pear.php.net');
1207
            $test = $this->_installRegistry->packageExists($package, 'pear.php.net');
1119
            $channel = 'pear.php.net';
1208
            $channel = 'pear.php.net';
1120
        }
1209
        }
-
 
1210
 
1121
        if ($test) {
1211
        if ($test) {
1122
            if (isset($dep['uri'])) {
1212
            if (isset($dep['uri'])) {
1123
                if ($this->_installRegistry->packageInfo($package, 'uri', '__uri') == $dep['uri']) {
1213
                if ($this->_installRegistry->packageInfo($package, 'uri', '__uri') == $dep['uri']) {
1124
                    return true;
1214
                    return true;
1125
                }
1215
                }
1126
            }
1216
            }
-
 
1217
 
1127
            if (isset($options['upgrade'])) {
1218
            if (isset($options['upgrade'])) {
1128
                if ($oper == 'has') {
-
 
1129
                    if (version_compare($this->_installRegistry->packageInfo(
1219
                $packageVersion = $this->_installRegistry->packageInfo($package, 'version', $channel);
1130
                          $package, 'version', $channel),
-
 
1131
                          $dep['version'], '>=')) {
-
 
1132
                        return true;
-
 
1133
                    } else {
-
 
1134
                        return false;
-
 
1135
                    }
-
 
1136
                } else {
-
 
1137
                    if (version_compare($this->_installRegistry->packageInfo(
-
 
1138
                          $package, 'version', $channel),
-
 
1139
                          $dep['version'], '>=')) {
1220
                if (version_compare($packageVersion, $dep['version'], '>=')) {
1140
                        return true;
1221
                    return true;
1141
                    }
-
 
1142
                    return false;
-
 
1143
                }
1222
                }
-
 
1223
 
-
 
1224
                return false;
1144
            }
1225
            }
-
 
1226
 
1145
            return true;
1227
            return true;
1146
        }
1228
        }
-
 
1229
 
1147
        return false;
1230
        return false;
1148
    }
1231
    }
Line 1149... Line 1232...
1149
 
1232
 
-
 
1233
    /**
-
 
1234
     * Detect duplicate package names with differing versions
-
 
1235
     *
-
 
1236
     * If a user requests to install Date 1.4.6 and Date 1.4.7,
-
 
1237
     * for instance, this is a logic error.  This method
-
 
1238
     * detects this situation.
-
 
1239
     *
-
 
1240
     * @param array $params array of PEAR_Downloader_Package objects
-
 
1241
     * @param array $errorparams empty array
-
 
1242
     * @return array array of stupid duplicated packages in PEAR_Downloader_Package obejcts
-
 
1243
     */
-
 
1244
    public static function detectStupidDuplicates($params, &$errorparams)
-
 
1245
    {
-
 
1246
        $existing = array();
-
 
1247
        foreach ($params as $i => $param) {
-
 
1248
            $package = $param->getPackage();
-
 
1249
            $channel = $param->getChannel();
-
 
1250
            $group   = $param->getGroup();
-
 
1251
            if (!isset($existing[$channel . '/' . $package])) {
-
 
1252
                $existing[$channel . '/' . $package] = array();
-
 
1253
            }
-
 
1254
 
-
 
1255
            if (!isset($existing[$channel . '/' . $package][$group])) {
-
 
1256
                $existing[$channel . '/' . $package][$group] = array();
-
 
1257
            }
-
 
1258
 
-
 
1259
            $existing[$channel . '/' . $package][$group][] = $i;
-
 
1260
        }
-
 
1261
 
-
 
1262
        $indices = array();
-
 
1263
        foreach ($existing as $package => $groups) {
-
 
1264
            foreach ($groups as $group => $dupes) {
-
 
1265
                if (count($dupes) > 1) {
-
 
1266
                    $indices = $indices + $dupes;
-
 
1267
                }
-
 
1268
            }
-
 
1269
        }
-
 
1270
 
-
 
1271
        $indices = array_unique($indices);
-
 
1272
        foreach ($indices as $index) {
-
 
1273
            $errorparams[] = $params[$index];
-
 
1274
        }
-
 
1275
 
-
 
1276
        return count($errorparams);
-
 
1277
    }
-
 
1278
 
1150
    /**
1279
    /**
1151
     * @param array
1280
     * @param array
1152
     * @param bool ignore install groups - for final removal of dupe packages
-
 
1153
     * @static
1281
     * @param bool ignore install groups - for final removal of dupe packages
1154
     */
1282
     */
1155
    function removeDuplicates(&$params, $ignoreGroups = false)
1283
    public static function removeDuplicates(&$params, $ignoreGroups = false)
1156
    {
1284
    {
1157
        $pnames = array();
1285
        $pnames = array();
1158
        foreach ($params as $i => $param) {
1286
        foreach ($params as $i => $param) {
1159
            if (!$param) {
1287
            if (!$param) {
1160
                continue;
1288
                continue;
-
 
1289
            }
1161
            }
1290
 
1162
            if ($param->getPackage()) {
-
 
1163
                if ($ignoreGroups) {
-
 
1164
                    $group = '';
-
 
1165
                } else {
1291
            if ($param->getPackage()) {
1166
                    $group = $param->getGroup();
-
 
1167
                }
1292
                $group = $ignoreGroups ? '' : $param->getGroup();
1168
                $pnames[$i] = $param->getChannel() . '/' .
1293
                $pnames[$i] = $param->getChannel() . '/' .
1169
                    $param->getPackage() . '-' . $param->getVersion() . '#' . $group;
1294
                    $param->getPackage() . '-' . $param->getVersion() . '#' . $group;
1170
            }
1295
            }
-
 
1296
        }
1171
        }
1297
 
1172
        $pnames = array_unique($pnames);
1298
        $pnames = array_unique($pnames);
1173
        $unset = array_diff(array_keys($params), array_keys($pnames));
1299
        $unset  = array_diff(array_keys($params), array_keys($pnames));
1174
        $testp = array_flip($pnames);
1300
        $testp  = array_flip($pnames);
1175
        foreach ($params as $i => $param) {
1301
        foreach ($params as $i => $param) {
1176
            if (!$param) {
1302
            if (!$param) {
1177
                $unset[] = $i;
1303
                $unset[] = $i;
1178
                continue;
1304
                continue;
-
 
1305
            }
1179
            }
1306
 
1180
            if (!is_a($param, 'PEAR_Downloader_Package')) {
1307
            if (!is_a($param, 'PEAR_Downloader_Package')) {
1181
                $unset[] = $i;
1308
                $unset[] = $i;
1182
                continue;
1309
                continue;
1183
            }
-
 
1184
            if ($ignoreGroups) {
-
 
1185
                $group = '';
-
 
-
 
1310
            }
1186
            } else {
1311
 
1187
                $group = $param->getGroup();
-
 
1188
            }
1312
            $group = $ignoreGroups ? '' : $param->getGroup();
1189
            if (!isset($testp[$param->getChannel() . '/' . $param->getPackage() . '-' .
1313
            if (!isset($testp[$param->getChannel() . '/' . $param->getPackage() . '-' .
1190
                  $param->getVersion() . '#' . $group])) {
1314
                  $param->getVersion() . '#' . $group])) {
1191
                $unset[] = $i;
1315
                $unset[] = $i;
1192
            }
1316
            }
-
 
1317
        }
1193
        }
1318
 
1194
        foreach ($unset as $i) {
1319
        foreach ($unset as $i) {
1195
            unset($params[$i]);
1320
            unset($params[$i]);
-
 
1321
        }
1196
        }
1322
 
1197
        $ret = array();
1323
        $ret = array();
1198
        foreach ($params as $i => $param) {
1324
        foreach ($params as $i => $param) {
1199
            $ret[] = &$params[$i];
1325
            $ret[] = &$params[$i];
-
 
1326
        }
1200
        }
1327
 
1201
        $params = array();
1328
        $params = array();
1202
        foreach ($ret as $i => $param) {
1329
        foreach ($ret as $i => $param) {
1203
            $params[] = &$ret[$i];
1330
            $params[] = &$ret[$i];
1204
        }
1331
        }
Line 1213... Line 1340...
1213
    {
1340
    {
1214
        $this->_explicitState = $s;
1341
        $this->_explicitState = $s;
1215
    }
1342
    }
Line 1216... Line 1343...
1216
 
1343
 
1217
    /**
-
 
1218
     * @static
1344
    /**
1219
     */
1345
     */
1220
    function mergeDependencies(&$params)
1346
    public static function mergeDependencies(&$params)
1221
    {
1347
    {
1222
        $newparams = array();
-
 
1223
        $bundles = array();
1348
        $bundles = $newparams = array();
1224
        foreach ($params as $i => $param) {
1349
        foreach ($params as $i => $param) {
1225
            if (!$param->isBundle()) {
1350
            if (!$param->isBundle()) {
1226
                continue;
1351
                continue;
-
 
1352
            }
1227
            }
1353
 
1228
            $bundles[] = $i;
1354
            $bundles[] = $i;
1229
            $pf = &$param->getPackageFile();
1355
            $pf = &$param->getPackageFile();
1230
            $newdeps = array();
1356
            $newdeps = array();
1231
            $contents = $pf->getBundledPackages();
1357
            $contents = $pf->getBundledPackages();
1232
            if (!is_array($contents)) {
1358
            if (!is_array($contents)) {
1233
                $contents = array($contents);
1359
                $contents = array($contents);
-
 
1360
            }
1234
            }
1361
 
1235
            foreach ($contents as $file) {
1362
            foreach ($contents as $file) {
1236
                $filecontents = $pf->getFileContents($file);
1363
                $filecontents = $pf->getFileContents($file);
1237
                $dl = &$param->getDownloader();
1364
                $dl = &$param->getDownloader();
1238
                $options = $dl->getOptions();
1365
                $options = $dl->getOptions();
1239
                if (PEAR::isError($dir = $dl->getDownloadDir())) {
1366
                if (PEAR::isError($dir = $dl->getDownloadDir())) {
1240
                    return $dir;
1367
                    return $dir;
-
 
1368
                }
1241
                }
1369
 
1242
                $fp = @fopen($dir . DIRECTORY_SEPARATOR . $file, 'wb');
1370
                $fp = @fopen($dir . DIRECTORY_SEPARATOR . $file, 'wb');
1243
                if (!$fp) {
1371
                if (!$fp) {
1244
                    continue;
1372
                    continue;
-
 
1373
                }
-
 
1374
 
-
 
1375
                // FIXME do symlink check
1245
                }
1376
 
1246
                fwrite($fp, $filecontents, strlen($filecontents));
1377
                fwrite($fp, $filecontents, strlen($filecontents));
1247
                fclose($fp);
1378
                fclose($fp);
1248
                if ($s = $params[$i]->explicitState()) {
1379
                if ($s = $params[$i]->explicitState()) {
1249
                    $obj->setExplicitState($s);
1380
                    $obj->setExplicitState($s);
-
 
1381
                }
1250
                }
1382
 
1251
                $obj = &new PEAR_Downloader_Package($params[$i]->getDownloader());
1383
                $obj = new PEAR_Downloader_Package($params[$i]->getDownloader());
1252
                PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
1384
                PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
1253
                if (PEAR::isError($dir = $dl->getDownloadDir())) {
1385
                if (PEAR::isError($dir = $dl->getDownloadDir())) {
1254
                    PEAR::popErrorHandling();
1386
                    PEAR::popErrorHandling();
1255
                    return $dir;
1387
                    return $dir;
1256
                }
1388
                }
-
 
1389
                $a = $dir . DIRECTORY_SEPARATOR . $file;
1257
                $e = $obj->_fromFile($a = $dir . DIRECTORY_SEPARATOR . $file);
1390
                $e = $obj->_fromFile($a);
1258
                PEAR::popErrorHandling();
1391
                PEAR::popErrorHandling();
1259
                if (PEAR::isError($e)) {
1392
                if (PEAR::isError($e)) {
1260
                    if (!isset($options['soft'])) {
1393
                    if (!isset($options['soft'])) {
1261
                        $dl->log(0, $e->getMessage());
1394
                        $dl->log(0, $e->getMessage());
1262
                    }
1395
                    }
1263
                    continue;
1396
                    continue;
1264
                }
-
 
-
 
1397
                }
1265
                $j = &$obj;
1398
 
1266
                if (!PEAR_Downloader_Package::willDownload($j,
1399
                if (!PEAR_Downloader_Package::willDownload($obj,
1267
                      array_merge($params, $newparams)) && !$param->isInstalled($j)) {
1400
                      array_merge($params, $newparams)) && !$param->isInstalled($obj)) {
1268
                    $newparams[] = &$j;
1401
                    $newparams[] = $obj;
1269
                }
1402
                }
1270
            }
1403
            }
-
 
1404
        }
1271
        }
1405
 
1272
        foreach ($bundles as $i) {
1406
        foreach ($bundles as $i) {
1273
            unset($params[$i]); // remove bundles - only their contents matter for installation
1407
            unset($params[$i]); // remove bundles - only their contents matter for installation
-
 
1408
        }
1274
        }
1409
 
1275
        PEAR_Downloader_Package::removeDuplicates($params); // strip any unset indices
1410
        PEAR_Downloader_Package::removeDuplicates($params); // strip any unset indices
1276
        if (count($newparams)) { // add in bundled packages for install
1411
        if (count($newparams)) { // add in bundled packages for install
1277
            foreach ($newparams as $i => $unused) {
1412
            foreach ($newparams as $i => $unused) {
1278
                $params[] = &$newparams[$i];
1413
                $params[] = &$newparams[$i];
1279
            }
1414
            }
1280
            $newparams = array();
1415
            $newparams = array();
-
 
1416
        }
1281
        }
1417
 
1282
        foreach ($params as $i => $param) {
1418
        foreach ($params as $i => $param) {
1283
            $newdeps = array();
1419
            $newdeps = array();
-
 
1420
            foreach ($param->_downloadDeps as $dep) {
1284
            foreach ($param->_downloadDeps as $dep) {
1421
                $merge = array_merge($params, $newparams);
1285
                if (!PEAR_Downloader_Package::willDownload($dep,
1422
                if (!PEAR_Downloader_Package::willDownload($dep, $merge)
-
 
1423
                    && !$param->isInstalled($dep)
1286
                      array_merge($params, $newparams)) && !$param->isInstalled($dep)) {
1424
                ) {
1287
                    $newdeps[] = $dep;
1425
                    $newdeps[] = $dep;
-
 
1426
                } else {
1288
                } else {
1427
                    //var_dump($dep);
1289
                    // detect versioning conflicts here
1428
                    // detect versioning conflicts here
1290
                }
1429
                }
-
 
1430
            }
1291
            }
1431
 
1292
            // convert the dependencies into PEAR_Downloader_Package objects for the next time
-
 
1293
            // around
1432
            // convert the dependencies into PEAR_Downloader_Package objects for the next time around
1294
            $params[$i]->_downloadDeps = array();
1433
            $params[$i]->_downloadDeps = array();
1295
            foreach ($newdeps as $dep) {
1434
            foreach ($newdeps as $dep) {
1296
                $obj = &new PEAR_Downloader_Package($params[$i]->getDownloader());
1435
                $obj = new PEAR_Downloader_Package($params[$i]->getDownloader());
1297
                if ($s = $params[$i]->explicitState()) {
1436
                if ($s = $params[$i]->explicitState()) {
1298
                    $obj->setExplicitState($s);
1437
                    $obj->setExplicitState($s);
-
 
1438
                }
1299
                }
1439
 
1300
                PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
1440
                PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
1301
                $e = $obj->fromDepURL($dep);
1441
                $e = $obj->fromDepURL($dep);
1302
                PEAR::popErrorHandling();
1442
                PEAR::popErrorHandling();
1303
                if (PEAR::isError($e)) {
1443
                if (PEAR::isError($e)) {
1304
                    if (!isset($options['soft'])) {
1444
                    if (!isset($options['soft'])) {
1305
                        $obj->_downloader->log(0, $e->getMessage());
1445
                        $obj->_downloader->log(0, $e->getMessage());
1306
                    }
1446
                    }
1307
                    continue;
1447
                    continue;
-
 
1448
                }
1308
                }
1449
 
1309
                $e = $obj->detectDependencies($params);
1450
                $e = $obj->detectDependencies($params);
1310
                if (PEAR::isError($e)) {
1451
                if (PEAR::isError($e)) {
1311
                    if (!isset($options['soft'])) {
1452
                    if (!isset($options['soft'])) {
1312
                        $obj->_downloader->log(0, $e->getMessage());
1453
                        $obj->_downloader->log(0, $e->getMessage());
1313
                    }
1454
                    }
1314
                }
-
 
-
 
1455
                }
1315
                $j = &$obj;
1456
 
1316
                $newparams[] = &$j;
1457
                $newparams[] = $obj;
1317
            }
1458
            }
-
 
1459
        }
1318
        }
1460
 
1319
        if (count($newparams)) {
1461
        if (count($newparams)) {
1320
            foreach ($newparams as $i => $unused) {
1462
            foreach ($newparams as $i => $unused) {
1321
                $params[] = &$newparams[$i];
1463
                $params[] = &$newparams[$i];
1322
            }
1464
            }
1323
            return true;
-
 
1324
        } else {
-
 
1325
            return false;
1465
            return true;
-
 
1466
        }
-
 
1467
 
1326
        }
1468
        return false;
Line 1327... Line 1469...
1327
    }
1469
    }
1328
 
-
 
1329
 
1470
 
1330
    /**
1471
 
1331
     * @static
1472
    /**
1332
     */
1473
     */
1333
    function willDownload($param, $params)
1474
    public static function willDownload($param, $params)
1334
    {
1475
    {
-
 
1476
        if (!is_array($params)) {
1335
        if (!is_array($params)) {
1477
            return false;
1336
            return false;
1478
        }
1337
        }
1479
 
1338
        foreach ($params as $obj) {
1480
        foreach ($params as $obj) {
1339
            if ($obj->isEqual($param)) {
1481
            if ($obj->isEqual($param)) {
-
 
1482
                return true;
1340
                return true;
1483
            }
1341
            }
1484
        }
Line 1342... Line 1485...
1342
        }
1485
 
1343
        return false;
1486
        return false;
1344
    }
1487
    }
1345
 
1488
 
1346
    /**
1489
    /**
1347
     * For simpler unit-testing
1490
     * For simpler unit-testing
1348
     * @param PEAR_Config
1491
     * @param PEAR_Config
1349
     * @param int
1492
     * @param int
1350
     * @param string
1493
     * @param string
1351
     */
1494
     */
1352
    function &getPackagefileObject(&$c, $d, $t = false)
1495
    function &getPackagefileObject(&$c, $d)
Line 1353... Line -...
1353
    {
-
 
1354
        $a = &new PEAR_PackageFile($c, $d, $t);
1496
    {
1355
        return $a;
1497
        $a = new PEAR_PackageFile($c, $d);
1356
    }
1498
        return $a;
1357
 
1499
    }
1358
 
1500
 
Line 1367... Line 1509...
1367
        $saveparam = $param;
1509
        $saveparam = $param;
1368
        if (is_string($param)) {
1510
        if (is_string($param)) {
1369
            if (!@file_exists($param)) {
1511
            if (!@file_exists($param)) {
1370
                $test = explode('#', $param);
1512
                $test = explode('#', $param);
1371
                $group = array_pop($test);
1513
                $group = array_pop($test);
1372
                if (file_exists(implode('#', $test))) {
1514
                if (@file_exists(implode('#', $test))) {
1373
                    $this->setGroup($group);
1515
                    $this->setGroup($group);
1374
                    $param = implode('#', $test);
1516
                    $param = implode('#', $test);
1375
                    $this->_explicitGroup = true;
1517
                    $this->_explicitGroup = true;
1376
                }
1518
                }
1377
            }
1519
            }
-
 
1520
 
1378
            if (@is_file($param)) {
1521
            if (@is_file($param)) {
1379
                $this->_type = 'local';
1522
                $this->_type = 'local';
1380
                $options = $this->_downloader->getOptions();
1523
                $options = $this->_downloader->getOptions();
1381
                if (isset($options['downloadonly'])) {
-
 
1382
                    $pkg = &$this->getPackagefileObject($this->_config,
1524
                $pkg = &$this->getPackagefileObject($this->_config, $this->_downloader->_debug);
1383
                        $this->_downloader->_debug);
-
 
1384
                } else {
-
 
1385
                    if (PEAR::isError($dir = $this->_downloader->getDownloadDir())) {
-
 
1386
                        return $dir;
-
 
1387
                    }
-
 
1388
                    $pkg = &$this->getPackagefileObject($this->_config,
-
 
1389
                        $this->_downloader->_debug, $dir);
-
 
1390
                }
-
 
1391
                PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
1525
                PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
1392
                $pf = &$pkg->fromAnyFile($param, PEAR_VALIDATE_INSTALLING);
1526
                $pf = &$pkg->fromAnyFile($param, PEAR_VALIDATE_INSTALLING);
1393
                PEAR::popErrorHandling();
1527
                PEAR::popErrorHandling();
1394
                if (PEAR::isError($pf)) {
1528
                if (PEAR::isError($pf)) {
1395
                    $this->_valid = false;
1529
                    $this->_valid = false;
Line 1407... Line 1541...
1407
        return $this->_valid = false;
1541
        return $this->_valid = false;
1408
    }
1542
    }
Line 1409... Line 1543...
1409
 
1543
 
1410
    function _fromUrl($param, $saveparam = '')
1544
    function _fromUrl($param, $saveparam = '')
1411
    {
-
 
1412
        if (!is_array($param) &&
1545
    {
1413
              (preg_match('#^(http|ftp)://#', $param))) {
1546
        if (!is_array($param) && (preg_match('#^(http|https|ftp)://#', $param))) {
1414
            $options = $this->_downloader->getOptions();
1547
            $options = $this->_downloader->getOptions();
1415
            $this->_type = 'url';
1548
            $this->_type = 'url';
1416
            $callback = $this->_downloader->ui ?
1549
            $callback = $this->_downloader->ui ?
1417
                array(&$this->_downloader, '_downloadCallback') : null;
1550
                array(&$this->_downloader, '_downloadCallback') : null;
1418
            $this->_downloader->pushErrorHandling(PEAR_ERROR_RETURN);
1551
            $this->_downloader->pushErrorHandling(PEAR_ERROR_RETURN);
1419
            if (PEAR::isError($dir = $this->_downloader->getDownloadDir())) {
1552
            if (PEAR::isError($dir = $this->_downloader->getDownloadDir())) {
1420
                $this->_downloader->popErrorHandling();
1553
                $this->_downloader->popErrorHandling();
1421
                return $dir;
1554
                return $dir;
-
 
1555
            }
-
 
1556
 
1422
            }
1557
            $this->_downloader->log(3, 'Downloading "' . $param . '"');
1423
            $file = $this->_downloader->downloadHttp($param, $this->_downloader->ui,
1558
            $file = $this->_downloader->downloadHttp($param, $this->_downloader->ui,
1424
                $dir, $callback);
1559
                $dir, $callback, null, false, $this->getChannel());
1425
            $this->_downloader->popErrorHandling();
1560
            $this->_downloader->popErrorHandling();
1426
            if (PEAR::isError($file)) {
1561
            if (PEAR::isError($file)) {
1427
                if (!empty($saveparam)) {
1562
                if (!empty($saveparam)) {
1428
                    $saveparam = ", cannot download \"$saveparam\"";
1563
                    $saveparam = ", cannot download \"$saveparam\"";
1429
                }
1564
                }
1430
                $err = PEAR::raiseError('Could not download from "' . $param .
1565
                $err = PEAR::raiseError('Could not download from "' . $param .
1431
                    '"' . $saveparam . ' (' . $file->getMessage() . ')');
1566
                    '"' . $saveparam . ' (' . $file->getMessage() . ')');
1432
                    return $err;
1567
                    return $err;
-
 
1568
            }
1433
            }
1569
 
1434
            if ($this->_rawpackagefile) {
1570
            if ($this->_rawpackagefile) {
1435
                require_once 'Archive/Tar.php';
1571
                require_once 'Archive/Tar.php';
1436
                $tar = &new Archive_Tar($file);
1572
                $tar = new Archive_Tar($file);
1437
                $packagexml = $tar->extractInString('package2.xml');
1573
                $packagexml = $tar->extractInString('package2.xml');
1438
                if (!$packagexml) {
1574
                if (!$packagexml) {
1439
                    $packagexml = $tar->extractInString('package.xml');
1575
                    $packagexml = $tar->extractInString('package.xml');
-
 
1576
                }
1440
                }
1577
 
1441
                if (str_replace(array("\n", "\r"), array('',''), $packagexml) !=
1578
                if (str_replace(array("\n", "\r"), array('',''), $packagexml) !=
1442
                      str_replace(array("\n", "\r"), array('',''), $this->_rawpackagefile)) {
1579
                      str_replace(array("\n", "\r"), array('',''), $this->_rawpackagefile)) {
1443
                    if ($this->getChannel() == 'pear.php.net') {
-
 
1444
                        // be more lax for the existing PEAR packages that have not-ok
-
 
1445
                        // characters in their package.xml
-
 
1446
                        $this->_downloader->log(0, 'CRITICAL WARNING: The "' .
-
 
1447
                            $this->getPackage() . '" package has invalid characters in its ' .
-
 
1448
                            'package.xml.  The next version of PEAR may not be able to install ' .
-
 
1449
                            'this package for security reasons.  Please open a bug report at ' .
-
 
1450
                            'http://pear.php.net/package/' . $this->getPackage() . '/bugs');
-
 
1451
                    } else {
1580
                    if ($this->getChannel() != 'pear.php.net') {
1452
                        return PEAR::raiseError('CRITICAL ERROR: package.xml downloaded does ' .
1581
                        return PEAR::raiseError('CRITICAL ERROR: package.xml downloaded does ' .
1453
                            'not match value returned from xml-rpc');
1582
                            'not match value returned from xml-rpc');
-
 
1583
                    }
-
 
1584
 
-
 
1585
                    // be more lax for the existing PEAR packages that have not-ok
-
 
1586
                    // characters in their package.xml
-
 
1587
                    $this->_downloader->log(0, 'CRITICAL WARNING: The "' .
-
 
1588
                        $this->getPackage() . '" package has invalid characters in its ' .
-
 
1589
                        'package.xml.  The next version of PEAR may not be able to install ' .
-
 
1590
                        'this package for security reasons.  Please open a bug report at ' .
1454
                    }
1591
                        'http://pear.php.net/package/' . $this->getPackage() . '/bugs');
1455
                }
1592
                }
-
 
1593
            }
1456
            }
1594
 
1457
            // whew, download worked!
-
 
1458
            if (isset($options['downloadonly'])) {
1595
            // whew, download worked!
1459
                $pkg = &$this->getPackagefileObject($this->_config, $this->_downloader->debug);
-
 
1460
            } else {
-
 
1461
                if (PEAR::isError($dir = $this->_downloader->getDownloadDir())) {
-
 
1462
                    return $dir;
-
 
1463
                }
-
 
1464
                $pkg = &$this->getPackagefileObject($this->_config, $this->_downloader->debug,
-
 
1465
                    $dir);
1596
            $pkg = &$this->getPackagefileObject($this->_config, $this->_downloader->debug);
1466
            }
1597
 
1467
            PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
1598
            PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
1468
            $pf = &$pkg->fromAnyFile($file, PEAR_VALIDATE_INSTALLING);
1599
            $pf = &$pkg->fromAnyFile($file, PEAR_VALIDATE_INSTALLING);
1469
            PEAR::popErrorHandling();
1600
            PEAR::popErrorHandling();
1470
            if (PEAR::isError($pf)) {
1601
            if (PEAR::isError($pf)) {
1471
                if (is_array($pf->getUserInfo())) {
1602
                if (is_array($pf->getUserInfo())) {
1472
                    foreach ($pf->getUserInfo() as $err) {
1603
                    foreach ($pf->getUserInfo() as $err) {
1473
                        if (is_array($err)) {
1604
                        if (is_array($err)) {
1474
                            $err = $err['message'];
1605
                            $err = $err['message'];
-
 
1606
                        }
1475
                        }
1607
 
1476
                        if (!isset($options['soft'])) {
1608
                        if (!isset($options['soft'])) {
1477
                            $this->_downloader->log(0, "Validation Error: $err");
1609
                            $this->_downloader->log(0, "Validation Error: $err");
1478
                        }
1610
                        }
1479
                    }
1611
                    }
-
 
1612
                }
1480
                }
1613
 
1481
                if (!isset($options['soft'])) {
1614
                if (!isset($options['soft'])) {
1482
                    $this->_downloader->log(0, $pf->getMessage());
1615
                    $this->_downloader->log(0, $pf->getMessage());
-
 
1616
                }
-
 
1617
 
-
 
1618
                ///FIXME need to pass back some error code that we can use to match with to cancel all further operations
1483
                }
1619
                /// At least stop all deps of this package from being installed
1484
                $err = PEAR::raiseError('Download of "' . ($saveparam ? $saveparam :
1620
                $out = $saveparam ? $saveparam : $param;
1485
                    $param) . '" succeeded, but it is not a valid package archive');
1621
                $err = PEAR::raiseError('Download of "' . $out . '" succeeded, but it is not a valid package archive');
1486
                $this->_valid = false;
1622
                $this->_valid = false;
1487
                return $err;
1623
                return $err;
-
 
1624
            }
1488
            }
1625
 
1489
            $this->_packagefile = &$pf;
1626
            $this->_packagefile = &$pf;
1490
            $this->setGroup('default'); // install the default dependency group
1627
            $this->setGroup('default'); // install the default dependency group
1491
            return $this->_valid = true;
1628
            return $this->_valid = true;
-
 
1629
        }
1492
        }
1630
 
1493
        return $this->_valid = false;
1631
        return $this->_valid = false;
Line 1494... Line 1632...
1494
    }
1632
    }
1495
 
1633
 
Line 1504... Line 1642...
1504
     *                     or a string of format [channame/]pname[-version|-state]
1642
     *                     or a string of format [channame/]pname[-version|-state]
1505
     */
1643
     */
1506
    function _fromString($param)
1644
    function _fromString($param)
1507
    {
1645
    {
1508
        $options = $this->_downloader->getOptions();
1646
        $options = $this->_downloader->getOptions();
-
 
1647
        $channel = $this->_config->get('default_channel');
1509
        PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
1648
        PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
1510
        $pname = $this->_registry->parsePackageName($param,
1649
        $pname = $this->_registry->parsePackageName($param, $channel);
1511
            $this->_config->get('default_channel'));
-
 
1512
        PEAR::popErrorHandling();
1650
        PEAR::popErrorHandling();
1513
        if (PEAR::isError($pname)) {
1651
        if (PEAR::isError($pname)) {
1514
            if ($pname->getCode() == 'invalid') {
1652
            if ($pname->getCode() == 'invalid') {
1515
                $this->_valid = false;
1653
                $this->_valid = false;
1516
                return false;
1654
                return false;
1517
            }
1655
            }
-
 
1656
 
1518
            if ($pname->getCode() == 'channel') {
1657
            if ($pname->getCode() == 'channel') {
1519
                $parsed = $pname->getUserInfo();
1658
                $parsed = $pname->getUserInfo();
1520
                if ($this->_downloader->discover($parsed['channel'])) {
1659
                if ($this->_downloader->discover($parsed['channel'])) {
1521
                    if ($this->_config->get('auto_discover')) {
1660
                    if ($this->_config->get('auto_discover')) {
1522
                        PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
1661
                        PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
1523
                        $pname = $this->_registry->parsePackageName($param,
1662
                        $pname = $this->_registry->parsePackageName($param, $channel);
1524
                            $this->_config->get('default_channel'));
-
 
1525
                        PEAR::popErrorHandling();
1663
                        PEAR::popErrorHandling();
1526
                    } else {
1664
                    } else {
1527
                        if (!isset($options['soft'])) {
1665
                        if (!isset($options['soft'])) {
1528
                            $this->_downloader->log(0, 'Channel "' . $parsed['channel'] .
1666
                            $this->_downloader->log(0, 'Channel "' . $parsed['channel'] .
1529
                                '" is not initialized, use ' .
1667
                                '" is not initialized, use ' .
1530
                                '"pear channel-discover ' . $parsed['channel'] . '" to initialize' .
1668
                                '"pear channel-discover ' . $parsed['channel'] . '" to initialize' .
1531
                                'or pear config-set auto_discover 1');
1669
                                'or pear config-set auto_discover 1');
1532
                        }
1670
                        }
1533
                    }
1671
                    }
1534
                }
1672
                }
-
 
1673
 
1535
                if (PEAR::isError($pname)) {
1674
                if (PEAR::isError($pname)) {
1536
                    if (!isset($options['soft'])) {
1675
                    if (!isset($options['soft'])) {
1537
                        $this->_downloader->log(0, $pname->getMessage());
1676
                        $this->_downloader->log(0, $pname->getMessage());
1538
                    }
1677
                    }
-
 
1678
 
1539
                    if (is_array($param)) {
1679
                    if (is_array($param)) {
1540
                        $param = $this->_registry->parsedPackageNameToString($param);
1680
                        $param = $this->_registry->parsedPackageNameToString($param);
1541
                    }
1681
                    }
-
 
1682
 
1542
                    $err = PEAR::raiseError('invalid package name/package file "' .
1683
                    $err = PEAR::raiseError('invalid package name/package file "' . $param . '"');
1543
                        $param . '"');
-
 
1544
                    $this->_valid = false;
1684
                    $this->_valid = false;
1545
                    return $err;
1685
                    return $err;
1546
                }
1686
                }
1547
            } else {
1687
            } else {
1548
                if (!isset($options['soft'])) {
1688
                if (!isset($options['soft'])) {
1549
                    $this->_downloader->log(0, $pname->getMessage());
1689
                    $this->_downloader->log(0, $pname->getMessage());
1550
                }
1690
                }
-
 
1691
 
1551
                $err = PEAR::raiseError('invalid package name/package file "' .
1692
                $err = PEAR::raiseError('invalid package name/package file "' . $param . '"');
1552
                    $param . '"');
-
 
1553
                $this->_valid = false;
1693
                $this->_valid = false;
1554
                return $err;
1694
                return $err;
1555
            }
1695
            }
1556
        }
1696
        }
-
 
1697
 
1557
        if (!isset($this->_type)) {
1698
        if (!isset($this->_type)) {
1558
            $this->_type = 'xmlrpc';
1699
            $this->_type = 'rest';
1559
        }
-
 
1560
        $this->_parsedname = $pname;
-
 
1561
        if (isset($pname['state'])) {
-
 
1562
            $this->_explicitState = $pname['state'];
-
 
1563
        } else {
-
 
1564
            $this->_explicitState = false;
-
 
1565
        }
-
 
1566
        if (isset($pname['group'])) {
-
 
1567
            $this->_explicitGroup = true;
-
 
1568
        } else {
-
 
1569
            $this->_explicitGroup = false;
-
 
1570
        }
1700
        }
-
 
1701
 
-
 
1702
        $this->_parsedname    = $pname;
-
 
1703
        $this->_explicitState = isset($pname['state']) ? $pname['state'] : false;
-
 
1704
        $this->_explicitGroup = isset($pname['group']) ? true : false;
-
 
1705
 
1571
        $info = $this->_downloader->_getPackageDownloadUrl($pname);
1706
        $info = $this->_downloader->_getPackageDownloadUrl($pname);
1572
        if (PEAR::isError($info)) {
1707
        if (PEAR::isError($info)) {
1573
            if ($info->getCode() != -976 && $pname['channel'] == 'pear.php.net') {
1708
            if ($info->getCode() != -976 && $pname['channel'] == 'pear.php.net') {
1574
                // try pecl
1709
                // try pecl
1575
                $pname['channel'] = 'pecl.php.net';
1710
                $pname['channel'] = 'pecl.php.net';
Line 1584... Line 1719...
1584
                    }
1719
                    }
1585
                } else {
1720
                } else {
1586
                    $pname['channel'] = 'pear.php.net';
1721
                    $pname['channel'] = 'pear.php.net';
1587
                }
1722
                }
1588
            }
1723
            }
-
 
1724
 
1589
            return $info;
1725
            return $info;
1590
        }
1726
        }
-
 
1727
 
1591
        $this->_rawpackagefile = $info['raw'];
1728
        $this->_rawpackagefile = $info['raw'];
1592
        $ret = $this->_analyzeDownloadURL($info, $param, $pname);
1729
        $ret = $this->_analyzeDownloadURL($info, $param, $pname);
1593
        if (PEAR::isError($ret)) {
1730
        if (PEAR::isError($ret)) {
1594
            return $ret;
1731
            return $ret;
1595
        }
1732
        }
-
 
1733
 
1596
        if ($ret) {
1734
        if ($ret) {
1597
            $this->_downloadURL = $ret;
1735
            $this->_downloadURL = $ret;
1598
            return $this->_valid = (bool) $ret;
1736
            return $this->_valid = (bool) $ret;
1599
        }
1737
        }
1600
    }
1738
    }
Line 1613... Line 1751...
1613
                                 $isdependency = false)
1751
                                 $isdependency = false)
1614
    {
1752
    {
1615
        if (!is_string($param) && PEAR_Downloader_Package::willDownload($param, $params)) {
1753
        if (!is_string($param) && PEAR_Downloader_Package::willDownload($param, $params)) {
1616
            return false;
1754
            return false;
1617
        }
1755
        }
-
 
1756
 
1618
        if (!$info) {
1757
        if ($info === false) {
1619
            if (!is_string($param)) {
-
 
1620
                $saveparam = ", cannot download \"$param\"";
1758
            $saveparam = !is_string($param) ? ", cannot download \"$param\"" : '';
1621
            } else {
-
 
1622
                $saveparam = '';
-
 
1623
            }
1759
 
1624
            // no releases exist
1760
            // no releases exist
1625
            return PEAR::raiseError('No releases for package "' .
1761
            return PEAR::raiseError('No releases for package "' .
1626
                $this->_registry->parsedPackageNameToString($pname, true) . '" exist' . $saveparam);
1762
                $this->_registry->parsedPackageNameToString($pname, true) . '" exist' . $saveparam);
1627
        }
1763
        }
-
 
1764
 
1628
        if (strtolower($info['info']->getChannel()) != strtolower($pname['channel'])) {
1765
        if (strtolower($info['info']->getChannel()) != strtolower($pname['channel'])) {
1629
            $err = false;
1766
            $err = false;
1630
            if ($pname['channel'] == 'pecl.php.net') {
1767
            if ($pname['channel'] == 'pecl.php.net') {
1631
                if ($info['info']->getChannel() != 'pear.php.net') {
1768
                if ($info['info']->getChannel() != 'pear.php.net') {
1632
                    $err = true;
1769
                    $err = true;
Line 1636... Line 1773...
1636
                    $err = true;
1773
                    $err = true;
1637
                }
1774
                }
1638
            } else {
1775
            } else {
1639
                $err = true;
1776
                $err = true;
1640
            }
1777
            }
-
 
1778
 
1641
            if ($err) {
1779
            if ($err) {
1642
                return PEAR::raiseError('SECURITY ERROR: package in channel "' . $pname['channel'] .
1780
                return PEAR::raiseError('SECURITY ERROR: package in channel "' . $pname['channel'] .
1643
                    '" retrieved another channel\'s name for download! ("' .
1781
                    '" retrieved another channel\'s name for download! ("' .
1644
                    $info['info']->getChannel() . '")');
1782
                    $info['info']->getChannel() . '")');
1645
            }
1783
            }
1646
        }
1784
        }
-
 
1785
 
-
 
1786
        $preferred_state = $this->_config->get('preferred_state');
1647
        if (!isset($info['url'])) {
1787
        if (!isset($info['url'])) {
-
 
1788
            $package_version = $this->_registry->packageInfo($info['info']->getPackage(),
-
 
1789
            'version', $info['info']->getChannel());
1648
            if ($this->isInstalled($info)) {
1790
            if ($this->isInstalled($info)) {
1649
                if ($isdependency && version_compare($info['version'],
1791
                if ($isdependency && version_compare($info['version'], $package_version, '<=')) {
1650
                      $this->_registry->packageInfo($info['info']->getPackage(),
-
 
1651
                            'version', $info['info']->getChannel()), '<=')) {
-
 
1652
                    // ignore bogus errors of "failed to download dependency"
1792
                    // ignore bogus errors of "failed to download dependency"
1653
                    // if it is already installed and the one that would be
1793
                    // if it is already installed and the one that would be
1654
                    // downloaded is older or the same version (Bug #7219)
1794
                    // downloaded is older or the same version (Bug #7219)
1655
                    return false;
1795
                    return false;
1656
                }
1796
                }
1657
            }
1797
            }
-
 
1798
 
-
 
1799
            if ($info['version'] === $package_version) {
-
 
1800
                if (!isset($options['soft'])) {
-
 
1801
                    $this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] .
-
 
1802
                        '/' . $pname['package'] . '-' . $package_version. ', additionally the suggested version' .
-
 
1803
                        ' (' . $package_version . ') is the same as the locally installed one.');
-
 
1804
                }
-
 
1805
 
-
 
1806
                return false;
-
 
1807
            }
-
 
1808
 
-
 
1809
            if (version_compare($info['version'], $package_version, '<=')) {
-
 
1810
                if (!isset($options['soft'])) {
-
 
1811
                    $this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] .
-
 
1812
                        '/' . $pname['package'] . '-' . $package_version . ', additionally the suggested version' .
-
 
1813
                        ' (' . $info['version'] . ') is a lower version than the locally installed one (' . $package_version . ').');
-
 
1814
                }
-
 
1815
 
-
 
1816
                return false;
-
 
1817
            }
-
 
1818
 
1658
            $instead =  ', will instead download version ' . $info['version'] .
1819
            $instead =  ', will instead download version ' . $info['version'] .
1659
                        ', stability "' . $info['info']->getState() . '"';
1820
                        ', stability "' . $info['info']->getState() . '"';
1660
            // releases exist, but we failed to get any
1821
            // releases exist, but we failed to get any
1661
            if (isset($this->_downloader->_options['force'])) {
1822
            if (isset($this->_downloader->_options['force'])) {
1662
                if (isset($pname['version'])) {
1823
                if (isset($pname['version'])) {
Line 1665... Line 1826...
1665
                    $vs = ', stability "' . $pname['state'] . '"';
1826
                    $vs = ', stability "' . $pname['state'] . '"';
1666
                } elseif ($param == 'dependency') {
1827
                } elseif ($param == 'dependency') {
1667
                    if (!class_exists('PEAR_Common')) {
1828
                    if (!class_exists('PEAR_Common')) {
1668
                        require_once 'PEAR/Common.php';
1829
                        require_once 'PEAR/Common.php';
1669
                    }
1830
                    }
-
 
1831
 
1670
                    if (!in_array($info['info']->getState(),
1832
                    if (!in_array($info['info']->getState(),
1671
                          PEAR_Common::betterStates($this->_config->get('preferred_state'), true))) {
1833
                          PEAR_Common::betterStates($preferred_state, true))) {
1672
                        if ($optional) {
1834
                        if ($optional) {
1673
                            // don't spit out confusing error message
1835
                            // don't spit out confusing error message
1674
                            return $this->_downloader->_getPackageDownloadUrl(
1836
                            return $this->_downloader->_getPackageDownloadUrl(
1675
                                array('package' => $pname['package'],
1837
                                array('package' => $pname['package'],
1676
                                      'channel' => $pname['channel'],
1838
                                      'channel' => $pname['channel'],
1677
                                      'version' => $info['version']));
1839
                                      'version' => $info['version']));
1678
                        }
1840
                        }
1679
                        $vs = ' within preferred state "' . $this->_config->get('preferred_state') .
1841
                        $vs = ' within preferred state "' . $preferred_state .
1680
                            '"';
1842
                            '"';
1681
                    } else {
1843
                    } else {
1682
                        if (!class_exists('PEAR_Dependency2')) {
1844
                        if (!class_exists('PEAR_Dependency2')) {
1683
                            require_once 'PEAR/Dependency2.php';
1845
                            require_once 'PEAR/Dependency2.php';
1684
                        }
1846
                        }
-
 
1847
 
1685
                        if ($optional) {
1848
                        if ($optional) {
1686
                            // don't spit out confusing error message
1849
                            // don't spit out confusing error message
1687
                            return $this->_downloader->_getPackageDownloadUrl(
1850
                            return $this->_downloader->_getPackageDownloadUrl(
1688
                                array('package' => $pname['package'],
1851
                                array('package' => $pname['package'],
1689
                                      'channel' => $pname['channel'],
1852
                                      'channel' => $pname['channel'],
Line 1691... Line 1854...
1691
                        }
1854
                        }
1692
                        $vs = PEAR_Dependency2::_getExtraString($pname);
1855
                        $vs = PEAR_Dependency2::_getExtraString($pname);
1693
                        $instead = '';
1856
                        $instead = '';
1694
                    }
1857
                    }
1695
                } else {
1858
                } else {
1696
                    $vs = ' within preferred state "' . $this->_config->get(
1859
                    $vs = ' within preferred state "' . $preferred_state . '"';
1697
                        'preferred_state') . '"';
-
 
1698
                }
1860
                }
-
 
1861
 
1699
                if (!isset($options['soft'])) {
1862
                if (!isset($options['soft'])) {
1700
                    $this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] .
1863
                    $this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] .
1701
                        '/' . $pname['package'] . $vs . $instead);
1864
                        '/' . $pname['package'] . $vs . $instead);
1702
                }
1865
                }
-
 
1866
 
1703
                // download the latest release
1867
                // download the latest release
1704
                return $this->_downloader->_getPackageDownloadUrl(
1868
                return $this->_downloader->_getPackageDownloadUrl(
1705
                    array('package' => $pname['package'],
1869
                    array('package' => $pname['package'],
1706
                          'channel' => $pname['channel'],
1870
                          'channel' => $pname['channel'],
1707
                          'version' => $info['version']));
1871
                          'version' => $info['version']));
1708
            } else {
1872
            } else {
-
 
1873
                if (isset($info['php']) && $info['php']) {
-
 
1874
                    $err = PEAR::raiseError('Failed to download ' .
-
 
1875
                        $this->_registry->parsedPackageNameToString(
-
 
1876
                            array('channel' => $pname['channel'],
-
 
1877
                                  'package' => $pname['package']),
-
 
1878
                                true) .
-
 
1879
                        ', latest release is version ' . $info['php']['v'] .
-
 
1880
                        ', but it requires PHP version "' .
-
 
1881
                        $info['php']['m'] . '", use "' .
-
 
1882
                        $this->_registry->parsedPackageNameToString(
-
 
1883
                            array('channel' => $pname['channel'], 'package' => $pname['package'],
-
 
1884
                            'version' => $info['php']['v'])) . '" to install',
-
 
1885
                            PEAR_DOWNLOADER_PACKAGE_PHPVERSION);
-
 
1886
                    return $err;
-
 
1887
                }
-
 
1888
 
1709
                // construct helpful error message
1889
                // construct helpful error message
1710
                if (isset($pname['version'])) {
1890
                if (isset($pname['version'])) {
1711
                    $vs = ', version "' . $pname['version'] . '"';
1891
                    $vs = ', version "' . $pname['version'] . '"';
1712
                } elseif (isset($pname['state'])) {
1892
                } elseif (isset($pname['state'])) {
1713
                    $vs = ', stability "' . $pname['state'] . '"';
1893
                    $vs = ', stability "' . $pname['state'] . '"';
1714
                } elseif ($param == 'dependency') {
1894
                } elseif ($param == 'dependency') {
1715
                    if (!class_exists('PEAR_Common')) {
1895
                    if (!class_exists('PEAR_Common')) {
1716
                        require_once 'PEAR/Common.php';
1896
                        require_once 'PEAR/Common.php';
1717
                    }
1897
                    }
-
 
1898
 
1718
                    if (!in_array($info['info']->getState(),
1899
                    if (!in_array($info['info']->getState(),
1719
                          PEAR_Common::betterStates($this->_config->get('preferred_state'), true))) {
1900
                          PEAR_Common::betterStates($preferred_state, true))) {
1720
                        if ($optional) {
1901
                        if ($optional) {
1721
                            // don't spit out confusing error message, and don't die on
1902
                            // don't spit out confusing error message, and don't die on
1722
                            // optional dep failure!
1903
                            // optional dep failure!
1723
                            return $this->_downloader->_getPackageDownloadUrl(
1904
                            return $this->_downloader->_getPackageDownloadUrl(
1724
                                array('package' => $pname['package'],
1905
                                array('package' => $pname['package'],
1725
                                      'channel' => $pname['channel'],
1906
                                      'channel' => $pname['channel'],
1726
                                      'version' => $info['version']));
1907
                                      'version' => $info['version']));
1727
                        }
1908
                        }
1728
                        $vs = ' within preferred state "' . $this->_config->get('preferred_state') .
1909
                        $vs = ' within preferred state "' . $preferred_state . '"';
1729
                            '"';
-
 
1730
                    } else {
1910
                    } else {
1731
                        if (!class_exists('PEAR_Dependency2')) {
1911
                        if (!class_exists('PEAR_Dependency2')) {
1732
                            require_once 'PEAR/Dependency2.php';
1912
                            require_once 'PEAR/Dependency2.php';
1733
                        }
1913
                        }
-
 
1914
 
1734
                        if ($optional) {
1915
                        if ($optional) {
1735
                            // don't spit out confusing error message, and don't die on
1916
                            // don't spit out confusing error message, and don't die on
1736
                            // optional dep failure!
1917
                            // optional dep failure!
1737
                            return $this->_downloader->_getPackageDownloadUrl(
1918
                            return $this->_downloader->_getPackageDownloadUrl(
1738
                                array('package' => $pname['package'],
1919
                                array('package' => $pname['package'],
Line 1740... Line 1921...
1740
                                      'version' => $info['version']));
1921
                                      'version' => $info['version']));
1741
                        }
1922
                        }
1742
                        $vs = PEAR_Dependency2::_getExtraString($pname);
1923
                        $vs = PEAR_Dependency2::_getExtraString($pname);
1743
                    }
1924
                    }
1744
                } else {
1925
                } else {
1745
                    $vs = ' within preferred state "' . $this->_downloader->config->get(
1926
                    $vs = ' within preferred state "' . $this->_downloader->config->get('preferred_state') . '"';
1746
                        'preferred_state') . '"';
-
 
1747
                }
1927
                }
-
 
1928
 
1748
                $options = $this->_downloader->getOptions();
1929
                $options = $this->_downloader->getOptions();
1749
                // this is only set by the "download-all" command
1930
                // this is only set by the "download-all" command
1750
                if (isset($options['ignorepreferred_state'])) {
1931
                if (isset($options['ignorepreferred_state'])) {
1751
                    $err = PEAR::raiseError(
1932
                    $err = PEAR::raiseError(
1752
                        'Failed to download ' . $this->_registry->parsedPackageNameToString(
1933
                        'Failed to download ' . $this->_registry->parsedPackageNameToString(
Line 1759... Line 1940...
1759
                            array('channel' => $pname['channel'], 'package' => $pname['package'],
1940
                            array('channel' => $pname['channel'], 'package' => $pname['package'],
1760
                            'version' => $info['version'])) . '" to install',
1941
                            'version' => $info['version'])) . '" to install',
1761
                            PEAR_DOWNLOADER_PACKAGE_STATE);
1942
                            PEAR_DOWNLOADER_PACKAGE_STATE);
1762
                    return $err;
1943
                    return $err;
1763
                }
1944
                }
-
 
1945
 
-
 
1946
                // Checks if the user has a package installed already and checks the release against
-
 
1947
                // the state against the installed package, this allows upgrades for packages
-
 
1948
                // with lower stability than the preferred_state
-
 
1949
                $stability = $this->_registry->packageInfo($pname['package'], 'stability', $pname['channel']);
-
 
1950
                if (!$this->isInstalled($info)
-
 
1951
                    || !in_array($info['info']->getState(), PEAR_Common::betterStates($stability['release'], true))
-
 
1952
                ) {
1764
                $err = PEAR::raiseError(
1953
                    $err = PEAR::raiseError(
1765
                    'Failed to download ' . $this->_registry->parsedPackageNameToString(
1954
                        'Failed to download ' . $this->_registry->parsedPackageNameToString(
1766
                        array('channel' => $pname['channel'], 'package' => $pname['package']),
1955
                            array('channel' => $pname['channel'], 'package' => $pname['package']),
1767
                            true)
1956
                                true)
1768
                     . $vs .
1957
                         . $vs .
1769
                    ', latest release is version ' . $info['version'] .
1958
                        ', latest release is version ' . $info['version'] .
1770
                    ', stability "' . $info['info']->getState() . '", use "' .
1959
                        ', stability "' . $info['info']->getState() . '", use "' .
1771
                    $this->_registry->parsedPackageNameToString(
1960
                        $this->_registry->parsedPackageNameToString(
1772
                        array('channel' => $pname['channel'], 'package' => $pname['package'],
1961
                            array('channel' => $pname['channel'], 'package' => $pname['package'],
1773
                        'version' => $info['version'])) . '" to install');
1962
                            'version' => $info['version'])) . '" to install');
1774
                return $err;
1963
                    return $err;
-
 
1964
                }
1775
            }
1965
            }
1776
        }
1966
        }
-
 
1967
 
1777
        if (isset($info['deprecated']) && $info['deprecated']) {
1968
        if (isset($info['deprecated']) && $info['deprecated']) {
1778
            $this->_downloader->log(0,
1969
            $this->_downloader->log(0,
1779
                'WARNING: "' . 
1970
                'WARNING: "' .
1780
                    $this->_registry->parsedPackageNameToString(
1971
                    $this->_registry->parsedPackageNameToString(
1781
                            array('channel' => $info['info']->getChannel(),
1972
                            array('channel' => $info['info']->getChannel(),
1782
                                  'package' => $info['info']->getPackage()), true) .
1973
                                  'package' => $info['info']->getPackage()), true) .
1783
                '" is deprecated in favor of "' .
1974
                '" is deprecated in favor of "' .
1784
                    $this->_registry->parsedPackageNameToString($info['deprecated'], true) .
1975
                    $this->_registry->parsedPackageNameToString($info['deprecated'], true) .
1785
                '"');
1976
                '"');
1786
        }
1977
        }
-
 
1978
 
1787
        return $info;
1979
        return $info;
1788
    }
1980
    }
1789
}
1981
}
1790
?>
-