Exemplo n.º 1
0
 /**
  * (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;
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 /**
  * 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();
 }
Exemplo n.º 4
0
 /**
  * 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;
 }
Exemplo n.º 5
0
 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;
 }
Exemplo n.º 6
0
 /**
  * @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;
             }
             // construct helpful error message
             if (isset($pname['version'])) {
                 $vs = ', version "' . $pname['version'] . '"';
             } elseif (isset($pname['state'])) {
                 $vs = ', stability "' . $pname['state'] . '"';
             } elseif ($param == 'dependency') {
                 if (!class_exists('PEAR_Common')) {
                     require_once 'PEAR/Common.php';
                 }
                 if (!in_array($info['info']->getState(), PEAR_Common::betterStates($preferred_state, true))) {
                     if ($optional) {
                         // don't spit out confusing error message, and don't die on
                         // optional dep failure!
                         return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
                     }
                     $vs = ' within preferred state "' . $preferred_state . '"';
                 } else {
                     if (!class_exists('PEAR_Dependency2')) {
                         require_once 'PEAR/Dependency2.php';
                     }
                     if ($optional) {
                         // don't spit out confusing error message, and don't die on
                         // optional dep failure!
                         return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
                     }
                     $vs = PEAR_Dependency2::_getExtraString($pname);
                 }
             } else {
                 $vs = ' within preferred state "' . $this->_downloader->config->get('preferred_state') . '"';
             }
             $options = $this->_downloader->getOptions();
             // this is only set by the "download-all" command
             if (isset($options['ignorepreferred_state'])) {
                 $err = PEAR::raiseError('Failed to download ' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package']), true) . $vs . ', latest release is version ' . $info['version'] . ', stability "' . $info['info']->getState() . '", use "' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package'], 'version' => $info['version'])) . '" to install', PEAR_DOWNLOADER_PACKAGE_STATE);
                 return $err;
             }
             // Checks if the user has a package installed already and checks the release against
             // the state against the installed package, this allows upgrades for packages
             // with lower stability than the preferred_state
             $stability = $this->_registry->packageInfo($pname['package'], 'stability', $pname['channel']);
             if (!$this->isInstalled($info) || !in_array($info['info']->getState(), PEAR_Common::betterStates($stability['release'], true))) {
                 $err = PEAR::raiseError('Failed to download ' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package']), true) . $vs . ', latest release is version ' . $info['version'] . ', stability "' . $info['info']->getState() . '", use "' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package'], 'version' => $info['version'])) . '" to install');
                 return $err;
             }
         }
     }
     if (isset($info['deprecated']) && $info['deprecated']) {
         $this->_downloader->log(0, 'WARNING: "' . $this->_registry->parsedPackageNameToString(array('channel' => $info['info']->getChannel(), 'package' => $info['info']->getPackage()), true) . '" is deprecated in favor of "' . $this->_registry->parsedPackageNameToString($info['deprecated'], true) . '"');
     }
     return $info;
 }
Exemplo n.º 7
0
 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;
 }
Exemplo n.º 8
0
 * @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);
Exemplo n.º 9
0
 /**
  * @param array dependency array
  * @access private
  */
 function _getDepPackageDownloadUrl($dep, $parr)
 {
     $xsdversion = isset($dep['rel']) ? '1.0' : '2.0';
     $curchannel = $this->config->get('default_channel');
     if (isset($dep['channel'])) {
         $remotechannel = $dep['channel'];
     } else {
         $remotechannel = 'pear.php.net';
     }
     if (!$this->_registry->channelExists($remotechannel)) {
         do {
             if ($this->config->get('auto_discover')) {
                 if ($this->discover($remotechannel)) {
                     break;
                 }
             }
             return PEAR::raiseError('Unknown remote channel: ' . $remotechannel);
         } while (false);
     }
     $this->configSet('default_channel', $remotechannel);
     $state = isset($parr['state']) ? $parr['state'] : $this->config->get('preferred_state');
     if (isset($parr['state']) && isset($parr['version'])) {
         unset($parr['state']);
     }
     $chan =& $this->_registry->getChannel($remotechannel);
     if (PEAR::isError($chan)) {
         return $chan;
     }
     $version = $this->_registry->packageInfo($dep['name'], 'version', $remotechannel);
     if ($chan->supportsREST($this->config->get('preferred_mirror')) && ($base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror')))) {
         $rest =& $this->config->getREST('1.0', $this->_options);
         $url = $rest->getDepDownloadURL($base, $xsdversion, $dep, $parr, $state, $version);
         if (PEAR::isError($url)) {
             return $url;
         }
         if ($parr['channel'] != $curchannel) {
             $this->configSet('default_channel', $curchannel);
         }
         if (!is_array($url)) {
             return $url;
         }
         $url['raw'] = false;
         // no checking is necessary for REST
         if (!is_array($url['info'])) {
             return PEAR::raiseError('Invalid remote dependencies retrieved from REST - ' . 'this should never happen');
         }
         if (isset($url['info']['required'])) {
             if (!class_exists('PEAR_PackageFile_v2')) {
                 require_once 'PEAR/PackageFile/v2.php';
             }
             $pf = new PEAR_PackageFile_v2();
             $pf->setRawChannel($remotechannel);
         } else {
             if (!class_exists('PEAR_PackageFile_v1')) {
                 require_once 'PEAR/PackageFile/v1.php';
             }
             $pf = new PEAR_PackageFile_v1();
         }
         $pf->setRawPackage($url['package']);
         $pf->setDeps($url['info']);
         $pf->setRawState($url['stability']);
         $url['info'] =& $pf;
         if (!extension_loaded("zlib") || isset($this->_options['nocompress'])) {
             $ext = '.tar';
         } else {
             $ext = '.tgz';
         }
         if (is_array($url)) {
             if (isset($url['url'])) {
                 $url['url'] .= $ext;
             }
         }
         return $url;
     } elseif ($chan->supports('xmlrpc', 'package.getDepDownloadURL', false, '1.1')) {
         if ($version) {
             $url = $this->_remote->call('package.getDepDownloadURL', $xsdversion, $dep, $parr, $state, $version);
         } else {
             $url = $this->_remote->call('package.getDepDownloadURL', $xsdversion, $dep, $parr, $state);
         }
     } else {
         $url = $this->_remote->call('package.getDepDownloadURL', $xsdversion, $dep, $parr, $state);
     }
     if ($parr['channel'] != $curchannel) {
         $this->configSet('default_channel', $curchannel);
     }
     if (!is_array($url)) {
         return $url;
     }
     if (isset($url['__PEAR_ERROR_CLASS__'])) {
         return PEAR::raiseError($url['message']);
     }
     $url['raw'] = $url['info'];
     $pkg =& $this->getPackagefileObject($this->config, $this->debug);
     PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
     $pinfo =& $pkg->fromXmlString($url['info'], PEAR_VALIDATE_DOWNLOADING, 'remote');
     PEAR::staticPopErrorHandling();
     if (PEAR::isError($pinfo)) {
         if (!isset($this->_options['soft'])) {
             $this->log(0, $pinfo->getMessage());
         }
         return PEAR::raiseError('Remote package.xml is not valid - this should never happen');
     }
     $url['info'] =& $pinfo;
     if (is_array($url)) {
         if (!extension_loaded("zlib") || isset($this->_options['nocompress'])) {
             $ext = '.tar';
         } else {
             $ext = '.tgz';
         }
         if (isset($url['url'])) {
             $url['url'] .= $ext;
         }
     }
     return $url;
 }
Exemplo n.º 10
0
 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;
 }
