/trunk/bibliotheque/pear/PEAR/Command/Package.php |
---|
5,20 → 5,13 |
* |
* 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 Stig Bakken <ssb@php.net> |
* @author Martin Jansen <mj@php.net> |
* @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.122 2006/06/07 23:38:14 pajoye Exp $ |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 0.1 |
*/ |
36,9 → 29,9 |
* @author Stig Bakken <ssb@php.net> |
* @author Martin Jansen <mj@php.net> |
* @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: 1.5.1 |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: @package_version@ |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 0.1 |
*/ |
45,8 → 38,6 |
class PEAR_Command_Package extends PEAR_Command_Common |
{ |
// {{{ properties |
var $commands = array( |
'package' => array( |
'summary' => 'Build Package', |
142,6 → 133,39 |
of a specific release. |
', |
), |
'svntag' => array( |
'summary' => 'Set SVN Release Tag', |
'function' => 'doSvnTag', |
'shortcut' => 'sv', |
'options' => array( |
'quiet' => array( |
'shortopt' => 'q', |
'doc' => 'Be quiet', |
), |
'slide' => array( |
'shortopt' => 'F', |
'doc' => 'Move (slide) tag if it exists', |
), |
'delete' => array( |
'shortopt' => 'd', |
'doc' => 'Remove tag', |
), |
'dry-run' => array( |
'shortopt' => 'n', |
'doc' => 'Don\'t do anything, just pretend', |
), |
), |
'doc' => '<package.xml> [files...] |
Sets a SVN tag on all files in a package. Use this command after you have |
packaged a distribution tarball with the "package" command to tag what |
revisions of what files were in that release. If need to fix something |
after running svntag once, but before the tarball is released to the public, |
use the "slide" option to move the release tag. |
to include files (such as a second package.xml, or tests not included in the |
release), pass them as additional parameters. |
', |
), |
'cvstag' => array( |
'summary' => 'Set CVS Release Tag', |
'function' => 'doCvsTag', |
184,14 → 208,20 |
'function' => 'doPackageDependencies', |
'shortcut' => 'pd', |
'options' => array(), |
'doc' => ' |
List all dependencies the package has.' |
'doc' => '<package-file> or <package.xml> or <install-package-name> |
List all dependencies the package has. |
Can take a tgz / tar file, package.xml or a package name of an installed package.' |
), |
'sign' => array( |
'summary' => 'Sign a package distribution file', |
'function' => 'doSign', |
'shortcut' => 'si', |
'options' => array(), |
'options' => array( |
'verbose' => array( |
'shortopt' => 'v', |
'doc' => 'Display GnuPG output', |
), |
), |
'doc' => '<package-file> |
Signs a package distribution (.tar or .tgz) file with GnuPG.', |
), |
247,23 → 277,16 |
var $output; |
// }}} |
// {{{ constructor |
/** |
* PEAR_Command_Package constructor. |
* |
* @access public |
*/ |
function PEAR_Command_Package(&$ui, &$config) |
function __construct(&$ui, &$config) |
{ |
parent::PEAR_Command_Common($ui, $config); |
parent::__construct($ui, $config); |
} |
// }}} |
// {{{ _displayValidationResults() |
function _displayValidationResults($err, $warn, $strict = false) |
{ |
foreach ($err as $e) { |
274,7 → 297,7 |
} |
$this->output .= sprintf('Validation: %d error(s), %d warning(s)'."\n", |
sizeof($err), sizeof($warn)); |
if ($strict && sizeof($err) > 0) { |
if ($strict && count($err) > 0) { |
$this->output .= "Fix these errors and try again."; |
return false; |
} |
281,31 → 304,29 |
return true; |
} |
// }}} |
function &getPackager() |
{ |
if (!class_exists('PEAR_Packager')) { |
require_once 'PEAR/Packager.php'; |
} |
$a = &new PEAR_Packager; |
$a = new PEAR_Packager; |
return $a; |
} |
function &getPackageFile($config, $debug = false, $tmpdir = null) |
function &getPackageFile($config, $debug = false) |
{ |
if (!class_exists('PEAR_Common')) { |
require_once 'PEAR/Common.php'; |
} |
if (!class_exists('PEAR/PackageFile.php')) { |
if (!class_exists('PEAR_PackageFile')) { |
require_once 'PEAR/PackageFile.php'; |
} |
$a = &new PEAR_PackageFile($config, $debug, $tmpdir); |
$a = new PEAR_PackageFile($config, $debug); |
$common = new PEAR_Common; |
$common->ui = $this->ui; |
$a->setLogger($common); |
return $a; |
} |
// {{{ doPackage() |
function doPackage($command, $options, $params) |
{ |
312,36 → 333,36 |
$this->output = ''; |
$pkginfofile = isset($params[0]) ? $params[0] : 'package.xml'; |
$pkg2 = isset($params[1]) ? $params[1] : null; |
if (!$pkg2 && !isset($params[0])) { |
if (file_exists('package2.xml')) { |
$pkg2 = 'package2.xml'; |
} |
if (!$pkg2 && !isset($params[0]) && file_exists('package2.xml')) { |
$pkg2 = 'package2.xml'; |
} |
$packager = &$this->getPackager(); |
$compress = empty($options['nocompress']) ? true : false; |
$result = $packager->package($pkginfofile, $compress, $pkg2); |
$result = $packager->package($pkginfofile, $compress, $pkg2); |
if (PEAR::isError($result)) { |
return $this->raiseError($result); |
} |
// Don't want output, only the package file name just created |
if (isset($options['showname'])) { |
$this->output = $result; |
} |
if ($this->output) { |
$this->ui->outputData($this->output, $command); |
} |
return true; |
} |
// }}} |
// {{{ doPackageValidate() |
function doPackageValidate($command, $options, $params) |
{ |
$this->output = ''; |
if (sizeof($params) < 1) { |
$params[0] = "package.xml"; |
if (count($params) < 1) { |
$params[0] = 'package.xml'; |
} |
$obj = &$this->getPackageFile($this->config, $this->_debug); |
$obj->rawReturn(); |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
350,16 → 371,18 |
$info = $obj->fromPackageFile($params[0], PEAR_VALIDATE_NORMAL); |
} else { |
$archive = $info->getArchiveFile(); |
$tar = &new Archive_Tar($archive); |
$tar = new Archive_Tar($archive); |
$tar->extract(dirname($info->getPackageFile())); |
$info->setPackageFile(dirname($info->getPackageFile()) . DIRECTORY_SEPARATOR . |
$info->getPackage() . '-' . $info->getVersion() . DIRECTORY_SEPARATOR . |
basename($info->getPackageFile())); |
} |
PEAR::staticPopErrorHandling(); |
if (PEAR::isError($info)) { |
return $this->raiseError($info); |
} |
$valid = false; |
if ($info->getPackagexmlVersion() == '2.0') { |
if ($valid = $info->validate(PEAR_VALIDATE_NORMAL)) { |
369,10 → 392,10 |
} else { |
$valid = $info->validate(PEAR_VALIDATE_PACKAGING); |
} |
$err = array(); |
$warn = array(); |
if (!$valid) { |
foreach ($info->getValidationWarnings() as $error) { |
$err = $warn = array(); |
if ($errors = $info->getValidationWarnings()) { |
foreach ($errors as $error) { |
if ($error['level'] == 'warning') { |
$warn[] = $error['message']; |
} else { |
380,27 → 403,243 |
} |
} |
} |
$this->_displayValidationResults($err, $warn); |
$this->ui->outputData($this->output, $command); |
return true; |
} |
// }}} |
// {{{ doCvsTag() |
function doSvnTag($command, $options, $params) |
{ |
$this->output = ''; |
$_cmd = $command; |
if (count($params) < 1) { |
$help = $this->getHelp($command); |
return $this->raiseError("$command: missing parameter: $help[0]"); |
} |
$packageFile = realpath($params[0]); |
$dir = dirname($packageFile); |
$dir = substr($dir, strrpos($dir, DIRECTORY_SEPARATOR) + 1); |
$obj = &$this->getPackageFile($this->config, $this->_debug); |
$info = $obj->fromAnyFile($packageFile, PEAR_VALIDATE_NORMAL); |
if (PEAR::isError($info)) { |
return $this->raiseError($info); |
} |
$err = $warn = array(); |
if (!$info->validate()) { |
foreach ($info->getValidationWarnings() as $error) { |
if ($error['level'] == 'warning') { |
$warn[] = $error['message']; |
} else { |
$err[] = $error['message']; |
} |
} |
} |
if (!$this->_displayValidationResults($err, $warn, true)) { |
$this->ui->outputData($this->output, $command); |
return $this->raiseError('SVN tag failed'); |
} |
$version = $info->getVersion(); |
$package = $info->getName(); |
$svntag = "$package-$version"; |
if (isset($options['delete'])) { |
return $this->_svnRemoveTag($version, $package, $svntag, $packageFile, $options); |
} |
$path = $this->_svnFindPath($packageFile); |
// Check if there are any modified files |
$fp = popen('svn st --xml ' . dirname($packageFile), "r"); |
$out = ''; |
while ($line = fgets($fp, 1024)) { |
$out .= rtrim($line)."\n"; |
} |
pclose($fp); |
if (!isset($options['quiet']) && strpos($out, 'item="modified"')) { |
$params = array(array( |
'name' => 'modified', |
'type' => 'yesno', |
'default' => 'no', |
'prompt' => 'You have files in your SVN checkout (' . $path['from'] . ') that have been modified but not committed, do you still want to tag ' . $version . '?', |
)); |
$answers = $this->ui->confirmDialog($params); |
if (!in_array($answers['modified'], array('y', 'yes', 'on', '1'))) { |
return true; |
} |
} |
if (isset($options['slide'])) { |
$this->_svnRemoveTag($version, $package, $svntag, $packageFile, $options); |
} |
// Check if tag already exists |
$releaseTag = $path['local']['base'] . 'tags' . DIRECTORY_SEPARATOR . $svntag; |
$existsCommand = 'svn ls ' . $path['base'] . 'tags/'; |
$fp = popen($existsCommand, "r"); |
$out = ''; |
while ($line = fgets($fp, 1024)) { |
$out .= rtrim($line)."\n"; |
} |
pclose($fp); |
if (in_array($svntag . DIRECTORY_SEPARATOR, explode("\n", $out))) { |
$this->ui->outputData($this->output, $command); |
return $this->raiseError('SVN tag ' . $svntag . ' for ' . $package . ' already exists.'); |
} elseif (file_exists($path['local']['base'] . 'tags') === false) { |
return $this->raiseError('Can not locate the tags directory at ' . $path['local']['base'] . 'tags'); |
} elseif (is_writeable($path['local']['base'] . 'tags') === false) { |
return $this->raiseError('Can not write to the tag directory at ' . $path['local']['base'] . 'tags'); |
} else { |
$makeCommand = 'svn mkdir ' . $releaseTag; |
$this->output .= "+ $makeCommand\n"; |
if (empty($options['dry-run'])) { |
// We need to create the tag dir. |
$fp = popen($makeCommand, "r"); |
$out = ''; |
while ($line = fgets($fp, 1024)) { |
$out .= rtrim($line)."\n"; |
} |
pclose($fp); |
$this->output .= "$out\n"; |
} |
} |
$command = 'svn'; |
if (isset($options['quiet'])) { |
$command .= ' -q'; |
} |
$command .= ' copy --parents '; |
$dir = dirname($packageFile); |
$dir = substr($dir, strrpos($dir, DIRECTORY_SEPARATOR) + 1); |
$files = array_keys($info->getFilelist()); |
if (!in_array(basename($packageFile), $files)) { |
$files[] = basename($packageFile); |
} |
array_shift($params); |
if (count($params)) { |
// add in additional files to be tagged (package files and such) |
$files = array_merge($files, $params); |
} |
$commands = array(); |
foreach ($files as $file) { |
if (!file_exists($file)) { |
$file = $dir . DIRECTORY_SEPARATOR . $file; |
} |
$commands[] = $command . ' ' . escapeshellarg($file) . ' ' . |
escapeshellarg($releaseTag . DIRECTORY_SEPARATOR . $file); |
} |
$this->output .= implode("\n", $commands) . "\n"; |
if (empty($options['dry-run'])) { |
foreach ($commands as $command) { |
$fp = popen($command, "r"); |
while ($line = fgets($fp, 1024)) { |
$this->output .= rtrim($line)."\n"; |
} |
pclose($fp); |
} |
} |
$command = 'svn ci -m "Tagging the ' . $version . ' release" ' . $releaseTag . "\n"; |
$this->output .= "+ $command\n"; |
if (empty($options['dry-run'])) { |
$fp = popen($command, "r"); |
while ($line = fgets($fp, 1024)) { |
$this->output .= rtrim($line)."\n"; |
} |
pclose($fp); |
} |
$this->ui->outputData($this->output, $_cmd); |
return true; |
} |
function _svnFindPath($file) |
{ |
$xml = ''; |
$command = "svn info --xml $file"; |
$fp = popen($command, "r"); |
while ($line = fgets($fp, 1024)) { |
$xml .= rtrim($line)."\n"; |
} |
pclose($fp); |
$url_tag = strpos($xml, '<url>'); |
$url = substr($xml, $url_tag + 5, strpos($xml, '</url>', $url_tag + 5) - ($url_tag + 5)); |
$path = array(); |
$path['from'] = substr($url, 0, strrpos($url, '/')); |
$path['base'] = substr($path['from'], 0, strrpos($path['from'], '/') + 1); |
// Figure out the local paths - see http://pear.php.net/bugs/17463 |
$pos = strpos($file, DIRECTORY_SEPARATOR . 'trunk' . DIRECTORY_SEPARATOR); |
if ($pos === false) { |
$pos = strpos($file, DIRECTORY_SEPARATOR . 'branches' . DIRECTORY_SEPARATOR); |
} |
$path['local']['base'] = substr($file, 0, $pos + 1); |
return $path; |
} |
function _svnRemoveTag($version, $package, $tag, $packageFile, $options) |
{ |
$command = 'svn'; |
if (isset($options['quiet'])) { |
$command .= ' -q'; |
} |
$command .= ' remove'; |
$command .= ' -m "Removing tag for the ' . $version . ' release."'; |
$path = $this->_svnFindPath($packageFile); |
$command .= ' ' . $path['base'] . 'tags/' . $tag; |
if ($this->config->get('verbose') > 1) { |
$this->output .= "+ $command\n"; |
} |
$this->output .= "+ $command\n"; |
if (empty($options['dry-run'])) { |
$fp = popen($command, "r"); |
while ($line = fgets($fp, 1024)) { |
$this->output .= rtrim($line)."\n"; |
} |
pclose($fp); |
} |
$this->ui->outputData($this->output, $command); |
return true; |
} |
function doCvsTag($command, $options, $params) |
{ |
$this->output = ''; |
$_cmd = $command; |
if (sizeof($params) < 1) { |
if (count($params) < 1) { |
$help = $this->getHelp($command); |
return $this->raiseError("$command: missing parameter: $help[0]"); |
} |
$obj = &$this->getPackageFile($this->config, $this->_debug); |
$info = $obj->fromAnyFile($params[0], PEAR_VALIDATE_NORMAL); |
$packageFile = realpath($params[0]); |
$obj = &$this->getPackageFile($this->config, $this->_debug); |
$info = $obj->fromAnyFile($packageFile, PEAR_VALIDATE_NORMAL); |
if (PEAR::isError($info)) { |
return $this->raiseError($info); |
} |
$err = $warn = array(); |
if (!$info->validate()) { |
foreach ($info->getValidationWarnings() as $error) { |
411,28 → 650,34 |
} |
} |
} |
if (!$this->_displayValidationResults($err, $warn, true)) { |
$this->ui->outputData($this->output, $command); |
return $this->raiseError('CVS tag failed'); |
} |
$version = $info->getVersion(); |
$version = $info->getVersion(); |
$cvsversion = preg_replace('/[^a-z0-9]/i', '_', $version); |
$cvstag = "RELEASE_$cvsversion"; |
$files = array_keys($info->getFilelist()); |
$command = "cvs"; |
$cvstag = "RELEASE_$cvsversion"; |
$files = array_keys($info->getFilelist()); |
$command = 'cvs'; |
if (isset($options['quiet'])) { |
$command .= ' -q'; |
} |
if (isset($options['reallyquiet'])) { |
$command .= ' -Q'; |
} |
$command .= ' tag'; |
if (isset($options['slide'])) { |
$command .= ' -F'; |
} |
if (isset($options['delete'])) { |
$command .= ' -d'; |
} |
$command .= ' ' . $cvstag . ' ' . escapeshellarg($params[0]); |
array_shift($params); |
if (count($params)) { |
439,12 → 684,20 |
// add in additional files to be tagged |
$files = array_merge($files, $params); |
} |
$dir = dirname($packageFile); |
$dir = substr($dir, strrpos($dir, '/') + 1); |
foreach ($files as $file) { |
if (!file_exists($file)) { |
$file = $dir . DIRECTORY_SEPARATOR . $file; |
} |
$command .= ' ' . escapeshellarg($file); |
} |
if ($this->config->get('verbose') > 1) { |
$this->output .= "+ $command\n"; |
} |
$this->output .= "+ $command\n"; |
if (empty($options['dry-run'])) { |
$fp = popen($command, "r"); |
453,13 → 706,11 |
} |
pclose($fp); |
} |
$this->ui->outputData($this->output, $_cmd); |
return true; |
} |
// }}} |
// {{{ doCvsDiff() |
function doCvsDiff($command, $options, $params) |
{ |
$this->output = ''; |
467,11 → 718,14 |
$help = $this->getHelp($command); |
return $this->raiseError("$command: missing parameter: $help[0]"); |
} |
$obj = &$this->getPackageFile($this->config, $this->_debug); |
$info = $obj->fromAnyFile($params[0], PEAR_VALIDATE_NORMAL); |
$file = realpath($params[0]); |
$obj = &$this->getPackageFile($this->config, $this->_debug); |
$info = $obj->fromAnyFile($file, PEAR_VALIDATE_NORMAL); |
if (PEAR::isError($info)) { |
return $this->raiseError($info); |
} |
$err = $warn = array(); |
if (!$info->validate()) { |
foreach ($info->getValidationWarnings() as $error) { |
482,10 → 736,12 |
} |
} |
} |
if (!$this->_displayValidationResults($err, $warn, true)) { |
$this->ui->outputData($this->output, $command); |
return $this->raiseError('CVS diff failed'); |
} |
$info1 = $info->getFilelist(); |
$files = $info1; |
$cmd = "cvs"; |
493,10 → 749,12 |
$cmd .= ' -q'; |
unset($options['quiet']); |
} |
if (isset($options['reallyquiet'])) { |
$cmd .= ' -Q'; |
unset($options['reallyquiet']); |
} |
if (isset($options['release'])) { |
$cvsversion = preg_replace('/[^a-z0-9]/i', '_', $options['release']); |
$cvstag = "RELEASE_$cvsversion"; |
503,11 → 761,13 |
$options['revision'] = $cvstag; |
unset($options['release']); |
} |
$execute = true; |
if (isset($options['dry-run'])) { |
$execute = false; |
unset($options['dry-run']); |
} |
$cmd .= ' diff'; |
// the rest of the options are passed right on to "cvs diff" |
foreach ($options as $option => $optarg) { |
521,12 → 781,15 |
$cmd .= ($short ? '' : '=') . escapeshellarg($optarg); |
} |
} |
foreach ($files as $file) { |
$cmd .= ' ' . escapeshellarg($file['name']); |
} |
if ($this->config->get('verbose') > 1) { |
$this->output .= "+ $cmd\n"; |
} |
if ($execute) { |
$fp = popen($cmd, "r"); |
while ($line = fgets($fp, 1024)) { |
534,24 → 797,30 |
} |
pclose($fp); |
} |
$this->ui->outputData($this->output, $command); |
return true; |
} |
// }}} |
// {{{ doPackageDependencies() |
function doPackageDependencies($command, $options, $params) |
{ |
// $params[0] -> the PEAR package to list its information |
if (sizeof($params) != 1) { |
if (count($params) !== 1) { |
return $this->raiseError("bad parameter(s), try \"help $command\""); |
} |
$obj = &$this->getPackageFile($this->config, $this->_debug); |
$info = $obj->fromAnyFile($params[0], PEAR_VALIDATE_NORMAL); |
if (is_file($params[0]) || strpos($params[0], '.xml') > 0) { |
$info = $obj->fromAnyFile($params[0], PEAR_VALIDATE_NORMAL); |
} else { |
$reg = $this->config->getRegistry(); |
$info = $obj->fromArray($reg->packageInfo($params[0])); |
} |
if (PEAR::isError($info)) { |
return $this->raiseError($info); |
} |
$deps = $info->getDeps(); |
if (is_array($deps)) { |
if ($info->getPackagexmlVersion() == '1.0') { |
571,6 → 840,7 |
} else { |
$req = 'Yes'; |
} |
if (isset($this->_deps_rel_trans[$d['rel']])) { |
$rel = $this->_deps_rel_trans[$d['rel']]; |
} else { |
610,25 → 880,30 |
); |
foreach ($deps as $type => $subd) { |
$req = ($type == 'required') ? 'Yes' : 'No'; |
if ($type == 'group') { |
if ($type == 'group' && isset($subd['attribs']['name'])) { |
$group = $subd['attribs']['name']; |
} else { |
$group = ''; |
} |
if (!isset($subd[0])) { |
$subd = array($subd); |
} |
foreach ($subd as $groupa) { |
foreach ($groupa as $deptype => $depinfo) { |
if ($deptype == 'attribs') { |
continue; |
} |
if ($deptype == 'pearinstaller') { |
$deptype = 'pear Installer'; |
} |
if (!isset($depinfo[0])) { |
$depinfo = array($depinfo); |
} |
foreach ($depinfo as $inf) { |
$name = ''; |
if (isset($inf['channel'])) { |
637,6 → 912,7 |
$alias = '(channel?) ' .$inf['channel']; |
} |
$name = $alias . '/'; |
} |
if (isset($inf['name'])) { |
$name .= $inf['name']; |
645,14 → 921,17 |
} else { |
$name .= ''; |
} |
if (isset($inf['uri'])) { |
$name .= ' [' . $inf['uri'] . ']'; |
} |
if (isset($inf['conflicts'])) { |
$ver = 'conflicts'; |
} else { |
$ver = $d->_getExtraString($inf); |
} |
$data['data'][] = array($req, ucfirst($deptype), $name, |
$ver, $group); |
} |
670,60 → 949,79 |
$this->ui->outputData("This package does not have any dependencies.", $command); |
} |
// }}} |
// {{{ doSign() |
function doSign($command, $options, $params) |
{ |
require_once 'System.php'; |
require_once 'Archive/Tar.php'; |
// should move most of this code into PEAR_Packager |
// so it'll be easy to implement "pear package --sign" |
if (sizeof($params) != 1) { |
if (count($params) !== 1) { |
return $this->raiseError("bad parameter(s), try \"help $command\""); |
} |
require_once 'System.php'; |
require_once 'Archive/Tar.php'; |
if (!file_exists($params[0])) { |
return $this->raiseError("file does not exist: $params[0]"); |
} |
$obj = $this->getPackageFile($this->config, $this->_debug); |
$info = $obj->fromTgzFile($params[0], PEAR_VALIDATE_NORMAL); |
if (PEAR::isError($info)) { |
return $this->raiseError($info); |
} |
$tar = new Archive_Tar($params[0]); |
$tmpdir = System::mktemp('-d pearsign'); |
if (!$tar->extractList('package2.xml package.sig', $tmpdir)) { |
if (!$tar->extractList('package.xml package.sig', $tmpdir)) { |
return $this->raiseError("failed to extract tar file"); |
} |
$tmpdir = $this->config->get('temp_dir'); |
$tmpdir = System::mktemp(' -t "' . $tmpdir . '" -d pearsign'); |
if (!$tar->extractList('package2.xml package.xml package.sig', $tmpdir)) { |
return $this->raiseError("failed to extract tar file"); |
} |
if (file_exists("$tmpdir/package.sig")) { |
return $this->raiseError("package already signed"); |
} |
$packagexml = 'package.xml'; |
if (file_exists("$tmpdir/package2.xml")) { |
$packagexml = 'package2.xml'; |
} |
if (file_exists("$tmpdir/package.sig")) { |
unlink("$tmpdir/package.sig"); |
} |
if (!file_exists("$tmpdir/$packagexml")) { |
return $this->raiseError("Extracted file $tmpdir/$packagexml not found."); |
} |
$input = $this->ui->userDialog($command, |
array('GnuPG Passphrase'), |
array('password')); |
$gpg = popen("gpg --batch --passphrase-fd 0 --armor --detach-sign --output $tmpdir/package.sig $tmpdir/$packagexml 2>/dev/null", "w"); |
if (!isset($input[0])) { |
//use empty passphrase |
$input[0] = ''; |
} |
$devnull = (isset($options['verbose'])) ? '' : ' 2>/dev/null'; |
$gpg = popen("gpg --batch --passphrase-fd 0 --armor --detach-sign --output $tmpdir/package.sig $tmpdir/$packagexml" . $devnull, "w"); |
if (!$gpg) { |
return $this->raiseError("gpg command failed"); |
} |
fwrite($gpg, "$input[0]\n"); |
if (pclose($gpg) || !file_exists("$tmpdir/package.sig")) { |
return $this->raiseError("gpg sign failed"); |
} |
$tar->addModify("$tmpdir/package.sig", '', $tmpdir); |
if (!$tar->addModify("$tmpdir/package.sig", '', $tmpdir)) { |
return $this->raiseError('failed adding signature to file'); |
} |
$this->ui->outputData("Package signed.", $command); |
return true; |
} |
// }}} |
/** |
* For unit testing purposes |
*/ |
732,10 → 1030,10 |
if (!class_exists('PEAR_Installer')) { |
require_once 'PEAR/Installer.php'; |
} |
$a = &new PEAR_Installer($ui); |
$a = new PEAR_Installer($ui); |
return $a; |
} |
/** |
* For unit testing purposes |
*/ |
747,17 → 1045,16 |
include_once 'PEAR/Command/Packaging.php'; |
} |
} |
if (class_exists('PEAR_Command_Packaging')) { |
$a = &new PEAR_Command_Packaging($ui, $config); |
$a = new PEAR_Command_Packaging($ui, $config); |
} else { |
$a = null; |
} |
return $a; |
} |
// {{{ doMakeRPM() |
function doMakeRPM($command, $options, $params) |
{ |
770,17 → 1067,17 |
$this->ui->outputData('PEAR_Command_Packaging is installed; using '. |
'newer "make-rpm-spec" command instead'); |
return $packaging_cmd->run('make-rpm-spec', $options, $params); |
} else { |
$this->ui->outputData('WARNING: "pear makerpm" is no longer available; an '. |
'improved version is available via "pear make-rpm-spec", which '. |
'is available by installing PEAR_Command_Packaging'); |
} |
$this->ui->outputData('WARNING: "pear makerpm" is no longer available; an '. |
'improved version is available via "pear make-rpm-spec", which '. |
'is available by installing PEAR_Command_Packaging'); |
return true; |
} |
function doConvert($command, $options, $params) |
{ |
$packagexml = isset($params[0]) ? $params[0] : 'package.xml'; |
$packagexml = isset($params[0]) ? $params[0] : 'package.xml'; |
$newpackagexml = isset($params[1]) ? $params[1] : dirname($packagexml) . |
DIRECTORY_SEPARATOR . 'package2.xml'; |
$pkg = &$this->getPackageFile($this->config, $this->_debug); |
787,32 → 1084,7 |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$pf = $pkg->fromPackageFile($packagexml, PEAR_VALIDATE_NORMAL); |
PEAR::staticPopErrorHandling(); |
if (!PEAR::isError($pf)) { |
if (is_a($pf, 'PEAR_PackageFile_v2')) { |
$this->ui->outputData($packagexml . ' is already a package.xml version 2.0'); |
return true; |
} |
$gen = &$pf->getDefaultGenerator(); |
$newpf = &$gen->toV2(); |
$newpf->setPackagefile($newpackagexml); |
$gen = &$newpf->getDefaultGenerator(); |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$state = (isset($options['flat']) ? PEAR_VALIDATE_PACKAGING : PEAR_VALIDATE_NORMAL); |
$saved = $gen->toPackageFile(dirname($newpackagexml), $state, |
basename($newpackagexml)); |
PEAR::staticPopErrorHandling(); |
if (PEAR::isError($saved)) { |
if (is_array($saved->getUserInfo())) { |
foreach ($saved->getUserInfo() as $warning) { |
$this->ui->outputData($warning['message']); |
} |
} |
$this->ui->outputData($saved->getMessage()); |
return true; |
} |
$this->ui->outputData('Wrote new version 2.0 package.xml to "' . $saved . '"'); |
return true; |
} else { |
if (PEAR::isError($pf)) { |
if (is_array($pf->getUserInfo())) { |
foreach ($pf->getUserInfo() as $warning) { |
$this->ui->outputData($warning['message']); |
820,9 → 1092,32 |
} |
return $this->raiseError($pf); |
} |
if (is_a($pf, 'PEAR_PackageFile_v2')) { |
$this->ui->outputData($packagexml . ' is already a package.xml version 2.0'); |
return true; |
} |
$gen = &$pf->getDefaultGenerator(); |
$newpf = &$gen->toV2(); |
$newpf->setPackagefile($newpackagexml); |
$gen = &$newpf->getDefaultGenerator(); |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$state = (isset($options['flat']) ? PEAR_VALIDATE_PACKAGING : PEAR_VALIDATE_NORMAL); |
$saved = $gen->toPackageFile(dirname($newpackagexml), $state, basename($newpackagexml)); |
PEAR::staticPopErrorHandling(); |
if (PEAR::isError($saved)) { |
if (is_array($saved->getUserInfo())) { |
foreach ($saved->getUserInfo() as $warning) { |
$this->ui->outputData($warning['message']); |
} |
} |
$this->ui->outputData($saved->getMessage()); |
return true; |
} |
$this->ui->outputData('Wrote new version 2.0 package.xml to "' . $saved . '"'); |
return true; |
} |
// }}} |
} |
?> |
/trunk/bibliotheque/pear/PEAR/Command/Channels.php |
---|
6,19 → 6,12 |
* |
* 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 Stig Bakken <ssb@php.net> |
* @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: Channels.php,v 1.46 2006/07/17 18:19:25 pajoye Exp $ |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.4.0a1 |
*/ |
28,6 → 21,8 |
*/ |
require_once 'PEAR/Command/Common.php'; |
define('PEAR_COMMAND_CHANNELS_CHANNEL_EXISTS', -500); |
/** |
* PEAR commands for managing channels. |
* |
34,16 → 29,14 |
* @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: 1.5.1 |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 1.4.0a1 |
*/ |
class PEAR_Command_Channels extends PEAR_Command_Common |
{ |
// {{{ properties |
var $commands = array( |
'list-channels' => array( |
'summary' => 'List Available Channels', |
133,28 → 126,51 |
'shortcut' => 'di', |
'options' => array(), |
'doc' => '[<channel.xml>|<channel name>] |
Initialize a Channel from its server and creates the local channel.xml. |
Initialize a channel from its server and create a local channel.xml. |
If <channel name> is in the format "<username>:<password>@<channel>" then |
<username> and <password> will be set as the login username/password for |
<channel>. Use caution when passing the username/password in this way, as |
it may allow other users on your computer to briefly view your username/ |
password via the system\'s process list. |
' |
), |
'channel-login' => array( |
'summary' => 'Connects and authenticates to remote channel server', |
'shortcut' => 'cli', |
'function' => 'doLogin', |
'options' => array(), |
'doc' => '<channel name> |
Log in to a remote channel server. If <channel name> is not supplied, |
the default channel is used. To use remote functions in the installer |
that require any kind of privileges, you need to log in first. The |
username and password you enter here will be stored in your per-user |
PEAR configuration (~/.pearrc on Unix-like systems). After logging |
in, your username and password will be sent along in subsequent |
operations on the remote server.', |
), |
'channel-logout' => array( |
'summary' => 'Logs out from the remote channel server', |
'shortcut' => 'clo', |
'function' => 'doLogout', |
'options' => array(), |
'doc' => '<channel name> |
Logs out from a remote channel server. If <channel name> is not supplied, |
the default channel is used. This command does not actually connect to the |
remote server, it only deletes the stored username and password from your user |
configuration.', |
), |
); |
// }}} |
// {{{ constructor |
/** |
* PEAR_Command_Registry constructor. |
* |
* @access public |
*/ |
function PEAR_Command_Channels(&$ui, &$config) |
function __construct(&$ui, &$config) |
{ |
parent::PEAR_Command_Common($ui, $config); |
parent::__construct($ui, $config); |
} |
// }}} |
// {{{ doList() |
function _sortChannels($a, $b) |
{ |
return strnatcasecmp($a->getName(), $b->getName()); |
169,160 → 185,51 |
$data = array( |
'caption' => 'Registered Channels:', |
'border' => true, |
'headline' => array('Channel', 'Summary') |
'headline' => array('Channel', 'Alias', 'Summary') |
); |
foreach ($registered as $channel) { |
$data['data'][] = array($channel->getName(), |
$channel->getSummary()); |
$channel->getAlias(), |
$channel->getSummary()); |
} |
if (count($registered)==0) { |
if (count($registered) === 0) { |
$data = '(no registered channels)'; |
} |
$this->ui->outputData($data, $command); |
return true; |
} |
function doUpdateAll($command, $options, $params) |
{ |
$reg = &$this->config->getRegistry(); |
$savechannel = $this->config->get('default_channel'); |
if (isset($options['channel'])) { |
if (!$reg->channelExists($options['channel'])) { |
return $this->raiseError('Unknown channel "' . $options['channel'] . '"'); |
} |
$this->config->set('default_channel', $options['channel']); |
} else { |
$this->config->set('default_channel', 'pear.php.net'); |
} |
$remote = &$this->config->getRemote(); |
$channels = $remote->call('channel.listAll'); |
if (PEAR::isError($channels)) { |
$this->config->set('default_channel', $savechannel); |
return $channels; |
} |
if (!is_array($channels) || isset($channels['faultCode'])) { |
$this->config->set('default_channel', $savechannel); |
return $this->raiseError("Incorrect channel listing returned from channel '$chan'"); |
} |
if (!count($channels)) { |
$data = 'no updates available'; |
} |
$dl = &$this->getDownloader(); |
if (!class_exists('System')) { |
require_once 'System.php'; |
} |
$tmpdir = System::mktemp(array('-d')); |
$channels = $reg->getChannels(); |
$success = true; |
foreach ($channels as $channel) { |
$channel = $channel[0]; |
$save = $channel; |
if ($reg->channelExists($channel, true)) { |
$this->ui->outputData("Updating channel \"$channel\"", $command); |
$test = $reg->getChannel($channel, true); |
if (PEAR::isError($test)) { |
$this->ui->outputData("Channel '$channel' is corrupt in registry!", $command); |
$lastmodified = false; |
if ($channel->getName() != '__uri') { |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$err = $this->doUpdate('channel-update', |
$options, |
array($channel->getName())); |
if (PEAR::isError($err)) { |
$this->ui->outputData($err->getMessage(), $command); |
$success = false; |
} else { |
$lastmodified = $test->lastModified(); |
$success &= $err; |
} |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$contents = $dl->downloadHttp('http://' . $test->getName() . '/channel.xml', |
$this->ui, $tmpdir, null, $lastmodified); |
PEAR::staticPopErrorHandling(); |
if (PEAR::isError($contents)) { |
$this->ui->outputData('ERROR: Cannot retrieve channel.xml for channel "' . |
$test->getName() . '"', $command); |
continue; |
} |
if (!$contents) { |
$this->ui->outputData("Channel \"$channel\" is up-to-date", $command); |
continue; |
} |
list($contents, $lastmodified) = $contents; |
$info = implode('', file($contents)); |
if (!$info) { |
$this->ui->outputData("Channel \"$channel\" is up-to-date", $command); |
continue; |
} |
if (!class_exists('PEAR_ChannelFile')) { |
require_once 'PEAR/ChannelFile.php'; |
} |
$channelinfo = new PEAR_ChannelFile; |
$channelinfo->fromXmlString($info); |
if ($channelinfo->getErrors()) { |
$this->ui->outputData("Downloaded channel data from channel \"$channel\" " . |
'is corrupt, skipping', $command); |
continue; |
} |
$channel = $channelinfo; |
if ($channel->getName() != $save) { |
$this->ui->outputData('ERROR: Security risk - downloaded channel ' . |
'definition file for channel "' |
. $channel->getName() . ' from channel "' . $save . |
'". To use anyway, use channel-update', $command); |
continue; |
} |
$reg->updateChannel($channel, $lastmodified); |
} else { |
if ($reg->isAlias($channel)) { |
$temp = &$reg->getChannel($channel); |
if (PEAR::isError($temp)) { |
return $this->raiseError($temp); |
} |
$temp->setAlias($temp->getName(), true); // set the alias to the channel name |
if ($reg->channelExists($temp->getName())) { |
$this->ui->outputData('ERROR: existing channel "' . $temp->getName() . |
'" is aliased to "' . $channel . '" already and cannot be ' . |
're-aliased to "' . $temp->getName() . '" because a channel with ' . |
'that name or alias already exists! Please re-alias and try ' . |
'again.', $command); |
continue; |
} |
} |
$this->ui->outputData("Adding new channel \"$channel\"", $command); |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$contents = $dl->downloadHttp('http://' . $channel . '/channel.xml', |
$this->ui, $tmpdir, null, false); |
PEAR::staticPopErrorHandling(); |
if (PEAR::isError($contents)) { |
$this->ui->outputData('ERROR: Cannot retrieve channel.xml for channel "' . |
$channel . '"', $command); |
continue; |
} |
list($contents, $lastmodified) = $contents; |
$info = implode('', file($contents)); |
if (!class_exists('PEAR_ChannelFile')) { |
require_once 'PEAR/ChannelFile.php'; |
} |
$channelinfo = new PEAR_Channelfile; |
$channelinfo->fromXmlString($info); |
if ($channelinfo->getErrors()) { |
$this->ui->outputData("Downloaded channel data from channel \"$channel\"" . |
' is corrupt, skipping', $command); |
continue; |
} |
$channel = $channelinfo; |
if ($channel->getName() != $save) { |
$this->ui->outputData('ERROR: Security risk - downloaded channel ' . |
'definition file for channel "' |
. $channel->getName() . '" from channel "' . $save . |
'". To use anyway, use channel-update', $command); |
continue; |
} |
$reg->addChannel($channel, $lastmodified); |
} |
} |
$this->config->set('default_channel', $savechannel); |
$this->ui->outputData('update-channels complete', $command); |
return true; |
return $success; |
} |
function doInfo($command, $options, $params) |
{ |
if (sizeof($params) != 1) { |
if (count($params) !== 1) { |
return $this->raiseError("No channel specified"); |
} |
$reg = &$this->config->getRegistry(); |
$reg = &$this->config->getRegistry(); |
$channel = strtolower($params[0]); |
if ($reg->channelExists($channel)) { |
$chan = $reg->getChannel($channel); |
332,27 → 239,26 |
} else { |
if (strpos($channel, '://')) { |
$downloader = &$this->getDownloader(); |
if (!class_exists('System')) { |
require_once 'System.php'; |
} |
$tmpdir = System::mktemp(array('-d')); |
$tmpdir = $this->config->get('temp_dir'); |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$loc = $downloader->downloadHttp($channel, $this->ui, $tmpdir); |
PEAR::staticPopErrorHandling(); |
if (PEAR::isError($loc)) { |
return $this->raiseError('Cannot open "' . $channel . '"'); |
return $this->raiseError('Cannot open "' . $channel . |
'" (' . $loc->getMessage() . ')'); |
} else { |
$contents = implode('', file($loc)); |
} |
} else { |
if (file_exists($params[0])) { |
$fp = fopen($params[0], 'r'); |
if (!$fp) { |
return $this->raiseError('Cannot open "' . $params[0] . '"'); |
} |
} else { |
if (!file_exists($params[0])) { |
return $this->raiseError('Unknown channel "' . $channel . '"'); |
} |
$fp = fopen($params[0], 'r'); |
if (!$fp) { |
return $this->raiseError('Cannot open "' . $params[0] . '"'); |
} |
$contents = ''; |
while (!feof($fp)) { |
$contents .= fread($fp, 1024); |
359,9 → 265,11 |
} |
fclose($fp); |
} |
if (!class_exists('PEAR_ChannelFile')) { |
require_once 'PEAR/ChannelFile.php'; |
} |
$chan = new PEAR_ChannelFile; |
$chan->fromXmlString($contents); |
$chan->validate(); |
372,147 → 280,123 |
return $this->raiseError('Channel file "' . $params[0] . '" is not valid'); |
} |
} |
if ($chan) { |
$channel = $chan->getName(); |
$caption = 'Channel ' . $channel . ' Information:'; |
$data1 = array( |
'caption' => $caption, |
'border' => true); |
$data1['data']['server'] = array('Name and Server', $chan->getName()); |
if ($chan->getAlias() != $chan->getName()) { |
$data1['data']['alias'] = array('Alias', $chan->getAlias()); |
} |
$data1['data']['summary'] = array('Summary', $chan->getSummary()); |
$validate = $chan->getValidationPackage(); |
$data1['data']['vpackage'] = array('Validation Package Name', $validate['_content']); |
$data1['data']['vpackageversion'] = |
array('Validation Package Version', $validate['attribs']['version']); |
$d = array(); |
$d['main'] = $data1; |
$data['data'] = array(); |
$data['caption'] = 'Server Capabilities'; |
$data['headline'] = array('Type', 'Version/REST type', 'Function Name/REST base'); |
$capabilities = $chan->getFunctions('xmlrpc'); |
$soaps = $chan->getFunctions('soap'); |
if ($capabilities || $soaps || $chan->supportsREST()) { |
if ($capabilities) { |
if (!isset($capabilities[0])) { |
$capabilities = array($capabilities); |
} |
foreach ($capabilities as $protocol) { |
$data['data'][] = array('xmlrpc', $protocol['attribs']['version'], |
$protocol['_content']); |
} |
if (!$chan) { |
return $this->raiseError('Serious error: Channel "' . $params[0] . |
'" has a corrupted registry entry'); |
} |
$channel = $chan->getName(); |
$caption = 'Channel ' . $channel . ' Information:'; |
$data1 = array( |
'caption' => $caption, |
'border' => true); |
$data1['data']['server'] = array('Name and Server', $chan->getName()); |
if ($chan->getAlias() != $chan->getName()) { |
$data1['data']['alias'] = array('Alias', $chan->getAlias()); |
} |
$data1['data']['summary'] = array('Summary', $chan->getSummary()); |
$validate = $chan->getValidationPackage(); |
$data1['data']['vpackage'] = array('Validation Package Name', $validate['_content']); |
$data1['data']['vpackageversion'] = |
array('Validation Package Version', $validate['attribs']['version']); |
$d = array(); |
$d['main'] = $data1; |
$data['data'] = array(); |
$data['caption'] = 'Server Capabilities'; |
$data['headline'] = array('Type', 'Version/REST type', 'Function Name/REST base'); |
if ($chan->supportsREST()) { |
if ($chan->supportsREST()) { |
$funcs = $chan->getFunctions('rest'); |
if (!isset($funcs[0])) { |
$funcs = array($funcs); |
} |
if ($soaps) { |
if (!isset($soaps[0])) { |
$soaps = array($soaps); |
} |
foreach ($soaps as $protocol) { |
$data['data'][] = array('soap', $protocol['attribs']['version'], |
$protocol['_content']); |
} |
foreach ($funcs as $protocol) { |
$data['data'][] = array('rest', $protocol['attribs']['type'], |
$protocol['_content']); |
} |
if ($chan->supportsREST()) { |
$funcs = $chan->getFunctions('rest'); |
if (!isset($funcs[0])) { |
$funcs = array($funcs); |
} |
foreach ($funcs as $protocol) { |
$data['data'][] = array('rest', $protocol['attribs']['type'], |
$protocol['_content']); |
} |
} |
} else { |
$data['data'][] = array('No supported protocols'); |
} |
$d['protocols'] = $data; |
$data['data'] = array(); |
$mirrors = $chan->getMirrors(); |
if ($mirrors) { |
$data['caption'] = 'Channel ' . $channel . ' Mirrors:'; |
unset($data['headline']); |
foreach ($mirrors as $mirror) { |
$data['data'][] = array($mirror['attribs']['host']); |
$d['mirrors'] = $data; |
} |
foreach ($mirrors as $mirror) { |
$data['data'] = array(); |
$data['caption'] = 'Mirror ' . $mirror['attribs']['host'] . ' Capabilities'; |
$data['headline'] = array('Type', 'Version/REST type', 'Function Name/REST base'); |
$capabilities = $chan->getFunctions('xmlrpc', $mirror['attribs']['host']); |
$soaps = $chan->getFunctions('soap', $mirror['attribs']['host']); |
if ($capabilities || $soaps || $chan->supportsREST($mirror['attribs']['host'])) { |
if ($capabilities) { |
if (!isset($capabilities[0])) { |
$capabilities = array($capabilities); |
} |
foreach ($capabilities as $protocol) { |
$data['data'][] = array('xmlrpc', $protocol['attribs']['version'], |
$protocol['_content']); |
} |
} else { |
$data['data'][] = array('No supported protocols'); |
} |
$d['protocols'] = $data; |
$data['data'] = array(); |
$mirrors = $chan->getMirrors(); |
if ($mirrors) { |
$data['caption'] = 'Channel ' . $channel . ' Mirrors:'; |
unset($data['headline']); |
foreach ($mirrors as $mirror) { |
$data['data'][] = array($mirror['attribs']['host']); |
$d['mirrors'] = $data; |
} |
foreach ($mirrors as $i => $mirror) { |
$data['data'] = array(); |
$data['caption'] = 'Mirror ' . $mirror['attribs']['host'] . ' Capabilities'; |
$data['headline'] = array('Type', 'Version/REST type', 'Function Name/REST base'); |
if ($chan->supportsREST($mirror['attribs']['host'])) { |
if ($chan->supportsREST($mirror['attribs']['host'])) { |
$funcs = $chan->getFunctions('rest', $mirror['attribs']['host']); |
if (!isset($funcs[0])) { |
$funcs = array($funcs); |
} |
if ($soaps) { |
if (!isset($soaps[0])) { |
$soaps = array($soaps); |
} |
foreach ($soaps as $protocol) { |
$data['data'][] = array('soap', $protocol['attribs']['version'], |
$protocol['_content']); |
} |
foreach ($funcs as $protocol) { |
$data['data'][] = array('rest', $protocol['attribs']['type'], |
$protocol['_content']); |
} |
if ($chan->supportsREST($mirror['attribs']['host'])) { |
$funcs = $chan->getFunctions('rest', $mirror['attribs']['host']); |
if (!isset($funcs[0])) { |
$funcs = array($funcs); |
} |
foreach ($funcs as $protocol) { |
$data['data'][] = array('rest', $protocol['attribs']['type'], |
$protocol['_content']); |
} |
} |
} else { |
$data['data'][] = array('No supported protocols'); |
} |
$d['mirrorprotocols'] = $data; |
} else { |
$data['data'][] = array('No supported protocols'); |
} |
$d['mirrorprotocols' . $i] = $data; |
} |
$this->ui->outputData($d, 'channel-info'); |
} else { |
return $this->raiseError('Serious error: Channel "' . $params[0] . |
'" has a corrupted registry entry'); |
} |
$this->ui->outputData($d, 'channel-info'); |
} |
// }}} |
function doDelete($command, $options, $params) |
{ |
if (sizeof($params) != 1) { |
if (count($params) !== 1) { |
return $this->raiseError('channel-delete: no channel specified'); |
} |
$reg = &$this->config->getRegistry(); |
if (!$reg->channelExists($params[0])) { |
return $this->raiseError('channel-delete: channel "' . $params[0] . '" does not exist'); |
} |
$channel = $reg->channelName($params[0]); |
if ($channel == 'pear.php.net') { |
return $this->raiseError('Cannot delete the pear.php.net channel'); |
} |
if ($channel == 'pecl.php.net') { |
return $this->raiseError('Cannot delete the pecl.php.net channel'); |
} |
if ($channel == 'doc.php.net') { |
return $this->raiseError('Cannot delete the doc.php.net channel'); |
} |
if ($channel == '__uri') { |
return $this->raiseError('Cannot delete the __uri pseudo-channel'); |
} |
if (PEAR::isError($err = $reg->listPackages($channel))) { |
return $err; |
} |
if (count($err)) { |
return $this->raiseError('Channel "' . $channel . |
'" has installed packages, cannot delete'); |
} |
if (!$reg->deleteChannel($channel)) { |
return $this->raiseError('Channel "' . $channel . '" deletion failed'); |
} else { |
523,32 → 407,51 |
function doAdd($command, $options, $params) |
{ |
if (sizeof($params) != 1) { |
if (count($params) !== 1) { |
return $this->raiseError('channel-add: no channel file specified'); |
} |
if (strpos($params[0], '://')) { |
$downloader = &$this->getDownloader(); |
if (!class_exists('System')) { |
$tmpdir = $this->config->get('temp_dir'); |
if (!file_exists($tmpdir)) { |
require_once 'System.php'; |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$err = System::mkdir(array('-p', $tmpdir)); |
PEAR::staticPopErrorHandling(); |
if (PEAR::isError($err)) { |
return $this->raiseError('channel-add: temp_dir does not exist: "' . |
$tmpdir . |
'" - You can change this location with "pear config-set temp_dir"'); |
} |
} |
$tmpdir = System::mktemp(array('-d')); |
if (!is_writable($tmpdir)) { |
return $this->raiseError('channel-add: temp_dir is not writable: "' . |
$tmpdir . |
'" - You can change this location with "pear config-set temp_dir"'); |
} |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$loc = $downloader->downloadHttp($params[0], $this->ui, $tmpdir, null, false); |
PEAR::staticPopErrorHandling(); |
if (PEAR::isError($loc)) { |
return $this->raiseError('channel-add: Cannot open "' . $params[0] . '"'); |
} else { |
list($loc, $lastmodified) = $loc; |
$contents = implode('', file($loc)); |
return $this->raiseError('channel-add: Cannot open "' . $params[0] . |
'" (' . $loc->getMessage() . ')'); |
} |
list($loc, $lastmodified) = $loc; |
$contents = implode('', file($loc)); |
} else { |
$lastmodified = $fp = false; |
if (file_exists($params[0])) { |
$fp = fopen($params[0], 'r'); |
} |
if (!$fp) { |
return $this->raiseError('channel-add: cannot open "' . $params[0] . '"'); |
} |
$contents = ''; |
while (!feof($fp)) { |
$contents .= fread($fp, 1024); |
555,9 → 458,11 |
} |
fclose($fp); |
} |
if (!class_exists('PEAR_ChannelFile')) { |
require_once 'PEAR/ChannelFile.php'; |
} |
$channel = new PEAR_ChannelFile; |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$result = $channel->fromXmlString($contents); |
576,19 → 481,23 |
} |
} |
} |
$reg = &$this->config->getRegistry(); |
if ($reg->channelExists($channel->getName())) { |
return $this->raiseError('channel-add: Channel "' . $channel->getName() . |
'" exists, use channel-update to update entry'); |
'" exists, use channel-update to update entry', PEAR_COMMAND_CHANNELS_CHANNEL_EXISTS); |
} |
$ret = $reg->addChannel($channel, $lastmodified); |
if (PEAR::isError($ret)) { |
return $ret; |
} |
if (!$ret) { |
return $this->raiseError('channel-add: adding Channel "' . $channel->getName() . |
'" to registry failed'); |
} |
$this->config->setChannels($reg->listChannels()); |
$this->config->writeConfigFile(); |
$this->ui->outputData('Adding Channel "' . $channel->getName() . '" succeeded', $command); |
596,14 → 505,30 |
function doUpdate($command, $options, $params) |
{ |
if (!class_exists('System')) { |
if (count($params) !== 1) { |
return $this->raiseError("No channel file specified"); |
} |
$tmpdir = $this->config->get('temp_dir'); |
if (!file_exists($tmpdir)) { |
require_once 'System.php'; |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$err = System::mkdir(array('-p', $tmpdir)); |
PEAR::staticPopErrorHandling(); |
if (PEAR::isError($err)) { |
return $this->raiseError('channel-add: temp_dir does not exist: "' . |
$tmpdir . |
'" - You can change this location with "pear config-set temp_dir"'); |
} |
} |
$tmpdir = System::mktemp(array('-d')); |
if (!is_writable($tmpdir)) { |
return $this->raiseError('channel-add: temp_dir is not writable: "' . |
$tmpdir . |
'" - You can change this location with "pear config-set temp_dir"'); |
} |
$reg = &$this->config->getRegistry(); |
if (sizeof($params) != 1) { |
return $this->raiseError("No channel file specified"); |
} |
$lastmodified = false; |
if ((!file_exists($params[0]) || is_dir($params[0])) |
&& $reg->channelExists(strtolower($params[0]))) { |
611,7 → 536,8 |
if (PEAR::isError($c)) { |
return $this->raiseError($c); |
} |
$this->ui->outputData('Retrieving channel.xml from remote server'); |
$this->ui->outputData("Updating channel \"$params[0]\"", $command); |
$dl = &$this->getDownloader(array()); |
// if force is specified, use a timestamp of "1" to force retrieval |
$lastmodified = isset($options['force']) ? false : $c->lastModified(); |
620,32 → 546,44 |
$this->ui, $tmpdir, null, $lastmodified); |
PEAR::staticPopErrorHandling(); |
if (PEAR::isError($contents)) { |
return $this->raiseError('Cannot retrieve channel.xml for channel "' . |
$c->getName() . '"'); |
// Attempt to fall back to https |
$this->ui->outputData("Channel \"$params[0]\" is not responding over http://, failed with message: " . $contents->getMessage()); |
$this->ui->outputData("Trying channel \"$params[0]\" over https:// instead"); |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$contents = $dl->downloadHttp('https://' . $c->getName() . '/channel.xml', |
$this->ui, $tmpdir, null, $lastmodified); |
PEAR::staticPopErrorHandling(); |
if (PEAR::isError($contents)) { |
return $this->raiseError('Cannot retrieve channel.xml for channel "' . |
$c->getName() . '" (' . $contents->getMessage() . ')'); |
} |
} |
list($contents, $lastmodified) = $contents; |
if (!$contents) { |
$this->ui->outputData("Channel $params[0] channel.xml is up to date"); |
$this->ui->outputData("Channel \"$params[0]\" is up to date"); |
return; |
} |
$contents = implode('', file($contents)); |
if (!class_exists('PEAR_ChannelFile')) { |
require_once 'PEAR/ChannelFile.php'; |
} |
$channel = new PEAR_ChannelFile; |
$channel->fromXmlString($contents); |
if (!$channel->getErrors()) { |
// security check: is the downloaded file for the channel we got it from? |
if (strtolower($channel->getName()) != strtolower($c->getName())) { |
if (isset($options['force'])) { |
$this->ui->log(0, 'WARNING: downloaded channel definition file' . |
' for channel "' . $channel->getName() . '" from channel "' . |
strtolower($c->getName()) . '"'); |
} else { |
if (!isset($options['force'])) { |
return $this->raiseError('ERROR: downloaded channel definition file' . |
' for channel "' . $channel->getName() . '" from channel "' . |
strtolower($c->getName()) . '"'); |
} |
$this->ui->log(0, 'WARNING: downloaded channel definition file' . |
' for channel "' . $channel->getName() . '" from channel "' . |
strtolower($c->getName()) . '"'); |
} |
} |
} else { |
656,19 → 594,22 |
$this->ui, $tmpdir, null, $lastmodified); |
PEAR::staticPopErrorHandling(); |
if (PEAR::isError($loc)) { |
return $this->raiseError("Cannot open " . $params[0]); |
} else { |
list($loc, $lastmodified) = $loc; |
$contents = implode('', file($loc)); |
return $this->raiseError("Cannot open " . $params[0] . |
' (' . $loc->getMessage() . ')'); |
} |
list($loc, $lastmodified) = $loc; |
$contents = implode('', file($loc)); |
} else { |
$fp = false; |
if (file_exists($params[0])) { |
$fp = fopen($params[0], 'r'); |
} |
if (!$fp) { |
return $this->raiseError("Cannot open " . $params[0]); |
} |
$contents = ''; |
while (!feof($fp)) { |
$contents .= fread($fp, 1024); |
675,12 → 616,15 |
} |
fclose($fp); |
} |
if (!class_exists('PEAR_ChannelFile')) { |
require_once 'PEAR/ChannelFile.php'; |
} |
$channel = new PEAR_ChannelFile; |
$channel->fromXmlString($contents); |
} |
$exit = false; |
if (count($errors = $channel->getErrors(true))) { |
foreach ($errors as $error) { |
693,18 → 637,22 |
return $this->raiseError('Invalid channel.xml file'); |
} |
} |
if (!$reg->channelExists($channel->getName())) { |
return $this->raiseError('Error: Channel "' . $channel->getName() . |
'" does not exist, use channel-add to add an entry'); |
} |
$ret = $reg->updateChannel($channel, $lastmodified); |
if (PEAR::isError($ret)) { |
return $ret; |
} |
if (!$ret) { |
return $this->raiseError('Updating Channel "' . $channel->getName() . |
'" in registry failed'); |
} |
$this->config->setChannels($reg->listChannels()); |
$this->config->writeConfigFile(); |
$this->ui->outputData('Update of Channel "' . $channel->getName() . '" succeeded'); |
721,65 → 669,214 |
function doAlias($command, $options, $params) |
{ |
$reg = &$this->config->getRegistry(); |
if (sizeof($params) == 1) { |
if (count($params) === 1) { |
return $this->raiseError('No channel alias specified'); |
} |
if (sizeof($params) != 2) { |
if (count($params) !== 2 || (!empty($params[1]) && $params[1]{0} == '-')) { |
return $this->raiseError( |
'Invalid format, correct is: channel-alias channel alias'); |
} |
$reg = &$this->config->getRegistry(); |
if (!$reg->channelExists($params[0], true)) { |
$extra = ''; |
if ($reg->isAlias($params[0])) { |
$extra = ' (use "channel-alias ' . $reg->channelName($params[0]) . ' ' . |
strtolower($params[1]) . '")'; |
} else { |
$extra = ''; |
} |
return $this->raiseError('"' . $params[0] . '" is not a valid channel' . $extra); |
} |
if ($reg->isAlias($params[1])) { |
return $this->raiseError('Channel "' . $reg->channelName($params[1]) . '" is ' . |
'already aliased to "' . strtolower($params[1]) . '", cannot re-alias'); |
} |
$chan = &$reg->getChannel($params[0]); |
$chan = $reg->getChannel($params[0]); |
if (PEAR::isError($chan)) { |
return $this->raiseError('Corrupt registry? Error retrieving channel "' . $params[0] . |
'" information (' . $chan->getMessage() . ')'); |
} |
// make it a local alias |
if (!$chan->setAlias(strtolower($params[1]), true)) { |
return $this->raiseError('Alias "' . strtolower($params[1]) . |
'" is not a valid channel alias'); |
} |
$reg->updateChannel($chan); |
$this->ui->outputData('Channel "' . $chan->getName() . '" aliased successfully to "' . |
strtolower($params[1]) . '"'); |
} |
/** |
* The channel-discover command |
* |
* @param string $command command name |
* @param array $options option_name => value |
* @param array $params list of additional parameters. |
* $params[0] should contain a string with either: |
* - <channel name> or |
* - <username>:<password>@<channel name> |
* @return null|PEAR_Error |
*/ |
function doDiscover($command, $options, $params) |
{ |
$reg = &$this->config->getRegistry(); |
if (sizeof($params) != 1) { |
if (count($params) !== 1) { |
return $this->raiseError("No channel server specified"); |
} |
if ($reg->channelExists($params[0])) { |
if ($reg->isAlias($params[0])) { |
return $this->raiseError("A channel alias named \"$params[0]\" " . |
'already exists, aliasing channel "' . $reg->channelName($params[0]) |
. '"'); |
} else { |
return $this->raiseError("Channel \"$params[0]\" is already initialized"); |
// Look for the possible input format "<username>:<password>@<channel>" |
if (preg_match('/^(.+):(.+)@(.+)\\z/', $params[0], $matches)) { |
$username = $matches[1]; |
$password = $matches[2]; |
$channel = $matches[3]; |
} else { |
$channel = $params[0]; |
} |
$reg = &$this->config->getRegistry(); |
if ($reg->channelExists($channel)) { |
if (!$reg->isAlias($channel)) { |
return $this->raiseError("Channel \"$channel\" is already initialized", PEAR_COMMAND_CHANNELS_CHANNEL_EXISTS); |
} |
return $this->raiseError("A channel alias named \"$channel\" " . |
'already exists, aliasing channel "' . $reg->channelName($channel) |
. '"'); |
} |
$this->pushErrorHandling(PEAR_ERROR_RETURN); |
$err = $this->doAdd($command, $options, array('http://' . $params[0] . '/channel.xml')); |
$err = $this->doAdd($command, $options, array('http://' . $channel . '/channel.xml')); |
$this->popErrorHandling(); |
if (PEAR::isError($err)) { |
return $this->raiseError("Discovery of channel \"$params[0]\" failed (" . |
$err->getMessage() . ')'); |
if ($err->getCode() === PEAR_COMMAND_CHANNELS_CHANNEL_EXISTS) { |
return $this->raiseError("Discovery of channel \"$channel\" failed (" . |
$err->getMessage() . ')'); |
} |
// Attempt fetch via https |
$this->ui->outputData("Discovering channel $channel over http:// failed with message: " . $err->getMessage()); |
$this->ui->outputData("Trying to discover channel $channel over https:// instead"); |
$this->pushErrorHandling(PEAR_ERROR_RETURN); |
$err = $this->doAdd($command, $options, array('https://' . $channel . '/channel.xml')); |
$this->popErrorHandling(); |
if (PEAR::isError($err)) { |
return $this->raiseError("Discovery of channel \"$channel\" failed (" . |
$err->getMessage() . ')'); |
} |
} |
$this->ui->outputData("Discovery of channel \"$params[0]\" succeeded", $command); |
// Store username/password if they were given |
// Arguably we should do a logintest on the channel here, but since |
// that's awkward on a REST-based channel (even "pear login" doesn't |
// do it for those), and XML-RPC is deprecated, it's fairly pointless. |
if (isset($username)) { |
$this->config->set('username', $username, 'user', $channel); |
$this->config->set('password', $password, 'user', $channel); |
$this->config->store(); |
$this->ui->outputData("Stored login for channel \"$channel\" using username \"$username\"", $command); |
} |
$this->ui->outputData("Discovery of channel \"$channel\" succeeded", $command); |
} |
/** |
* Execute the 'login' command. |
* |
* @param string $command command name |
* @param array $options option_name => value |
* @param array $params list of additional parameters |
* |
* @return bool TRUE on success or |
* a PEAR error on failure |
* |
* @access public |
*/ |
function doLogin($command, $options, $params) |
{ |
$reg = &$this->config->getRegistry(); |
// If a parameter is supplied, use that as the channel to log in to |
$channel = isset($params[0]) ? $params[0] : $this->config->get('default_channel'); |
$chan = $reg->getChannel($channel); |
if (PEAR::isError($chan)) { |
return $this->raiseError($chan); |
} |
$server = $this->config->get('preferred_mirror', null, $channel); |
$username = $this->config->get('username', null, $channel); |
if (empty($username)) { |
$username = isset($_ENV['USER']) ? $_ENV['USER'] : null; |
} |
$this->ui->outputData("Logging in to $server.", $command); |
list($username, $password) = $this->ui->userDialog( |
$command, |
array('Username', 'Password'), |
array('text', 'password'), |
array($username, '') |
); |
$username = trim($username); |
$password = trim($password); |
$ourfile = $this->config->getConfFile('user'); |
if (!$ourfile) { |
$ourfile = $this->config->getConfFile('system'); |
} |
$this->config->set('username', $username, 'user', $channel); |
$this->config->set('password', $password, 'user', $channel); |
if ($chan->supportsREST()) { |
$ok = true; |
} |
if ($ok !== true) { |
return $this->raiseError('Login failed!'); |
} |
$this->ui->outputData("Logged in.", $command); |
// avoid changing any temporary settings changed with -d |
$ourconfig = new PEAR_Config($ourfile, $ourfile); |
$ourconfig->set('username', $username, 'user', $channel); |
$ourconfig->set('password', $password, 'user', $channel); |
$ourconfig->store(); |
return true; |
} |
/** |
* Execute the 'logout' command. |
* |
* @param string $command command name |
* @param array $options option_name => value |
* @param array $params list of additional parameters |
* |
* @return bool TRUE on success or |
* a PEAR error on failure |
* |
* @access public |
*/ |
function doLogout($command, $options, $params) |
{ |
$reg = &$this->config->getRegistry(); |
// If a parameter is supplied, use that as the channel to log in to |
$channel = isset($params[0]) ? $params[0] : $this->config->get('default_channel'); |
$chan = $reg->getChannel($channel); |
if (PEAR::isError($chan)) { |
return $this->raiseError($chan); |
} |
$server = $this->config->get('preferred_mirror', null, $channel); |
$this->ui->outputData("Logging out from $server.", $command); |
$this->config->remove('username', 'user', $channel); |
$this->config->remove('password', 'user', $channel); |
$this->config->store(); |
return true; |
} |
} |
?> |
/trunk/bibliotheque/pear/PEAR/Command/Remote.php |
---|
5,19 → 5,12 |
* |
* 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 Stig Bakken <ssb@php.net> |
* @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: Remote.php,v 1.96 2006/09/24 03:08:57 cellog Exp $ |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 0.1 |
*/ |
35,16 → 28,14 |
* @package PEAR |
* @author Stig Bakken <ssb@php.net> |
* @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: 1.5.1 |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 0.1 |
*/ |
class PEAR_Command_Remote extends PEAR_Command_Common |
{ |
// {{{ command definitions |
var $commands = array( |
'remote-info' => array( |
'summary' => 'Information About Remote Packages', |
58,7 → 49,12 |
'summary' => 'List Available Upgrades', |
'function' => 'doListUpgrades', |
'shortcut' => 'lu', |
'options' => array(), |
'options' => array( |
'channelinfo' => array( |
'shortopt' => 'i', |
'doc' => 'output fully channel-aware data, even on failure', |
), |
), |
'doc' => '[preferred_state] |
List releases on the server of packages you have installed where |
a newer version is available with the same release state (stable etc.) |
90,7 → 86,15 |
'shortopt' => 'c', |
'doc' => 'specify a channel other than the default channel', |
'arg' => 'CHAN', |
) |
), |
'allchannels' => array( |
'shortopt' => 'a', |
'doc' => 'search packages from all known channels', |
), |
'channelinfo' => array( |
'shortopt' => 'i', |
'doc' => 'output fully channel-aware data, even on failure', |
), |
), |
'doc' => '[packagename] [packageinfo] |
Lists all packages which match the search parameters. The first |
108,7 → 112,11 |
'shortopt' => 'c', |
'doc' => 'specify a channel other than the default channel', |
'arg' => 'CHAN', |
) |
), |
'channelinfo' => array( |
'shortopt' => 'i', |
'doc' => 'output fully channel-aware data, even on failure', |
), |
), |
'doc' => ' |
Lists the packages available on the configured server along with the |
135,27 → 143,22 |
'shortcut' => 'cc', |
'options' => array(), |
'doc' => ' |
Clear the XML-RPC/REST cache. See also the cache_ttl configuration |
Clear the REST cache. See also the cache_ttl configuration |
parameter. |
', |
), |
); |
// }}} |
// {{{ constructor |
/** |
* PEAR_Command_Remote constructor. |
* |
* @access public |
*/ |
function PEAR_Command_Remote(&$ui, &$config) |
function __construct(&$ui, &$config) |
{ |
parent::PEAR_Command_Common($ui, $config); |
parent::__construct($ui, $config); |
} |
// }}} |
function _checkChannelForStatus($channel, $chan) |
{ |
if (PEAR::isError($chan)) { |
167,18 → 170,18 |
} |
$rest = new PEAR_REST($this->config); |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$mirror = $this->config->get('preferred_mirror', null, |
$channel); |
$a = $rest->downloadHttp('http://' . $channel . |
'/channel.xml', $chan->lastModified()); |
PEAR::staticPopErrorHandling(); |
if (!PEAR::isError($a) && $a) { |
$this->ui->outputData('WARNING: channel "' . $channel . '" has ' . |
'updated its protocols, use "channel-update ' . $channel . |
'updated its protocols, use "' . PEAR_RUNTYPE . ' channel-update ' . $channel . |
'" to update'); |
} |
} |
// {{{ doRemoteInfo() |
function doRemoteInfo($command, $options, $params) |
{ |
if (sizeof($params) != 1) { |
191,7 → 194,7 |
if (PEAR::isError($parsed)) { |
return $this->raiseError('Invalid package name "' . $package . '"'); |
} |
$channel = $parsed['channel']; |
$this->config->set('default_channel', $channel); |
$chan = $reg->getChannel($channel); |
198,18 → 201,22 |
if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) { |
return $e; |
} |
if ($chan->supportsREST($this->config->get('preferred_mirror')) && |
$base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) { |
$mirror = $this->config->get('preferred_mirror'); |
if ($chan->supportsREST($mirror) && $base = $chan->getBaseURL('REST1.0', $mirror)) { |
$rest = &$this->config->getREST('1.0', array()); |
$info = $rest->packageInfo($base, $parsed['package']); |
} else { |
$r = &$this->config->getRemote(); |
$info = $r->call('package.info', $parsed['package']); |
$info = $rest->packageInfo($base, $parsed['package'], $channel); |
} |
if (!isset($info)) { |
return $this->raiseError('No supported protocol was found'); |
} |
if (PEAR::isError($info)) { |
$this->config->set('default_channel', $savechannel); |
return $this->raiseError($info); |
} |
if (!isset($info['name'])) { |
return $this->raiseError('No remote package "' . $package . '" was found'); |
} |
226,9 → 233,6 |
return true; |
} |
// }}} |
// {{{ doRemoteList() |
function doRemoteList($command, $options, $params) |
{ |
$savechannel = $channel = $this->config->get('default_channel'); |
235,54 → 239,55 |
$reg = &$this->config->getRegistry(); |
if (isset($options['channel'])) { |
$channel = $options['channel']; |
if ($reg->channelExists($channel)) { |
$this->config->set('default_channel', $channel); |
} else { |
if (!$reg->channelExists($channel)) { |
return $this->raiseError('Channel "' . $channel . '" does not exist'); |
} |
$this->config->set('default_channel', $channel); |
} |
$chan = $reg->getChannel($channel); |
if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) { |
return $e; |
} |
$list_options = false; |
if ($this->config->get('preferred_state') == 'stable') { |
$list_options = true; |
} |
$available = array(); |
if ($chan->supportsREST($this->config->get('preferred_mirror')) && |
$base = $chan->getBaseURL('REST1.1', $this->config->get('preferred_mirror'))) { |
$base = $chan->getBaseURL('REST1.1', $this->config->get('preferred_mirror')) |
) { |
// use faster list-all if available |
$rest = &$this->config->getREST('1.1', array()); |
$available = $rest->listAll($base, $list_options); |
$available = $rest->listAll($base, $list_options, true, false, false, $chan->getName()); |
} elseif ($chan->supportsREST($this->config->get('preferred_mirror')) && |
$base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) { |
$rest = &$this->config->getREST('1.0', array()); |
$available = $rest->listAll($base, $list_options); |
} else { |
$r = &$this->config->getRemote(); |
if ($channel == 'pear.php.net') { |
// hack because of poor pearweb design |
$available = $r->call('package.listAll', true, $list_options, false); |
} else { |
$available = $r->call('package.listAll', true, $list_options); |
} |
$available = $rest->listAll($base, $list_options, true, false, false, $chan->getName()); |
} |
if (PEAR::isError($available)) { |
$this->config->set('default_channel', $savechannel); |
return $this->raiseError($available); |
} |
$i = $j = 0; |
$data = array( |
'caption' => 'Channel ' . $channel . ' Available packages:', |
'border' => true, |
'headline' => array('Package', 'Version'), |
'channel' => $channel |
); |
if (count($available)==0) { |
if (count($available) == 0) { |
$data = '(no packages available yet)'; |
} else { |
foreach ($available as $name => $info) { |
$data['data'][] = array($name, (isset($info['stable']) && $info['stable']) |
? $info['stable'] : '-n/a-'); |
$version = (isset($info['stable']) && $info['stable']) ? $info['stable'] : '-n/a-'; |
$data['data'][] = array($name, $version); |
} |
} |
$this->ui->outputData($data, $command); |
290,9 → 295,6 |
return true; |
} |
// }}} |
// {{{ doListAll() |
function doListAll($command, $options, $params) |
{ |
$savechannel = $channel = $this->config->get('default_channel'); |
299,47 → 301,52 |
$reg = &$this->config->getRegistry(); |
if (isset($options['channel'])) { |
$channel = $options['channel']; |
if ($reg->channelExists($channel)) { |
$this->config->set('default_channel', $channel); |
} else { |
if (!$reg->channelExists($channel)) { |
return $this->raiseError("Channel \"$channel\" does not exist"); |
} |
$this->config->set('default_channel', $channel); |
} |
$list_options = false; |
if ($this->config->get('preferred_state') == 'stable') { |
$list_options = true; |
} |
$chan = $reg->getChannel($channel); |
if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) { |
return $e; |
} |
if ($chan->supportsREST($this->config->get('preferred_mirror')) && |
$base = $chan->getBaseURL('REST1.1', $this->config->get('preferred_mirror'))) { |
// use faster list-all if available |
$rest = &$this->config->getREST('1.1', array()); |
$available = $rest->listAll($base, $list_options, false); |
$available = $rest->listAll($base, $list_options, false, false, false, $chan->getName()); |
} elseif ($chan->supportsREST($this->config->get('preferred_mirror')) && |
$base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) { |
$rest = &$this->config->getREST('1.0', array()); |
$available = $rest->listAll($base, $list_options, false); |
} else { |
$r = &$this->config->getRemote(); |
if ($channel == 'pear.php.net') { |
// hack because of poor pearweb design |
$available = $r->call('package.listAll', true, $list_options, false); |
} else { |
$available = $r->call('package.listAll', true, $list_options); |
} |
$available = $rest->listAll($base, $list_options, false, false, false, $chan->getName()); |
} |
if (PEAR::isError($available)) { |
$this->config->set('default_channel', $savechannel); |
return $this->raiseError('The package list could not be fetched from the remote server. Please try again. (Debug info: "' . $available->getMessage() . '")'); |
} |
$data = array( |
'caption' => 'All packages:', |
'caption' => 'All packages [Channel ' . $channel . ']:', |
'border' => true, |
'headline' => array('Package', 'Latest', 'Local'), |
'channel' => $channel, |
); |
if (isset($options['channelinfo'])) { |
// add full channelinfo |
$data['caption'] = 'Channel ' . $channel . ' All packages:'; |
$data['headline'] = array('Channel', 'Package', 'Latest', 'Local', |
'Description', 'Dependencies'); |
} |
$local_pkgs = $reg->listPackages($channel); |
foreach ($available as $name => $info) { |
373,13 → 380,39 |
if (isset($info['stable']) && !$info['stable']) { |
$info['stable'] = null; |
} |
$data['data'][$info['category']][] = array( |
$reg->channelAlias($channel) . '/' . $name, |
isset($info['stable']) ? $info['stable'] : null, |
isset($installed['version']) ? $installed['version'] : null, |
isset($desc) ? $desc : null, |
isset($info['deps']) ? $info['deps'] : null, |
if (isset($options['channelinfo'])) { |
// add full channelinfo |
if ($info['stable'] === $info['unstable']) { |
$state = $info['state']; |
} else { |
$state = 'stable'; |
} |
$latest = $info['stable'].' ('.$state.')'; |
$local = ''; |
if (isset($installed['version'])) { |
$inst_state = $reg->packageInfo($name, 'release_state', $channel); |
$local = $installed['version'].' ('.$inst_state.')'; |
} |
$packageinfo = array( |
$channel, |
$name, |
$latest, |
$local, |
isset($desc) ? $desc : null, |
isset($info['deps']) ? $info['deps'] : null, |
); |
} else { |
$packageinfo = array( |
$reg->channelAlias($channel) . '/' . $name, |
isset($info['stable']) ? $info['stable'] : null, |
isset($installed['version']) ? $installed['version'] : null, |
isset($desc) ? $desc : null, |
isset($info['deps']) ? $info['deps'] : null, |
); |
} |
$data['data'][$info['category']][] = $packageinfo; |
} |
if (isset($options['mode']) && in_array($options['mode'], array('notinstalled', 'upgrades'))) { |
387,6 → 420,7 |
$this->ui->outputData($data, $command); |
return true; |
} |
foreach ($local_pkgs as $name) { |
$info = &$reg->getPackage($name, $channel); |
$data['data']['Local'][] = array( |
403,9 → 437,6 |
return true; |
} |
// }}} |
// {{{ doSearch() |
function doSearch($command, $options, $params) |
{ |
if ((!isset($params[0]) || empty($params[0])) |
412,47 → 443,94 |
&& (!isset($params[1]) || empty($params[1]))) |
{ |
return $this->raiseError('no valid search string supplied'); |
}; |
} |
$channelinfo = isset($options['channelinfo']); |
$reg = &$this->config->getRegistry(); |
if (isset($options['allchannels'])) { |
// search all channels |
unset($options['allchannels']); |
$channels = $reg->getChannels(); |
$errors = array(); |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
foreach ($channels as $channel) { |
if ($channel->getName() != '__uri') { |
$options['channel'] = $channel->getName(); |
$ret = $this->doSearch($command, $options, $params); |
if (PEAR::isError($ret)) { |
$errors[] = $ret; |
} |
} |
} |
PEAR::staticPopErrorHandling(); |
if (count($errors) !== 0) { |
// for now, only give first error |
return PEAR::raiseError($errors[0]); |
} |
return true; |
} |
$savechannel = $channel = $this->config->get('default_channel'); |
$reg = &$this->config->getRegistry(); |
$package = $params[0]; |
$package = strtolower($params[0]); |
$summary = isset($params[1]) ? $params[1] : false; |
if (isset($options['channel'])) { |
$reg = &$this->config->getRegistry(); |
$channel = $options['channel']; |
if ($reg->channelExists($channel)) { |
$this->config->set('default_channel', $channel); |
} else { |
if (!$reg->channelExists($channel)) { |
return $this->raiseError('Channel "' . $channel . '" does not exist'); |
} |
$this->config->set('default_channel', $channel); |
} |
$chan = $reg->getChannel($channel); |
if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) { |
return $e; |
} |
if ($chan->supportsREST($this->config->get('preferred_mirror')) && |
$base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) { |
$rest = &$this->config->getREST('1.0', array()); |
$available = $rest->listAll($base, false, false, $package, $summary); |
} else { |
$r = &$this->config->getRemote(); |
$available = $r->call('package.search', $package, $summary, true, |
$this->config->get('preferred_state') == 'stable', true); |
$available = $rest->listAll($base, false, false, $package, $summary, $chan->getName()); |
} |
if (PEAR::isError($available)) { |
$this->config->set('default_channel', $savechannel); |
return $this->raiseError($available); |
} |
if (!$available) { |
return $this->raiseError('no packages found that match pattern "' . $package . '"'); |
if (!$available && !$channelinfo) { |
// clean exit when not found, no error ! |
$data = 'no packages found that match pattern "' . $package . '", for channel '.$channel.'.'; |
$this->ui->outputData($data); |
$this->config->set('default_channel', $channel); |
return true; |
} |
$data = array( |
'caption' => 'Matched packages, channel ' . $channel . ':', |
'border' => true, |
'headline' => array('Package', 'Stable/(Latest)', 'Local'), |
); |
if ($channelinfo) { |
$data = array( |
'caption' => 'Matched packages, channel ' . $channel . ':', |
'border' => true, |
'headline' => array('Channel', 'Package', 'Stable/(Latest)', 'Local'), |
'channel' => $channel |
); |
} else { |
$data = array( |
'caption' => 'Matched packages, channel ' . $channel . ':', |
'border' => true, |
'headline' => array('Package', 'Stable/(Latest)', 'Local'), |
'channel' => $channel |
); |
} |
if (!$available && $channelinfo) { |
unset($data['headline']); |
$data['data'] = 'No packages found that match pattern "' . $package . '".'; |
$available = array(); |
} |
foreach ($available as $name => $info) { |
$installed = $reg->packageInfo($name, null, $channel); |
$desc = $info['summary']; |
459,37 → 537,50 |
if (isset($params[$name])) |
$desc .= "\n\n".$info['description']; |
$unstable = ''; |
if ($info['unstable']) { |
$unstable = '/(' . $info['unstable'] . ' ' . $info['state'] . ')'; |
} |
if (!isset($info['stable']) || !$info['stable']) { |
$info['stable'] = 'none'; |
$version_remote = 'none'; |
} else { |
if ($info['unstable']) { |
$version_remote = $info['unstable']; |
} else { |
$version_remote = $info['stable']; |
} |
$version_remote .= ' ('.$info['state'].')'; |
} |
$version = is_array($installed['version']) ? $installed['version']['release'] : |
$installed['version']; |
$data['data'][$info['category']][] = array( |
$name, |
$info['stable'] . $unstable, |
$version, |
$desc, |
if ($channelinfo) { |
$packageinfo = array( |
$channel, |
$name, |
$version_remote, |
$version, |
$desc, |
); |
} else { |
$packageinfo = array( |
$name, |
$version_remote, |
$version, |
$desc, |
); |
} |
$data['data'][$info['category']][] = $packageinfo; |
} |
$this->ui->outputData($data, $command); |
$this->config->set('default_channel', $channel); |
return true; |
} |
// }}} |
function &getDownloader($options) |
{ |
if (!class_exists('PEAR_Downloader')) { |
require_once 'PEAR/Downloader.php'; |
} |
$a = &new PEAR_Downloader($this->ui, $options, $this->config); |
$a = new PEAR_Downloader($this->ui, $options, $this->config); |
return $a; |
} |
// {{{ doDownload() |
function doDownload($command, $options, $params) |
{ |
503,7 → 594,13 |
// eliminate error messages for preferred_state-related errors |
$downloader = &$this->getDownloader($options); |
$downloader->setDownloadDir(getcwd()); |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$e = $downloader->setDownloadDir(getcwd()); |
PEAR::staticPopErrorHandling(); |
if (PEAR::isError($e)) { |
return $this->raiseError('Current directory is not writeable, cannot download'); |
} |
$errors = array(); |
$downloaded = array(); |
$err = $downloader->download($params); |
510,17 → 607,23 |
if (PEAR::isError($err)) { |
return $err; |
} |
$errors = $downloader->getErrorMsgs(); |
if (count($errors)) { |
foreach ($errors as $error) { |
$this->ui->outputData($error); |
if ($error !== null) { |
$this->ui->outputData($error); |
} |
} |
return $this->raiseError("$command failed"); |
} |
$downloaded = $downloader->getDownloadedPackages(); |
foreach ($downloaded as $pkg) { |
$this->ui->outputData("File $pkg[file] downloaded", $command); |
} |
return true; |
} |
531,9 → 634,6 |
} |
} |
// }}} |
// {{{ doListUpgrades() |
function doListUpgrades($command, $options, $params) |
{ |
require_once 'PEAR/Common.php'; |
540,6 → 640,7 |
if (isset($params[0]) && !is_array(PEAR_Common::betterStates($params[0]))) { |
return $this->raiseError($params[0] . ' is not a valid state (stable/beta/alpha/devel/etc.) try "pear help list-upgrades"'); |
} |
$savechannel = $channel = $this->config->get('default_channel'); |
$reg = &$this->config->getRegistry(); |
foreach ($reg->listChannels() as $channel) { |
547,56 → 648,66 |
if (!count($inst)) { |
continue; |
} |
if ($channel == '__uri') { |
continue; |
} |
$this->config->set('default_channel', $channel); |
if (empty($params[0])) { |
$state = $this->config->get('preferred_state'); |
} else { |
$state = $params[0]; |
} |
$state = empty($params[0]) ? $this->config->get('preferred_state') : $params[0]; |
$caption = $channel . ' Available Upgrades'; |
$chan = $reg->getChannel($channel); |
if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) { |
return $e; |
} |
if ($chan->supportsREST($this->config->get('preferred_mirror')) && |
$base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) { |
$rest = &$this->config->getREST('1.0', array()); |
$latest = array(); |
$base2 = false; |
$preferred_mirror = $this->config->get('preferred_mirror'); |
if ($chan->supportsREST($preferred_mirror) && |
( |
($base2 = $chan->getBaseURL('REST1.3', $preferred_mirror)) |
|| ($base = $chan->getBaseURL('REST1.0', $preferred_mirror)) |
) |
) { |
if ($base2) { |
$rest = &$this->config->getREST('1.3', array()); |
$base = $base2; |
} else { |
$rest = &$this->config->getREST('1.0', array()); |
} |
if (empty($state) || $state == 'any') { |
$state = false; |
} else { |
$caption .= ' (' . implode(', ', PEAR_Common::betterStates($state, true)) . ')'; |
} |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$latest = $rest->listLatestUpgrades($base, $state, $inst, $channel, $reg); |
PEAR::staticPopErrorHandling(); |
} else { |
$remote = &$this->config->getRemote(); |
$remote->pushErrorHandling(PEAR_ERROR_RETURN); |
if (empty($state) || $state == 'any') { |
$latest = $remote->call("package.listLatestReleases"); |
} else { |
$latest = $remote->call("package.listLatestReleases", $state); |
$caption .= ' (' . implode(', ', PEAR_Common::betterStates($state, true)) . ')'; |
} |
$remote->popErrorHandling(); |
} |
if (PEAR::isError($latest)) { |
$this->ui->outputData($latest->getMessage()); |
continue; |
} |
$caption .= ':'; |
if (PEAR::isError($latest)) { |
$this->config->set('default_channel', $savechannel); |
return $latest; |
} |
$data = array( |
'caption' => $caption, |
'border' => 1, |
'headline' => array('Channel', 'Package', 'Local', 'Remote', 'Size'), |
'channel' => $channel |
); |
foreach ((array)$latest as $pkg => $info) { |
$package = strtolower($pkg); |
if (!isset($inst[$package])) { |
603,6 → 714,7 |
// skip packages we don't have installed |
continue; |
} |
extract($info); |
$inst_version = $reg->packageInfo($package, 'version', $channel); |
$inst_state = $reg->packageInfo($package, 'release_state', $channel); |
610,6 → 722,7 |
// installed version is up-to-date |
continue; |
} |
if ($filesize >= 20480) { |
$filesize += 1024 - ($filesize % 1024); |
$fs = sprintf("%dkB", $filesize / 1024); |
619,39 → 732,53 |
} else { |
$fs = " -"; // XXX center instead |
} |
$data['data'][] = array($channel, $pkg, "$inst_version ($inst_state)", "$version ($state)", $fs); |
} |
if (empty($data['data'])) { |
$this->ui->outputData('Channel ' . $channel . ': No upgrades available'); |
if (isset($options['channelinfo'])) { |
if (empty($data['data'])) { |
unset($data['headline']); |
if (count($inst) == 0) { |
$data['data'] = '(no packages installed)'; |
} else { |
$data['data'] = '(no upgrades available)'; |
} |
} |
$this->ui->outputData($data, $command); |
} else { |
$this->ui->outputData($data, $command); |
if (empty($data['data'])) { |
$this->ui->outputData('Channel ' . $channel . ': No upgrades available'); |
} else { |
$this->ui->outputData($data, $command); |
} |
} |
} |
$this->config->set('default_channel', $savechannel); |
return true; |
} |
// }}} |
// {{{ doClearCache() |
function doClearCache($command, $options, $params) |
{ |
$cache_dir = $this->config->get('cache_dir'); |
$verbose = $this->config->get('verbose'); |
$verbose = $this->config->get('verbose'); |
$output = ''; |
if (!file_exists($cache_dir) || !is_dir($cache_dir)) { |
return $this->raiseError("$cache_dir does not exist or is not a directory"); |
} |
if (!($dp = @opendir($cache_dir))) { |
return $this->raiseError("opendir($cache_dir) failed: $php_errormsg"); |
} |
if ($verbose >= 1) { |
$output .= "reading directory $cache_dir\n"; |
} |
$num = 0; |
while ($ent = readdir($dp)) { |
if (preg_match('/^xmlrpc_cache_[a-z0-9]{32}$/', $ent) || |
preg_match('/rest.cache(file|id)$/', $ent)) { |
if (preg_match('/rest.cache(file|id)\\z/', $ent)) { |
$path = $cache_dir . DIRECTORY_SEPARATOR . $ent; |
if (file_exists($path)) { |
$ok = @unlink($path); |
659,6 → 786,7 |
$ok = false; |
$php_errormsg = ''; |
} |
if ($ok) { |
if ($verbose >= 2) { |
$output .= "deleted $path\n"; |
669,15 → 797,13 |
} |
} |
} |
closedir($dp); |
if ($verbose >= 1) { |
$output .= "$num cache entries cleared\n"; |
} |
$this->ui->outputData(rtrim($output), $command); |
return $num; |
} |
// }}} |
} |
?> |
/trunk/bibliotheque/pear/PEAR/Command/Build.php |
---|
4,20 → 4,13 |
* |
* 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 Stig Bakken <ssb@php.net> |
* @author Tomas V.V.Cox <cox@idecnet.com> |
* @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: Build.php,v 1.13 2006/01/06 04:47:36 cellog Exp $ |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 0.1 |
*/ |
35,16 → 28,14 |
* @author Stig Bakken <ssb@php.net> |
* @author Tomas V.V.Cox <cox@idecnet.com> |
* @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: 1.5.1 |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 0.1 |
*/ |
class PEAR_Command_Build extends PEAR_Command_Common |
{ |
// {{{ properties |
var $commands = array( |
'build' => array( |
'summary' => 'Build an Extension From C Source', |
56,24 → 47,16 |
), |
); |
// }}} |
// {{{ constructor |
/** |
* PEAR_Command_Build constructor. |
* |
* @access public |
*/ |
function PEAR_Command_Build(&$ui, &$config) |
function __construct(&$ui, &$config) |
{ |
parent::PEAR_Command_Common($ui, $config); |
parent::__construct($ui, $config); |
} |
// }}} |
// {{{ doBuild() |
function doBuild($command, $options, $params) |
{ |
require_once 'PEAR/Builder.php'; |
80,18 → 63,17 |
if (sizeof($params) < 1) { |
$params[0] = 'package.xml'; |
} |
$builder = &new PEAR_Builder($this->ui); |
$builder = new PEAR_Builder($this->ui); |
$this->debug = $this->config->get('verbose'); |
$err = $builder->build($params[0], array(&$this, 'buildCallback')); |
if (PEAR::isError($err)) { |
return $err; |
} |
return true; |
} |
// }}} |
// {{{ buildCallback() |
function buildCallback($what, $data) |
{ |
if (($what == 'cmdoutput' && $this->debug > 1) || |
99,6 → 81,4 |
$this->ui->outputData(rtrim($data), 'build'); |
} |
} |
// }}} |
} |
/trunk/bibliotheque/pear/PEAR/Command/Auth.php |
---|
4,28 → 4,21 |
* |
* 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 Stig Bakken <ssb@php.net> |
* @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: Auth.php,v 1.24 2006/03/05 21:23:21 cellog Exp $ |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 0.1 |
* @deprecated since 1.8.0alpha1 |
*/ |
/** |
* base class |
*/ |
require_once 'PEAR/Command/Common.php'; |
require_once 'PEAR/Config.php'; |
require_once 'PEAR/Command/Channels.php'; |
/** |
* PEAR commands for login/logout |
34,24 → 27,26 |
* @package PEAR |
* @author Stig Bakken <ssb@php.net> |
* @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: 1.5.1 |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 0.1 |
* @deprecated since 1.8.0alpha1 |
*/ |
class PEAR_Command_Auth extends PEAR_Command_Common |
class PEAR_Command_Auth extends PEAR_Command_Channels |
{ |
// {{{ properties |
var $commands = array( |
'login' => array( |
'summary' => 'Connects and authenticates to remote server', |
'summary' => 'Connects and authenticates to remote server [Deprecated in favor of channel-login]', |
'shortcut' => 'li', |
'function' => 'doLogin', |
'options' => array(), |
'doc' => ' |
Log in to the remote server. To use remote functions in the installer |
'doc' => '<channel name> |
WARNING: This function is deprecated in favor of using channel-login |
Log in to a remote channel server. If <channel name> is not supplied, |
the default channel is used. To use remote functions in the installer |
that require any kind of privileges, you need to log in first. The |
username and password you enter here will be stored in your per-user |
PEAR configuration (~/.pearrc on Unix-like systems). After logging |
59,11 → 54,13 |
operations on the remote server.', |
), |
'logout' => array( |
'summary' => 'Logs out from the remote server', |
'summary' => 'Logs out from the remote server [Deprecated in favor of channel-logout]', |
'shortcut' => 'lo', |
'function' => 'doLogout', |
'options' => array(), |
'doc' => ' |
WARNING: This function is deprecated in favor of using channel-logout |
Logs out from the remote server. This command does not actually |
connect to the remote server, it only deletes the stored username and |
password from your user configuration.', |
71,116 → 68,13 |
); |
// }}} |
// {{{ constructor |
/** |
* PEAR_Command_Auth constructor. |
* |
* @access public |
*/ |
function PEAR_Command_Auth(&$ui, &$config) |
function __construct(&$ui, &$config) |
{ |
parent::PEAR_Command_Common($ui, $config); |
parent::__construct($ui, $config); |
} |
// }}} |
// {{{ doLogin() |
/** |
* Execute the 'login' command. |
* |
* @param string $command command name |
* |
* @param array $options option_name => value |
* |
* @param array $params list of additional parameters |
* |
* @return bool TRUE on success or |
* a PEAR error on failure |
* |
* @access public |
*/ |
function doLogin($command, $options, $params) |
{ |
$reg = &$this->config->getRegistry(); |
$channel = $this->config->get('default_channel'); |
$chan = $reg->getChannel($channel); |
if (PEAR::isError($chan)) { |
return $this->raiseError($chan); |
} |
$server = $this->config->get('preferred_mirror'); |
$remote = &$this->config->getRemote(); |
$username = $this->config->get('username'); |
if (empty($username)) { |
$username = isset($_ENV['USER']) ? $_ENV['USER'] : null; |
} |
$this->ui->outputData("Logging in to $server.", $command); |
list($username, $password) = $this->ui->userDialog( |
$command, |
array('Username', 'Password'), |
array('text', 'password'), |
array($username, '') |
); |
$username = trim($username); |
$password = trim($password); |
$this->config->set('username', $username); |
$this->config->set('password', $password); |
if ($chan->supportsREST()) { |
$ok = true; |
} else { |
$remote->expectError(401); |
$ok = $remote->call('logintest'); |
$remote->popExpect(); |
} |
if ($ok === true) { |
$this->ui->outputData("Logged in.", $command); |
$this->config->store(); |
} else { |
return $this->raiseError("Login failed!"); |
} |
return true; |
} |
// }}} |
// {{{ doLogout() |
/** |
* Execute the 'logout' command. |
* |
* @param string $command command name |
* |
* @param array $options option_name => value |
* |
* @param array $params list of additional parameters |
* |
* @return bool TRUE on success or |
* a PEAR error on failure |
* |
* @access public |
*/ |
function doLogout($command, $options, $params) |
{ |
$reg = &$this->config->getRegistry(); |
$channel = $this->config->get('default_channel'); |
$chan = $reg->getChannel($channel); |
if (PEAR::isError($chan)) { |
return $this->raiseError($chan); |
} |
$server = $this->config->get('preferred_mirror'); |
$this->ui->outputData("Logging out from $server.", $command); |
$this->config->remove('username'); |
$this->config->remove('password'); |
$this->config->store(); |
return true; |
} |
// }}} |
} |
?> |
/trunk/bibliotheque/pear/PEAR/Command/Remote.xml |
---|
11,7 → 11,12 |
<summary>List Available Upgrades</summary> |
<function>doListUpgrades</function> |
<shortcut>lu</shortcut> |
<options /> |
<options> |
<channelinfo> |
<shortopt>i</shortopt> |
<doc>output fully channel-aware data, even on failure</doc> |
</channelinfo> |
</options> |
<doc>[preferred_state] |
List releases on the server of packages you have installed where |
a newer version is available with the same release state (stable etc.) |
42,6 → 47,14 |
<doc>specify a channel other than the default channel</doc> |
<arg>CHAN</arg> |
</channel> |
<allchannels> |
<shortopt>a</shortopt> |
<doc>search packages from all known channels</doc> |
</allchannels> |
<channelinfo> |
<shortopt>i</shortopt> |
<doc>output fully channel-aware data, even on failure</doc> |
</channelinfo> |
</options> |
<doc>[packagename] [packageinfo] |
Lists all packages which match the search parameters. The first |
59,6 → 72,10 |
<doc>specify a channel other than the default channel</doc> |
<arg>CHAN</arg> |
</channel> |
<channelinfo> |
<shortopt>i</shortopt> |
<doc>output fully channel-aware data, even on failure</doc> |
</channelinfo> |
</options> |
<doc> |
Lists the packages available on the configured server along with the |
/trunk/bibliotheque/pear/PEAR/Command/Channels.xml |
---|
50,8 → 50,8 |
</force> |
<channel> |
<shortopt>c</shortopt> |
<doc>will force download of new channel.xml if an existing channel name is used</doc> |
<arg>CHANNEL</arg> |
<doc>will force download of new channel.xml if an existing channel name is used</doc> |
</channel> |
</options> |
<doc>[<channel.xml>|<channel name>] |
87,7 → 87,37 |
<shortcut>di</shortcut> |
<options /> |
<doc>[<channel.xml>|<channel name>] |
Initialize a Channel from its server and create the local channel.xml. |
Initialize a channel from its server and create a local channel.xml. |
If <channel name> is in the format "<username>:<password>@<channel>" then |
<username> and <password> will be set as the login username/password for |
<channel>. Use caution when passing the username/password in this way, as |
it may allow other users on your computer to briefly view your username/ |
password via the system's process list. |
</doc> |
</channel-discover> |
</commands> |
<channel-login> |
<summary>Connects and authenticates to remote channel server</summary> |
<function>doLogin</function> |
<shortcut>cli</shortcut> |
<options /> |
<doc><channel name> |
Log in to a remote channel server. If <channel name> is not supplied, |
the default channel is used. To use remote functions in the installer |
that require any kind of privileges, you need to log in first. The |
username and password you enter here will be stored in your per-user |
PEAR configuration (~/.pearrc on Unix-like systems). After logging |
in, your username and password will be sent along in subsequent |
operations on the remote server.</doc> |
</channel-login> |
<channel-logout> |
<summary>Logs out from the remote channel server</summary> |
<function>doLogout</function> |
<shortcut>clo</shortcut> |
<options /> |
<doc><channel name> |
Logs out from a remote channel server. If <channel name> is not supplied, |
the default channel is used. This command does not actually connect to the |
remote server, it only deletes the stored username and password from your user |
configuration.</doc> |
</channel-logout> |
</commands> |
/trunk/bibliotheque/pear/PEAR/Command/Package.xml |
---|
79,11 → 79,12 |
<doc>Ignore changes that insert or delete blank lines</doc> |
</ignore-blank-lines> |
<brief> |
<shortopt></shortopt> |
<doc>Report only whether the files differ, no details</doc> |
</brief> |
<dry-run> |
<shortopt>n</shortopt> |
<doc>Don't do anything, just pretend</doc> |
<doc>Don't do anything, just pretend</doc> |
</dry-run> |
</options> |
<doc><package.xml> |
93,6 → 94,39 |
of a specific release. |
</doc> |
</cvsdiff> |
<svntag> |
<summary>Set SVN Release Tag</summary> |
<function>doSvnTag</function> |
<shortcut>sv</shortcut> |
<options> |
<quiet> |
<shortopt>q</shortopt> |
<doc>Be quiet</doc> |
</quiet> |
<slide> |
<shortopt>F</shortopt> |
<doc>Move (slide) tag if it exists</doc> |
</slide> |
<delete> |
<shortopt>d</shortopt> |
<doc>Remove tag</doc> |
</delete> |
<dry-run> |
<shortopt>n</shortopt> |
<doc>Don't do anything, just pretend</doc> |
</dry-run> |
</options> |
<doc><package.xml> [files...] |
Sets a SVN tag on all files in a package. Use this command after you have |
packaged a distribution tarball with the "package" command to tag what |
revisions of what files were in that release. If need to fix something |
after running svntag once, but before the tarball is released to the public, |
use the "slide" option to move the release tag. |
to include files (such as a second package.xml, or tests not included in the |
release), pass them as additional parameters. |
</doc> |
</svntag> |
<cvstag> |
<summary>Set CVS Release Tag</summary> |
<function>doCvsTag</function> |
116,15 → 150,18 |
</delete> |
<dry-run> |
<shortopt>n</shortopt> |
<doc>Don't do anything, just pretend</doc> |
<doc>Don't do anything, just pretend</doc> |
</dry-run> |
</options> |
<doc><package.xml> |
<doc><package.xml> [files...] |
Sets a CVS tag on all files in a package. Use this command after you have |
packaged a distribution tarball with the "package" command to tag what |
revisions of what files were in that release. If need to fix something |
after running cvstag once, but before the tarball is released to the public, |
use the "slide" option to move the release tag. |
to include files (such as a second package.xml, or tests not included in the |
release), pass them as additional parameters. |
</doc> |
</cvstag> |
<package-dependencies> |
132,14 → 169,20 |
<function>doPackageDependencies</function> |
<shortcut>pd</shortcut> |
<options /> |
<doc> |
List all dependencies the package has.</doc> |
<doc><package-file> or <package.xml> or <install-package-name> |
List all dependencies the package has. |
Can take a tgz / tar file, package.xml or a package name of an installed package.</doc> |
</package-dependencies> |
<sign> |
<summary>Sign a package distribution file</summary> |
<function>doSign</function> |
<shortcut>si</shortcut> |
<options /> |
<options> |
<verbose> |
<shortopt>v</shortopt> |
<doc>Display GnuPG output</doc> |
</verbose> |
</options> |
<doc><package-file> |
Signs a package distribution (.tar or .tgz) file with GnuPG.</doc> |
</sign> |
150,14 → 193,14 |
<options> |
<spec-template> |
<shortopt>t</shortopt> |
<doc>Use FILE as RPM spec file template</doc> |
<arg>FILE</arg> |
<doc>Use FILE as RPM spec file template</doc> |
</spec-template> |
<rpm-pkgname> |
<shortopt>p</shortopt> |
<arg>FORMAT</arg> |
<doc>Use FORMAT as format string for RPM package name, %s is replaced |
by the PEAR package name, defaults to "PEAR::%s".</doc> |
<arg>FORMAT</arg> |
</rpm-pkgname> |
</options> |
<doc><package-file> |
191,4 → 234,4 |
used for automated conversion or learning the format. |
</doc> |
</convert> |
</commands> |
</commands> |
/trunk/bibliotheque/pear/PEAR/Command/Config.php |
---|
4,19 → 4,12 |
* |
* 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 Stig Bakken <ssb@php.net> |
* @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: Config.php,v 1.52 2006/03/05 21:32:47 cellog Exp $ |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 0.1 |
*/ |
33,16 → 26,14 |
* @package PEAR |
* @author Stig Bakken <ssb@php.net> |
* @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: 1.5.1 |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 0.1 |
*/ |
class PEAR_Command_Config extends PEAR_Command_Common |
{ |
// {{{ properties |
var $commands = array( |
'config-show' => array( |
'summary' => 'Show All Settings', |
136,29 → 127,21 |
), |
); |
// }}} |
// {{{ constructor |
/** |
* PEAR_Command_Config constructor. |
* |
* @access public |
*/ |
function PEAR_Command_Config(&$ui, &$config) |
function __construct(&$ui, &$config) |
{ |
parent::PEAR_Command_Common($ui, $config); |
parent::__construct($ui, $config); |
} |
// }}} |
// {{{ doConfigShow() |
function doConfigShow($command, $options, $params) |
{ |
$layer = null; |
if (is_array($params)) { |
$layer = isset($params[0]) ? $params[0] : NULL; |
} else { |
$layer = NULL; |
$layer = isset($params[0]) ? $params[0] : null; |
} |
// $params[0] -> the layer |
165,6 → 148,7 |
if ($error = $this->_checkLayer($layer)) { |
return $this->raiseError("config-show:$error"); |
} |
$keys = $this->config->getKeys(); |
sort($keys); |
$channel = isset($options['channel']) ? $options['channel'] : |
173,6 → 157,8 |
if (!$reg->channelExists($channel)) { |
return $this->raiseError('Channel "' . $channel . '" does not exist'); |
} |
$channel = $reg->channelName($channel); |
$data = array('caption' => 'Configuration (channel ' . $channel . '):'); |
foreach ($keys as $key) { |
$type = $this->config->getType($key); |
180,13 → 166,16 |
if ($type == 'password' && $value) { |
$value = '********'; |
} |
if ($value === false) { |
$value = 'false'; |
} elseif ($value === true) { |
$value = 'true'; |
} |
$data['data'][$this->config->getGroup($key)][] = array($this->config->getPrompt($key) , $key, $value); |
} |
foreach ($this->config->getLayers() as $layer) { |
$data['data']['Config Files'][] = array(ucfirst($layer) . ' Configuration File', 'Filename' , $this->config->getConfFile($layer)); |
} |
195,21 → 184,13 |
return true; |
} |
// }}} |
// {{{ doConfigGet() |
function doConfigGet($command, $options, $params) |
{ |
if (!is_array($params)) { |
$args_cnt = 0; |
} else { |
$args_cnt = count($params); |
} |
$args_cnt = is_array($params) ? count($params) : 0; |
switch ($args_cnt) { |
case 1: |
$config_key = $params[0]; |
$layer = NULL; |
$layer = null; |
break; |
case 2: |
$config_key = $params[0]; |
223,21 → 204,17 |
return $this->raiseError("config-get expects 1 or 2 parameters"); |
} |
$reg = &$this->config->getRegistry(); |
$channel = isset($options['channel']) ? $options['channel'] : $this->config->get('default_channel'); |
$reg = &$this->config->getRegistry(); |
if (!$reg->channelExists($channel)) { |
return $this->raiseError('Channel "' . $channel . '" does not exist'); |
} |
$channel = $reg->channelName($channel); |
$this->ui->outputData($this->config->get($config_key, $layer, $channel), $command); |
return true; |
} |
// }}} |
// {{{ doConfigSet() |
function doConfigSet($command, $options, $params) |
{ |
// $param[0] -> a parameter to set |
244,25 → 221,41 |
// $param[1] -> the value for the parameter |
// $param[2] -> the layer |
$failmsg = ''; |
if (sizeof($params) < 2 || sizeof($params) > 3) { |
if (count($params) < 2 || count($params) > 3) { |
$failmsg .= "config-set expects 2 or 3 parameters"; |
return PEAR::raiseError($failmsg); |
} |
if (isset($params[2]) && ($error = $this->_checkLayer($params[2]))) { |
$failmsg .= $error; |
return PEAR::raiseError("config-set:$failmsg"); |
} |
$channel = isset($options['channel']) ? $options['channel'] : |
$this->config->get('default_channel'); |
$channel = isset($options['channel']) ? $options['channel'] : $this->config->get('default_channel'); |
$reg = &$this->config->getRegistry(); |
if (!$reg->channelExists($channel)) { |
return $this->raiseError('Channel "' . $channel . '" does not exist'); |
} |
if ($params[0] == 'default_channel') { |
if (!$reg->channelExists($params[1])) { |
return $this->raiseError('Channel "' . $params[1] . '" does not exist'); |
} |
$channel = $reg->channelName($channel); |
if ($params[0] == 'default_channel' && !$reg->channelExists($params[1])) { |
return $this->raiseError('Channel "' . $params[1] . '" does not exist'); |
} |
if ($params[0] == 'preferred_mirror' |
&& ( |
!$reg->mirrorExists($channel, $params[1]) && |
(!$reg->channelExists($params[1]) || $channel != $params[1]) |
) |
) { |
$msg = 'Channel Mirror "' . $params[1] . '" does not exist'; |
$msg .= ' in your registry for channel "' . $channel . '".'; |
$msg .= "\n" . 'Attempt to run "pear channel-update ' . $channel .'"'; |
$msg .= ' if you believe this mirror should exist as you may'; |
$msg .= ' have outdated channel information.'; |
return $this->raiseError($msg); |
} |
if (count($params) == 2) { |
array_push($params, 'user'); |
$layer = 'user'; |
269,29 → 262,29 |
} else { |
$layer = $params[2]; |
} |
array_push($params, $channel); |
if (!call_user_func_array(array(&$this->config, 'set'), $params)) |
{ |
if (!call_user_func_array(array(&$this->config, 'set'), $params)) { |
array_pop($params); |
$failmsg = "config-set (" . implode(", ", $params) . ") failed, channel $channel"; |
} else { |
$this->config->store($layer); |
} |
if ($failmsg) { |
return $this->raiseError($failmsg); |
} |
$this->ui->outputData('config-set succeeded', $command); |
return true; |
} |
// }}} |
// {{{ doConfigHelp() |
function doConfigHelp($command, $options, $params) |
{ |
if (empty($params)) { |
$params = $this->config->getKeys(); |
} |
$data['caption'] = "Config help" . ((count($params) == 1) ? " for $params[0]" : ''); |
$data['headline'] = array('Name', 'Type', 'Description'); |
$data['border'] = true; |
302,14 → 295,13 |
$docs = rtrim($docs) . "\nValid set: " . |
implode(' ', $this->config->getSetValues($name)); |
} |
$data['data'][] = array($name, $type, $docs); |
} |
$this->ui->outputData($data, $command); |
} |
// }}} |
// {{{ doConfigCreate() |
function doConfigCreate($command, $options, $params) |
{ |
if (count($params) != 2) { |
316,6 → 308,7 |
return PEAR::raiseError('config-create: must have 2 parameters, root path and ' . |
'filename to save as'); |
} |
$root = $params[0]; |
// Clean up the DIRECTORY_SEPARATOR mess |
$ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR; |
323,38 → 316,45 |
array('/', '/', '/'), |
$root); |
if ($root{0} != '/') { |
if (isset($options['windows'])) { |
if (!preg_match('/^[A-Za-z]:/', $root)) { |
return PEAR::raiseError('Root directory must be an absolute path beginning ' . |
'with "\\" or "C:\\", was: "' . $root . '"'); |
} |
} else { |
if (!isset($options['windows'])) { |
return PEAR::raiseError('Root directory must be an absolute path beginning ' . |
'with "/", was: "' . $root . '"'); |
} |
if (!preg_match('/^[A-Za-z]:/', $root)) { |
return PEAR::raiseError('Root directory must be an absolute path beginning ' . |
'with "\\" or "C:\\", was: "' . $root . '"'); |
} |
} |
$windows = isset($options['windows']); |
if ($windows) { |
$root = str_replace('/', '\\', $root); |
} |
if (!file_exists($params[1])) { |
if (!@touch($params[1])) { |
return PEAR::raiseError('Could not create "' . $params[1] . '"'); |
} |
if (!file_exists($params[1]) && !@touch($params[1])) { |
return PEAR::raiseError('Could not create "' . $params[1] . '"'); |
} |
$params[1] = realpath($params[1]); |
$config = &new PEAR_Config($params[1], '#no#system#config#', false, false); |
$config = new PEAR_Config($params[1], '#no#system#config#', false, false); |
if ($root{strlen($root) - 1} == '/') { |
$root = substr($root, 0, strlen($root) - 1); |
} |
$config->noRegistry(); |
$config->set('php_dir', $windows ? "$root\\pear\\php" : "$root/pear/php", 'user'); |
$config->set('data_dir', $windows ? "$root\\pear\\data" : "$root/pear/data"); |
$config->set('www_dir', $windows ? "$root\\pear\\www" : "$root/pear/www"); |
$config->set('cfg_dir', $windows ? "$root\\pear\\cfg" : "$root/pear/cfg"); |
$config->set('ext_dir', $windows ? "$root\\pear\\ext" : "$root/pear/ext"); |
$config->set('doc_dir', $windows ? "$root\\pear\\docs" : "$root/pear/docs"); |
$config->set('test_dir', $windows ? "$root\\pear\\tests" : "$root/pear/tests"); |
$config->set('cache_dir', $windows ? "$root\\pear\\cache" : "$root/pear/cache"); |
$config->set('download_dir', $windows ? "$root\\pear\\download" : "$root/pear/download"); |
$config->set('temp_dir', $windows ? "$root\\pear\\temp" : "$root/pear/temp"); |
$config->set('bin_dir', $windows ? "$root\\pear" : "$root/pear"); |
$config->set('man_dir', $windows ? "$root\\pear\\man" : "$root/pear/man"); |
$config->writeConfigFile(); |
$this->_showConfig($config); |
$this->ui->outputData('Successfully created default configuration file "' . $params[1] . '"', |
361,8 → 361,6 |
$command); |
} |
// }}} |
function _showConfig(&$config) |
{ |
$params = array('user'); |
376,6 → 374,7 |
if ($type == 'password' && $value) { |
$value = '********'; |
} |
if ($value === false) { |
$value = 'false'; |
} elseif ($value === true) { |
384,6 → 383,7 |
$data['data'][$config->getGroup($key)][] = |
array($config->getPrompt($key) , $key, $value); |
} |
foreach ($config->getLayers() as $layer) { |
$data['data']['Config Files'][] = |
array(ucfirst($layer) . ' Configuration File', 'Filename' , |
393,7 → 393,6 |
$this->ui->outputData($data, 'config-show'); |
return true; |
} |
// {{{ _checkLayer() |
/** |
* Checks if a layer is defined or not |
409,10 → 408,7 |
return " only the layers: \"" . implode('" or "', $layers) . "\" are supported"; |
} |
} |
return false; |
} |
// }}} |
} |
?> |
/trunk/bibliotheque/pear/PEAR/Command/Install.php |
---|
4,19 → 4,12 |
* |
* 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 Stig Bakken <ssb@php.net> |
* @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: Install.php,v 1.122 2007/02/13 04:30:05 cellog Exp $ |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 0.1 |
*/ |
34,9 → 27,9 |
* @package PEAR |
* @author Stig Bakken <ssb@php.net> |
* @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: 1.5.1 |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 0.1 |
*/ |
140,6 → 133,11 |
'function' => 'doInstall', |
'shortcut' => 'up', |
'options' => array( |
'channel' => array( |
'shortopt' => 'c', |
'doc' => 'upgrade packages from a specific channel', |
'arg' => 'CHAN', |
), |
'force' => array( |
'shortopt' => 'f', |
'doc' => 'overwrite newer installed packages', |
167,13 → 165,8 |
'installroot' => array( |
'shortopt' => 'R', |
'arg' => 'DIR', |
'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT), use packagingroot for RPM', |
'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT)', |
), |
'packagingroot' => array( |
'shortopt' => 'P', |
'arg' => 'DIR', |
'doc' => 'root directory used when packaging files, like RPM packaging', |
), |
'ignore-errors' => array( |
'doc' => 'force install even if there were errors', |
), |
205,10 → 198,15 |
More than one package may be specified at once. |
'), |
'upgrade-all' => array( |
'summary' => 'Upgrade All Packages', |
'function' => 'doInstall', |
'summary' => 'Upgrade All Packages [Deprecated in favor of calling upgrade with no parameters]', |
'function' => 'doUpgradeAll', |
'shortcut' => 'ua', |
'options' => array( |
'channel' => array( |
'shortopt' => 'c', |
'doc' => 'upgrade packages from a specific channel', |
'arg' => 'CHAN', |
), |
'nodeps' => array( |
'shortopt' => 'n', |
'doc' => 'ignore dependencies, upgrade anyway', |
238,6 → 236,8 |
), |
), |
'doc' => ' |
WARNING: This function is deprecated in favor of using the upgrade command with no params |
Upgrades all packages that have a newer release available. Upgrades are |
done only if there is a release available of the state specified in |
"preferred_state" (currently {config preferred_state}), or a state considered |
312,9 → 312,9 |
* |
* @access public |
*/ |
function PEAR_Command_Install(&$ui, &$config) |
function __construct(&$ui, &$config) |
{ |
parent::PEAR_Command_Common($ui, $config); |
parent::__construct($ui, $config); |
} |
// }}} |
327,7 → 327,7 |
if (!class_exists('PEAR_Downloader')) { |
require_once 'PEAR/Downloader.php'; |
} |
$a = &new PEAR_Downloader($ui, $options, $config); |
$a = new PEAR_Downloader($ui, $options, $config); |
return $a; |
} |
339,7 → 339,7 |
if (!class_exists('PEAR_Installer')) { |
require_once 'PEAR/Installer.php'; |
} |
$a = &new PEAR_Installer($ui); |
$a = new PEAR_Installer($ui); |
return $a; |
} |
352,10 → 352,6 |
if (PEAR::isError($ini)) { |
return $ini; |
} |
$fp = @fopen($phpini, 'wb'); |
if (!$fp) { |
return PEAR::raiseError('cannot open php.ini "' . $phpini . '" for writing'); |
} |
$line = 0; |
if ($type == 'extsrc' || $type == 'extbin') { |
$search = 'extensions'; |
367,7 → 363,7 |
$info = ob_get_contents(); |
ob_end_clean(); |
$debug = function_exists('leak') ? '_debug' : ''; |
$ts = preg_match('Thread Safety.+enabled', $info) ? '_ts' : ''; |
$ts = preg_match('/Thread Safety.+enabled/', $info) ? '_ts' : ''; |
$enable = 'zend_extension' . $debug . $ts; |
} |
foreach ($ini[$search] as $line => $extension) { |
389,6 → 385,10 |
$newini[] = $enable . '="' . $binary . '"' . (OS_UNIX ? "\n" : "\r\n"); |
} |
$newini = array_merge($newini, array_slice($ini['all'], $line)); |
$fp = @fopen($phpini, 'wb'); |
if (!$fp) { |
return PEAR::raiseError('cannot open php.ini "' . $phpini . '" for writing'); |
} |
foreach ($newini as $line) { |
fwrite($fp, $line); |
} |
416,7 → 416,7 |
$info = ob_get_contents(); |
ob_end_clean(); |
$debug = function_exists('leak') ? '_debug' : ''; |
$ts = preg_match('Thread Safety.+enabled', $info) ? '_ts' : ''; |
$ts = preg_match('/Thread Safety.+enabled/', $info) ? '_ts' : ''; |
$enable = 'zend_extension' . $debug . $ts; |
} |
$found = false; |
451,70 → 451,71 |
function _parseIni($filename) |
{ |
if (file_exists($filename)) { |
if (filesize($filename) > 300000) { |
return PEAR::raiseError('php.ini "' . $filename . '" is too large, aborting'); |
if (!file_exists($filename)) { |
return PEAR::raiseError('php.ini "' . $filename . '" does not exist'); |
} |
if (filesize($filename) > 300000) { |
return PEAR::raiseError('php.ini "' . $filename . '" is too large, aborting'); |
} |
ob_start(); |
phpinfo(INFO_GENERAL); |
$info = ob_get_contents(); |
ob_end_clean(); |
$debug = function_exists('leak') ? '_debug' : ''; |
$ts = preg_match('/Thread Safety.+enabled/', $info) ? '_ts' : ''; |
$zend_extension_line = 'zend_extension' . $debug . $ts; |
$all = @file($filename); |
if ($all === false) { |
return PEAR::raiseError('php.ini "' . $filename .'" could not be read'); |
} |
$zend_extensions = $extensions = array(); |
// assume this is right, but pull from the php.ini if it is found |
$extension_dir = ini_get('extension_dir'); |
foreach ($all as $linenum => $line) { |
$line = trim($line); |
if (!$line) { |
continue; |
} |
ob_start(); |
phpinfo(INFO_GENERAL); |
$info = ob_get_contents(); |
ob_end_clean(); |
$debug = function_exists('leak') ? '_debug' : ''; |
$ts = preg_match('/Thread Safety.+enabled/', $info) ? '_ts' : ''; |
$zend_extension_line = 'zend_extension' . $debug . $ts; |
$all = @file($filename); |
if (!$all) { |
return PEAR::raiseError('php.ini "' . $filename .'" could not be read'); |
if ($line[0] == ';') { |
continue; |
} |
$zend_extensions = $extensions = array(); |
// assume this is right, but pull from the php.ini if it is found |
$extension_dir = ini_get('extension_dir'); |
foreach ($all as $linenum => $line) { |
$line = trim($line); |
if (!$line) { |
if (strtolower(substr($line, 0, 13)) == 'extension_dir') { |
$line = trim(substr($line, 13)); |
if ($line[0] == '=') { |
$x = trim(substr($line, 1)); |
$x = explode(';', $x); |
$extension_dir = str_replace('"', '', array_shift($x)); |
continue; |
} |
if ($line[0] == ';') { |
} |
if (strtolower(substr($line, 0, 9)) == 'extension') { |
$line = trim(substr($line, 9)); |
if ($line[0] == '=') { |
$x = trim(substr($line, 1)); |
$x = explode(';', $x); |
$extensions[$linenum] = str_replace('"', '', array_shift($x)); |
continue; |
} |
if (strtolower(substr($line, 0, 13)) == 'extension_dir') { |
$line = trim(substr($line, 13)); |
if ($line[0] == '=') { |
$x = trim(substr($line, 1)); |
$x = explode(';', $x); |
$extension_dir = str_replace('"', '', array_shift($x)); |
continue; |
} |
} |
if (strtolower(substr($line, 0, strlen($zend_extension_line))) == |
$zend_extension_line) { |
$line = trim(substr($line, strlen($zend_extension_line))); |
if ($line[0] == '=') { |
$x = trim(substr($line, 1)); |
$x = explode(';', $x); |
$zend_extensions[$linenum] = str_replace('"', '', array_shift($x)); |
continue; |
} |
if (strtolower(substr($line, 0, 9)) == 'extension') { |
$line = trim(substr($line, 9)); |
if ($line[0] == '=') { |
$x = trim(substr($line, 1)); |
$x = explode(';', $x); |
$extensions[$linenum] = str_replace('"', '', array_shift($x)); |
continue; |
} |
} |
if (strtolower(substr($line, 0, strlen($zend_extension_line))) == |
$zend_extension_line) { |
$line = trim(substr($line, strlen($zend_extension_line))); |
if ($line[0] == '=') { |
$x = trim(substr($line, 1)); |
$x = explode(';', $x); |
$zend_extensions[$linenum] = str_replace('"', '', array_shift($x)); |
continue; |
} |
} |
} |
return array( |
'extensions' => $extensions, |
'zend_extensions' => $zend_extensions, |
'extension_dir' => $extension_dir, |
'all' => $all, |
); |
} else { |
return PEAR::raiseError('php.ini "' . $filename . '" does not exist'); |
} |
return array( |
'extensions' => $extensions, |
'zend_extensions' => $zend_extensions, |
'extension_dir' => $extension_dir, |
'all' => $all, |
); |
} |
// {{{ doInstall() |
521,98 → 522,176 |
function doInstall($command, $options, $params) |
{ |
if (!class_exists('PEAR_PackageFile')) { |
require_once 'PEAR/PackageFile.php'; |
} |
if (isset($options['installroot']) && isset($options['packagingroot'])) { |
return $this->raiseError('ERROR: cannot use both --installroot and --packagingroot'); |
} |
$reg = &$this->config->getRegistry(); |
$channel = isset($options['channel']) ? $options['channel'] : $this->config->get('default_channel'); |
if (!$reg->channelExists($channel)) { |
return $this->raiseError('Channel "' . $channel . '" does not exist'); |
} |
if (empty($this->installer)) { |
$this->installer = &$this->getInstaller($this->ui); |
} |
if ($command == 'upgrade') { |
if ($command == 'upgrade' || $command == 'upgrade-all') { |
// If people run the upgrade command but pass nothing, emulate a upgrade-all |
if ($command == 'upgrade' && empty($params)) { |
return $this->doUpgradeAll($command, $options, $params); |
} |
$options['upgrade'] = true; |
} else { |
$packages = $params; |
} |
if (isset($options['installroot']) && isset($options['packagingroot'])) { |
return $this->raiseError('ERROR: cannot use both --installroot and --packagingroot'); |
$instreg = &$reg; // instreg used to check if package is installed |
if (isset($options['packagingroot']) && !isset($options['upgrade'])) { |
$packrootphp_dir = $this->installer->_prependPath( |
$this->config->get('php_dir', null, 'pear.php.net'), |
$options['packagingroot']); |
$metadata_dir = $this->config->get('metadata_dir', null, 'pear.php.net'); |
if ($metadata_dir) { |
$metadata_dir = $this->installer->_prependPath( |
$metadata_dir, |
$options['packagingroot']); |
} |
$instreg = new PEAR_Registry($packrootphp_dir, false, false, $metadata_dir); // other instreg! |
if ($this->config->get('verbose') > 2) { |
$this->ui->outputData('using package root: ' . $options['packagingroot']); |
} |
} |
if (isset($options['packagingroot']) && $this->config->get('verbose') > 2) { |
$this->ui->outputData('using package root: ' . $options['packagingroot']); |
} |
$reg = &$this->config->getRegistry(); |
if ($command == 'upgrade-all') { |
$options['upgrade'] = true; |
$reg = &$this->config->getRegistry(); |
$savechannel = $this->config->get('default_channel'); |
$params = array(); |
foreach ($reg->listChannels() as $channel) { |
if ($channel == '__uri') { |
$abstractpackages = $otherpackages = array(); |
// parse params |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
foreach ($params as $param) { |
if (strpos($param, 'http://') === 0) { |
$otherpackages[] = $param; |
continue; |
} |
if (strpos($param, 'channel://') === false && @file_exists($param)) { |
if (isset($options['force'])) { |
$otherpackages[] = $param; |
continue; |
} |
$this->config->set('default_channel', $channel); |
$chan = &$reg->getChannel($channel); |
if (PEAR::isError($chan)) { |
return $this->raiseError($chan); |
$pkg = new PEAR_PackageFile($this->config); |
$pf = $pkg->fromAnyFile($param, PEAR_VALIDATE_DOWNLOADING); |
if (PEAR::isError($pf)) { |
$otherpackages[] = $param; |
continue; |
} |
if ($chan->supportsREST($this->config->get('preferred_mirror')) && |
$base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) { |
$dorest = true; |
unset($remote); |
} else { |
$dorest = false; |
$remote = &$this->config->getRemote($this->config); |
} |
$state = $this->config->get('preferred_state'); |
$installed = array_flip($reg->listPackages($channel)); |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
if ($dorest) { |
$rest = &$this->config->getREST('1.0', array()); |
$latest = $rest->listLatestUpgrades($base, $state, $installed, $channel, $reg); |
} else { |
if (empty($state) || $state == 'any') { |
$latest = $remote->call("package.listLatestReleases"); |
} else { |
$latest = $remote->call("package.listLatestReleases", $state); |
$exists = $reg->packageExists($pf->getPackage(), $pf->getChannel()); |
$pversion = $reg->packageInfo($pf->getPackage(), 'version', $pf->getChannel()); |
$version_compare = version_compare($pf->getVersion(), $pversion, '<='); |
if ($exists && $version_compare) { |
if ($this->config->get('verbose')) { |
$this->ui->outputData('Ignoring installed package ' . |
$reg->parsedPackageNameToString( |
array('package' => $pf->getPackage(), |
'channel' => $pf->getChannel()), true)); |
} |
} |
PEAR::staticPopErrorHandling(); |
if (PEAR::isError($latest) || !is_array($latest)) { |
continue; |
} |
foreach ($latest as $package => $info) { |
$package = strtolower($package); |
if (!isset($installed[$package])) { |
// skip packages we don't have installed |
$otherpackages[] = $param; |
continue; |
} |
$e = $reg->parsePackageName($param, $channel); |
if (PEAR::isError($e)) { |
$otherpackages[] = $param; |
} else { |
$abstractpackages[] = $e; |
} |
} |
PEAR::staticPopErrorHandling(); |
// if there are any local package .tgz or remote static url, we can't |
// filter. The filter only works for abstract packages |
if (count($abstractpackages) && !isset($options['force'])) { |
// when not being forced, only do necessary upgrades/installs |
if (isset($options['upgrade'])) { |
$abstractpackages = $this->_filterUptodatePackages($abstractpackages, $command); |
} else { |
$count = count($abstractpackages); |
foreach ($abstractpackages as $i => $package) { |
if (isset($package['group'])) { |
// do not filter out install groups |
continue; |
} |
$inst_version = $reg->packageInfo($package, 'version', $channel); |
if (version_compare("$info[version]", "$inst_version", "le")) { |
// installed version is up-to-date |
continue; |
if ($instreg->packageExists($package['package'], $package['channel'])) { |
if ($count > 1) { |
if ($this->config->get('verbose')) { |
$this->ui->outputData('Ignoring installed package ' . |
$reg->parsedPackageNameToString($package, true)); |
} |
unset($abstractpackages[$i]); |
} elseif ($count === 1) { |
// Lets try to upgrade it since it's already installed |
$options['upgrade'] = true; |
} |
} |
$params[] = $a = $reg->parsedPackageNameToString(array('package' => $package, |
'channel' => $channel)); |
$this->ui->outputData(array('data' => "Will upgrade $a"), $command); |
} |
} |
$this->config->set('default_channel', $savechannel); |
$abstractpackages = |
array_map(array($reg, 'parsedPackageNameToString'), $abstractpackages); |
} elseif (count($abstractpackages)) { |
$abstractpackages = |
array_map(array($reg, 'parsedPackageNameToString'), $abstractpackages); |
} |
$packages = array_merge($abstractpackages, $otherpackages); |
if (!count($packages)) { |
$c = ''; |
if (isset($options['channel'])){ |
$c .= ' in channel "' . $options['channel'] . '"'; |
} |
$this->ui->outputData('Nothing to ' . $command . $c); |
return true; |
} |
$this->downloader = &$this->getDownloader($this->ui, $options, $this->config); |
$errors = array(); |
$downloaded = array(); |
$downloaded = &$this->downloader->download($params); |
$errors = $downloaded = $binaries = array(); |
$downloaded = &$this->downloader->download($packages); |
if (PEAR::isError($downloaded)) { |
return $this->raiseError($downloaded); |
} |
$errors = $this->downloader->getErrorMsgs(); |
if (count($errors)) { |
$err = array(); |
$err['data'] = array(); |
foreach ($errors as $error) { |
$err['data'][] = array($error); |
if ($error !== null) { |
$err['data'][] = array($error); |
} |
} |
$err['headline'] = 'Install Errors'; |
$this->ui->outputData($err); |
if (!empty($err['data'])) { |
$err['headline'] = 'Install Errors'; |
$this->ui->outputData($err); |
} |
if (!count($downloaded)) { |
return $this->raiseError("$command failed"); |
} |
} |
$data = array( |
'headline' => 'Packages that would be Installed' |
); |
if (isset($options['pretend'])) { |
foreach ($downloaded as $package) { |
$data['data'][] = array($reg->parsedPackageNameToString($package->getParsedPackage())); |
620,6 → 699,7 |
$this->ui->outputData($data, 'pretend'); |
return true; |
} |
$this->installer->setOptions($options); |
$this->installer->sortPackagesForInstall($downloaded); |
if (PEAR::isError($err = $this->installer->setDownloadedPackages($downloaded))) { |
626,15 → 706,8 |
$this->raiseError($err->getMessage()); |
return true; |
} |
$extrainfo = array(); |
if (isset($options['packagingroot'])) { |
$packrootphp_dir = $this->installer->_prependPath( |
$this->config->get('php_dir', null, 'pear.php.net'), |
$options['packagingroot']); |
$instreg = new PEAR_Registry($packrootphp_dir); |
} else { |
$instreg = $reg; |
} |
$binaries = $extrainfo = array(); |
foreach ($downloaded as $param) { |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$info = $this->installer->install($param, $options); |
647,39 → 720,50 |
$this->ui->outputData('ERROR: ' .$oldinfo->getMessage()); |
continue; |
} |
// we just installed a different package than requested, |
// let's change the param and info so that the rest of this works |
$param = $info[0]; |
$info = $info[1]; |
$info = $info[1]; |
} |
} |
if (is_array($info)) { |
if ($param->getPackageType() == 'extsrc' || |
$param->getPackageType() == 'extbin' || |
$param->getPackageType() == 'zendextsrc' || |
$param->getPackageType() == 'zendextbin') { |
$pkg = &$param->getPackageFile(); |
if ($instbin = $pkg->getInstalledBinary()) { |
$instpkg = &$instreg->getPackage($instbin, $pkg->getChannel()); |
} else { |
$instpkg = &$instreg->getPackage($pkg->getPackage(), $pkg->getChannel()); |
if (!is_array($info)) { |
return $this->raiseError("$command failed"); |
} |
if ($param->getPackageType() == 'extsrc' || |
$param->getPackageType() == 'extbin' || |
$param->getPackageType() == 'zendextsrc' || |
$param->getPackageType() == 'zendextbin' |
) { |
$pkg = &$param->getPackageFile(); |
if ($instbin = $pkg->getInstalledBinary()) { |
$instpkg = &$instreg->getPackage($instbin, $pkg->getChannel()); |
} else { |
$instpkg = &$instreg->getPackage($pkg->getPackage(), $pkg->getChannel()); |
} |
foreach ($instpkg->getFilelist() as $name => $atts) { |
$pinfo = pathinfo($atts['installed_as']); |
if (!isset($pinfo['extension']) || |
in_array($pinfo['extension'], array('c', 'h')) |
) { |
continue; // make sure we don't match php_blah.h |
} |
foreach ($instpkg->getFilelist() as $name => $atts) { |
$pinfo = pathinfo($atts['installed_as']); |
if (!isset($pinfo['extension']) || |
in_array($pinfo['extension'], array('c', 'h'))) { |
continue; // make sure we don't match php_blah.h |
} |
if ((strpos($pinfo['basename'], 'php_') === 0 && |
$pinfo['extension'] == 'dll') || |
// most unices |
$pinfo['extension'] == 'so' || |
// hp-ux |
$pinfo['extension'] == 'sl') { |
$binaries[] = array($atts['installed_as'], $pinfo); |
break; |
} |
if ((strpos($pinfo['basename'], 'php_') === 0 && |
$pinfo['extension'] == 'dll') || |
// most unices |
$pinfo['extension'] == 'so' || |
// hp-ux |
$pinfo['extension'] == 'sl') { |
$binaries[] = array($atts['installed_as'], $pinfo); |
break; |
} |
} |
if (count($binaries)) { |
foreach ($binaries as $pinfo) { |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$ret = $this->enableExtension(array($pinfo[0]), $param->getPackageType()); |
689,17 → 773,13 |
if ($param->getPackageType() == 'extsrc' || |
$param->getPackageType() == 'extbin') { |
$exttype = 'extension'; |
$extpath = $pinfo[1]['basename']; |
} else { |
ob_start(); |
phpinfo(INFO_GENERAL); |
$info = ob_get_contents(); |
ob_end_clean(); |
$debug = function_exists('leak') ? '_debug' : ''; |
$ts = preg_match('Thread Safety.+enabled', $info) ? '_ts' : ''; |
$exttype = 'zend_extension' . $debug . $ts; |
$exttype = 'zend_extension'; |
$extpath = $atts['installed_as']; |
} |
$extrainfo[] = 'You should add "' . $exttype . '=' . |
$pinfo[1]['basename'] . '" to php.ini'; |
$extpath . '" to php.ini'; |
} else { |
$extrainfo[] = 'Extension ' . $instpkg->getProvidesExtension() . |
' enabled in php.ini'; |
706,100 → 786,139 |
} |
} |
} |
if ($this->config->get('verbose') > 0) { |
$channel = $param->getChannel(); |
$label = $reg->parsedPackageNameToString( |
array( |
'channel' => $channel, |
'package' => $param->getPackage(), |
'version' => $param->getVersion(), |
)); |
$out = array('data' => "$command ok: $label"); |
if (isset($info['release_warnings'])) { |
$out['release_warnings'] = $info['release_warnings']; |
} |
$this->ui->outputData($out, $command); |
if (!isset($options['register-only']) && !isset($options['offline'])) { |
if ($this->config->isDefinedLayer('ftp')) { |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$info = $this->installer->ftpInstall($param); |
PEAR::staticPopErrorHandling(); |
if (PEAR::isError($info)) { |
$this->ui->outputData($info->getMessage()); |
$this->ui->outputData("remote install failed: $label"); |
} else { |
$this->ui->outputData("remote install ok: $label"); |
} |
} |
if ($this->config->get('verbose') > 0) { |
$chan = $param->getChannel(); |
$label = $reg->parsedPackageNameToString( |
array( |
'channel' => $chan, |
'package' => $param->getPackage(), |
'version' => $param->getVersion(), |
)); |
$out = array('data' => "$command ok: $label"); |
if (isset($info['release_warnings'])) { |
$out['release_warnings'] = $info['release_warnings']; |
} |
$this->ui->outputData($out, $command); |
if (!isset($options['register-only']) && !isset($options['offline'])) { |
if ($this->config->isDefinedLayer('ftp')) { |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$info = $this->installer->ftpInstall($param); |
PEAR::staticPopErrorHandling(); |
if (PEAR::isError($info)) { |
$this->ui->outputData($info->getMessage()); |
$this->ui->outputData("remote install failed: $label"); |
} else { |
$this->ui->outputData("remote install ok: $label"); |
} |
} |
} |
$deps = $param->getDeps(); |
if ($deps) { |
if (isset($deps['group'])) { |
$groups = $deps['group']; |
if (!isset($groups[0])) { |
$groups = array($groups); |
} |
$deps = $param->getDeps(); |
if ($deps) { |
if (isset($deps['group'])) { |
$groups = $deps['group']; |
if (!isset($groups[0])) { |
$groups = array($groups); |
} |
foreach ($groups as $group) { |
if ($group['attribs']['name'] == 'default') { |
// default group is always installed, unless the user |
// explicitly chooses to install another group |
continue; |
} |
foreach ($groups as $group) { |
if ($group['attribs']['name'] == 'default') { |
// default group is always installed, unless the user |
// explicitly chooses to install another group |
continue; |
} |
$this->ui->outputData($param->getPackage() . ': Optional feature ' . |
$group['attribs']['name'] . ' available (' . |
$group['attribs']['hint'] . ')'); |
} |
$extrainfo[] = 'To install use "pear install ' . |
$reg->parsedPackageNameToString( |
array('package' => $param->getPackage(), |
'channel' => $param->getChannel()), true) . |
'#featurename"'; |
$extrainfo[] = $param->getPackage() . ': Optional feature ' . |
$group['attribs']['name'] . ' available (' . |
$group['attribs']['hint'] . ')'; |
} |
$extrainfo[] = $param->getPackage() . |
': To install optional features use "pear install ' . |
$reg->parsedPackageNameToString( |
array('package' => $param->getPackage(), |
'channel' => $param->getChannel()), true) . |
'#featurename"'; |
} |
if (isset($options['installroot'])) { |
$reg = &$this->config->getRegistry(); |
} |
if (isset($options['packagingroot'])) { |
$instreg = new PEAR_Registry($packrootphp_dir); |
} else { |
$instreg = $reg; |
} |
$pkg = &$instreg->getPackage($param->getPackage(), $param->getChannel()); |
// $pkg may be NULL if install is a 'fake' install via --packagingroot |
if (is_object($pkg)) { |
$pkg->setConfig($this->config); |
if ($list = $pkg->listPostinstallScripts()) { |
$pn = $reg->parsedPackageNameToString(array('channel' => |
$param->getChannel(), 'package' => $param->getPackage()), true); |
$extrainfo[] = $pn . ' has post-install scripts:'; |
foreach ($list as $file) { |
$extrainfo[] = $file; |
} |
$extrainfo[] = 'Use "pear run-scripts ' . $pn . '" to run'; |
$extrainfo[] = 'DO NOT RUN SCRIPTS FROM UNTRUSTED SOURCES'; |
} |
$pkg = &$instreg->getPackage($param->getPackage(), $param->getChannel()); |
// $pkg may be NULL if install is a 'fake' install via --packagingroot |
if (is_object($pkg)) { |
$pkg->setConfig($this->config); |
if ($list = $pkg->listPostinstallScripts()) { |
$pn = $reg->parsedPackageNameToString(array('channel' => |
$param->getChannel(), 'package' => $param->getPackage()), true); |
$extrainfo[] = $pn . ' has post-install scripts:'; |
foreach ($list as $file) { |
$extrainfo[] = $file; |
} |
$extrainfo[] = $param->getPackage() . |
': Use "pear run-scripts ' . $pn . '" to finish setup.'; |
$extrainfo[] = 'DO NOT RUN SCRIPTS FROM UNTRUSTED SOURCES'; |
} |
} else { |
return $this->raiseError("$command failed"); |
} |
} |
if (count($extrainfo)) { |
foreach ($extrainfo as $info) { |
$this->ui->outputData($info); |
} |
} |
return true; |
} |
// }}} |
// {{{ doUpgradeAll() |
function doUpgradeAll($command, $options, $params) |
{ |
$reg = &$this->config->getRegistry(); |
$upgrade = array(); |
if (isset($options['channel'])) { |
$channels = array($options['channel']); |
} else { |
$channels = $reg->listChannels(); |
} |
foreach ($channels as $channel) { |
if ($channel == '__uri') { |
continue; |
} |
// parse name with channel |
foreach ($reg->listPackages($channel) as $name) { |
$upgrade[] = $reg->parsedPackageNameToString(array( |
'channel' => $channel, |
'package' => $name |
)); |
} |
} |
$err = $this->doInstall($command, $options, $upgrade); |
if (PEAR::isError($err)) { |
$this->ui->outputData($err->getMessage(), $command); |
} |
} |
// }}} |
// {{{ doUninstall() |
function doUninstall($command, $options, $params) |
{ |
if (count($params) < 1) { |
return $this->raiseError("Please supply the package(s) you want to uninstall"); |
} |
if (empty($this->installer)) { |
$this->installer = &$this->getInstaller($this->ui); |
} |
if (isset($options['remoteconfig'])) { |
$e = $this->config->readFTPConfigFile($options['remoteconfig']); |
if (!PEAR::isError($e)) { |
806,11 → 925,10 |
$this->installer->setConfig($this->config); |
} |
} |
if (sizeof($params) < 1) { |
return $this->raiseError("Please supply the package(s) you want to uninstall"); |
} |
$reg = &$this->config->getRegistry(); |
$newparams = array(); |
$binaries = array(); |
$badparams = array(); |
foreach ($params as $pkg) { |
$channel = $this->config->get('default_channel'); |
849,7 → 967,7 |
if (isset($parsed['group'])) { |
$group = $info->getDependencyGroup($parsed['group']); |
if ($group) { |
$installed = &$reg->getInstalledGroup($group); |
$installed = $reg->getInstalledGroup($group); |
if ($installed) { |
foreach ($installed as $i => $p) { |
$newparams[] = &$installed[$i]; |
869,6 → 987,7 |
// for circular dependencies like subpackages |
$this->installer->setUninstallPackages($newparams); |
$params = array_merge($params, $badparams); |
$binaries = array(); |
foreach ($params as $pkg) { |
$this->installer->pushErrorHandling(PEAR_ERROR_RETURN); |
if ($err = $this->installer->uninstall($pkg, $options)) { |
884,6 → 1003,7 |
if ($instbin = $pkg->getInstalledBinary()) { |
continue; // this will be uninstalled later |
} |
foreach ($pkg->getFilelist() as $name => $atts) { |
$pinfo = pathinfo($atts['installed_as']); |
if (!isset($pinfo['extension']) || |
900,29 → 1020,31 |
break; |
} |
} |
foreach ($binaries as $pinfo) { |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$ret = $this->disableExtension(array($pinfo[0]), $pkg->getPackageType()); |
PEAR::staticPopErrorHandling(); |
if (PEAR::isError($ret)) { |
$extrainfo[] = $ret->getMessage(); |
if ($pkg->getPackageType() == 'extsrc' || |
$pkg->getPackageType() == 'extbin') { |
$exttype = 'extension'; |
if (count($binaries)) { |
foreach ($binaries as $pinfo) { |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$ret = $this->disableExtension(array($pinfo[0]), $pkg->getPackageType()); |
PEAR::staticPopErrorHandling(); |
if (PEAR::isError($ret)) { |
$extrainfo[] = $ret->getMessage(); |
if ($pkg->getPackageType() == 'extsrc' || |
$pkg->getPackageType() == 'extbin') { |
$exttype = 'extension'; |
} else { |
ob_start(); |
phpinfo(INFO_GENERAL); |
$info = ob_get_contents(); |
ob_end_clean(); |
$debug = function_exists('leak') ? '_debug' : ''; |
$ts = preg_match('/Thread Safety.+enabled/', $info) ? '_ts' : ''; |
$exttype = 'zend_extension' . $debug . $ts; |
} |
$this->ui->outputData('Unable to remove "' . $exttype . '=' . |
$pinfo[1]['basename'] . '" from php.ini', $command); |
} else { |
ob_start(); |
phpinfo(INFO_GENERAL); |
$info = ob_get_contents(); |
ob_end_clean(); |
$debug = function_exists('leak') ? '_debug' : ''; |
$ts = preg_match('Thread Safety.+enabled', $info) ? '_ts' : ''; |
$exttype = 'zend_extension' . $debug . $ts; |
$this->ui->outputData('Extension ' . $pkg->getProvidesExtension() . |
' disabled in php.ini', $command); |
} |
$this->ui->outputData('Unable to remove "' . $exttype . '=' . |
$pinfo[1]['basename'] . '" from php.ini', $command); |
} else { |
$this->ui->outputData('Extension ' . $pkg->getProvidesExtension() . |
' disabled in php.ini', $command); |
} |
} |
} |
949,12 → 1071,13 |
} |
} else { |
$this->installer->popErrorHandling(); |
if (is_object($pkg)) { |
$pkg = $reg->parsedPackageNameToString($pkg); |
if (!is_object($pkg)) { |
return $this->raiseError("uninstall failed: $pkg"); |
} |
return $this->raiseError("uninstall failed: $pkg"); |
$pkg = $reg->parsedPackageNameToString($pkg); |
} |
} |
return true; |
} |
970,10 → 1093,15 |
function doBundle($command, $options, $params) |
{ |
$downloader = &$this->getDownloader($this->ui, array('force' => true, 'nodeps' => true, |
'soft' => true, 'downloadonly' => true), $this->config); |
$opts = array( |
'force' => true, |
'nodeps' => true, |
'soft' => true, |
'downloadonly' => true |
); |
$downloader = &$this->getDownloader($this->ui, $opts, $this->config); |
$reg = &$this->config->getRegistry(); |
if (sizeof($params) < 1) { |
if (count($params) < 1) { |
return $this->raiseError("Please supply the package you want to bundle"); |
} |
983,18 → 1111,24 |
} |
$dest = realpath($options['destination']); |
} else { |
$pwd = getcwd(); |
if (is_dir($pwd . DIRECTORY_SEPARATOR . 'ext')) { |
$dest = $pwd . DIRECTORY_SEPARATOR . 'ext'; |
} else { |
$dest = $pwd; |
} |
$pwd = getcwd(); |
$dir = $pwd . DIRECTORY_SEPARATOR . 'ext'; |
$dest = is_dir($dir) ? $dir : $pwd; |
} |
$downloader->setDownloadDir($dest); |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$err = $downloader->setDownloadDir($dest); |
PEAR::staticPopErrorHandling(); |
if (PEAR::isError($err)) { |
return PEAR::raiseError('download directory "' . $dest . |
'" is not writeable.'); |
} |
$result = &$downloader->download(array($params[0])); |
if (PEAR::isError($result)) { |
return $result; |
} |
if (!isset($result[0])) { |
return $this->raiseError('unable to unpack ' . $params[0]); |
} |
$pkgfile = &$result[0]->getPackageFile(); |
$pkgname = $pkgfile->getName(); |
$pkgversion = $pkgfile->getVersion(); |
1003,7 → 1137,7 |
$dest .= DIRECTORY_SEPARATOR . $pkgname; |
$orig = $pkgname . '-' . $pkgversion; |
$tar = &new Archive_Tar($pkgfile->getArchiveFile()); |
$tar = new Archive_Tar($pkgfile->getArchiveFile()); |
if (!$tar->extractModify($dest, $orig)) { |
return $this->raiseError('unable to unpack ' . $pkgfile->getArchiveFile()); |
} |
1018,6 → 1152,7 |
if (!isset($params[0])) { |
return $this->raiseError('run-scripts expects 1 parameter: a package name'); |
} |
$reg = &$this->config->getRegistry(); |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$parsed = $reg->parsePackageName($params[0], $this->config->get('default_channel')); |
1025,15 → 1160,110 |
if (PEAR::isError($parsed)) { |
return $this->raiseError($parsed); |
} |
$package = &$reg->getPackage($parsed['package'], $parsed['channel']); |
if (is_object($package)) { |
$package->setConfig($this->config); |
$package->runPostinstallScripts(); |
} else { |
if (!is_object($package)) { |
return $this->raiseError('Could not retrieve package "' . $params[0] . '" from registry'); |
} |
$package->setConfig($this->config); |
$package->runPostinstallScripts(); |
$this->ui->outputData('Install scripts complete', $command); |
return true; |
} |
/** |
* Given a list of packages, filter out those ones that are already up to date |
* |
* @param $packages: packages, in parsed array format ! |
* @return list of packages that can be upgraded |
*/ |
function _filterUptodatePackages($packages, $command) |
{ |
$reg = &$this->config->getRegistry(); |
$latestReleases = array(); |
$ret = array(); |
foreach ($packages as $package) { |
if (isset($package['group'])) { |
$ret[] = $package; |
continue; |
} |
$channel = $package['channel']; |
$name = $package['package']; |
if (!$reg->packageExists($name, $channel)) { |
$ret[] = $package; |
continue; |
} |
if (!isset($latestReleases[$channel])) { |
// fill in cache for this channel |
$chan = $reg->getChannel($channel); |
if (PEAR::isError($chan)) { |
return $this->raiseError($chan); |
} |
$base2 = false; |
$preferred_mirror = $this->config->get('preferred_mirror', null, $channel); |
if ($chan->supportsREST($preferred_mirror) && |
( |
//($base2 = $chan->getBaseURL('REST1.4', $preferred_mirror)) || |
($base = $chan->getBaseURL('REST1.0', $preferred_mirror)) |
) |
) { |
$dorest = true; |
} |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
if (!isset($package['state'])) { |
$state = $this->config->get('preferred_state', null, $channel); |
} else { |
$state = $package['state']; |
} |
if ($dorest) { |
if ($base2) { |
$rest = &$this->config->getREST('1.4', array()); |
$base = $base2; |
} else { |
$rest = &$this->config->getREST('1.0', array()); |
} |
$installed = array_flip($reg->listPackages($channel)); |
$latest = $rest->listLatestUpgrades($base, $state, $installed, $channel, $reg); |
} |
PEAR::staticPopErrorHandling(); |
if (PEAR::isError($latest)) { |
$this->ui->outputData('Error getting channel info from ' . $channel . |
': ' . $latest->getMessage()); |
continue; |
} |
$latestReleases[$channel] = array_change_key_case($latest); |
} |
// check package for latest release |
$name_lower = strtolower($name); |
if (isset($latestReleases[$channel][$name_lower])) { |
// if not set, up to date |
$inst_version = $reg->packageInfo($name, 'version', $channel); |
$channel_version = $latestReleases[$channel][$name_lower]['version']; |
if (version_compare($channel_version, $inst_version, 'le')) { |
// installed version is up-to-date |
continue; |
} |
// maintain BC |
if ($command == 'upgrade-all') { |
$this->ui->outputData(array('data' => 'Will upgrade ' . |
$reg->parsedPackageNameToString($package)), $command); |
} |
$ret[] = $package; |
} |
} |
return $ret; |
} |
} |
?> |
/trunk/bibliotheque/pear/PEAR/Command/Pickle.php |
---|
4,18 → 4,11 |
* |
* 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 2005-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version CVS: $Id: Pickle.php,v 1.6 2006/05/12 02:38:58 cellog Exp $ |
* @copyright 2005-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.4.1 |
*/ |
31,9 → 24,9 |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 2005-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.5.1 |
* @copyright 2005-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 1.4.1 |
*/ |
82,12 → 75,11 |
* |
* @access public |
*/ |
function PEAR_Command_Pickle(&$ui, &$config) |
function __construct(&$ui, &$config) |
{ |
parent::PEAR_Command_Common($ui, $config); |
parent::__construct($ui, $config); |
} |
/** |
* For unit-testing ease |
* |
98,7 → 90,8 |
if (!class_exists('PEAR_Packager')) { |
require_once 'PEAR/Packager.php'; |
} |
$a = &new PEAR_Packager; |
$a = new PEAR_Packager; |
return $a; |
} |
110,15 → 103,17 |
* @param string|null $tmpdir |
* @return PEAR_PackageFile |
*/ |
function &getPackageFile($config, $debug = false, $tmpdir = null) |
function &getPackageFile($config, $debug = false) |
{ |
if (!class_exists('PEAR_Common')) { |
require_once 'PEAR/Common.php'; |
} |
if (!class_exists('PEAR/PackageFile.php')) { |
if (!class_exists('PEAR_PackageFile')) { |
require_once 'PEAR/PackageFile.php'; |
} |
$a = &new PEAR_PackageFile($config, $debug, $tmpdir); |
$a = new PEAR_PackageFile($config, $debug); |
$common = new PEAR_Common; |
$common->ui = $this->ui; |
$a->setLogger($common); |
133,15 → 128,18 |
if (PEAR::isError($err = $this->_convertPackage($pkginfofile))) { |
return $err; |
} |
$compress = empty($options['nocompress']) ? true : false; |
$result = $packager->package($pkginfofile, $compress, 'package.xml'); |
if (PEAR::isError($result)) { |
return $this->raiseError($result); |
} |
// Don't want output, only the package file name just created |
if (isset($options['showname'])) { |
$this->ui->outputData($result, $command); |
} |
return true; |
} |
153,6 → 151,7 |
return $this->raiseError('Cannot process "' . |
$packagexml . '", is not a package.xml 2.0'); |
} |
require_once 'PEAR/PackageFile/v1.php'; |
$pf = new PEAR_PackageFile_v1; |
$pf->setConfig($this->config); |
161,16 → 160,19 |
'", is not an extension source package. Using a PEAR_PackageFileManager-based ' . |
'script is an option'); |
} |
if (is_array($pf2->getUsesRole())) { |
return $this->raiseError('Cannot safely convert "' . $packagexml . |
'", contains custom roles. Using a PEAR_PackageFileManager-based script or ' . |
'the convert command is an option'); |
} |
if (is_array($pf2->getUsesTask())) { |
return $this->raiseError('Cannot safely convert "' . $packagexml . |
'", contains custom tasks. Using a PEAR_PackageFileManager-based script or ' . |
'the convert command is an option'); |
} |
$deps = $pf2->getDependencies(); |
if (isset($deps['group'])) { |
return $this->raiseError('Cannot safely convert "' . $packagexml . |
177,6 → 179,7 |
'", contains dependency groups. Using a PEAR_PackageFileManager-based script ' . |
'or the convert command is an option'); |
} |
if (isset($deps['required']['subpackage']) || |
isset($deps['optional']['subpackage'])) { |
return $this->raiseError('Cannot safely convert "' . $packagexml . |
183,16 → 186,19 |
'", contains subpackage dependencies. Using a PEAR_PackageFileManager-based '. |
'script is an option'); |
} |
if (isset($deps['required']['os'])) { |
return $this->raiseError('Cannot safely convert "' . $packagexml . |
'", contains os dependencies. Using a PEAR_PackageFileManager-based '. |
'script is an option'); |
} |
if (isset($deps['required']['arch'])) { |
return $this->raiseError('Cannot safely convert "' . $packagexml . |
'", contains arch dependencies. Using a PEAR_PackageFileManager-based '. |
'script is an option'); |
} |
$pf->setPackage($pf2->getPackage()); |
$pf->setSummary($pf2->getSummary()); |
$pf->setDescription($pf2->getDescription()); |
200,6 → 206,7 |
$pf->addMaintainer($maintainer['role'], $maintainer['handle'], |
$maintainer['name'], $maintainer['email']); |
} |
$pf->setVersion($pf2->getVersion()); |
$pf->setDate($pf2->getDate()); |
$pf->setLicense($pf2->getLicense()); |
209,10 → 216,12 |
if (isset($deps['required']['php']['max'])) { |
$pf->addPhpDep($deps['required']['php']['max'], 'le'); |
} |
if (isset($deps['required']['package'])) { |
if (!isset($deps['required']['package'][0])) { |
$deps['required']['package'] = array($deps['required']['package']); |
} |
foreach ($deps['required']['package'] as $dep) { |
if (!isset($dep['channel'])) { |
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . |
219,31 → 228,40 |
' contains uri-based dependency on a package. Using a ' . |
'PEAR_PackageFileManager-based script is an option'); |
} |
if ($dep['channel'] != 'pear.php.net' && $dep['channel'] != 'pecl.php.net') { |
if ($dep['channel'] != 'pear.php.net' |
&& $dep['channel'] != 'pecl.php.net' |
&& $dep['channel'] != 'doc.php.net') { |
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . |
' contains dependency on a non-standard channel package. Using a ' . |
'PEAR_PackageFileManager-based script is an option'); |
} |
if (isset($dep['conflicts'])) { |
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . |
' contains conflicts dependency. Using a ' . |
'PEAR_PackageFileManager-based script is an option'); |
} |
if (isset($dep['exclude'])) { |
$this->ui->outputData('WARNING: exclude tags are ignored in conversion'); |
} |
if (isset($dep['min'])) { |
$pf->addPackageDep($dep['name'], $dep['min'], 'ge'); |
} |
if (isset($dep['max'])) { |
$pf->addPackageDep($dep['name'], $dep['max'], 'le'); |
} |
} |
} |
if (isset($deps['required']['extension'])) { |
if (!isset($deps['required']['extension'][0])) { |
$deps['required']['extension'] = array($deps['required']['extension']); |
} |
foreach ($deps['required']['extension'] as $dep) { |
if (isset($dep['conflicts'])) { |
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . |
250,21 → 268,26 |
' contains conflicts dependency. Using a ' . |
'PEAR_PackageFileManager-based script is an option'); |
} |
if (isset($dep['exclude'])) { |
$this->ui->outputData('WARNING: exclude tags are ignored in conversion'); |
} |
if (isset($dep['min'])) { |
$pf->addExtensionDep($dep['name'], $dep['min'], 'ge'); |
} |
if (isset($dep['max'])) { |
$pf->addExtensionDep($dep['name'], $dep['max'], 'le'); |
} |
} |
} |
if (isset($deps['optional']['package'])) { |
if (!isset($deps['optional']['package'][0])) { |
$deps['optional']['package'] = array($deps['optional']['package']); |
} |
foreach ($deps['optional']['package'] as $dep) { |
if (!isset($dep['channel'])) { |
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . |
271,72 → 294,90 |
' contains uri-based dependency on a package. Using a ' . |
'PEAR_PackageFileManager-based script is an option'); |
} |
if ($dep['channel'] != 'pear.php.net' && $dep['channel'] != 'pecl.php.net') { |
if ($dep['channel'] != 'pear.php.net' |
&& $dep['channel'] != 'pecl.php.net' |
&& $dep['channel'] != 'doc.php.net') { |
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . |
' contains dependency on a non-standard channel package. Using a ' . |
'PEAR_PackageFileManager-based script is an option'); |
} |
if (isset($dep['exclude'])) { |
$this->ui->outputData('WARNING: exclude tags are ignored in conversion'); |
} |
if (isset($dep['min'])) { |
$pf->addPackageDep($dep['name'], $dep['min'], 'ge', 'yes'); |
} |
if (isset($dep['max'])) { |
$pf->addPackageDep($dep['name'], $dep['max'], 'le', 'yes'); |
} |
} |
} |
if (isset($deps['optional']['extension'])) { |
if (!isset($deps['optional']['extension'][0])) { |
$deps['optional']['extension'] = array($deps['optional']['extension']); |
} |
foreach ($deps['optional']['extension'] as $dep) { |
if (isset($dep['exclude'])) { |
$this->ui->outputData('WARNING: exclude tags are ignored in conversion'); |
} |
if (isset($dep['min'])) { |
$pf->addExtensionDep($dep['name'], $dep['min'], 'ge', 'yes'); |
} |
if (isset($dep['max'])) { |
$pf->addExtensionDep($dep['name'], $dep['max'], 'le', 'yes'); |
} |
} |
} |
$contents = $pf2->getContents(); |
$release = $pf2->getReleases(); |
$release = $pf2->getReleases(); |
if (isset($releases[0])) { |
return $this->raiseError('Cannot safely process "' . $packagexml . '" contains ' |
return $this->raiseError('Cannot safely process "' . $packagexml . '" contains ' |
. 'multiple extsrcrelease/zendextsrcrelease tags. Using a PEAR_PackageFileManager-based script ' . |
'or the convert command is an option'); |
} |
if ($configoptions = $pf2->getConfigureOptions()) { |
foreach ($configoptions as $option) { |
$pf->addConfigureOption($option['name'], $option['prompt'], |
isset($option['default']) ? $option['default'] : false); |
$default = isset($option['default']) ? $option['default'] : false; |
$pf->addConfigureOption($option['name'], $option['prompt'], $default); |
} |
} |
if (isset($release['filelist']['ignore'])) { |
return $this->raiseError('Cannot safely process "' . $packagexml . '" contains ' |
return $this->raiseError('Cannot safely process "' . $packagexml . '" contains ' |
. 'ignore tags. Using a PEAR_PackageFileManager-based script or the convert' . |
' command is an option'); |
} |
if (isset($release['filelist']['install']) && |
!isset($release['filelist']['install'][0])) { |
$release['filelist']['install'] = array($release['filelist']['install']); |
} |
if (isset($contents['dir']['attribs']['baseinstalldir'])) { |
$baseinstalldir = $contents['dir']['attribs']['baseinstalldir']; |
} else { |
$baseinstalldir = false; |
} |
if (!isset($contents['dir']['file'][0])) { |
$contents['dir']['file'] = array($contents['dir']['file']); |
} |
foreach ($contents['dir']['file'] as $file) { |
if ($baseinstalldir && !isset($file['attribs']['baseinstalldir'])) { |
$file['attribs']['baseinstalldir'] = $baseinstalldir; |
} |
$processFile = $file; |
unset($processFile['attribs']); |
if (count($processFile)) { |
349,11 → 390,13 |
$file['attribs']['replace'][] = $task; |
} |
} |
if (!in_array($file['attribs']['role'], PEAR_Common::getFileRoles())) { |
return $this->raiseError('Cannot safely convert "' . $packagexml . |
'", contains custom roles. Using a PEAR_PackageFileManager-based script ' . |
'or the convert command is an option'); |
} |
if (isset($release['filelist']['install'])) { |
foreach ($release['filelist']['install'] as $installas) { |
if ($installas['attribs']['name'] == $file['attribs']['name']) { |
361,16 → 404,17 |
} |
} |
} |
$pf->addFile('/', $file['attribs']['name'], $file['attribs']); |
} |
if ($pf2->getChangeLog()) { |
$this->ui->outputData('WARNING: changelog is not translated to package.xml ' . |
'1.0, use PEAR_PackageFileManager-based script if you need changelog-' . |
'translation for package.xml 1.0'); |
} |
$gen = &$pf->getDefaultGenerator(); |
$gen->toPackageFile('.'); |
} |
} |
?> |
/trunk/bibliotheque/pear/PEAR/Command/Registry.php |
---|
4,19 → 4,12 |
* |
* 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 Stig Bakken <ssb@php.net> |
* @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: Registry.php,v 1.75 2006/11/19 23:50:09 cellog Exp $ |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 0.1 |
*/ |
33,16 → 26,14 |
* @package PEAR |
* @author Stig Bakken <ssb@php.net> |
* @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: 1.5.1 |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 0.1 |
*/ |
class PEAR_Command_Registry extends PEAR_Command_Common |
{ |
// {{{ properties |
var $commands = array( |
'list' => array( |
'summary' => 'List Installed Packages In The Default Channel', |
58,6 → 49,10 |
'shortopt' => 'a', |
'doc' => 'list installed packages from all channels', |
), |
'channelinfo' => array( |
'shortopt' => 'i', |
'doc' => 'output fully channel-aware data, even on failure', |
), |
), |
'doc' => '<package> |
If invoked without parameters, this command lists the PEAR packages |
97,23 → 92,16 |
) |
); |
// }}} |
// {{{ constructor |
/** |
* PEAR_Command_Registry constructor. |
* |
* @access public |
*/ |
function PEAR_Command_Registry(&$ui, &$config) |
function __construct(&$ui, &$config) |
{ |
parent::PEAR_Command_Common($ui, $config); |
parent::__construct($ui, $config); |
} |
// }}} |
// {{{ doList() |
function _sortinfo($a, $b) |
{ |
$apackage = isset($a['package']) ? $a['package'] : $a['name']; |
123,67 → 111,131 |
function doList($command, $options, $params) |
{ |
if (isset($options['allchannels'])) { |
$reg = &$this->config->getRegistry(); |
$channelinfo = isset($options['channelinfo']); |
if (isset($options['allchannels']) && !$channelinfo) { |
return $this->doListAll($command, array(), $params); |
} |
$reg = &$this->config->getRegistry(); |
if (count($params) == 1) { |
if (isset($options['allchannels']) && $channelinfo) { |
// allchannels with $channelinfo |
unset($options['allchannels']); |
$channels = $reg->getChannels(); |
$errors = array(); |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
foreach ($channels as $channel) { |
$options['channel'] = $channel->getName(); |
$ret = $this->doList($command, $options, $params); |
if (PEAR::isError($ret)) { |
$errors[] = $ret; |
} |
} |
PEAR::staticPopErrorHandling(); |
if (count($errors)) { |
// for now, only give first error |
return PEAR::raiseError($errors[0]); |
} |
return true; |
} |
if (count($params) === 1) { |
return $this->doFileList($command, $options, $params); |
} |
if (isset($options['channel'])) { |
if ($reg->channelExists($options['channel'])) { |
$channel = $reg->channelName($options['channel']); |
} else { |
if (!$reg->channelExists($options['channel'])) { |
return $this->raiseError('Channel "' . $options['channel'] .'" does not exist'); |
} |
$channel = $reg->channelName($options['channel']); |
} else { |
$channel = $this->config->get('default_channel'); |
} |
$installed = $reg->packageInfo(null, null, $channel); |
usort($installed, array(&$this, '_sortinfo')); |
$i = $j = 0; |
$data = array( |
'caption' => 'Installed packages, channel ' . |
$channel . ':', |
'border' => true, |
'headline' => array('Package', 'Version', 'State') |
'headline' => array('Package', 'Version', 'State'), |
'channel' => $channel, |
); |
if ($channelinfo) { |
$data['headline'] = array('Channel', 'Package', 'Version', 'State'); |
} |
if (count($installed) && !isset($data['data'])) { |
$data['data'] = array(); |
} |
foreach ($installed as $package) { |
$pobj = $reg->getPackage(isset($package['package']) ? |
$package['package'] : $package['name'], $channel); |
$data['data'][] = array($pobj->getPackage(), $pobj->getVersion(), |
if ($channelinfo) { |
$packageinfo = array($pobj->getChannel(), $pobj->getPackage(), $pobj->getVersion(), |
$pobj->getState() ? $pobj->getState() : null); |
} else { |
$packageinfo = array($pobj->getPackage(), $pobj->getVersion(), |
$pobj->getState() ? $pobj->getState() : null); |
} |
$data['data'][] = $packageinfo; |
} |
if (count($installed)==0) { |
$data = '(no packages installed from channel ' . $channel . ')'; |
if (count($installed) === 0) { |
if (!$channelinfo) { |
$data = '(no packages installed from channel ' . $channel . ')'; |
} else { |
$data = array( |
'caption' => 'Installed packages, channel ' . |
$channel . ':', |
'border' => true, |
'channel' => $channel, |
'data' => array(array('(no packages installed)')), |
); |
} |
} |
$this->ui->outputData($data, $command); |
return true; |
} |
function doListAll($command, $options, $params) |
{ |
// This duplicate code is deprecated over |
// list --channelinfo, which gives identical |
// output for list and list --allchannels. |
$reg = &$this->config->getRegistry(); |
$installed = $reg->packageInfo(null, null, null); |
foreach ($installed as $channel => $packages) { |
usort($packages, array($this, '_sortinfo')); |
$i = $j = 0; |
$data = array( |
'caption' => 'Installed packages, channel ' . $channel . ':', |
'border' => true, |
'headline' => array('Package', 'Version', 'State') |
); |
'caption' => 'Installed packages, channel ' . $channel . ':', |
'border' => true, |
'headline' => array('Package', 'Version', 'State'), |
'channel' => $channel |
); |
foreach ($packages as $package) { |
$pobj = $reg->getPackage(isset($package['package']) ? |
$package['package'] : $package['name'], $channel); |
$p = isset($package['package']) ? $package['package'] : $package['name']; |
$pobj = $reg->getPackage($p, $channel); |
$data['data'][] = array($pobj->getPackage(), $pobj->getVersion(), |
$pobj->getState() ? $pobj->getState() : null); |
} |
if (count($packages)==0) { |
// Adds a blank line after each section |
$data['data'][] = array(); |
if (count($packages) === 0) { |
$data = array( |
'caption' => 'Installed packages, channel ' . $channel . ':', |
'border' => true, |
'data' => array(array('(no packages installed)')), |
'data' => array(array('(no packages installed)'), array()), |
'channel' => $channel |
); |
} |
$this->ui->outputData($data, $command); |
190,23 → 242,25 |
} |
return true; |
} |
function doFileList($command, $options, $params) |
{ |
if (count($params) != 1) { |
if (count($params) !== 1) { |
return $this->raiseError('list-files expects 1 parameter'); |
} |
$reg = &$this->config->getRegistry(); |
$fp = false; |
if (!is_dir($params[0]) && (file_exists($params[0]) || $fp = @fopen($params[0], |
'r'))) { |
if (!is_dir($params[0]) && (file_exists($params[0]) || $fp = @fopen($params[0], 'r'))) { |
if ($fp) { |
fclose($fp); |
} |
if (!class_exists('PEAR_PackageFile')) { |
require_once 'PEAR/PackageFile.php'; |
} |
$pkg = &new PEAR_PackageFile($this->config, $this->_debug); |
$pkg = new PEAR_PackageFile($this->config, $this->_debug); |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$info = &$pkg->fromAnyFile($params[0], PEAR_VALIDATE_NORMAL); |
PEAR::staticPopErrorHandling(); |
219,16 → 273,20 |
if (PEAR::isError($parsed)) { |
return $this->raiseError($parsed); |
} |
$info = &$reg->getPackage($parsed['package'], $parsed['channel']); |
$headings = array('Type', 'Install Path'); |
$installed = true; |
} |
if (PEAR::isError($info)) { |
return $this->raiseError($info); |
} |
if ($info === null) { |
return $this->raiseError("`$params[0]' not installed"); |
} |
$list = ($info->getPackagexmlVersion() == '1.0' || $installed) ? |
$info->getFilelist() : $info->getContents(); |
if ($installed) { |
236,6 → 294,7 |
} else { |
$caption = 'Contents of ' . basename($params[0]); |
} |
$data = array( |
'caption' => $caption, |
'border' => true, |
285,6 → 344,7 |
if (!isset($list['dir']['file'][0])) { |
$list['dir']['file'] = array($list['dir']['file']); |
} |
foreach ($list['dir']['file'] as $att) { |
$att = $att['attribs']; |
$file = $att['name']; |
303,18 → 363,17 |
$data['data'][] = array($file, $dest); |
} |
} |
$this->ui->outputData($data, $command); |
return true; |
} |
// }}} |
// {{{ doShellTest() |
function doShellTest($command, $options, $params) |
{ |
if (count($params) < 1) { |
return PEAR::raiseError('ERROR, usage: pear shell-test packagename [[relation] version]'); |
} |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$reg = &$this->config->getRegistry(); |
$info = $reg->parsePackageName($params[0], $this->config->get('default_channel')); |
321,6 → 380,7 |
if (PEAR::isError($info)) { |
exit(1); // invalid package name |
} |
$package = $info['package']; |
$channel = $info['channel']; |
// "pear shell-test Foo" |
331,18 → 391,19 |
} |
} |
} |
if (sizeof($params) == 1) { |
if (count($params) === 1) { |
if (!$reg->packageExists($package, $channel)) { |
exit(1); |
} |
// "pear shell-test Foo 1.0" |
} elseif (sizeof($params) == 2) { |
} elseif (count($params) === 2) { |
$v = $reg->packageInfo($package, 'version', $channel); |
if (!$v || !version_compare("$v", "{$params[1]}", "ge")) { |
exit(1); |
} |
// "pear shell-test Foo ge 1.0" |
} elseif (sizeof($params) == 3) { |
} elseif (count($params) === 3) { |
$v = $reg->packageInfo($package, 'version', $channel); |
if (!$v || !version_compare("$v", "{$params[2]}", $params[1])) { |
exit(1); |
354,24 → 415,26 |
} |
} |
// }}} |
// {{{ doInfo |
function doInfo($command, $options, $params) |
{ |
if (count($params) != 1) { |
if (count($params) !== 1) { |
return $this->raiseError('pear info expects 1 parameter'); |
} |
$info = $fp = false; |
$reg = &$this->config->getRegistry(); |
if ((file_exists($params[0]) && is_file($params[0]) && !is_dir($params[0])) || $fp = @fopen($params[0], 'r')) { |
if (is_file($params[0]) && !is_dir($params[0]) && |
(file_exists($params[0]) || $fp = @fopen($params[0], 'r')) |
) { |
if ($fp) { |
fclose($fp); |
} |
if (!class_exists('PEAR_PackageFile')) { |
require_once 'PEAR/PackageFile.php'; |
} |
$pkg = &new PEAR_PackageFile($this->config, $this->_debug); |
$pkg = new PEAR_PackageFile($this->config, $this->_debug); |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$obj = &$pkg->fromAnyFile($params[0], PEAR_VALIDATE_NORMAL); |
PEAR::staticPopErrorHandling(); |
385,18 → 448,21 |
$this->ui->outputData($message); |
} |
} |
return $this->raiseError($obj); |
} |
if ($obj->getPackagexmlVersion() == '1.0') { |
$info = $obj->toArray(); |
} else { |
if ($obj->getPackagexmlVersion() != '1.0') { |
return $this->_doInfo2($command, $options, $params, $obj, false); |
} |
$info = $obj->toArray(); |
} else { |
$parsed = $reg->parsePackageName($params[0], $this->config->get('default_channel')); |
if (PEAR::isError($parsed)) { |
return $this->raiseError($parsed); |
} |
$package = $parsed['package']; |
$channel = $parsed['channel']; |
$info = $reg->packageInfo($package, null, $channel); |
405,13 → 471,16 |
return $this->_doInfo2($command, $options, $params, $obj, true); |
} |
} |
if (PEAR::isError($info)) { |
return $info; |
} |
if (empty($info)) { |
$this->raiseError("No information found for `$params[0]'"); |
return; |
} |
unset($info['filelist']); |
unset($info['dirtree']); |
unset($info['changelog']); |
419,10 → 488,12 |
$info['package.xml version'] = $info['xsdversion']; |
unset($info['xsdversion']); |
} |
if (isset($info['packagerversion'])) { |
$info['packaged with PEAR version'] = $info['packagerversion']; |
unset($info['packagerversion']); |
} |
$keys = array_keys($info); |
$longtext = array('description', 'summary'); |
foreach ($keys as $key) { |
527,6 → 598,7 |
} |
} |
} |
if ($key == '_lastmodified') { |
$hdate = date('Y-m-d', $info[$key]); |
unset($info[$key]); |
541,6 → 613,7 |
} |
} |
} |
$caption = 'About ' . $info['package'] . '-' . $info['version']; |
$data = array( |
'caption' => $caption, |
554,8 → 627,6 |
$this->ui->outputData($data, 'package-info'); |
} |
// }}} |
/** |
* @access private |
*/ |
593,6 → 664,7 |
if ($src = $obj->getSourcePackage()) { |
$extends .= ' (source package ' . $src['channel'] . '/' . $src['package'] . ')'; |
} |
$info = array( |
'Release Type' => $release, |
'Name' => $extends, |
606,21 → 678,27 |
if (!$leads) { |
continue; |
} |
if (isset($leads['active'])) { |
$leads = array($leads); |
} |
foreach ($leads as $lead) { |
if (!empty($info['Maintainers'])) { |
$info['Maintainers'] .= "\n"; |
} |
$active = $lead['active'] == 'no' ? ', inactive' : ''; |
$info['Maintainers'] .= $lead['name'] . ' <'; |
$info['Maintainers'] .= $lead['email'] . "> ($role)"; |
$info['Maintainers'] .= $lead['email'] . "> ($role$active)"; |
} |
} |
$info['Release Date'] = $obj->getDate(); |
if ($time = $obj->getTime()) { |
$info['Release Date'] .= ' ' . $time; |
} |
$info['Release Version'] = $obj->getVersion() . ' (' . $obj->getState() . ')'; |
$info['API Version'] = $obj->getVersion('api') . ' (' . $obj->getState('api') . ')'; |
$info['License'] = $obj->getLicense(); |
635,16 → 713,22 |
} |
} |
} |
$info['Release Notes'] = $obj->getNotes(); |
if ($compat = $obj->getCompatible()) { |
if (!isset($compat[0])) { |
$compat = array($compat); |
} |
$info['Compatible with'] = ''; |
foreach ($compat as $package) { |
$info['Compatible with'] .= $package['channel'] . '/' . $package['package'] . |
$info['Compatible with'] .= $package['channel'] . '/' . $package['name'] . |
"\nVersions >= " . $package['min'] . ', <= ' . $package['max']; |
if (isset($package['exclude'])) { |
if (is_array($package['exclude'])) { |
$package['exclude'] = implode(', ', $package['exclude']); |
} |
if (!isset($info['Not Compatible with'])) { |
$info['Not Compatible with'] = ''; |
} else { |
651,15 → 735,17 |
$info['Not Compatible with'] .= "\n"; |
} |
$info['Not Compatible with'] .= $package['channel'] . '/' . |
$package['package'] . "\nVersions " . $package['exclude']; |
$package['name'] . "\nVersions " . $package['exclude']; |
} |
} |
} |
$usesrole = $obj->getUsesrole(); |
if ($usesrole) { |
if (!isset($usesrole[0])) { |
$usesrole = array($usesrole); |
} |
foreach ($usesrole as $roledata) { |
if (isset($info['Uses Custom Roles'])) { |
$info['Uses Custom Roles'] .= "\n"; |
666,6 → 752,7 |
} else { |
$info['Uses Custom Roles'] = ''; |
} |
if (isset($roledata['package'])) { |
$rolepackage = $reg->parsedPackageNameToString($roledata, true); |
} else { |
674,11 → 761,13 |
$info['Uses Custom Roles'] .= $roledata['role'] . ' (' . $rolepackage . ')'; |
} |
} |
$usestask = $obj->getUsestask(); |
if ($usestask) { |
if (!isset($usestask[0])) { |
$usestask = array($usestask); |
} |
foreach ($usestask as $taskdata) { |
if (isset($info['Uses Custom Tasks'])) { |
$info['Uses Custom Tasks'] .= "\n"; |
685,6 → 774,7 |
} else { |
$info['Uses Custom Tasks'] = ''; |
} |
if (isset($taskdata['package'])) { |
$taskpackage = $reg->parsedPackageNameToString($taskdata, true); |
} else { |
693,6 → 783,7 |
$info['Uses Custom Tasks'] .= $taskdata['task'] . ' (' . $taskpackage . ')'; |
} |
} |
$deps = $obj->getDependencies(); |
$info['Required Dependencies'] = 'PHP version ' . $deps['required']['php']['min']; |
if (isset($deps['required']['php']['max'])) { |
700,6 → 791,7 |
} else { |
$info['Required Dependencies'] .= "\n"; |
} |
if (isset($deps['required']['php']['exclude'])) { |
if (!isset($info['Not Compatible with'])) { |
$info['Not Compatible with'] = ''; |
706,6 → 798,7 |
} else { |
$info['Not Compatible with'] .= "\n"; |
} |
if (is_array($deps['required']['php']['exclude'])) { |
$deps['required']['php']['exclude'] = |
implode(', ', $deps['required']['php']['exclude']); |
713,6 → 806,7 |
$info['Not Compatible with'] .= "PHP versions\n " . |
$deps['required']['php']['exclude']; |
} |
$info['Required Dependencies'] .= 'PEAR installer version'; |
if (isset($deps['required']['pearinstaller']['max'])) { |
$info['Required Dependencies'] .= 's ' . |
722,6 → 816,7 |
$info['Required Dependencies'] .= ' ' . |
$deps['required']['pearinstaller']['min'] . ' or newer'; |
} |
if (isset($deps['required']['pearinstaller']['exclude'])) { |
if (!isset($info['Not Compatible with'])) { |
$info['Not Compatible with'] = ''; |
728,6 → 823,7 |
} else { |
$info['Not Compatible with'] .= "\n"; |
} |
if (is_array($deps['required']['pearinstaller']['exclude'])) { |
$deps['required']['pearinstaller']['exclude'] = |
implode(', ', $deps['required']['pearinstaller']['exclude']); |
735,6 → 831,7 |
$info['Not Compatible with'] .= "PEAR installer\n Versions " . |
$deps['required']['pearinstaller']['exclude']; |
} |
foreach (array('Package', 'Extension') as $type) { |
$index = strtolower($type); |
if (isset($deps['required'][$index])) { |
741,6 → 838,7 |
if (isset($deps['required'][$index]['name'])) { |
$deps['required'][$index] = array($deps['required'][$index]); |
} |
foreach ($deps['required'][$index] as $package) { |
if (isset($package['conflicts'])) { |
$infoindex = 'Not Compatible with'; |
753,6 → 851,7 |
$infoindex = 'Required Dependencies'; |
$info[$infoindex] .= "\n"; |
} |
if ($index == 'extension') { |
$name = $package['name']; |
} else { |
762,11 → 861,13 |
$name = '__uri/' . $package['name'] . ' (static URI)'; |
} |
} |
$info[$infoindex] .= "$type $name"; |
if (isset($package['uri'])) { |
$info[$infoindex] .= "\n Download URI: $package[uri]"; |
continue; |
} |
if (isset($package['max']) && isset($package['min'])) { |
$info[$infoindex] .= " \n Versions " . |
$package['min'] . '-' . $package['max']; |
777,9 → 878,11 |
$info[$infoindex] .= " \n Version " . |
$package['max'] . ' or older'; |
} |
if (isset($package['recommended'])) { |
$info[$infoindex] .= "\n Recommended version: $package[recommended]"; |
} |
if (isset($package['exclude'])) { |
if (!isset($info['Not Compatible with'])) { |
$info['Not Compatible with'] = ''; |
786,9 → 889,11 |
} else { |
$info['Not Compatible with'] .= "\n"; |
} |
if (is_array($package['exclude'])) { |
$package['exclude'] = implode(', ', $package['exclude']); |
} |
$package['package'] = $package['name']; // for parsedPackageNameToString |
if (isset($package['conflicts'])) { |
$info['Not Compatible with'] .= '=> except '; |
800,10 → 905,12 |
} |
} |
} |
if (isset($deps['required']['os'])) { |
if (isset($deps['required']['os']['name'])) { |
$dep['required']['os']['name'] = array($dep['required']['os']['name']); |
} |
foreach ($dep['required']['os'] as $os) { |
if (isset($os['conflicts']) && $os['conflicts'] == 'yes') { |
if (!isset($info['Not Compatible with'])) { |
818,10 → 925,12 |
} |
} |
} |
if (isset($deps['required']['arch'])) { |
if (isset($deps['required']['arch']['pattern'])) { |
$dep['required']['arch']['pattern'] = array($dep['required']['os']['pattern']); |
} |
foreach ($dep['required']['arch'] as $os) { |
if (isset($os['conflicts']) && $os['conflicts'] == 'yes') { |
if (!isset($info['Not Compatible with'])) { |
836,6 → 945,7 |
} |
} |
} |
if (isset($deps['optional'])) { |
foreach (array('Package', 'Extension') as $type) { |
$index = strtolower($type); |
843,6 → 953,7 |
if (isset($deps['optional'][$index]['name'])) { |
$deps['optional'][$index] = array($deps['optional'][$index]); |
} |
foreach ($deps['optional'][$index] as $package) { |
if (isset($package['conflicts']) && $package['conflicts'] == 'yes') { |
$infoindex = 'Not Compatible with'; |
859,6 → 970,7 |
$info['Optional Dependencies'] .= "\n"; |
} |
} |
if ($index == 'extension') { |
$name = $package['name']; |
} else { |
868,15 → 980,18 |
$name = '__uri/' . $package['name'] . ' (static URI)'; |
} |
} |
$info[$infoindex] .= "$type $name"; |
if (isset($package['uri'])) { |
$info[$infoindex] .= "\n Download URI: $package[uri]"; |
continue; |
} |
if ($infoindex == 'Not Compatible with') { |
// conflicts is only used to say that all versions conflict |
continue; |
} |
if (isset($package['max']) && isset($package['min'])) { |
$info[$infoindex] .= " \n Versions " . |
$package['min'] . '-' . $package['max']; |
887,9 → 1002,11 |
$info[$infoindex] .= " \n Version " . |
$package['min'] . ' or older'; |
} |
if (isset($package['recommended'])) { |
$info[$infoindex] .= "\n Recommended version: $package[recommended]"; |
} |
if (isset($package['exclude'])) { |
if (!isset($info['Not Compatible with'])) { |
$info['Not Compatible with'] = ''; |
896,9 → 1013,11 |
} else { |
$info['Not Compatible with'] .= "\n"; |
} |
if (is_array($package['exclude'])) { |
$package['exclude'] = implode(', ', $package['exclude']); |
} |
$info['Not Compatible with'] .= "Package $package\n Versions " . |
$package['exclude']; |
} |
906,10 → 1025,12 |
} |
} |
} |
if (isset($deps['group'])) { |
if (!isset($deps['group'][0])) { |
$deps['group'] = array($deps['group']); |
} |
foreach ($deps['group'] as $group) { |
$info['Dependency Group ' . $group['attribs']['name']] = $group['attribs']['hint']; |
$groupindex = $group['attribs']['name'] . ' Contents'; |
920,10 → 1041,12 |
if (isset($group[$index]['name'])) { |
$group[$index] = array($group[$index]); |
} |
foreach ($group[$index] as $package) { |
if (!empty($info[$groupindex])) { |
$info[$groupindex] .= "\n"; |
} |
if ($index == 'extension') { |
$name = $package['name']; |
} else { |
933,6 → 1056,7 |
$name = '__uri/' . $package['name'] . ' (static URI)'; |
} |
} |
if (isset($package['uri'])) { |
if (isset($package['conflicts']) && $package['conflicts'] == 'yes') { |
$info[$groupindex] .= "Not Compatible with $type $name"; |
939,13 → 1063,16 |
} else { |
$info[$groupindex] .= "$type $name"; |
} |
$info[$groupindex] .= "\n Download URI: $package[uri]"; |
continue; |
} |
if (isset($package['conflicts']) && $package['conflicts'] == 'yes') { |
$info[$groupindex] .= "Not Compatible with $type $name"; |
continue; |
} |
$info[$groupindex] .= "$type $name"; |
if (isset($package['max']) && isset($package['min'])) { |
$info[$groupindex] .= " \n Versions " . |
957,9 → 1084,11 |
$info[$groupindex] .= " \n Version " . |
$package['min'] . ' or older'; |
} |
if (isset($package['recommended'])) { |
$info[$groupindex] .= "\n Recommended version: $package[recommended]"; |
} |
if (isset($package['exclude'])) { |
if (!isset($info['Not Compatible with'])) { |
$info['Not Compatible with'] = ''; |
966,6 → 1095,7 |
} else { |
$info[$groupindex] .= "Not Compatible with\n"; |
} |
if (is_array($package['exclude'])) { |
$package['exclude'] = implode(', ', $package['exclude']); |
} |
977,6 → 1107,7 |
} |
} |
} |
if ($obj->getPackageType() == 'bundle') { |
$info['Bundled Packages'] = ''; |
foreach ($obj->getBundledPackages() as $package) { |
983,6 → 1114,7 |
if (!empty($info['Bundled Packages'])) { |
$info['Bundled Packages'] .= "\n"; |
} |
if (isset($package['uri'])) { |
$info['Bundled Packages'] .= '__uri/' . $package['name']; |
$info['Bundled Packages'] .= "\n (URI: $package[uri]"; |
991,21 → 1123,22 |
} |
} |
} |
$info['package.xml version'] = '2.0'; |
if ($installed) { |
if ($obj->getLastModified()) { |
$info['Last Modified'] = date('Y-m-d H:i', $obj->getLastModified()); |
} |
$v = $obj->getLastInstalledVersion(); |
$info['Previous Installed Version'] = $v ? $v : '- None -'; |
} |
foreach ($info as $key => $value) { |
$data['data'][] = array($key, $value); |
} |
$data['raw'] = $obj->getArray(); // no validation needed |
$this->ui->outputData($data, 'package-info'); |
} |
} |
?> |
/trunk/bibliotheque/pear/PEAR/Command/Auth.xml |
---|
1,11 → 1,14 |
<commands version="1.0"> |
<login> |
<summary>Connects and authenticates to remote server</summary> |
<summary>Connects and authenticates to remote server [Deprecated in favor of channel-login]</summary> |
<function>doLogin</function> |
<shortcut>li</shortcut> |
<function>doLogin</function> |
<options /> |
<doc> |
Log in to the remote server. To use remote functions in the installer |
<doc><channel name> |
WARNING: This function is deprecated in favor of using channel-login |
Log in to a remote channel server. If <channel name> is not supplied, |
the default channel is used. To use remote functions in the installer |
that require any kind of privileges, you need to log in first. The |
username and password you enter here will be stored in your per-user |
PEAR configuration (~/.pearrc on Unix-like systems). After logging |
13,11 → 16,13 |
operations on the remote server.</doc> |
</login> |
<logout> |
<summary>Logs out from the remote server</summary> |
<summary>Logs out from the remote server [Deprecated in favor of channel-logout]</summary> |
<function>doLogout</function> |
<shortcut>lo</shortcut> |
<function>doLogout</function> |
<options /> |
<doc> |
WARNING: This function is deprecated in favor of using channel-logout |
Logs out from the remote server. This command does not actually |
connect to the remote server, it only deletes the stored username and |
password from your user configuration.</doc> |
/trunk/bibliotheque/pear/PEAR/Command/Mirror.php |
---|
4,18 → 4,11 |
* |
* 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 Alexander Merz <alexmerz@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version CVS: $Id: Mirror.php,v 1.18 2006/03/02 18:14:13 cellog Exp $ |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.2.0 |
*/ |
31,16 → 24,14 |
* @category pear |
* @package PEAR |
* @author Alexander Merz <alexmerz@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.5.1 |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 1.2.0 |
*/ |
class PEAR_Command_Mirror extends PEAR_Command_Common |
{ |
// {{{ properties |
var $commands = array( |
'download-all' => array( |
'summary' => 'Downloads each available package from the default channel', |
61,10 → 52,6 |
), |
); |
// }}} |
// {{{ constructor |
/** |
* PEAR_Command_Mirror constructor. |
* |
72,13 → 59,11 |
* @param object PEAR_Frontend a reference to an frontend |
* @param object PEAR_Config a reference to the configuration data |
*/ |
function PEAR_Command_Mirror(&$ui, &$config) |
function __construct(&$ui, &$config) |
{ |
parent::PEAR_Command_Common($ui, $config); |
parent::__construct($ui, $config); |
} |
// }}} |
/** |
* For unit-testing |
*/ |
88,7 → 73,6 |
return $a; |
} |
// {{{ doDownloadAll() |
/** |
* retrieves a list of avaible Packages from master server |
* and downloads them |
97,8 → 81,8 |
* @param string $command the command |
* @param array $options the command options before the command |
* @param array $params the stuff after the command name |
* @return bool true if succesful |
* @throw PEAR_Error |
* @return bool true if successful |
* @throw PEAR_Error |
*/ |
function doDownloadAll($command, $options, $params) |
{ |
111,32 → 95,34 |
return $this->raiseError('Channel "' . $channel . '" does not exist'); |
} |
$this->config->set('default_channel', $channel); |
$this->ui->outputData('Using Channel ' . $this->config->get('default_channel')); |
$chan = $reg->getChannel($channel); |
if (PEAR::isError($chan)) { |
return $this->raiseError($chan); |
} |
if ($chan->supportsREST($this->config->get('preferred_mirror')) && |
$base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) { |
$rest = &$this->config->getREST('1.0', array()); |
$remoteInfo = array_flip($rest->listPackages($base)); |
} else { |
$remote = &$this->config->getRemote(); |
$stable = ($this->config->get('preferred_state') == 'stable'); |
$remoteInfo = $remote->call("package.listAll", true, $stable, false); |
$remoteInfo = array_flip($rest->listPackages($base, $channel)); |
} |
if (PEAR::isError($remoteInfo)) { |
return $remoteInfo; |
} |
$cmd = &$this->factory("download"); |
if (PEAR::isError($cmd)) { |
return $cmd; |
} |
$this->ui->outputData('Using Preferred State of ' . |
$this->config->get('preferred_state')); |
$this->ui->outputData('Gathering release information, please wait...'); |
/** |
* Error handling not necessary, because already done by |
* Error handling not necessary, because already done by |
* the download command |
*/ |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
146,8 → 132,7 |
if (PEAR::isError($err)) { |
$this->ui->outputData($err->getMessage()); |
} |
return true; |
} |
// }}} |
} |
/trunk/bibliotheque/pear/PEAR/Command/Test.php |
---|
4,20 → 4,13 |
* |
* 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 Stig Bakken <ssb@php.net> |
* @author Martin Jansen <mj@php.net> |
* @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: Test.php,v 1.15 2007/02/17 17:51:25 cellog Exp $ |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 0.1 |
*/ |
35,9 → 28,9 |
* @author Stig Bakken <ssb@php.net> |
* @author Martin Jansen <mj@php.net> |
* @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: 1.5.1 |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 0.1 |
*/ |
44,8 → 37,6 |
class PEAR_Command_Test extends PEAR_Command_Common |
{ |
// {{{ properties |
var $commands = array( |
'run-tests' => array( |
'summary' => 'Run Regression Tests', |
79,7 → 70,8 |
), |
'phpunit' => array( |
'shortopt' => 'u', |
'doc' => 'Search parameters for AllTests.php, and use that to run phpunit-based tests', |
'doc' => 'Search parameters for AllTests.php, and use that to run phpunit-based tests |
If none is found, all .phpt tests will be tried instead.', |
), |
'tapoutput' => array( |
'shortopt' => 't', |
90,6 → 82,14 |
'doc' => 'CGI php executable (needed for tests with POST/GET section)', |
'arg' => 'PHPCGI', |
), |
'coverage' => array( |
'shortopt' => 'x', |
'doc' => 'Generate a code coverage report (requires Xdebug 2.0.0+)', |
), |
'showdiff' => array( |
'shortopt' => 'd', |
'doc' => 'Output diff on test failure', |
), |
), |
'doc' => '[testfile|dir ...] |
Run regression tests with PHP\'s regression testing script (run-tests.php).', |
98,42 → 98,33 |
var $output; |
// }}} |
// {{{ constructor |
/** |
* PEAR_Command_Test constructor. |
* |
* @access public |
*/ |
function PEAR_Command_Test(&$ui, &$config) |
function __construct(&$ui, &$config) |
{ |
parent::PEAR_Command_Common($ui, $config); |
parent::__construct($ui, $config); |
} |
// }}} |
// {{{ doRunTests() |
function doRunTests($command, $options, $params) |
{ |
if (isset($options['phpunit']) && isset($options['tapoutput'])) { |
return $this->raiseError('ERROR: cannot use both --phpunit and --tapoutput at the same time'); |
} |
require_once 'PEAR/Common.php'; |
require_once 'PEAR/RunTest.php'; |
require_once 'System.php'; |
$log = new PEAR_Common; |
$log->ui = &$this->ui; // slightly hacky, but it will work |
$run = new PEAR_RunTest($log, $options); |
$tests = array(); |
if (isset($options['recur'])) { |
$depth = 4; |
} else { |
$depth = 1; |
} |
$depth = isset($options['recur']) ? 14 : 1; |
if (!count($params)) { |
$params[] = '.'; |
} |
if (isset($options['package'])) { |
$oldparams = $params; |
$params = array(); |
143,29 → 134,30 |
if (PEAR::isError($pname)) { |
return $this->raiseError($pname); |
} |
$package = &$reg->getPackage($pname['package'], $pname['channel']); |
if (!$package) { |
return PEAR::raiseError('Unknown package "' . |
$reg->parsedPackageNameToString($pname) . '"'); |
} |
$filelist = $package->getFilelist(); |
foreach ($filelist as $name => $atts) { |
if (isset($atts['role']) && $atts['role'] != 'test') { |
continue; |
} |
if (isset($options['phpunit'])) { |
if (!preg_match('/AllTests\.php$/i', $name)) { |
continue; |
} |
} else { |
if (!preg_match('/\.phpt$/', $name)) { |
continue; |
} |
if (isset($options['phpunit']) && preg_match('/AllTests\.php\\z/i', $name)) { |
$params[] = $atts['installed_as']; |
continue; |
} elseif (!preg_match('/\.phpt\\z/', $name)) { |
continue; |
} |
$params[] = $atts['installed_as']; |
} |
} |
} |
foreach ($params as $p) { |
if (is_dir($p)) { |
if (isset($options['phpunit'])) { |
172,75 → 164,115 |
$dir = System::find(array($p, '-type', 'f', |
'-maxdepth', $depth, |
'-name', 'AllTests.php')); |
} else { |
$dir = System::find(array($p, '-type', 'f', |
'-maxdepth', $depth, |
'-name', '*.phpt')); |
if (count($dir)) { |
foreach ($dir as $p) { |
$p = realpath($p); |
if (!count($tests) || |
(count($tests) && strlen($p) < strlen($tests[0]))) { |
// this is in a higher-level directory, use this one instead. |
$tests = array($p); |
} |
} |
} |
continue; |
} |
$tests = array_merge($tests, $dir); |
$args = array($p, '-type', 'f', '-name', '*.phpt'); |
} else { |
if (isset($options['phpunit'])) { |
if (!preg_match('/AllTests\.php$/i', $p)) { |
continue; |
} |
$tests[] = $p; |
} else { |
if (!file_exists($p)) { |
if (!preg_match('/\.phpt$/', $p)) { |
$p .= '.phpt'; |
if (preg_match('/AllTests\.php\\z/i', $p)) { |
$p = realpath($p); |
if (!count($tests) || |
(count($tests) && strlen($p) < strlen($tests[0]))) { |
// this is in a higher-level directory, use this one instead. |
$tests = array($p); |
} |
$dir = System::find(array(dirname($p), '-type', 'f', |
'-maxdepth', $depth, |
'-name', $p)); |
$tests = array_merge($tests, $dir); |
} else { |
$tests[] = $p; |
} |
continue; |
} |
if (file_exists($p) && preg_match('/\.phpt$/', $p)) { |
$tests[] = $p; |
continue; |
} |
if (!preg_match('/\.phpt\\z/', $p)) { |
$p .= '.phpt'; |
} |
$args = array(dirname($p), '-type', 'f', '-name', $p); |
} |
if (!isset($options['recur'])) { |
$args[] = '-maxdepth'; |
$args[] = 1; |
} |
$dir = System::find($args); |
$tests = array_merge($tests, $dir); |
} |
$ini_settings = ''; |
if (isset($options['ini'])) { |
$ini_settings .= $options['ini']; |
} |
if (isset($_ENV['TEST_PHP_INCLUDE_PATH'])) { |
$ini_settings .= " -d include_path={$_ENV['TEST_PHP_INCLUDE_PATH']}"; |
} |
if ($ini_settings) { |
$this->ui->outputData('Using INI settings: "' . $ini_settings . '"'); |
} |
$skipped = $passed = $failed = array(); |
$this->ui->outputData('Running ' . count($tests) . ' tests', $command); |
$tests_count = count($tests); |
$this->ui->outputData('Running ' . $tests_count . ' tests', $command); |
$start = time(); |
if (isset($options['realtimelog'])) { |
if (file_exists('run-tests.log')) { |
unlink('run-tests.log'); |
} |
if (isset($options['realtimelog']) && file_exists('run-tests.log')) { |
unlink('run-tests.log'); |
} |
if (isset($options['tapoutput'])) { |
$tap = '1..' . count($tests) . "\n"; |
$tap = '1..' . $tests_count . "\n"; |
} |
$i = 1; |
require_once 'PEAR/RunTest.php'; |
$run = new PEAR_RunTest($log, $options); |
$run->tests_count = $tests_count; |
if (isset($options['coverage']) && extension_loaded('xdebug')){ |
$run->xdebug_loaded = true; |
} else { |
$run->xdebug_loaded = false; |
} |
$j = $i = 1; |
foreach ($tests as $t) { |
if (isset($options['realtimelog'])) { |
$fp = @fopen('run-tests.log', 'a'); |
if ($fp) { |
fwrite($fp, "Running test $t..."); |
fwrite($fp, "Running test [$i / $tests_count] $t..."); |
fclose($fp); |
} |
} |
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); |
$result = $run->run($t, $ini_settings); |
if (isset($options['phpunit'])) { |
$result = $run->runPHPUnit($t, $ini_settings); |
} else { |
$result = $run->run($t, $ini_settings, $j); |
} |
PEAR::staticPopErrorHandling(); |
if (PEAR::isError($result)) { |
$this->ui->log($result->getMessage()); |
continue; |
} |
if (isset($options['tapoutput'])) { |
$tap .= $result[0] . ' ' . $i . $result[1] . "\n"; |
$i++; |
continue; |
} |
if (isset($options['realtimelog'])) { |
$fp = @fopen('run-tests.log', 'a'); |
if ($fp) { |
248,16 → 280,20 |
fclose($fp); |
} |
} |
if ($result == 'FAILED') { |
$failed[] = $t; |
$failed[] = $t; |
} |
if ($result == 'PASSED') { |
$passed[] = $t; |
$passed[] = $t; |
} |
if ($result == 'SKIPPED') { |
$skipped[] = $t; |
$skipped[] = $t; |
} |
$j++; |
} |
$total = date('i:s', time() - $start); |
if (isset($options['tapoutput'])) { |
$fp = @fopen('run-tests.log', 'w'); |
272,15 → 308,14 |
$output = "TOTAL TIME: $total\n"; |
$output .= count($passed) . " PASSED TESTS\n"; |
$output .= count($skipped) . " SKIPPED TESTS\n"; |
$output .= count($failed) . " FAILED TESTS:\n"; |
foreach ($failed as $failure) { |
$output .= $failure . "\n"; |
} |
if (isset($options['realtimelog'])) { |
$fp = @fopen('run-tests.log', 'a'); |
} else { |
$fp = @fopen('run-tests.log', 'w'); |
$output .= count($failed) . " FAILED TESTS:\n"; |
foreach ($failed as $failure) { |
$output .= $failure . "\n"; |
} |
$mode = isset($options['realtimelog']) ? 'a' : 'w'; |
$fp = @fopen('run-tests.log', $mode); |
if ($fp) { |
fwrite($fp, $output, strlen($output)); |
fclose($fp); |
294,15 → 329,15 |
$this->ui->outputData(count($passed) . ' PASSED TESTS', $command); |
$this->ui->outputData(count($skipped) . ' SKIPPED TESTS', $command); |
if (count($failed)) { |
$this->ui->outputData(count($failed) . ' FAILED TESTS:', $command); |
foreach ($failed as $failure) { |
$this->ui->outputData($failure, $command); |
} |
$this->ui->outputData(count($failed) . ' FAILED TESTS:', $command); |
foreach ($failed as $failure) { |
$this->ui->outputData($failure, $command); |
} |
} |
return true; |
if (count($failed) == 0) { |
return true; |
} |
return $this->raiseError('Some tests failed'); |
} |
// }}} |
} |
?> |
/trunk/bibliotheque/pear/PEAR/Command/Install.xml |
---|
26,7 → 26,7 |
</soft> |
<nobuild> |
<shortopt>B</shortopt> |
<doc>don't build C extensions</doc> |
<doc>don't build C extensions</doc> |
</nobuild> |
<nocompress> |
<shortopt>Z</shortopt> |
34,10 → 34,16 |
</nocompress> |
<installroot> |
<shortopt>R</shortopt> |
<doc>root directory used when installing files (ala PHP's INSTALL_ROOT), use packagingroot for RPM</doc> |
<arg>DIR</arg> |
<doc>root directory used when installing files (ala PHP's INSTALL_ROOT)</doc> |
</installroot> |
<packagingroot> |
<shortopt>P</shortopt> |
<doc>root directory used when packaging files, like RPM packaging</doc> |
<arg>DIR</arg> |
</packagingroot> |
<ignore-errors> |
<shortopt></shortopt> |
<doc>force install even if there were errors</doc> |
</ignore-errors> |
<alldeps> |
70,7 → 76,7 |
package.xml. Useful for testing, or for wrapping a PEAR package in |
another package manager such as RPM. |
"Package[-version/state][.tar]" : queries your default channel's server |
"Package[-version/state][.tar]" : queries your default channel's server |
({config master_server}) and downloads the newest package with |
the preferred quality/state ({config preferred_state}). |
90,6 → 96,11 |
<function>doInstall</function> |
<shortcut>up</shortcut> |
<options> |
<channel> |
<shortopt>c</shortopt> |
<doc>upgrade packages from a specific channel</doc> |
<arg>CHAN</arg> |
</channel> |
<force> |
<shortopt>f</shortopt> |
<doc>overwrite newer installed packages</doc> |
108,7 → 119,7 |
</register-only> |
<nobuild> |
<shortopt>B</shortopt> |
<doc>don't build C extensions</doc> |
<doc>don't build C extensions</doc> |
</nobuild> |
<nocompress> |
<shortopt>Z</shortopt> |
116,10 → 127,11 |
</nocompress> |
<installroot> |
<shortopt>R</shortopt> |
<doc>root directory used when installing files (ala PHP's INSTALL_ROOT)</doc> |
<arg>DIR</arg> |
<doc>root directory used when installing files (ala PHP's INSTALL_ROOT)</doc> |
</installroot> |
<ignore-errors> |
<shortopt></shortopt> |
<doc>force install even if there were errors</doc> |
</ignore-errors> |
<alldeps> |
151,10 → 163,15 |
</doc> |
</upgrade> |
<upgrade-all> |
<summary>Upgrade All Packages</summary> |
<function>doInstall</function> |
<summary>Upgrade All Packages [Deprecated in favor of calling upgrade with no parameters]</summary> |
<function>doUpgradeAll</function> |
<shortcut>ua</shortcut> |
<options> |
<channel> |
<shortopt>c</shortopt> |
<doc>upgrade packages from a specific channel</doc> |
<arg>CHAN</arg> |
</channel> |
<nodeps> |
<shortopt>n</shortopt> |
<doc>ignore dependencies, upgrade anyway</doc> |
165,7 → 182,7 |
</register-only> |
<nobuild> |
<shortopt>B</shortopt> |
<doc>don't build C extensions</doc> |
<doc>don't build C extensions</doc> |
</nobuild> |
<nocompress> |
<shortopt>Z</shortopt> |
173,17 → 190,21 |
</nocompress> |
<installroot> |
<shortopt>R</shortopt> |
<doc>root directory used when installing files (ala PHP's INSTALL_ROOT), use packagingroot for RPM</doc> |
<arg>DIR</arg> |
<doc>root directory used when installing files (ala PHP's INSTALL_ROOT)</doc> |
</installroot> |
<ignore-errors> |
<shortopt></shortopt> |
<doc>force install even if there were errors</doc> |
</ignore-errors> |
<loose> |
<shortopt></shortopt> |
<doc>do not check for recommended dependency version</doc> |
</loose> |
</options> |
<doc> |
WARNING: This function is deprecated in favor of using the upgrade command with no params |
Upgrades all packages that have a newer release available. Upgrades are |
done only if there is a release available of the state specified in |
"preferred_state" (currently {config preferred_state}), or a state considered |
205,10 → 226,11 |
</register-only> |
<installroot> |
<shortopt>R</shortopt> |
<doc>root directory used when installing files (ala PHP's INSTALL_ROOT)</doc> |
<arg>DIR</arg> |
<doc>root directory used when installing files (ala PHP's INSTALL_ROOT)</doc> |
</installroot> |
<ignore-errors> |
<shortopt></shortopt> |
<doc>force install even if there were errors</doc> |
</ignore-errors> |
<offline> |
229,8 → 251,8 |
<options> |
<destination> |
<shortopt>d</shortopt> |
<doc>Optional destination directory for unpacking (defaults to current path or "ext" if exists)</doc> |
<arg>DIR</arg> |
<doc>Optional destination directory for unpacking (defaults to current path or "ext" if exists)</doc> |
</destination> |
<force> |
<shortopt>f</shortopt> |
/trunk/bibliotheque/pear/PEAR/Command/Pickle.xml |
---|
13,20 → 13,15 |
<doc>Print the name of the packaged file.</doc> |
</showname> |
</options> |
<doc>[descfile] [descfile2] |
Creates a PECL package from its description file (usually called |
package.xml). If a second packagefile is passed in, then |
the packager will check to make sure that one is a package.xml |
version 1.0, and the other is a package.xml version 2.0. The |
package.xml version 1.0 will be saved as "package.xml" in the archive, |
and the other as "package2.xml" in the archive" |
<doc>[descfile] |
Creates a PECL package from its package2.xml file. |
If no second file is passed in, and [descfile] is a package.xml 2.0, |
an automatic conversion will be made to a package.xml 1.0. Note that |
An automatic conversion will be made to a package.xml 1.0 and written out to |
disk in the current directory as "package.xml". Note that |
only simple package.xml 2.0 will be converted. package.xml 2.0 with: |
- dependency types other than required/optional PECL package/ext/php/pearinstaller |
- more than one extsrcrelease/zendextsrcrelease |
- more than one extsrcrelease or zendextsrcrelease |
- zendextbinrelease, extbinrelease, phprelease, or bundle release type |
- dependency groups |
- ignore tags in release filelist |
35,6 → 30,7 |
will cause pickle to fail, and output an error message. If your package2.xml |
uses any of these features, you are best off using PEAR_PackageFileManager to |
generate both package.xml.</doc> |
generate both package.xml. |
</doc> |
</pickle> |
</commands> |
/trunk/bibliotheque/pear/PEAR/Command/Registry.xml |
---|
13,6 → 13,10 |
<shortopt>a</shortopt> |
<doc>list installed packages from all channels</doc> |
</allchannels> |
<channelinfo> |
<shortopt>i</shortopt> |
<doc>output fully channel-aware data, even on failure</doc> |
</channelinfo> |
</options> |
<doc><package> |
If invoked without parameters, this command lists the PEAR packages |
/trunk/bibliotheque/pear/PEAR/Command/Common.php |
---|
4,19 → 4,12 |
* |
* 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 Stig Bakken <ssb@php.net> |
* @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: Common.php,v 1.35 2006/06/08 22:25:18 pajoye Exp $ |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 0.1 |
*/ |
33,16 → 26,14 |
* @package PEAR |
* @author Stig Bakken <ssb@php.net> |
* @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: 1.5.1 |
* @copyright 1997-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 0.1 |
*/ |
class PEAR_Command_Common extends PEAR |
{ |
// {{{ properties |
/** |
* PEAR_Config object used to pass user system and configuration |
* on when executing commands |
84,25 → 75,18 |
'sapi' => 'SAPI backend' |
); |
// }}} |
// {{{ constructor |
/** |
* PEAR_Command_Common constructor. |
* |
* @access public |
*/ |
function PEAR_Command_Common(&$ui, &$config) |
function __construct(&$ui, &$config) |
{ |
parent::PEAR(); |
parent::__construct(); |
$this->config = &$config; |
$this->ui = &$ui; |
} |
// }}} |
// {{{ getCommands() |
/** |
* Return a list of all the commands defined by this class. |
* @return array list of commands |
114,12 → 98,10 |
foreach (array_keys($this->commands) as $command) { |
$ret[$command] = $this->commands[$command]['summary']; |
} |
return $ret; |
} |
// }}} |
// {{{ getShortcuts() |
/** |
* Return a list of all the command shortcuts defined by this class. |
* @return array shortcut => command |
133,12 → 115,10 |
$ret[$this->commands[$command]['shortcut']] = $command; |
} |
} |
return $ret; |
} |
// }}} |
// {{{ getOptions() |
function getOptions($command) |
{ |
$shortcuts = $this->getShortcuts(); |
145,24 → 125,23 |
if (isset($shortcuts[$command])) { |
$command = $shortcuts[$command]; |
} |
if (isset($this->commands[$command]) && |
isset($this->commands[$command]['options'])) { |
return $this->commands[$command]['options']; |
} else { |
return null; |
} |
return null; |
} |
// }}} |
// {{{ getGetoptArgs() |
function getGetoptArgs($command, &$short_args, &$long_args) |
{ |
$short_args = ""; |
$short_args = ''; |
$long_args = array(); |
if (empty($this->commands[$command]) || empty($this->commands[$command]['options'])) { |
return; |
} |
reset($this->commands[$command]['options']); |
while (list($option, $info) = each($this->commands[$command]['options'])) { |
$larg = $sarg = ''; |
177,15 → 156,15 |
$arg = $info['arg']; |
} |
} |
if (isset($info['shortopt'])) { |
$short_args .= $info['shortopt'] . $sarg; |
} |
$long_args[] = $option . $larg; |
} |
} |
// }}} |
// {{{ getHelp() |
/** |
* Returns the help message for the given command |
* |
200,10 → 179,12 |
if (!isset($this->commands[$command])) { |
return "No such command \"$command\""; |
} |
$help = null; |
if (isset($this->commands[$command]['doc'])) { |
$help = $this->commands[$command]['doc']; |
} |
if (empty($help)) { |
// XXX (cox) Fallback to summary if there is no doc (show both?) |
if (!isset($this->commands[$command]['summary'])) { |
211,22 → 192,22 |
} |
$help = $this->commands[$command]['summary']; |
} |
if (preg_match_all('/{config\s+([^\}]+)}/e', $help, $matches)) { |
foreach($matches[0] as $k => $v) { |
$help = preg_replace("/$v/", $config->get($matches[1][$k]), $help); |
} |
} |
return array($help, $this->getHelpArgs($command)); |
} |
// }}} |
// {{{ getHelpArgs() |
/** |
* Returns the help for the accepted arguments of a command |
* |
* @param string $command |
* @return string The help string |
*/ |
* Returns the help for the accepted arguments of a command |
* |
* @param string $command |
* @return string The help string |
*/ |
function getHelpArgs($command) |
{ |
if (isset($this->commands[$command]['options']) && |
246,6 → 227,7 |
} else { |
$sapp = $lapp = ""; |
} |
if (isset($v['shortopt'])) { |
$s = $v['shortopt']; |
$help .= " -$s$sapp, --$k$lapp\n"; |
252,18 → 234,18 |
} else { |
$help .= " --$k$lapp\n"; |
} |
$p = " "; |
$doc = rtrim(str_replace("\n", "\n$p", $v['doc'])); |
$help .= " $doc\n"; |
} |
return $help; |
} |
return null; |
} |
// }}} |
// {{{ run() |
function run($command, $options, $params) |
{ |
if (empty($this->commands[$command]['function'])) { |
276,6 → 258,8 |
$func = $this->commands[$cmd]['function']; |
} |
$command = $cmd; |
//$command = $this->commands[$cmd]['function']; |
break; |
} |
} |
282,10 → 266,7 |
} else { |
$func = $this->commands[$command]['function']; |
} |
return $this->$func($command, $options, $params); |
} |
// }}} |
} |
?> |
/trunk/bibliotheque/pear/PEAR/Command/Test.xml |
---|
31,7 → 31,8 |
</package> |
<phpunit> |
<shortopt>u</shortopt> |
<doc>Search parameters for AllTests.php, and use that to run phpunit-based tests</doc> |
<doc>Search parameters for AllTests.php, and use that to run phpunit-based tests |
If none is found, all .phpt tests will be tried instead.</doc> |
</phpunit> |
<tapoutput> |
<shortopt>t</shortopt> |
42,8 → 43,12 |
<doc>CGI php executable (needed for tests with POST/GET section)</doc> |
<arg>PHPCGI</arg> |
</cgi> |
<coverage> |
<shortopt>x</shortopt> |
<doc>Generate a code coverage report (requires Xdebug 2.0.0+)</doc> |
</coverage> |
</options> |
<doc>[testfile|dir ...] |
Run regression tests with PHP's regression testing script (run-tests.php).</doc> |
Run regression tests with PHP's regression testing script (run-tests.php).</doc> |
</run-tests> |
</commands> |