本文整理汇总了PHP中PEAR_Registry::packageInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_Registry::packageInfo方法的具体用法?PHP PEAR_Registry::packageInfo怎么用?PHP PEAR_Registry::packageInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEAR_Registry
的用法示例。
在下文中一共展示了PEAR_Registry::packageInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: packageInfo
/**
* (non-PHPdoc)
* @see lib/Faett/Core/Interfaces/Faett_Core_Interfaces_Service#packageInfo($packageName, $channel)
*/
public function packageInfo($packageName, $channel)
{
// store the default channel
$savechannel = $this->_config->get('default_channel');
// check if the cannel already exists
if ($this->_registry->channelExists($channel)) {
$this->_config->set('default_channel', $channel);
} else {
// throw a new exception
throw Faett_Core_Exceptions_UnknownChannelException::create('Channel ' . $channel . ' does not exist');
}
// load the channel from the registry
$chan = $this->_registry->getChannel($channel);
// initialize a REST command for checking the channel's state
$cmd = new PEAR_Command_Remote($this->_ui, $this->_config);
if (PEAR::isError($e = $cmd->_checkChannelForStatus($channel, $chan))) {
// reset the default channel
$this->_config->set('default_channel', $savechannel);
// throw a new exception
throw Faett_Core_Exceptions_UnknownChannelStateException::create($e->getMessage());
}
// get the channel's base URL
$base = $chan->getBaseURL('REST1.0', $this->_config->get('preferred_mirror'));
// check if the channel's server is REST enabled
$restSupport = $chan->supportsREST($this->_config->get('preferred_mirror'));
// check if the channel is REST enabled
if ($restSupport && $base) {
// load the channel data and the package information
$rest = $this->_config->getREST('1.0', array());
$info = $rest->packageInfo($base, $packageName);
} else {
$r = $this->_config->getRemote();
$info = $r->call('package.info', $packageName);
}
// check if the package information was loaded successfully
if (PEAR::isError($info)) {
// reset the default channel
$this->_config->set('default_channel', $savechannel);
// throw a new exception
throw Faett_Core_Exceptions_PackageInfoException::create($info->getMessage());
}
// if no packge name was found log an error message
if (!isset($info['name'])) {
// reset the default channel
$this->_config->set('default_channel', $savechannel);
// throw a new exception
throw Faett_Core_Exceptions_PackageInfoException::create('Can\'t find a package name');
}
// check if the package is installed
$installed = $this->_registry->packageInfo($info['name'], null, $channel);
// if yes, set the information
$info['installed'] = $installed['version'] ? $installed['version'] : '';
if (is_array($info['installed'])) {
$info['installed'] = $info['installed']['release'];
}
// return the package information
return $info;
}
示例2: isInstalled
function isInstalled($dep, $oper = '==')
{
if (!$dep) {
return false;
}
if ($oper != 'ge' && $oper != 'gt' && $oper != 'has' && $oper != '==') {
return false;
}
if (is_object($dep)) {
$package = $dep->getPackage();
$channel = $dep->getChannel();
if ($dep->getURI()) {
$dep = array('uri' => $dep->getURI(), 'version' => $dep->getVersion());
} else {
$dep = array('version' => $dep->getVersion());
}
} else {
if (isset($dep['uri'])) {
$channel = '__uri';
$package = $dep['dep']['name'];
} else {
$channel = $dep['info']->getChannel();
$package = $dep['info']->getPackage();
}
}
$options = $this->_downloader->getOptions();
$test = $this->_registry->packageExists($package, $channel);
if (!$test && $channel == 'pecl.php.net') {
// do magic to allow upgrading from old pecl packages to new ones
$test = $this->_registry->packageExists($package, 'pear.php.net');
$channel = 'pear.php.net';
}
if ($test) {
if (isset($dep['uri'])) {
if ($this->_registry->packageInfo($package, 'uri', '__uri') == $dep['uri']) {
return true;
}
}
if (isset($options['upgrade'])) {
if ($oper == 'has') {
if (version_compare($this->_registry->packageInfo($package, 'version', $channel), $dep['version'], '>=')) {
return true;
} else {
return false;
}
} else {
if (version_compare($this->_registry->packageInfo($package, 'version', $channel), $dep['version'], '>=')) {
return true;
}
return false;
}
}
return true;
}
return false;
}
示例3: getComponentDependencies
/**
* Returns a list of components that $componentName depends on.
*
* If $componentName is left empty, all installed components are returned.
*
* The returned array has as keys the component names, and as values the
* version of the components.
*
* @return array(string=>string).
*/
public function getComponentDependencies($componentName = 'ezcomponents')
{
@($packageInfo = $this->registry->packageInfo($componentName, 'dependencies', 'components.ez.no'));
if (isset($packageInfo['required']['package'])) {
$deps = array();
if (isset($packageInfo['required']['package']['name'])) {
$deps[$packageInfo['required']['package']['name']] = $packageInfo['required']['package']['min'];
} else {
foreach ($packageInfo['required']['package'] as $package) {
$deps[$package['name']] = $package['min'];
}
}
return $deps;
}
return array();
}
示例4: check
/**
* Check php package exists and has corresponding version
*
* Returns 0 on success, non-zero otherwise
*
* @return int
*/
public function check()
{
require_once 'PEAR/Registry.php';
$registry = new PEAR_Registry();
$installedVersion = $registry->packageInfo($this->name, 'version', $this->channel);
if (is_null($installedVersion)) {
$this->log('Package "' . $this->name . '" from "' . $this->channel . '" is required', Project::MSG_ERR);
return 1;
}
if ($this->min && version_compare($installedVersion, $this->min, '<')) {
$this->log('Package "' . $this->name . '" from "' . $this->channel . '" is ' . $installedVersion . '. >= ' . $this->min . ' is required', Project::MSG_ERR);
return 1;
}
if ($this->max && version_compare($installedVersion, $this->max, '>')) {
$this->log('Package "' . $this->name . '" from "' . $this->channel . '" is ' . $installedVersion . '. <= ' . $this->max . ' is required', Project::MSG_ERR);
return 1;
}
$this->log('Package "' . $this->name . '" ' . $installedVersion . ' is passed', Project::MSG_VERBOSE);
return 0;
}
示例5: doInstall
function doInstall($command, $options, $params)
{
if (empty($this->installer)) {
$this->installer =& new PEAR_Installer($this->ui);
}
if ($command == 'upgrade') {
$options[$command] = true;
}
if ($command == 'upgrade-all') {
include_once "PEAR/Remote.php";
$options['upgrade'] = true;
$remote = new PEAR_Remote($this->config);
$state = $this->config->get('preferred_state');
if (empty($state) || $state == 'any') {
$latest = $remote->call("package.listLatestReleases");
} else {
$latest = $remote->call("package.listLatestReleases", $state);
}
if (PEAR::isError($latest)) {
return $latest;
}
$reg = new PEAR_Registry($this->config->get('php_dir'));
$installed = array_flip($reg->listPackages());
$params = array();
foreach ($latest as $package => $info) {
if (!isset($installed[$package])) {
// skip packages we don't have installed
continue;
}
$inst_version = $reg->packageInfo($package, 'version');
if (version_compare("{$info['version']}", "{$inst_version}", "le")) {
// installed version is up-to-date
continue;
}
$params[] = $package;
$this->ui->outputData("will upgrade {$package}", $command);
}
}
foreach ($params as $pkg) {
$bn = basename($pkg);
$info = $this->installer->install($pkg, $options, $this->config);
if (is_array($info)) {
if ($this->config->get('verbose') > 0) {
$label = "{$info['package']} {$info['version']}";
$out = array('data' => "{$command} ok: {$label}");
if (isset($info['release_warnings'])) {
$out['release_warnings'] = $info['release_warnings'];
}
$this->ui->outputData($out, $command);
}
} else {
return $this->raiseError("{$command} failed");
}
}
return true;
}
示例6: elseif
/**
* @param array output of package.getDownloadURL
* @param string|array|object information for detecting packages to be downloaded, and
* for errors
* @param array name information of the package
* @param array|null packages to be downloaded
* @param bool is this an optional dependency?
* @param bool is this any kind of dependency?
* @access private
*/
function _analyzeDownloadURL($info, $param, $pname, $params = null, $optional = false, $isdependency = false)
{
if (!is_string($param) && PEAR_Downloader_Package::willDownload($param, $params)) {
return false;
}
if ($info === false) {
$saveparam = !is_string($param) ? ", cannot download \"{$param}\"" : '';
// no releases exist
return PEAR::raiseError('No releases for package "' . $this->_registry->parsedPackageNameToString($pname, true) . '" exist' . $saveparam);
}
if (strtolower($info['info']->getChannel()) != strtolower($pname['channel'])) {
$err = false;
if ($pname['channel'] == 'pecl.php.net') {
if ($info['info']->getChannel() != 'pear.php.net') {
$err = true;
}
} elseif ($info['info']->getChannel() == 'pecl.php.net') {
if ($pname['channel'] != 'pear.php.net') {
$err = true;
}
} else {
$err = true;
}
if ($err) {
return PEAR::raiseError('SECURITY ERROR: package in channel "' . $pname['channel'] . '" retrieved another channel\'s name for download! ("' . $info['info']->getChannel() . '")');
}
}
$preferred_state = $this->_config->get('preferred_state');
if (!isset($info['url'])) {
$package_version = $this->_registry->packageInfo($info['info']->getPackage(), 'version', $info['info']->getChannel());
if ($this->isInstalled($info)) {
if ($isdependency && version_compare($info['version'], $package_version, '<=')) {
// ignore bogus errors of "failed to download dependency"
// if it is already installed and the one that would be
// downloaded is older or the same version (Bug #7219)
return false;
}
}
if ($info['version'] === $package_version) {
if (!isset($options['soft'])) {
$this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] . '/' . $pname['package'] . '-' . $package_version . ', additionally the suggested version' . ' (' . $package_version . ') is the same as the locally installed one.');
}
return false;
}
if (version_compare($info['version'], $package_version, '<=')) {
if (!isset($options['soft'])) {
$this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] . '/' . $pname['package'] . '-' . $package_version . ', additionally the suggested version' . ' (' . $info['version'] . ') is a lower version than the locally installed one (' . $package_version . ').');
}
return false;
}
$instead = ', will instead download version ' . $info['version'] . ', stability "' . $info['info']->getState() . '"';
// releases exist, but we failed to get any
if (isset($this->_downloader->_options['force'])) {
if (isset($pname['version'])) {
$vs = ', version "' . $pname['version'] . '"';
} elseif (isset($pname['state'])) {
$vs = ', stability "' . $pname['state'] . '"';
} elseif ($param == 'dependency') {
if (!class_exists('PEAR_Common')) {
require_once 'PEAR/Common.php';
}
if (!in_array($info['info']->getState(), PEAR_Common::betterStates($preferred_state, true))) {
if ($optional) {
// don't spit out confusing error message
return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
}
$vs = ' within preferred state "' . $preferred_state . '"';
} else {
if (!class_exists('PEAR_Dependency2')) {
require_once 'PEAR/Dependency2.php';
}
if ($optional) {
// don't spit out confusing error message
return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
}
$vs = PEAR_Dependency2::_getExtraString($pname);
$instead = '';
}
} else {
$vs = ' within preferred state "' . $preferred_state . '"';
}
if (!isset($options['soft'])) {
$this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] . '/' . $pname['package'] . $vs . $instead);
}
// download the latest release
return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
} else {
if (isset($info['php']) && $info['php']) {
$err = PEAR::raiseError('Failed to download ' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package']), true) . ', latest release is version ' . $info['php']['v'] . ', but it requires PHP version "' . $info['php']['m'] . '", use "' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package'], 'version' => $info['php']['v'])) . '" to install', PEAR_DOWNLOADER_PACKAGE_PHPVERSION);
return $err;
//.........这里部分代码省略.........
示例7: doUninstall
function doUninstall($command, $options, $params)
{
if (empty($this->installer)) {
$this->installer =& new PEAR_Installer($this->ui);
}
if (sizeof($params) < 1) {
return $this->raiseError("Please supply the package(s) you want to uninstall");
}
include_once 'PEAR/Registry.php';
$reg = new PEAR_Registry($this->config->get('php_dir'));
$newparams = array();
$badparams = array();
foreach ($params as $pkg) {
$info = $reg->packageInfo($pkg);
if ($info === null) {
$badparams[] = $pkg;
} else {
$newparams[] = $info;
}
}
PEAR_Common::sortPkgDeps($newparams, true);
$params = array();
foreach ($newparams as $info) {
$params[] = $info['info']['package'];
}
$params = array_merge($params, $badparams);
foreach ($params as $pkg) {
if ($this->installer->uninstall($pkg, $options)) {
if ($this->config->get('verbose') > 0) {
$this->ui->outputData("uninstall ok: {$pkg}", $command);
}
} else {
return $this->raiseError("uninstall failed: {$pkg}");
}
}
return true;
}
示例8: array
* @version $Revision$
* @package liberty
* @subpackage plugins_format
*/
/**
* definitions
*/
global $gLibertySystem;
if (@(include_once 'PEAR/Registry.php')) {
if (@(include_once 'Text/Wiki.php')) {
$genPluginParams = array('store_function' => 'pearwiki_general_save_data', 'verify_function' => 'pearwiki_general_verify_data', 'plugin_type' => FORMAT_PLUGIN, 'linebreak' => "\r\n");
$reg = new PEAR_Registry();
foreach ($reg->listPackages() as $package) {
if (preg_match('!^text_wiki!', $package)) {
// get package information
$inf = $reg->packageInfo($package);
// package information is all over the place. this should clean it up a bit
if (!empty($inf['name'])) {
$package = $inf['name'];
} elseif (!empty($inf['name'])) {
$package = $inf['package'];
} else {
continue;
}
// fetch parser name
$p = substr($package, strlen("text_wiki"));
if (empty($p)) {
$parser = "Text_Wiki";
$parser_class = "Default";
} else {
$parser = substr($p, 1);
示例9: isset
/**
* @param array dependency array
* @access private
*/
function _getDepPackageDownloadUrl($dep, $parr)
{
$xsdversion = isset($dep['rel']) ? '1.0' : '2.0';
$curchannel = $this->config->get('default_channel');
if (isset($dep['channel'])) {
$remotechannel = $dep['channel'];
} else {
$remotechannel = 'pear.php.net';
}
if (!$this->_registry->channelExists($remotechannel)) {
do {
if ($this->config->get('auto_discover')) {
if ($this->discover($remotechannel)) {
break;
}
}
return PEAR::raiseError('Unknown remote channel: ' . $remotechannel);
} while (false);
}
$this->configSet('default_channel', $remotechannel);
$state = isset($parr['state']) ? $parr['state'] : $this->config->get('preferred_state');
if (isset($parr['state']) && isset($parr['version'])) {
unset($parr['state']);
}
$chan =& $this->_registry->getChannel($remotechannel);
if (PEAR::isError($chan)) {
return $chan;
}
$version = $this->_registry->packageInfo($dep['name'], 'version', $remotechannel);
if ($chan->supportsREST($this->config->get('preferred_mirror')) && ($base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror')))) {
$rest =& $this->config->getREST('1.0', $this->_options);
$url = $rest->getDepDownloadURL($base, $xsdversion, $dep, $parr, $state, $version);
if (PEAR::isError($url)) {
return $url;
}
if ($parr['channel'] != $curchannel) {
$this->configSet('default_channel', $curchannel);
}
if (!is_array($url)) {
return $url;
}
$url['raw'] = false;
// no checking is necessary for REST
if (!is_array($url['info'])) {
return PEAR::raiseError('Invalid remote dependencies retrieved from REST - ' . 'this should never happen');
}
if (isset($url['info']['required'])) {
if (!class_exists('PEAR_PackageFile_v2')) {
require_once 'PEAR/PackageFile/v2.php';
}
$pf = new PEAR_PackageFile_v2();
$pf->setRawChannel($remotechannel);
} else {
if (!class_exists('PEAR_PackageFile_v1')) {
require_once 'PEAR/PackageFile/v1.php';
}
$pf = new PEAR_PackageFile_v1();
}
$pf->setRawPackage($url['package']);
$pf->setDeps($url['info']);
$pf->setRawState($url['stability']);
$url['info'] =& $pf;
if (!extension_loaded("zlib") || isset($this->_options['nocompress'])) {
$ext = '.tar';
} else {
$ext = '.tgz';
}
if (is_array($url)) {
if (isset($url['url'])) {
$url['url'] .= $ext;
}
}
return $url;
} elseif ($chan->supports('xmlrpc', 'package.getDepDownloadURL', false, '1.1')) {
if ($version) {
$url = $this->_remote->call('package.getDepDownloadURL', $xsdversion, $dep, $parr, $state, $version);
} else {
$url = $this->_remote->call('package.getDepDownloadURL', $xsdversion, $dep, $parr, $state);
}
} else {
$url = $this->_remote->call('package.getDepDownloadURL', $xsdversion, $dep, $parr, $state);
}
if ($parr['channel'] != $curchannel) {
$this->configSet('default_channel', $curchannel);
}
if (!is_array($url)) {
return $url;
}
if (isset($url['__PEAR_ERROR_CLASS__'])) {
return PEAR::raiseError($url['message']);
}
$url['raw'] = $url['info'];
$pkg =& $this->getPackagefileObject($this->config, $this->debug);
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$pinfo =& $pkg->fromXmlString($url['info'], PEAR_VALIDATE_DOWNLOADING, 'remote');
PEAR::staticPopErrorHandling();
//.........这里部分代码省略.........
示例10: doList
function doList($command, $options, $params)
{
$reg = new PEAR_Registry($this->config->get('php_dir'));
if (sizeof($params) == 0) {
$installed = $reg->packageInfo();
usort($installed, array(&$this, '_sortinfo'));
$i = $j = 0;
$data = array('caption' => 'Installed packages:', 'border' => true, 'headline' => array('Package', 'Version', 'State'));
foreach ($installed as $package) {
$data['data'][] = array($package['package'], $package['version'], @$package['release_state']);
}
if (count($installed) == 0) {
$data = '(no packages installed)';
}
$this->ui->outputData($data, $command);
} else {
if (file_exists($params[0]) && !is_dir($params[0])) {
include_once "PEAR/Common.php";
$obj =& new PEAR_Common();
$info = $obj->infoFromAny($params[0]);
$headings = array('Package File', 'Install Path');
$installed = false;
} else {
$info = $reg->packageInfo($params[0]);
$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['filelist'];
if ($installed) {
$caption = 'Installed Files For ' . $params[0];
} else {
$caption = 'Contents of ' . basename($params[0]);
}
$data = array('caption' => $caption, 'border' => true, 'headline' => $headings);
foreach ($list as $file => $att) {
if ($installed) {
if (empty($att['installed_as'])) {
continue;
}
$data['data'][] = array($att['role'], $att['installed_as']);
} else {
if (isset($att['baseinstalldir'])) {
$dest = $att['baseinstalldir'] . DIRECTORY_SEPARATOR . $file;
} else {
$dest = $file;
}
switch ($att['role']) {
case 'test':
case 'data':
if ($installed) {
break 2;
}
$dest = '-- will not be installed --';
break;
case 'doc':
$dest = $this->config->get('doc_dir') . DIRECTORY_SEPARATOR . $dest;
break;
case 'php':
default:
$dest = $this->config->get('php_dir') . DIRECTORY_SEPARATOR . $dest;
}
$dest = preg_replace('!/+!', '/', $dest);
$file = preg_replace('!/+!', '/', $file);
$data['data'][] = array($file, $dest);
}
}
$this->ui->outputData($data, $command);
}
return true;
}
示例11: array
$ok = $cmd->run('config-set', array(), array('php_dir', $dir . 'PEAR'));
$ok = $cmd->run('config-set', array(), array('doc_dir', $dir . 'docs'));
$ok = $cmd->run('config-set', array(), array('ext_dir', $dir . 'ext'));
$ok = $cmd->run('config-set', array(), array('bin_dir', $dir . 'bin'));
$ok = $cmd->run('config-set', array(), array('data_dir', $dir . 'data'));
$ok = $cmd->run('config-set', array(), array('test_dir', $dir . 'test'));
$ok = $cmd->run('config-set', array(), array('cache_dir', $dir . 'cache'));
$ok = $cmd->run('config-set', array(), array('cache_ttl', 300));
// Register packages
$packages = array('Archive_Tar', 'Console_Getopt', 'HTML_Template_IT', 'Net_UserAgent_Detect', 'Pager', 'PEAR', 'PEAR_Frontend_Web', 'XML_RPC');
$reg = new PEAR_Registry($dir . 'PEAR');
if (!file_exists($dir . 'PEAR/.registry')) {
PEAR::raiseError('Directory "' . $dir . 'PEAR/.registry" does not exist. please check your installation');
}
foreach ($packages as $pkg) {
$info = $reg->packageInfo($pkg);
foreach ($info['filelist'] as $fileName => $fileInfo) {
if ($fileInfo['role'] == "php") {
$info['filelist'][$fileName]['installed_as'] = str_replace('{dir}', $dir, $fileInfo['installed_as']);
}
}
$reg->updatePackage($pkg, $info, false);
}
}
// Handle some diffrent Commands
if (isset($_GET["command"])) {
switch ($_GET["command"]) {
case 'install':
case 'uninstall':
case 'upgrade':
if (USE_DHTML_PROGRESS && isset($_GET['dhtml'])) {
示例12:
$status = OK;
}
print_row("Database Support", $result, $status);
// PEAR
$have_pear = false;
if (!($pear_dir = find_path($path_list, "PEAR"))) {
$result = "Not installed. The PEAR extension is required by several other " . "PHP extensions that Maia needs. See <a href=\"http://pear.php.net/\">this page</a> " . "for more information about downloading and installing PEAR.";
$status = ERROR;
} else {
// include_once ("PEAR/Remote.php"); // PEAR::Remote
include_once "PEAR/Registry.php";
// PEAR::Registry
$have_pear = true;
$pear = new PEAR_Config();
$pear_reg = new PEAR_Registry($pear->get('php_dir'));
$pear_info = $pear_reg->packageInfo("PEAR");
$pear_list = $pear_reg->listPackages();
$pear_version = is_array($pear_info["version"]) ? $pear_info["version"]["release"] : $pear_info["version"];
$result = $pear_version;
$status = OK;
}
print_row("PEAR", $result, $status);
// PEAR::Mail_Mime
if ($have_pear) {
if (!in_array("mail_mime", $pear_list)) {
$result = "Not installed. This PHP extension is required to decode " . "MIME-structured e-mail. Use <b>pear install Mail_Mime</b> to " . "install this.";
$status = ERROR;
} else {
$info = $pear_reg->packageInfo("Mail_Mime");
$result = is_array($info["version"]) ? $info["version"]["release"] : $info["version"];
if (version_compare($result, "1.3.0") < 0) {
示例13: install
/**
* Installs the files within the package file specified.
*
* @param string|PEAR_Downloader_Package $pkgfile path to the package file,
* or a pre-initialized packagefile object
* @param array $options
* recognized options:
* - installroot : optional prefix directory for installation
* - force : force installation
* - register-only : update registry but don't install files
* - upgrade : upgrade existing install
* - soft : fail silently
* - nodeps : ignore dependency conflicts/missing dependencies
* - alldeps : install all dependencies
* - onlyreqdeps : install only required dependencies
*
* @return array|PEAR_Error package info if successful
*/
function install($pkgfile, $options = array())
{
$this->_options = $options;
$this->_registry =& $this->config->getRegistry();
if (is_object($pkgfile)) {
$dlpkg =& $pkgfile;
$pkg = $pkgfile->getPackageFile();
$pkgfile = $pkg->getArchiveFile();
$descfile = $pkg->getPackageFile();
} else {
$descfile = $pkgfile;
$pkg = $this->_parsePackageXml($descfile);
if (PEAR::isError($pkg)) {
return $pkg;
}
}
$tmpdir = dirname($descfile);
if (realpath($descfile) != realpath($pkgfile)) {
// Use the temp_dir since $descfile can contain the download dir path
$tmpdir = $this->config->get('temp_dir', null, 'pear.php.net');
$tmpdir = System::mktemp('-d -t "' . $tmpdir . '"');
$tar = new Archive_Tar($pkgfile);
if (!$tar->extract($tmpdir)) {
return $this->raiseError("unable to unpack {$pkgfile}");
}
}
$pkgname = $pkg->getName();
$channel = $pkg->getChannel();
if (isset($this->_options['packagingroot'])) {
$regdir = $this->_prependPath($this->config->get('php_dir', null, 'pear.php.net'), $this->_options['packagingroot']);
$packrootphp_dir = $this->_prependPath($this->config->get('php_dir', null, $channel), $this->_options['packagingroot']);
}
if (isset($options['installroot'])) {
$this->config->setInstallRoot($options['installroot']);
$this->_registry =& $this->config->getRegistry();
$installregistry =& $this->_registry;
$this->installroot = '';
// all done automagically now
$php_dir = $this->config->get('php_dir', null, $channel);
} else {
$this->config->setInstallRoot(false);
$this->_registry =& $this->config->getRegistry();
if (isset($this->_options['packagingroot'])) {
$installregistry = new PEAR_Registry($regdir);
if (!$installregistry->channelExists($channel, true)) {
// we need to fake a channel-discover of this channel
$chanobj = $this->_registry->getChannel($channel, true);
$installregistry->addChannel($chanobj);
}
$php_dir = $packrootphp_dir;
} else {
$installregistry =& $this->_registry;
$php_dir = $this->config->get('php_dir', null, $channel);
}
$this->installroot = '';
}
// {{{ checks to do when not in "force" mode
if (empty($options['force']) && (file_exists($this->config->get('php_dir')) && is_dir($this->config->get('php_dir')))) {
$testp = $channel == 'pear.php.net' ? $pkgname : array($channel, $pkgname);
$instfilelist = $pkg->getInstallationFileList(true);
if (PEAR::isError($instfilelist)) {
return $instfilelist;
}
// ensure we have the most accurate registry
$installregistry->flushFileMap();
$test = $installregistry->checkFileMap($instfilelist, $testp, '1.1');
if (PEAR::isError($test)) {
return $test;
}
if (sizeof($test)) {
$pkgs = $this->getInstallPackages();
$found = false;
foreach ($pkgs as $param) {
if ($pkg->isSubpackageOf($param)) {
$found = true;
break;
}
}
if ($found) {
// subpackages can conflict with earlier versions of parent packages
$parentreg = $installregistry->packageInfo($param->getPackage(), null, $param->getChannel());
$tmp = $test;
//.........这里部分代码省略.........
示例14: doInfo
function doInfo($command, $options, $params)
{
// $params[0] The package for showing info
if (sizeof($params) != 1) {
return $this->raiseError("This command only accepts one param: " . "the package you want information");
}
if (@is_file($params[0])) {
$obj = new PEAR_Common();
$info = $obj->infoFromAny($params[0]);
} else {
$reg = new PEAR_Registry($this->config->get('php_dir'));
$info = $reg->packageInfo($params[0]);
}
if (PEAR::isError($info)) {
return $info;
}
if (empty($info)) {
$this->raiseError("Nothing found for `{$params['0']}'");
return;
}
unset($info['filelist']);
unset($info['changelog']);
$keys = array_keys($info);
$longtext = array('description', 'summary');
foreach ($keys as $key) {
if (is_array($info[$key])) {
switch ($key) {
case 'maintainers':
$i = 0;
$mstr = '';
foreach ($info[$key] as $m) {
if ($i++ > 0) {
$mstr .= "\n";
}
$mstr .= $m['name'] . " <";
if (isset($m['email'])) {
$mstr .= $m['email'];
} else {
$mstr .= $m['handle'] . '@php.net';
}
$mstr .= "> ({$m['role']})";
}
$info[$key] = $mstr;
break;
case 'release_deps':
$i = 0;
$dstr = '';
foreach ($info[$key] as $d) {
if (isset($this->_deps_rel_trans[$d['rel']])) {
$rel = $this->_deps_rel_trans[$d['rel']];
} else {
$rel = $d['rel'];
}
if (isset($this->_deps_type_trans[$d['type']])) {
$type = ucfirst($this->_deps_type_trans[$d['type']]);
} else {
$type = $d['type'];
}
if (isset($d['name'])) {
$name = $d['name'] . ' ';
} else {
$name = '';
}
if (isset($d['version'])) {
$version = $d['version'] . ' ';
} else {
$version = '';
}
$dstr .= "{$type} {$name}{$rel} {$version}\n";
}
$info[$key] = $dstr;
break;
case 'provides':
$debug = $this->config->get('verbose');
if ($debug < 2) {
$pstr = 'Classes: ';
} else {
$pstr = '';
}
$i = 0;
foreach ($info[$key] as $p) {
if ($debug < 2 && $p['type'] != "class") {
continue;
}
// Only print classes when verbosity mode is < 2
if ($debug < 2) {
if ($i++ > 0) {
$pstr .= ", ";
}
$pstr .= $p['name'];
} else {
if ($i++ > 0) {
$pstr .= "\n";
}
$pstr .= ucfirst($p['type']) . " " . $p['name'];
if (isset($p['explicit']) && $p['explicit'] == 1) {
$pstr .= " (explicit)";
}
}
}
//.........这里部分代码省略.........
示例15: packageInstalled
/**
* Check if a package is installed
*/
function packageInstalled($package_name, $version = null, $pear_user_config = null)
{
if (is_null($pear_user_config)) {
$config = new PEAR_Config();
} else {
$config = new PEAR_Config($pear_user_config);
}
$reg = new PEAR_Registry($config->get('php_dir'));
if (is_null($version)) {
return $reg->packageExists($package_name);
} else {
$installed = $reg->packageInfo($package_name);
return version_compare($version, $installed['version'], '<=');
}
}