Exemplo n.º 11
0
    $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'])) {
Exemplo n.º 12
0
    $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) {
Exemplo n.º 13
0
 /**
  * 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;
                 foreach ($tmp as $file => $info) {
                     if (is_array($info)) {
                         if (strtolower($info[1]) == strtolower($param->getPackage()) && strtolower($info[0]) == strtolower($param->getChannel())) {
                             if (isset($parentreg['filelist'][$file])) {
                                 unset($parentreg['filelist'][$file]);
                             } else {
                                 $pos = strpos($file, '/');
                                 $basedir = substr($file, 0, $pos);
                                 $file2 = substr($file, $pos + 1);
                                 if (isset($parentreg['filelist'][$file2]['baseinstalldir']) && $parentreg['filelist'][$file2]['baseinstalldir'] === $basedir) {
                                     unset($parentreg['filelist'][$file2]);
                                 }
                             }
                             unset($test[$file]);
                         }
                     } else {
                         if (strtolower($param->getChannel()) != 'pear.php.net') {
                             continue;
                         }
                         if (strtolower($info) == strtolower($param->getPackage())) {
                             if (isset($parentreg['filelist'][$file])) {
                                 unset($parentreg['filelist'][$file]);
                             } else {
                                 $pos = strpos($file, '/');
                                 $basedir = substr($file, 0, $pos);
                                 $file2 = substr($file, $pos + 1);
                                 if (isset($parentreg['filelist'][$file2]['baseinstalldir']) && $parentreg['filelist'][$file2]['baseinstalldir'] === $basedir) {
                                     unset($parentreg['filelist'][$file2]);
                                 }
                             }
                             unset($test[$file]);
                         }
                     }
                 }
                 $pfk = new PEAR_PackageFile($this->config);
                 $parentpkg =& $pfk->fromArray($parentreg);
                 $installregistry->updatePackage2($parentpkg);
             }
             if ($param->getChannel() == 'pecl.php.net' && isset($options['upgrade'])) {
                 $tmp = $test;
                 foreach ($tmp as $file => $info) {
                     if (is_string($info)) {
                         // pear.php.net packages are always stored as strings
                         if (strtolower($info) == strtolower($param->getPackage())) {
                             // upgrading existing package
                             unset($test[$file]);
                         }
                     }
                 }
             }
             if (count($test)) {
                 $msg = "{$channel}/{$pkgname}: conflicting files found:\n";
                 $longest = max(array_map("strlen", array_keys($test)));
                 $fmt = "%{$longest}s (%s)\n";
                 foreach ($test as $file => $info) {
                     if (!is_array($info)) {
                         $info = array('pear.php.net', $info);
                     }
                     $info = $info[0] . '/' . $info[1];
                     $msg .= sprintf($fmt, $file, $info);
                 }
                 if (!isset($options['ignore-errors'])) {
                     return $this->raiseError($msg);
                 }
                 if (!isset($options['soft'])) {
                     $this->log(0, "WARNING: {$msg}");
                 }
             }
         }
     }
     // }}}
     $this->startFileTransaction();
     $usechannel = $channel;
     if ($channel == 'pecl.php.net') {
         $test = $installregistry->packageExists($pkgname, $channel);
         if (!$test) {
             $test = $installregistry->packageExists($pkgname, 'pear.php.net');
             $usechannel = 'pear.php.net';
         }
     } else {
         $test = $installregistry->packageExists($pkgname, $channel);
     }
     if (empty($options['upgrade']) && empty($options['soft'])) {
         // checks to do only when installing new packages
         if (empty($options['force']) && $test) {
             return $this->raiseError("{$channel}/{$pkgname} is already installed");
         }
     } else {
         // Upgrade
         if ($test) {
             $v1 = $installregistry->packageInfo($pkgname, 'version', $usechannel);
             $v2 = $pkg->getVersion();
             $cmp = version_compare("{$v1}", "{$v2}", 'gt');
             if (empty($options['force']) && !version_compare("{$v2}", "{$v1}", 'gt')) {
                 return $this->raiseError("upgrade to a newer version ({$v2} is not newer than {$v1})");
             }
         }
     }
     // Do cleanups for upgrade and install, remove old release's files first
     if ($test && empty($options['register-only'])) {
         // when upgrading, remove old release's files first:
         if (PEAR::isError($err = $this->_deletePackageFiles($pkgname, $usechannel, true))) {
             if (!isset($options['ignore-errors'])) {
                 return $this->raiseError($err);
             }
             if (!isset($options['soft'])) {
                 $this->log(0, 'WARNING: ' . $err->getMessage());
             }
         } else {
             $backedup = $err;
         }
     }
     // {{{ Copy files to dest dir ---------------------------------------
     // info from the package it self we want to access from _installFile
     $this->pkginfo =& $pkg;
     // used to determine whether we should build any C code
     $this->source_files = 0;
     $savechannel = $this->config->get('default_channel');
     if (empty($options['register-only']) && !is_dir($php_dir)) {
         if (PEAR::isError(System::mkdir(array('-p'), $php_dir))) {
             return $this->raiseError("no installation destination directory '{$php_dir}'\n");
         }
     }
     if (substr($pkgfile, -4) != '.xml') {
         $tmpdir .= DIRECTORY_SEPARATOR . $pkgname . '-' . $pkg->getVersion();
     }
     $this->configSet('default_channel', $channel);
     // {{{ install files
     $ver = $pkg->getPackagexmlVersion();
     if (version_compare($ver, '2.0', '>=')) {
         $filelist = $pkg->getInstallationFilelist();
     } else {
         $filelist = $pkg->getFileList();
     }
     if (PEAR::isError($filelist)) {
         return $filelist;
     }
     $p =& $installregistry->getPackage($pkgname, $channel);
     $dirtree = empty($options['register-only']) && $p ? $p->getDirTree() : false;
     $pkg->resetFilelist();
     $pkg->setLastInstalledVersion($installregistry->packageInfo($pkg->getPackage(), 'version', $pkg->getChannel()));
     foreach ($filelist as $file => $atts) {
         $this->expectError(PEAR_INSTALLER_FAILED);
         if ($pkg->getPackagexmlVersion() == '1.0') {
             $res = $this->_installFile($file, $atts, $tmpdir, $options);
         } else {
             $res = $this->_installFile2($pkg, $file, $atts, $tmpdir, $options);
         }
         $this->popExpect();
         if (PEAR::isError($res)) {
             if (empty($options['ignore-errors'])) {
                 $this->rollbackFileTransaction();
                 if ($res->getMessage() == "file does not exist") {
                     $this->raiseError("file {$file} in package.xml does not exist");
                 }
                 return $this->raiseError($res);
             }
             if (!isset($options['soft'])) {
                 $this->log(0, "Warning: " . $res->getMessage());
             }
         }
         $real = isset($atts['attribs']) ? $atts['attribs'] : $atts;
         if ($res == PEAR_INSTALLER_OK && $real['role'] != 'src') {
             // Register files that were installed
             $pkg->installedFile($file, $atts);
         }
     }
     // }}}
     // {{{ compile and install source files
     if ($this->source_files > 0 && empty($options['nobuild'])) {
         if (PEAR::isError($err = $this->_compileSourceFiles($savechannel, $pkg))) {
             return $err;
         }
     }
     // }}}
     if (isset($backedup)) {
         $this->_removeBackups($backedup);
     }
     if (!$this->commitFileTransaction()) {
         $this->rollbackFileTransaction();
         $this->configSet('default_channel', $savechannel);
         return $this->raiseError("commit failed", PEAR_INSTALLER_FAILED);
     }
     // }}}
     $ret = false;
     $installphase = 'install';
     $oldversion = false;
     // {{{ Register that the package is installed -----------------------
     if (empty($options['upgrade'])) {
         // if 'force' is used, replace the info in registry
         $usechannel = $channel;
         if ($channel == 'pecl.php.net') {
             $test = $installregistry->packageExists($pkgname, $channel);
             if (!$test) {
                 $test = $installregistry->packageExists($pkgname, 'pear.php.net');
                 $usechannel = 'pear.php.net';
             }
         } else {
             $test = $installregistry->packageExists($pkgname, $channel);
         }
         if (!empty($options['force']) && $test) {
             $oldversion = $installregistry->packageInfo($pkgname, 'version', $usechannel);
             $installregistry->deletePackage($pkgname, $usechannel);
         }
         $ret = $installregistry->addPackage2($pkg);
     } else {
         if ($dirtree) {
             $this->startFileTransaction();
             // attempt to delete empty directories
             uksort($dirtree, array($this, '_sortDirs'));
             foreach ($dirtree as $dir => $notused) {
                 $this->addFileOperation('rmdir', array($dir));
             }
             $this->commitFileTransaction();
         }
         $usechannel = $channel;
         if ($channel == 'pecl.php.net') {
             $test = $installregistry->packageExists($pkgname, $channel);
             if (!$test) {
                 $test = $installregistry->packageExists($pkgname, 'pear.php.net');
                 $usechannel = 'pear.php.net';
             }
         } else {
             $test = $installregistry->packageExists($pkgname, $channel);
         }
         // new: upgrade installs a package if it isn't installed
         if (!$test) {
             $ret = $installregistry->addPackage2($pkg);
         } else {
             if ($usechannel != $channel) {
                 $installregistry->deletePackage($pkgname, $usechannel);
                 $ret = $installregistry->addPackage2($pkg);
             } else {
                 $ret = $installregistry->updatePackage2($pkg);
             }
             $installphase = 'upgrade';
         }
     }
     if (!$ret) {
         $this->configSet('default_channel', $savechannel);
         return $this->raiseError("Adding package {$channel}/{$pkgname} to registry failed");
     }
     // }}}
     $this->configSet('default_channel', $savechannel);
     if (class_exists('PEAR_Task_Common')) {
         // this is auto-included if any tasks exist
         if (PEAR_Task_Common::hasPostinstallTasks()) {
             PEAR_Task_Common::runPostinstallTasks($installphase);
         }
     }
     return $pkg->toArray(true);
 }
Exemplo n.º 14
0
 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)";
                             }
                         }
                     }
                     $info[$key] = $pstr;
                     break;
                 default:
                     $info[$key] = implode(", ", $info[$key]);
                     break;
             }
         }
         if ($key == '_lastmodified') {
             $hdate = date('Y-m-d', $info[$key]);
             unset($info[$key]);
             $info['Last Modified'] = $hdate;
         } else {
             $info[$key] = trim($info[$key]);
             if (in_array($key, $longtext)) {
                 $info[$key] = preg_replace('/  +/', ' ', $info[$key]);
             }
         }
     }
     $caption = 'About ' . $info['package'] . '-' . $info['version'];
     $data = array('caption' => $caption, 'border' => true);
     foreach ($info as $key => $value) {
         $key = ucwords(trim(str_replace('_', ' ', $key)));
         $data['data'][] = array($key, $value);
     }
     $data['raw'] = $info;
     $this->ui->outputData($data, 'package-info');
 }
Exemplo n.º 15
0
 /**
  * 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'], '<=');
     }
 }
Exemplo n.º 16
0
 function doListUpgrades($command, $options, $params)
 {
     include_once "PEAR/Registry.php";
     $remote = new PEAR_Remote($this->config);
     if (empty($params[0])) {
         $state = $this->config->get('preferred_state');
     } else {
         $state = $params[0];
     }
     $caption = 'Available Upgrades';
     if (empty($state) || $state == 'any') {
         $latest = $remote->call("package.listLatestReleases");
     } else {
         $latest = $remote->call("package.listLatestReleases", $state);
         $caption .= ' (' . $state . ')';
     }
     $caption .= ':';
     if (PEAR::isError($latest)) {
         return $latest;
     }
     $reg = new PEAR_Registry($this->config->get('php_dir'));
     $inst = array_flip($reg->listPackages());
     $data = array('caption' => $caption, 'border' => 1, 'headline' => array('Package', 'Version', 'Size'));
     foreach ($latest as $package => $info) {
         if (!isset($inst[$package])) {
             // skip packages we don't have installed
             continue;
         }
         extract($info);
         $inst_version = $reg->packageInfo($package, 'version');
         if (version_compare("{$version}", "{$inst_version}", "le")) {
             // installed version is up-to-date
             continue;
         }
         if ($filesize >= 20480) {
             $filesize += 1024 - $filesize % 1024;
             $fs = sprintf("%dkB", $filesize / 1024);
         } elseif ($filesize > 0) {
             $filesize += 103 - $filesize % 103;
             $fs = sprintf("%.1fkB", $filesize / 1024.0);
         } else {
             $fs = "  -";
             // XXX center instead
         }
         $data['data'][] = array($package, $version, $fs);
     }
     if (empty($data['data'])) {
         $this->ui->outputData('No upgrades available');
     } else {
         $this->ui->outputData($data, $command);
     }
     return true;
 }
Exemplo n.º 17
0
<?php

# $NetBSD: pear_plist.php,v 1.9 2015/12/11 16:16:48 taca Exp $
# Parses package XML file and outputs appropriate PLIST
include_once "PEAR/Registry.php";
include_once "PEAR/PackageFile.php";
$PREFIX = getenv('PREFIX');
$PEAR_LIB = getenv('PEAR_LIB');
$WRKSRC = getenv('WRKSRC');
if (!($DESTDIR = getenv('DESTDIR'))) {
    $DESTDIR = '';
}
$config = PEAR_Config::singleton();
$package = new PEAR_PackageFile($config);
$info = $package->fromAnyFile("{$WRKSRC}/package.xml", PEAR_VALIDATE_INSTALLING);
$pkg = $info->getName();
$channel = $info->getChannel();
$registry = new PEAR_Registry($DESTDIR . $PREFIX . "/" . $PEAR_LIB);
$flist = $registry->packageInfo($pkg, 'filelist', $channel);
$regfile = $PEAR_LIB . '/.registry/.channel.' . $channel . '/' . strtolower($pkg) . '.reg';
if (!file_exists($DESTDIR . $PREFIX . '/' . $regfile)) {
    $regfile = $PEAR_LIB . '/.registry/' . strtolower($pkg) . '.reg';
}
echo "{$regfile}\n";
# output list of package files, in same order as specified in package
foreach ($flist as $f) {
    echo str_replace($PREFIX . '/', '', $f['installed_as']) . "\n";
}
Exemplo n.º 18
0
 /**
  * Process a dependency, download if necessary
  * @param array dependency information from PEAR_Remote call
  * @param array packages that will be installed in this iteration
  * @return false|string|PEAR_Error
  * @access private
  * @todo Add test for relation 'lt'/'le' -> make sure that the dependency requested is
  *       in fact lower than the required value.  This will be very important for BC dependencies
  */
 function _processDependency($package, $info, $mywillinstall)
 {
     $state = $this->_preferredState;
     if (!isset($this->_options['alldeps']) && isset($info['optional']) && $info['optional'] == 'yes') {
         // skip optional deps
         $this->log(0, "skipping Package '{$package}' optional dependency '{$info['name']}'");
         return false;
     }
     // {{{ get releases
     $releases = $this->_remote->call('package.info', $info['name'], 'releases', true);
     if (PEAR::isError($releases)) {
         return $releases;
     }
     if (!count($releases)) {
         if (!isset($this->_installed[strtolower($info['name'])])) {
             $this->pushError("Package '{$package}' dependency '{$info['name']}' " . "has no releases");
         }
         return false;
     }
     $found = false;
     $save = $releases;
     while (count($releases) && !$found) {
         if (!empty($state) && $state != 'any') {
             list($release_version, $release) = each($releases);
             if ($state != $release['state'] && !in_array($release['state'], $this->betterStates($state))) {
                 // drop this release - it ain't stable enough
                 array_shift($releases);
             } else {
                 $found = true;
             }
         } else {
             $found = true;
         }
     }
     if (!count($releases) && !$found) {
         $get = array();
         foreach ($save as $release) {
             $get = array_merge($get, $this->betterStates($release['state'], true));
         }
         $savestate = array_shift($get);
         $this->pushError("Release for '{$package}' dependency '{$info['name']}' " . "has state '{$savestate}', requires '{$state}'");
         return false;
     }
     if (in_array(strtolower($info['name']), $this->_toDownload) || isset($mywillinstall[strtolower($info['name'])])) {
         // skip upgrade check for packages we will install
         return false;
     }
     if (!isset($this->_installed[strtolower($info['name'])])) {
         // check to see if we can install the specific version required
         if ($info['rel'] == 'eq') {
             return $info['name'] . '-' . $info['version'];
         }
         // skip upgrade check for packages we don't have installed
         return $info['name'];
     }
     // }}}
     // {{{ see if a dependency must be upgraded
     $inst_version = $this->_registry->packageInfo($info['name'], 'version');
     if (!isset($info['version'])) {
         // this is a rel='has' dependency, check against latest
         if (version_compare($release_version, $inst_version, 'le')) {
             return false;
         } else {
             return $info['name'];
         }
     }
     if (version_compare($info['version'], $inst_version, 'le')) {
         // installed version is up-to-date
         return false;
     }
     return $info['name'];
 }
Exemplo n.º 19
0
 /**
  * @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['uri'])) {
         $xsdversion = '2.0';
         $chan =& $this->_registry->getChannel('__uri');
         if (PEAR::isError($chan)) {
             return $chan;
         }
         $version = $this->_registry->packageInfo($dep['name'], 'version', '__uri');
         $this->configSet('default_channel', '__uri');
     } else {
         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);
         }
         $chan =& $this->_registry->getChannel($remotechannel);
         if (PEAR::isError($chan)) {
             return $chan;
         }
         $version = $this->_registry->packageInfo($dep['name'], 'version', $remotechannel);
         $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']);
     }
     if (isset($dep['uri'])) {
         $info =& $this->newDownloaderPackage($this);
         PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
         $err = $info->initialize($dep);
         PEAR::staticPopErrorHandling();
         if (!$err) {
             // skip parameters that were missed by preferred_state
             return PEAR::raiseError('Cannot initialize dependency');
         }
         if (PEAR::isError($err)) {
             if (!isset($this->_options['soft'])) {
                 $this->log(0, $err->getMessage());
             }
             if (is_object($info)) {
                 $param = $info->getChannel() . '/' . $info->getPackage();
             }
             return PEAR::raiseError('Package "' . $param . '" is not valid');
         }
         return $info;
     } elseif ($chan->supportsREST($this->config->get('preferred_mirror')) && (($base2 = $chan->getBaseURL('REST1.3', $this->config->get('preferred_mirror'))) || ($base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))))) {
         if ($base2) {
             $base = $base2;
             $rest =& $this->config->getREST('1.3', $this->_options);
         } else {
             $rest =& $this->config->getREST('1.0', $this->_options);
         }
         $url = $rest->getDepDownloadURL($base, $xsdversion, $dep, $parr, $state, $version, $chan->getName());
         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']);
         if ($url['compatible']) {
             $pf->setCompatible($url['compatible']);
         }
         $pf->setRawState($url['stability']);
         $url['info'] =& $pf;
         if (!extension_loaded("zlib") || isset($this->_options['nocompress'])) {
             $ext = '.tar';
         } else {
             $ext = '.tgz';
         }
         if (is_array($url) && isset($url['url'])) {
             $url['url'] .= $ext;
         }
         return $url;
     }
     return $this->raiseError($parr['channel'] . ' is using a unsupported protocol - This should never happen.');
 }
Exemplo n.º 20
0
 /**
  * Add the widgets that make up the dependencies page.
  *
  * The dependencies page consists of one widget to 
  * display installed packages, one widget to display
  * packages selected as dependencies, a button to clear
  * the selected list and a button to add the dependencies.
  *
  * @return array
  * @access private
  */
 function _createAddDependenciesPage()
 {
     // An HBox holds everything.
     $mainVBox =& new GtkVBox();
     // Two VBoxes hold the tree and list.
     $topVBox =& new GtkVBox();
     $bottomVBox =& new GtkVBox();
     $buttonHBox =& new GtkHBox();
     // We need a label to make to tell people to click
     // the package make it optional.
     $instructions =& new GtkLabel('Click a package to make it an optional dependency.');
     // Put the tree in a scrolling window.
     $treeScrolledWindow =& new GtkScrolledWindow();
     $treeScrolledWindow->set_policy(GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
     $listScrolledWindow =& new GtkScrolledWindow();
     $listScrolledWindow->set_policy(GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
     $treeScrolledWindow->set_usize(200, 150);
     $listScrolledWindow->set_usize(200, 150);
     // Create the tree.
     $cTree =& new GtkCTree(1, 0);
     $cTree->set_line_style(GTK_CTREE_LINES_SOLID);
     $root =& $cTree->insert_node(NULL, NULL, array('Packages'), 0, NULL, NULL, NULL, NULL, NULL, NULL);
     // Use PEAR_Registry to build the tree.
     require_once 'PEAR/Registry.php';
     $reg = new PEAR_Registry();
     // Loop through the packages and add a node for each
     // package with a child for the version.
     foreach ($reg->packageInfo() as $package) {
         // I don't know why but some return info from PEAR_Registry
         // has no package name. That aint cool!
         if (empty($package['package'])) {
             continue;
         }
         $name =& $cTree->insert_node($root, NULL, array($package['package']), 0, NULL, NULL, NULL, NULL, NULL, NULL);
         $version =& $cTree->insert_node($name, NULL, array($package['version']), 0, NULL, NULL, NULL, NULL, NULL, NULL);
         // Set some data so that we can tell what the user
         // selected later.
         $cTree->node_set_row_data($version, array($package['package'], $package['version'], ''));
         // Add the older versions if there are any.
         if (count($package['changelog'])) {
             foreach ($package['changelog'] as $change) {
                 if ($change['version'] != $package['version']) {
                     $oldVersion =& $cTree->insert_node($name, NULL, array($change['version']), 0, NULL, NULL, NULL, NULL, NULL, NULL);
                     $cTree->node_set_row_data($oldVersion, array($package['package'], $change['version'], ''));
                 }
             }
         }
     }
     // Organize the list.
     $cTree->sort();
     // Create a GtkCList to show the added dependencies.
     $cList =& new GtkCList(3, array('Package', 'Version', 'Optional'));
     // Make the first column automatically adjust to
     // the needed width.
     $cList->set_column_auto_resize(0, true);
     // Automatically sort the entries.
     $cList->set_auto_sort(true);
     // When the user selects a package we want to toggle
     // its optional status.
     $cList->connect('select-row', array(&$this, '_toggleOptional'));
     // Connect the tree-select-row so that the user
     // can add information.
     $cTree->connect('tree-select-row', array(&$this, '_treeToCList'), $cList);
     // Show dependencies from import in cList.
     $this->_getDependencies($cList);
     // Add some buttons to make things a little easier to
     // work with.
     $clearButton =& new GtkButton('Clear');
     $addButton =& new GtkButton('Add Dependencies');
     // We also want an auto detect button.
     $autoButton =& new GtkButton('Auto Detect');
     // The clear but should clear out the cList.
     // Clearing dependencies already in a package file
     // is not possible.
     $clearButton->connect_object('clicked', array(&$cList, 'clear'));
     $clearButton->connect_object('clicked', array(&$this->_packageFileManager, 'setOptions'), $this->_options + array('deps' => array()));
     // The auto detect button should be connected to the PFM
     // detectDependencies method.
     $autoButton->connect_object('clicked', array(&$this->_packageFileManager, 'detectDependencies'));
     // We need to let the user know that it did something.
     $autoButton->connect_object_after('clicked', array(&$this, '_getDependencies'), $cList);
     // The add button should add the dependencies from the cList
     // to the package.
     $addButton->connect_object('clicked', array(&$this, '_addDependencies'), $cList);
     // Pack everything away.
     $treeScrolledWindow->add($cTree);
     $topVBox->pack_start($treeScrolledWindow);
     $listScrolledWindow->add($cList);
     $bottomVBox->pack_start($listScrolledWindow);
     $buttonHBox->pack_start($clearButton, false, false, 3);
     $buttonHBox->pack_start($autoButton, false, false, 3);
     $buttonHBox->pack_end($addButton, false, false, 3);
     $mainVBox->pack_start($topVBox);
     $mainVBox->pack_start($bottomVBox);
     $mainVBox->pack_start($instructions);
     $mainVBox->pack_start($buttonHBox);
     return array(&$mainVBox, new GtkLabel('Depenedencies'));
 }