cvs: pear-core / package-PEAR.xml package2.xml /PEAR Downloader.php /PEAR/Downloader Package.php /PEAR/REST 10.php
/tests/PEAR_Command_Install/upgrade test_bug6931.phpt

From: Date: Tue, 28 Mar 2006 03:51:40 +0000
Subject: cvs: pear-core / package-PEAR.xml package2.xml /PEAR Downloader.php /PEAR/Downloader Package.php /PEAR/REST 10.php
/tests/PEAR_Command_Install/upgrade test_bug6931.phpt
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-39376@lists.php.net to get a copy of this message
cellog Tue Mar 28 03:51:40 2006 UTC Modified files: /pear-core package-PEAR.xml package2.xml /pear-core/PEAR Downloader.php /pear-core/PEAR/Downloader Package.php /pear-core/PEAR/REST 10.php /pear-core/tests/PEAR_Command_Install/upgrade test_bug6931.phpt Log: * fix Bug #6931: pear upgrade PEAR-alpha tries to upgrade to 1.4.0a12 * fix Bug #7221: pear install blah-alpha won't install a newer stable

http://cvs.php.net/viewcvs.cgi/pear-core/package-PEAR.xml?r1=1.358&r2=1.359&diff_format=u Index: pear-core/package-PEAR.xml diff -u pear-core/package-PEAR.xml:1.358 pear-core/package-PEAR.xml:1.359 --- pear-core/package-PEAR.xml:1.358 Mon Mar 27 21:14:28 2006 +++ pear-core/package-PEAR.xml Tue Mar 28 03:51:40 2006 @@ -1,674 +1,676 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!--DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0"--> -<package version="1.0" xmlns="http://pear.php.net/dtd/package-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/package-1.0 -http://pear.php.net/dtd/package-1.0.xsd"> - <name>PEAR</name> - <summary>PEAR Base System</summary> - <description>The PEAR package contains: - * the PEAR installer, for creating, distributing - and installing packages - * the beta-quality PEAR_Exception PHP5 error handling mechanism - * the beta-quality PEAR_ErrorStack advanced error handling mechanism - * the PEAR_Error error handling mechanism - * the OS_Guess class for retrieving info about the OS - where PHP is running on - * the System class for quick handling of common operations - with files and directories - * the PEAR base class - - New features in a nutshell: - * full support for channels - * pre-download dependency validation - * new package.xml 2.0 format allows tremendous flexibility while maintaining BC - * support for optional dependency groups and limited support for sub-packaging - * robust dependency support - * full dependency validation on uninstall - * remote install for hosts with only ftp access - no more problems with - restricted host installation - * full support for mirroring - * support for bundling several packages into a single tarball - * support for static dependencies on a url-based package - * support for custom file roles and installation tasks - - NOTE: users of PEAR_Frontend_Web/PEAR_Frontend_Gtk must upgrade their installations - to the latest version, or PEAR will not upgrade properly - </description> - <maintainers> - <maintainer> - <user>cellog</user> - <role>lead</role> - <name>Greg Beaver</name> - <email>cellog@php.net</email> - </maintainer> - <maintainer> - <user>ssb</user> - <role>lead</role> - <name>Stig Bakken</name> - <email>stig@php.net</email> - </maintainer> - <maintainer> - <user>cox</user> - <role>lead</role> - <name>Tomas V.V.Cox</name> - <email>cox@idecnet.com</email> - </maintainer> - <maintainer> - <user>pajoye</user> - <role>lead</role> - <name>Pierre-Alain Joye</name> - <email>pajoye@pearfr.org</email> - </maintainer> - <maintainer> - <user>timj</user> - <role>helper</role> - <name>Tim Jackson</name> - <email>timj@php.net</email> - </maintainer> - <maintainer> - <user>toggg</user> - <role>helper</role> - <name>Bertrand Gugger</name> - <email>toggg@php.net</email> - </maintainer> - <maintainer> - <user>mj</user> - <role>helper</role> - <name>Martin Jansen</name> - <email>mj@php.net</email> - </maintainer> - </maintainers> - <release> - <version>1.5.0a1</version> - <date>2006-05-01</date> - <license>PHP License</license> - <state>alpha</state> - <notes> - Minor feature addition/bugfixes - * fix Bug #7021: Everything must be within &lt;dir name=&quot;/&quot;&gt; - * fix Bug #7196: PEAR crashes when using autoload_prepend_file - * fix Bug #7207: proxy user/pass is not urldecoded in download - * fix Bug #7219: bogus &quot;will download PEAR 1.4.8&quot; error - * implement Request #7090: PEAR_Downloader mustn't contact pear server - when installing local package file - </notes> - <provides type="class" name="OS_Guess"/> - <provides type="class" name="System"/> - <provides type="function" name="md5_file"/> - <deps> - <dep type="php" rel="ge" version="4.3.0"/> - <dep type="pkg" rel="ge" version="1.3.3">PEAR</dep> - <dep type="pkg" rel="ge" version="1.3.1">Archive_Tar</dep> - <dep type="pkg" rel="ge" version="1.2">Console_Getopt</dep> - <dep type="pkg" rel="ge" version="1.4.0" optional="yes">XML_RPC</dep> - <dep type="pkg" rel="ge" version="0.5.0" optional="yes">PEAR_Frontend_Web</dep> - <dep type="pkg" rel="ge" version="0.4.0" optional="yes">PEAR_Frontend_Gtk</dep> - <dep type="ext" rel="has">xml</dep> - <dep type="ext" rel="has">pcre</dep> - </deps> - <filelist> - <dir name="OS"> - <file role="php" name="Guess.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - </dir> - <dir name="PEAR"> - <dir name="ChannelFile"> - <file name="Parser.php" role="php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - </dir> - <dir name="Command"> - <file role="php" name="Auth.xml"/> - <file role="php" name="Auth.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Build.xml"/> - <file role="php" name="Build.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Channels.xml"/> - <file role="php" name="Channels.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Common.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Config.xml"/> - <file role="php" name="Config.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Install.xml"/> - <file role="php" name="Install.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Package.xml"/> - <file role="php" name="Package.php"> - <replace from="@DATA-DIR@" to="data_dir" type="pear-config"/> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Pickle.xml"/> - <file role="php" name="Pickle.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Registry.xml"/> - <file role="php" name="Registry.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Remote.xml"/> - <file role="php" name="Remote.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Mirror.xml"/> - <file role="php" name="Mirror.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Test.xml"/> - <file role="php" name="Test.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - </dir> - <dir name="Downloader"> - <file role="php" name="Package.php"> - <replace from="@PEAR-VER@" to="version" type="package-info"/> - </file> - </dir> - <dir name="Frontend"> - <file role="php" name="CLI.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - </dir> - <dir name="Installer"> - <dir name="Role"> - <file role="php" name="Common.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Data.xml"/> - <file role="php" name="Data.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Doc.xml"/> - <file role="php" name="Doc.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Ext.xml"/> - <file role="php" name="Ext.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Php.xml"/> - <file role="php" name="Php.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Script.xml"/> - <file role="php" name="Script.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Src.xml"/> - <file role="php" name="Src.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Test.xml"/> - <file role="php" name="Test.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - </dir> - <file role="php" name="Role.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - </dir> - <dir name="PackageFile"> - <dir name="Generator"> - <file role="php" name="v1.php"> - <replace from="@PEAR-VER@" to="version" type="package-info"/> - </file> - <file role="php" name="v2.php"> - <replace from="@PEAR-VER@" to="version" type="package-info"/> - </file> - </dir> - <dir name="Parser"> - <file role="php" name="v1.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="v2.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - </dir> - <dir name="v2"> - <file role="php" name="rw.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Validator.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - </dir> - <file role="php" name="v1.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="v2.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - </dir> - <dir name="REST"> - <file role="php" name="10.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="11.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - </dir> - <dir name="Task"> - <dir name="Postinstallscript"> - <file role="php" name="rw.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - </dir> - <dir name="Replace"> - <file role="php" name="rw.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - </dir> - <dir name="Unixeol"> - <file role="php" name="rw.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - </dir> - <dir name="Windowseol"> - <file role="php" name="rw.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - </dir> - <file role="php" name="Common.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Postinstallscript.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Replace.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Unixeol.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Windowseol.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - </dir> - <dir name="Validator"> - <file role="php" name="PECL.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - </dir> - <file role="php" name="Autoloader.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Builder.php"> - <replace from="@PEAR-VER@" to="version" type="package-info"/> - </file> - <file role="php" name="ChannelFile.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Command.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Common.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Config.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Dependency.php"/> - <file role="php" name="DependencyDB.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Dependency2.php"> - <replace from="@PEAR-VER@" to="version" type="package-info"/> - </file> - <file role="php" name="Downloader.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="ErrorStack.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Exception.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Frontend.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Installer.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Packager.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="PackageFile.php"> - <replace from="@PEAR-VER@" to="version" type="package-info"/> - </file> - <file role="php" name="Registry.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Remote.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="REST.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="RunTest.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="Validate.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="XMLParser.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - </dir> - <dir name="scripts" baseinstalldir="/"> - <file role="script" install-as="pear" name="pear.sh" platform="!windows"> - <replace from="@php_bin@" to="php_bin" type="pear-config"/> - <replace from="@php_dir@" to="php_dir" type="pear-config"/> - <replace from="@pear_version@" to="version" type="package-info"/> - <replace from="@include_path@" to="php_dir" type="pear-config"/> - </file> - <file role="script" install-as="peardev" name="peardev.sh" platform="!windows"> - <replace from="@php_bin@" to="php_bin" type="pear-config"/> - <replace from="@php_dir@" to="php_dir" type="pear-config"/> - <replace from="@pear_version@" to="version" type="package-info"/> - <replace from="@include_path@" to="php_dir" type="pear-config"/> - </file> - <file role="script" install-as="pecl" name="pecl.sh" platform="!windows"> - <replace from="@php_bin@" to="php_bin" type="pear-config"/> - <replace from="@php_dir@" to="php_dir" type="pear-config"/> - <replace from="@pear_version@" to="version" type="package-info"/> - <replace from="@include_path@" to="php_dir" type="pear-config"/> - </file> - <file role="script" platform="windows" install-as="peardev.bat" name="peardev.bat"> - <replace from="@bin_dir@" to="bin_dir" type="pear-config"/> - <replace from="@php_bin@" to="php_bin" type="pear-config"/> - <replace from="@include_path@" to="php_dir" type="pear-config"/> - </file> - <file role="script" platform="windows" install-as="pear.bat" name="pear.bat"> - <replace from="@bin_dir@" to="bin_dir" type="pear-config"/> - <replace from="@php_bin@" to="php_bin" type="pear-config"/> - <replace from="@include_path@" to="php_dir" type="pear-config"/> - </file> - <file role="script" platform="windows" install-as="pecl.bat" name="pecl.bat"> - <replace from="@bin_dir@" to="bin_dir" type="pear-config"/> - <replace from="@php_bin@" to="php_bin" type="pear-config"/> - <replace from="@include_path@" to="php_dir" type="pear-config"/> - </file> - <file role="php" install-as="pearcmd.php" name="pearcmd.php"> - <replace from="@php_bin@" to="php_bin" type="pear-config"/> - <replace from="@php_dir@" to="php_dir" type="pear-config"/> - <replace from="@pear_version@" to="version" type="package-info"/> - <replace from="@include_path@" to="php_dir" type="pear-config"/> - </file> - <file role="php" install-as="peclcmd.php" name="peclcmd.php"> - <replace from="@php_bin@" to="php_bin" type="pear-config"/> - <replace from="@php_dir@" to="php_dir" type="pear-config"/> - <replace from="@pear_version@" to="version" type="package-info"/> - <replace from="@include_path@" to="php_dir" type="pear-config"/> - </file> - </dir> - <file role="data" name="package.dtd"/> - <file role="data" name="template.spec"/> - <file role="php" name="PEAR.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - <file role="php" name="System.php"> - <replace from="@package_version@" to="version" type="package-info"/> - </file> - </filelist> - </release> - <changelog> - <release> - <version>1.4.0</version> - <date>2005-09-18</date> - <license>PHP License</license> - <state>stable</state> - <notes> - This is a major milestone release for PEAR. In addition to several killer features, - every single element of PEAR has a regression test, and so stability is much higher - than any previous PEAR release. - - New features in a nutshell: - * full support for channels - * pre-download dependency validation - * new package.xml 2.0 format allows tremendous flexibility while maintaining BC - * support for optional dependency groups and limited support for sub-packaging - * robust dependency support - * full dependency validation on uninstall - * remote install for hosts with only ftp access - no more problems with - restricted host installation - * full support for mirroring - * support for bundling several packages into a single tarball - * support for static dependencies on a url-based package - * support for custom file roles and installation tasks - - NOTE: users of PEAR_Frontend_Web/PEAR_Frontend_Gtk must upgrade their installations - to the latest version, or PEAR will not upgrade properly - </notes> - </release> - <release> - <version>1.4.1</version> - <date>2005-09-25</date> - <license>PHP License</license> - <state>stable</state> - <notes> - Major bugfix release. This is a recommended download for ALL PEAR users - - UPGRADING FROM 1.4.0 WILL CAUSE A SERIES OF NOTICES. IGNORE THEM. - THIS IS CAUSED BY A BUG IN 1.4.0 THAT IS FIXED IN 1.4.1 - - * fix prompt processing in post-install scripts - * make dual package.xml equivalency stricter when using package.xml/package2.xml - * fix critical error in validating bogus php dependencies of package.xml 1.0 - This error has existed for every PEAR version, and allows dependencies like: - &lt;dep type=&quot;php&quot; rel=&quot;has&quot;&gt;4.3.0&lt;/dep&gt; to - slip through unnoticed - * re-enable php-const replacements - * PEAR_PackageFile_v2::getConfigureOptions() was missing!! - * fix cvsdiff command - * fix xml encoding issues finally - * clean up package.xml 1.0 dir/file parsing - * fix invalid PEAR_Config generation - * change the user agent from PHP/phpversion to PEAR/pearversion/PHP/phpversion - * don't use a bogus uri for licenses on running convert command - * add &quot;pickle&quot; command for PECL packaging - * add validation warning if the release date in package.xml is not today when packaging - * implement progress bar for list-all/remote-list - * fix Bug #5323: pear search returns odd version numbers - * fix Bug #5428: pear cvstag package2.xml does not include the package.xml - * fix Bug #5449: pear makerpm completely broken for package.xml 2.0 - * fix Bug #5462: raiseError method does not return by ref anymore - * fix Bug #5465: pear install --offline fails to display error - * fix Bug #5477: Bug in Downloader.php and Dependency2.php - * fix Bug #5481: &quot;pear install PECLextension&quot; should display warning to use pecl command - * fix Bug #5482: installation of PECL packages should say add extensions to php.ini - * fix Bug #5483: pecl uninstall crack fatal error - * fix Bug #5487: PECL: compiled files are not uninstalled via the uninstall command - * fix Bug #5488: pecl uninstall package fails if package has a package.xml 1.0 - * fix Bug #5501: the commands list mentions XML-RPC - * fix Bug #5509: addDependecyGroup does not validate group name - * fix Bug #5513: PEAR 1.4 does not install non-pear.php.net packages - </notes> - </release> - <release> - <version>1.4.2</version> - <date>2005-10-08</date> - <license>PHP License</license> - <state>stable</state> - <notes> - Minor bugfix release - - * fix issues with API for adding tasks to package2.xml - * fix Bug #5520: pecl pickle fails on pecl pickle fails on extension/package deps - * fix Bug #5523: pecl pickle misses to put configureoptions into package.xml v1 - * fix Bug #5527: No need for cpp - * fix Bug #5529: configure options in package.xml 2.0 will be ignored - * fix Bug #5530: PEAR_PackageFile_v2->getConfigureOptions() API incompatible with v1 - * fix Bug #5531: adding of installconditions/binarypackage/configure options - to extsrc may fail - * fix Bug #5550: PHP notices/warnings/errors are 1 file off in trace - * fix Bug #5580: pear makerpm XML_sql2xml-0.3.2.tgz error - * fix Bug #5619: pear makerpm produces invalid .spec dependancy code - * fix Bug #5629: pear install http_download dies with bad error message - </notes> - </release> - <release> - <version>1.4.3</version> - <date>2005-11-03</date> - <license>PHP License</license> - <state>stable</state> - <notes> - MINOR SECURITY FIX release - - A security vulnerability has been discovered in all - PEAR versions (1.0 to 1.4.2). This vulnerability has been fixed, - and this is a recommended upgrade for all users. - - Run "pear channel-update" after upgrading for exponentially - faster list-all/remote-list!! - - * fix installation of files named like &quot;.test&quot; - * fix base class for writeable unixeol/windowseol classes - * fix running of post-install scripts with empty or no paramgroup - in CLI frontend - * fix validation of &lt;postinstallscript&gt; - * fix writeable PEAR_Task_Postinstallscript_rw class - * fix error in REST-based search command if searching through description - as well - * silence warning on list-upgrades/upgrade-all if no releases exist at a channel - * add checks for updated channel.xml in all remote commands - * fix pecl script if safe_mode is enabled by default - * implement SERIOUS improvement in list-all/remote-list speed. From 6 minutes - down to about 16-30 seconds - * implement --loose option to avoid recommended version validation - * implement Request #5527: alternative approach to determining glibc version - * fix Bug #5717: analyzeSourceCode() fails to process certain - quote situations properly - * fix Bug #5736: if registry can't lock registry or open filemap, - checkFileMap(), no error - * fix Bug #5676: pear config-create broken - * fix Bug #5683: Deadlock with (almost) circular dependency - * fix Bug #5725: PHP5 warnings need improvement - * fix Bug #5789: small typo - * fix Bug #5810: internet should not be contacted on install if dependencies are installed - </notes> - </release> - <release> - <version>1.4.4</version> - <date>2005-11-04</date> - <license>PHP License</license> - <state>stable</state> - <notes> - * fix Bug #5865: doesn't work with PHP4.2.x - </notes> - </release> - <release> - <version>1.4.5</version> - <date>2005-11-21</date> - <license>PHP License</license> - <state>stable</state> - <notes> - * REALLY fix Bug #5865: doesn't work with PHP4.2.x - * fix Bug #5854: if no installconditions match, no error is raised - * fix Bug #5945: installer should auto-skip to the next channel on timeout - * fix Bug #5947: Some package-info not handled by PEAR_PackageFile_v2 - * fix Bug #5948: Minor typo in PEAR_Validate - * fix Bug #5958: strange error on mistyping - * fix Bug #5959: patch: pear makerpm produces RPMs that do not uninstall/upgrade cleanly - </notes> - </release> - <release> - <version>1.4.6</version> - <date>2006-01-06</date> - <license>PHP License</license> - <state>stable</state> - <notes> - Minor bugfix release - * fix problem with -options when using CGI version of PHP - * fix Critical Bug #5999: support for baseinstalldir broken in package2.xml format - * fix Bug #6034: date format bug - * fix Bug #6040: PEAR_Frontend#setFrontendClass has no docblock; - PEAR_Frontend not documented - * fix Bug #6044: PEAR_REST::retrieveCacheFirst doesn't return error codes - * fix Bug #6047: pear makerpm fails to handle docs in root directory - * fix Bug #6048: PEAR_Frontend::log parameters are wrong - * fix Bug #6106: Notices by list-upgrades (caused by time-outs ?) - * fix Bug #6145: Can't install PEAR with INSTALL_ROOT environment - * fix Bug #6218: the "pear" command does nothing - * fix Bug #6269: System::which() returns silliness if passed null - * fix Bug #6322: Installer fails to follow redirects [patch by Bertrand Gugger] - * fix Request #6119: Add PEAR_Frontend_Gtk2 support to PEAR - </notes> - </release> - <release> - <version>1.4.7</version> - <date>2006-02-27</date> - <license>PHP License</license> - <state>stable</state> - <notes> - Minor bugfix release - * Prevent packaging of release candidate releases with versions like 1.0.0rc1 - version_compare() only understands upper-case 1.0.0RC1 - * implement CLEAN section in .phpt tests - * implement run-tests command for phpunit-based tests - * implement Request #6039: setFrontendObject needed to allow objects passed - * fix Bug #6075: unnecessary validation of maintainers can break PEAR_PFM - * fix Bug #6076: optional is not set for conversion of package2.xml to "has" rel - * fix Bug #6077: PEAR_PackageFile_Parser_v2 should return by reference - * fix Bug #6273: pear download-all fails - * fix Bug #6383: incomplete PEAR::Error message on addReplacement() - * fix Bug #6445: PEAR::registerShutdownFunc doesn't work in static calls - * fix Bug #6480: pear install --installroot option fails for pecl packages [timj] - * fix Bug #6510: status active of a maintainer cannot be change - * fix Bug #6537: wrong export compatible v1 dependencies list with exclude limit - * fix Bug #6559: pear should ignore safemode/open_basedir - * fix Bug #6576: PFM2 run in trouble with sessions - * fix Bug #6579: PFM2 changelog and license with uri - * fix Bug #6673: pear install --offline --packagingroot=/blah does not work - * fix Bug #6674: --packagingroot always uses channel pear.php.net configuration - * fix Bug #6675: postinstallscript validation fails - * fix Bug #6690: channel with / will not allow upgrade - * fix Bug #6692: Optional feature install message needs channel name - * fix Bug #6716: &quot;pear install -r&quot; errors after install when - attempting &quot;pear list &lt;pkgname&gt;&quot; - * fix Bug #6735: PEAR_PackageFile::fromTgzFile doesn't work with package.xml - not in root dir - </notes> - </release> - <release> - <version>1.4.8</version> - <date>2006-03-05</date> - <license>PHP License</license> - <state>stable</state> - <notes> - CRITICAL BUGFIX RELEASE - - Channels with &quot;-&quot; in their name were suddenly invalid, and - caused crashes in many places due to improper error handling - * fix Bug #6960: channels are not allowed to have &quot;-&quot; in their name - * fix critical Bug #6969: PEAR list-upgrades crashes - * fix Bug #6991: Class 'PEAR_PackageFile_v1' not found in Registry.php at line 1657 - * fix Bug #7008: PEAR_Frontend::setFrontendObject doesn't set the object - * fix Bug #7015: install a package.tgz with unknown channel, fatal error in PEAR/Registry.php - * fix Bug #7020: tests/PEAR_Registry/api1_1/test_getChannelValidator.phpt crashes PEAR - </notes> - </release> - <release> - <version>1.4.9</version> - <date>2006-03-29</date> - <license>PHP License</license> - <state>stable</state> - <notes> - CRITICAL BUGFIX RELEASE - users upgrading from PEAR 1.3.x cannot upgrade to 1.4.8 - users who use --packagingroot may find that installation fails - * fix Bug #7093: if pear channel does not exist, it cannot be retrieved - * fix Bug #7165: warnings in pear - * fix Bug #7075: PEAR_PackageFile_v2 :: setLogger failed on autodetection - </notes> - </notes> - </release> - </changelog> -</package> +<?xml version="1.0" encoding="ISO-8859-1"?> +<!--DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0"--> +<package version="1.0" xmlns="http://pear.php.net/dtd/package-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/package-1.0 +http://pear.php.net/dtd/package-1.0.xsd"> + <name>PEAR</name> + <summary>PEAR Base System</summary> + <description>The PEAR package contains: + * the PEAR installer, for creating, distributing + and installing packages + * the beta-quality PEAR_Exception PHP5 error handling mechanism + * the beta-quality PEAR_ErrorStack advanced error handling mechanism + * the PEAR_Error error handling mechanism + * the OS_Guess class for retrieving info about the OS + where PHP is running on + * the System class for quick handling of common operations + with files and directories + * the PEAR base class + + New features in a nutshell: + * full support for channels + * pre-download dependency validation + * new package.xml 2.0 format allows tremendous flexibility while maintaining BC + * support for optional dependency groups and limited support for sub-packaging + * robust dependency support + * full dependency validation on uninstall + * remote install for hosts with only ftp access - no more problems with + restricted host installation + * full support for mirroring + * support for bundling several packages into a single tarball + * support for static dependencies on a url-based package + * support for custom file roles and installation tasks + + NOTE: users of PEAR_Frontend_Web/PEAR_Frontend_Gtk must upgrade their installations + to the latest version, or PEAR will not upgrade properly + </description> + <maintainers> + <maintainer> + <user>cellog</user> + <role>lead</role> + <name>Greg Beaver</name> + <email>cellog@php.net</email> + </maintainer> + <maintainer> + <user>ssb</user> + <role>lead</role> + <name>Stig Bakken</name> + <email>stig@php.net</email> + </maintainer> + <maintainer> + <user>cox</user> + <role>lead</role> + <name>Tomas V.V.Cox</name> + <email>cox@idecnet.com</email> + </maintainer> + <maintainer> + <user>pajoye</user> + <role>lead</role> + <name>Pierre-Alain Joye</name> + <email>pajoye@pearfr.org</email> + </maintainer> + <maintainer> + <user>timj</user> + <role>helper</role> + <name>Tim Jackson</name> + <email>timj@php.net</email> + </maintainer> + <maintainer> + <user>toggg</user> + <role>helper</role> + <name>Bertrand Gugger</name> + <email>toggg@php.net</email> + </maintainer> + <maintainer> + <user>mj</user> + <role>helper</role> + <name>Martin Jansen</name> + <email>mj@php.net</email> + </maintainer> + </maintainers> + <release> + <version>1.5.0a1</version> + <date>2006-05-01</date> + <license>PHP License</license> + <state>alpha</state> + <notes> + Minor feature addition/bugfixes + * fix Bug #6931: pear upgrade PEAR-alpha tries to upgrade to 1.4.0a12 + * fix Bug #7021: Everything must be within &lt;dir name=&quot;/&quot;&gt; + * fix Bug #7196: PEAR crashes when using autoload_prepend_file + * fix Bug #7207: proxy user/pass is not urldecoded in download + * fix Bug #7219: bogus &quot;will download PEAR 1.4.8&quot; error + * fix Bug #7221: pear install blah-alpha won't install a newer stable + * implement Request #7090: PEAR_Downloader mustn't contact pear server + when installing local package file + </notes> + <provides type="class" name="OS_Guess"/> + <provides type="class" name="System"/> + <provides type="function" name="md5_file"/> + <deps> + <dep type="php" rel="ge" version="4.3.0"/> + <dep type="pkg" rel="ge" version="1.3.3">PEAR</dep> + <dep type="pkg" rel="ge" version="1.3.1">Archive_Tar</dep> + <dep type="pkg" rel="ge" version="1.2">Console_Getopt</dep> + <dep type="pkg" rel="ge" version="1.4.0" optional="yes">XML_RPC</dep> + <dep type="pkg" rel="ge" version="0.5.0" optional="yes">PEAR_Frontend_Web</dep> + <dep type="pkg" rel="ge" version="0.4.0" optional="yes">PEAR_Frontend_Gtk</dep> + <dep type="ext" rel="has">xml</dep> + <dep type="ext" rel="has">pcre</dep> + </deps> + <filelist> + <dir name="OS"> + <file role="php" name="Guess.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + </dir> + <dir name="PEAR"> + <dir name="ChannelFile"> + <file name="Parser.php" role="php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + </dir> + <dir name="Command"> + <file role="php" name="Auth.xml"/> + <file role="php" name="Auth.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Build.xml"/> + <file role="php" name="Build.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Channels.xml"/> + <file role="php" name="Channels.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Common.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Config.xml"/> + <file role="php" name="Config.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Install.xml"/> + <file role="php" name="Install.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Package.xml"/> + <file role="php" name="Package.php"> + <replace from="@DATA-DIR@" to="data_dir" type="pear-config"/> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Pickle.xml"/> + <file role="php" name="Pickle.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Registry.xml"/> + <file role="php" name="Registry.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Remote.xml"/> + <file role="php" name="Remote.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Mirror.xml"/> + <file role="php" name="Mirror.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Test.xml"/> + <file role="php" name="Test.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + </dir> + <dir name="Downloader"> + <file role="php" name="Package.php"> + <replace from="@PEAR-VER@" to="version" type="package-info"/> + </file> + </dir> + <dir name="Frontend"> + <file role="php" name="CLI.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + </dir> + <dir name="Installer"> + <dir name="Role"> + <file role="php" name="Common.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Data.xml"/> + <file role="php" name="Data.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Doc.xml"/> + <file role="php" name="Doc.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Ext.xml"/> + <file role="php" name="Ext.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Php.xml"/> + <file role="php" name="Php.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Script.xml"/> + <file role="php" name="Script.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Src.xml"/> + <file role="php" name="Src.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Test.xml"/> + <file role="php" name="Test.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + </dir> + <file role="php" name="Role.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + </dir> + <dir name="PackageFile"> + <dir name="Generator"> + <file role="php" name="v1.php"> + <replace from="@PEAR-VER@" to="version" type="package-info"/> + </file> + <file role="php" name="v2.php"> + <replace from="@PEAR-VER@" to="version" type="package-info"/> + </file> + </dir> + <dir name="Parser"> + <file role="php" name="v1.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="v2.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + </dir> + <dir name="v2"> + <file role="php" name="rw.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Validator.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + </dir> + <file role="php" name="v1.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="v2.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + </dir> + <dir name="REST"> + <file role="php" name="10.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="11.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + </dir> + <dir name="Task"> + <dir name="Postinstallscript"> + <file role="php" name="rw.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + </dir> + <dir name="Replace"> + <file role="php" name="rw.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + </dir> + <dir name="Unixeol"> + <file role="php" name="rw.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + </dir> + <dir name="Windowseol"> + <file role="php" name="rw.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + </dir> + <file role="php" name="Common.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Postinstallscript.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Replace.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Unixeol.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Windowseol.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + </dir> + <dir name="Validator"> + <file role="php" name="PECL.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + </dir> + <file role="php" name="Autoloader.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Builder.php"> + <replace from="@PEAR-VER@" to="version" type="package-info"/> + </file> + <file role="php" name="ChannelFile.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Command.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Common.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Config.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Dependency.php"/> + <file role="php" name="DependencyDB.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Dependency2.php"> + <replace from="@PEAR-VER@" to="version" type="package-info"/> + </file> + <file role="php" name="Downloader.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="ErrorStack.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Exception.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Frontend.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Installer.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Packager.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="PackageFile.php"> + <replace from="@PEAR-VER@" to="version" type="package-info"/> + </file> + <file role="php" name="Registry.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Remote.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="REST.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="RunTest.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="Validate.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="XMLParser.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + </dir> + <dir name="scripts" baseinstalldir="/"> + <file role="script" install-as="pear" name="pear.sh" platform="!windows"> + <replace from="@php_bin@" to="php_bin" type="pear-config"/> + <replace from="@php_dir@" to="php_dir" type="pear-config"/> + <replace from="@pear_version@" to="version" type="package-info"/> + <replace from="@include_path@" to="php_dir" type="pear-config"/> + </file> + <file role="script" install-as="peardev" name="peardev.sh" platform="!windows"> + <replace from="@php_bin@" to="php_bin" type="pear-config"/> + <replace from="@php_dir@" to="php_dir" type="pear-config"/> + <replace from="@pear_version@" to="version" type="package-info"/> + <replace from="@include_path@" to="php_dir" type="pear-config"/> + </file> + <file role="script" install-as="pecl" name="pecl.sh" platform="!windows"> + <replace from="@php_bin@" to="php_bin" type="pear-config"/> + <replace from="@php_dir@" to="php_dir" type="pear-config"/> + <replace from="@pear_version@" to="version" type="package-info"/> + <replace from="@include_path@" to="php_dir" type="pear-config"/> + </file> + <file role="script" platform="windows" install-as="peardev.bat" name="peardev.bat"> + <replace from="@bin_dir@" to="bin_dir" type="pear-config"/> + <replace from="@php_bin@" to="php_bin" type="pear-config"/> + <replace from="@include_path@" to="php_dir" type="pear-config"/> + </file> + <file role="script" platform="windows" install-as="pear.bat" name="pear.bat"> + <replace from="@bin_dir@" to="bin_dir" type="pear-config"/> + <replace from="@php_bin@" to="php_bin" type="pear-config"/> + <replace from="@include_path@" to="php_dir" type="pear-config"/> + </file> + <file role="script" platform="windows" install-as="pecl.bat" name="pecl.bat"> + <replace from="@bin_dir@" to="bin_dir" type="pear-config"/> + <replace from="@php_bin@" to="php_bin" type="pear-config"/> + <replace from="@include_path@" to="php_dir" type="pear-config"/> + </file> + <file role="php" install-as="pearcmd.php" name="pearcmd.php"> + <replace from="@php_bin@" to="php_bin" type="pear-config"/> + <replace from="@php_dir@" to="php_dir" type="pear-config"/> + <replace from="@pear_version@" to="version" type="package-info"/> + <replace from="@include_path@" to="php_dir" type="pear-config"/> + </file> + <file role="php" install-as="peclcmd.php" name="peclcmd.php"> + <replace from="@php_bin@" to="php_bin" type="pear-config"/> + <replace from="@php_dir@" to="php_dir" type="pear-config"/> + <replace from="@pear_version@" to="version" type="package-info"/> + <replace from="@include_path@" to="php_dir" type="pear-config"/> + </file> + </dir> + <file role="data" name="package.dtd"/> + <file role="data" name="template.spec"/> + <file role="php" name="PEAR.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + <file role="php" name="System.php"> + <replace from="@package_version@" to="version" type="package-info"/> + </file> + </filelist> + </release> + <changelog> + <release> + <version>1.4.0</version> + <date>2005-09-18</date> + <license>PHP License</license> + <state>stable</state> + <notes> + This is a major milestone release for PEAR. In addition to several killer features, + every single element of PEAR has a regression test, and so stability is much higher + than any previous PEAR release. + + New features in a nutshell: + * full support for channels + * pre-download dependency validation + * new package.xml 2.0 format allows tremendous flexibility while maintaining BC + * support for optional dependency groups and limited support for sub-packaging + * robust dependency support + * full dependency validation on uninstall + * remote install for hosts with only ftp access - no more problems with + restricted host installation + * full support for mirroring + * support for bundling several packages into a single tarball + * support for static dependencies on a url-based package + * support for custom file roles and installation tasks + + NOTE: users of PEAR_Frontend_Web/PEAR_Frontend_Gtk must upgrade their installations + to the latest version, or PEAR will not upgrade properly + </notes> + </release> + <release> + <version>1.4.1</version> + <date>2005-09-25</date> + <license>PHP License</license> + <state>stable</state> + <notes> + Major bugfix release. This is a recommended download for ALL PEAR users + + UPGRADING FROM 1.4.0 WILL CAUSE A SERIES OF NOTICES. IGNORE THEM. + THIS IS CAUSED BY A BUG IN 1.4.0 THAT IS FIXED IN 1.4.1 + + * fix prompt processing in post-install scripts + * make dual package.xml equivalency stricter when using package.xml/package2.xml + * fix critical error in validating bogus php dependencies of package.xml 1.0 + This error has existed for every PEAR version, and allows dependencies like: + &lt;dep type=&quot;php&quot; rel=&quot;has&quot;&gt;4.3.0&lt;/dep&gt; to + slip through unnoticed + * re-enable php-const replacements + * PEAR_PackageFile_v2::getConfigureOptions() was missing!! + * fix cvsdiff command + * fix xml encoding issues finally + * clean up package.xml 1.0 dir/file parsing + * fix invalid PEAR_Config generation + * change the user agent from PHP/phpversion to PEAR/pearversion/PHP/phpversion + * don't use a bogus uri for licenses on running convert command + * add &quot;pickle&quot; command for PECL packaging + * add validation warning if the release date in package.xml is not today when packaging + * implement progress bar for list-all/remote-list + * fix Bug #5323: pear search returns odd version numbers + * fix Bug #5428: pear cvstag package2.xml does not include the package.xml + * fix Bug #5449: pear makerpm completely broken for package.xml 2.0 + * fix Bug #5462: raiseError method does not return by ref anymore + * fix Bug #5465: pear install --offline fails to display error + * fix Bug #5477: Bug in Downloader.php and Dependency2.php + * fix Bug #5481: &quot;pear install PECLextension&quot; should display warning to use pecl command + * fix Bug #5482: installation of PECL packages should say add extensions to php.ini + * fix Bug #5483: pecl uninstall crack fatal error + * fix Bug #5487: PECL: compiled files are not uninstalled via the uninstall command + * fix Bug #5488: pecl uninstall package fails if package has a package.xml 1.0 + * fix Bug #5501: the commands list mentions XML-RPC + * fix Bug #5509: addDependecyGroup does not validate group name + * fix Bug #5513: PEAR 1.4 does not install non-pear.php.net packages + </notes> + </release> + <release> + <version>1.4.2</version> + <date>2005-10-08</date> + <license>PHP License</license> + <state>stable</state> + <notes> + Minor bugfix release + + * fix issues with API for adding tasks to package2.xml + * fix Bug #5520: pecl pickle fails on pecl pickle fails on extension/package deps + * fix Bug #5523: pecl pickle misses to put configureoptions into package.xml v1 + * fix Bug #5527: No need for cpp + * fix Bug #5529: configure options in package.xml 2.0 will be ignored + * fix Bug #5530: PEAR_PackageFile_v2->getConfigureOptions() API incompatible with v1 + * fix Bug #5531: adding of installconditions/binarypackage/configure options + to extsrc may fail + * fix Bug #5550: PHP notices/warnings/errors are 1 file off in trace + * fix Bug #5580: pear makerpm XML_sql2xml-0.3.2.tgz error + * fix Bug #5619: pear makerpm produces invalid .spec dependancy code + * fix Bug #5629: pear install http_download dies with bad error message + </notes> + </release> + <release> + <version>1.4.3</version> + <date>2005-11-03</date> + <license>PHP License</license> + <state>stable</state> + <notes> + MINOR SECURITY FIX release + + A security vulnerability has been discovered in all + PEAR versions (1.0 to 1.4.2). This vulnerability has been fixed, + and this is a recommended upgrade for all users. + + Run "pear channel-update" after upgrading for exponentially + faster list-all/remote-list!! + + * fix installation of files named like &quot;.test&quot; + * fix base class for writeable unixeol/windowseol classes + * fix running of post-install scripts with empty or no paramgroup + in CLI frontend + * fix validation of &lt;postinstallscript&gt; + * fix writeable PEAR_Task_Postinstallscript_rw class + * fix error in REST-based search command if searching through description + as well + * silence warning on list-upgrades/upgrade-all if no releases exist at a channel + * add checks for updated channel.xml in all remote commands + * fix pecl script if safe_mode is enabled by default + * implement SERIOUS improvement in list-all/remote-list speed. From 6 minutes + down to about 16-30 seconds + * implement --loose option to avoid recommended version validation + * implement Request #5527: alternative approach to determining glibc version + * fix Bug #5717: analyzeSourceCode() fails to process certain + quote situations properly + * fix Bug #5736: if registry can't lock registry or open filemap, + checkFileMap(), no error + * fix Bug #5676: pear config-create broken + * fix Bug #5683: Deadlock with (almost) circular dependency + * fix Bug #5725: PHP5 warnings need improvement + * fix Bug #5789: small typo + * fix Bug #5810: internet should not be contacted on install if dependencies are installed + </notes> + </release> + <release> + <version>1.4.4</version> + <date>2005-11-04</date> + <license>PHP License</license> + <state>stable</state> + <notes> + * fix Bug #5865: doesn't work with PHP4.2.x + </notes> + </release> + <release> + <version>1.4.5</version> + <date>2005-11-21</date> + <license>PHP License</license> + <state>stable</state> + <notes> + * REALLY fix Bug #5865: doesn't work with PHP4.2.x + * fix Bug #5854: if no installconditions match, no error is raised + * fix Bug #5945: installer should auto-skip to the next channel on timeout + * fix Bug #5947: Some package-info not handled by PEAR_PackageFile_v2 + * fix Bug #5948: Minor typo in PEAR_Validate + * fix Bug #5958: strange error on mistyping + * fix Bug #5959: patch: pear makerpm produces RPMs that do not uninstall/upgrade cleanly + </notes> + </release> + <release> + <version>1.4.6</version> + <date>2006-01-06</date> + <license>PHP License</license> + <state>stable</state> + <notes> + Minor bugfix release + * fix problem with -options when using CGI version of PHP + * fix Critical Bug #5999: support for baseinstalldir broken in package2.xml format + * fix Bug #6034: date format bug + * fix Bug #6040: PEAR_Frontend#setFrontendClass has no docblock; + PEAR_Frontend not documented + * fix Bug #6044: PEAR_REST::retrieveCacheFirst doesn't return error codes + * fix Bug #6047: pear makerpm fails to handle docs in root directory + * fix Bug #6048: PEAR_Frontend::log parameters are wrong + * fix Bug #6106: Notices by list-upgrades (caused by time-outs ?) + * fix Bug #6145: Can't install PEAR with INSTALL_ROOT environment + * fix Bug #6218: the "pear" command does nothing + * fix Bug #6269: System::which() returns silliness if passed null + * fix Bug #6322: Installer fails to follow redirects [patch by Bertrand Gugger] + * fix Request #6119: Add PEAR_Frontend_Gtk2 support to PEAR + </notes> + </release> + <release> + <version>1.4.7</version> + <date>2006-02-27</date> + <license>PHP License</license> + <state>stable</state> + <notes> + Minor bugfix release + * Prevent packaging of release candidate releases with versions like 1.0.0rc1 + version_compare() only understands upper-case 1.0.0RC1 + * implement CLEAN section in .phpt tests + * implement run-tests command for phpunit-based tests + * implement Request #6039: setFrontendObject needed to allow objects passed + * fix Bug #6075: unnecessary validation of maintainers can break PEAR_PFM + * fix Bug #6076: optional is not set for conversion of package2.xml to "has" rel + * fix Bug #6077: PEAR_PackageFile_Parser_v2 should return by reference + * fix Bug #6273: pear download-all fails + * fix Bug #6383: incomplete PEAR::Error message on addReplacement() + * fix Bug #6445: PEAR::registerShutdownFunc doesn't work in static calls + * fix Bug #6480: pear install --installroot option fails for pecl packages [timj] + * fix Bug #6510: status active of a maintainer cannot be change + * fix Bug #6537: wrong export compatible v1 dependencies list with exclude limit + * fix Bug #6559: pear should ignore safemode/open_basedir + * fix Bug #6576: PFM2 run in trouble with sessions + * fix Bug #6579: PFM2 changelog and license with uri + * fix Bug #6673: pear install --offline --packagingroot=/blah does not work + * fix Bug #6674: --packagingroot always uses channel pear.php.net configuration + * fix Bug #6675: postinstallscript validation fails + * fix Bug #6690: channel with / will not allow upgrade + * fix Bug #6692: Optional feature install message needs channel name + * fix Bug #6716: &quot;pear install -r&quot; errors after install when + attempting &quot;pear list &lt;pkgname&gt;&quot; + * fix Bug #6735: PEAR_PackageFile::fromTgzFile doesn't work with package.xml + not in root dir + </notes> + </release> + <release> + <version>1.4.8</version> + <date>2006-03-05</date> + <license>PHP License</license> + <state>stable</state> + <notes> + CRITICAL BUGFIX RELEASE + + Channels with &quot;-&quot; in their name were suddenly invalid, and + caused crashes in many places due to improper error handling + * fix Bug #6960: channels are not allowed to have &quot;-&quot; in their name + * fix critical Bug #6969: PEAR list-upgrades crashes + * fix Bug #6991: Class 'PEAR_PackageFile_v1' not found in Registry.php at line 1657 + * fix Bug #7008: PEAR_Frontend::setFrontendObject doesn't set the object + * fix Bug #7015: install a package.tgz with unknown channel, fatal error in PEAR/Registry.php + * fix Bug #7020: tests/PEAR_Registry/api1_1/test_getChannelValidator.phpt crashes PEAR + </notes> + </release> + <release> + <version>1.4.9</version> + <date>2006-03-29</date> + <license>PHP License</license> + <state>stable</state> + <notes> + CRITICAL BUGFIX RELEASE + users upgrading from PEAR 1.3.x cannot upgrade to 1.4.8 + users who use --packagingroot may find that installation fails + * fix Bug #7093: if pear channel does not exist, it cannot be retrieved + * fix Bug #7165: warnings in pear + * fix Bug #7075: PEAR_PackageFile_v2 :: setLogger failed on autodetection + </notes> + </notes> + </release> + </changelog> +</package> http://cvs.php.net/viewcvs.cgi/pear-core/package2.xml?r1=1.252&r2=1.253&diff_format=u Index: pear-core/package2.xml diff -u pear-core/package2.xml:1.252 pear-core/package2.xml:1.253 --- pear-core/package2.xml:1.252 Mon Mar 27 21:14:28 2006 +++ pear-core/package2.xml Tue Mar 28 03:51:40 2006 @@ -1,838 +1,840 @@ -<?xml version="1.0" encoding="UTF-8"?> -<package version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 -http://pear.php.net/dtd/tasks-1.0.xsd -http://pear.php.net/dtd/package-2.0 -http://pear.php.net/dtd/package-2.0.xsd"> - <name>PEAR</name> - <channel>pear.php.net</channel> - <summary>PEAR Base System</summary> - <description>The PEAR package contains: - * the PEAR installer, for creating, distributing - and installing packages - * the beta-quality PEAR_Exception PHP5 error handling mechanism - * the beta-quality PEAR_ErrorStack advanced error handling mechanism - * the PEAR_Error error handling mechanism - * the OS_Guess class for retrieving info about the OS - where PHP is running on - * the System class for quick handling of common operations - with files and directories - * the PEAR base class - - New features in a nutshell: - * full support for channels - * pre-download dependency validation - * new package.xml 2.0 format allows tremendous flexibility while maintaining BC - * support for optional dependency groups and limited support for sub-packaging - * robust dependency support - * full dependency validation on uninstall - * remote install for hosts with only ftp access - no more problems with - restricted host installation - * full support for mirroring - * support for bundling several packages into a single tarball - * support for static dependencies on a url-based package - * support for custom file roles and installation tasks - - NOTE: users of PEAR_Frontend_Web/PEAR_Frontend_Gtk must upgrade their installations - to the latest version, or PEAR will not upgrade properly - </description> - <lead> - <name>Greg Beaver</name> - <user>cellog</user> - <email>cellog@php.net</email> - <active>yes</active> - </lead> - <lead> - <name>Stig Bakken</name> - <user>ssb</user> - <email>stig@php.net</email> - <active>yes</active> - </lead> - <lead> - <name>Tomas V.V.Cox</name> - <user>cox</user> - <email>cox@idecnet.com</email> - <active>yes</active> - </lead> - <lead> - <name>Pierre-Alain Joye</name> - <user>pajoye</user> - <email>pajoye@pearfr.org</email> - <active>yes</active> - </lead> - <helper> - <name>Tim Jackson</name> - <user>timj</user> - <email>timj@php.net</email> - <active>yes</active> - </helper> - <helper> - <name>Bertrand Gugger</name> - <user>toggg</user> - <email>toggg@php.net</email> - <active>yes</active> - </helper> - <helper> - <name>Martin Jansen</name> - <user>mj</user> - <email>mj@php.net</email> - <active>no</active> - </helper> - <date>2006-05-01</date> - <version> - <release>1.5.0a1</release> - <api>1.5.0</api> - </version> - <stability> - <release>alpha</release> - <api>alpha</api> - </stability> - <license uri="http://www.php.net/license">PHP License</license> - <notes> - Minor feature addition/bugfixes - * fix Bug #7021: Everything must be within &lt;dir name=&quot;/&quot;&gt; - * fix Bug #7196: PEAR crashes when using autoload_prepend_file - * fix Bug #7207: proxy user/pass is not urldecoded in download - * fix Bug #7219: bogus &quot;will download PEAR 1.4.8&quot; error - * implement Request #7090: PEAR_Downloader mustn't contact pear server - when installing local package file - </notes> - <contents> - <dir name="/"> - <dir name="OS"> - <file name="Guess.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - </dir> <!-- /OS --> - <dir name="PEAR"> - <dir name="ChannelFile"> - <file name="Parser.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - </dir> <!-- /PEAR/ChannelFile --> - <dir name="Command"> - <file name="Auth.xml" role="php"/> - <file name="Auth.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Build.xml" role="php"/> - <file name="Build.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Channels.xml" role="php"/> - <file name="Channels.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Common.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Config.xml" role="php"/> - <file name="Config.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Install.xml" role="php"/> - <file name="Install.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Mirror.xml" role="php"/> - <file name="Mirror.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Package.xml" role="php"/> - <file name="Package.php" role="php"> - <tasks:replace from="@DATA-DIR@" to="data_dir" type="pear-config" /> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Pickle.xml" role="php"/> - <file name="Pickle.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Registry.xml" role="php"/> - <file name="Registry.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Remote.xml" role="php"/> - <file name="Remote.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Test.xml" role="php"/> - <file name="Test.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - </dir> <!-- /PEAR/Command --> - <dir name="Downloader"> - <file name="Package.php" role="php"> - <tasks:replace from="@PEAR-VER@" to="version" type="package-info" /> - </file> - </dir> <!-- /PEAR/Downloader --> - <dir name="Frontend"> - <file name="CLI.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - </dir> <!-- /PEAR/Frontend --> - <dir name="Installer"> - <dir name="Role"> - <file name="Common.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Data.xml" role="php"/> - <file name="Data.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Doc.xml" role="php"/> - <file name="Doc.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Ext.xml" role="php"/> - <file name="Ext.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Php.xml" role="php"/> - <file name="Php.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Script.xml" role="php"/> - <file name="Script.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Src.xml" role="php"/> - <file name="Src.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Test.xml" role="php"/> - <file name="Test.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - </dir> <!-- /PEAR/Installer/Role --> - <file name="Role.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - </dir> <!-- /PEAR/Installer --> - <dir name="PackageFile"> - <dir name="Generator"> - <file name="v1.php" role="php"> - <tasks:replace from="@PEAR-VER@" to="version" type="package-info" /> - </file> - <file name="v2.php" role="php"> - <tasks:replace from="@PEAR-VER@" to="version" type="package-info" /> - </file> - </dir> <!-- /PEAR/PackageFile/Generator --> - <dir name="Parser"> - <file name="v1.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="v2.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - </dir> <!-- /PEAR/PackageFile/Parser --> - <dir name="v2"> - <file role="php" name="rw.php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file role="php" name="Validator.php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - </dir> <!-- /PEAR/PackageFile/v2 --> - <file name="v1.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="v2.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - </dir> <!-- /PEAR/PackageFile --> - <dir name="REST"> - <file name="10.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="11.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - </dir> <!-- /PEAR/REST --> - <dir name="Task"> - <dir name="Postinstallscript"> - <file name="rw.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - </dir> <!-- /PEAR/Task/Postinstallscript --> - <dir name="Replace"> - <file name="rw.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - </dir> <!-- /PEAR/Task/Replace --> - <dir name="Unixeol"> - <file name="rw.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - </dir> <!-- /PEAR/Task/Unixeol --> - <dir name="Windowseol"> - <file name="rw.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - </dir> <!-- /PEAR/Task/Windowseol --> - <file name="Common.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Postinstallscript.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Replace.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Unixeol.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Windowseol.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - </dir> <!-- /PEAR/Task --> - <dir name="Validator"> - <file name="PECL.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - </dir> <!-- /PEAR/Validator --> - <file name="Autoloader.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Builder.php" role="php"> - <tasks:replace from="@PEAR-VER@" to="version" type="package-info"/> - </file> - <file name="ChannelFile.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Command.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Common.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Config.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Dependency.php" role="php" /> - <file name="DependencyDB.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Dependency2.php" role="php"> - <tasks:replace from="@PEAR-VER@" to="version" type="package-info"/> - </file> - <file name="Downloader.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="ErrorStack.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Exception.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Frontend.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Installer.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="PackageFile.php" role="php"> - <tasks:replace from="@PEAR-VER@" to="version" type="package-info" /> - </file> - <file name="Packager.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Registry.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Remote.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="REST.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="RunTest.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="Validate.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="XMLParser.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - </dir> <!-- /PEAR --> - <dir name="scripts" baseinstalldir="/"> - <file name="pear.bat" role="script"> - <tasks:replace from="@bin_dir@" to="bin_dir" type="pear-config" /> - <tasks:replace from="@php_bin@" to="php_bin" type="pear-config" /> - <tasks:replace from="@include_path@" to="php_dir" type="pear-config" /> - <tasks:windowseol/> - </file> - <file name="peardev.bat" role="script"> - <tasks:replace from="@bin_dir@" to="bin_dir" type="pear-config" /> - <tasks:replace from="@php_bin@" to="php_bin" type="pear-config" /> - <tasks:replace from="@include_path@" to="php_dir" type="pear-config" /> - <tasks:windowseol/> - </file> - <file name="pecl.bat" role="script"> - <tasks:replace from="@bin_dir@" to="bin_dir" type="pear-config" /> - <tasks:replace from="@php_bin@" to="php_bin" type="pear-config" /> - <tasks:replace from="@include_path@" to="php_dir" type="pear-config" /> - <tasks:windowseol/> - </file> - <file name="pear.sh" role="script"> - <tasks:replace from="@php_bin@" to="php_bin" type="pear-config" /> - <tasks:replace from="@php_dir@" to="php_dir" type="pear-config" /> - <tasks:replace from="@pear_version@" to="version" type="package-info" /> - <tasks:replace from="@include_path@" to="php_dir" type="pear-config" /> - <tasks:unixeol/> - </file> - <file name="peardev.sh" role="script"> - <tasks:replace from="@php_bin@" to="php_bin" type="pear-config" /> - <tasks:replace from="@php_dir@" to="php_dir" type="pear-config" /> - <tasks:replace from="@pear_version@" to="version" type="package-info" /> - <tasks:replace from="@include_path@" to="php_dir" type="pear-config" /> - <tasks:unixeol/> - </file> - <file name="pecl.sh" role="script"> - <tasks:replace from="@php_bin@" to="php_bin" type="pear-config" /> - <tasks:replace from="@php_dir@" to="php_dir" type="pear-config" /> - <tasks:replace from="@pear_version@" to="version" type="package-info" /> - <tasks:replace from="@include_path@" to="php_dir" type="pear-config" /> - <tasks:unixeol/> - </file> - <file name="pearcmd.php" role="php"> - <tasks:replace from="@php_bin@" to="php_bin" type="pear-config" /> - <tasks:replace from="@php_dir@" to="php_dir" type="pear-config" /> - <tasks:replace from="@pear_version@" to="version" type="package-info" /> - <tasks:replace from="@include_path@" to="php_dir" type="pear-config" /> - </file> - <file name="peclcmd.php" role="php"> - <tasks:replace from="@php_bin@" to="php_bin" type="pear-config" /> - <tasks:replace from="@php_dir@" to="php_dir" type="pear-config" /> - <tasks:replace from="@pear_version@" to="version" type="package-info" /> - <tasks:replace from="@include_path@" to="php_dir" type="pear-config" /> - </file> - </dir> <!-- /scripts --> - <file name="package.dtd" role="data" /> - <file name="PEAR.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="System.php" role="php"> - <tasks:replace from="@package_version@" to="version" type="package-info" /> - </file> - <file name="template.spec" role="data" /> - </dir> <!-- / --> - </contents> - <dependencies> - <required> - <php> - <min>4.3.0</min> - </php> - <pearinstaller> - <min>1.4.3</min> - </pearinstaller> - <package> - <name>Archive_Tar</name> - <channel>pear.php.net</channel> - <min>1.1</min> - <recommended>1.3.1</recommended> - <exclude>1.3.0</exclude> - </package> - <package> - <name>Console_Getopt</name> - <channel>pear.php.net</channel> - <min>1.2</min> - <recommended>1.2</recommended> - </package> - <package> - <name>PEAR_Frontend_Web</name> - <channel>pear.php.net</channel> - <max>0.5.0</max> - <exclude>0.5.0</exclude> - <conflicts/> - </package> - <package> - <name>PEAR_Frontend_Gtk</name> - <channel>pear.php.net</channel> - <max>0.4.0</max> - <exclude>0.4.0</exclude> - <conflicts/> - </package> - <extension> - <name>xml</name> - </extension> - <extension> - <name>pcre</name> - </extension> - </required> - <optional> - <package> - <name>XML_RPC</name> - <channel>pear.php.net</channel> - <min>1.4.0</min> - </package> - </optional> -<!-- <group name="remoteinstall" hint="adds the ability to install packages to a remote ftp server"> - <subpackage> - <name>PEAR_RemoteInstaller</name> - <channel>pear.php.net</channel> - <min>0.1.0</min> - <recommended>0.1.0</recommended> - </subpackage> - </group> --> - <group name="webinstaller" hint="PEAR's web-based installer"> - <package> - <name>PEAR_Frontend_Web</name> - <channel>pear.php.net</channel> - <min>0.5.0</min> - </package> - </group> - <group name="gtkinstaller" hint="PEAR's PHP-GTK-based installer"> - <package> - <name>PEAR_Frontend_Gtk</name> - <channel>pear.php.net</channel> - <min>0.4.0</min> - </package> - </group> - <group name="gtk2installer" hint="PEAR's PHP-GTK2-based installer"> - <package> - <name>PEAR_Frontend_Gtk2</name> - <channel>pear.php.net</channel> - </package> - </group> - </dependencies> - <phprelease> - <installconditions> - <os> - <name>windows</name> - </os> - </installconditions> - <filelist> - <install as="pear.bat" name="scripts/pear.bat" /> - <install as="peardev.bat" name="scripts/peardev.bat" /> - <install as="pecl.bat" name="scripts/pecl.bat" /> - <install as="pearcmd.php" name="scripts/pearcmd.php" /> - <install as="peclcmd.php" name="scripts/peclcmd.php" /> - <ignore name="scripts/peardev.sh" /> - <ignore name="scripts/pear.sh" /> - <ignore name="scripts/pecl.sh" /> - </filelist> - </phprelease> - <phprelease> - <filelist> - <install as="pear" name="scripts/pear.sh" /> - <install as="peardev" name="scripts/peardev.sh" /> - <install as="pecl" name="scripts/pecl.sh" /> - <install as="pearcmd.php" name="scripts/pearcmd.php" /> - <install as="peclcmd.php" name="scripts/peclcmd.php" /> - <ignore name="scripts/pear.bat" /> - <ignore name="scripts/peardev.bat" /> - <ignore name="scripts/pecl.bat" /> - </filelist> - </phprelease> - <changelog> - <release> - <version> - <release>1.4.0</release> - <api>1.4.0</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2005-09-18</date> - <license uri="http://www.php.net/license/3_0.txt">PHP License</license> - <notes> - This is a major milestone release for PEAR. In addition to several killer features, - every single element of PEAR has a regression test, and so stability is much higher - than any previous PEAR release. - - New features in a nutshell: - * full support for channels - * pre-download dependency validation - * new package.xml 2.0 format allows tremendous flexibility while maintaining BC - * support for optional dependency groups and limited support for sub-packaging - * robust dependency support - * full dependency validation on uninstall - * remote install for hosts with only ftp access - no more problems with - restricted host installation [through PEAR_RemoteInstaller package] - * full support for mirroring - * support for bundling several packages into a single tarball - * support for static dependencies on a uri-based package - * support for custom file roles and installation tasks - - NOTE: users of PEAR_Frontend_Web/PEAR_Frontend_Gtk must upgrade their installations - to the latest version, or PEAR will not upgrade properly - </notes> - </release> - <release> - <version> - <release>1.4.1</release> - <api>1.4.0</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2005-09-25</date> - <license uri="http://www.php.net/license/3_0.txt">PHP License</license> - <notes> - Major bugfix release. This is a recommended download for ALL PEAR users - - UPGRADING FROM 1.4.0 WILL CAUSE A SERIES OF NOTICES. IGNORE THEM. - THIS IS CAUSED BY A BUG IN 1.4.0 THAT IS FIXED IN 1.4.1 - - * fix prompt processing in post-install scripts - * make dual package.xml equivalency stricter when using package.xml/package2.xml - * fix critical error in validating bogus php dependencies of package.xml 1.0 - This error has existed for every PEAR version, and allows dependencies like: - &lt;dep type=&quot;php&quot; rel=&quot;has&quot;&gt;4.3.0&lt;/dep&gt; to - slip through unnoticed - * re-enable php-const replacements - * PEAR_PackageFile_v2::getConfigureOptions() was missing!! - * fix cvsdiff command - * fix xml encoding issues finally - * clean up package.xml 1.0 dir/file parsing - * fix invalid PEAR_Config generation - * change the user agent from PHP/phpversion to PEAR/pearversion/PHP/phpversion - * don't use a bogus uri for licenses on running convert command - * add &quot;pickle&quot; command for PECL packaging - * add validation warning if the release date in package.xml is not today when packaging - * implement progress bar for list-all/remote-list - * fix Bug #5323: pear search returns odd version numbers - * fix Bug #5428: pear cvstag package2.xml does not include the package.xml - * fix Bug #5449: pear makerpm completely broken for package.xml 2.0 - * fix Bug #5462: raiseError method does not return by ref anymore - * fix Bug #5465: pear install --offline fails to display error - * fix Bug #5477: Bug in Downloader.php and Dependency2.php - * fix Bug #5481: &quot;pear install PECLextension&quot; should display warning to use pecl command - * fix Bug #5482: installation of PECL packages should say add extensions to php.ini - * fix Bug #5483: pecl uninstall crack fatal error - * fix Bug #5487: PECL: compiled files are not uninstalled via the uninstall command - * fix Bug #5488: pecl uninstall package fails if package has a package.xml 1.0 - * fix Bug #5501: the commands list mentions XML-RPC - * fix Bug #5509: addDependecyGroup does not validate group name - * fix Bug #5513: PEAR 1.4 does not install non-pear.php.net packages - </notes> - </release> - <release> - <version> - <release>1.4.2</release> - <api>1.4.0</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2005-10-08</date> - <license uri="http://www.php.net/license/3_0.txt">PHP License</license> - <notes> - Minor bugfix release - - * fix issues with API for adding tasks to package2.xml - * fix Bug #5520: pecl pickle fails on pecl pickle fails on extension/package deps - * fix Bug #5523: pecl pickle misses to put configureoptions into package.xml v1 - * fix Bug #5527: No need for cpp - * fix Bug #5529: configure options in package.xml 2.0 will be ignored - * fix Bug #5530: PEAR_PackageFile_v2->getConfigureOptions() API incompatible with v1 - * fix Bug #5531: adding of installconditions/binarypackage/configure options - to extsrc may fail - * fix Bug #5550: PHP notices/warnings/errors are 1 file off in trace - * fix Bug #5580: pear makerpm XML_sql2xml-0.3.2.tgz error - * fix Bug #5619: pear makerpm produces invalid .spec dependancy code - * fix Bug #5629: pear install http_download dies with bad error message - </notes> - </release> - <release> - <version> - <release>1.4.3</release> - <api>1.4.1</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2005-11-03</date> - <license uri="http://www.php.net/license/3_0.txt">PHP License</license> - <notes> - MINOR SECURITY FIX release - - A security vulnerability has been discovered in all - PEAR versions (1.0 to 1.4.2). This vulnerability has been fixed, - and this is a recommended upgrade for all users. - - Run "pear channel-update" after upgrading for exponentially - faster list-all/remote-list!! - - * fix installation of files named like &quot;.test&quot; - * fix base class for writeable unixeol/windowseol classes - * fix running of post-install scripts with empty or no paramgroup - in CLI frontend - * fix validation of &lt;postinstallscript&gt; - * fix writeable PEAR_Task_Postinstallscript_rw class - * fix error in REST-based search command if searching through description - as well - * silence warning on list-upgrades/upgrade-all if no releases exist at a channel - * add checks for updated channel.xml in all remote commands - * fix pecl script if safe_mode is enabled by default - * implement SERIOUS improvement in list-all/remote-list speed. From 6 minutes - down to about 16-30 seconds - * implement --loose option to avoid recommended version validation - * implement Request #5527: alternative approach to determining glibc version - * fix Bug #5717: analyzeSourceCode() fails to process certain - quote situations properly - * fix Bug #5736: if registry can't lock registry or open filemap, - checkFileMap(), no error - * fix Bug #5676: pear config-create broken - * fix Bug #5683: Deadlock with (almost) circular dependency - * fix Bug #5725: PHP5 warnings need improvement - * fix Bug #5789: small typo - * fix Bug #5810: internet should not be contacted on install if dependencies are installed - </notes> - </release> - <release> - <version> - <release>1.4.4</release> - <api>1.4.1</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2005-11-04</date> - <license uri="http://www.php.net/license/3_0.txt">PHP License</license> - <notes> - * fix Bug #5865: doesn't work with PHP4.2.x - </notes> - </release> - <release> - <version> - <release>1.4.5</release> - <api>1.4.1</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2005-11-21</date> - <license uri="http://www.php.net/license/3_0.txt">PHP License</license> - <notes> - * REALLY fix Bug #5865: doesn't work with PHP4.2.x - * fix Bug #5854: if no installconditions match, no error is raised - * fix Bug #5945: installer should auto-skip to the next channel on timeout - * fix Bug #5947: Some package-info not handled by PEAR_PackageFile_v2 - * fix Bug #5948: Minor typo in PEAR_Validate - * fix Bug #5958: strange error on mistyping - * fix Bug #5959: patch: pear makerpm produces RPMs that do not uninstall/upgrade cleanly - </notes> - </release> - <release> - <version> - <release>1.4.6</release> - <api>1.4.1</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2006-01-06</date> - <license uri="http://www.php.net/license/3_0.txt">PHP License</license> - <notes> - Minor bugfix release - * fix problem with -options when using CGI version of PHP - * fix Critical Bug #5999: support for baseinstalldir broken in package2.xml format - * fix Bug #6034: date format bug - * fix Bug #6040: PEAR_Frontend#setFrontendClass has no docblock; - PEAR_Frontend not documented - * fix Bug #6044: PEAR_REST::retrieveCacheFirst doesn't return error codes - * fix Bug #6047: pear makerpm fails to handle docs in root directory - * fix Bug #6048: PEAR_Frontend::log parameters are wrong - * fix Bug #6106: Notices by list-upgrades (caused by time-outs ?) - * fix Bug #6145: Can't install PEAR with INSTALL_ROOT environment - * fix Bug #6218: the "pear" command does nothing - * fix Bug #6269: System::which() returns silliness if passed null - * fix Bug #6322: Installer fails to follow redirects [patch by Bertrand Gugger] - * fix Request #6119: Add PEAR_Frontend_Gtk2 support to PEAR - </notes> - </release> - <release> - <version> - <release>1.4.7</release> - <api>1.4.1</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2006-02-27</date> - <license uri="http://www.php.net/license/3_0.txt">PHP License</license> - <notes> - Minor bugfix release - * Prevent packaging of release candidate releases with versions like 1.0.0rc1 - version_compare() only understands upper-case 1.0.0RC1 - * implement CLEAN section in .phpt tests - * implement run-tests command for phpunit-based tests - * implement Request #6039: setFrontendObject needed to allow objects passed - * fix Bug #6075: unnecessary validation of maintainers can break PEAR_PFM - * fix Bug #6076: optional is not set for conversion of package2.xml to "has" rel - * fix Bug #6077: PEAR_PackageFile_Parser_v2 should return by reference - * fix Bug #6273: pear download-all fails - * fix Bug #6383: incomplete PEAR::Error message on addReplacement() - * fix Bug #6445: PEAR::registerShutdownFunc doesn't work in static calls - * fix Bug #6480: pear install --installroot option fails for pecl packages [timj] - * fix Bug #6510: status active of a maintainer cannot be change - * fix Bug #6537: wrong export compatible v1 dependencies list with exclude limit - * fix Bug #6559: pear should ignore safemode/open_basedir - * fix Bug #6576: PFM2 run in trouble with sessions - * fix Bug #6579: PFM2 changelog and license with uri - * fix Bug #6673: pear install --offline --packagingroot=/blah does not work - * fix Bug #6674: --packagingroot always uses channel pear.php.net configuration - * fix Bug #6675: postinstallscript validation fails - * fix Bug #6690: channel with / will not allow upgrade - * fix Bug #6692: Optional feature install message needs channel name - * fix Bug #6716: &quot;pear install -r&quot; errors after install when - attempting &quot;pear list &lt;pkgname&gt;&quot; - * fix Bug #6735: PEAR_PackageFile::fromTgzFile doesn't work with package.xml - not in root dir - </notes> - </release> - <release> - <version> - <release>1.4.8</release> - <api>1.4.2</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2006-03-05</date> - <license uri="http://www.php.net/license/3_0.txt">PHP License</license> - <notes> - CRITICAL BUGFIX RELEASE - - Channels with &quot;-&quot; in their name were suddenly invalid, and - caused crashes in many places due to improper error handling - * fix Bug #6960: channels are not allowed to have &quot;-&quot; in their name - * fix critical Bug #6969: PEAR list-upgrades crashes - * fix Bug #6991: Class 'PEAR_PackageFile_v1' not found in Registry.php at line 1657 - * fix Bug #7008: PEAR_Frontend::setFrontendObject doesn't set the object - * fix Bug #7015: install a package.tgz with unknown channel, fatal error in PEAR/Registry.php - * fix Bug #7020: tests/PEAR_Registry/api1_1/test_getChannelValidator.phpt crashes PEAR - </notes> - </release> - <release> - <version> - <release>1.4.9</release> - <api>1.4.2</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2006-03-29</date> - <license uri="http://www.php.net/license">PHP License</license> - <notes> - CRITICAL BUGFIX RELEASE - users upgrading from PEAR 1.3.x cannot upgrade to 1.4.8 - users who use --packagingroot may find that installation fails - * fix Bug #7093: if pear channel does not exist, it cannot be retrieved - * fix Bug #7165: warnings in pear - * fix Bug #7075: PEAR_PackageFile_v2 :: setLogger failed on autodetection - </notes> - </release> - </changelog> -</package> +<?xml version="1.0" encoding="UTF-8"?> +<package version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 +http://pear.php.net/dtd/tasks-1.0.xsd +http://pear.php.net/dtd/package-2.0 +http://pear.php.net/dtd/package-2.0.xsd"> + <name>PEAR</name> + <channel>pear.php.net</channel> + <summary>PEAR Base System</summary> + <description>The PEAR package contains: + * the PEAR installer, for creating, distributing + and installing packages + * the beta-quality PEAR_Exception PHP5 error handling mechanism + * the beta-quality PEAR_ErrorStack advanced error handling mechanism + * the PEAR_Error error handling mechanism + * the OS_Guess class for retrieving info about the OS + where PHP is running on + * the System class for quick handling of common operations + with files and directories + * the PEAR base class + + New features in a nutshell: + * full support for channels + * pre-download dependency validation + * new package.xml 2.0 format allows tremendous flexibility while maintaining BC + * support for optional dependency groups and limited support for sub-packaging + * robust dependency support + * full dependency validation on uninstall + * remote install for hosts with only ftp access - no more problems with + restricted host installation + * full support for mirroring + * support for bundling several packages into a single tarball + * support for static dependencies on a url-based package + * support for custom file roles and installation tasks + + NOTE: users of PEAR_Frontend_Web/PEAR_Frontend_Gtk must upgrade their installations + to the latest version, or PEAR will not upgrade properly + </description> + <lead> + <name>Greg Beaver</name> + <user>cellog</user> + <email>cellog@php.net</email> + <active>yes</active> + </lead> + <lead> + <name>Stig Bakken</name> + <user>ssb</user> + <email>stig@php.net</email> + <active>yes</active> + </lead> + <lead> + <name>Tomas V.V.Cox</name> + <user>cox</user> + <email>cox@idecnet.com</email> + <active>yes</active> + </lead> + <lead> + <name>Pierre-Alain Joye</name> + <user>pajoye</user> + <email>pajoye@pearfr.org</email> + <active>yes</active> + </lead> + <helper> + <name>Tim Jackson</name> + <user>timj</user> + <email>timj@php.net</email> + <active>yes</active> + </helper> + <helper> + <name>Bertrand Gugger</name> + <user>toggg</user> + <email>toggg@php.net</email> + <active>yes</active> + </helper> + <helper> + <name>Martin Jansen</name> + <user>mj</user> + <email>mj@php.net</email> + <active>no</active> + </helper> + <date>2006-05-01</date> + <version> + <release>1.5.0a1</release> + <api>1.5.0</api> + </version> + <stability> + <release>alpha</release> + <api>alpha</api> + </stability> + <license uri="http://www.php.net/license">PHP License</license> + <notes> + Minor feature addition/bugfixes + * fix Bug #6931: pear upgrade PEAR-alpha tries to upgrade to 1.4.0a12 + * fix Bug #7021: Everything must be within &lt;dir name=&quot;/&quot;&gt; + * fix Bug #7196: PEAR crashes when using autoload_prepend_file + * fix Bug #7207: proxy user/pass is not urldecoded in download + * fix Bug #7219: bogus &quot;will download PEAR 1.4.8&quot; error + * fix Bug #7221: pear install blah-alpha won't install a newer stable + * implement Request #7090: PEAR_Downloader mustn't contact pear server + when installing local package file + </notes> + <contents> + <dir name="/"> + <dir name="OS"> + <file name="Guess.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + </dir> <!-- /OS --> + <dir name="PEAR"> + <dir name="ChannelFile"> + <file name="Parser.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + </dir> <!-- /PEAR/ChannelFile --> + <dir name="Command"> + <file name="Auth.xml" role="php"/> + <file name="Auth.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Build.xml" role="php"/> + <file name="Build.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Channels.xml" role="php"/> + <file name="Channels.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Common.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Config.xml" role="php"/> + <file name="Config.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Install.xml" role="php"/> + <file name="Install.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Mirror.xml" role="php"/> + <file name="Mirror.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Package.xml" role="php"/> + <file name="Package.php" role="php"> + <tasks:replace from="@DATA-DIR@" to="data_dir" type="pear-config" /> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Pickle.xml" role="php"/> + <file name="Pickle.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Registry.xml" role="php"/> + <file name="Registry.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Remote.xml" role="php"/> + <file name="Remote.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Test.xml" role="php"/> + <file name="Test.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + </dir> <!-- /PEAR/Command --> + <dir name="Downloader"> + <file name="Package.php" role="php"> + <tasks:replace from="@PEAR-VER@" to="version" type="package-info" /> + </file> + </dir> <!-- /PEAR/Downloader --> + <dir name="Frontend"> + <file name="CLI.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + </dir> <!-- /PEAR/Frontend --> + <dir name="Installer"> + <dir name="Role"> + <file name="Common.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Data.xml" role="php"/> + <file name="Data.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Doc.xml" role="php"/> + <file name="Doc.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Ext.xml" role="php"/> + <file name="Ext.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Php.xml" role="php"/> + <file name="Php.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Script.xml" role="php"/> + <file name="Script.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Src.xml" role="php"/> + <file name="Src.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Test.xml" role="php"/> + <file name="Test.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + </dir> <!-- /PEAR/Installer/Role --> + <file name="Role.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + </dir> <!-- /PEAR/Installer --> + <dir name="PackageFile"> + <dir name="Generator"> + <file name="v1.php" role="php"> + <tasks:replace from="@PEAR-VER@" to="version" type="package-info" /> + </file> + <file name="v2.php" role="php"> + <tasks:replace from="@PEAR-VER@" to="version" type="package-info" /> + </file> + </dir> <!-- /PEAR/PackageFile/Generator --> + <dir name="Parser"> + <file name="v1.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="v2.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + </dir> <!-- /PEAR/PackageFile/Parser --> + <dir name="v2"> + <file role="php" name="rw.php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file role="php" name="Validator.php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + </dir> <!-- /PEAR/PackageFile/v2 --> + <file name="v1.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="v2.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + </dir> <!-- /PEAR/PackageFile --> + <dir name="REST"> + <file name="10.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="11.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + </dir> <!-- /PEAR/REST --> + <dir name="Task"> + <dir name="Postinstallscript"> + <file name="rw.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + </dir> <!-- /PEAR/Task/Postinstallscript --> + <dir name="Replace"> + <file name="rw.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + </dir> <!-- /PEAR/Task/Replace --> + <dir name="Unixeol"> + <file name="rw.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + </dir> <!-- /PEAR/Task/Unixeol --> + <dir name="Windowseol"> + <file name="rw.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + </dir> <!-- /PEAR/Task/Windowseol --> + <file name="Common.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Postinstallscript.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Replace.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Unixeol.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Windowseol.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + </dir> <!-- /PEAR/Task --> + <dir name="Validator"> + <file name="PECL.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + </dir> <!-- /PEAR/Validator --> + <file name="Autoloader.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Builder.php" role="php"> + <tasks:replace from="@PEAR-VER@" to="version" type="package-info"/> + </file> + <file name="ChannelFile.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Command.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Common.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Config.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Dependency.php" role="php" /> + <file name="DependencyDB.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Dependency2.php" role="php"> + <tasks:replace from="@PEAR-VER@" to="version" type="package-info"/> + </file> + <file name="Downloader.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="ErrorStack.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Exception.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Frontend.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Installer.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="PackageFile.php" role="php"> + <tasks:replace from="@PEAR-VER@" to="version" type="package-info" /> + </file> + <file name="Packager.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Registry.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Remote.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="REST.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="RunTest.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="Validate.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="XMLParser.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + </dir> <!-- /PEAR --> + <dir name="scripts" baseinstalldir="/"> + <file name="pear.bat" role="script"> + <tasks:replace from="@bin_dir@" to="bin_dir" type="pear-config" /> + <tasks:replace from="@php_bin@" to="php_bin" type="pear-config" /> + <tasks:replace from="@include_path@" to="php_dir" type="pear-config" /> + <tasks:windowseol/> + </file> + <file name="peardev.bat" role="script"> + <tasks:replace from="@bin_dir@" to="bin_dir" type="pear-config" /> + <tasks:replace from="@php_bin@" to="php_bin" type="pear-config" /> + <tasks:replace from="@include_path@" to="php_dir" type="pear-config" /> + <tasks:windowseol/> + </file> + <file name="pecl.bat" role="script"> + <tasks:replace from="@bin_dir@" to="bin_dir" type="pear-config" /> + <tasks:replace from="@php_bin@" to="php_bin" type="pear-config" /> + <tasks:replace from="@include_path@" to="php_dir" type="pear-config" /> + <tasks:windowseol/> + </file> + <file name="pear.sh" role="script"> + <tasks:replace from="@php_bin@" to="php_bin" type="pear-config" /> + <tasks:replace from="@php_dir@" to="php_dir" type="pear-config" /> + <tasks:replace from="@pear_version@" to="version" type="package-info" /> + <tasks:replace from="@include_path@" to="php_dir" type="pear-config" /> + <tasks:unixeol/> + </file> + <file name="peardev.sh" role="script"> + <tasks:replace from="@php_bin@" to="php_bin" type="pear-config" /> + <tasks:replace from="@php_dir@" to="php_dir" type="pear-config" /> + <tasks:replace from="@pear_version@" to="version" type="package-info" /> + <tasks:replace from="@include_path@" to="php_dir" type="pear-config" /> + <tasks:unixeol/> + </file> + <file name="pecl.sh" role="script"> + <tasks:replace from="@php_bin@" to="php_bin" type="pear-config" /> + <tasks:replace from="@php_dir@" to="php_dir" type="pear-config" /> + <tasks:replace from="@pear_version@" to="version" type="package-info" /> + <tasks:replace from="@include_path@" to="php_dir" type="pear-config" /> + <tasks:unixeol/> + </file> + <file name="pearcmd.php" role="php"> + <tasks:replace from="@php_bin@" to="php_bin" type="pear-config" /> + <tasks:replace from="@php_dir@" to="php_dir" type="pear-config" /> + <tasks:replace from="@pear_version@" to="version" type="package-info" /> + <tasks:replace from="@include_path@" to="php_dir" type="pear-config" /> + </file> + <file name="peclcmd.php" role="php"> + <tasks:replace from="@php_bin@" to="php_bin" type="pear-config" /> + <tasks:replace from="@php_dir@" to="php_dir" type="pear-config" /> + <tasks:replace from="@pear_version@" to="version" type="package-info" /> + <tasks:replace from="@include_path@" to="php_dir" type="pear-config" /> + </file> + </dir> <!-- /scripts --> + <file name="package.dtd" role="data" /> + <file name="PEAR.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="System.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file name="template.spec" role="data" /> + </dir> <!-- / --> + </contents> + <dependencies> + <required> + <php> + <min>4.3.0</min> + </php> + <pearinstaller> + <min>1.4.3</min> + </pearinstaller> + <package> + <name>Archive_Tar</name> + <channel>pear.php.net</channel> + <min>1.1</min> + <recommended>1.3.1</recommended> + <exclude>1.3.0</exclude> + </package> + <package> + <name>Console_Getopt</name> + <channel>pear.php.net</channel> + <min>1.2</min> + <recommended>1.2</recommended> + </package> + <package> + <name>PEAR_Frontend_Web</name> + <channel>pear.php.net</channel> + <max>0.5.0</max> + <exclude>0.5.0</exclude> + <conflicts/> + </package> + <package> + <name>PEAR_Frontend_Gtk</name> + <channel>pear.php.net</channel> + <max>0.4.0</max> + <exclude>0.4.0</exclude> + <conflicts/> + </package> + <extension> + <name>xml</name> + </extension> + <extension> + <name>pcre</name> + </extension> + </required> + <optional> + <package> + <name>XML_RPC</name> + <channel>pear.php.net</channel> + <min>1.4.0</min> + </package> + </optional> +<!-- <group name="remoteinstall" hint="adds the ability to install packages to a remote ftp server"> + <subpackage> + <name>PEAR_RemoteInstaller</name> + <channel>pear.php.net</channel> + <min>0.1.0</min> + <recommended>0.1.0</recommended> + </subpackage> + </group> --> + <group name="webinstaller" hint="PEAR's web-based installer"> + <package> + <name>PEAR_Frontend_Web</name> + <channel>pear.php.net</channel> + <min>0.5.0</min> + </package> + </group> + <group name="gtkinstaller" hint="PEAR's PHP-GTK-based installer"> + <package> + <name>PEAR_Frontend_Gtk</name> + <channel>pear.php.net</channel> + <min>0.4.0</min> + </package> + </group> + <group name="gtk2installer" hint="PEAR's PHP-GTK2-based installer"> + <package> + <name>PEAR_Frontend_Gtk2</name> + <channel>pear.php.net</channel> + </package> + </group> + </dependencies> + <phprelease> + <installconditions> + <os> + <name>windows</name> + </os> + </installconditions> + <filelist> + <install as="pear.bat" name="scripts/pear.bat" /> + <install as="peardev.bat" name="scripts/peardev.bat" /> + <install as="pecl.bat" name="scripts/pecl.bat" /> + <install as="pearcmd.php" name="scripts/pearcmd.php" /> + <install as="peclcmd.php" name="scripts/peclcmd.php" /> + <ignore name="scripts/peardev.sh" /> + <ignore name="scripts/pear.sh" /> + <ignore name="scripts/pecl.sh" /> + </filelist> + </phprelease> + <phprelease> + <filelist> + <install as="pear" name="scripts/pear.sh" /> + <install as="peardev" name="scripts/peardev.sh" /> + <install as="pecl" name="scripts/pecl.sh" /> + <install as="pearcmd.php" name="scripts/pearcmd.php" /> + <install as="peclcmd.php" name="scripts/peclcmd.php" /> + <ignore name="scripts/pear.bat" /> + <ignore name="scripts/peardev.bat" /> + <ignore name="scripts/pecl.bat" /> + </filelist> + </phprelease> + <changelog> + <release> + <version> + <release>1.4.0</release> + <api>1.4.0</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <date>2005-09-18</date> + <license uri="http://www.php.net/license/3_0.txt">PHP License</license> + <notes> + This is a major milestone release for PEAR. In addition to several killer features, + every single element of PEAR has a regression test, and so stability is much higher + than any previous PEAR release. + + New features in a nutshell: + * full support for channels + * pre-download dependency validation + * new package.xml 2.0 format allows tremendous flexibility while maintaining BC + * support for optional dependency groups and limited support for sub-packaging + * robust dependency support + * full dependency validation on uninstall + * remote install for hosts with only ftp access - no more problems with + restricted host installation [through PEAR_RemoteInstaller package] + * full support for mirroring + * support for bundling several packages into a single tarball + * support for static dependencies on a uri-based package + * support for custom file roles and installation tasks + + NOTE: users of PEAR_Frontend_Web/PEAR_Frontend_Gtk must upgrade their installations + to the latest version, or PEAR will not upgrade properly + </notes> + </release> + <release> + <version> + <release>1.4.1</release> + <api>1.4.0</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <date>2005-09-25</date> + <license uri="http://www.php.net/license/3_0.txt">PHP License</license> + <notes> + Major bugfix release. This is a recommended download for ALL PEAR users + + UPGRADING FROM 1.4.0 WILL CAUSE A SERIES OF NOTICES. IGNORE THEM. + THIS IS CAUSED BY A BUG IN 1.4.0 THAT IS FIXED IN 1.4.1 + + * fix prompt processing in post-install scripts + * make dual package.xml equivalency stricter when using package.xml/package2.xml + * fix critical error in validating bogus php dependencies of package.xml 1.0 + This error has existed for every PEAR version, and allows dependencies like: + &lt;dep type=&quot;php&quot; rel=&quot;has&quot;&gt;4.3.0&lt;/dep&gt; to + slip through unnoticed + * re-enable php-const replacements + * PEAR_PackageFile_v2::getConfigureOptions() was missing!! + * fix cvsdiff command + * fix xml encoding issues finally + * clean up package.xml 1.0 dir/file parsing + * fix invalid PEAR_Config generation + * change the user agent from PHP/phpversion to PEAR/pearversion/PHP/phpversion + * don't use a bogus uri for licenses on running convert command + * add &quot;pickle&quot; command for PECL packaging + * add validation warning if the release date in package.xml is not today when packaging + * implement progress bar for list-all/remote-list + * fix Bug #5323: pear search returns odd version numbers + * fix Bug #5428: pear cvstag package2.xml does not include the package.xml + * fix Bug #5449: pear makerpm completely broken for package.xml 2.0 + * fix Bug #5462: raiseError method does not return by ref anymore + * fix Bug #5465: pear install --offline fails to display error + * fix Bug #5477: Bug in Downloader.php and Dependency2.php + * fix Bug #5481: &quot;pear install PECLextension&quot; should display warning to use pecl command + * fix Bug #5482: installation of PECL packages should say add extensions to php.ini + * fix Bug #5483: pecl uninstall crack fatal error + * fix Bug #5487: PECL: compiled files are not uninstalled via the uninstall command + * fix Bug #5488: pecl uninstall package fails if package has a package.xml 1.0 + * fix Bug #5501: the commands list mentions XML-RPC + * fix Bug #5509: addDependecyGroup does not validate group name + * fix Bug #5513: PEAR 1.4 does not install non-pear.php.net packages + </notes> + </release> + <release> + <version> + <release>1.4.2</release> + <api>1.4.0</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <date>2005-10-08</date> + <license uri="http://www.php.net/license/3_0.txt">PHP License</license> + <notes> + Minor bugfix release + + * fix issues with API for adding tasks to package2.xml + * fix Bug #5520: pecl pickle fails on pecl pickle fails on extension/package deps + * fix Bug #5523: pecl pickle misses to put configureoptions into package.xml v1 + * fix Bug #5527: No need for cpp + * fix Bug #5529: configure options in package.xml 2.0 will be ignored + * fix Bug #5530: PEAR_PackageFile_v2->getConfigureOptions() API incompatible with v1 + * fix Bug #5531: adding of installconditions/binarypackage/configure options + to extsrc may fail + * fix Bug #5550: PHP notices/warnings/errors are 1 file off in trace + * fix Bug #5580: pear makerpm XML_sql2xml-0.3.2.tgz error + * fix Bug #5619: pear makerpm produces invalid .spec dependancy code + * fix Bug #5629: pear install http_download dies with bad error message + </notes> + </release> + <release> + <version> + <release>1.4.3</release> + <api>1.4.1</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <date>2005-11-03</date> + <license uri="http://www.php.net/license/3_0.txt">PHP License</license> + <notes> + MINOR SECURITY FIX release + + A security vulnerability has been discovered in all + PEAR versions (1.0 to 1.4.2). This vulnerability has been fixed, + and this is a recommended upgrade for all users. + + Run "pear channel-update" after upgrading for exponentially + faster list-all/remote-list!! + + * fix installation of files named like &quot;.test&quot; + * fix base class for writeable unixeol/windowseol classes + * fix running of post-install scripts with empty or no paramgroup + in CLI frontend + * fix validation of &lt;postinstallscript&gt; + * fix writeable PEAR_Task_Postinstallscript_rw class + * fix error in REST-based search command if searching through description + as well + * silence warning on list-upgrades/upgrade-all if no releases exist at a channel + * add checks for updated channel.xml in all remote commands + * fix pecl script if safe_mode is enabled by default + * implement SERIOUS improvement in list-all/remote-list speed. From 6 minutes + down to about 16-30 seconds + * implement --loose option to avoid recommended version validation + * implement Request #5527: alternative approach to determining glibc version + * fix Bug #5717: analyzeSourceCode() fails to process certain + quote situations properly + * fix Bug #5736: if registry can't lock registry or open filemap, + checkFileMap(), no error + * fix Bug #5676: pear config-create broken + * fix Bug #5683: Deadlock with (almost) circular dependency + * fix Bug #5725: PHP5 warnings need improvement + * fix Bug #5789: small typo + * fix Bug #5810: internet should not be contacted on install if dependencies are installed + </notes> + </release> + <release> + <version> + <release>1.4.4</release> + <api>1.4.1</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <date>2005-11-04</date> + <license uri="http://www.php.net/license/3_0.txt">PHP License</license> + <notes> + * fix Bug #5865: doesn't work with PHP4.2.x + </notes> + </release> + <release> + <version> + <release>1.4.5</release> + <api>1.4.1</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <date>2005-11-21</date> + <license uri="http://www.php.net/license/3_0.txt">PHP License</license> + <notes> + * REALLY fix Bug #5865: doesn't work with PHP4.2.x + * fix Bug #5854: if no installconditions match, no error is raised + * fix Bug #5945: installer should auto-skip to the next channel on timeout + * fix Bug #5947: Some package-info not handled by PEAR_PackageFile_v2 + * fix Bug #5948: Minor typo in PEAR_Validate + * fix Bug #5958: strange error on mistyping + * fix Bug #5959: patch: pear makerpm produces RPMs that do not uninstall/upgrade cleanly + </notes> + </release> + <release> + <version> + <release>1.4.6</release> + <api>1.4.1</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <date>2006-01-06</date> + <license uri="http://www.php.net/license/3_0.txt">PHP License</license> + <notes> + Minor bugfix release + * fix problem with -options when using CGI version of PHP + * fix Critical Bug #5999: support for baseinstalldir broken in package2.xml format + * fix Bug #6034: date format bug + * fix Bug #6040: PEAR_Frontend#setFrontendClass has no docblock; + PEAR_Frontend not documented + * fix Bug #6044: PEAR_REST::retrieveCacheFirst doesn't return error codes + * fix Bug #6047: pear makerpm fails to handle docs in root directory + * fix Bug #6048: PEAR_Frontend::log parameters are wrong + * fix Bug #6106: Notices by list-upgrades (caused by time-outs ?) + * fix Bug #6145: Can't install PEAR with INSTALL_ROOT environment + * fix Bug #6218: the "pear" command does nothing + * fix Bug #6269: System::which() returns silliness if passed null + * fix Bug #6322: Installer fails to follow redirects [patch by Bertrand Gugger] + * fix Request #6119: Add PEAR_Frontend_Gtk2 support to PEAR + </notes> + </release> + <release> + <version> + <release>1.4.7</release> + <api>1.4.1</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <date>2006-02-27</date> + <license uri="http://www.php.net/license/3_0.txt">PHP License</license> + <notes> + Minor bugfix release + * Prevent packaging of release candidate releases with versions like 1.0.0rc1 + version_compare() only understands upper-case 1.0.0RC1 + * implement CLEAN section in .phpt tests + * implement run-tests command for phpunit-based tests + * implement Request #6039: setFrontendObject needed to allow objects passed + * fix Bug #6075: unnecessary validation of maintainers can break PEAR_PFM + * fix Bug #6076: optional is not set for conversion of package2.xml to "has" rel + * fix Bug #6077: PEAR_PackageFile_Parser_v2 should return by reference + * fix Bug #6273: pear download-all fails + * fix Bug #6383: incomplete PEAR::Error message on addReplacement() + * fix Bug #6445: PEAR::registerShutdownFunc doesn't work in static calls + * fix Bug #6480: pear install --installroot option fails for pecl packages [timj] + * fix Bug #6510: status active of a maintainer cannot be change + * fix Bug #6537: wrong export compatible v1 dependencies list with exclude limit + * fix Bug #6559: pear should ignore safemode/open_basedir + * fix Bug #6576: PFM2 run in trouble with sessions + * fix Bug #6579: PFM2 changelog and license with uri + * fix Bug #6673: pear install --offline --packagingroot=/blah does not work + * fix Bug #6674: --packagingroot always uses channel pear.php.net configuration + * fix Bug #6675: postinstallscript validation fails + * fix Bug #6690: channel with / will not allow upgrade + * fix Bug #6692: Optional feature install message needs channel name + * fix Bug #6716: &quot;pear install -r&quot; errors after install when + attempting &quot;pear list &lt;pkgname&gt;&quot; + * fix Bug #6735: PEAR_PackageFile::fromTgzFile doesn't work with package.xml + not in root dir + </notes> + </release> + <release> + <version> + <release>1.4.8</release> + <api>1.4.2</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <date>2006-03-05</date> + <license uri="http://www.php.net/license/3_0.txt">PHP License</license> + <notes> + CRITICAL BUGFIX RELEASE + + Channels with &quot;-&quot; in their name were suddenly invalid, and + caused crashes in many places due to improper error handling + * fix Bug #6960: channels are not allowed to have &quot;-&quot; in their name + * fix critical Bug #6969: PEAR list-upgrades crashes + * fix Bug #6991: Class 'PEAR_PackageFile_v1' not found in Registry.php at line 1657 + * fix Bug #7008: PEAR_Frontend::setFrontendObject doesn't set the object + * fix Bug #7015: install a package.tgz with unknown channel, fatal error in PEAR/Registry.php + * fix Bug #7020: tests/PEAR_Registry/api1_1/test_getChannelValidator.phpt crashes PEAR + </notes> + </release> + <release> + <version> + <release>1.4.9</release> + <api>1.4.2</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <date>2006-03-29</date> + <license uri="http://www.php.net/license">PHP License</license> + <notes> + CRITICAL BUGFIX RELEASE + users upgrading from PEAR 1.3.x cannot upgrade to 1.4.8 + users who use --packagingroot may find that installation fails + * fix Bug #7093: if pear channel does not exist, it cannot be retrieved + * fix Bug #7165: warnings in pear + * fix Bug #7075: PEAR_PackageFile_v2 :: setLogger failed on autodetection + </notes> + </release> + </changelog> +</package> http://cvs.php.net/viewcvs.cgi/pear-core/PEAR/Downloader.php?r1=1.103&r2=1.104&diff_format=u Index: pear-core/PEAR/Downloader.php diff -u pear-core/PEAR/Downloader.php:1.103 pear-core/PEAR/Downloader.php:1.104 --- pear-core/PEAR/Downloader.php:1.103 Mon Mar 27 05:53:16 2006 +++ pear-core/PEAR/Downloader.php Tue Mar 28 03:51:40 2006 @@ -1,1515 +1,1526 @@ -<?php -/** - * PEAR_Downloader, the PEAR Installer's download utility class - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 3.0 of the PHP license - * that is available through the world-wide-web at the following URI: - * http://www.php.net/license/3_0.txt. If you did not receive a copy of - * the PHP License and are unable to obtain it through the web, please - * send a note to license@php.net so we can mail you a copy immediately. - * - * @category pear - * @package PEAR - * @author Greg Beaver <cellog@php.net> - * @author Stig Bakken <ssb@php.net> - * @author Tomas V. V. Cox <cox@idecnet.com> - * @author Martin Jansen <mj@php.net> - * @copyright 1997-2006 The PHP Group - * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Downloader.php,v 1.103 2006/03/27 05:53:16 cellog Exp $ - * @link http://pear.php.net/package/PEAR - * @since File available since Release 1.3.0 - */ - -/** - * Needed for constants, extending - */ -require_once 'PEAR/Common.php'; - -define('PEAR_INSTALLER_OK', 1); -define('PEAR_INSTALLER_FAILED', 0); -define('PEAR_INSTALLER_SKIPPED', -1); -define('PEAR_INSTALLER_ERROR_NO_PREF_STATE', 2); - -/** - * Administration class used to download anything from the internet (PEAR Packages, - * static URLs, xml files) - * - * @category pear - * @package PEAR - * @author Greg Beaver <cellog@php.net> - * @author Stig Bakken <ssb@php.net> - * @author Tomas V. V. Cox <cox@idecnet.com> - * @author Martin Jansen <mj@php.net> - * @copyright 1997-2006 The PHP Group - * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version Release: @package_version@ - * @link http://pear.php.net/package/PEAR - * @since Class available since Release 1.3.0 - */ -class PEAR_Downloader extends PEAR_Common -{ - /** - * @var PEAR_Registry - * @access private - */ - var $_registry; - - /** - * @var PEAR_Remote - * @access private - */ - var $_remote; - - /** - * Preferred Installation State (snapshot, devel, alpha, beta, stable) - * @var string|null - * @access private - */ - var $_preferredState; - - /** - * Options from command-line passed to Install. - * - * Recognized options:<br /> - * - onlyreqdeps : install all required dependencies as well - * - alldeps : install all dependencies, including optional - * - installroot : base relative path to install files in - * - force : force a download even if warnings would prevent it - * - nocompress : download uncompressed tarballs - * @see PEAR_Command_Install - * @access private - * @var array - */ - var $_options; - - /** - * Downloaded Packages after a call to download(). - * - * Format of each entry: - * - * <code> - * array('pkg' => 'package_name', 'file' => '/path/to/local/file', - * 'info' => array() // parsed package.xml - * ); - * </code> - * @access private - * @var array - */ - var $_downloadedPackages = array(); - - /** - * Packages slated for download. - * - * This is used to prevent downloading a package more than once should it be a dependency - * for two packages to be installed. - * Format of each entry: - * - * <pre> - * array('package_name1' => parsed package.xml, 'package_name2' => parsed package.xml, - * ); - * </pre> - * @access private - * @var array - */ - var $_toDownload = array(); - - /** - * Array of every package installed, with names lower-cased. - * - * Format: - * <code> - * array('package1' => 0, 'package2' => 1, ); - * </code> - * @var array - */ - var $_installed = array(); - - /** - * @var array - * @access private - */ - var $_errorStack = array(); - - /** - * @var boolean - * @access private - */ - var $_internalDownload = false; - - /** - * Temporary variable used in sorting packages by dependency in {@link sortPkgDeps()} - * @var array - * @access private - */ - var $_packageSortTree; - - /** - * Temporary directory, or configuration value where downloads will occur - * @var string - */ - var $_downloadDir; - // {{{ PEAR_Downloader() - - /** - * @param PEAR_Frontend_* - * @param array - * @param PEAR_Config - */ - function PEAR_Downloader(&$ui, $options, &$config) - { - parent::PEAR_Common(); - $this->_options = $options; - $this->config = &$config; - $this->_preferredState = $this->config->get('preferred_state'); - $this->ui = &$ui; - if (!$this->_preferredState) { - // don't inadvertantly use a non-set preferred_state - $this->_preferredState = null; - } - - if (isset($this->_options['installroot'])) { - $this->config->setInstallRoot($this->_options['installroot']); - } - $this->_registry = &$config->getRegistry(); - $this->_remote = &$config->getRemote(); - - if (isset($this->_options['alldeps']) || isset($this->_options['onlyreqdeps'])) { - $this->_installed = $this->_registry->listAllPackages(); - foreach ($this->_installed as $key => $unused) { - if (!count($unused)) { - continue; - } - $strtolower = create_function('$a','return strtolower($a);'); - array_walk($this->_installed[$key], $strtolower); - } - } - } - - /** - * Attempt to discover a channel's remote capabilities from - * its server name - * @param string - * @return boolean - */ - function discover($channel) - { - $this->log(1, 'Attempting to discover channel "' . $channel . '"...'); - PEAR::pushErrorHandling(PEAR_ERROR_RETURN); - $callback = $this->ui ? array(&$this, '_downloadCallback') : null; - if (!class_exists('System')) { - require_once 'System.php'; - } - $a = $this->downloadHttp('http://' . $channel . '/channel.xml', $this->ui, - System::mktemp(array('-d')), $callback, false); - PEAR::popErrorHandling(); - if (PEAR::isError($a)) { - return false; - } - list($a, $lastmodified) = $a; - if (!class_exists('PEAR/ChannelFile.php')) { - require_once 'PEAR/ChannelFile.php'; - } - $b = new PEAR_ChannelFile; - if ($b->fromXmlFile($a)) { - unlink($a); - if ($this->config->get('auto_discover')) { - $this->_registry->addChannel($b, $lastmodified); - $alias = $b->getName(); - if ($b->getName() == $this->_registry->channelName($b->getAlias())) { - $alias = $b->getAlias(); - } - $this->log(1, 'Auto-discovered channel "' . $channel . - '", alias "' . $alias . '", adding to registry'); - } - return true; - } - unlink($a); - return false; - } - - /** - * For simpler unit-testing - * @param PEAR_Downloader - * @return PEAR_Downloader_Package - */ - function &newDownloaderPackage(&$t) - { - if (!class_exists('PEAR_Downloader_Package')) { - require_once 'PEAR/Downloader/Package.php'; - } - $a = &new PEAR_Downloader_Package($t); - return $a; - } - - /** - * For simpler unit-testing - * @param PEAR_Config - * @param array - * @param array - * @param int - */ - function &getDependency2Object(&$c, $i, $p, $s) - { - if (!class_exists('PEAR/Dependency2.php')) { - require_once 'PEAR/Dependency2.php'; - } - $z = &new PEAR_Dependency2($c, $i, $p, $s); - return $z; - } - - function &download($params) - { - if (!count($params)) { - $a = array(); - return $a; - } - if (!isset($this->_registry)) { - $this->_registry = &$this->config->getRegistry(); - } - if (!isset($this->_remote)) { - $this->_remote = &$this->config->getRemote(); - } - $channelschecked = array(); - // convert all parameters into PEAR_Downloader_Package objects - foreach ($params as $i => $param) { - $params[$i] = &$this->newDownloaderPackage($this); - PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); - $err = $params[$i]->initialize($param); - PEAR::staticPopErrorHandling(); - if (!$err) { - // skip parameters that were missed by preferred_state - continue; - } - if (PEAR::isError($err)) { - if (!isset($this->_options['soft'])) { - $this->log(0, $err->getMessage()); - } - $params[$i] = false; - if (is_object($param)) { - $param = $param->getChannel() . '/' . $param->getPackage(); - } - $this->pushError('Package "' . $param . '" is not valid', - PEAR_INSTALLER_SKIPPED); - } else { - do { - if ($params[$i] && $params[$i]->getType() == 'local') { - // bug #7090 - // skip channel.xml check for local packages - break; - } - if ($params[$i] && !isset($channelschecked[$params[$i]->getChannel()]) && - !isset($this->_options['offline'])) { - $channelschecked[$params[$i]->getChannel()] = true; - PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); - if (!class_exists('System')) { - require_once 'System.php'; - } - $curchannel = &$this->_registry->getChannel($params[$i]->getChannel()); - if (PEAR::isError($curchannel)) { - PEAR::staticPopErrorHandling(); - return $this->raiseError($curchannel); - } - $a = $this->downloadHttp('http://' . $params[$i]->getChannel() . - '/channel.xml', $this->ui, - System::mktemp(array('-d')), null, $curchannel->lastModified()); - PEAR::staticPopErrorHandling(); - if (PEAR::isError($a) || !$a) { - break; - } - $this->log(0, 'WARNING: channel "' . $params[$i]->getChannel() . '" has ' . - 'updated its protocols, use "channel-update ' . $params[$i]->getChannel() . - '" to update'); - } - } while (false); - if ($params[$i] && !isset($this->_options['downloadonly'])) { - if (isset($this->_options['packagingroot'])) { - $checkdir = $this->_prependPath( - $this->config->get('php_dir', null, $params[$i]->getChannel()), - $this->_options['packagingroot']); - } else { - $checkdir = $this->config->get('php_dir', - null, $params[$i]->getChannel()); - } - while ($checkdir && $checkdir != '/' && !file_exists($checkdir)) { - $checkdir = dirname($checkdir); - } - if ($checkdir == '.') { - $checkdir = '/'; - } - if (!is_writeable($checkdir)) { - return PEAR::raiseError('Cannot install, php_dir for channel "' . - $params[$i]->getChannel() . '" is not writeable by the current user'); - } - } - } - } - unset($channelschecked); - PEAR_Downloader_Package::removeDuplicates($params); - if (!count($params)) { - $a = array(); - return $a; - } - if (!isset($this->_options['nodeps']) && !isset($this->_options['offline'])) { - $reverify = true; - while ($reverify) { - $reverify = false; - foreach ($params as $i => $param) { - $ret = $params[$i]->detectDependencies($params); - if (PEAR::isError($ret)) { - $reverify = true; - $params[$i] = false; - PEAR_Downloader_Package::removeDuplicates($params); - if (!isset($this->_options['soft'])) { - $this->log(0, $ret->getMessage()); - } - continue 2; - } - } - } - } - if (isset($this->_options['offline'])) { - $this->log(3, 'Skipping dependency download check, --offline specified'); - } - if (!count($params)) { - $a = array(); - return $a; - } - while (PEAR_Downloader_Package::mergeDependencies($params)); - PEAR_Downloader_Package::removeInstalled($params); - if (!count($params)) { - $this->pushError('No valid packages found', PEAR_INSTALLER_FAILED); - $a = array(); - return $a; - } - PEAR::pushErrorHandling(PEAR_ERROR_RETURN); - $err = $this->analyzeDependencies($params); - PEAR::popErrorHandling(); - if (!count($params)) { - $this->pushError('No valid packages found', PEAR_INSTALLER_FAILED); - $a = array(); - return $a; - } - $ret = array(); - $newparams = array(); - if (isset($this->_options['pretend'])) { - return $params; - } - foreach ($params as $i => $package) { - PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); - $pf = &$params[$i]->download(); - PEAR::staticPopErrorHandling(); - if (PEAR::isError($pf)) { - if (!isset($this->_options['soft'])) { - $this->log(1, $pf->getMessage()); - $this->log(0, 'Error: cannot download "' . - $this->_registry->parsedPackageNameToString($package->getParsedPackage(), - true) . - '"'); - } - continue; - } - $newparams[] = &$params[$i]; - $ret[] = array('file' => $pf->getArchiveFile(), - 'info' => &$pf, - 'pkg' => $pf->getPackage()); - } - $this->_downloadedPackages = $ret; - return $newparams; - } - - /** - * @param array all packages to be installed - */ - function analyzeDependencies(&$params) - { - $hasfailed = $failed = false; - if (isset($this->_options['downloadonly'])) { - return; - } - PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); - $redo = true; - $reset = false; - while ($redo) { - $redo = false; - foreach ($params as $i => $param) { - $deps = $param->getDeps(); - if (!$deps) { - $depchecker = &$this->getDependency2Object($this->config, $this->getOptions(), - $param->getParsedPackage(), PEAR_VALIDATE_DOWNLOADING); - if ($param->getType() == 'xmlrpc') { - $send = $param->getDownloadURL(); - } else { - $send = $param->getPackageFile(); - } - $installcheck = $depchecker->validatePackage($send, $this, $params); - if (PEAR::isError($installcheck)) { - if (!isset($this->_options['soft'])) { - $this->log(0, $installcheck->getMessage()); - } - $hasfailed = true; - $params[$i] = false; - $reset = true; - $redo = true; - $failed = false; - PEAR_Downloader_Package::removeDuplicates($params); - continue 2; - } - continue; - } - if (!$reset && $param->alreadyValidated()) { - continue; - } - if (count($deps)) { - $depchecker = &$this->getDependency2Object($this->config, $this->getOptions(), - $param->getParsedPackage(), PEAR_VALIDATE_DOWNLOADING); - if ($param->getType() == 'xmlrpc') { - $send = $param->getDownloadURL(); - } else { - $send = $param->getPackageFile(); - } - $installcheck = $depchecker->validatePackage($send, $this, $params); - if (PEAR::isError($installcheck)) { - if (!isset($this->_options['soft'])) { - $this->log(0, $installcheck->getMessage()); - } - $hasfailed = true; - $params[$i] = false; - $reset = true; - $redo = true; - $failed = false; - PEAR_Downloader_Package::removeDuplicates($params); - continue 2; - } - $failed = false; - if (isset($deps['required'])) { - foreach ($deps['required'] as $type => $dep) { - // note: Dependency2 will never return a PEAR_Error if ignore-errors - // is specified, so soft is needed to turn off logging - if (!isset($dep[0])) { - if (PEAR::isError($e = $depchecker->{"validate{$type}Dependency"}($dep, - true, $params))) { - $failed = true; - if (!isset($this->_options['soft'])) { - $this->log(0, $e->getMessage()); - } - } elseif (is_array($e) && !$param->alreadyValidated()) { - if (!isset($this->_options['soft'])) { - $this->log(0, $e[0]); - } - } - } else { - foreach ($dep as $d) { - if (PEAR::isError($e = - $depchecker->{"validate{$type}Dependency"}($d, - true, $params))) { - $failed = true; - if (!isset($this->_options['soft'])) { - $this->log(0, $e->getMessage()); - } - } elseif (is_array($e) && !$param->alreadyValidated()) { - if (!isset($this->_options['soft'])) { - $this->log(0, $e[0]); - } - } - } - } - } - if (isset($deps['optional'])) { - foreach ($deps['optional'] as $type => $dep) { - if (!isset($dep[0])) { - if (PEAR::isError($e = - $depchecker->{"validate{$type}Dependency"}($dep, - false, $params))) { - $failed = true; - if (!isset($this->_options['soft'])) { - $this->log(0, $e->getMessage()); - } - } elseif (is_array($e) && !$param->alreadyValidated()) { - if (!isset($this->_options['soft'])) { - $this->log(0, $e[0]); - } - } - } else { - foreach ($dep as $d) { - if (PEAR::isError($e = - $depchecker->{"validate{$type}Dependency"}($d, - false, $params))) { - $failed = true; - if (!isset($this->_options['soft'])) { - $this->log(0, $e->getMessage()); - } - } elseif (is_array($e) && !$param->alreadyValidated()) { - if (!isset($this->_options['soft'])) { - $this->log(0, $e[0]); - } - } - } - } - } - } - $groupname = $param->getGroup(); - if (isset($deps['group']) && $groupname) { - if (!isset($deps['group'][0])) { - $deps['group'] = array($deps['group']); - } - $found = false; - foreach ($deps['group'] as $group) { - if ($group['attribs']['name'] == $groupname) { - $found = true; - break; - } - } - if ($found) { - unset($group['attribs']); - foreach ($group as $type => $dep) { - if (!isset($dep[0])) { - if (PEAR::isError($e = - $depchecker->{"validate{$type}Dependency"}($dep, - false, $params))) { - $failed = true; - if (!isset($this->_options['soft'])) { - $this->log(0, $e->getMessage()); - } - } elseif (is_array($e) && !$param->alreadyValidated()) { - if (!isset($this->_options['soft'])) { - $this->log(0, $e[0]); - } - } - } else { - foreach ($dep as $d) { - if (PEAR::isError($e = - $depchecker->{"validate{$type}Dependency"}($d, - false, $params))) { - $failed = true; - if (!isset($this->_options['soft'])) { - $this->log(0, $e->getMessage()); - } - } elseif (is_array($e) && !$param->alreadyValidated()) { - if (!isset($this->_options['soft'])) { - $this->log(0, $e[0]); - } - } - } - } - } - } - } - } else { - foreach ($deps as $dep) { - if (PEAR::isError($e = $depchecker->validateDependency1($dep, $params))) { - $failed = true; - if (!isset($this->_options['soft'])) { - $this->log(0, $e->getMessage()); - } - } elseif (is_array($e) && !$param->alreadyValidated()) { - if (!isset($this->_options['soft'])) { - $this->log(0, $e[0]); - } - } - } - } - $params[$i]->setValidated(); - } - if ($failed) { - $hasfailed = true; - $params[$i] = false; - $reset = true; - $redo = true; - $failed = false; - PEAR_Downloader_Package::removeDuplicates($params); - continue 2; - } - } - } - PEAR::staticPopErrorHandling(); - if ($hasfailed && (isset($this->_options['ignore-errors']) || - isset($this->_options['nodeps']))) { - // this is probably not needed, but just in case - if (!isset($this->_options['soft'])) { - $this->log(0, 'WARNING: dependencies failed'); - } - } - } - - /** - * Retrieve the directory that downloads will happen in - * @access private - * @return string - */ - function getDownloadDir() - { - if (isset($this->_downloadDir)) { - return $this->_downloadDir; - } - $downloaddir = $this->config->get('download_dir'); - if (empty($downloaddir)) { - if (!class_exists('System')) { - require_once 'System.php'; - } - if (PEAR::isError($downloaddir = System::mktemp('-d'))) { - return $downloaddir; - } - $this->log(3, '+ tmp dir created at ' . $downloaddir); - } - return $this->_downloadDir = $downloaddir; - } - - function setDownloadDir($dir) - { - $this->_downloadDir = $dir; - } - - // }}} - // {{{ configSet() - function configSet($key, $value, $layer = 'user', $channel = false) - { - $this->config->set($key, $value, $layer, $channel); - $this->_preferredState = $this->config->get('preferred_state', null, $channel); - if (!$this->_preferredState) { - // don't inadvertantly use a non-set preferred_state - $this->_preferredState = null; - } - } - - // }}} - // {{{ setOptions() - function setOptions($options) - { - $this->_options = $options; - } - - // }}} - // {{{ setOptions() - function getOptions() - { - return $this->_options; - } - - // }}} - - /** - * For simpler unit-testing - * @param PEAR_Config - * @param int - * @param string - */ - function &getPackagefileObject(&$c, $d, $t = false) - { - if (!class_exists('PEAR_PackageFile')) { - require_once 'PEAR/PackageFile.php'; - } - $a = &new PEAR_PackageFile($c, $d, $t); - return $a; - } - - // {{{ _getPackageDownloadUrl() - - /** - * @param array output of {@link parsePackageName()} - * @access private - */ - function _getPackageDownloadUrl($parr) - { - $curchannel = $this->config->get('default_channel'); - $this->configSet('default_channel', $parr['channel']); - // getDownloadURL returns an array. On error, it only contains information - // on the latest release as array(version, info). On success it contains - // array(version, info, download url string) - $state = isset($parr['state']) ? $parr['state'] : $this->config->get('preferred_state'); - if (!$this->_registry->channelExists($parr['channel'])) { - do { - if ($this->config->get('auto_discover')) { - if ($this->discover($parr['channel'])) { - break; - } - } - $this->configSet('default_channel', $curchannel); - return PEAR::raiseError('Unknown remote channel: ' . $remotechannel); - } while (false); - } - $chan = &$this->_registry->getChannel($parr['channel']); - if (PEAR::isError($chan)) { - return $chan; - } - $version = $this->_registry->packageInfo($parr['package'], 'version', - $parr['channel']); - if ($chan->supportsREST($this->config->get('preferred_mirror')) && - $base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) { - $rest = &$this->config->getREST('1.0', $this->_options); - if (!isset($parr['version']) && !isset($parr['state']) && $version - && !isset($this->_options['downloadonly'])) { - $url = $rest->getDownloadURL($base, $parr, $state, $version); - } else { - $url = $rest->getDownloadURL($base, $parr, $state, false); - } - if (PEAR::isError($url)) { - $this->configSet('default_channel', $curchannel); - return $url; - } - if ($parr['channel'] != $curchannel) { - $this->configSet('default_channel', $curchannel); - } - if (!is_array($url)) { - return $url; - } - $url['raw'] = false; // no checking is necessary for REST - if (!is_array($url['info'])) { - return PEAR::raiseError('Invalid remote dependencies retrieved from REST - ' . - 'this should never happen'); - } - if (isset($url['info']['required']) || $url['compatible']) { - require_once 'PEAR/PackageFile/v2.php'; - $pf = new PEAR_PackageFile_v2; - $pf->setRawChannel($parr['channel']); - if ($url['compatible']) { - $pf->setRawCompatible($url['compatible']); - } - } else { - require_once 'PEAR/PackageFile/v1.php'; - $pf = new PEAR_PackageFile_v1; - } - $pf->setRawPackage($url['package']); - $pf->setDeps($url['info']); - $pf->setRawState($url['stability']); - $url['info'] = &$pf; - if (!extension_loaded("zlib") || isset($this->_options['nocompress'])) { - $ext = '.tar'; - } else { - $ext = '.tgz'; - } - if (is_array($url)) { - if (isset($url['url'])) { - $url['url'] .= $ext; - } - } - return $url; - } elseif ($chan->supports('xmlrpc', 'package.getDownloadURL', false, '1.1')) { - // don't install with the old version information unless we're doing a plain - // vanilla simple installation. If the user says to install a particular - // version or state, ignore the current installed version - if (!isset($parr['version']) && !isset($parr['state']) && $version - && !isset($this->_options['downloadonly'])) { - $url = $this->_remote->call('package.getDownloadURL', $parr, $state, $version); - } else { - $url = $this->_remote->call('package.getDownloadURL', $parr, $state); - } - } else { - $url = $this->_remote->call('package.getDownloadURL', $parr, $state); - } - if (PEAR::isError($url)) { - return $url; - } - if ($parr['channel'] != $curchannel) { - $this->configSet('default_channel', $curchannel); - } - if (isset($url['__PEAR_ERROR_CLASS__'])) { - return PEAR::raiseError($url['message']); - } - if (!is_array($url)) { - return $url; - } - $url['raw'] = $url['info']; - if (isset($this->_options['downloadonly'])) { - $pkg = &$this->getPackagefileObject($this->config, $this->debug); - } else { - $pkg = &$this->getPackagefileObject($this->config, $this->debug, - $this->getDownloadDir()); - } - PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); - $pinfo = &$pkg->fromXmlString($url['info'], PEAR_VALIDATE_DOWNLOADING, 'remote'); - PEAR::staticPopErrorHandling(); - if (PEAR::isError($pinfo)) { - if (!isset($this->_options['soft'])) { - $this->log(0, $pinfo->getMessage()); - } - return PEAR::raiseError('Remote package.xml is not valid - this should never happen'); - } - $url['info'] = &$pinfo; - if (!extension_loaded("zlib") || isset($this->_options['nocompress'])) { - $ext = '.tar'; - } else { - $ext = '.tgz'; - } - if (is_array($url)) { - if (isset($url['url'])) { - $url['url'] .= $ext; - } - } - return $url; - } - // }}} - // {{{ getDepPackageDownloadUrl() - - /** - * @param array dependency array - * @access private - */ - function _getDepPackageDownloadUrl($dep, $parr) - { - $xsdversion = isset($dep['rel']) ? '1.0' : '2.0'; - $curchannel = $this->config->get('default_channel'); - if (isset($dep['channel'])) { - $remotechannel = $dep['channel']; - } else { - $remotechannel = 'pear.php.net'; - } - if (!$this->_registry->channelExists($remotechannel)) { - do { - if ($this->config->get('auto_discover')) { - if ($this->discover($remotechannel)) { - break; - } - } - return PEAR::raiseError('Unknown remote channel: ' . $remotechannel); - } while (false); - } - $this->configSet('default_channel', $remotechannel); - $state = isset($parr['state']) ? $parr['state'] : $this->config->get('preferred_state'); - if (isset($parr['state']) && isset($parr['version'])) { - unset($parr['state']); - } - $chan = &$this->_registry->getChannel($remotechannel); - if (PEAR::isError($chan)) { - return $chan; - } - $version = $this->_registry->packageInfo($dep['name'], 'version', - $remotechannel); - if ($chan->supportsREST($this->config->get('preferred_mirror')) && - $base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) { - $rest = &$this->config->getREST('1.0', $this->_options); - $url = $rest->getDepDownloadURL($base, $xsdversion, $dep, $parr, - $state, $version); - if (PEAR::isError($url)) { - return $url; - } - if ($parr['channel'] != $curchannel) { - $this->configSet('default_channel', $curchannel); - } - if (!is_array($url)) { - return $url; - } - $url['raw'] = false; // no checking is necessary for REST - if (!is_array($url['info'])) { - return PEAR::raiseError('Invalid remote dependencies retrieved from REST - ' . - 'this should never happen'); - } - if (isset($url['info']['required'])) { - if (!class_exists('PEAR_PackageFile_v2')) { - require_once 'PEAR/PackageFile/v2.php'; - } - $pf = new PEAR_PackageFile_v2; - $pf->setRawChannel($remotechannel); - } else { - if (!class_exists('PEAR_PackageFile_v1')) { - require_once 'PEAR/PackageFile/v1.php'; - } - $pf = new PEAR_PackageFile_v1; - } - $pf->setRawPackage($url['package']); - $pf->setDeps($url['info']); - $pf->setRawState($url['stability']); - $url['info'] = &$pf; - if (!extension_loaded("zlib") || isset($this->_options['nocompress'])) { - $ext = '.tar'; - } else { - $ext = '.tgz'; - } - if (is_array($url)) { - if (isset($url['url'])) { - $url['url'] .= $ext; - } - } - return $url; - } elseif ($chan->supports('xmlrpc', 'package.getDepDownloadURL', false, '1.1')) { - if ($version) { - $url = $this->_remote->call('package.getDepDownloadURL', $xsdversion, $dep, $parr, - $state, $version); - } else { - $url = $this->_remote->call('package.getDepDownloadURL', $xsdversion, $dep, $parr, - $state); - } - } else { - $url = $this->_remote->call('package.getDepDownloadURL', $xsdversion, $dep, $parr, $state); - } - if ($parr['channel'] != $curchannel) { - $this->configSet('default_channel', $curchannel); - } - if (!is_array($url)) { - return $url; - } - if (isset($url['__PEAR_ERROR_CLASS__'])) { - return PEAR::raiseError($url['message']); - } - $url['raw'] = $url['info']; - $pkg = &$this->getPackagefileObject($this->config, $this->debug); - PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); - $pinfo = &$pkg->fromXmlString($url['info'], PEAR_VALIDATE_DOWNLOADING, 'remote'); - PEAR::staticPopErrorHandling(); - if (PEAR::isError($pinfo)) { - if (!isset($this->_options['soft'])) { - $this->log(0, $pinfo->getMessage()); - } - return PEAR::raiseError('Remote package.xml is not valid - this should never happen'); - } - $url['info'] = &$pinfo; - if (is_array($url)) { - if (!extension_loaded("zlib") || isset($this->_options['nocompress'])) { - $ext = '.tar'; - } else { - $ext = '.tgz'; - } - if (isset($url['url'])) { - $url['url'] .= $ext; - } - } - return $url; - } - // }}} - // {{{ getPackageDownloadUrl() - - /** - * @deprecated in favor of _getPackageDownloadUrl - */ - function getPackageDownloadUrl($package, $version = null, $channel = false) - { - if ($version) { - $package .= "-$version"; - } - if ($this === null || $this->_registry === null) { - $package = "http://pear.php.net/get/$package"; - } else { - $chan = $this->_registry->getChannel($channel); - if (PEAR::isError($chan)) { - return ''; - } - $package = "http://" . $chan->getServer() . "/get/$package"; - } - if (!extension_loaded("zlib")) { - $package .= '?uncompress=yes'; - } - return $package; - } - - // }}} - // {{{ getDownloadedPackages() - - /** - * Retrieve a list of downloaded packages after a call to {@link download()}. - * - * Also resets the list of downloaded packages. - * @return array - */ - function getDownloadedPackages() - { - $ret = $this->_downloadedPackages; - $this->_downloadedPackages = array(); - $this->_toDownload = array(); - return $ret; - } - - // }}} - // {{{ _downloadCallback() - - function _downloadCallback($msg, $params = null) - { - switch ($msg) { - case 'saveas': - $this->log(1, "downloading $params ..."); - break; - case 'done': - $this->log(1, '...done: ' . number_format($params, 0, '', ',') . ' bytes'); - break; - case 'bytesread': - static $bytes; - if (empty($bytes)) { - $bytes = 0; - } - if (!($bytes % 10240)) { - $this->log(1, '.', false); - } - $bytes += $params; - break; - case 'start': - $this->log(1, "Starting to download {$params[0]} (".number_format($params[1], 0, '', ',')." bytes)"); - break; - } - if (method_exists($this->ui, '_downloadCallback')) - $this->ui->_downloadCallback($msg, $params); - } - - // }}} - // {{{ _prependPath($path, $prepend) - - function _prependPath($path, $prepend) - { - if (strlen($prepend) > 0) { - if (OS_WINDOWS && preg_match('/^[a-z]:/i', $path)) { - if (preg_match('/^[a-z]:/i', $prepend)) { - $prepend = substr($prepend, 2); - } elseif ($prepend{0} != '\\') { - $prepend = "\\$prepend"; - } - $path = substr($path, 0, 2) . $prepend . substr($path, 2); - } else { - $path = $prepend . $path; - } - } - return $path; - } - // }}} - // {{{ pushError($errmsg, $code) - - /** - * @param string - * @param integer - */ - function pushError($errmsg, $code = -1) - { - array_push($this->_errorStack, array($errmsg, $code)); - } - - // }}} - // {{{ getErrorMsgs() - - function getErrorMsgs() - { - $msgs = array(); - $errs = $this->_errorStack; - foreach ($errs as $err) { - $msgs[] = $err[0]; - } - $this->_errorStack = array(); - return $msgs; - } - - // }}} - - /** - * for BC - */ - function sortPkgDeps(&$packages, $uninstall = false) - { - $uninstall ? - $this->sortPackagesForUninstall($packages) : - $this->sortPackagesForInstall($packages); - } - - function _getDepTreeDP($package, $packages, &$deps, &$checked) - { - $pf = $package->getPackageFile(); - $checked[strtolower($package->getChannel())][strtolower($package->getPackage())] - = true; - $pdeps = $pf->getDeps(true); - if (!$pdeps) { - return; - } - if ($pf->getPackagexmlVersion() == '1.0') { - foreach ($pdeps as $dep) { - if ($dep['type'] != 'pkg') { - continue; - } - $deps['pear.php.net'][strtolower($dep['name'])] = true; - foreach ($packages as $p) { - $dep['channel'] = 'pear.php.net'; - $dep['package'] = $dep['name']; - if ($p->isEqual($dep)) { - if (!isset($checked[strtolower($p->getChannel())] - [strtolower($p->getPackage())])) { - // add the dependency's dependencies to the tree - $this->_getDepTreeDP($p, $packages, $deps, $checked); - } - } - } - } - } else { - $tdeps = array(); - if (isset($pdeps['required']['package'])) { - $t = $pdeps['required']['package']; - if (!isset($t[0])) { - $t = array($t); - } - $tdeps = array_merge($tdeps, $t); - } - if (isset($pdeps['required']['subpackage'])) { - $t = $pdeps['required']['subpackage']; - if (!isset($t[0])) { - $t = array($t); - } - $tdeps = array_merge($tdeps, $t); - } - if (isset($pdeps['optional']['package'])) { - $t = $pdeps['optional']['package']; - if (!isset($t[0])) { - $t = array($t); - } - $tdeps = array_merge($tdeps, $t); - } - if (isset($pdeps['optional']['subpackage'])) { - $t = $pdeps['optional']['subpackage']; - if (!isset($t[0])) { - $t = array($t); - } - $tdeps = array_merge($tdeps, $t); - } - if (isset($pdeps['group'])) { - if (!isset($pdeps['group'][0])) { - $pdeps['group'] = array($pdeps['group']); - } - foreach ($pdeps['group'] as $group) { - if (isset($group['package'])) { - $t = $group['package']; - if (!isset($t[0])) { - $t = array($t); - } - $tdeps = array_merge($tdeps, $t); - } - if (isset($group['subpackage'])) { - $t = $group['subpackage']; - if (!isset($t[0])) { - $t = array($t); - } - $tdeps = array_merge($tdeps, $t); - } - } - } - foreach ($tdeps as $dep) { - if (!isset($dep['channel'])) { - $depchannel = '__uri'; - } else { - $depchannel = $dep['channel']; - } - $deps[$depchannel][strtolower($dep['name'])] = true; - foreach ($packages as $p) { - $dep['channel'] = $depchannel; - $dep['package'] = $dep['name']; - if ($p->isEqual($dep)) { - if (!isset($checked[strtolower($p->getChannel())] - [strtolower($p->getPackage())])) { - // add the dependency's dependencies to the tree - $this->_getDepTreeDP($p, $packages, $deps, $checked); - } - } - } - } - } - } - - /** - * Sort a list of arrays of array(downloaded packagefilename) by dependency. - * - * It also removes duplicate dependencies - * @param array an array of downloaded PEAR_Downloader_Packages - * @return array array of array(packagefilename, package.xml contents) - */ - function sortPackagesForInstall(&$packages) - { - foreach ($packages as $i => $package) { - $checked = $deps = array(); - $this->_getDepTreeDP($packages[$i], $packages, $deps, $checked); - $this->_depTree[$package->getChannel()][$package->getPackage()] = $deps; - } - usort($packages, array(&$this, '_sortInstall')); - } - - function _dependsOn($a, $b) - { - return $this->_checkDepTree(strtolower($a->getChannel()), strtolower($a->getPackage()), - $b); - } - - function _checkDepTree($channel, $package, $b, $checked = array()) - { - $checked[$channel][$package] = true; - if (!isset($this->_depTree[$channel][$package])) { - return false; - } - if (isset($this->_depTree[$channel][$package][strtolower($b->getChannel())] - [strtolower($b->getPackage())])) { - return true; - } - foreach ($this->_depTree[$channel][$package] as $ch => $packages) { - foreach ($packages as $pa => $true) { - if ($this->_checkDepTree($ch, $pa, $b, $checked)) { - return true; - } - } - } - return false; - } - - function _sortInstall($a, $b) - { - if (!$a->getDeps() && !$b->getDeps()) { - return 0; // neither package has dependencies, order is insignificant - } - if ($a->getDeps() && !$b->getDeps()) { - return 1; // $a must be installed after $b because $a has dependencies - } - if (!$a->getDeps() && $b->getDeps()) { - return -1; // $b must be installed after $a because $b has dependencies - } - // both packages have dependencies - if ($this->_dependsOn($a, $b)) { - return 1; - } - if ($this->_dependsOn($b, $a)) { - return -1; - } - return 0; - } - - /** - * Download a file through HTTP. Considers suggested file name in - * Content-disposition: header and can run a callback function for - * different events. The callback will be called with two - * parameters: the callback type, and parameters. The implemented - * callback types are: - * - * 'setup' called at the very beginning, parameter is a UI object - * that should be used for all output - * 'message' the parameter is a string with an informational message - * 'saveas' may be used to save with a different file name, the - * parameter is the filename that is about to be used. - * If a 'saveas' callback returns a non-empty string, - * that file name will be used as the filename instead. - * Note that $save_dir will not be affected by this, only - * the basename of the file. - * 'start' download is starting, parameter is number of bytes - * that are expected, or -1 if unknown - * 'bytesread' parameter is the number of bytes read so far - * 'done' download is complete, parameter is the total number - * of bytes read - * 'connfailed' if the TCP/SSL connection fails, this callback is called - * with array(host,port,errno,errmsg) - * 'writefailed' if writing to disk fails, this callback is called - * with array(destfile,errmsg) - * - * If an HTTP proxy has been configured (http_proxy PEAR_Config - * setting), the proxy will be used. - * - * @param string $url the URL to download - * @param object $ui PEAR_Frontend_* instance - * @param object $config PEAR_Config instance - * @param string $save_dir directory to save file in - * @param mixed $callback function/method to call for status - * updates - * @param false|string|array $lastmodified header values to check against for caching - * use false to return the header values from this download - * @param false|array $accept Accept headers to send - * @return string|array Returns the full path of the downloaded file or a PEAR - * error on failure. If the error is caused by - * socket-related errors, the error object will - * have the fsockopen error code available through - * getCode(). If caching is requested, then return the header - * values. - * - * @access public - */ - function downloadHttp($url, &$ui, $save_dir = '.', $callback = null, $lastmodified = null, - $accept = false) - { - static $redirect = 0; - // allways reset , so we are clean case of error - $wasredirect = $redirect; - $redirect = 0; - if ($callback) { - call_user_func($callback, 'setup', array(&$ui)); - } - $info = parse_url($url); - if (!isset($info['scheme']) || !in_array($info['scheme'], array('http', 'https'))) { - return PEAR::raiseError('Cannot download non-http URL "' . $url . '"'); - } - if (!isset($info['host'])) { - return PEAR::raiseError('Cannot download from non-URL "' . $url . '"'); - } else { - $host = isset($info['host']) ? $info['host'] : null; - $port = isset($info['port']) ? $info['port'] : null; - $path = isset($info['path']) ? $info['path'] : null; - } - if (isset($this)) { - $config = &$this->config; - } else { - $config = &PEAR_Config::singleton(); - } - $proxy_host = $proxy_port = $proxy_user = $proxy_pass = ''; - if ($config->get('http_proxy') && - $proxy = parse_url($config->get('http_proxy'))) { - $proxy_host = isset($proxy['host']) ? $proxy['host'] : null; - if (isset($proxy['scheme']) && $proxy['scheme'] == 'https') { - $proxy_host = 'ssl://' . $proxy_host; - } - $proxy_port = isset($proxy['port']) ? $proxy['port'] : 8080; - $proxy_user = isset($proxy['user']) ? urldecode($proxy['user']) : null; - $proxy_pass = isset($proxy['pass']) ? urldecode($proxy['pass']) : null; - - if ($callback) { - call_user_func($callback, 'message', "Using HTTP proxy $host:$port"); - } - } - if (empty($port)) { - if (isset($info['scheme']) && $info['scheme'] == 'https') { - $port = 443; - } else { - $port = 80; - } - } - if ($proxy_host != '') { - $fp = @fsockopen($proxy_host, $proxy_port, $errno, $errstr); - if (!$fp) { - if ($callback) { - call_user_func($callback, 'connfailed', array($proxy_host, $proxy_port, - $errno, $errstr)); - } - return PEAR::raiseError("Connection to `$proxy_host:$proxy_port' failed: $errstr", $errno); - } - if ($lastmodified === false || $lastmodified) { - $request = "GET $url HTTP/1.1\r\n"; - } else { - $request = "GET $url HTTP/1.0\r\n"; - } - } else { - if (isset($info['scheme']) && $info['scheme'] == 'https') { - $host = 'ssl://' . $host; - } - $fp = @fsockopen($host, $port, $errno, $errstr); - if (!$fp) { - if ($callback) { - call_user_func($callback, 'connfailed', array($host, $port, - $errno, $errstr)); - } - return PEAR::raiseError("Connection to `$host:$port' failed: $errstr", $errno); - } - if ($lastmodified === false || $lastmodified) { - $request = "GET $path HTTP/1.1\r\n"; - } else { - $request = "GET $path HTTP/1.0\r\n"; - } - } - $ifmodifiedsince = ''; - if (is_array($lastmodified)) { - if (isset($lastmodified['Last-Modified'])) { - $ifmodifiedsince = 'If-Modified-Since: ' . $lastmodified['Last-Modified'] . "\r\n"; - } - if (isset($lastmodified['ETag'])) { - $ifmodifiedsince .= "If-None-Match: $lastmodified[ETag]\r\n"; - } - } else { - $ifmodifiedsince = ($lastmodified ? "If-Modified-Since: $lastmodified\r\n" : ''); - } - $request .= "Host: $host:$port\r\n" . $ifmodifiedsince . - "User-Agent: PEAR/@package_version@/PHP/" . PHP_VERSION . "\r\n"; - if (isset($this)) { // only pass in authentication for non-static calls - $username = $config->get('username'); - $password = $config->get('password'); - if ($username && $password) { - $tmp = base64_encode("$username:$password"); - $request .= "Authorization: Basic $tmp\r\n"; - } - } - if ($proxy_host != '' && $proxy_user != '') { - $request .= 'Proxy-Authorization: Basic ' . - base64_encode($proxy_user . ':' . $proxy_pass) . "\r\n"; - } - if ($accept) { - $request .= 'Accept: ' . implode(', ', $accept) . "\r\n"; - } - $request .= "Connection: close\r\n"; - $request .= "\r\n"; - fwrite($fp, $request); - $headers = array(); - $reply = 0; - while (trim($line = fgets($fp, 1024))) { - if (preg_match('/^([^:]+):\s+(.*)\s*$/', $line, $matches)) { - $headers[strtolower($matches[1])] = trim($matches[2]); - } elseif (preg_match('|^HTTP/1.[01] ([0-9]{3}) |', $line, $matches)) { - $reply = (int) $matches[1]; - if ($reply == 304 && ($lastmodified || ($lastmodified === false))) { - return false; - } - if (! in_array($reply, array(200, 301, 302, 303, 305, 307))) { - return PEAR::raiseError("File http://$host:$port$path not valid (received: $line)"); - } - } - } - if ($reply != 200) { - if (isset($headers['location'])) { - if ($wasredirect < 5) { - $redirect = $wasredirect + 1; - return $this->downloadHttp($headers['location'], - $ui, $save_dir, $callback, $lastmodified, $accept); - } else { - return PEAR::raiseError("File http://$host:$port$path not valid (redirection looped more than 5 times)"); - } - } else { - return PEAR::raiseError("File http://$host:$port$path not valid (redirected but no location)"); - } - } - if (isset($headers['content-disposition']) && - preg_match('/\sfilename=\"([^;]*\S)\"\s*(;|$)/', $headers['content-disposition'], $matches)) { - $save_as = basename($matches[1]); - } else { - $save_as = basename($url); - } - if ($callback) { - $tmp = call_user_func($callback, 'saveas', $save_as); - if ($tmp) { - $save_as = $tmp; - } - } - $dest_file = $save_dir . DIRECTORY_SEPARATOR . $save_as; - if (!$wp = @fopen($dest_file, 'wb')) { - fclose($fp); - if ($callback) { - call_user_func($callback, 'writefailed', array($dest_file, $php_errormsg)); - } - return PEAR::raiseError("could not open $dest_file for writing"); - } - if (isset($headers['content-length'])) { - $length = $headers['content-length']; - } else { - $length = -1; - } - $bytes = 0; - if ($callback) { - call_user_func($callback, 'start', array(basename($dest_file), $length)); - } - while ($data = fread($fp, 1024)) { - $bytes += strlen($data); - if ($callback) { - call_user_func($callback, 'bytesread', $bytes); - } - if (!@fwrite($wp, $data)) { - fclose($fp); - if ($callback) { - call_user_func($callback, 'writefailed', array($dest_file, $php_errormsg)); - } - return PEAR::raiseError("$dest_file: write failed ($php_errormsg)"); - } - } - fclose($fp); - fclose($wp); - if ($callback) { - call_user_func($callback, 'done', $bytes); - } - if ($lastmodified === false || $lastmodified) { - if (isset($headers['etag'])) { - $lastmodified = array('ETag' => $headers['etag']); - } - if (isset($headers['last-modified'])) { - if (is_array($lastmodified)) { - $lastmodified['Last-Modified'] = $headers['last-modified']; - } else { - $lastmodified = $headers['last-modified']; - } - } - return array($dest_file, $lastmodified, $headers); - } - return $dest_file; - } -} -// }}} - -?> +<?php +/** + * PEAR_Downloader, the PEAR Installer's download utility class + * + * PHP versions 4 and 5 + * + * LICENSE: This source file is subject to version 3.0 of the PHP license + * that is available through the world-wide-web at the following URI: + * http://www.php.net/license/3_0.txt. If you did not receive a copy of + * the PHP License and are unable to obtain it through the web, please + * send a note to license@php.net so we can mail you a copy immediately. + * + * @category pear + * @package PEAR + * @author Greg Beaver <cellog@php.net> + * @author Stig Bakken <ssb@php.net> + * @author Tomas V. V. Cox <cox@idecnet.com> + * @author Martin Jansen <mj@php.net> + * @copyright 1997-2006 The PHP Group + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version CVS: $Id: Downloader.php,v 1.104 2006/03/28 03:51:40 cellog Exp $ + * @link http://pear.php.net/package/PEAR + * @since File available since Release 1.3.0 + */ + +/** + * Needed for constants, extending + */ +require_once 'PEAR/Common.php'; + +define('PEAR_INSTALLER_OK', 1); +define('PEAR_INSTALLER_FAILED', 0); +define('PEAR_INSTALLER_SKIPPED', -1); +define('PEAR_INSTALLER_ERROR_NO_PREF_STATE', 2); + +/** + * Administration class used to download anything from the internet (PEAR Packages, + * static URLs, xml files) + * + * @category pear + * @package PEAR + * @author Greg Beaver <cellog@php.net> + * @author Stig Bakken <ssb@php.net> + * @author Tomas V. V. Cox <cox@idecnet.com> + * @author Martin Jansen <mj@php.net> + * @copyright 1997-2006 The PHP Group + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version Release: @package_version@ + * @link http://pear.php.net/package/PEAR + * @since Class available since Release 1.3.0 + */ +class PEAR_Downloader extends PEAR_Common +{ + /** + * @var PEAR_Registry + * @access private + */ + var $_registry; + + /** + * @var PEAR_Remote + * @access private + */ + var $_remote; + + /** + * Preferred Installation State (snapshot, devel, alpha, beta, stable) + * @var string|null + * @access private + */ + var $_preferredState; + + /** + * Options from command-line passed to Install. + * + * Recognized options:<br /> + * - onlyreqdeps : install all required dependencies as well + * - alldeps : install all dependencies, including optional + * - installroot : base relative path to install files in + * - force : force a download even if warnings would prevent it + * - nocompress : download uncompressed tarballs + * @see PEAR_Command_Install + * @access private + * @var array + */ + var $_options; + + /** + * Downloaded Packages after a call to download(). + * + * Format of each entry: + * + * <code> + * array('pkg' => 'package_name', 'file' => '/path/to/local/file', + * 'info' => array() // parsed package.xml + * ); + * </code> + * @access private + * @var array + */ + var $_downloadedPackages = array(); + + /** + * Packages slated for download. + * + * This is used to prevent downloading a package more than once should it be a dependency + * for two packages to be installed. + * Format of each entry: + * + * <pre> + * array('package_name1' => parsed package.xml, 'package_name2' => parsed package.xml, + * ); + * </pre> + * @access private + * @var array + */ + var $_toDownload = array(); + + /** + * Array of every package installed, with names lower-cased. + * + * Format: + * <code> + * array('package1' => 0, 'package2' => 1, ); + * </code> + * @var array + */ + var $_installed = array(); + + /** + * @var array + * @access private + */ + var $_errorStack = array(); + + /** + * @var boolean + * @access private + */ + var $_internalDownload = false; + + /** + * Temporary variable used in sorting packages by dependency in {@link sortPkgDeps()} + * @var array + * @access private + */ + var $_packageSortTree; + + /** + * Temporary directory, or configuration value where downloads will occur + * @var string + */ + var $_downloadDir; + // {{{ PEAR_Downloader() + + /** + * @param PEAR_Frontend_* + * @param array + * @param PEAR_Config + */ + function PEAR_Downloader(&$ui, $options, &$config) + { + parent::PEAR_Common(); + $this->_options = $options; + $this->config = &$config; + $this->_preferredState = $this->config->get('preferred_state'); + $this->ui = &$ui; + if (!$this->_preferredState) { + // don't inadvertantly use a non-set preferred_state + $this->_preferredState = null; + } + + if (isset($this->_options['installroot'])) { + $this->config->setInstallRoot($this->_options['installroot']); + } + $this->_registry = &$config->getRegistry(); + $this->_remote = &$config->getRemote(); + + if (isset($this->_options['alldeps']) || isset($this->_options['onlyreqdeps'])) { + $this->_installed = $this->_registry->listAllPackages(); + foreach ($this->_installed as $key => $unused) { + if (!count($unused)) { + continue; + } + $strtolower = create_function('$a','return strtolower($a);'); + array_walk($this->_installed[$key], $strtolower); + } + } + } + + /** + * Attempt to discover a channel's remote capabilities from + * its server name + * @param string + * @return boolean + */ + function discover($channel) + { + $this->log(1, 'Attempting to discover channel "' . $channel . '"...'); + PEAR::pushErrorHandling(PEAR_ERROR_RETURN); + $callback = $this->ui ? array(&$this, '_downloadCallback') : null; + if (!class_exists('System')) { + require_once 'System.php'; + } + $a = $this->downloadHttp('http://' . $channel . '/channel.xml', $this->ui, + System::mktemp(array('-d')), $callback, false); + PEAR::popErrorHandling(); + if (PEAR::isError($a)) { + return false; + } + list($a, $lastmodified) = $a; + if (!class_exists('PEAR/ChannelFile.php')) { + require_once 'PEAR/ChannelFile.php'; + } + $b = new PEAR_ChannelFile; + if ($b->fromXmlFile($a)) { + unlink($a); + if ($this->config->get('auto_discover')) { + $this->_registry->addChannel($b, $lastmodified); + $alias = $b->getName(); + if ($b->getName() == $this->_registry->channelName($b->getAlias())) { + $alias = $b->getAlias(); + } + $this->log(1, 'Auto-discovered channel "' . $channel . + '", alias "' . $alias . '", adding to registry'); + } + return true; + } + unlink($a); + return false; + } + + /** + * For simpler unit-testing + * @param PEAR_Downloader + * @return PEAR_Downloader_Package + */ + function &newDownloaderPackage(&$t) + { + if (!class_exists('PEAR_Downloader_Package')) { + require_once 'PEAR/Downloader/Package.php'; + } + $a = &new PEAR_Downloader_Package($t); + return $a; + } + + /** + * For simpler unit-testing + * @param PEAR_Config + * @param array + * @param array + * @param int + */ + function &getDependency2Object(&$c, $i, $p, $s) + { + if (!class_exists('PEAR/Dependency2.php')) { + require_once 'PEAR/Dependency2.php'; + } + $z = &new PEAR_Dependency2($c, $i, $p, $s); + return $z; + } + + function &download($params) + { + if (!count($params)) { + $a = array(); + return $a; + } + if (!isset($this->_registry)) { + $this->_registry = &$this->config->getRegistry(); + } + if (!isset($this->_remote)) { + $this->_remote = &$this->config->getRemote(); + } + $channelschecked = array(); + // convert all parameters into PEAR_Downloader_Package objects + foreach ($params as $i => $param) { + $params[$i] = &$this->newDownloaderPackage($this); + PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); + $err = $params[$i]->initialize($param); + PEAR::staticPopErrorHandling(); + if (!$err) { + // skip parameters that were missed by preferred_state + continue; + } + if (PEAR::isError($err)) { + if (!isset($this->_options['soft'])) { + $this->log(0, $err->getMessage()); + } + $params[$i] = false; + if (is_object($param)) { + $param = $param->getChannel() . '/' . $param->getPackage(); + } + $this->pushError('Package "' . $param . '" is not valid', + PEAR_INSTALLER_SKIPPED); + } else { + do { + if ($params[$i] && $params[$i]->getType() == 'local') { + // bug #7090 + // skip channel.xml check for local packages + break; + } + if ($params[$i] && !isset($channelschecked[$params[$i]->getChannel()]) && + !isset($this->_options['offline'])) { + $channelschecked[$params[$i]->getChannel()] = true; + PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); + if (!class_exists('System')) { + require_once 'System.php'; + } + $curchannel = &$this->_registry->getChannel($params[$i]->getChannel()); + if (PEAR::isError($curchannel)) { + PEAR::staticPopErrorHandling(); + return $this->raiseError($curchannel); + } + $a = $this->downloadHttp('http://' . $params[$i]->getChannel() . + '/channel.xml', $this->ui, + System::mktemp(array('-d')), null, $curchannel->lastModified()); + PEAR::staticPopErrorHandling(); + if (PEAR::isError($a) || !$a) { + break; + } + $this->log(0, 'WARNING: channel "' . $params[$i]->getChannel() . '" has ' . + 'updated its protocols, use "channel-update ' . $params[$i]->getChannel() . + '" to update'); + } + } while (false); + if ($params[$i] && !isset($this->_options['downloadonly'])) { + if (isset($this->_options['packagingroot'])) { + $checkdir = $this->_prependPath( + $this->config->get('php_dir', null, $params[$i]->getChannel()), + $this->_options['packagingroot']); + } else { + $checkdir = $this->config->get('php_dir', + null, $params[$i]->getChannel()); + } + while ($checkdir && $checkdir != '/' && !file_exists($checkdir)) { + $checkdir = dirname($checkdir); + } + if ($checkdir == '.') { + $checkdir = '/'; + } + if (!is_writeable($checkdir)) { + return PEAR::raiseError('Cannot install, php_dir for channel "' . + $params[$i]->getChannel() . '" is not writeable by the current user'); + } + } + } + } + unset($channelschecked); + PEAR_Downloader_Package::removeDuplicates($params); + if (!count($params)) { + $a = array(); + return $a; + } + if (!isset($this->_options['nodeps']) && !isset($this->_options['offline'])) { + $reverify = true; + while ($reverify) { + $reverify = false; + foreach ($params as $i => $param) { + $ret = $params[$i]->detectDependencies($params); + if (PEAR::isError($ret)) { + $reverify = true; + $params[$i] = false; + PEAR_Downloader_Package::removeDuplicates($params); + if (!isset($this->_options['soft'])) { + $this->log(0, $ret->getMessage()); + } + continue 2; + } + } + } + } + if (isset($this->_options['offline'])) { + $this->log(3, 'Skipping dependency download check, --offline specified'); + } + if (!count($params)) { + $a = array(); + return $a; + } + while (PEAR_Downloader_Package::mergeDependencies($params)); + PEAR_Downloader_Package::removeInstalled($params); + if (!count($params)) { + $this->pushError('No valid packages found', PEAR_INSTALLER_FAILED); + $a = array(); + return $a; + } + PEAR::pushErrorHandling(PEAR_ERROR_RETURN); + $err = $this->analyzeDependencies($params); + PEAR::popErrorHandling(); + if (!count($params)) { + $this->pushError('No valid packages found', PEAR_INSTALLER_FAILED); + $a = array(); + return $a; + } + $ret = array(); + $newparams = array(); + if (isset($this->_options['pretend'])) { + return $params; + } + foreach ($params as $i => $package) { + PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); + $pf = &$params[$i]->download(); + PEAR::staticPopErrorHandling(); + if (PEAR::isError($pf)) { + if (!isset($this->_options['soft'])) { + $this->log(1, $pf->getMessage()); + $this->log(0, 'Error: cannot download "' . + $this->_registry->parsedPackageNameToString($package->getParsedPackage(), + true) . + '"'); + } + continue; + } + $newparams[] = &$params[$i]; + $ret[] = array('file' => $pf->getArchiveFile(), + 'info' => &$pf, + 'pkg' => $pf->getPackage()); + } + $this->_downloadedPackages = $ret; + return $newparams; + } + + /** + * @param array all packages to be installed + */ + function analyzeDependencies(&$params) + { + $hasfailed = $failed = false; + if (isset($this->_options['downloadonly'])) { + return; + } + PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); + $redo = true; + $reset = false; + while ($redo) { + $redo = false; + foreach ($params as $i => $param) { + $deps = $param->getDeps(); + if (!$deps) { + $depchecker = &$this->getDependency2Object($this->config, $this->getOptions(), + $param->getParsedPackage(), PEAR_VALIDATE_DOWNLOADING); + if ($param->getType() == 'xmlrpc') { + $send = $param->getDownloadURL(); + } else { + $send = $param->getPackageFile(); + } + $installcheck = $depchecker->validatePackage($send, $this, $params); + if (PEAR::isError($installcheck)) { + if (!isset($this->_options['soft'])) { + $this->log(0, $installcheck->getMessage()); + } + $hasfailed = true; + $params[$i] = false; + $reset = true; + $redo = true; + $failed = false; + PEAR_Downloader_Package::removeDuplicates($params); + continue 2; + } + continue; + } + if (!$reset && $param->alreadyValidated()) { + continue; + } + if (count($deps)) { + $depchecker = &$this->getDependency2Object($this->config, $this->getOptions(), + $param->getParsedPackage(), PEAR_VALIDATE_DOWNLOADING); + if ($param->getType() == 'xmlrpc') { + $send = $param->getDownloadURL(); + } else { + $send = $param->getPackageFile(); + } + $installcheck = $depchecker->validatePackage($send, $this, $params); + if (PEAR::isError($installcheck)) { + if (!isset($this->_options['soft'])) { + $this->log(0, $installcheck->getMessage()); + } + $hasfailed = true; + $params[$i] = false; + $reset = true; + $redo = true; + $failed = false; + PEAR_Downloader_Package::removeDuplicates($params); + continue 2; + } + $failed = false; + if (isset($deps['required'])) { + foreach ($deps['required'] as $type => $dep) { + // note: Dependency2 will never return a PEAR_Error if ignore-errors + // is specified, so soft is needed to turn off logging + if (!isset($dep[0])) { + if (PEAR::isError($e = $depchecker->{"validate{$type}Dependency"}($dep, + true, $params))) { + $failed = true; + if (!isset($this->_options['soft'])) { + $this->log(0, $e->getMessage()); + } + } elseif (is_array($e) && !$param->alreadyValidated()) { + if (!isset($this->_options['soft'])) { + $this->log(0, $e[0]); + } + } + } else { + foreach ($dep as $d) { + if (PEAR::isError($e = + $depchecker->{"validate{$type}Dependency"}($d, + true, $params))) { + $failed = true; + if (!isset($this->_options['soft'])) { + $this->log(0, $e->getMessage()); + } + } elseif (is_array($e) && !$param->alreadyValidated()) { + if (!isset($this->_options['soft'])) { + $this->log(0, $e[0]); + } + } + } + } + } + if (isset($deps['optional'])) { + foreach ($deps['optional'] as $type => $dep) { + if (!isset($dep[0])) { + if (PEAR::isError($e = + $depchecker->{"validate{$type}Dependency"}($dep, + false, $params))) { + $failed = true; + if (!isset($this->_options['soft'])) { + $this->log(0, $e->getMessage()); + } + } elseif (is_array($e) && !$param->alreadyValidated()) { + if (!isset($this->_options['soft'])) { + $this->log(0, $e[0]); + } + } + } else { + foreach ($dep as $d) { + if (PEAR::isError($e = + $depchecker->{"validate{$type}Dependency"}($d, + false, $params))) { + $failed = true; + if (!isset($this->_options['soft'])) { + $this->log(0, $e->getMessage()); + } + } elseif (is_array($e) && !$param->alreadyValidated()) { + if (!isset($this->_options['soft'])) { + $this->log(0, $e[0]); + } + } + } + } + } + } + $groupname = $param->getGroup(); + if (isset($deps['group']) && $groupname) { + if (!isset($deps['group'][0])) { + $deps['group'] = array($deps['group']); + } + $found = false; + foreach ($deps['group'] as $group) { + if ($group['attribs']['name'] == $groupname) { + $found = true; + break; + } + } + if ($found) { + unset($group['attribs']); + foreach ($group as $type => $dep) { + if (!isset($dep[0])) { + if (PEAR::isError($e = + $depchecker->{"validate{$type}Dependency"}($dep, + false, $params))) { + $failed = true; + if (!isset($this->_options['soft'])) { + $this->log(0, $e->getMessage()); + } + } elseif (is_array($e) && !$param->alreadyValidated()) { + if (!isset($this->_options['soft'])) { + $this->log(0, $e[0]); + } + } + } else { + foreach ($dep as $d) { + if (PEAR::isError($e = + $depchecker->{"validate{$type}Dependency"}($d, + false, $params))) { + $failed = true; + if (!isset($this->_options['soft'])) { + $this->log(0, $e->getMessage()); + } + } elseif (is_array($e) && !$param->alreadyValidated()) { + if (!isset($this->_options['soft'])) { + $this->log(0, $e[0]); + } + } + } + } + } + } + } + } else { + foreach ($deps as $dep) { + if (PEAR::isError($e = $depchecker->validateDependency1($dep, $params))) { + $failed = true; + if (!isset($this->_options['soft'])) { + $this->log(0, $e->getMessage()); + } + } elseif (is_array($e) && !$param->alreadyValidated()) { + if (!isset($this->_options['soft'])) { + $this->log(0, $e[0]); + } + } + } + } + $params[$i]->setValidated(); + } + if ($failed) { + $hasfailed = true; + $params[$i] = false; + $reset = true; + $redo = true; + $failed = false; + PEAR_Downloader_Package::removeDuplicates($params); + continue 2; + } + } + } + PEAR::staticPopErrorHandling(); + if ($hasfailed && (isset($this->_options['ignore-errors']) || + isset($this->_options['nodeps']))) { + // this is probably not needed, but just in case + if (!isset($this->_options['soft'])) { + $this->log(0, 'WARNING: dependencies failed'); + } + } + } + + /** + * Retrieve the directory that downloads will happen in + * @access private + * @return string + */ + function getDownloadDir() + { + if (isset($this->_downloadDir)) { + return $this->_downloadDir; + } + $downloaddir = $this->config->get('download_dir'); + if (empty($downloaddir)) { + if (!class_exists('System')) { + require_once 'System.php'; + } + if (PEAR::isError($downloaddir = System::mktemp('-d'))) { + return $downloaddir; + } + $this->log(3, '+ tmp dir created at ' . $downloaddir); + } + return $this->_downloadDir = $downloaddir; + } + + function setDownloadDir($dir) + { + $this->_downloadDir = $dir; + } + + // }}} + // {{{ configSet() + function configSet($key, $value, $layer = 'user', $channel = false) + { + $this->config->set($key, $value, $layer, $channel); + $this->_preferredState = $this->config->get('preferred_state', null, $channel); + if (!$this->_preferredState) { + // don't inadvertantly use a non-set preferred_state + $this->_preferredState = null; + } + } + + // }}} + // {{{ setOptions() + function setOptions($options) + { + $this->_options = $options; + } + + // }}} + // {{{ setOptions() + function getOptions() + { + return $this->_options; + } + + // }}} + + /** + * For simpler unit-testing + * @param PEAR_Config + * @param int + * @param string + */ + function &getPackagefileObject(&$c, $d, $t = false) + { + if (!class_exists('PEAR_PackageFile')) { + require_once 'PEAR/PackageFile.php'; + } + $a = &new PEAR_PackageFile($c, $d, $t); + return $a; + } + + // {{{ _getPackageDownloadUrl() + + /** + * @param array output of {@link parsePackageName()} + * @access private + */ + function _getPackageDownloadUrl($parr) + { + $curchannel = $this->config->get('default_channel'); + $this->configSet('default_channel', $parr['channel']); + // getDownloadURL returns an array. On error, it only contains information + // on the latest release as array(version, info). On success it contains + // array(version, info, download url string) + $state = isset($parr['state']) ? $parr['state'] : $this->config->get('preferred_state'); + if (!$this->_registry->channelExists($parr['channel'])) { + do { + if ($this->config->get('auto_discover')) { + if ($this->discover($parr['channel'])) { + break; + } + } + $this->configSet('default_channel', $curchannel); + return PEAR::raiseError('Unknown remote channel: ' . $remotechannel); + } while (false); + } + $chan = &$this->_registry->getChannel($parr['channel']); + if (PEAR::isError($chan)) { + return $chan; + } + $version = $this->_registry->packageInfo($parr['package'], 'version', + $parr['channel']); + if ($chan->supportsREST($this->config->get('preferred_mirror')) && + $base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) { + $rest = &$this->config->getREST('1.0', $this->_options); + if (!isset($parr['version']) && !isset($parr['state']) && $version + && !isset($this->_options['downloadonly'])) { + $url = $rest->getDownloadURL($base, $parr, $state, $version); + } else { + $url = $rest->getDownloadURL($base, $parr, $state, false); + } + if (PEAR::isError($url)) { + $this->configSet('default_channel', $curchannel); + return $url; + } + if ($parr['channel'] != $curchannel) { + $this->configSet('default_channel', $curchannel); + } + if (!is_array($url)) { + return $url; + } + $url['raw'] = false; // no checking is necessary for REST + if (!is_array($url['info'])) { + return PEAR::raiseError('Invalid remote dependencies retrieved from REST - ' . + 'this should never happen'); + } + PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); + $testversion = $this->_registry->packageInfo($url['package'], 'version', + $parr['channel']); + PEAR::staticPopErrorHandling(); + if (!isset($this->_options['force']) && !PEAR::isError($testversion)) { + if (version_compare($testversion, $url['version'], '>=')) { + return PEAR::raiseError($this->_registry->parsedPackageNameToString( + $parr, true) . ' is already installed and is newer than detected ' . + 'release version ' . $url['version'], -976); + } + } + if (isset($url['info']['required']) || $url['compatible']) { + require_once 'PEAR/PackageFile/v2.php'; + $pf = new PEAR_PackageFile_v2; + $pf->setRawChannel($parr['channel']); + if ($url['compatible']) { + $pf->setRawCompatible($url['compatible']); + } + } else { + require_once 'PEAR/PackageFile/v1.php'; + $pf = new PEAR_PackageFile_v1; + } + $pf->setRawPackage($url['package']); + $pf->setDeps($url['info']); + $pf->setRawState($url['stability']); + $url['info'] = &$pf; + if (!extension_loaded("zlib") || isset($this->_options['nocompress'])) { + $ext = '.tar'; + } else { + $ext = '.tgz'; + } + if (is_array($url)) { + if (isset($url['url'])) { + $url['url'] .= $ext; + } + } + return $url; + } elseif ($chan->supports('xmlrpc', 'package.getDownloadURL', false, '1.1')) { + // don't install with the old version information unless we're doing a plain + // vanilla simple installation. If the user says to install a particular + // version or state, ignore the current installed version + if (!isset($parr['version']) && !isset($parr['state']) && $version + && !isset($this->_options['downloadonly'])) { + $url = $this->_remote->call('package.getDownloadURL', $parr, $state, $version); + } else { + $url = $this->_remote->call('package.getDownloadURL', $parr, $state); + } + } else { + $url = $this->_remote->call('package.getDownloadURL', $parr, $state); + } + if (PEAR::isError($url)) { + return $url; + } + if ($parr['channel'] != $curchannel) { + $this->configSet('default_channel', $curchannel); + } + if (isset($url['__PEAR_ERROR_CLASS__'])) { + return PEAR::raiseError($url['message']); + } + if (!is_array($url)) { + return $url; + } + $url['raw'] = $url['info']; + if (isset($this->_options['downloadonly'])) { + $pkg = &$this->getPackagefileObject($this->config, $this->debug); + } else { + $pkg = &$this->getPackagefileObject($this->config, $this->debug, + $this->getDownloadDir()); + } + PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); + $pinfo = &$pkg->fromXmlString($url['info'], PEAR_VALIDATE_DOWNLOADING, 'remote'); + PEAR::staticPopErrorHandling(); + if (PEAR::isError($pinfo)) { + if (!isset($this->_options['soft'])) { + $this->log(0, $pinfo->getMessage()); + } + return PEAR::raiseError('Remote package.xml is not valid - this should never happen'); + } + $url['info'] = &$pinfo; + if (!extension_loaded("zlib") || isset($this->_options['nocompress'])) { + $ext = '.tar'; + } else { + $ext = '.tgz'; + } + if (is_array($url)) { + if (isset($url['url'])) { + $url['url'] .= $ext; + } + } + return $url; + } + // }}} + // {{{ getDepPackageDownloadUrl() + + /** + * @param array dependency array + * @access private + */ + function _getDepPackageDownloadUrl($dep, $parr) + { + $xsdversion = isset($dep['rel']) ? '1.0' : '2.0'; + $curchannel = $this->config->get('default_channel'); + if (isset($dep['channel'])) { + $remotechannel = $dep['channel']; + } else { + $remotechannel = 'pear.php.net'; + } + if (!$this->_registry->channelExists($remotechannel)) { + do { + if ($this->config->get('auto_discover')) { + if ($this->discover($remotechannel)) { + break; + } + } + return PEAR::raiseError('Unknown remote channel: ' . $remotechannel); + } while (false); + } + $this->configSet('default_channel', $remotechannel); + $state = isset($parr['state']) ? $parr['state'] : $this->config->get('preferred_state'); + if (isset($parr['state']) && isset($parr['version'])) { + unset($parr['state']); + } + $chan = &$this->_registry->getChannel($remotechannel); + if (PEAR::isError($chan)) { + return $chan; + } + $version = $this->_registry->packageInfo($dep['name'], 'version', + $remotechannel); + if ($chan->supportsREST($this->config->get('preferred_mirror')) && + $base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) { + $rest = &$this->config->getREST('1.0', $this->_options); + $url = $rest->getDepDownloadURL($base, $xsdversion, $dep, $parr, + $state, $version); + if (PEAR::isError($url)) { + return $url; + } + if ($parr['channel'] != $curchannel) { + $this->configSet('default_channel', $curchannel); + } + if (!is_array($url)) { + return $url; + } + $url['raw'] = false; // no checking is necessary for REST + if (!is_array($url['info'])) { + return PEAR::raiseError('Invalid remote dependencies retrieved from REST - ' . + 'this should never happen'); + } + if (isset($url['info']['required'])) { + if (!class_exists('PEAR_PackageFile_v2')) { + require_once 'PEAR/PackageFile/v2.php'; + } + $pf = new PEAR_PackageFile_v2; + $pf->setRawChannel($remotechannel); + } else { + if (!class_exists('PEAR_PackageFile_v1')) { + require_once 'PEAR/PackageFile/v1.php'; + } + $pf = new PEAR_PackageFile_v1; + } + $pf->setRawPackage($url['package']); + $pf->setDeps($url['info']); + $pf->setRawState($url['stability']); + $url['info'] = &$pf; + if (!extension_loaded("zlib") || isset($this->_options['nocompress'])) { + $ext = '.tar'; + } else { + $ext = '.tgz'; + } + if (is_array($url)) { + if (isset($url['url'])) { + $url['url'] .= $ext; + } + } + return $url; + } elseif ($chan->supports('xmlrpc', 'package.getDepDownloadURL', false, '1.1')) { + if ($version) { + $url = $this->_remote->call('package.getDepDownloadURL', $xsdversion, $dep, $parr, + $state, $version); + } else { + $url = $this->_remote->call('package.getDepDownloadURL', $xsdversion, $dep, $parr, + $state); + } + } else { + $url = $this->_remote->call('package.getDepDownloadURL', $xsdversion, $dep, $parr, $state); + } + if ($parr['channel'] != $curchannel) { + $this->configSet('default_channel', $curchannel); + } + if (!is_array($url)) { + return $url; + } + if (isset($url['__PEAR_ERROR_CLASS__'])) { + return PEAR::raiseError($url['message']); + } + $url['raw'] = $url['info']; + $pkg = &$this->getPackagefileObject($this->config, $this->debug); + PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); + $pinfo = &$pkg->fromXmlString($url['info'], PEAR_VALIDATE_DOWNLOADING, 'remote'); + PEAR::staticPopErrorHandling(); + if (PEAR::isError($pinfo)) { + if (!isset($this->_options['soft'])) { + $this->log(0, $pinfo->getMessage()); + } + return PEAR::raiseError('Remote package.xml is not valid - this should never happen'); + } + $url['info'] = &$pinfo; + if (is_array($url)) { + if (!extension_loaded("zlib") || isset($this->_options['nocompress'])) { + $ext = '.tar'; + } else { + $ext = '.tgz'; + } + if (isset($url['url'])) { + $url['url'] .= $ext; + } + } + return $url; + } + // }}} + // {{{ getPackageDownloadUrl() + + /** + * @deprecated in favor of _getPackageDownloadUrl + */ + function getPackageDownloadUrl($package, $version = null, $channel = false) + { + if ($version) { + $package .= "-$version"; + } + if ($this === null || $this->_registry === null) { + $package = "http://pear.php.net/get/$package"; + } else { + $chan = $this->_registry->getChannel($channel); + if (PEAR::isError($chan)) { + return ''; + } + $package = "http://" . $chan->getServer() . "/get/$package"; + } + if (!extension_loaded("zlib")) { + $package .= '?uncompress=yes'; + } + return $package; + } + + // }}} + // {{{ getDownloadedPackages() + + /** + * Retrieve a list of downloaded packages after a call to {@link download()}. + * + * Also resets the list of downloaded packages. + * @return array + */ + function getDownloadedPackages() + { + $ret = $this->_downloadedPackages; + $this->_downloadedPackages = array(); + $this->_toDownload = array(); + return $ret; + } + + // }}} + // {{{ _downloadCallback() + + function _downloadCallback($msg, $params = null) + { + switch ($msg) { + case 'saveas': + $this->log(1, "downloading $params ..."); + break; + case 'done': + $this->log(1, '...done: ' . number_format($params, 0, '', ',') . ' bytes'); + break; + case 'bytesread': + static $bytes; + if (empty($bytes)) { + $bytes = 0; + } + if (!($bytes % 10240)) { + $this->log(1, '.', false); + } + $bytes += $params; + break; + case 'start': + $this->log(1, "Starting to download {$params[0]} (".number_format($params[1], 0, '', ',')." bytes)"); + break; + } + if (method_exists($this->ui, '_downloadCallback')) + $this->ui->_downloadCallback($msg, $params); + } + + // }}} + // {{{ _prependPath($path, $prepend) + + function _prependPath($path, $prepend) + { + if (strlen($prepend) > 0) { + if (OS_WINDOWS && preg_match('/^[a-z]:/i', $path)) { + if (preg_match('/^[a-z]:/i', $prepend)) { + $prepend = substr($prepend, 2); + } elseif ($prepend{0} != '\\') { + $prepend = "\\$prepend"; + } + $path = substr($path, 0, 2) . $prepend . substr($path, 2); + } else { + $path = $prepend . $path; + } + } + return $path; + } + // }}} + // {{{ pushError($errmsg, $code) + + /** + * @param string + * @param integer + */ + function pushError($errmsg, $code = -1) + { + array_push($this->_errorStack, array($errmsg, $code)); + } + + // }}} + // {{{ getErrorMsgs() + + function getErrorMsgs() + { + $msgs = array(); + $errs = $this->_errorStack; + foreach ($errs as $err) { + $msgs[] = $err[0]; + } + $this->_errorStack = array(); + return $msgs; + } + + // }}} + + /** + * for BC + */ + function sortPkgDeps(&$packages, $uninstall = false) + { + $uninstall ? + $this->sortPackagesForUninstall($packages) : + $this->sortPackagesForInstall($packages); + } + + function _getDepTreeDP($package, $packages, &$deps, &$checked) + { + $pf = $package->getPackageFile(); + $checked[strtolower($package->getChannel())][strtolower($package->getPackage())] + = true; + $pdeps = $pf->getDeps(true); + if (!$pdeps) { + return; + } + if ($pf->getPackagexmlVersion() == '1.0') { + foreach ($pdeps as $dep) { + if ($dep['type'] != 'pkg') { + continue; + } + $deps['pear.php.net'][strtolower($dep['name'])] = true; + foreach ($packages as $p) { + $dep['channel'] = 'pear.php.net'; + $dep['package'] = $dep['name']; + if ($p->isEqual($dep)) { + if (!isset($checked[strtolower($p->getChannel())] + [strtolower($p->getPackage())])) { + // add the dependency's dependencies to the tree + $this->_getDepTreeDP($p, $packages, $deps, $checked); + } + } + } + } + } else { + $tdeps = array(); + if (isset($pdeps['required']['package'])) { + $t = $pdeps['required']['package']; + if (!isset($t[0])) { + $t = array($t); + } + $tdeps = array_merge($tdeps, $t); + } + if (isset($pdeps['required']['subpackage'])) { + $t = $pdeps['required']['subpackage']; + if (!isset($t[0])) { + $t = array($t); + } + $tdeps = array_merge($tdeps, $t); + } + if (isset($pdeps['optional']['package'])) { + $t = $pdeps['optional']['package']; + if (!isset($t[0])) { + $t = array($t); + } + $tdeps = array_merge($tdeps, $t); + } + if (isset($pdeps['optional']['subpackage'])) { + $t = $pdeps['optional']['subpackage']; + if (!isset($t[0])) { + $t = array($t); + } + $tdeps = array_merge($tdeps, $t); + } + if (isset($pdeps['group'])) { + if (!isset($pdeps['group'][0])) { + $pdeps['group'] = array($pdeps['group']); + } + foreach ($pdeps['group'] as $group) { + if (isset($group['package'])) { + $t = $group['package']; + if (!isset($t[0])) { + $t = array($t); + } + $tdeps = array_merge($tdeps, $t); + } + if (isset($group['subpackage'])) { + $t = $group['subpackage']; + if (!isset($t[0])) { + $t = array($t); + } + $tdeps = array_merge($tdeps, $t); + } + } + } + foreach ($tdeps as $dep) { + if (!isset($dep['channel'])) { + $depchannel = '__uri'; + } else { + $depchannel = $dep['channel']; + } + $deps[$depchannel][strtolower($dep['name'])] = true; + foreach ($packages as $p) { + $dep['channel'] = $depchannel; + $dep['package'] = $dep['name']; + if ($p->isEqual($dep)) { + if (!isset($checked[strtolower($p->getChannel())] + [strtolower($p->getPackage())])) { + // add the dependency's dependencies to the tree + $this->_getDepTreeDP($p, $packages, $deps, $checked); + } + } + } + } + } + } + + /** + * Sort a list of arrays of array(downloaded packagefilename) by dependency. + * + * It also removes duplicate dependencies + * @param array an array of downloaded PEAR_Downloader_Packages + * @return array array of array(packagefilename, package.xml contents) + */ + function sortPackagesForInstall(&$packages) + { + foreach ($packages as $i => $package) { + $checked = $deps = array(); + $this->_getDepTreeDP($packages[$i], $packages, $deps, $checked); + $this->_depTree[$package->getChannel()][$package->getPackage()] = $deps; + } + usort($packages, array(&$this, '_sortInstall')); + } + + function _dependsOn($a, $b) + { + return $this->_checkDepTree(strtolower($a->getChannel()), strtolower($a->getPackage()), + $b); + } + + function _checkDepTree($channel, $package, $b, $checked = array()) + { + $checked[$channel][$package] = true; + if (!isset($this->_depTree[$channel][$package])) { + return false; + } + if (isset($this->_depTree[$channel][$package][strtolower($b->getChannel())] + [strtolower($b->getPackage())])) { + return true; + } + foreach ($this->_depTree[$channel][$package] as $ch => $packages) { + foreach ($packages as $pa => $true) { + if ($this->_checkDepTree($ch, $pa, $b, $checked)) { + return true; + } + } + } + return false; + } + + function _sortInstall($a, $b) + { + if (!$a->getDeps() && !$b->getDeps()) { + return 0; // neither package has dependencies, order is insignificant + } + if ($a->getDeps() && !$b->getDeps()) { + return 1; // $a must be installed after $b because $a has dependencies + } + if (!$a->getDeps() && $b->getDeps()) { + return -1; // $b must be installed after $a because $b has dependencies + } + // both packages have dependencies + if ($this->_dependsOn($a, $b)) { + return 1; + } + if ($this->_dependsOn($b, $a)) { + return -1; + } + return 0; + } + + /** + * Download a file through HTTP. Considers suggested file name in + * Content-disposition: header and can run a callback function for + * different events. The callback will be called with two + * parameters: the callback type, and parameters. The implemented + * callback types are: + * + * 'setup' called at the very beginning, parameter is a UI object + * that should be used for all output + * 'message' the parameter is a string with an informational message + * 'saveas' may be used to save with a different file name, the + * parameter is the filename that is about to be used. + * If a 'saveas' callback returns a non-empty string, + * that file name will be used as the filename instead. + * Note that $save_dir will not be affected by this, only + * the basename of the file. + * 'start' download is starting, parameter is number of bytes + * that are expected, or -1 if unknown + * 'bytesread' parameter is the number of bytes read so far + * 'done' download is complete, parameter is the total number + * of bytes read + * 'connfailed' if the TCP/SSL connection fails, this callback is called + * with array(host,port,errno,errmsg) + * 'writefailed' if writing to disk fails, this callback is called + * with array(destfile,errmsg) + * + * If an HTTP proxy has been configured (http_proxy PEAR_Config + * setting), the proxy will be used. + * + * @param string $url the URL to download + * @param object $ui PEAR_Frontend_* instance + * @param object $config PEAR_Config instance + * @param string $save_dir directory to save file in + * @param mixed $callback function/method to call for status + * updates + * @param false|string|array $lastmodified header values to check against for caching + * use false to return the header values from this download + * @param false|array $accept Accept headers to send + * @return string|array Returns the full path of the downloaded file or a PEAR + * error on failure. If the error is caused by + * socket-related errors, the error object will + * have the fsockopen error code available through + * getCode(). If caching is requested, then return the header + * values. + * + * @access public + */ + function downloadHttp($url, &$ui, $save_dir = '.', $callback = null, $lastmodified = null, + $accept = false) + { + static $redirect = 0; + // allways reset , so we are clean case of error + $wasredirect = $redirect; + $redirect = 0; + if ($callback) { + call_user_func($callback, 'setup', array(&$ui)); + } + $info = parse_url($url); + if (!isset($info['scheme']) || !in_array($info['scheme'], array('http', 'https'))) { + return PEAR::raiseError('Cannot download non-http URL "' . $url . '"'); + } + if (!isset($info['host'])) { + return PEAR::raiseError('Cannot download from non-URL "' . $url . '"'); + } else { + $host = isset($info['host']) ? $info['host'] : null; + $port = isset($info['port']) ? $info['port'] : null; + $path = isset($info['path']) ? $info['path'] : null; + } + if (isset($this)) { + $config = &$this->config; + } else { + $config = &PEAR_Config::singleton(); + } + $proxy_host = $proxy_port = $proxy_user = $proxy_pass = ''; + if ($config->get('http_proxy') && + $proxy = parse_url($config->get('http_proxy'))) { + $proxy_host = isset($proxy['host']) ? $proxy['host'] : null; + if (isset($proxy['scheme']) && $proxy['scheme'] == 'https') { + $proxy_host = 'ssl://' . $proxy_host; + } + $proxy_port = isset($proxy['port']) ? $proxy['port'] : 8080; + $proxy_user = isset($proxy['user']) ? urldecode($proxy['user']) : null; + $proxy_pass = isset($proxy['pass']) ? urldecode($proxy['pass']) : null; + + if ($callback) { + call_user_func($callback, 'message', "Using HTTP proxy $host:$port"); + } + } + if (empty($port)) { + if (isset($info['scheme']) && $info['scheme'] == 'https') { + $port = 443; + } else { + $port = 80; + } + } + if ($proxy_host != '') { + $fp = @fsockopen($proxy_host, $proxy_port, $errno, $errstr); + if (!$fp) { + if ($callback) { + call_user_func($callback, 'connfailed', array($proxy_host, $proxy_port, + $errno, $errstr)); + } + return PEAR::raiseError("Connection to `$proxy_host:$proxy_port' failed: $errstr", $errno); + } + if ($lastmodified === false || $lastmodified) { + $request = "GET $url HTTP/1.1\r\n"; + } else { + $request = "GET $url HTTP/1.0\r\n"; + } + } else { + if (isset($info['scheme']) && $info['scheme'] == 'https') { + $host = 'ssl://' . $host; + } + $fp = @fsockopen($host, $port, $errno, $errstr); + if (!$fp) { + if ($callback) { + call_user_func($callback, 'connfailed', array($host, $port, + $errno, $errstr)); + } + return PEAR::raiseError("Connection to `$host:$port' failed: $errstr", $errno); + } + if ($lastmodified === false || $lastmodified) { + $request = "GET $path HTTP/1.1\r\n"; + } else { + $request = "GET $path HTTP/1.0\r\n"; + } + } + $ifmodifiedsince = ''; + if (is_array($lastmodified)) { + if (isset($lastmodified['Last-Modified'])) { + $ifmodifiedsince = 'If-Modified-Since: ' . $lastmodified['Last-Modified'] . "\r\n"; + } + if (isset($lastmodified['ETag'])) { + $ifmodifiedsince .= "If-None-Match: $lastmodified[ETag]\r\n"; + } + } else { + $ifmodifiedsince = ($lastmodified ? "If-Modified-Since: $lastmodified\r\n" : ''); + } + $request .= "Host: $host:$port\r\n" . $ifmodifiedsince . + "User-Agent: PEAR/@package_version@/PHP/" . PHP_VERSION . "\r\n"; + if (isset($this)) { // only pass in authentication for non-static calls + $username = $config->get('username'); + $password = $config->get('password'); + if ($username && $password) { + $tmp = base64_encode("$username:$password"); + $request .= "Authorization: Basic $tmp\r\n"; + } + } + if ($proxy_host != '' && $proxy_user != '') { + $request .= 'Proxy-Authorization: Basic ' . + base64_encode($proxy_user . ':' . $proxy_pass) . "\r\n"; + } + if ($accept) { + $request .= 'Accept: ' . implode(', ', $accept) . "\r\n"; + } + $request .= "Connection: close\r\n"; + $request .= "\r\n"; + fwrite($fp, $request); + $headers = array(); + $reply = 0; + while (trim($line = fgets($fp, 1024))) { + if (preg_match('/^([^:]+):\s+(.*)\s*$/', $line, $matches)) { + $headers[strtolower($matches[1])] = trim($matches[2]); + } elseif (preg_match('|^HTTP/1.[01] ([0-9]{3}) |', $line, $matches)) { + $reply = (int) $matches[1]; + if ($reply == 304 && ($lastmodified || ($lastmodified === false))) { + return false; + } + if (! in_array($reply, array(200, 301, 302, 303, 305, 307))) { + return PEAR::raiseError("File http://$host:$port$path not valid (received: $line)"); + } + } + } + if ($reply != 200) { + if (isset($headers['location'])) { + if ($wasredirect < 5) { + $redirect = $wasredirect + 1; + return $this->downloadHttp($headers['location'], + $ui, $save_dir, $callback, $lastmodified, $accept); + } else { + return PEAR::raiseError("File http://$host:$port$path not valid (redirection looped more than 5 times)"); + } + } else { + return PEAR::raiseError("File http://$host:$port$path not valid (redirected but no location)"); + } + } + if (isset($headers['content-disposition']) && + preg_match('/\sfilename=\"([^;]*\S)\"\s*(;|$)/', $headers['content-disposition'], $matches)) { + $save_as = basename($matches[1]); + } else { + $save_as = basename($url); + } + if ($callback) { + $tmp = call_user_func($callback, 'saveas', $save_as); + if ($tmp) { + $save_as = $tmp; + } + } + $dest_file = $save_dir . DIRECTORY_SEPARATOR . $save_as; + if (!$wp = @fopen($dest_file, 'wb')) { + fclose($fp); + if ($callback) { + call_user_func($callback, 'writefailed', array($dest_file, $php_errormsg)); + } + return PEAR::raiseError("could not open $dest_file for writing"); + } + if (isset($headers['content-length'])) { + $length = $headers['content-length']; + } else { + $length = -1; + } + $bytes = 0; + if ($callback) { + call_user_func($callback, 'start', array(basename($dest_file), $length)); + } + while ($data = fread($fp, 1024)) { + $bytes += strlen($data); + if ($callback) { + call_user_func($callback, 'bytesread', $bytes); + } + if (!@fwrite($wp, $data)) { + fclose($fp); + if ($callback) { + call_user_func($callback, 'writefailed', array($dest_file, $php_errormsg)); + } + return PEAR::raiseError("$dest_file: write failed ($php_errormsg)"); + } + } + fclose($fp); + fclose($wp); + if ($callback) { + call_user_func($callback, 'done', $bytes); + } + if ($lastmodified === false || $lastmodified) { + if (isset($headers['etag'])) { + $lastmodified = array('ETag' => $headers['etag']); + } + if (isset($headers['last-modified'])) { + if (is_array($lastmodified)) { + $lastmodified['Last-Modified'] = $headers['last-modified']; + } else { + $lastmodified = $headers['last-modified']; + } + } + return array($dest_file, $lastmodified, $headers); + } + return $dest_file; + } +} +// }}} + +?> http://cvs.php.net/viewcvs.cgi/pear-core/PEAR/Downloader/Package.php?r1=1.94&r2=1.95&diff_format=u Index: pear-core/PEAR/Downloader/Package.php diff -u pear-core/PEAR/Downloader/Package.php:1.94 pear-core/PEAR/Downloader/Package.php:1.95 --- pear-core/PEAR/Downloader/Package.php:1.94 Mon Mar 27 21:14:28 2006 +++ pear-core/PEAR/Downloader/Package.php Tue Mar 28 03:51:40 2006 @@ -1,1741 +1,1741 @@ -<?php -/** - * PEAR_Downloader_Package - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 3.0 of the PHP license - * that is available through the world-wide-web at the following URI: - * http://www.php.net/license/3_0.txt. If you did not receive a copy of - * the PHP License and are unable to obtain it through the web, please - * send a note to license@php.net so we can mail you a copy immediately. - * - * @category pear - * @package PEAR - * @author Greg Beaver <cellog@php.net> - * @copyright 1997-2006 The PHP Group - * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Package.php,v 1.94 2006/03/27 21:14:28 cellog Exp $ - * @link http://pear.php.net/package/PEAR - * @since File available since Release 1.4.0a1 - */ -/** - * Error code when parameter initialization fails because no releases - * exist within preferred_state, but releases do exist - */ -define('PEAR_DOWNLOADER_PACKAGE_STATE', -1003); -/** - * Coordinates download parameters and manages their dependencies - * prior to downloading them. - * - * Input can come from three sources: - * - * - local files (archives or package.xml) - * - remote files (downloadable urls) - * - abstract package names - * - * The first two elements are handled cleanly by PEAR_PackageFile, but the third requires - * accessing pearweb's xml-rpc interface to determine necessary dependencies, and the - * format returned of dependencies is slightly different from that used in package.xml. - * - * This class hides the differences between these elements, and makes automatic - * dependency resolution a piece of cake. It also manages conflicts when - * two classes depend on incompatible dependencies, or differing versions of the same - * package dependency. In addition, download will not be attempted if the php version is - * not supported, PEAR installer version is not supported, or non-PECL extensions are not - * installed. - * @category pear - * @package PEAR - * @author Greg Beaver <cellog@php.net> - * @copyright 1997-2006 The PHP Group - * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version Release: @PEAR-VER@ - * @link http://pear.php.net/package/PEAR - * @since Class available since Release 1.4.0a1 - */ -class PEAR_Downloader_Package -{ - /** - * @var PEAR_Downloader - */ - var $_downloader; - /** - * @var PEAR_Config - */ - var $_config; - /** - * @var PEAR_Registry - */ - var $_registry; - /** - * Used to implement packagingroot properly - * @var PEAR_Registry - */ - var $_installRegistry; - /** - * @var PEAR_PackageFile_v1|PEAR_PackageFile|v2 - */ - var $_packagefile; - /** - * @var array - */ - var $_parsedname; - /** - * @var array - */ - var $_downloadURL; - /** - * @var array - */ - var $_downloadDeps = array(); - /** - * @var boolean - */ - var $_valid = false; - /** - * @var boolean - */ - var $_analyzed = false; - /** - * if this or a parent package was invoked with Package-state, this is set to the - * state variable. - * - * This allows temporary reassignment of preferred_state for a parent package and all of - * its dependencies. - * @var string|false - */ - var $_explicitState = false; - /** - * If this package is invoked with Package#group, this variable will be true - */ - var $_explicitGroup = false; - /** - * Package type local|url|xmlrpc - * @var string - */ - var $_type; - /** - * Contents of package.xml, if downloaded from a remote channel - * @var string|false - * @access private - */ - var $_rawpackagefile; - /** - * @var boolean - * @access private - */ - var $_validated = false; - - /** - * @param PEAR_Downloader - */ - function PEAR_Downloader_Package(&$downloader) - { - $this->_downloader = &$downloader; - $this->_config = &$this->_downloader->config; - $this->_registry = &$this->_config->getRegistry(); - $options = $downloader->getOptions(); - if (isset($options['packagingroot'])) { - $this->_config->setInstallRoot($options['packagingroot']); - $this->_installRegistry = &$this->_config->getRegistry(); - $this->_config->setInstallRoot(false); - } else { - $this->_installRegistry = &$this->_registry; - } - $this->_valid = $this->_analyzed = false; - } - - /** - * Parse the input and determine whether this is a local file, a remote uri, or an - * abstract package name. - * - * This is the heart of the PEAR_Downloader_Package(), and is used in - * {@link PEAR_Downloader::download()} - * @param string - * @return bool|PEAR_Error - */ - function initialize($param) - { - $origErr = $this->_fromFile($param); - if (!$this->_valid) { - $options = $this->_downloader->getOptions(); - if (isset($options['offline'])) { - if (PEAR::isError($origErr)) { - if (!isset($options['soft'])) { - $this->_downloader->log(0, $origErr->getMessage()); - } - } - return PEAR::raiseError('Cannot download non-local package "' . $param . '"'); - } - $err = $this->_fromUrl($param); - if (PEAR::isError($err) || !$this->_valid) { - if ($this->_type == 'url') { - if (PEAR::isError($err)) { - if (!isset($options['soft'])) { - $this->_downloader->log(0, $err->getMessage()); - } - } - return PEAR::raiseError("Invalid or missing remote package file"); - } - $err = $this->_fromString($param); - if (PEAR::isError($err) || !$this->_valid) { - if (PEAR::isError($err) && - $err->getCode() == PEAR_DOWNLOADER_PACKAGE_STATE) { - return false; // instruct the downloader to silently skip - } - if (isset($this->_type) && $this->_type == 'local' && - PEAR::isError($origErr)) { - if (is_array($origErr->getUserInfo())) { - foreach ($origErr->getUserInfo() as $err) { - if (is_array($err)) { - $err = $err['message']; - } - if (!isset($options['soft'])) { - $this->_downloader->log(0, $err); - } - } - } - if (!isset($options['soft'])) { - $this->_downloader->log(0, $origErr->getMessage()); - } - if (is_array($param)) { - $param = $this->_registry->parsedPackageNameToString($param, - true); - } - return PEAR::raiseError( - "Cannot initialize '$param', invalid or missing package file"); - } - if (PEAR::isError($err)) { - if (!isset($options['soft'])) { - $this->_downloader->log(0, $err->getMessage()); - } - } - if (is_array($param)) { - $param = $this->_registry->parsedPackageNameToString($param, true); - } - return PEAR::raiseError( - "Cannot initialize '$param', invalid or missing package file"); - } - } - } - return true; - } - - /** - * Retrieve any non-local packages - * @return PEAR_PackageFile_v1|PEAR_PackageFile_v2|PEAR_Error - */ - function &download() - { - if (isset($this->_packagefile)) { - return $this->_packagefile; - } - if (isset($this->_downloadURL['url'])) { - $this->_isvalid = false; - $info = $this->getParsedPackage(); - foreach ($info as $i => $p) { - $info[$i] = strtolower($p); - } - $err = $this->_fromUrl($this->_downloadURL['url'], - $this->_registry->parsedPackageNameToString($this->_parsedname, true)); - $newinfo = $this->getParsedPackage(); - foreach ($newinfo as $i => $p) { - $newinfo[$i] = strtolower($p); - } - if ($info != $newinfo) { - do { - if ($info['package'] == 'pecl.php.net' && $newinfo['package'] == 'pear.php.net') { - $info['package'] = 'pear.php.net'; - if ($info == $newinfo) { - // skip the channel check if a pecl package says it's a PEAR package - break; - } - } - return PEAR::raiseError('CRITICAL ERROR: We are ' . - $this->_registry->parsedPackageNameToString($info) . ', but the file ' . - 'downloaded claims to be ' . - $this->_registry->parsedPackageNameToString($this->getParsedPackage())); - } while (false); - } - if (PEAR::isError($err) || !$this->_valid) { - return $err; - } - } - $this->_type = 'local'; - return $this->_packagefile; - } - - function &getPackageFile() - { - return $this->_packagefile; - } - - function &getDownloader() - { - return $this->_downloader; - } - - function getType() - { - return $this->_type; - } - - /** - * Like {@link initialize()}, but operates on a dependency - */ - function fromDepURL($dep) - { - $this->_downloadURL = $dep; - if (isset($dep['uri'])) { - $options = $this->_downloader->getOptions(); - if (!extension_loaded("zlib") || isset($options['nocompress'])) { - $ext = '.tar'; - } else { - $ext = '.tgz'; - } - PEAR::pushErrorHandling(PEAR_ERROR_RETURN); - $err = $this->_fromUrl($dep['uri'] . $ext); - PEAR::popErrorHandling(); - if (PEAR::isError($err)) { - if (!isset($options['soft'])) { - $this->_downloader->log(0, $err->getMessage()); - } - return PEAR::raiseError('Invalid uri dependency "' . $dep['uri'] . $ext . '", ' . - 'cannot download'); - } - } else { - $this->_parsedname = - array( - 'package' => $dep['info']->getPackage(), - 'channel' => $dep['info']->getChannel(), - 'version' => $dep['version'] - ); - if (!isset($dep['nodefault'])) { - $this->_parsedname['group'] = 'default'; // download the default dependency group - $this->_explicitGroup = false; - } - $this->_rawpackagefile = $dep['raw']; - } - } - - function detectDependencies($params) - { - $options = $this->_downloader->getOptions(); - if (isset($options['downloadonly'])) { - return; - } - if (isset($options['offline'])) { - $this->_downloader->log(3, 'Skipping dependency download check, --offline specified'); - return; - } - $pname = $this->getParsedPackage(); - if (!$pname) { - return; - } - $deps = $this->getDeps(); - if (!$deps) { - return; - } - if (isset($deps['required'])) { // package.xml 2.0 - return $this->_detect2($deps, $pname, $options, $params); - } else { - return $this->_detect1($deps, $pname, $options, $params); - } - } - - function setValidated() - { - $this->_validated = true; - } - - function alreadyValidated() - { - return $this->_validated; - } - - /** - * Remove packages to be downloaded that are already installed - * @param array of PEAR_Downloader_Package objects - * @static - */ - function removeInstalled(&$params) - { - if (!isset($params[0])) { - return; - } - $options = $params[0]->_downloader->getOptions(); - if (!isset($options['downloadonly'])) { - foreach ($params as $i => $param) { - // remove self if already installed with this version - // this does not need any pecl magic - we only remove exact matches - if ($param->_installRegistry->packageExists($param->getPackage(), $param->getChannel())) { - if (version_compare($param->_installRegistry->packageInfo($param->getPackage(), 'version', - $param->getChannel()), $param->getVersion(), '==')) { - if (!isset($options['force'])) { - $info = $param->getParsedPackage(); - unset($info['version']); - unset($info['state']); - if (!isset($options['soft'])) { - $param->_downloader->log(1, 'Skipping package "' . - $param->getShortName() . - '", already installed as version ' . - $param->_installRegistry->packageInfo($param->getPackage(), - 'version', $param->getChannel())); - } - $params[$i] = false; - } - } elseif (!isset($options['force']) && !isset($options['upgrade']) && - !isset($options['soft'])) { - $info = $param->getParsedPackage(); - $param->_downloader->log(1, 'Skipping package "' . - $param->getShortName() . - '", already installed as version ' . - $param->_installRegistry->packageInfo($param->getPackage(), 'version', - $param->getChannel())); - $params[$i] = false; - } - } - } - } - PEAR_Downloader_Package::removeDuplicates($params); - } - - function _detect2($deps, $pname, $options, $params) - { - $this->_downloadDeps = array(); - $groupnotfound = false; - foreach (array('package', 'subpackage') as $packagetype) { - // get required dependency group - if (isset($deps['required'][$packagetype])) { - if (isset($deps['required'][$packagetype][0])) { - foreach ($deps['required'][$packagetype] as $dep) { - if (isset($dep['conflicts'])) { - // skip any package that this package conflicts with - continue; - } - $ret = $this->_detect2Dep($dep, $pname, 'required', $params); - if (is_array($ret)) { - $this->_downloadDeps[] = $ret; - } - } - } else { - $dep = $deps['required'][$packagetype]; - if (!isset($dep['conflicts'])) { - // skip any package that this package conflicts with - $ret = $this->_detect2Dep($dep, $pname, 'required', $params); - if (is_array($ret)) { - $this->_downloadDeps[] = $ret; - } - } - } - } - // get optional dependency group, if any - if (isset($deps['optional'][$packagetype])) { - $skipnames = array(); - if (!isset($deps['optional'][$packagetype][0])) { - $deps['optional'][$packagetype] = array($deps['optional'][$packagetype]); - } - foreach ($deps['optional'][$packagetype] as $dep) { - $skip = false; - if (!isset($options['alldeps'])) { - $dep['package'] = $dep['name']; - if (!isset($options['soft'])) { - $this->_downloader->log(3, 'Notice: package "' . - $this->_registry->parsedPackageNameToString($this->getParsedPackage(), - true) . '" optional dependency "' . - $this->_registry->parsedPackageNameToString(array('package' => - $dep['name'], 'channel' => 'pear.php.net'), true) . - '" will not be automatically downloaded'); - } - $skipnames[] = $this->_registry->parsedPackageNameToString($dep, true); - $skip = true; - unset($dep['package']); - } - if (!($ret = $this->_detect2Dep($dep, $pname, 'optional', $params))) { - $dep['package'] = $dep['name']; - $skip = count($skipnames) ? - $skipnames[count($skipnames) - 1] : ''; - if ($skip == - $this->_registry->parsedPackageNameToString($dep, true)) { - array_pop($skipnames); - } - } - if (!$skip && is_array($ret)) { - $this->_downloadDeps[] = $ret; - } - } - if (count($skipnames)) { - if (!isset($options['soft'])) { - $this->_downloader->log(1, 'Did not download optional dependencies: ' . - implode(', ', $skipnames) . - ', use --alldeps to download automatically'); - } - } - } - // get requested dependency group, if any - $groupname = $this->getGroup(); - $explicit = $this->_explicitGroup; - if (!$groupname) { - if ($this->canDefault()) { - $groupname = 'default'; // try the default dependency group - } else { - continue; - } - } - if ($groupnotfound) { - continue; - } - if (isset($deps['group'])) { - if (isset($deps['group']['attribs'])) { - if (strtolower($deps['group']['attribs']['name']) == strtolower($groupname)) { - $group = $deps['group']; - } elseif ($explicit) { - if (!isset($options['soft'])) { - $this->_downloader->log(0, 'Warning: package "' . - $this->_registry->parsedPackageNameToString($pname, true) . - '" has no dependency ' . 'group named "' . $groupname . '"'); - } - $groupnotfound = true; - continue; - } - } else { - $found = false; - foreach ($deps['group'] as $group) { - if (strtolower($group['attribs']['name']) == strtolower($groupname)) { - $found = true; - break; - } - } - if (!$found) { - if ($explicit) { - if (!isset($options['soft'])) { - $this->_downloader->log(0, 'Warning: package "' . - $this->_registry->parsedPackageNameToString($pname, true) . - '" has no dependency ' . 'group named "' . $groupname . '"'); - } - } - $groupnotfound = true; - continue; - } - } - } - if (isset($group)) { - if (isset($group[$packagetype])) { - if (isset($group[$packagetype][0])) { - foreach ($group[$packagetype] as $dep) { - $ret = $this->_detect2Dep($dep, $pname, 'dependency group "' . - $group['attribs']['name'] . '"', $params); - if (is_array($ret)) { - $this->_downloadDeps[] = $ret; - } - } - } else { - $ret = $this->_detect2Dep($group[$packagetype], $pname, - 'dependency group "' . - $group['attribs']['name'] . '"', $params); - if (is_array($ret)) { - $this->_downloadDeps[] = $ret; - } - } - } - } - } - } - - function _detect2Dep($dep, $pname, $group, $params) - { - if (isset($dep['conflicts'])) { - return true; - } - $options = $this->_downloader->getOptions(); - if (isset($dep['uri'])) { - return array('uri' => $dep['uri'], 'dep' => $dep);; - } - $testdep = $dep; - $testdep['package'] = $dep['name']; - if (PEAR_Downloader_Package::willDownload($testdep, $params)) { - $dep['package'] = $dep['name']; - if (!isset($options['soft'])) { - $this->_downloader->log(2, $this->getShortName() . ': Skipping ' . $group . - ' dependency "' . - $this->_registry->parsedPackageNameToString($dep, true) . - '", will be installed'); - } - return false; - } - $options = $this->_downloader->getOptions(); - PEAR::pushErrorHandling(PEAR_ERROR_RETURN); - if ($this->_explicitState) { - $pname['state'] = $this->_explicitState; - } - $url = - $this->_downloader->_getDepPackageDownloadUrl($dep, $pname); - if (PEAR::isError($url)) { - PEAR::popErrorHandling(); - return $url; - } - $dep['package'] = $dep['name']; - $ret = $this->_analyzeDownloadURL($url, 'dependency', $dep, $params, $group == 'optional' && - !isset($options['alldeps']), true); - PEAR::popErrorHandling(); - if (PEAR::isError($ret)) { - if (!isset($options['soft'])) { - $this->_downloader->log(0, $ret->getMessage()); - } - return false; - } else { - // check to see if a dep is already installed and is the same or newer - if (!isset($dep['min']) && !isset($dep['max']) && !isset($dep['recommended'])) { - $oper = 'has'; - } else { - $oper = 'gt'; - } - // do not try to move this before getDepPackageDownloadURL - // we can't determine whether upgrade is necessary until we know what - // version would be downloaded - if (!isset($options['force']) && $this->isInstalled($ret, $oper)) { - $version = $this->_installRegistry->packageInfo($dep['name'], 'version', - $dep['channel']); - $dep['package'] = $dep['name']; - if (!isset($options['soft'])) { - $this->_downloader->log(3, $this->getShortName() . ': Skipping ' . $group . - ' dependency "' . - $this->_registry->parsedPackageNameToString($dep, true) . - '" version ' . $url['version'] . ', already installed as version ' . - $version); - } - return false; - } - } - if (isset($dep['nodefault'])) { - $ret['nodefault'] = true; - } - return $ret; - } - - function _detect1($deps, $pname, $options, $params) - { - $this->_downloadDeps = array(); - $skipnames = array(); - foreach ($deps as $dep) { - $nodownload = false; - if ($dep['type'] == 'pkg') { - $dep['channel'] = 'pear.php.net'; - $dep['package'] = $dep['name']; - switch ($dep['rel']) { - case 'not' : - continue 2; - case 'ge' : - case 'eq' : - case 'gt' : - case 'has' : - $group = (!isset($dep['optional']) || $dep['optional'] == 'no') ? - 'required' : - 'optional'; - if (PEAR_Downloader_Package::willDownload($dep, $params)) { - $this->_downloader->log(2, $this->getShortName() . ': Skipping ' . $group - . ' dependency "' . - $this->_registry->parsedPackageNameToString($dep, true) . - '", will be installed'); - continue 2; - } - $fakedp = new PEAR_PackageFile_v1; - $fakedp->setPackage($dep['name']); - // skip internet check if we are not upgrading (bug #5810) - if (!isset($options['upgrade']) && $this->isInstalled( - $fakedp, $dep['rel'])) { - $this->_downloader->log(2, $this->getShortName() . ': Skipping ' . $group - . ' dependency "' . - $this->_registry->parsedPackageNameToString($dep, true) . - '", is already installed'); - continue 2; - } - } - PEAR::pushErrorHandling(PEAR_ERROR_RETURN); - if ($this->_explicitState) { - $pname['state'] = $this->_explicitState; - } - $url = - $this->_downloader->_getDepPackageDownloadUrl($dep, $pname); - $chan = 'pear.php.net'; - if (PEAR::isError($url)) { - // check to see if this is a pecl package that has jumped - // from pear.php.net to pecl.php.net channel - if (!class_exists('PEAR_Dependency2')) { - require_once 'PEAR/Dependency2.php'; - } - $newdep = PEAR_Dependency2::normalizeDep($dep); - $newdep = $newdep[0]; - $newdep['channel'] = 'pecl.php.net'; - $chan = 'pecl.php.net'; - $url = - $this->_downloader->_getDepPackageDownloadUrl($newdep, $pname); - $obj = &$this->_installRegistry->getPackage($dep['name']); - if (PEAR::isError($url)) { - PEAR::popErrorHandling(); - if ($obj !== null && $this->isInstalled($obj, $dep['rel'])) { - $group = (!isset($dep['optional']) || $dep['optional'] == 'no') ? - 'required' : - 'optional'; - $dep['package'] = $dep['name']; - if (!isset($options['soft'])) { - $this->_downloader->log(3, $this->getShortName() . - ': Skipping ' . $group . ' dependency "' . - $this->_registry->parsedPackageNameToString($dep, true) . - '", already installed as version ' . $obj->getVersion()); - } - $skip = count($skipnames) ? - $skipnames[count($skipnames) - 1] : ''; - if ($skip == - $this->_registry->parsedPackageNameToString($dep, true)) { - array_pop($skipnames); - } - continue; - } else { - if (isset($dep['optional']) && $dep['optional'] == 'yes') { - $this->_downloader->log(2, $this->getShortName() . - ': Skipping ' . $group - . ' dependency "' . - $this->_registry->parsedPackageNameToString($dep, true) . - '", no releases exist'); - continue; - } else { - return $url; - } - } - } - } - PEAR::popErrorHandling(); - if (!isset($options['alldeps'])) { - if (isset($dep['optional']) && $dep['optional'] == 'yes') { - if (!isset($options['soft'])) { - $this->_downloader->log(3, 'Notice: package "' . - $this->getShortName() . - '" optional dependency "' . - $this->_registry->parsedPackageNameToString( - array('channel' => $chan, 'package' => - $dep['name']), true) . - '" will not be automatically downloaded'); - } - $skipnames[] = $this->_registry->parsedPackageNameToString( - array('channel' => $chan, 'package' => - $dep['name']), true); - $nodownload = true; - } - } - if (!isset($options['alldeps']) && !isset($options['onlyreqdeps'])) { - if (!isset($dep['optional']) || $dep['optional'] == 'no') { - if (!isset($options['soft'])) { - $this->_downloader->log(3, 'Notice: package "' . - $this->getShortName() . - '" required dependency "' . - $this->_registry->parsedPackageNameToString( - array('channel' => $chan, 'package' => - $dep['name']), true) . - '" will not be automatically downloaded'); - } - $skipnames[] = $this->_registry->parsedPackageNameToString( - array('channel' => $chan, 'package' => - $dep['name']), true); - $nodownload = true; - } - } - // check to see if a dep is already installed - // do not try to move this before getDepPackageDownloadURL - // we can't determine whether upgrade is necessary until we know what - // version would be downloaded - if (!isset($options['force']) && $this->isInstalled( - $url, $dep['rel'])) { - $group = (!isset($dep['optional']) || $dep['optional'] == 'no') ? - 'required' : - 'optional'; - $dep['package'] = $dep['name']; - if (isset($newdep)) { - $version = $this->_installRegistry->packageInfo($newdep['name'], 'version', - $newdep['channel']); - } else { - $version = $this->_installRegistry->packageInfo($dep['name'], 'version'); - } - $dep['version'] = $url['version']; - if (!isset($options['soft'])) { - $this->_downloader->log(3, $this->getShortName() . ': Skipping ' . $group . - ' dependency "' . - $this->_registry->parsedPackageNameToString($dep, true) . - '", already installed as version ' . $version); - } - $skip = count($skipnames) ? - $skipnames[count($skipnames) - 1] : ''; - if ($skip == - $this->_registry->parsedPackageNameToString($dep, true)) { - array_pop($skipnames); - } - continue; - } - if ($nodownload) { - continue; - } - PEAR::pushErrorHandling(PEAR_ERROR_RETURN); - if (isset($newdep)) { - $dep = $newdep; - } - $dep['package'] = $dep['name']; - $ret = $this->_analyzeDownloadURL($url, 'dependency', $dep, $params, - isset($dep['optional']) && $dep['optional'] == 'yes' && - !isset($options['alldeps']), true); - PEAR::popErrorHandling(); - if (PEAR::isError($ret)) { - if (!isset($options['soft'])) { - $this->_downloader->log(0, $ret->getMessage()); - } - continue; - } - $this->_downloadDeps[] = $ret; - } - } - if (count($skipnames)) { - if (!isset($options['soft'])) { - $this->_downloader->log(1, 'Did not download dependencies: ' . - implode(', ', $skipnames) . - ', use --alldeps or --onlyreqdeps to download automatically'); - } - } - } - - function setDownloadURL($pkg) - { - $this->_downloadURL = $pkg; - } - - /** - * Set the package.xml object for this downloaded package - * - * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2 $pkg - */ - function setPackageFile(&$pkg) - { - $this->_packagefile = &$pkg; - } - - function getShortName() - { - return $this->_registry->parsedPackageNameToString(array('channel' => $this->getChannel(), - 'package' => $this->getPackage()), true); - } - - function getParsedPackage() - { - if (isset($this->_packagefile) || isset($this->_parsedname)) { - return array('channel' => $this->getChannel(), - 'package' => $this->getPackage(), - 'version' => $this->getVersion()); - } - return false; - } - - function getDownloadURL() - { - return $this->_downloadURL; - } - - function canDefault() - { - if (isset($this->_downloadURL)) { - if (isset($this->_downloadURL['nodefault'])) { - return false; - } - } - return true; - } - - function getPackage() - { - if (isset($this->_packagefile)) { - return $this->_packagefile->getPackage(); - } elseif (isset($this->_downloadURL['info'])) { - return $this->_downloadURL['info']->getPackage(); - } else { - return false; - } - } - - /** - * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2 - */ - function isSubpackage(&$pf) - { - if (isset($this->_packagefile)) { - return $this->_packagefile->isSubpackage($pf); - } elseif (isset($this->_downloadURL['info'])) { - return $this->_downloadURL['info']->isSubpackage($pf); - } else { - return false; - } - } - - function getPackageType() - { - if (isset($this->_packagefile)) { - return $this->_packagefile->getPackageType(); - } elseif (isset($this->_downloadURL['info'])) { - return $this->_downloadURL['info']->getPackageType(); - } else { - return false; - } - } - - function isBundle() - { - if (isset($this->_packagefile)) { - return $this->_packagefile->getPackageType() == 'bundle'; - } else { - return false; - } - } - - function getPackageXmlVersion() - { - if (isset($this->_packagefile)) { - return $this->_packagefile->getPackagexmlVersion(); - } elseif (isset($this->_downloadURL['info'])) { - return $this->_downloadURL['info']->getPackagexmlVersion(); - } else { - return '1.0'; - } - } - - function getChannel() - { - if (isset($this->_packagefile)) { - return $this->_packagefile->getChannel(); - } elseif (isset($this->_downloadURL['info'])) { - return $this->_downloadURL['info']->getChannel(); - } else { - return false; - } - } - - function getURI() - { - if (isset($this->_packagefile)) { - return $this->_packagefile->getURI(); - } elseif (isset($this->_downloadURL['info'])) { - return $this->_downloadURL['info']->getURI(); - } else { - return false; - } - } - - function getVersion() - { - if (isset($this->_packagefile)) { - return $this->_packagefile->getVersion(); - } elseif (isset($this->_downloadURL['version'])) { - return $this->_downloadURL['version']; - } else { - return false; - } - } - - function isCompatible($pf) - { - if (isset($this->_packagefile)) { - return $this->_packagefile->isCompatible($pf); - } elseif (isset($this->_downloadURL['info'])) { - return $this->_downloadURL['info']->isCompatible($pf); - } else { - return true; - } - } - - function setGroup($group) - { - $this->_parsedname['group'] = $group; - } - - function getGroup() - { - if (isset($this->_parsedname['group'])) { - return $this->_parsedname['group']; - } else { - return ''; - } - } - - function isExtension($name) - { - if (isset($this->_packagefile)) { - return $this->_packagefile->isExtension($name); - } elseif (isset($this->_downloadURL['info'])) { - return $this->_downloadURL['info']->getProvidesExtension() == $name; - } else { - return false; - } - } - - function getDeps() - { - if (isset($this->_packagefile)) { - if ($this->_packagefile->getPackagexmlVersion() == '2.0') { - return $this->_packagefile->getDeps(true); - } else { - return $this->_packagefile->getDeps(); - } - } elseif (isset($this->_downloadURL['info'])) { - if ($this->_downloadURL['info']->getPackagexmlVersion() == '2.0') { - return $this->_downloadURL['info']->getDeps(true); - } else { - return $this->_downloadURL['info']->getDeps(); - } - } else { - return array(); - } - } - - /** - * @param array Parsed array from {@link PEAR_Registry::parsePackageName()} or a dependency - * returned from getDepDownloadURL() - */ - function isEqual($param) - { - if (is_object($param)) { - $channel = $param->getChannel(); - $package = $param->getPackage(); - if ($param->getURI()) { - $param = array( - 'channel' => $param->getChannel(), - 'package' => $param->getPackage(), - 'version' => $param->getVersion(), - 'uri' => $param->getURI(), - ); - } else { - $param = array( - 'channel' => $param->getChannel(), - 'package' => $param->getPackage(), - 'version' => $param->getVersion(), - ); - } - } else { - if (isset($param['uri'])) { - $param['channel'] = '__uri'; - $param['package'] = $param['dep']['name']; - } - $package = isset($param['package']) ? $param['package'] : - $param['info']->getPackage(); - $channel = isset($param['channel']) ? $param['channel'] : - $param['info']->getChannel(); - if (isset($param['rel'])) { - if (!class_exists('PEAR_Dependency2')) { - require_once 'PEAR/Dependency2.php'; - } - $newdep = PEAR_Dependency2::normalizeDep($param); - $newdep = $newdep[0]; - } elseif (isset($param['min'])) { - $newdep = $param; - } - } - if (isset($newdep)) { - if (!isset($newdep['min'])) { - $newdep['min'] = '0'; - } - if (!isset($newdep['max'])) { - $newdep['max'] = '100000000000000000000'; - } - // use magic to support pecl packages suddenly jumping to the pecl channel - // we need to support both dependency possibilities - if ($channel == 'pear.php.net' && $this->getChannel() == 'pecl.php.net') { - if ($package == $this->getPackage()) { - $channel = 'pecl.php.net'; - } - } - if ($channel == 'pecl.php.net' && $this->getChannel() == 'pear.php.net') { - if ($package == $this->getPackage()) { - $channel = 'pear.php.net'; - } - } - return (strtolower($package) == strtolower($this->getPackage()) && - $channel == $this->getChannel() && - version_compare($newdep['min'], $this->getVersion(), '<=') && - version_compare($newdep['max'], $this->getVersion(), '>=')); - } - // use magic to support pecl packages suddenly jumping to the pecl channel - if ($channel == 'pecl.php.net' && $this->getChannel() == 'pear.php.net') { - if (strtolower($package) == strtolower($this->getPackage())) { - $channel = 'pear.php.net'; - } - } - if (isset($param['version'])) { - return (strtolower($package) == strtolower($this->getPackage()) && - $channel == $this->getChannel() && - $param['version'] == $this->getVersion()); - } else { - return strtolower($package) == strtolower($this->getPackage()) && - $channel == $this->getChannel(); - } - } - - function isInstalled($dep, $oper = '==') - { - if (!$dep) { - return false; - } - if ($oper != 'ge' && $oper != 'gt' && $oper != 'has' && $oper != '==') { - return false; - } - if (is_object($dep)) { - $package = $dep->getPackage(); - $channel = $dep->getChannel(); - if ($dep->getURI()) { - $dep = array( - 'uri' => $dep->getURI(), - 'version' => $dep->getVersion(), - ); - } else { - $dep = array( - 'version' => $dep->getVersion(), - ); - } - } else { - if (isset($dep['uri'])) { - $channel = '__uri'; - $package = $dep['dep']['name']; - } else { - $channel = $dep['info']->getChannel(); - $package = $dep['info']->getPackage(); - } - } - $options = $this->_downloader->getOptions(); - $test = $this->_installRegistry->packageExists($package, $channel); - if (!$test && $channel == 'pecl.php.net') { - // do magic to allow upgrading from old pecl packages to new ones - $test = $this->_installRegistry->packageExists($package, 'pear.php.net'); - $channel = 'pear.php.net'; - } - if ($test) { - if (isset($dep['uri'])) { - if ($this->_installRegistry->packageInfo($package, 'uri', '__uri') == $dep['uri']) { - return true; - } - } - if (isset($options['upgrade'])) { - if ($oper == 'has') { - if (version_compare($this->_installRegistry->packageInfo( - $package, 'version', $channel), - $dep['version'], '>=')) { - return true; - } else { - return false; - } - } else { - if (version_compare($this->_installRegistry->packageInfo( - $package, 'version', $channel), - $dep['version'], '>=')) { - return true; - } - return false; - } - } - return true; - } - return false; - } - - /** - * @param array - * @static - */ - function removeDuplicates(&$params) - { - $pnames = array(); - foreach ($params as $i => $param) { - if (!$param) { - continue; - } - if ($param->getPackage()) { - $pnames[$i] = $param->getChannel() . '/' . - $param->getPackage() . '-' . $param->getVersion() . '#' . $param->getGroup(); - } - } - $pnames = array_unique($pnames); - $unset = array_diff(array_keys($params), array_keys($pnames)); - $testp = array_flip($pnames); - foreach ($params as $i => $param) { - if (!$param) { - $unset[] = $i; - continue; - } - if (!is_a($param, 'PEAR_Downloader_Package')) { - $unset[] = $i; - continue; - } - if (!isset($testp[$param->getChannel() . '/' . $param->getPackage() . '-' . - $param->getVersion() . '#' . $param->getGroup()])) { - $unset[] = $i; - } - } - foreach ($unset as $i) { - unset($params[$i]); - } - $ret = array(); - foreach ($params as $i => $param) { - $ret[] = &$params[$i]; - } - $params = array(); - foreach ($ret as $i => $param) { - $params[] = &$ret[$i]; - } - } - - function explicitState() - { - return $this->_explicitState; - } - - function setExplicitState($s) - { - $this->_explicitState = $s; - } - - /** - * @static - */ - function mergeDependencies(&$params) - { - $newparams = array(); - $bundles = array(); - foreach ($params as $i => $param) { - if (!$param->isBundle()) { - continue; - } - $bundles[] = $i; - $pf = &$param->getPackageFile(); - $newdeps = array(); - $contents = $pf->getBundledPackages(); - if (!is_array($contents)) { - $contents = array($contents); - } - foreach ($contents as $file) { - $filecontents = $pf->getFileContents($file); - $dl = &$param->getDownloader(); - $options = $dl->getOptions(); - $fp = @fopen($dl->getDownloadDir() . DIRECTORY_SEPARATOR . $file, 'wb'); - if (!$fp) { - continue; - } - fwrite($fp, $filecontents, strlen($filecontents)); - fclose($fp); - if ($s = $params[$i]->explicitState()) { - $obj->setExplicitState($s); - } - $obj = &new PEAR_Downloader_Package($params[$i]->getDownloader()); - PEAR::pushErrorHandling(PEAR_ERROR_RETURN); - $e = $obj->_fromFile($a = $dl->getDownloadDir() . DIRECTORY_SEPARATOR . $file); - PEAR::popErrorHandling(); - if (PEAR::isError($e)) { - if (!isset($options['soft'])) { - $dl->log(0, $e->getMessage()); - } - continue; - } - $j = &$obj; - if (!PEAR_Downloader_Package::willDownload($j, - array_merge($params, $newparams)) && !$param->isInstalled($j)) { - $newparams[] = &$j; - } - } - } - foreach ($bundles as $i) { - unset($params[$i]); // remove bundles - only their contents matter for installation - } - PEAR_Downloader_Package::removeDuplicates($params); // strip any unset indices - if (count($newparams)) { // add in bundled packages for install - foreach ($newparams as $i => $unused) { - $params[] = &$newparams[$i]; - } - $newparams = array(); - } - foreach ($params as $i => $param) { - $newdeps = array(); - foreach ($param->_downloadDeps as $dep) { - if (!PEAR_Downloader_Package::willDownload($dep, - array_merge($params, $newparams)) && !$param->isInstalled($dep)) { - $newdeps[] = $dep; - } else { - // detect versioning conflicts here - } - } - // convert the dependencies into PEAR_Downloader_Package objects for the next time - // around - $params[$i]->_downloadDeps = array(); - foreach ($newdeps as $dep) { - $obj = &new PEAR_Downloader_Package($params[$i]->getDownloader()); - if ($s = $params[$i]->explicitState()) { - $obj->setExplicitState($s); - } - PEAR::pushErrorHandling(PEAR_ERROR_RETURN); - $e = $obj->fromDepURL($dep); - PEAR::popErrorHandling(); - if (PEAR::isError($e)) { - if (!isset($options['soft'])) { - $obj->_downloader->log(0, $e->getMessage()); - } - continue; - } - $e = $obj->detectDependencies($params); - if (PEAR::isError($e)) { - if (!isset($options['soft'])) { - $obj->_downloader->log(0, $e->getMessage()); - } - } - $j = &$obj; - $newparams[] = &$j; - } - } - if (count($newparams)) { - foreach ($newparams as $i => $unused) { - $params[] = &$newparams[$i]; - } - return true; - } else { - return false; - } - } - - - /** - * @static - */ - function willDownload($param, $params) - { - if (!is_array($params)) { - return false; - } - foreach ($params as $obj) { - if ($obj->isEqual($param)) { - return true; - } - } - return false; - } - - /** - * For simpler unit-testing - * @param PEAR_Config - * @param int - * @param string - */ - function &getPackagefileObject(&$c, $d, $t = false) - { - $a = &new PEAR_PackageFile($c, $d, $t); - return $a; - } - - - /** - * This will retrieve from a local file if possible, and parse out - * a group name as well. The original parameter will be modified to reflect this. - * @param string|array can be a parsed package name as well - * @access private - */ - function _fromFile(&$param) - { - if (is_string($param)) { - if (!file_exists($param)) { - $test = explode('#', $param); - $group = array_pop($test); - if (file_exists(implode('#', $test))) { - $this->setGroup($group); - $param = implode('#', $test); - $this->_explicitGroup = true; - } - } - if (is_file($param)) { - $this->_type = 'local'; - $options = $this->_downloader->getOptions(); - if (isset($options['downloadonly'])) { - $pkg = &$this->getPackagefileObject($this->_config, - $this->_downloader->_debug); - } else { - $pkg = &$this->getPackagefileObject($this->_config, - $this->_downloader->_debug, $this->_downloader->getDownloadDir()); - } - PEAR::pushErrorHandling(PEAR_ERROR_RETURN); - $pf = &$pkg->fromAnyFile($param, PEAR_VALIDATE_INSTALLING); - PEAR::popErrorHandling(); - if (PEAR::isError($pf)) { - $this->_valid = false; - return $pf; - } - $this->_packagefile = &$pf; - if (!$this->getGroup()) { - $this->setGroup('default'); // install the default dependency group - } - return $this->_valid = true; - } - } - return $this->_valid = false; - } - - function _fromUrl($param, $saveparam = '') - { - if (!is_array($param) && - (preg_match('#^(http|ftp)://#', $param))) { - $options = $this->_downloader->getOptions(); - $this->_type = 'url'; - $callback = $this->_downloader->ui ? - array(&$this->_downloader, '_downloadCallback') : null; - $this->_downloader->pushErrorHandling(PEAR_ERROR_RETURN); - $file = $this->_downloader->downloadHttp($param, $this->_downloader->ui, - $this->_downloader->getDownloadDir(), $callback); - $this->_downloader->popErrorHandling(); - if (PEAR::isError($file)) { - if (!empty($saveparam)) { - $saveparam = ", cannot download \"$saveparam\""; - } - $err = PEAR::raiseError('Could not download from "' . $param . - '"' . $saveparam . ' (' . $file->getMessage() . ')'); - return $err; - } - if ($this->_rawpackagefile) { - require_once 'Archive/Tar.php'; - $tar = &new Archive_Tar($file); - $packagexml = $tar->extractInString('package2.xml'); - if (!$packagexml) { - $packagexml = $tar->extractInString('package.xml'); - } - if (str_replace(array("\n", "\r"), array('',''), $packagexml) != - str_replace(array("\n", "\r"), array('',''), $this->_rawpackagefile)) { - if ($this->getChannel() == 'pear.php.net') { - // be more lax for the existing PEAR packages that have not-ok - // characters in their package.xml - $this->_downloader->log(0, 'CRITICAL WARNING: The "' . - $this->getPackage() . '" package has invalid characters in its ' . - 'package.xml. The next version of PEAR may not be able to install ' . - 'this package for security reasons. Please open a bug report at ' . - 'http://pear.php.net/package/' . $this->getPackage() . '/bugs'); - } else { - return PEAR::raiseError('CRITICAL ERROR: package.xml downloaded does ' . - 'not match value returned from xml-rpc'); - } - } - } - // whew, download worked! - if (isset($options['downloadonly'])) { - $pkg = &$this->getPackagefileObject($this->_config, $this->_downloader->debug); - } else { - $pkg = &$this->getPackagefileObject($this->_config, $this->_downloader->debug, - $this->_downloader->getDownloadDir()); - } - PEAR::pushErrorHandling(PEAR_ERROR_RETURN); - $pf = &$pkg->fromAnyFile($file, PEAR_VALIDATE_INSTALLING); - PEAR::popErrorHandling(); - if (PEAR::isError($pf)) { - if (is_array($pf->getUserInfo())) { - foreach ($pf->getUserInfo() as $err) { - if (is_array($err)) { - $err = $err['message']; - } - if (!isset($options['soft'])) { - $this->_downloader->log(0, "Validation Error: $err"); - } - } - } - if (!isset($options['soft'])) { - $this->_downloader->log(0, $pf->getMessage()); - } - $err = PEAR::raiseError('Download of "' . ($saveparam ? $saveparam : - $param) . '" succeeded, but it is not a valid package archive'); - $this->_valid = false; - return $err; - } - $this->_packagefile = &$pf; - $this->setGroup('default'); // install the default dependency group - return $this->_valid = true; - } - return $this->_valid = false; - } - - /** - * - * @param string|array pass in an array of format - * array( - * 'package' => 'pname', - * ['channel' => 'channame',] - * ['version' => 'version',] - * ['state' => 'state',]) - * or a string of format [channame/]pname[-version|-state] - */ - function _fromString($param) - { - $options = $this->_downloader->getOptions(); - PEAR::pushErrorHandling(PEAR_ERROR_RETURN); - $pname = $this->_registry->parsePackageName($param, - $this->_config->get('default_channel')); - PEAR::popErrorHandling(); - if (PEAR::isError($pname)) { - if ($pname->getCode() == 'invalid') { - $this->_valid = false; - return false; - } - if ($pname->getCode() == 'channel') { - $parsed = $pname->getUserInfo(); - if ($this->_downloader->discover($parsed['channel'])) { - if ($this->_config->get('auto_discover')) { - PEAR::pushErrorHandling(PEAR_ERROR_RETURN); - $pname = $this->_registry->parsePackageName($param, - $this->_config->get('default_channel')); - PEAR::popErrorHandling(); - } else { - if (!isset($options['soft'])) { - $this->_downloader->log(0, 'Channel "' . $parsed['channel'] . - '" is not initialized, use ' . - '"pear channel-discover ' . $parsed['channel'] . '" to initialize' . - 'or pear config-set auto_discover 1'); - } - } - } - if (PEAR::isError($pname)) { - if (!isset($options['soft'])) { - $this->_downloader->log(0, $pname->getMessage()); - } - if (is_array($param)) { - $param = $this->_registry->parsedPackageNameToString($param); - } - $err = PEAR::raiseError('invalid package name/package file "' . - $param . '"'); - $this->_valid = false; - return $err; - } - } else { - if (!isset($options['soft'])) { - $this->_downloader->log(0, $pname->getMessage()); - } - $err = PEAR::raiseError('invalid package name/package file "' . - $param . '"'); - $this->_valid = false; - return $err; - } - } - if (!isset($this->_type)) { - $this->_type = 'xmlrpc'; - } - $this->_parsedname = $pname; - if (isset($pname['state'])) { - $this->_explicitState = $pname['state']; - } else { - $this->_explicitState = false; - } - if (isset($pname['group'])) { - $this->_explicitGroup = true; - } else { - $this->_explicitGroup = false; - } - $info = $this->_downloader->_getPackageDownloadUrl($pname); - if (PEAR::isError($info)) { - if ($pname['channel'] == 'pear.php.net') { - // try pecl - $pname['channel'] = 'pecl.php.net'; - if ($test = $this->_downloader->_getPackageDownloadUrl($pname)) { - if (!PEAR::isError($test)) { - $info = PEAR::raiseError($info->getMessage() . ' - package ' . - $this->_registry->parsedPackageNameToString($pname, true) . - ' can be installed with "pecl install ' . $pname['package'] . - '"'); - } else { - $pname['channel'] = 'pear.php.net'; - } - } else { - $pname['channel'] = 'pear.php.net'; - } - } - return $info; - } - $this->_rawpackagefile = $info['raw']; - $ret = $this->_analyzeDownloadURL($info, $param, $pname); - if (PEAR::isError($ret)) { - return $ret; - } - if ($ret) { - $this->_downloadURL = $ret; - return $this->_valid = (bool) $ret; - } - } - - /** - * @param array output of package.getDownloadURL - * @param string|array|object information for detecting packages to be downloaded, and - * for errors - * @param array name information of the package - * @param array|null packages to be downloaded - * @param bool is this an optional dependency? - * @param bool is this any kind of dependency? - * @access private - */ - function _analyzeDownloadURL($info, $param, $pname, $params = null, $optional = false, - $isdependency = false) - { - if (!is_string($param) && PEAR_Downloader_Package::willDownload($param, $params)) { - return false; - } - if (!$info) { - if (!is_string($param)) { - $saveparam = ", cannot download \"$param\""; - } else { - $saveparam = ''; - } - // no releases exist - return PEAR::raiseError('No releases for package "' . - $this->_registry->parsedPackageNameToString($pname, true) . '" exist' . $saveparam); - } - if (strtolower($info['info']->getChannel()) != strtolower($pname['channel'])) { - $err = false; - if ($pname['channel'] == 'pecl.php.net') { - if ($info['info']->getChannel() != 'pear.php.net') { - $err = true; - } - } elseif ($info['info']->getChannel() == 'pecl.php.net') { - if ($pname['channel'] != 'pear.php.net') { - $err = true; - } - } else { - $err = true; - } - if ($err) { - return PEAR::raiseError('SECURITY ERROR: package in channel "' . $pname['channel'] . - '" retrieved another channel\'s name for download! ("' . - $info['info']->getChannel() . '")'); - } - } - if (!isset($info['url'])) { - if ($this->isInstalled($info)) { - if ($isdependency && version_compare($info['version'], - $this->_registry->packageInfo($info['info']->getPackage(), - 'version', $info['info']->getChannel()), '<=')) { - // ignore bogus errors of "failed to download dependency" - // if it is already installed and the one that would be - // downloaded is older or the same version (Bug #7219) - return false; - } - } - $instead = ', will instead download version ' . $info['version'] . - ', stability "' . $info['info']->getState() . '"'; - // releases exist, but we failed to get any - if (isset($this->_downloader->_options['force'])) { - if (isset($pname['version'])) { - $vs = ', version "' . $pname['version'] . '"'; - } elseif (isset($pname['state'])) { - $vs = ', stability "' . $pname['state'] . '"'; - } elseif ($param == 'dependency') { - if (!class_exists('PEAR_Common')) { - require_once 'PEAR/Common.php'; - } - if (!in_array($info['info']->getState(), - PEAR_Common::betterStates($this->_config->get('preferred_state'), true))) { - if ($optional) { - // don't spit out confusing error message - return $this->_downloader->_getPackageDownloadUrl( - array('package' => $pname['package'], - 'channel' => $pname['channel'], - 'version' => $info['version'])); - } - $vs = ' within preferred state "' . $this->_config->get('preferred_state') . - '"'; - } else { - if (!class_exists('PEAR_Dependency2')) { - require_once 'PEAR/Dependency2.php'; - } - if ($optional) { - // don't spit out confusing error message - return $this->_downloader->_getPackageDownloadUrl( - array('package' => $pname['package'], - 'channel' => $pname['channel'], - 'version' => $info['version'])); - } - $vs = PEAR_Dependency2::_getExtraString($pname); - $instead = ''; - } - } else { - $vs = ' within preferred state "' . $this->_config->get( - 'preferred_state') . '"'; - } - if (!isset($options['soft'])) { - $this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] . - '/' . $pname['package'] . $vs . $instead); - } - // download the latest release - return $this->_downloader->_getPackageDownloadUrl( - array('package' => $pname['package'], - 'channel' => $pname['channel'], - 'version' => $info['version'])); - } else { - // construct helpful error message - if (isset($pname['version'])) { - $vs = ', version "' . $pname['version'] . '"'; - } elseif (isset($pname['state'])) { - $vs = ', stability "' . $pname['state'] . '"'; - } elseif ($param == 'dependency') { - if (!class_exists('PEAR_Common')) { - require_once 'PEAR/Common.php'; - } - if (!in_array($info['info']->getState(), - PEAR_Common::betterStates($this->_config->get('preferred_state'), true))) { - if ($optional) { - // don't spit out confusing error message, and don't die on - // optional dep failure! - return $this->_downloader->_getPackageDownloadUrl( - array('package' => $pname['package'], - 'channel' => $pname['channel'], - 'version' => $info['version'])); - } - $vs = ' within preferred state "' . $this->_config->get('preferred_state') . - '"'; - } else { - if (!class_exists('PEAR_Dependency2')) { - require_once 'PEAR/Dependency2.php'; - } - if ($optional) { - // don't spit out confusing error message, and don't die on - // optional dep failure! - return $this->_downloader->_getPackageDownloadUrl( - array('package' => $pname['package'], - 'channel' => $pname['channel'], - 'version' => $info['version'])); - } - $vs = PEAR_Dependency2::_getExtraString($pname); - } - } else { - $vs = ' within preferred state "' . $this->_downloader->config->get( - 'preferred_state') . '"'; - } - $options = $this->_downloader->getOptions(); - // this is only set by the "download-all" command - if (isset($options['ignorepreferred_state'])) { - $err = PEAR::raiseError( - 'Failed to download ' . $this->_registry->parsedPackageNameToString( - array('channel' => $pname['channel'], 'package' => $pname['package']), - true) - . $vs . - ', latest release is version ' . $info['version'] . - ', stability "' . $info['info']->getState() . '", use "' . - $this->_registry->parsedPackageNameToString( - array('channel' => $pname['channel'], 'package' => $pname['package'], - 'version' => $info['version'])) . '" to install', - PEAR_DOWNLOADER_PACKAGE_STATE); - return $err; - } - $err = PEAR::raiseError( - 'Failed to download ' . $this->_registry->parsedPackageNameToString( - array('channel' => $pname['channel'], 'package' => $pname['package']), - true) - . $vs . - ', latest release is version ' . $info['version'] . - ', stability "' . $info['info']->getState() . '", use "' . - $this->_registry->parsedPackageNameToString( - array('channel' => $pname['channel'], 'package' => $pname['package'], - 'version' => $info['version'])) . '" to install'); - return $err; - } - } - return $info; - } -} -?> +<?php +/** + * PEAR_Downloader_Package + * + * PHP versions 4 and 5 + * + * LICENSE: This source file is subject to version 3.0 of the PHP license + * that is available through the world-wide-web at the following URI: + * http://www.php.net/license/3_0.txt. If you did not receive a copy of + * the PHP License and are unable to obtain it through the web, please + * send a note to license@php.net so we can mail you a copy immediately. + * + * @category pear + * @package PEAR + * @author Greg Beaver <cellog@php.net> + * @copyright 1997-2006 The PHP Group + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version CVS: $Id: Package.php,v 1.95 2006/03/28 03:51:40 cellog Exp $ + * @link http://pear.php.net/package/PEAR + * @since File available since Release 1.4.0a1 + */ +/** + * Error code when parameter initialization fails because no releases + * exist within preferred_state, but releases do exist + */ +define('PEAR_DOWNLOADER_PACKAGE_STATE', -1003); +/** + * Coordinates download parameters and manages their dependencies + * prior to downloading them. + * + * Input can come from three sources: + * + * - local files (archives or package.xml) + * - remote files (downloadable urls) + * - abstract package names + * + * The first two elements are handled cleanly by PEAR_PackageFile, but the third requires + * accessing pearweb's xml-rpc interface to determine necessary dependencies, and the + * format returned of dependencies is slightly different from that used in package.xml. + * + * This class hides the differences between these elements, and makes automatic + * dependency resolution a piece of cake. It also manages conflicts when + * two classes depend on incompatible dependencies, or differing versions of the same + * package dependency. In addition, download will not be attempted if the php version is + * not supported, PEAR installer version is not supported, or non-PECL extensions are not + * installed. + * @category pear + * @package PEAR + * @author Greg Beaver <cellog@php.net> + * @copyright 1997-2006 The PHP Group + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version Release: @PEAR-VER@ + * @link http://pear.php.net/package/PEAR + * @since Class available since Release 1.4.0a1 + */ +class PEAR_Downloader_Package +{ + /** + * @var PEAR_Downloader + */ + var $_downloader; + /** + * @var PEAR_Config + */ + var $_config; + /** + * @var PEAR_Registry + */ + var $_registry; + /** + * Used to implement packagingroot properly + * @var PEAR_Registry + */ + var $_installRegistry; + /** + * @var PEAR_PackageFile_v1|PEAR_PackageFile|v2 + */ + var $_packagefile; + /** + * @var array + */ + var $_parsedname; + /** + * @var array + */ + var $_downloadURL; + /** + * @var array + */ + var $_downloadDeps = array(); + /** + * @var boolean + */ + var $_valid = false; + /** + * @var boolean + */ + var $_analyzed = false; + /** + * if this or a parent package was invoked with Package-state, this is set to the + * state variable. + * + * This allows temporary reassignment of preferred_state for a parent package and all of + * its dependencies. + * @var string|false + */ + var $_explicitState = false; + /** + * If this package is invoked with Package#group, this variable will be true + */ + var $_explicitGroup = false; + /** + * Package type local|url|xmlrpc + * @var string + */ + var $_type; + /** + * Contents of package.xml, if downloaded from a remote channel + * @var string|false + * @access private + */ + var $_rawpackagefile; + /** + * @var boolean + * @access private + */ + var $_validated = false; + + /** + * @param PEAR_Downloader + */ + function PEAR_Downloader_Package(&$downloader) + { + $this->_downloader = &$downloader; + $this->_config = &$this->_downloader->config; + $this->_registry = &$this->_config->getRegistry(); + $options = $downloader->getOptions(); + if (isset($options['packagingroot'])) { + $this->_config->setInstallRoot($options['packagingroot']); + $this->_installRegistry = &$this->_config->getRegistry(); + $this->_config->setInstallRoot(false); + } else { + $this->_installRegistry = &$this->_registry; + } + $this->_valid = $this->_analyzed = false; + } + + /** + * Parse the input and determine whether this is a local file, a remote uri, or an + * abstract package name. + * + * This is the heart of the PEAR_Downloader_Package(), and is used in + * {@link PEAR_Downloader::download()} + * @param string + * @return bool|PEAR_Error + */ + function initialize($param) + { + $origErr = $this->_fromFile($param); + if (!$this->_valid) { + $options = $this->_downloader->getOptions(); + if (isset($options['offline'])) { + if (PEAR::isError($origErr)) { + if (!isset($options['soft'])) { + $this->_downloader->log(0, $origErr->getMessage()); + } + } + return PEAR::raiseError('Cannot download non-local package "' . $param . '"'); + } + $err = $this->_fromUrl($param); + if (PEAR::isError($err) || !$this->_valid) { + if ($this->_type == 'url') { + if (PEAR::isError($err)) { + if (!isset($options['soft'])) { + $this->_downloader->log(0, $err->getMessage()); + } + } + return PEAR::raiseError("Invalid or missing remote package file"); + } + $err = $this->_fromString($param); + if (PEAR::isError($err) || !$this->_valid) { + if (PEAR::isError($err) && + $err->getCode() == PEAR_DOWNLOADER_PACKAGE_STATE) { + return false; // instruct the downloader to silently skip + } + if (isset($this->_type) && $this->_type == 'local' && + PEAR::isError($origErr)) { + if (is_array($origErr->getUserInfo())) { + foreach ($origErr->getUserInfo() as $err) { + if (is_array($err)) { + $err = $err['message']; + } + if (!isset($options['soft'])) { + $this->_downloader->log(0, $err); + } + } + } + if (!isset($options['soft'])) { + $this->_downloader->log(0, $origErr->getMessage()); + } + if (is_array($param)) { + $param = $this->_registry->parsedPackageNameToString($param, + true); + } + return PEAR::raiseError( + "Cannot initialize '$param', invalid or missing package file"); + } + if (PEAR::isError($err)) { + if (!isset($options['soft'])) { + $this->_downloader->log(0, $err->getMessage()); + } + } + if (is_array($param)) { + $param = $this->_registry->parsedPackageNameToString($param, true); + } + return PEAR::raiseError( + "Cannot initialize '$param', invalid or missing package file"); + } + } + } + return true; + } + + /** + * Retrieve any non-local packages + * @return PEAR_PackageFile_v1|PEAR_PackageFile_v2|PEAR_Error + */ + function &download() + { + if (isset($this->_packagefile)) { + return $this->_packagefile; + } + if (isset($this->_downloadURL['url'])) { + $this->_isvalid = false; + $info = $this->getParsedPackage(); + foreach ($info as $i => $p) { + $info[$i] = strtolower($p); + } + $err = $this->_fromUrl($this->_downloadURL['url'], + $this->_registry->parsedPackageNameToString($this->_parsedname, true)); + $newinfo = $this->getParsedPackage(); + foreach ($newinfo as $i => $p) { + $newinfo[$i] = strtolower($p); + } + if ($info != $newinfo) { + do { + if ($info['package'] == 'pecl.php.net' && $newinfo['package'] == 'pear.php.net') { + $info['package'] = 'pear.php.net'; + if ($info == $newinfo) { + // skip the channel check if a pecl package says it's a PEAR package + break; + } + } + return PEAR::raiseError('CRITICAL ERROR: We are ' . + $this->_registry->parsedPackageNameToString($info) . ', but the file ' . + 'downloaded claims to be ' . + $this->_registry->parsedPackageNameToString($this->getParsedPackage())); + } while (false); + } + if (PEAR::isError($err) || !$this->_valid) { + return $err; + } + } + $this->_type = 'local'; + return $this->_packagefile; + } + + function &getPackageFile() + { + return $this->_packagefile; + } + + function &getDownloader() + { + return $this->_downloader; + } + + function getType() + { + return $this->_type; + } + + /** + * Like {@link initialize()}, but operates on a dependency + */ + function fromDepURL($dep) + { + $this->_downloadURL = $dep; + if (isset($dep['uri'])) { + $options = $this->_downloader->getOptions(); + if (!extension_loaded("zlib") || isset($options['nocompress'])) { + $ext = '.tar'; + } else { + $ext = '.tgz'; + } + PEAR::pushErrorHandling(PEAR_ERROR_RETURN); + $err = $this->_fromUrl($dep['uri'] . $ext); + PEAR::popErrorHandling(); + if (PEAR::isError($err)) { + if (!isset($options['soft'])) { + $this->_downloader->log(0, $err->getMessage()); + } + return PEAR::raiseError('Invalid uri dependency "' . $dep['uri'] . $ext . '", ' . + 'cannot download'); + } + } else { + $this->_parsedname = + array( + 'package' => $dep['info']->getPackage(), + 'channel' => $dep['info']->getChannel(), + 'version' => $dep['version'] + ); + if (!isset($dep['nodefault'])) { + $this->_parsedname['group'] = 'default'; // download the default dependency group + $this->_explicitGroup = false; + } + $this->_rawpackagefile = $dep['raw']; + } + } + + function detectDependencies($params) + { + $options = $this->_downloader->getOptions(); + if (isset($options['downloadonly'])) { + return; + } + if (isset($options['offline'])) { + $this->_downloader->log(3, 'Skipping dependency download check, --offline specified'); + return; + } + $pname = $this->getParsedPackage(); + if (!$pname) { + return; + } + $deps = $this->getDeps(); + if (!$deps) { + return; + } + if (isset($deps['required'])) { // package.xml 2.0 + return $this->_detect2($deps, $pname, $options, $params); + } else { + return $this->_detect1($deps, $pname, $options, $params); + } + } + + function setValidated() + { + $this->_validated = true; + } + + function alreadyValidated() + { + return $this->_validated; + } + + /** + * Remove packages to be downloaded that are already installed + * @param array of PEAR_Downloader_Package objects + * @static + */ + function removeInstalled(&$params) + { + if (!isset($params[0])) { + return; + } + $options = $params[0]->_downloader->getOptions(); + if (!isset($options['downloadonly'])) { + foreach ($params as $i => $param) { + // remove self if already installed with this version + // this does not need any pecl magic - we only remove exact matches + if ($param->_installRegistry->packageExists($param->getPackage(), $param->getChannel())) { + if (version_compare($param->_installRegistry->packageInfo($param->getPackage(), 'version', + $param->getChannel()), $param->getVersion(), '==')) { + if (!isset($options['force'])) { + $info = $param->getParsedPackage(); + unset($info['version']); + unset($info['state']); + if (!isset($options['soft'])) { + $param->_downloader->log(1, 'Skipping package "' . + $param->getShortName() . + '", already installed as version ' . + $param->_installRegistry->packageInfo($param->getPackage(), + 'version', $param->getChannel())); + } + $params[$i] = false; + } + } elseif (!isset($options['force']) && !isset($options['upgrade']) && + !isset($options['soft'])) { + $info = $param->getParsedPackage(); + $param->_downloader->log(1, 'Skipping package "' . + $param->getShortName() . + '", already installed as version ' . + $param->_installRegistry->packageInfo($param->getPackage(), 'version', + $param->getChannel())); + $params[$i] = false; + } + } + } + } + PEAR_Downloader_Package::removeDuplicates($params); + } + + function _detect2($deps, $pname, $options, $params) + { + $this->_downloadDeps = array(); + $groupnotfound = false; + foreach (array('package', 'subpackage') as $packagetype) { + // get required dependency group + if (isset($deps['required'][$packagetype])) { + if (isset($deps['required'][$packagetype][0])) { + foreach ($deps['required'][$packagetype] as $dep) { + if (isset($dep['conflicts'])) { + // skip any package that this package conflicts with + continue; + } + $ret = $this->_detect2Dep($dep, $pname, 'required', $params); + if (is_array($ret)) { + $this->_downloadDeps[] = $ret; + } + } + } else { + $dep = $deps['required'][$packagetype]; + if (!isset($dep['conflicts'])) { + // skip any package that this package conflicts with + $ret = $this->_detect2Dep($dep, $pname, 'required', $params); + if (is_array($ret)) { + $this->_downloadDeps[] = $ret; + } + } + } + } + // get optional dependency group, if any + if (isset($deps['optional'][$packagetype])) { + $skipnames = array(); + if (!isset($deps['optional'][$packagetype][0])) { + $deps['optional'][$packagetype] = array($deps['optional'][$packagetype]); + } + foreach ($deps['optional'][$packagetype] as $dep) { + $skip = false; + if (!isset($options['alldeps'])) { + $dep['package'] = $dep['name']; + if (!isset($options['soft'])) { + $this->_downloader->log(3, 'Notice: package "' . + $this->_registry->parsedPackageNameToString($this->getParsedPackage(), + true) . '" optional dependency "' . + $this->_registry->parsedPackageNameToString(array('package' => + $dep['name'], 'channel' => 'pear.php.net'), true) . + '" will not be automatically downloaded'); + } + $skipnames[] = $this->_registry->parsedPackageNameToString($dep, true); + $skip = true; + unset($dep['package']); + } + if (!($ret = $this->_detect2Dep($dep, $pname, 'optional', $params))) { + $dep['package'] = $dep['name']; + $skip = count($skipnames) ? + $skipnames[count($skipnames) - 1] : ''; + if ($skip == + $this->_registry->parsedPackageNameToString($dep, true)) { + array_pop($skipnames); + } + } + if (!$skip && is_array($ret)) { + $this->_downloadDeps[] = $ret; + } + } + if (count($skipnames)) { + if (!isset($options['soft'])) { + $this->_downloader->log(1, 'Did not download optional dependencies: ' . + implode(', ', $skipnames) . + ', use --alldeps to download automatically'); + } + } + } + // get requested dependency group, if any + $groupname = $this->getGroup(); + $explicit = $this->_explicitGroup; + if (!$groupname) { + if ($this->canDefault()) { + $groupname = 'default'; // try the default dependency group + } else { + continue; + } + } + if ($groupnotfound) { + continue; + } + if (isset($deps['group'])) { + if (isset($deps['group']['attribs'])) { + if (strtolower($deps['group']['attribs']['name']) == strtolower($groupname)) { + $group = $deps['group']; + } elseif ($explicit) { + if (!isset($options['soft'])) { + $this->_downloader->log(0, 'Warning: package "' . + $this->_registry->parsedPackageNameToString($pname, true) . + '" has no dependency ' . 'group named "' . $groupname . '"'); + } + $groupnotfound = true; + continue; + } + } else { + $found = false; + foreach ($deps['group'] as $group) { + if (strtolower($group['attribs']['name']) == strtolower($groupname)) { + $found = true; + break; + } + } + if (!$found) { + if ($explicit) { + if (!isset($options['soft'])) { + $this->_downloader->log(0, 'Warning: package "' . + $this->_registry->parsedPackageNameToString($pname, true) . + '" has no dependency ' . 'group named "' . $groupname . '"'); + } + } + $groupnotfound = true; + continue; + } + } + } + if (isset($group)) { + if (isset($group[$packagetype])) { + if (isset($group[$packagetype][0])) { + foreach ($group[$packagetype] as $dep) { + $ret = $this->_detect2Dep($dep, $pname, 'dependency group "' . + $group['attribs']['name'] . '"', $params); + if (is_array($ret)) { + $this->_downloadDeps[] = $ret; + } + } + } else { + $ret = $this->_detect2Dep($group[$packagetype], $pname, + 'dependency group "' . + $group['attribs']['name'] . '"', $params); + if (is_array($ret)) { + $this->_downloadDeps[] = $ret; + } + } + } + } + } + } + + function _detect2Dep($dep, $pname, $group, $params) + { + if (isset($dep['conflicts'])) { + return true; + } + $options = $this->_downloader->getOptions(); + if (isset($dep['uri'])) { + return array('uri' => $dep['uri'], 'dep' => $dep);; + } + $testdep = $dep; + $testdep['package'] = $dep['name']; + if (PEAR_Downloader_Package::willDownload($testdep, $params)) { + $dep['package'] = $dep['name']; + if (!isset($options['soft'])) { + $this->_downloader->log(2, $this->getShortName() . ': Skipping ' . $group . + ' dependency "' . + $this->_registry->parsedPackageNameToString($dep, true) . + '", will be installed'); + } + return false; + } + $options = $this->_downloader->getOptions(); + PEAR::pushErrorHandling(PEAR_ERROR_RETURN); + if ($this->_explicitState) { + $pname['state'] = $this->_explicitState; + } + $url = + $this->_downloader->_getDepPackageDownloadUrl($dep, $pname); + if (PEAR::isError($url)) { + PEAR::popErrorHandling(); + return $url; + } + $dep['package'] = $dep['name']; + $ret = $this->_analyzeDownloadURL($url, 'dependency', $dep, $params, $group == 'optional' && + !isset($options['alldeps']), true); + PEAR::popErrorHandling(); + if (PEAR::isError($ret)) { + if (!isset($options['soft'])) { + $this->_downloader->log(0, $ret->getMessage()); + } + return false; + } else { + // check to see if a dep is already installed and is the same or newer + if (!isset($dep['min']) && !isset($dep['max']) && !isset($dep['recommended'])) { + $oper = 'has'; + } else { + $oper = 'gt'; + } + // do not try to move this before getDepPackageDownloadURL + // we can't determine whether upgrade is necessary until we know what + // version would be downloaded + if (!isset($options['force']) && $this->isInstalled($ret, $oper)) { + $version = $this->_installRegistry->packageInfo($dep['name'], 'version', + $dep['channel']); + $dep['package'] = $dep['name']; + if (!isset($options['soft'])) { + $this->_downloader->log(3, $this->getShortName() . ': Skipping ' . $group . + ' dependency "' . + $this->_registry->parsedPackageNameToString($dep, true) . + '" version ' . $url['version'] . ', already installed as version ' . + $version); + } + return false; + } + } + if (isset($dep['nodefault'])) { + $ret['nodefault'] = true; + } + return $ret; + } + + function _detect1($deps, $pname, $options, $params) + { + $this->_downloadDeps = array(); + $skipnames = array(); + foreach ($deps as $dep) { + $nodownload = false; + if ($dep['type'] == 'pkg') { + $dep['channel'] = 'pear.php.net'; + $dep['package'] = $dep['name']; + switch ($dep['rel']) { + case 'not' : + continue 2; + case 'ge' : + case 'eq' : + case 'gt' : + case 'has' : + $group = (!isset($dep['optional']) || $dep['optional'] == 'no') ? + 'required' : + 'optional'; + if (PEAR_Downloader_Package::willDownload($dep, $params)) { + $this->_downloader->log(2, $this->getShortName() . ': Skipping ' . $group + . ' dependency "' . + $this->_registry->parsedPackageNameToString($dep, true) . + '", will be installed'); + continue 2; + } + $fakedp = new PEAR_PackageFile_v1; + $fakedp->setPackage($dep['name']); + // skip internet check if we are not upgrading (bug #5810) + if (!isset($options['upgrade']) && $this->isInstalled( + $fakedp, $dep['rel'])) { + $this->_downloader->log(2, $this->getShortName() . ': Skipping ' . $group + . ' dependency "' . + $this->_registry->parsedPackageNameToString($dep, true) . + '", is already installed'); + continue 2; + } + } + PEAR::pushErrorHandling(PEAR_ERROR_RETURN); + if ($this->_explicitState) { + $pname['state'] = $this->_explicitState; + } + $url = + $this->_downloader->_getDepPackageDownloadUrl($dep, $pname); + $chan = 'pear.php.net'; + if (PEAR::isError($url)) { + // check to see if this is a pecl package that has jumped + // from pear.php.net to pecl.php.net channel + if (!class_exists('PEAR_Dependency2')) { + require_once 'PEAR/Dependency2.php'; + } + $newdep = PEAR_Dependency2::normalizeDep($dep); + $newdep = $newdep[0]; + $newdep['channel'] = 'pecl.php.net'; + $chan = 'pecl.php.net'; + $url = + $this->_downloader->_getDepPackageDownloadUrl($newdep, $pname); + $obj = &$this->_installRegistry->getPackage($dep['name']); + if (PEAR::isError($url)) { + PEAR::popErrorHandling(); + if ($obj !== null && $this->isInstalled($obj, $dep['rel'])) { + $group = (!isset($dep['optional']) || $dep['optional'] == 'no') ? + 'required' : + 'optional'; + $dep['package'] = $dep['name']; + if (!isset($options['soft'])) { + $this->_downloader->log(3, $this->getShortName() . + ': Skipping ' . $group . ' dependency "' . + $this->_registry->parsedPackageNameToString($dep, true) . + '", already installed as version ' . $obj->getVersion()); + } + $skip = count($skipnames) ? + $skipnames[count($skipnames) - 1] : ''; + if ($skip == + $this->_registry->parsedPackageNameToString($dep, true)) { + array_pop($skipnames); + } + continue; + } else { + if (isset($dep['optional']) && $dep['optional'] == 'yes') { + $this->_downloader->log(2, $this->getShortName() . + ': Skipping ' . $group + . ' dependency "' . + $this->_registry->parsedPackageNameToString($dep, true) . + '", no releases exist'); + continue; + } else { + return $url; + } + } + } + } + PEAR::popErrorHandling(); + if (!isset($options['alldeps'])) { + if (isset($dep['optional']) && $dep['optional'] == 'yes') { + if (!isset($options['soft'])) { + $this->_downloader->log(3, 'Notice: package "' . + $this->getShortName() . + '" optional dependency "' . + $this->_registry->parsedPackageNameToString( + array('channel' => $chan, 'package' => + $dep['name']), true) . + '" will not be automatically downloaded'); + } + $skipnames[] = $this->_registry->parsedPackageNameToString( + array('channel' => $chan, 'package' => + $dep['name']), true); + $nodownload = true; + } + } + if (!isset($options['alldeps']) && !isset($options['onlyreqdeps'])) { + if (!isset($dep['optional']) || $dep['optional'] == 'no') { + if (!isset($options['soft'])) { + $this->_downloader->log(3, 'Notice: package "' . + $this->getShortName() . + '" required dependency "' . + $this->_registry->parsedPackageNameToString( + array('channel' => $chan, 'package' => + $dep['name']), true) . + '" will not be automatically downloaded'); + } + $skipnames[] = $this->_registry->parsedPackageNameToString( + array('channel' => $chan, 'package' => + $dep['name']), true); + $nodownload = true; + } + } + // check to see if a dep is already installed + // do not try to move this before getDepPackageDownloadURL + // we can't determine whether upgrade is necessary until we know what + // version would be downloaded + if (!isset($options['force']) && $this->isInstalled( + $url, $dep['rel'])) { + $group = (!isset($dep['optional']) || $dep['optional'] == 'no') ? + 'required' : + 'optional'; + $dep['package'] = $dep['name']; + if (isset($newdep)) { + $version = $this->_installRegistry->packageInfo($newdep['name'], 'version', + $newdep['channel']); + } else { + $version = $this->_installRegistry->packageInfo($dep['name'], 'version'); + } + $dep['version'] = $url['version']; + if (!isset($options['soft'])) { + $this->_downloader->log(3, $this->getShortName() . ': Skipping ' . $group . + ' dependency "' . + $this->_registry->parsedPackageNameToString($dep, true) . + '", already installed as version ' . $version); + } + $skip = count($skipnames) ? + $skipnames[count($skipnames) - 1] : ''; + if ($skip == + $this->_registry->parsedPackageNameToString($dep, true)) { + array_pop($skipnames); + } + continue; + } + if ($nodownload) { + continue; + } + PEAR::pushErrorHandling(PEAR_ERROR_RETURN); + if (isset($newdep)) { + $dep = $newdep; + } + $dep['package'] = $dep['name']; + $ret = $this->_analyzeDownloadURL($url, 'dependency', $dep, $params, + isset($dep['optional']) && $dep['optional'] == 'yes' && + !isset($options['alldeps']), true); + PEAR::popErrorHandling(); + if (PEAR::isError($ret)) { + if (!isset($options['soft'])) { + $this->_downloader->log(0, $ret->getMessage()); + } + continue; + } + $this->_downloadDeps[] = $ret; + } + } + if (count($skipnames)) { + if (!isset($options['soft'])) { + $this->_downloader->log(1, 'Did not download dependencies: ' . + implode(', ', $skipnames) . + ', use --alldeps or --onlyreqdeps to download automatically'); + } + } + } + + function setDownloadURL($pkg) + { + $this->_downloadURL = $pkg; + } + + /** + * Set the package.xml object for this downloaded package + * + * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2 $pkg + */ + function setPackageFile(&$pkg) + { + $this->_packagefile = &$pkg; + } + + function getShortName() + { + return $this->_registry->parsedPackageNameToString(array('channel' => $this->getChannel(), + 'package' => $this->getPackage()), true); + } + + function getParsedPackage() + { + if (isset($this->_packagefile) || isset($this->_parsedname)) { + return array('channel' => $this->getChannel(), + 'package' => $this->getPackage(), + 'version' => $this->getVersion()); + } + return false; + } + + function getDownloadURL() + { + return $this->_downloadURL; + } + + function canDefault() + { + if (isset($this->_downloadURL)) { + if (isset($this->_downloadURL['nodefault'])) { + return false; + } + } + return true; + } + + function getPackage() + { + if (isset($this->_packagefile)) { + return $this->_packagefile->getPackage(); + } elseif (isset($this->_downloadURL['info'])) { + return $this->_downloadURL['info']->getPackage(); + } else { + return false; + } + } + + /** + * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2 + */ + function isSubpackage(&$pf) + { + if (isset($this->_packagefile)) { + return $this->_packagefile->isSubpackage($pf); + } elseif (isset($this->_downloadURL['info'])) { + return $this->_downloadURL['info']->isSubpackage($pf); + } else { + return false; + } + } + + function getPackageType() + { + if (isset($this->_packagefile)) { + return $this->_packagefile->getPackageType(); + } elseif (isset($this->_downloadURL['info'])) { + return $this->_downloadURL['info']->getPackageType(); + } else { + return false; + } + } + + function isBundle() + { + if (isset($this->_packagefile)) { + return $this->_packagefile->getPackageType() == 'bundle'; + } else { + return false; + } + } + + function getPackageXmlVersion() + { + if (isset($this->_packagefile)) { + return $this->_packagefile->getPackagexmlVersion(); + } elseif (isset($this->_downloadURL['info'])) { + return $this->_downloadURL['info']->getPackagexmlVersion(); + } else { + return '1.0'; + } + } + + function getChannel() + { + if (isset($this->_packagefile)) { + return $this->_packagefile->getChannel(); + } elseif (isset($this->_downloadURL['info'])) { + return $this->_downloadURL['info']->getChannel(); + } else { + return false; + } + } + + function getURI() + { + if (isset($this->_packagefile)) { + return $this->_packagefile->getURI(); + } elseif (isset($this->_downloadURL['info'])) { + return $this->_downloadURL['info']->getURI(); + } else { + return false; + } + } + + function getVersion() + { + if (isset($this->_packagefile)) { + return $this->_packagefile->getVersion(); + } elseif (isset($this->_downloadURL['version'])) { + return $this->_downloadURL['version']; + } else { + return false; + } + } + + function isCompatible($pf) + { + if (isset($this->_packagefile)) { + return $this->_packagefile->isCompatible($pf); + } elseif (isset($this->_downloadURL['info'])) { + return $this->_downloadURL['info']->isCompatible($pf); + } else { + return true; + } + } + + function setGroup($group) + { + $this->_parsedname['group'] = $group; + } + + function getGroup() + { + if (isset($this->_parsedname['group'])) { + return $this->_parsedname['group']; + } else { + return ''; + } + } + + function isExtension($name) + { + if (isset($this->_packagefile)) { + return $this->_packagefile->isExtension($name); + } elseif (isset($this->_downloadURL['info'])) { + return $this->_downloadURL['info']->getProvidesExtension() == $name; + } else { + return false; + } + } + + function getDeps() + { + if (isset($this->_packagefile)) { + if ($this->_packagefile->getPackagexmlVersion() == '2.0') { + return $this->_packagefile->getDeps(true); + } else { + return $this->_packagefile->getDeps(); + } + } elseif (isset($this->_downloadURL['info'])) { + if ($this->_downloadURL['info']->getPackagexmlVersion() == '2.0') { + return $this->_downloadURL['info']->getDeps(true); + } else { + return $this->_downloadURL['info']->getDeps(); + } + } else { + return array(); + } + } + + /** + * @param array Parsed array from {@link PEAR_Registry::parsePackageName()} or a dependency + * returned from getDepDownloadURL() + */ + function isEqual($param) + { + if (is_object($param)) { + $channel = $param->getChannel(); + $package = $param->getPackage(); + if ($param->getURI()) { + $param = array( + 'channel' => $param->getChannel(), + 'package' => $param->getPackage(), + 'version' => $param->getVersion(), + 'uri' => $param->getURI(), + ); + } else { + $param = array( + 'channel' => $param->getChannel(), + 'package' => $param->getPackage(), + 'version' => $param->getVersion(), + ); + } + } else { + if (isset($param['uri'])) { + $param['channel'] = '__uri'; + $param['package'] = $param['dep']['name']; + } + $package = isset($param['package']) ? $param['package'] : + $param['info']->getPackage(); + $channel = isset($param['channel']) ? $param['channel'] : + $param['info']->getChannel(); + if (isset($param['rel'])) { + if (!class_exists('PEAR_Dependency2')) { + require_once 'PEAR/Dependency2.php'; + } + $newdep = PEAR_Dependency2::normalizeDep($param); + $newdep = $newdep[0]; + } elseif (isset($param['min'])) { + $newdep = $param; + } + } + if (isset($newdep)) { + if (!isset($newdep['min'])) { + $newdep['min'] = '0'; + } + if (!isset($newdep['max'])) { + $newdep['max'] = '100000000000000000000'; + } + // use magic to support pecl packages suddenly jumping to the pecl channel + // we need to support both dependency possibilities + if ($channel == 'pear.php.net' && $this->getChannel() == 'pecl.php.net') { + if ($package == $this->getPackage()) { + $channel = 'pecl.php.net'; + } + } + if ($channel == 'pecl.php.net' && $this->getChannel() == 'pear.php.net') { + if ($package == $this->getPackage()) { + $channel = 'pear.php.net'; + } + } + return (strtolower($package) == strtolower($this->getPackage()) && + $channel == $this->getChannel() && + version_compare($newdep['min'], $this->getVersion(), '<=') && + version_compare($newdep['max'], $this->getVersion(), '>=')); + } + // use magic to support pecl packages suddenly jumping to the pecl channel + if ($channel == 'pecl.php.net' && $this->getChannel() == 'pear.php.net') { + if (strtolower($package) == strtolower($this->getPackage())) { + $channel = 'pear.php.net'; + } + } + if (isset($param['version'])) { + return (strtolower($package) == strtolower($this->getPackage()) && + $channel == $this->getChannel() && + $param['version'] == $this->getVersion()); + } else { + return strtolower($package) == strtolower($this->getPackage()) && + $channel == $this->getChannel(); + } + } + + function isInstalled($dep, $oper = '==') + { + if (!$dep) { + return false; + } + if ($oper != 'ge' && $oper != 'gt' && $oper != 'has' && $oper != '==') { + return false; + } + if (is_object($dep)) { + $package = $dep->getPackage(); + $channel = $dep->getChannel(); + if ($dep->getURI()) { + $dep = array( + 'uri' => $dep->getURI(), + 'version' => $dep->getVersion(), + ); + } else { + $dep = array( + 'version' => $dep->getVersion(), + ); + } + } else { + if (isset($dep['uri'])) { + $channel = '__uri'; + $package = $dep['dep']['name']; + } else { + $channel = $dep['info']->getChannel(); + $package = $dep['info']->getPackage(); + } + } + $options = $this->_downloader->getOptions(); + $test = $this->_installRegistry->packageExists($package, $channel); + if (!$test && $channel == 'pecl.php.net') { + // do magic to allow upgrading from old pecl packages to new ones + $test = $this->_installRegistry->packageExists($package, 'pear.php.net'); + $channel = 'pear.php.net'; + } + if ($test) { + if (isset($dep['uri'])) { + if ($this->_installRegistry->packageInfo($package, 'uri', '__uri') == $dep['uri']) { + return true; + } + } + if (isset($options['upgrade'])) { + if ($oper == 'has') { + if (version_compare($this->_installRegistry->packageInfo( + $package, 'version', $channel), + $dep['version'], '>=')) { + return true; + } else { + return false; + } + } else { + if (version_compare($this->_installRegistry->packageInfo( + $package, 'version', $channel), + $dep['version'], '>=')) { + return true; + } + return false; + } + } + return true; + } + return false; + } + + /** + * @param array + * @static + */ + function removeDuplicates(&$params) + { + $pnames = array(); + foreach ($params as $i => $param) { + if (!$param) { + continue; + } + if ($param->getPackage()) { + $pnames[$i] = $param->getChannel() . '/' . + $param->getPackage() . '-' . $param->getVersion() . '#' . $param->getGroup(); + } + } + $pnames = array_unique($pnames); + $unset = array_diff(array_keys($params), array_keys($pnames)); + $testp = array_flip($pnames); + foreach ($params as $i => $param) { + if (!$param) { + $unset[] = $i; + continue; + } + if (!is_a($param, 'PEAR_Downloader_Package')) { + $unset[] = $i; + continue; + } + if (!isset($testp[$param->getChannel() . '/' . $param->getPackage() . '-' . + $param->getVersion() . '#' . $param->getGroup()])) { + $unset[] = $i; + } + } + foreach ($unset as $i) { + unset($params[$i]); + } + $ret = array(); + foreach ($params as $i => $param) { + $ret[] = &$params[$i]; + } + $params = array(); + foreach ($ret as $i => $param) { + $params[] = &$ret[$i]; + } + } + + function explicitState() + { + return $this->_explicitState; + } + + function setExplicitState($s) + { + $this->_explicitState = $s; + } + + /** + * @static + */ + function mergeDependencies(&$params) + { + $newparams = array(); + $bundles = array(); + foreach ($params as $i => $param) { + if (!$param->isBundle()) { + continue; + } + $bundles[] = $i; + $pf = &$param->getPackageFile(); + $newdeps = array(); + $contents = $pf->getBundledPackages(); + if (!is_array($contents)) { + $contents = array($contents); + } + foreach ($contents as $file) { + $filecontents = $pf->getFileContents($file); + $dl = &$param->getDownloader(); + $options = $dl->getOptions(); + $fp = @fopen($dl->getDownloadDir() . DIRECTORY_SEPARATOR . $file, 'wb'); + if (!$fp) { + continue; + } + fwrite($fp, $filecontents, strlen($filecontents)); + fclose($fp); + if ($s = $params[$i]->explicitState()) { + $obj->setExplicitState($s); + } + $obj = &new PEAR_Downloader_Package($params[$i]->getDownloader()); + PEAR::pushErrorHandling(PEAR_ERROR_RETURN); + $e = $obj->_fromFile($a = $dl->getDownloadDir() . DIRECTORY_SEPARATOR . $file); + PEAR::popErrorHandling(); + if (PEAR::isError($e)) { + if (!isset($options['soft'])) { + $dl->log(0, $e->getMessage()); + } + continue; + } + $j = &$obj; + if (!PEAR_Downloader_Package::willDownload($j, + array_merge($params, $newparams)) && !$param->isInstalled($j)) { + $newparams[] = &$j; + } + } + } + foreach ($bundles as $i) { + unset($params[$i]); // remove bundles - only their contents matter for installation + } + PEAR_Downloader_Package::removeDuplicates($params); // strip any unset indices + if (count($newparams)) { // add in bundled packages for install + foreach ($newparams as $i => $unused) { + $params[] = &$newparams[$i]; + } + $newparams = array(); + } + foreach ($params as $i => $param) { + $newdeps = array(); + foreach ($param->_downloadDeps as $dep) { + if (!PEAR_Downloader_Package::willDownload($dep, + array_merge($params, $newparams)) && !$param->isInstalled($dep)) { + $newdeps[] = $dep; + } else { + // detect versioning conflicts here + } + } + // convert the dependencies into PEAR_Downloader_Package objects for the next time + // around + $params[$i]->_downloadDeps = array(); + foreach ($newdeps as $dep) { + $obj = &new PEAR_Downloader_Package($params[$i]->getDownloader()); + if ($s = $params[$i]->explicitState()) { + $obj->setExplicitState($s); + } + PEAR::pushErrorHandling(PEAR_ERROR_RETURN); + $e = $obj->fromDepURL($dep); + PEAR::popErrorHandling(); + if (PEAR::isError($e)) { + if (!isset($options['soft'])) { + $obj->_downloader->log(0, $e->getMessage()); + } + continue; + } + $e = $obj->detectDependencies($params); + if (PEAR::isError($e)) { + if (!isset($options['soft'])) { + $obj->_downloader->log(0, $e->getMessage()); + } + } + $j = &$obj; + $newparams[] = &$j; + } + } + if (count($newparams)) { + foreach ($newparams as $i => $unused) { + $params[] = &$newparams[$i]; + } + return true; + } else { + return false; + } + } + + + /** + * @static + */ + function willDownload($param, $params) + { + if (!is_array($params)) { + return false; + } + foreach ($params as $obj) { + if ($obj->isEqual($param)) { + return true; + } + } + return false; + } + + /** + * For simpler unit-testing + * @param PEAR_Config + * @param int + * @param string + */ + function &getPackagefileObject(&$c, $d, $t = false) + { + $a = &new PEAR_PackageFile($c, $d, $t); + return $a; + } + + + /** + * This will retrieve from a local file if possible, and parse out + * a group name as well. The original parameter will be modified to reflect this. + * @param string|array can be a parsed package name as well + * @access private + */ + function _fromFile(&$param) + { + if (is_string($param)) { + if (!file_exists($param)) { + $test = explode('#', $param); + $group = array_pop($test); + if (file_exists(implode('#', $test))) { + $this->setGroup($group); + $param = implode('#', $test); + $this->_explicitGroup = true; + } + } + if (is_file($param)) { + $this->_type = 'local'; + $options = $this->_downloader->getOptions(); + if (isset($options['downloadonly'])) { + $pkg = &$this->getPackagefileObject($this->_config, + $this->_downloader->_debug); + } else { + $pkg = &$this->getPackagefileObject($this->_config, + $this->_downloader->_debug, $this->_downloader->getDownloadDir()); + } + PEAR::pushErrorHandling(PEAR_ERROR_RETURN); + $pf = &$pkg->fromAnyFile($param, PEAR_VALIDATE_INSTALLING); + PEAR::popErrorHandling(); + if (PEAR::isError($pf)) { + $this->_valid = false; + return $pf; + } + $this->_packagefile = &$pf; + if (!$this->getGroup()) { + $this->setGroup('default'); // install the default dependency group + } + return $this->_valid = true; + } + } + return $this->_valid = false; + } + + function _fromUrl($param, $saveparam = '') + { + if (!is_array($param) && + (preg_match('#^(http|ftp)://#', $param))) { + $options = $this->_downloader->getOptions(); + $this->_type = 'url'; + $callback = $this->_downloader->ui ? + array(&$this->_downloader, '_downloadCallback') : null; + $this->_downloader->pushErrorHandling(PEAR_ERROR_RETURN); + $file = $this->_downloader->downloadHttp($param, $this->_downloader->ui, + $this->_downloader->getDownloadDir(), $callback); + $this->_downloader->popErrorHandling(); + if (PEAR::isError($file)) { + if (!empty($saveparam)) { + $saveparam = ", cannot download \"$saveparam\""; + } + $err = PEAR::raiseError('Could not download from "' . $param . + '"' . $saveparam . ' (' . $file->getMessage() . ')'); + return $err; + } + if ($this->_rawpackagefile) { + require_once 'Archive/Tar.php'; + $tar = &new Archive_Tar($file); + $packagexml = $tar->extractInString('package2.xml'); + if (!$packagexml) { + $packagexml = $tar->extractInString('package.xml'); + } + if (str_replace(array("\n", "\r"), array('',''), $packagexml) != + str_replace(array("\n", "\r"), array('',''), $this->_rawpackagefile)) { + if ($this->getChannel() == 'pear.php.net') { + // be more lax for the existing PEAR packages that have not-ok + // characters in their package.xml + $this->_downloader->log(0, 'CRITICAL WARNING: The "' . + $this->getPackage() . '" package has invalid characters in its ' . + 'package.xml. The next version of PEAR may not be able to install ' . + 'this package for security reasons. Please open a bug report at ' . + 'http://pear.php.net/package/' . $this->getPackage() . '/bugs'); + } else { + return PEAR::raiseError('CRITICAL ERROR: package.xml downloaded does ' . + 'not match value returned from xml-rpc'); + } + } + } + // whew, download worked! + if (isset($options['downloadonly'])) { + $pkg = &$this->getPackagefileObject($this->_config, $this->_downloader->debug); + } else { + $pkg = &$this->getPackagefileObject($this->_config, $this->_downloader->debug, + $this->_downloader->getDownloadDir()); + } + PEAR::pushErrorHandling(PEAR_ERROR_RETURN); + $pf = &$pkg->fromAnyFile($file, PEAR_VALIDATE_INSTALLING); + PEAR::popErrorHandling(); + if (PEAR::isError($pf)) { + if (is_array($pf->getUserInfo())) { + foreach ($pf->getUserInfo() as $err) { + if (is_array($err)) { + $err = $err['message']; + } + if (!isset($options['soft'])) { + $this->_downloader->log(0, "Validation Error: $err"); + } + } + } + if (!isset($options['soft'])) { + $this->_downloader->log(0, $pf->getMessage()); + } + $err = PEAR::raiseError('Download of "' . ($saveparam ? $saveparam : + $param) . '" succeeded, but it is not a valid package archive'); + $this->_valid = false; + return $err; + } + $this->_packagefile = &$pf; + $this->setGroup('default'); // install the default dependency group + return $this->_valid = true; + } + return $this->_valid = false; + } + + /** + * + * @param string|array pass in an array of format + * array( + * 'package' => 'pname', + * ['channel' => 'channame',] + * ['version' => 'version',] + * ['state' => 'state',]) + * or a string of format [channame/]pname[-version|-state] + */ + function _fromString($param) + { + $options = $this->_downloader->getOptions(); + PEAR::pushErrorHandling(PEAR_ERROR_RETURN); + $pname = $this->_registry->parsePackageName($param, + $this->_config->get('default_channel')); + PEAR::popErrorHandling(); + if (PEAR::isError($pname)) { + if ($pname->getCode() == 'invalid') { + $this->_valid = false; + return false; + } + if ($pname->getCode() == 'channel') { + $parsed = $pname->getUserInfo(); + if ($this->_downloader->discover($parsed['channel'])) { + if ($this->_config->get('auto_discover')) { + PEAR::pushErrorHandling(PEAR_ERROR_RETURN); + $pname = $this->_registry->parsePackageName($param, + $this->_config->get('default_channel')); + PEAR::popErrorHandling(); + } else { + if (!isset($options['soft'])) { + $this->_downloader->log(0, 'Channel "' . $parsed['channel'] . + '" is not initialized, use ' . + '"pear channel-discover ' . $parsed['channel'] . '" to initialize' . + 'or pear config-set auto_discover 1'); + } + } + } + if (PEAR::isError($pname)) { + if (!isset($options['soft'])) { + $this->_downloader->log(0, $pname->getMessage()); + } + if (is_array($param)) { + $param = $this->_registry->parsedPackageNameToString($param); + } + $err = PEAR::raiseError('invalid package name/package file "' . + $param . '"'); + $this->_valid = false; + return $err; + } + } else { + if (!isset($options['soft'])) { + $this->_downloader->log(0, $pname->getMessage()); + } + $err = PEAR::raiseError('invalid package name/package file "' . + $param . '"'); + $this->_valid = false; + return $err; + } + } + if (!isset($this->_type)) { + $this->_type = 'xmlrpc'; + } + $this->_parsedname = $pname; + if (isset($pname['state'])) { + $this->_explicitState = $pname['state']; + } else { + $this->_explicitState = false; + } + if (isset($pname['group'])) { + $this->_explicitGroup = true; + } else { + $this->_explicitGroup = false; + } + $info = $this->_downloader->_getPackageDownloadUrl($pname); + if (PEAR::isError($info)) { + if ($info->getCode() != -976 && $pname['channel'] == 'pear.php.net') { + // try pecl + $pname['channel'] = 'pecl.php.net'; + if ($test = $this->_downloader->_getPackageDownloadUrl($pname)) { + if (!PEAR::isError($test)) { + $info = PEAR::raiseError($info->getMessage() . ' - package ' . + $this->_registry->parsedPackageNameToString($pname, true) . + ' can be installed with "pecl install ' . $pname['package'] . + '"'); + } else { + $pname['channel'] = 'pear.php.net'; + } + } else { + $pname['channel'] = 'pear.php.net'; + } + } + return $info; + } + $this->_rawpackagefile = $info['raw']; + $ret = $this->_analyzeDownloadURL($info, $param, $pname); + if (PEAR::isError($ret)) { + return $ret; + } + if ($ret) { + $this->_downloadURL = $ret; + return $this->_valid = (bool) $ret; + } + } + + /** + * @param array output of package.getDownloadURL + * @param string|array|object information for detecting packages to be downloaded, and + * for errors + * @param array name information of the package + * @param array|null packages to be downloaded + * @param bool is this an optional dependency? + * @param bool is this any kind of dependency? + * @access private + */ + function _analyzeDownloadURL($info, $param, $pname, $params = null, $optional = false, + $isdependency = false) + { + if (!is_string($param) && PEAR_Downloader_Package::willDownload($param, $params)) { + return false; + } + if (!$info) { + if (!is_string($param)) { + $saveparam = ", cannot download \"$param\""; + } else { + $saveparam = ''; + } + // no releases exist + return PEAR::raiseError('No releases for package "' . + $this->_registry->parsedPackageNameToString($pname, true) . '" exist' . $saveparam); + } + if (strtolower($info['info']->getChannel()) != strtolower($pname['channel'])) { + $err = false; + if ($pname['channel'] == 'pecl.php.net') { + if ($info['info']->getChannel() != 'pear.php.net') { + $err = true; + } + } elseif ($info['info']->getChannel() == 'pecl.php.net') { + if ($pname['channel'] != 'pear.php.net') { + $err = true; + } + } else { + $err = true; + } + if ($err) { + return PEAR::raiseError('SECURITY ERROR: package in channel "' . $pname['channel'] . + '" retrieved another channel\'s name for download! ("' . + $info['info']->getChannel() . '")'); + } + } + if (!isset($info['url'])) { + if ($this->isInstalled($info)) { + if ($isdependency && version_compare($info['version'], + $this->_registry->packageInfo($info['info']->getPackage(), + 'version', $info['info']->getChannel()), '<=')) { + // ignore bogus errors of "failed to download dependency" + // if it is already installed and the one that would be + // downloaded is older or the same version (Bug #7219) + return false; + } + } + $instead = ', will instead download version ' . $info['version'] . + ', stability "' . $info['info']->getState() . '"'; + // releases exist, but we failed to get any + if (isset($this->_downloader->_options['force'])) { + if (isset($pname['version'])) { + $vs = ', version "' . $pname['version'] . '"'; + } elseif (isset($pname['state'])) { + $vs = ', stability "' . $pname['state'] . '"'; + } elseif ($param == 'dependency') { + if (!class_exists('PEAR_Common')) { + require_once 'PEAR/Common.php'; + } + if (!in_array($info['info']->getState(), + PEAR_Common::betterStates($this->_config->get('preferred_state'), true))) { + if ($optional) { + // don't spit out confusing error message + return $this->_downloader->_getPackageDownloadUrl( + array('package' => $pname['package'], + 'channel' => $pname['channel'], + 'version' => $info['version'])); + } + $vs = ' within preferred state "' . $this->_config->get('preferred_state') . + '"'; + } else { + if (!class_exists('PEAR_Dependency2')) { + require_once 'PEAR/Dependency2.php'; + } + if ($optional) { + // don't spit out confusing error message + return $this->_downloader->_getPackageDownloadUrl( + array('package' => $pname['package'], + 'channel' => $pname['channel'], + 'version' => $info['version'])); + } + $vs = PEAR_Dependency2::_getExtraString($pname); + $instead = ''; + } + } else { + $vs = ' within preferred state "' . $this->_config->get( + 'preferred_state') . '"'; + } + if (!isset($options['soft'])) { + $this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] . + '/' . $pname['package'] . $vs . $instead); + } + // download the latest release + return $this->_downloader->_getPackageDownloadUrl( + array('package' => $pname['package'], + 'channel' => $pname['channel'], + 'version' => $info['version'])); + } else { + // construct helpful error message + if (isset($pname['version'])) { + $vs = ', version "' . $pname['version'] . '"'; + } elseif (isset($pname['state'])) { + $vs = ', stability "' . $pname['state'] . '"'; + } elseif ($param == 'dependency') { + if (!class_exists('PEAR_Common')) { + require_once 'PEAR/Common.php'; + } + if (!in_array($info['info']->getState(), + PEAR_Common::betterStates($this->_config->get('preferred_state'), true))) { + if ($optional) { + // don't spit out confusing error message, and don't die on + // optional dep failure! + return $this->_downloader->_getPackageDownloadUrl( + array('package' => $pname['package'], + 'channel' => $pname['channel'], + 'version' => $info['version'])); + } + $vs = ' within preferred state "' . $this->_config->get('preferred_state') . + '"'; + } else { + if (!class_exists('PEAR_Dependency2')) { + require_once 'PEAR/Dependency2.php'; + } + if ($optional) { + // don't spit out confusing error message, and don't die on + // optional dep failure! + return $this->_downloader->_getPackageDownloadUrl( + array('package' => $pname['package'], + 'channel' => $pname['channel'], + 'version' => $info['version'])); + } + $vs = PEAR_Dependency2::_getExtraString($pname); + } + } else { + $vs = ' within preferred state "' . $this->_downloader->config->get( + 'preferred_state') . '"'; + } + $options = $this->_downloader->getOptions(); + // this is only set by the "download-all" command + if (isset($options['ignorepreferred_state'])) { + $err = PEAR::raiseError( + 'Failed to download ' . $this->_registry->parsedPackageNameToString( + array('channel' => $pname['channel'], 'package' => $pname['package']), + true) + . $vs . + ', latest release is version ' . $info['version'] . + ', stability "' . $info['info']->getState() . '", use "' . + $this->_registry->parsedPackageNameToString( + array('channel' => $pname['channel'], 'package' => $pname['package'], + 'version' => $info['version'])) . '" to install', + PEAR_DOWNLOADER_PACKAGE_STATE); + return $err; + } + $err = PEAR::raiseError( + 'Failed to download ' . $this->_registry->parsedPackageNameToString( + array('channel' => $pname['channel'], 'package' => $pname['package']), + true) + . $vs . + ', latest release is version ' . $info['version'] . + ', stability "' . $info['info']->getState() . '", use "' . + $this->_registry->parsedPackageNameToString( + array('channel' => $pname['channel'], 'package' => $pname['package'], + 'version' => $info['version'])) . '" to install'); + return $err; + } + } + return $info; + } +} +?> http://cvs.php.net/viewcvs.cgi/pear-core/PEAR/REST/10.php?r1=1.40&r2=1.41&diff_format=u Index: pear-core/PEAR/REST/10.php diff -u pear-core/PEAR/REST/10.php:1.40 pear-core/PEAR/REST/10.php:1.41 --- pear-core/PEAR/REST/10.php:1.40 Fri Jan 6 04:47:37 2006 +++ pear-core/PEAR/REST/10.php Tue Mar 28 03:51:40 2006 @@ -1,624 +1,648 @@ -<?php -/** - * PEAR_REST_10 - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 3.0 of the PHP license - * that is available through the world-wide-web at the following URI: - * http://www.php.net/license/3_0.txt. If you did not receive a copy of - * the PHP License and are unable to obtain it through the web, please - * send a note to license@php.net so we can mail you a copy immediately. - * - * @category pear - * @package PEAR - * @author Greg Beaver <cellog@php.net> - * @copyright 1997-2006 The PHP Group - * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: 10.php,v 1.40 2006/01/06 04:47:37 cellog Exp $ - * @link http://pear.php.net/package/PEAR - * @since File available since Release 1.4.0a12 - */ - -/** - * For downloading REST xml/txt files - */ -require_once 'PEAR/REST.php'; - -/** - * Implement REST 1.0 - * - * @category pear - * @package PEAR - * @author Greg Beaver <cellog@php.net> - * @copyright 1997-2006 The PHP Group - * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version Release: @package_version@ - * @link http://pear.php.net/package/PEAR - * @since Class available since Release 1.4.0a12 - */ -class PEAR_REST_10 -{ - /** - * @var PEAR_REST - */ - var $_rest; - function PEAR_REST_10($config, $options = array()) - { - $this->_rest = &new PEAR_REST($config, $options); - } - - function getDownloadURL($base, $packageinfo, $prefstate, $installed) - { - $channel = $packageinfo['channel']; - $package = $packageinfo['package']; - $states = $this->betterStates($prefstate, true); - if (!$states) { - return PEAR::raiseError('"' . $prefstate . '" is not a valid state'); - } - $state = $version = null; - if (isset($packageinfo['state'])) { - $state = $packageinfo['state']; - } - if (isset($packageinfo['version'])) { - $version = $packageinfo['version']; - } - $info = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . '/allreleases.xml'); - if (PEAR::isError($info)) { - return PEAR::raiseError('No releases available for package "' . - $channel . '/' . $package . '"'); - } - if (!isset($info['r'])) { - return false; - } - $found = false; - $release = false; - if (!is_array($info['r']) || !isset($info['r'][0])) { - $info['r'] = array($info['r']); - } - foreach ($info['r'] as $release) { - if (!isset($this->_rest->_options['force']) && ($installed && - version_compare($release['v'], $installed, '<'))) { - continue; - } - if (isset($state)) { - if ($release['s'] == $state) { - $found = true; - break; - } - } elseif (isset($version)) { - if ($release['v'] == $version) { - $found = true; - break; - } - } else { - if (in_array($release['s'], $states)) { - $found = true; - break; - } - } - } - return $this->_returnDownloadURL($base, $package, $release, $info, $found); - } - - function getDepDownloadURL($base, $xsdversion, $dependency, $deppackage, - $prefstate = 'stable', $installed = false) - { - $channel = $dependency['channel']; - $package = $dependency['name']; - $states = $this->betterStates($prefstate, true); - if (!$states) { - return PEAR::raiseError('"' . $prefstate . '" is not a valid state'); - } - $state = $version = null; - if (isset($packageinfo['state'])) { - $state = $packageinfo['state']; - } - if (isset($packageinfo['version'])) { - $version = $packageinfo['version']; - } - $info = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . '/allreleases.xml'); - if (PEAR::isError($info)) { - return PEAR::raiseError('Package "' . $deppackage['channel'] . '/' . $deppackage['package'] - . '" dependency "' . $channel . '/' . $package . '" has no releases'); - } - if (!is_array($info) || !isset($info['r'])) { - return false; - } - $exclude = array(); - $min = $max = $recommended = false; - if ($xsdversion == '1.0') { - $pinfo['package'] = $dependency['name']; - $pinfo['channel'] = 'pear.php.net'; // this is always true - don't change this - switch ($dependency['rel']) { - case 'ge' : - $min = $dependency['version']; - break; - case 'gt' : - $min = $dependency['version']; - $exclude = array($dependency['version']); - break; - case 'eq' : - $recommended = $dependency['version']; - break; - case 'lt' : - $max = $dependency['version']; - $exclude = array($dependency['version']); - break; - case 'le' : - $max = $dependency['version']; - break; - case 'ne' : - $exclude = array($dependency['version']); - break; - } - } else { - $pinfo['package'] = $dependency['name']; - $min = isset($dependency['min']) ? $dependency['min'] : false; - $max = isset($dependency['max']) ? $dependency['max'] : false; - $recommended = isset($dependency['recommended']) ? - $dependency['recommended'] : false; - if (isset($dependency['exclude'])) { - if (!isset($dependency['exclude'][0])) { - $exclude = array($dependency['exclude']); - } - } - } - $found = false; - $release = false; - if (!is_array($info['r']) || !isset($info['r'][0])) { - $info['r'] = array($info['r']); - } - foreach ($info['r'] as $release) { - if (!isset($this->_rest->_options['force']) && ($installed && - version_compare($release['v'], $installed, '<'))) { - continue; - } - if (in_array($release['v'], $exclude)) { // skip excluded versions - continue; - } - // allow newer releases to say "I'm OK with the dependent package" - if ($xsdversion == '2.0' && isset($release['co'])) { - if (!is_array($release['co']) || !isset($release['co'][0])) { - $release['co'] = array($release['co']); - } - foreach ($release['co'] as $entry) { - if (isset($entry['x']) && !is_array($entry['x'])) { - $entry['x'] = array($entry['x']); - } elseif (!isset($entry['x'])) { - $entry['x'] = array(); - } - if ($entry['c'] == $deppackage['channel'] && - strtolower($entry['p']) == strtolower($deppackage['package']) && - version_compare($deppackage['version'], $entry['min'], '>=') && - version_compare($deppackage['version'], $entry['max'], '<=') && - !in_array($release['v'], $entry['x'])) { - $recommended = $release['v']; - break; - } - } - } - if ($recommended) { - if ($release['v'] != $recommended) { // if we want a specific - // version, then skip all others - continue; - } else { - if (!in_array($release['s'], $states)) { - // the stability is too low, but we must return the - // recommended version if possible - return $this->_returnDownloadURL($base, $package, $release, $info, true); - } - } - } - if ($min && version_compare($release['v'], $min, 'lt')) { // skip too old versions - continue; - } - if ($max && version_compare($release['v'], $max, 'gt')) { // skip too new versions - continue; - } - if ($installed && version_compare($release['v'], $installed, '<')) { - continue; - } - if (in_array($release['s'], $states)) { // if in the preferred state... - $found = true; // ... then use it - break; - } - } - return $this->_returnDownloadURL($base, $package, $release, $info, $found); - } - - function _returnDownloadURL($base, $package, $release, $info, $found) - { - if (!$found) { - $release = $info['r'][0]; - } - $releaseinfo = $this->_rest->retrieveCacheFirst($base . 'r/' . strtolower($package) . '/' . - $release['v'] . '.xml'); - if (PEAR::isError($releaseinfo)) { - return PEAR::raiseError('Package "' . $package . '" Version "' . $release['v'] . - '" does not have REST xml available'); - } - $packagexml = $this->_rest->retrieveCacheFirst($base . 'r/' . strtolower($package) . '/' . - 'deps.' . $release['v'] . '.txt', false, true); - if (PEAR::isError($packagexml)) { - return PEAR::raiseError('Package "' . $package . '" Version "' . $release['v'] . - '" does not have REST dependency information available'); - } - $packagexml = unserialize($packagexml); - if (!$packagexml) { - $packagexml = array(); - } - $allinfo = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . - '/allreleases.xml'); - if (!is_array($allinfo['r']) || !isset($allinfo['r'][0])) { - $allinfo['r'] = array($allinfo['r']); - } - $compatible = false; - foreach ($allinfo['r'] as $release) { - if ($release['v'] != $releaseinfo['v']) { - continue; - } - if (!isset($release['co'])) { - break; - } - $compatible = array(); - if (!is_array($release['co']) || !isset($release['co'][0])) { - $release['co'] = array($release['co']); - } - foreach ($release['co'] as $entry) { - $comp = array(); - $comp['name'] = $entry['p']; - $comp['channel'] = $entry['c']; - $comp['min'] = $entry['min']; - $comp['max'] = $entry['max']; - if (isset($entry['x']) && !is_array($entry['x'])) { - $comp['exclude'] = $entry['x']; - } - $compatible[] = $comp; - } - if (count($compatible) == 1) { - $compatible = $compatible[0]; - } - break; - } - if ($found) { - return - array('version' => $releaseinfo['v'], - 'info' => $packagexml, - 'package' => $releaseinfo['p']['_content'], - 'stability' => $releaseinfo['st'], - 'url' => $releaseinfo['g'], - 'compatible' => $compatible); - } else { - return - array('version' => $releaseinfo['v'], - 'package' => $releaseinfo['p']['_content'], - 'stability' => $releaseinfo['st'], - 'info' => $packagexml, - 'compatible' => $compatible); - } - } - - function listPackages($base) - { - $packagelist = $this->_rest->retrieveData($base . 'p/packages.xml'); - if (PEAR::isError($packagelist)) { - return $packagelist; - } - if (!is_array($packagelist) || !isset($packagelist['p'])) { - return array(); - } - if (!is_array($packagelist['p'])) { - $packagelist['p'] = array($packagelist['p']); - } - return $packagelist['p']; - } - - function listAll($base, $dostable, $basic = true, $searchpackage = false, $searchsummary = false) - { - $packagelist = $this->_rest->retrieveData($base . 'p/packages.xml'); - if (PEAR::isError($packagelist)) { - return $packagelist; - } - if ($this->_rest->config->get('verbose') > 0) { - $ui = &PEAR_Frontend::singleton(); - $ui->log('Retrieving data...0%', false); - } - $ret = array(); - if (!is_array($packagelist) || !isset($packagelist['p'])) { - return $ret; - } - if (!is_array($packagelist['p'])) { - $packagelist['p'] = array($packagelist['p']); - } - PEAR::pushErrorHandling(PEAR_ERROR_RETURN); - $next = .1; - foreach ($packagelist['p'] as $progress => $package) { - if ($this->_rest->config->get('verbose') > 0) { - if ($progress / count($packagelist['p']) >= $next) { - if ($next == .5) { - $ui->log('50%', false); - } else { - $ui->log('.', false); - } - $next += .1; - } - } - if ($basic) { // remote-list command - if ($dostable) { - $latest = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . - '/stable.txt'); - } else { - $latest = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . - '/latest.txt'); - } - if (PEAR::isError($latest)) { - $latest = false; - } - $info = array('stable' => $latest); - } else { // list-all command - $inf = $this->_rest->retrieveData($base . 'p/' . strtolower($package) . '/info.xml'); - if (PEAR::isError($inf)) { - PEAR::popErrorHandling(); - return $inf; - } - if ($searchpackage) { - $found = (!empty($searchpackage) && stristr($package, $searchpackage) !== false); - if (!$found && !(isset($searchsummary) && !empty($searchsummary) - && (stristr($inf['s'], $searchsummary) !== false - || stristr($inf['d'], $searchsummary) !== false))) - { - continue; - }; - } - $releases = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . - '/allreleases.xml'); - if (PEAR::isError($releases)) { - continue; - } - if (!isset($releases['r'][0])) { - $releases['r'] = array($releases['r']); - } - unset($latest); - unset($unstable); - unset($stable); - unset($state); - foreach ($releases['r'] as $release) { - if (!isset($latest)) { - if ($dostable && $release['s'] == 'stable') { - $latest = $release['v']; - $state = 'stable'; - } - if (!$dostable) { - $latest = $release['v']; - $state = $release['s']; - } - } - if (!isset($stable) && $release['s'] == 'stable') { - $stable = $release['v']; - if (!isset($unstable)) { - $unstable = $stable; - } - } - if (!isset($unstable) && $release['s'] != 'stable') { - $latest = $unstable = $release['v']; - $state = $release['s']; - } - if (isset($latest) && !isset($state)) { - $state = $release['s']; - } - if (isset($latest) && isset($stable) && isset($unstable)) { - break; - } - } - $deps = array(); - if (!isset($unstable)) { - $unstable = false; - $state = 'stable'; - if (isset($stable)) { - $latest = $unstable = $stable; - } - } else { - $latest = $unstable; - } - if (!isset($latest)) { - $latest = false; - } - if ($latest) { - $d = $this->_rest->retrieveCacheFirst($base . 'r/' . strtolower($package) . '/deps.' . - $latest . '.txt'); - if (!PEAR::isError($d)) { - $d = unserialize($d); - if ($d) { - if (isset($d['required'])) { - if (!class_exists('PEAR_PackageFile_v2')) { - require_once 'PEAR/PackageFile/v2.php'; - } - if (!isset($pf)) { - $pf = new PEAR_PackageFile_v2; - } - $pf->setDeps($d); - $tdeps = $pf->getDeps(); - } else { - $tdeps = $d; - } - foreach ($tdeps as $dep) { - if ($dep['type'] !== 'pkg') { - continue; - } - $deps[] = $dep; - } - } - } - } - if (!isset($stable)) { - $stable = '-n/a-'; - } - if (!$searchpackage) { - $info = array('stable' => $latest, 'summary' => $inf['s'], 'description' => - $inf['d'], 'deps' => $deps, 'category' => $inf['ca']['_content'], - 'unstable' => $unstable, 'state' => $state); - } else { - $info = array('stable' => $stable, 'summary' => $inf['s'], 'description' => - $inf['d'], 'deps' => $deps, 'category' => $inf['ca']['_content'], - 'unstable' => $unstable, 'state' => $state); - } - } - $ret[$package] = $info; - } - PEAR::popErrorHandling(); - return $ret; - } - - function listLatestUpgrades($base, $state, $installed, $channel, &$reg) - { - $packagelist = $this->_rest->retrieveData($base . 'p/packages.xml'); - if (PEAR::isError($packagelist)) { - return $packagelist; - } - $ret = array(); - if (!is_array($packagelist) || !isset($packagelist['p'])) { - return $ret; - } - if (!is_array($packagelist['p'])) { - $packagelist['p'] = array($packagelist['p']); - } - if ($state) { - $states = $this->betterStates($state, true); - } - foreach ($packagelist['p'] as $package) { - if (!isset($installed[strtolower($package)])) { - continue; - } - $inst_version = $reg->packageInfo($package, 'version', $channel); - PEAR::pushErrorHandling(PEAR_ERROR_RETURN); - $info = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . - '/allreleases.xml'); - PEAR::popErrorHandling(); - if (PEAR::isError($info)) { - continue; // no remote releases - } - if (!isset($info['r'])) { - continue; - } - $found = false; - $release = false; - if (!is_array($info['r']) || !isset($info['r'][0])) { - $info['r'] = array($info['r']); - } - foreach ($info['r'] as $release) { - if ($inst_version && version_compare($release['v'], $inst_version, '<=')) { - continue; - } - if ($state) { - if (in_array($release['s'], $states)) { - $found = true; - break; - } - } else { - $found = true; - break; - } - } - if (!$found) { - continue; - } - $relinfo = $this->_rest->retrieveCacheFirst($base . 'r/' . strtolower($package) . '/' . - $release['v'] . '.xml'); - if (PEAR::isError($relinfo)) { - return $relinfo; - } - $ret[$package] = array( - 'version' => $release['v'], - 'state' => $release['s'], - 'filesize' => $relinfo['f'], - ); - } - return $ret; - } - - function packageInfo($base, $package) - { - PEAR::pushErrorHandling(PEAR_ERROR_RETURN); - $pinfo = $this->_rest->retrieveData($base . 'p/' . strtolower($package) . '/info.xml'); - if (PEAR::isError($pinfo)) { - PEAR::popErrorHandling(); - return PEAR::raiseError('Unknown package: "' . $package . '" (Debug: ' . - $pinfo->getMessage() . ')'); - } - $releases = array(); - $allreleases = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . - '/allreleases.xml'); - if (!PEAR::isError($allreleases)) { - if (!class_exists('PEAR_PackageFile_v2')) { - require_once 'PEAR/PackageFile/v2.php'; - } - if (!is_array($allreleases['r'])) { - $allreleases['r'] = array($allreleases['r']); - } - $pf = new PEAR_PackageFile_v2; - foreach ($allreleases['r'] as $release) { - $ds = $this->_rest->retrieveCacheFirst($base . 'r/' . strtolower($package) . '/deps.' . - $release['v'] . '.txt'); - if (PEAR::isError($ds)) { - continue; - } - if (!isset($latest)) { - $latest = $release['v']; - } - $pf->setDeps(unserialize($ds)); - $ds = $pf->getDeps(); - $info = $this->_rest->retrieveCacheFirst($base . 'r/' . strtolower($package) - . '/' . $release['v'] . '.xml'); - if (PEAR::isError($info)) { - continue; - } - $releases[$release['v']] = array( - 'doneby' => $info['m'], - 'license' => $info['l'], - 'summary' => $info['s'], - 'description' => $info['d'], - 'releasedate' => $info['da'], - 'releasenotes' => $info['n'], - 'state' => $release['s'], - 'deps' => $ds ? $ds : array(), - ); - } - } else { - $latest = ''; - } - PEAR::popErrorHandling(); - return array( - 'name' => $pinfo['n'], - 'channel' => $pinfo['c'], - 'category' => $pinfo['ca']['_content'], - 'stable' => $latest, - 'license' => $pinfo['l'], - 'summary' => $pinfo['s'], - 'description' => $pinfo['d'], - 'releases' => $releases, - ); - } - - /** - * Return an array containing all of the states that are more stable than - * or equal to the passed in state - * - * @param string Release state - * @param boolean Determines whether to include $state in the list - * @return false|array False if $state is not a valid release state - */ - function betterStates($state, $include = false) - { - static $states = array('snapshot', 'devel', 'alpha', 'beta', 'stable'); - $i = array_search($state, $states); - if ($i === false) { - return false; - } - if ($include) { - $i--; - } - return array_slice($states, $i + 1); - } -} +<?php +/** + * PEAR_REST_10 + * + * PHP versions 4 and 5 + * + * LICENSE: This source file is subject to version 3.0 of the PHP license + * that is available through the world-wide-web at the following URI: + * http://www.php.net/license/3_0.txt. If you did not receive a copy of + * the PHP License and are unable to obtain it through the web, please + * send a note to license@php.net so we can mail you a copy immediately. + * + * @category pear + * @package PEAR + * @author Greg Beaver <cellog@php.net> + * @copyright 1997-2006 The PHP Group + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version CVS: $Id: 10.php,v 1.41 2006/03/28 03:51:40 cellog Exp $ + * @link http://pear.php.net/package/PEAR + * @since File available since Release 1.4.0a12 + */ + +/** + * For downloading REST xml/txt files + */ +require_once 'PEAR/REST.php'; + +/** + * Implement REST 1.0 + * + * @category pear + * @package PEAR + * @author Greg Beaver <cellog@php.net> + * @copyright 1997-2006 The PHP Group + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version Release: @package_version@ + * @link http://pear.php.net/package/PEAR + * @since Class available since Release 1.4.0a12 + */ +class PEAR_REST_10 +{ + /** + * @var PEAR_REST + */ + var $_rest; + function PEAR_REST_10($config, $options = array()) + { + $this->_rest = &new PEAR_REST($config, $options); + } + + /** + * Retrieve information about a remote package to be downloaded from a REST server + * + * @param string $base The uri to prepend to all REST calls + * @param array $packageinfo an array of format: + * <pre> + * array( + * 'package' => 'packagename', + * 'channel' => 'channelname', + * ['state' => 'alpha' (or valid state),] + * -or- + * ['version' => '1.whatever'] + * </pre> + * @param string $prefstate Current preferred_state config variable value + * @param bool $installed the installed version of this package to compare against + * @return array|false|PEAR_Error see {@link _returnDownloadURL()} + */ + function getDownloadURL($base, $packageinfo, $prefstate, $installed) + { + $channel = $packageinfo['channel']; + $package = $packageinfo['package']; + $states = $this->betterStates($prefstate, true); + if (!$states) { + return PEAR::raiseError('"' . $prefstate . '" is not a valid state'); + } + $state = $version = null; + if (isset($packageinfo['state'])) { + $state = $packageinfo['state']; + } + if (isset($packageinfo['version'])) { + $version = $packageinfo['version']; + } + $info = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . '/allreleases.xml'); + if (PEAR::isError($info)) { + return PEAR::raiseError('No releases available for package "' . + $channel . '/' . $package . '"'); + } + if (!isset($info['r'])) { + return false; + } + $found = false; + $release = false; + if (!is_array($info['r']) || !isset($info['r'][0])) { + $info['r'] = array($info['r']); + } + foreach ($info['r'] as $release) { + if (!isset($this->_rest->_options['force']) && ($installed && + version_compare($release['v'], $installed, '<'))) { + continue; + } + if (isset($state)) { + // try our preferred state first + if ($release['s'] == $state) { + $found = true; + break; + } + // see if there is something newer and more stable + // bug #7221 + if (in_array($release['s'], $this->betterStates($state), true)) { + $found = true; + break; + } + } elseif (isset($version)) { + if ($release['v'] == $version) { + $found = true; + break; + } + } else { + if (in_array($release['s'], $states)) { + $found = true; + break; + } + } + } + return $this->_returnDownloadURL($base, $package, $release, $info, $found); + } + + function getDepDownloadURL($base, $xsdversion, $dependency, $deppackage, + $prefstate = 'stable', $installed = false) + { + $channel = $dependency['channel']; + $package = $dependency['name']; + $states = $this->betterStates($prefstate, true); + if (!$states) { + return PEAR::raiseError('"' . $prefstate . '" is not a valid state'); + } + $state = $version = null; + if (isset($packageinfo['state'])) { + $state = $packageinfo['state']; + } + if (isset($packageinfo['version'])) { + $version = $packageinfo['version']; + } + $info = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . '/allreleases.xml'); + if (PEAR::isError($info)) { + return PEAR::raiseError('Package "' . $deppackage['channel'] . '/' . $deppackage['package'] + . '" dependency "' . $channel . '/' . $package . '" has no releases'); + } + if (!is_array($info) || !isset($info['r'])) { + return false; + } + $exclude = array(); + $min = $max = $recommended = false; + if ($xsdversion == '1.0') { + $pinfo['package'] = $dependency['name']; + $pinfo['channel'] = 'pear.php.net'; // this is always true - don't change this + switch ($dependency['rel']) { + case 'ge' : + $min = $dependency['version']; + break; + case 'gt' : + $min = $dependency['version']; + $exclude = array($dependency['version']); + break; + case 'eq' : + $recommended = $dependency['version']; + break; + case 'lt' : + $max = $dependency['version']; + $exclude = array($dependency['version']); + break; + case 'le' : + $max = $dependency['version']; + break; + case 'ne' : + $exclude = array($dependency['version']); + break; + } + } else { + $pinfo['package'] = $dependency['name']; + $min = isset($dependency['min']) ? $dependency['min'] : false; + $max = isset($dependency['max']) ? $dependency['max'] : false; + $recommended = isset($dependency['recommended']) ? + $dependency['recommended'] : false; + if (isset($dependency['exclude'])) { + if (!isset($dependency['exclude'][0])) { + $exclude = array($dependency['exclude']); + } + } + } + $found = false; + $release = false; + if (!is_array($info['r']) || !isset($info['r'][0])) { + $info['r'] = array($info['r']); + } + foreach ($info['r'] as $release) { + if (!isset($this->_rest->_options['force']) && ($installed && + version_compare($release['v'], $installed, '<'))) { + continue; + } + if (in_array($release['v'], $exclude)) { // skip excluded versions + continue; + } + // allow newer releases to say "I'm OK with the dependent package" + if ($xsdversion == '2.0' && isset($release['co'])) { + if (!is_array($release['co']) || !isset($release['co'][0])) { + $release['co'] = array($release['co']); + } + foreach ($release['co'] as $entry) { + if (isset($entry['x']) && !is_array($entry['x'])) { + $entry['x'] = array($entry['x']); + } elseif (!isset($entry['x'])) { + $entry['x'] = array(); + } + if ($entry['c'] == $deppackage['channel'] && + strtolower($entry['p']) == strtolower($deppackage['package']) && + version_compare($deppackage['version'], $entry['min'], '>=') && + version_compare($deppackage['version'], $entry['max'], '<=') && + !in_array($release['v'], $entry['x'])) { + $recommended = $release['v']; + break; + } + } + } + if ($recommended) { + if ($release['v'] != $recommended) { // if we want a specific + // version, then skip all others + continue; + } else { + if (!in_array($release['s'], $states)) { + // the stability is too low, but we must return the + // recommended version if possible + return $this->_returnDownloadURL($base, $package, $release, $info, true); + } + } + } + if ($min && version_compare($release['v'], $min, 'lt')) { // skip too old versions + continue; + } + if ($max && version_compare($release['v'], $max, 'gt')) { // skip too new versions + continue; + } + if ($installed && version_compare($release['v'], $installed, '<')) { + continue; + } + if (in_array($release['s'], $states)) { // if in the preferred state... + $found = true; // ... then use it + break; + } + } + return $this->_returnDownloadURL($base, $package, $release, $info, $found); + } + + function _returnDownloadURL($base, $package, $release, $info, $found) + { + if (!$found) { + $release = $info['r'][0]; + } + $releaseinfo = $this->_rest->retrieveCacheFirst($base . 'r/' . strtolower($package) . '/' . + $release['v'] . '.xml'); + if (PEAR::isError($releaseinfo)) { + return PEAR::raiseError('Package "' . $package . '" Version "' . $release['v'] . + '" does not have REST xml available'); + } + $packagexml = $this->_rest->retrieveCacheFirst($base . 'r/' . strtolower($package) . '/' . + 'deps.' . $release['v'] . '.txt', false, true); + if (PEAR::isError($packagexml)) { + return PEAR::raiseError('Package "' . $package . '" Version "' . $release['v'] . + '" does not have REST dependency information available'); + } + $packagexml = unserialize($packagexml); + if (!$packagexml) { + $packagexml = array(); + } + $allinfo = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . + '/allreleases.xml'); + if (!is_array($allinfo['r']) || !isset($allinfo['r'][0])) { + $allinfo['r'] = array($allinfo['r']); + } + $compatible = false; + foreach ($allinfo['r'] as $release) { + if ($release['v'] != $releaseinfo['v']) { + continue; + } + if (!isset($release['co'])) { + break; + } + $compatible = array(); + if (!is_array($release['co']) || !isset($release['co'][0])) { + $release['co'] = array($release['co']); + } + foreach ($release['co'] as $entry) { + $comp = array(); + $comp['name'] = $entry['p']; + $comp['channel'] = $entry['c']; + $comp['min'] = $entry['min']; + $comp['max'] = $entry['max']; + if (isset($entry['x']) && !is_array($entry['x'])) { + $comp['exclude'] = $entry['x']; + } + $compatible[] = $comp; + } + if (count($compatible) == 1) { + $compatible = $compatible[0]; + } + break; + } + if ($found) { + return + array('version' => $releaseinfo['v'], + 'info' => $packagexml, + 'package' => $releaseinfo['p']['_content'], + 'stability' => $releaseinfo['st'], + 'url' => $releaseinfo['g'], + 'compatible' => $compatible); + } else { + return + array('version' => $releaseinfo['v'], + 'package' => $releaseinfo['p']['_content'], + 'stability' => $releaseinfo['st'], + 'info' => $packagexml, + 'compatible' => $compatible); + } + } + + function listPackages($base) + { + $packagelist = $this->_rest->retrieveData($base . 'p/packages.xml'); + if (PEAR::isError($packagelist)) { + return $packagelist; + } + if (!is_array($packagelist) || !isset($packagelist['p'])) { + return array(); + } + if (!is_array($packagelist['p'])) { + $packagelist['p'] = array($packagelist['p']); + } + return $packagelist['p']; + } + + function listAll($base, $dostable, $basic = true, $searchpackage = false, $searchsummary = false) + { + $packagelist = $this->_rest->retrieveData($base . 'p/packages.xml'); + if (PEAR::isError($packagelist)) { + return $packagelist; + } + if ($this->_rest->config->get('verbose') > 0) { + $ui = &PEAR_Frontend::singleton(); + $ui->log('Retrieving data...0%', false); + } + $ret = array(); + if (!is_array($packagelist) || !isset($packagelist['p'])) { + return $ret; + } + if (!is_array($packagelist['p'])) { + $packagelist['p'] = array($packagelist['p']); + } + PEAR::pushErrorHandling(PEAR_ERROR_RETURN); + $next = .1; + foreach ($packagelist['p'] as $progress => $package) { + if ($this->_rest->config->get('verbose') > 0) { + if ($progress / count($packagelist['p']) >= $next) { + if ($next == .5) { + $ui->log('50%', false); + } else { + $ui->log('.', false); + } + $next += .1; + } + } + if ($basic) { // remote-list command + if ($dostable) { + $latest = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . + '/stable.txt'); + } else { + $latest = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . + '/latest.txt'); + } + if (PEAR::isError($latest)) { + $latest = false; + } + $info = array('stable' => $latest); + } else { // list-all command + $inf = $this->_rest->retrieveData($base . 'p/' . strtolower($package) . '/info.xml'); + if (PEAR::isError($inf)) { + PEAR::popErrorHandling(); + return $inf; + } + if ($searchpackage) { + $found = (!empty($searchpackage) && stristr($package, $searchpackage) !== false); + if (!$found && !(isset($searchsummary) && !empty($searchsummary) + && (stristr($inf['s'], $searchsummary) !== false + || stristr($inf['d'], $searchsummary) !== false))) + { + continue; + }; + } + $releases = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . + '/allreleases.xml'); + if (PEAR::isError($releases)) { + continue; + } + if (!isset($releases['r'][0])) { + $releases['r'] = array($releases['r']); + } + unset($latest); + unset($unstable); + unset($stable); + unset($state); + foreach ($releases['r'] as $release) { + if (!isset($latest)) { + if ($dostable && $release['s'] == 'stable') { + $latest = $release['v']; + $state = 'stable'; + } + if (!$dostable) { + $latest = $release['v']; + $state = $release['s']; + } + } + if (!isset($stable) && $release['s'] == 'stable') { + $stable = $release['v']; + if (!isset($unstable)) { + $unstable = $stable; + } + } + if (!isset($unstable) && $release['s'] != 'stable') { + $latest = $unstable = $release['v']; + $state = $release['s']; + } + if (isset($latest) && !isset($state)) { + $state = $release['s']; + } + if (isset($latest) && isset($stable) && isset($unstable)) { + break; + } + } + $deps = array(); + if (!isset($unstable)) { + $unstable = false; + $state = 'stable'; + if (isset($stable)) { + $latest = $unstable = $stable; + } + } else { + $latest = $unstable; + } + if (!isset($latest)) { + $latest = false; + } + if ($latest) { + $d = $this->_rest->retrieveCacheFirst($base . 'r/' . strtolower($package) . '/deps.' . + $latest . '.txt'); + if (!PEAR::isError($d)) { + $d = unserialize($d); + if ($d) { + if (isset($d['required'])) { + if (!class_exists('PEAR_PackageFile_v2')) { + require_once 'PEAR/PackageFile/v2.php'; + } + if (!isset($pf)) { + $pf = new PEAR_PackageFile_v2; + } + $pf->setDeps($d); + $tdeps = $pf->getDeps(); + } else { + $tdeps = $d; + } + foreach ($tdeps as $dep) { + if ($dep['type'] !== 'pkg') { + continue; + } + $deps[] = $dep; + } + } + } + } + if (!isset($stable)) { + $stable = '-n/a-'; + } + if (!$searchpackage) { + $info = array('stable' => $latest, 'summary' => $inf['s'], 'description' => + $inf['d'], 'deps' => $deps, 'category' => $inf['ca']['_content'], + 'unstable' => $unstable, 'state' => $state); + } else { + $info = array('stable' => $stable, 'summary' => $inf['s'], 'description' => + $inf['d'], 'deps' => $deps, 'category' => $inf['ca']['_content'], + 'unstable' => $unstable, 'state' => $state); + } + } + $ret[$package] = $info; + } + PEAR::popErrorHandling(); + return $ret; + } + + function listLatestUpgrades($base, $state, $installed, $channel, &$reg) + { + $packagelist = $this->_rest->retrieveData($base . 'p/packages.xml'); + if (PEAR::isError($packagelist)) { + return $packagelist; + } + $ret = array(); + if (!is_array($packagelist) || !isset($packagelist['p'])) { + return $ret; + } + if (!is_array($packagelist['p'])) { + $packagelist['p'] = array($packagelist['p']); + } + if ($state) { + $states = $this->betterStates($state, true); + } + foreach ($packagelist['p'] as $package) { + if (!isset($installed[strtolower($package)])) { + continue; + } + $inst_version = $reg->packageInfo($package, 'version', $channel); + PEAR::pushErrorHandling(PEAR_ERROR_RETURN); + $info = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . + '/allreleases.xml'); + PEAR::popErrorHandling(); + if (PEAR::isError($info)) { + continue; // no remote releases + } + if (!isset($info['r'])) { + continue; + } + $found = false; + $release = false; + if (!is_array($info['r']) || !isset($info['r'][0])) { + $info['r'] = array($info['r']); + } + foreach ($info['r'] as $release) { + if ($inst_version && version_compare($release['v'], $inst_version, '<=')) { + continue; + } + if ($state) { + if (in_array($release['s'], $states)) { + $found = true; + break; + } + } else { + $found = true; + break; + } + } + if (!$found) { + continue; + } + $relinfo = $this->_rest->retrieveCacheFirst($base . 'r/' . strtolower($package) . '/' . + $release['v'] . '.xml'); + if (PEAR::isError($relinfo)) { + return $relinfo; + } + $ret[$package] = array( + 'version' => $release['v'], + 'state' => $release['s'], + 'filesize' => $relinfo['f'], + ); + } + return $ret; + } + + function packageInfo($base, $package) + { + PEAR::pushErrorHandling(PEAR_ERROR_RETURN); + $pinfo = $this->_rest->retrieveData($base . 'p/' . strtolower($package) . '/info.xml'); + if (PEAR::isError($pinfo)) { + PEAR::popErrorHandling(); + return PEAR::raiseError('Unknown package: "' . $package . '" (Debug: ' . + $pinfo->getMessage() . ')'); + } + $releases = array(); + $allreleases = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . + '/allreleases.xml'); + if (!PEAR::isError($allreleases)) { + if (!class_exists('PEAR_PackageFile_v2')) { + require_once 'PEAR/PackageFile/v2.php'; + } + if (!is_array($allreleases['r'])) { + $allreleases['r'] = array($allreleases['r']); + } + $pf = new PEAR_PackageFile_v2; + foreach ($allreleases['r'] as $release) { + $ds = $this->_rest->retrieveCacheFirst($base . 'r/' . strtolower($package) . '/deps.' . + $release['v'] . '.txt'); + if (PEAR::isError($ds)) { + continue; + } + if (!isset($latest)) { + $latest = $release['v']; + } + $pf->setDeps(unserialize($ds)); + $ds = $pf->getDeps(); + $info = $this->_rest->retrieveCacheFirst($base . 'r/' . strtolower($package) + . '/' . $release['v'] . '.xml'); + if (PEAR::isError($info)) { + continue; + } + $releases[$release['v']] = array( + 'doneby' => $info['m'], + 'license' => $info['l'], + 'summary' => $info['s'], + 'description' => $info['d'], + 'releasedate' => $info['da'], + 'releasenotes' => $info['n'], + 'state' => $release['s'], + 'deps' => $ds ? $ds : array(), + ); + } + } else { + $latest = ''; + } + PEAR::popErrorHandling(); + return array( + 'name' => $pinfo['n'], + 'channel' => $pinfo['c'], + 'category' => $pinfo['ca']['_content'], + 'stable' => $latest, + 'license' => $pinfo['l'], + 'summary' => $pinfo['s'], + 'description' => $pinfo['d'], + 'releases' => $releases, + ); + } + + /** + * Return an array containing all of the states that are more stable than + * or equal to the passed in state + * + * @param string Release state + * @param boolean Determines whether to include $state in the list + * @return false|array False if $state is not a valid release state + */ + function betterStates($state, $include = false) + { + static $states = array('snapshot', 'devel', 'alpha', 'beta', 'stable'); + $i = array_search($state, $states); + if ($i === false) { + return false; + } + if ($include) { + $i--; + } + return array_slice($states, $i + 1); + } +} ?> \ No newline at end of file http://cvs.php.net/viewcvs.cgi/pear-core/tests/PEAR_Command_Install/upgrade/test_bug6931.phpt?r1=1.1&r2=1.2&diff_format=u Index: pear-core/tests/PEAR_Command_Install/upgrade/test_bug6931.phpt diff -u pear-core/tests/PEAR_Command_Install/upgrade/test_bug6931.phpt:1.1 pear-core/tests/PEAR_Command_Install/upgrade/test_bug6931.phpt:1.2 --- pear-core/tests/PEAR_Command_Install/upgrade/test_bug6931.phpt:1.1 Tue Mar 28 03:43:54 2006 +++ pear-core/tests/PEAR_Command_Install/upgrade/test_bug6931.phpt Tue Mar 28 03:51:40 2006 @@ -488,7 +488,7 @@ 0 => array ( 0 => 0, - 1 => 'pear/PEAR is already installed and is newer than detected release version 1.4.0a12', + 1 => 'pear/PEAR is already installed and is newer than detected release version 1.4.8', ), 1 => array (
« previous php.pear.cvs (#39376) next »