예제 #1
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;
 }
예제 #2
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;
 }
예제 #3
0
 /**
  * @param PEAR_Frontend_*
  * @param array
  * @param PEAR_Config
  */
 function PEAR_Downloader(&$ui, $options, &$config)
 {
     parent::PEAR_Common();
     $this->_options = $options;
     $this->config =& $config;
     $this->_preferredState = $this->config->get('preferred_state');
     $this->ui =& $ui;
     if (!$this->_preferredState) {
         // don't inadvertantly use a non-set preferred_state
         $this->_preferredState = null;
     }
     if (isset($this->_options['installroot'])) {
         $this->config->setInstallRoot($this->_options['installroot']);
     }
     $this->_registry =& $config->getRegistry();
     if (isset($this->_options['alldeps']) || isset($this->_options['onlyreqdeps'])) {
         $this->_installed = $this->_registry->listAllPackages();
         foreach ($this->_installed as $key => $unused) {
             if (!count($unused)) {
                 continue;
             }
             $strtolower = create_function('$a', 'return strtolower($a);');
             array_walk($this->_installed[$key], $strtolower);
         }
     }
 }
예제 #4
0
   | This source file is subject to version 2.02 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available at through the world-wide-web at                           |
   | http://www.php.net/license/2_02.txt.                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
   +----------------------------------------------------------------------+
   | Authors:                                                             |
   +----------------------------------------------------------------------+
   $Id$
*/
require_once "PEAR/Common.php";
auth_require(true);
response_header('Fix Dependencies');
$pc = new PEAR_Common();
$pkg_id2name = $dbh->getAssoc("SELECT id,name FROM packages");
$rel_id2name = $dbh->getAssoc("SELECT r.id,concat_ws('-', p.name, r.version) FROM packages p, releases r WHERE r.package = p.id");
print "<h2>Deleting Existing Dependencies...</h2>\n";
$dbh->setOption("optimize", "portability");
$dbh->query("DELETE FROM deps");
$ar = $dbh->affectedRows();
$dbh->setOption("optimize", "performance");
print "{$ar} rows deleted<br />\n";
print "<h2>Inserting New Dependencies...</h2>\n";
$sth = $dbh->query("SELECT package, release, fullpath FROM files");
while ($sth->fetchInto($row)) {
    list($package, $release, $fullpath) = $row;
    printf("<h3>%s (package %d, release %d):</h3>\n", basename($fullpath), $package, $release);
    if (!@file_exists($fullpath)) {
        continue;
예제 #5
0
 /**
  * Check if role is valid
  *
  * @static
  * @param string Name of the role
  * @return boolean
  */
 function isValidRole($role)
 {
     require_once "PEAR/Common.php";
     static $roles;
     if (empty($roles)) {
         $roles = PEAR_Common::getUserRoles();
     }
     return in_array($role, $roles);
 }
예제 #6
0
 function _convertPackage($packagexml)
 {
     $pkg =& $this->getPackageFile($this->config);
     $pf2 =& $pkg->fromPackageFile($packagexml, PEAR_VALIDATE_NORMAL);
     if (!is_a($pf2, 'PEAR_PackageFile_v2')) {
         return $this->raiseError('Cannot process "' . $packagexml . '", is not a package.xml 2.0');
     }
     require_once 'PEAR/PackageFile/v1.php';
     $pf = new PEAR_PackageFile_v1();
     $pf->setConfig($this->config);
     if ($pf2->getPackageType() != 'extsrc' && $pf2->getPackageType() != 'zendextsrc') {
         return $this->raiseError('Cannot safely convert "' . $packagexml . '", is not an extension source package.  Using a PEAR_PackageFileManager-based ' . 'script is an option');
     }
     if (is_array($pf2->getUsesRole())) {
         return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains custom roles.  Using a PEAR_PackageFileManager-based script or ' . 'the convert command is an option');
     }
     if (is_array($pf2->getUsesTask())) {
         return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains custom tasks.  Using a PEAR_PackageFileManager-based script or ' . 'the convert command is an option');
     }
     $deps = $pf2->getDependencies();
     if (isset($deps['group'])) {
         return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains dependency groups.  Using a PEAR_PackageFileManager-based script ' . 'or the convert command is an option');
     }
     if (isset($deps['required']['subpackage']) || isset($deps['optional']['subpackage'])) {
         return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains subpackage dependencies.  Using a PEAR_PackageFileManager-based  ' . 'script is an option');
     }
     if (isset($deps['required']['os'])) {
         return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains os dependencies.  Using a PEAR_PackageFileManager-based  ' . 'script is an option');
     }
     if (isset($deps['required']['arch'])) {
         return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains arch dependencies.  Using a PEAR_PackageFileManager-based  ' . 'script is an option');
     }
     $pf->setPackage($pf2->getPackage());
     $pf->setSummary($pf2->getSummary());
     $pf->setDescription($pf2->getDescription());
     foreach ($pf2->getMaintainers() as $maintainer) {
         $pf->addMaintainer($maintainer['role'], $maintainer['handle'], $maintainer['name'], $maintainer['email']);
     }
     $pf->setVersion($pf2->getVersion());
     $pf->setDate($pf2->getDate());
     $pf->setLicense($pf2->getLicense());
     $pf->setState($pf2->getState());
     $pf->setNotes($pf2->getNotes());
     $pf->addPhpDep($deps['required']['php']['min'], 'ge');
     if (isset($deps['required']['php']['max'])) {
         $pf->addPhpDep($deps['required']['php']['max'], 'le');
     }
     if (isset($deps['required']['package'])) {
         if (!isset($deps['required']['package'][0])) {
             $deps['required']['package'] = array($deps['required']['package']);
         }
         foreach ($deps['required']['package'] as $dep) {
             if (!isset($dep['channel'])) {
                 return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . ' contains uri-based dependency on a package.  Using a ' . 'PEAR_PackageFileManager-based script is an option');
             }
             if ($dep['channel'] != 'pear.php.net' && $dep['channel'] != 'pecl.php.net') {
                 return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . ' contains dependency on a non-standard channel package.  Using a ' . 'PEAR_PackageFileManager-based script is an option');
             }
             if (isset($dep['conflicts'])) {
                 return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . ' contains conflicts dependency.  Using a ' . 'PEAR_PackageFileManager-based script is an option');
             }
             if (isset($dep['exclude'])) {
                 $this->ui->outputData('WARNING: exclude tags are ignored in conversion');
             }
             if (isset($dep['min'])) {
                 $pf->addPackageDep($dep['name'], $dep['min'], 'ge');
             }
             if (isset($dep['max'])) {
                 $pf->addPackageDep($dep['name'], $dep['max'], 'le');
             }
         }
     }
     if (isset($deps['required']['extension'])) {
         if (!isset($deps['required']['extension'][0])) {
             $deps['required']['extension'] = array($deps['required']['extension']);
         }
         foreach ($deps['required']['extension'] as $dep) {
             if (isset($dep['conflicts'])) {
                 return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . ' contains conflicts dependency.  Using a ' . 'PEAR_PackageFileManager-based script is an option');
             }
             if (isset($dep['exclude'])) {
                 $this->ui->outputData('WARNING: exclude tags are ignored in conversion');
             }
             if (isset($dep['min'])) {
                 $pf->addExtensionDep($dep['name'], $dep['min'], 'ge');
             }
             if (isset($dep['max'])) {
                 $pf->addExtensionDep($dep['name'], $dep['max'], 'le');
             }
         }
     }
     if (isset($deps['optional']['package'])) {
         if (!isset($deps['optional']['package'][0])) {
             $deps['optional']['package'] = array($deps['optional']['package']);
         }
         foreach ($deps['optional']['package'] as $dep) {
             if (!isset($dep['channel'])) {
                 return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . ' contains uri-based dependency on a package.  Using a ' . 'PEAR_PackageFileManager-based script is an option');
             }
             if ($dep['channel'] != 'pear.php.net' && $dep['channel'] != 'pecl.php.net') {
                 return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . ' contains dependency on a non-standard channel package.  Using a ' . 'PEAR_PackageFileManager-based script is an option');
             }
             if (isset($dep['exclude'])) {
                 $this->ui->outputData('WARNING: exclude tags are ignored in conversion');
             }
             if (isset($dep['min'])) {
                 $pf->addPackageDep($dep['name'], $dep['min'], 'ge', 'yes');
             }
             if (isset($dep['max'])) {
                 $pf->addPackageDep($dep['name'], $dep['max'], 'le', 'yes');
             }
         }
     }
     if (isset($deps['optional']['extension'])) {
         if (!isset($deps['optional']['extension'][0])) {
             $deps['optional']['extension'] = array($deps['optional']['extension']);
         }
         foreach ($deps['optional']['extension'] as $dep) {
             if (isset($dep['exclude'])) {
                 $this->ui->outputData('WARNING: exclude tags are ignored in conversion');
             }
             if (isset($dep['min'])) {
                 $pf->addExtensionDep($dep['name'], $dep['min'], 'ge', 'yes');
             }
             if (isset($dep['max'])) {
                 $pf->addExtensionDep($dep['name'], $dep['max'], 'le', 'yes');
             }
         }
     }
     $contents = $pf2->getContents();
     $release = $pf2->getReleases();
     if (isset($releases[0])) {
         return $this->raiseError('Cannot safely process "' . $packagexml . '" contains ' . 'multiple extsrcrelease/zendextsrcrelease tags.  Using a PEAR_PackageFileManager-based script ' . 'or the convert command is an option');
     }
     if ($configoptions = $pf2->getConfigureOptions()) {
         foreach ($configoptions as $option) {
             $pf->addConfigureOption($option['name'], $option['prompt'], isset($option['default']) ? $option['default'] : false);
         }
     }
     if (isset($release['filelist']['ignore'])) {
         return $this->raiseError('Cannot safely process "' . $packagexml . '" contains ' . 'ignore tags.  Using a PEAR_PackageFileManager-based script or the convert' . ' command is an option');
     }
     if (isset($release['filelist']['install']) && !isset($release['filelist']['install'][0])) {
         $release['filelist']['install'] = array($release['filelist']['install']);
     }
     if (isset($contents['dir']['attribs']['baseinstalldir'])) {
         $baseinstalldir = $contents['dir']['attribs']['baseinstalldir'];
     } else {
         $baseinstalldir = false;
     }
     if (!isset($contents['dir']['file'][0])) {
         $contents['dir']['file'] = array($contents['dir']['file']);
     }
     foreach ($contents['dir']['file'] as $file) {
         if ($baseinstalldir && !isset($file['attribs']['baseinstalldir'])) {
             $file['attribs']['baseinstalldir'] = $baseinstalldir;
         }
         $processFile = $file;
         unset($processFile['attribs']);
         if (count($processFile)) {
             foreach ($processFile as $name => $task) {
                 if ($name != $pf2->getTasksNs() . ':replace') {
                     return $this->raiseError('Cannot safely process "' . $packagexml . '" contains tasks other than replace.  Using a ' . 'PEAR_PackageFileManager-based script is an option.');
                 }
                 $file['attribs']['replace'][] = $task;
             }
         }
         if (!in_array($file['attribs']['role'], PEAR_Common::getFileRoles())) {
             return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains custom roles.  Using a PEAR_PackageFileManager-based script ' . 'or the convert command is an option');
         }
         if (isset($release['filelist']['install'])) {
             foreach ($release['filelist']['install'] as $installas) {
                 if ($installas['attribs']['name'] == $file['attribs']['name']) {
                     $file['attribs']['install-as'] = $installas['attribs']['as'];
                 }
             }
         }
         $pf->addFile('/', $file['attribs']['name'], $file['attribs']);
     }
     if ($pf2->getChangeLog()) {
         $this->ui->outputData('WARNING: changelog is not translated to package.xml ' . '1.0, use PEAR_PackageFileManager-based script if you need changelog-' . 'translation for package.xml 1.0');
     }
     $gen =& $pf->getDefaultGenerator();
     $gen->toPackageFile('.');
 }
예제 #7
0
 function _PEAR_Packager()
 {
     parent::_PEAR_Common();
 }
예제 #8
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?
  * @access private
  */
 function _analyzeDownloadURL($info, $param, $pname, $params = null, $optional = false)
 {
     if (!is_string($param) && PEAR_Downloader_Package::willDownload($param, $params)) {
         return false;
     }
     if (!$info) {
         if (!is_string($param)) {
             $saveparam = ", cannot download \"{$param}\"";
         } else {
             $saveparam = '';
         }
         // no releases exist
         return PEAR::raiseError('No releases for package "' . $this->_registry->parsedPackageNameToString($pname, true) . '" exist' . $saveparam);
     }
     if (strtolower($info['info']->getChannel()) != strtolower($pname['channel'])) {
         $err = false;
         if ($pname['channel'] == 'pecl.php.net') {
             if ($info['info']->getChannel() != 'pear.php.net') {
                 $err = true;
             }
         } elseif ($info['info']->getChannel() == 'pecl.php.net') {
             if ($pname['channel'] != 'pear.php.net') {
                 $err = true;
             }
         } else {
             $err = true;
         }
         if ($err) {
             return PEAR::raiseError('SECURITY ERROR: package in channel "' . $pname['channel'] . '" retrieved another channel\'s name for download! ("' . $info['info']->getChannel() . '")');
         }
     }
     if (!isset($info['url'])) {
         $instead = ', will instead download version ' . $info['version'] . ', stability "' . $info['info']->getState() . '"';
         // releases exist, but we failed to get any
         if (isset($this->_downloader->_options['force'])) {
             if (isset($pname['version'])) {
                 $vs = ', version "' . $pname['version'] . '"';
             } elseif (isset($pname['state'])) {
                 $vs = ', stability "' . $pname['state'] . '"';
             } elseif ($param == 'dependency') {
                 if (!class_exists('PEAR_Common')) {
                     require_once 'PEAR/Common.php';
                 }
                 if (!in_array($info['info']->getState(), PEAR_Common::betterStates($this->_config->get('preferred_state'), true))) {
                     if ($optional) {
                         // don't spit out confusing error message
                         return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
                     }
                     $vs = ' within preferred state "' . $this->_config->get('preferred_state') . '"';
                 } else {
                     if (!class_exists('PEAR_Dependency2')) {
                         require_once 'PEAR/Dependency2.php';
                     }
                     if ($optional) {
                         // don't spit out confusing error message
                         return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
                     }
                     $vs = PEAR_Dependency2::_getExtraString($pname);
                     $instead = '';
                 }
             } else {
                 $vs = ' within preferred state "' . $this->_config->get('preferred_state') . '"';
             }
             if (!isset($options['soft'])) {
                 $this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] . '/' . $pname['package'] . $vs . $instead);
             }
             // download the latest release
             return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
         } else {
             // construct helpful error message
             if (isset($pname['version'])) {
                 $vs = ', version "' . $pname['version'] . '"';
             } elseif (isset($pname['state'])) {
                 $vs = ', stability "' . $pname['state'] . '"';
             } elseif ($param == 'dependency') {
                 if (!class_exists('PEAR_Common')) {
                     require_once 'PEAR/Common.php';
                 }
                 if (!in_array($info['info']->getState(), PEAR_Common::betterStates($this->_config->get('preferred_state'), true))) {
                     if ($optional) {
                         // don't spit out confusing error message, and don't die on
                         // optional dep failure!
                         return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
                     }
                     $vs = ' within preferred state "' . $this->_config->get('preferred_state') . '"';
                 } else {
                     if (!class_exists('PEAR_Dependency2')) {
                         require_once 'PEAR/Dependency2.php';
                     }
                     if ($optional) {
                         // don't spit out confusing error message, and don't die on
                         // optional dep failure!
                         return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
                     }
                     $vs = PEAR_Dependency2::_getExtraString($pname);
                 }
             } else {
                 $vs = ' within preferred state "' . $this->_downloader->config->get('preferred_state') . '"';
             }
             $err = PEAR::raiseError('Failed to download ' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package']), true) . $vs . ', latest release is version ' . $info['version'] . ', stability "' . $info['info']->getState() . '", use "' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package'], 'version' => $info['version'])) . '" to install');
             return $err;
         }
     }
     return $info;
 }
 function analyzeSourceCode($file)
 {
     return PEAR_Common::analyzeSourceCode($file);
 }
예제 #10
0
 function mkDirHier($dir)
 {
     $this->addFileOperation('mkdir', array($dir));
     return parent::mkDirHier($dir);
 }
예제 #11
0
    $cookies = $response->getCookies();
    $session = $cookies[0]['value'];
    
    $send = new HTTP_Request2($hostname . '/syncACL.php/sync');
    $send->addCookie('PHPSESSID', $session);
    $send->addPostParameter('salt', $salt);
    $send->addPostParameter('package',     $_POST['name']);
    $send->addPostParameter('maintainers', $maintainers);
    $send->addPostParameter('project',     'pear1');
    $response = $send->send();
    $sendBody = $response->getBody();
    $sendCode = $response->getCode();
    */
}
include_once 'PEAR/Common.php';
$roles = PEAR_Common::getUserRoles();
$csrf_token_value = create_csrf_token($csrf_token_name);
?>
<h1>Package Information: <?php 
echo $package_name;
?>
</h1>
<?php 
print_package_navigation($pid, $package_name, '/admin/package-maintainers.php?pid=' . $pid);
?>
<form name="maintainers_edit" method="post" action="?pid=<?php 
echo $pid;
?>
">
<table class="form-holder" style="margin-bottom: 2em;" cellspacing="1" border="0">
<caption class="form-caption">Edit Maintainers list</caption>
예제 #12
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');
 }
예제 #13
0
 /**
  * Compare two package's package.xml, and sort
  * so that dependencies are uninstalled last
  *
  * This is a crude compare, real dependency checking is done on uninstall.
  * The only purpose this serves is to make the command-line
  * order-independent (you can list a dependency first, and
  * uninstallation occurs in the order required)
  * @access private
  */
 function _sortPkgDepsRev($p1, $p2)
 {
     $p1name = $p1['info']['package'];
     $p2name = $p2['info']['package'];
     $p1deps = PEAR_Common::_getRevPkgDeps($p1);
     $p2deps = PEAR_Common::_getRevPkgDeps($p2);
     if (!count($p1deps) && !count($p2deps)) {
         return 0;
         // order makes no difference
     }
     if (!count($p1deps)) {
         return 1;
         // package 2 has dependencies, package 1 doesn't
     }
     if (!count($p2deps)) {
         return -1;
         // package 2 has dependencies, package 1 doesn't
     }
     // both have dependencies
     if (in_array($p1name, $p2deps)) {
         return 1;
         // put package 1 last
     }
     if (in_array($p2name, $p1deps)) {
         return -1;
         // put package 2 last
     }
     // doesn't really matter if neither depends on the other
     return 0;
 }
예제 #14
0
파일: Remote.php 프로젝트: alex-k/velotur
 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 .= ' (' . implode(', ', PEAR_Common::betterStates($state, true)) . ')';
     }
     $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', 'Local', 'Remote', 'Size'));
     foreach ((array) $latest as $pkg => $info) {
         $package = strtolower($pkg);
         if (!isset($inst[$package])) {
             // skip packages we don't have installed
             continue;
         }
         extract($info);
         $pkginfo = $reg->packageInfo($package);
         $inst_version = $pkginfo['version'];
         $inst_state = $pkginfo['release_state'];
         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($pkg, "{$inst_version} ({$inst_state})", "{$version} ({$state})", $fs);
     }
     if (empty($data['data'])) {
         $this->ui->outputData('No upgrades available');
     } else {
         $this->ui->outputData($data, $command);
     }
     return true;
 }
 /**
  * Writes the package.xml file out with the newly created <release></release> tag
  *
  * ALWAYS use {@link debugPackageFile} to verify that output is correct before
  * overwriting your package.xml
  *
  * @param boolean $debuginterface (optional) null if no debugging, true if web interface, false if command-line
  *
  * @throws PEAR_PACKAGEFILEMANAGER_RUN_SETOPTIONS
  * @throws PEAR_PACKAGEFILEMANAGER_ADD_MAINTAINERS
  * @throws PEAR_PACKAGEFILEMANAGER_NONOTES
  * @throws PEAR_PACKAGEFILEMANAGER_NOLICENSE
  * @throws PEAR_PACKAGEFILEMANAGER_INVALID_PACKAGE
  * @throws PEAR_PACKAGEFILEMANAGER_CANTWRITE_PKGFILE
  * @throws PEAR_PACKAGEFILEMANAGER_CANTCOPY_PKGFILE
  * @throws PEAR_PACKAGEFILEMANAGER_CANTOPEN_TMPPKGFILE
  * @throws PEAR_PACKAGEFILEMANAGER_DEST_UNWRITABLE
  * @return true|PEAR_Error
  * @access public
  * @since  0.1
  */
 function writePackageFile($debuginterface = null)
 {
     if (!$this->_packageXml) {
         return $this->raiseError(PEAR_PACKAGEFILEMANAGER_RUN_SETOPTIONS);
     }
     if (!isset($this->_packageXml['maintainers']) || empty($this->_packageXml['maintainers'])) {
         return $this->raiseError(PEAR_PACKAGEFILEMANAGER_ADD_MAINTAINERS);
     }
     if (!isset($this->_options['notes']) || empty($this->_options['notes'])) {
         return $this->raiseError(PEAR_PACKAGEFILEMANAGER_NONOTES);
     }
     if (!isset($this->_options['license']) || empty($this->_options['license'])) {
         return $this->raiseError(PEAR_PACKAGEFILEMANAGER_NOLICENSE);
     }
     extract($this->_options);
     $date = date('Y-m-d');
     if (isset($package)) {
         $this->_packageXml['package'] = $package;
     }
     if (isset($summary)) {
         $this->_packageXml['summary'] = $summary;
     }
     if (isset($description)) {
         $this->_packageXml['description'] = $description;
     }
     $this->_packageXml['release_date'] = $date;
     $this->_packageXml['version'] = $version;
     $this->_packageXml['release_license'] = $license;
     $this->_packageXml['release_state'] = $state;
     $this->_packageXml['release_notes'] = $notes;
     $PEAR_Common = $this->_options['pearcommonclass'];
     $this->_pear = new $PEAR_Common();
     if (method_exists($this->_pear, 'setPackageFileManager')) {
         $this->_pear->setPackageFileManager($this);
     }
     $this->_packageXml['filelist'] = $this->_getFileList();
     $warnings = $this->getWarnings();
     if (count($warnings)) {
         $nl = isset($debuginterface) && $debuginterface ? '<br />' : "\n";
         foreach ($warnings as $errmsg) {
             echo 'WARNING: ' . $errmsg['message'] . $nl;
         }
     }
     if (PEAR::isError($this->_packageXml['filelist'])) {
         return $this->_packageXml['filelist'];
     }
     if (isset($this->_pear->pkginfo['provides'])) {
         $this->_packageXml['provides'] = $this->_pear->pkginfo['provides'];
     }
     if ($this->_options['simpleoutput']) {
         unset($this->_packageXml['provides']);
     }
     $this->_packageXml['release_deps'] = $this->_getDependencies();
     $this->_updateChangeLog();
     $common =& $this->_pear;
     $warnings = $errors = array();
     if (method_exists($common, 'setPackageFileManagerOptions')) {
         $common->setPackageFileManagerOptions($this->_options);
     }
     $packagexml = $common->xmlFromInfo($this->_packageXml);
     if (PEAR::isError($packagexml)) {
         $errs = $packagexml->getUserinfo();
         if (is_array($errs)) {
             foreach ($errs as $error) {
                 if ($error['level'] == 'error') {
                     $errors[] = $error['message'];
                 } else {
                     $warnings[] = $error['message'];
                 }
             }
         }
     } else {
         $common->validatePackageInfo($packagexml, $warnings, $errors, $this->_options['packagedirectory']);
     }
     if (count($errors)) {
         $ret = '';
         $nl = isset($debuginterface) && $debuginterface ? '<br />' : "\n";
         foreach ($errors as $errmsg) {
             $ret .= $errmsg . $nl;
         }
         return $this->raiseError(PEAR_PACKAGEFILEMANAGER_INVALID_PACKAGE, $nl, $ret);
     }
     if (count($warnings)) {
         $nl = isset($debuginterface) && $debuginterface ? '<br />' : "\n";
         foreach ($warnings as $errmsg) {
             echo $errmsg . $nl;
         }
     }
     if (!strpos($packagexml, '<!DOCTYPE')) {
         // hack to fix pear
         $packagexml = str_replace('<package version="1.0">', '<!DOCTYPE package SYSTEM "' . $this->_options['doctype'] . "\">\n<package version=\"1.0\">", $packagexml);
     }
     if (isset($debuginterface)) {
         if ($debuginterface) {
             echo '<pre>' . htmlentities($packagexml) . '</pre>';
         } else {
             echo $packagexml;
         }
         return true;
     }
     $outputdir = $this->_options['outputdirectory'] ? $this->_options['outputdirectory'] : $this->_options['packagedirectory'];
     if (file_exists($outputdir . $this->_options['packagefile']) && is_writable($outputdir . $this->_options['packagefile']) || @touch($outputdir . $this->_options['packagefile'])) {
         if ($fp = @fopen($outputdir . $this->_options['packagefile'] . '.tmp', "w")) {
             $written = @fwrite($fp, $packagexml);
             @fclose($fp);
             if ($written === false) {
                 return $this->raiseError(PEAR_PACKAGEFILEMANAGER_CANTWRITE_PKGFILE);
             }
             if (!@copy($outputdir . $this->_options['packagefile'] . '.tmp', $outputdir . $this->_options['packagefile'])) {
                 return $this->raiseError(PEAR_PACKAGEFILEMANAGER_CANTCOPY_PKGFILE);
             } else {
                 @unlink($outputdir . $this->_options['packagefile'] . '.tmp');
                 return true;
             }
         } else {
             return $this->raiseError(PEAR_PACKAGEFILEMANAGER_CANTOPEN_TMPPKGFILE, $outputdir . $this->_options['packagefile'] . '.tmp');
         }
     } else {
         return $this->raiseError(PEAR_PACKAGEFILEMANAGER_DEST_UNWRITABLE, $outputdir);
     }
 }
예제 #16
0
 function doDownload($command, $options, $params)
 {
     //$params[0] -> The package to download
     if (count($params) != 1) {
         return PEAR::raiseError("download expects one argument: the package to download");
     }
     $server = $this->config->get('master_server');
     if (!ereg('^http://', $params[0])) {
         $pkgfile = "http://{$server}/get/{$params['0']}";
     } else {
         $pkgfile = $params[0];
     }
     $this->bytes_downloaded = 0;
     $saved = PEAR_Common::downloadHttp($pkgfile, $this->ui, '.', array(&$this, 'downloadCallback'));
     if (PEAR::isError($saved)) {
         return $this->raiseError($saved);
     }
     $fname = basename($saved);
     $this->ui->outputData("File {$fname} downloaded ({$this->bytes_downloaded} bytes)", $command);
     return true;
 }
예제 #17
0
 function PEAR_Downloader(&$ui, $options, &$config)
 {
     $this->_options = $options;
     $this->_config =& $config;
     $this->_preferredState = $this->_config->get('preferred_state');
     $this->ui =& $ui;
     if (!$this->_preferredState) {
         // don't inadvertantly use a non-set preferred_state
         $this->_preferredState = null;
     }
     $php_dir = $this->_config->get('php_dir');
     if (isset($this->_options['installroot'])) {
         if (substr($this->_options['installroot'], -1) == DIRECTORY_SEPARATOR) {
             $this->_options['installroot'] = substr($this->_options['installroot'], 0, -1);
         }
         $php_dir = $this->_prependPath($php_dir, $this->_options['installroot']);
     }
     $this->_registry =& new PEAR_Registry($php_dir);
     $this->_remote =& new PEAR_Remote($config);
     if (isset($this->_options['alldeps']) || isset($this->_options['onlyreqdeps'])) {
         $this->_installed = $this->_registry->listPackages();
         array_walk($this->_installed, create_function('&$v,$k', '$v = strtolower($v);'));
         $this->_installed = array_flip($this->_installed);
     }
     parent::PEAR_Common();
 }
예제 #18
0
 function getReplacementTypes()
 {
     return PEAR_Common::getReplacementTypes();
 }
예제 #19
0
 /**
  * Validate XML package definition file.
  *
  * @param  string $info Filename of the package archive or of the
  *                package definition file
  * @param  array $errors Array that will contain the errors
  * @param  array $warnings Array that will contain the warnings
  * @param  string $dir_prefix (optional) directory where source files
  *                may be found, or empty if they are not available
  * @access public
  * @return boolean
  */
 function validatePackageInfo($info, &$errors, &$warnings, $dir_prefix = '')
 {
     if (PEAR::isError($info = $this->infoFromAny($info))) {
         return $this->raiseError($info);
     }
     if (!is_array($info)) {
         return false;
     }
     $errors = array();
     $warnings = array();
     if (!isset($info['package'])) {
         $errors[] = 'missing package name';
     } elseif (!$this->validPackageName($info['package'])) {
         $errors[] = 'invalid package name';
     }
     $this->_packageName = $pn = $info['package'];
     if (empty($info['summary'])) {
         $errors[] = 'missing summary';
     } elseif (strpos(trim($info['summary']), "\n") !== false) {
         $warnings[] = 'summary should be on a single line';
     }
     if (empty($info['description'])) {
         $errors[] = 'missing description';
     }
     if (empty($info['release_license'])) {
         $errors[] = 'missing license';
     }
     if (!isset($info['version'])) {
         $errors[] = 'missing version';
     } elseif (!$this->validPackageVersion($info['version'])) {
         $errors[] = 'invalid package version';
     }
     if (empty($info['release_state'])) {
         $errors[] = 'missing release state';
     } elseif (!in_array($info['release_state'], PEAR_Common::getReleaseStates())) {
         $errors[] = "invalid release state `{$info['release_state']}', should be one of: " . implode(' ', PEAR_Common::getReleaseStates());
     }
     if (empty($info['release_date'])) {
         $errors[] = 'missing release date';
     } elseif (!preg_match('/^\\d{4}-\\d\\d-\\d\\d$/', $info['release_date'])) {
         $errors[] = "invalid release date `{$info['release_date']}', format is YYYY-MM-DD";
     }
     if (empty($info['release_notes'])) {
         $errors[] = "missing release notes";
     }
     if (empty($info['maintainers'])) {
         $errors[] = 'no maintainer(s)';
     } else {
         $i = 1;
         foreach ($info['maintainers'] as $m) {
             if (empty($m['handle'])) {
                 $errors[] = "maintainer {$i}: missing handle";
             }
             if (empty($m['role'])) {
                 $errors[] = "maintainer {$i}: missing role";
             } elseif (!in_array($m['role'], PEAR_Common::getUserRoles())) {
                 $errors[] = "maintainer {$i}: invalid role `{$m['role']}', should be one of: " . implode(' ', PEAR_Common::getUserRoles());
             }
             if (empty($m['name'])) {
                 $errors[] = "maintainer {$i}: missing name";
             }
             if (empty($m['email'])) {
                 $errors[] = "maintainer {$i}: missing email";
             }
             $i++;
         }
     }
     if (!empty($info['deps'])) {
         $i = 1;
         foreach ($info['deps'] as $d) {
             if (empty($d['type'])) {
                 $errors[] = "dependency {$i}: missing type";
             } elseif (!in_array($d['type'], PEAR_Common::getDependencyTypes())) {
                 $errors[] = "dependency {$i}: invalid type, should be one of: " . implode(' ', PEAR_Common::getDependencyTypes());
             }
             if (empty($d['rel'])) {
                 $errors[] = "dependency {$i}: missing relation";
             } elseif (!in_array($d['rel'], PEAR_Common::getDependencyRelations())) {
                 $errors[] = "dependency {$i}: invalid relation, should be one of: " . implode(' ', PEAR_Common::getDependencyRelations());
             }
             if (!empty($d['optional'])) {
                 if (!in_array($d['optional'], array('yes', 'no'))) {
                     $errors[] = "dependency {$i}: invalid relation optional attribute, should be one of: yes no";
                 }
             }
             if ($d['rel'] != 'has' && empty($d['version'])) {
                 $warnings[] = "dependency {$i}: missing version";
             } elseif ($d['rel'] == 'has' && !empty($d['version'])) {
                 $warnings[] = "dependency {$i}: version ignored for `has' dependencies";
             }
             if ($d['type'] == 'php' && !empty($d['name'])) {
                 $warnings[] = "dependency {$i}: name ignored for php type dependencies";
             } elseif ($d['type'] != 'php' && empty($d['name'])) {
                 $errors[] = "dependency {$i}: missing name";
             }
             $i++;
         }
     }
     if (!empty($info['configure_options'])) {
         $i = 1;
         foreach ($info['configure_options'] as $c) {
             if (empty($c['name'])) {
                 $errors[] = "configure option {$i}: missing name";
             }
             if (empty($c['prompt'])) {
                 $errors[] = "configure option {$i}: missing prompt";
             }
             $i++;
         }
     }
     if (empty($info['filelist'])) {
         $errors[] = 'no files';
     } else {
         foreach ($info['filelist'] as $file => $fa) {
             if (empty($fa['role'])) {
                 $errors[] = "file {$file}: missing role";
                 continue;
             } elseif (!in_array($fa['role'], PEAR_Common::getFileRoles())) {
                 $errors[] = "file {$file}: invalid role, should be one of: " . implode(' ', PEAR_Common::getFileRoles());
             }
             if ($fa['role'] == 'php' && $dir_prefix) {
                 $this->log(1, "Analyzing {$file}");
                 $srcinfo = $this->analyzeSourceCode($dir_prefix . DIRECTORY_SEPARATOR . $file);
                 if ($srcinfo) {
                     $this->buildProvidesArray($srcinfo);
                 }
             }
             // (ssb) Any checks we can do for baseinstalldir?
             // (cox) Perhaps checks that either the target dir and
             //       baseInstall doesn't cointain "../../"
         }
     }
     $this->_packageName = $pn = $info['package'];
     $pnl = strlen($pn);
     foreach ((array) $this->pkginfo['provides'] as $key => $what) {
         if (isset($what['explicit'])) {
             // skip conformance checks if the provides entry is
             // specified in the package.xml file
             continue;
         }
         extract($what);
         if ($type == 'class') {
             if (!strncasecmp($name, $pn, $pnl)) {
                 continue;
             }
             $warnings[] = "in {$file}: class \"{$name}\" not prefixed with package name \"{$pn}\"";
         } elseif ($type == 'function') {
             if (strstr($name, '::') || !strncasecmp($name, $pn, $pnl)) {
                 continue;
             }
             $warnings[] = "in {$file}: function \"{$name}\" not prefixed with package name \"{$pn}\"";
         }
     }
     return true;
 }
예제 #20
0
파일: Builder.php 프로젝트: rjsmelo/tiki
 function log($level, $msg)
 {
     if ($this->current_callback) {
         if ($this->debug >= $level) {
             call_user_func($this->current_callback, 'output', $msg);
         }
         return;
     }
     return PEAR_Common::log($level, $msg);
 }
예제 #21
0
 function doSign($command, $options, $params)
 {
     // should move most of this code into PEAR_Packager
     // so it'll be easy to implement "pear package --sign"
     if (sizeof($params) != 1) {
         return $this->raiseError("bad parameter(s), try \"help {$command}\"");
     }
     if (!file_exists($params[0])) {
         return $this->raiseError("file does not exist: {$params['0']}");
     }
     $obj = new PEAR_Common();
     $info = $obj->infoFromTgzFile($params[0]);
     if (PEAR::isError($info)) {
         return $this->raiseError($info);
     }
     include_once "Archive/Tar.php";
     include_once "System.php";
     $tar = new Archive_Tar($params[0]);
     $tmpdir = System::mktemp('-d pearsign');
     if (!$tar->extractList('package.xml package.sig', $tmpdir)) {
         return $this->raiseError("failed to extract tar file");
     }
     if (file_exists("{$tmpdir}/package.sig")) {
         return $this->raiseError("package already signed");
     }
     @unlink("{$tmpdir}/package.sig");
     $input = $this->ui->userDialog($command, array('GnuPG Passphrase'), array('password'));
     $gpg = popen("gpg --batch --passphrase-fd 0 --armor --detach-sign --output {$tmpdir}/package.sig {$tmpdir}/package.xml 2>/dev/null", "w");
     if (!$gpg) {
         return $this->raiseError("gpg command failed");
     }
     fwrite($gpg, "{$input['0']}\r");
     if (pclose($gpg) || !file_exists("{$tmpdir}/package.sig")) {
         return $this->raiseError("gpg sign failed");
     }
     $tar->addModify("{$tmpdir}/package.sig", '', $tmpdir);
     return true;
 }
예제 #22
0
파일: v1.php 프로젝트: michabbb/pear-core
 /**
  * Validate XML package definition file.
  *
  * @access public
  * @return boolean
  */
 function validate($state = PEAR_VALIDATE_NORMAL, $nofilechecking = false)
 {
     if (($this->_isValid & $state) == $state) {
         return true;
     }
     $this->_isValid = true;
     $info = $this->_packageInfo;
     if (empty($info['package'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_NAME);
         $this->_packageName = $pn = 'unknown';
     } else {
         $this->_packageName = $pn = $info['package'];
     }
     if (empty($info['summary'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_SUMMARY);
     } elseif (strpos(trim($info['summary']), "\n") !== false) {
         $this->_validateWarning(PEAR_PACKAGEFILE_ERROR_MULTILINE_SUMMARY, array('summary' => $info['summary']));
     }
     if (empty($info['description'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DESCRIPTION);
     }
     if (empty($info['release_license'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_LICENSE);
     }
     if (empty($info['version'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_VERSION);
     }
     if (empty($info['release_state'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_STATE);
     }
     if (empty($info['release_date'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DATE);
     }
     if (empty($info['release_notes'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_NOTES);
     }
     if (empty($info['maintainers'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_MAINTAINERS);
     } else {
         $haslead = false;
         $i = 1;
         foreach ($info['maintainers'] as $m) {
             if (empty($m['handle'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_MAINTHANDLE, array('index' => $i));
             }
             if (empty($m['role'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_MAINTROLE, array('index' => $i, 'roles' => PEAR_Common::getUserRoles()));
             } elseif ($m['role'] == 'lead') {
                 $haslead = true;
             }
             if (empty($m['name'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_MAINTNAME, array('index' => $i));
             }
             if (empty($m['email'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_MAINTEMAIL, array('index' => $i));
             }
             $i++;
         }
         if (!$haslead) {
             $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_LEAD);
         }
     }
     if (!empty($info['release_deps'])) {
         $i = 1;
         foreach ($info['release_deps'] as $d) {
             if (!isset($d['type']) || empty($d['type'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPTYPE, array('index' => $i, 'types' => PEAR_Common::getDependencyTypes()));
                 continue;
             }
             if (!isset($d['rel']) || empty($d['rel'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPREL, array('index' => $i, 'rels' => PEAR_Common::getDependencyRelations()));
                 continue;
             }
             if (!empty($d['optional'])) {
                 if (!in_array($d['optional'], array('yes', 'no'))) {
                     $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_DEPOPTIONAL, array('index' => $i, 'opt' => $d['optional']));
                 }
             }
             if ($d['rel'] != 'has' && $d['rel'] != 'not' && empty($d['version'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPVERSION, array('index' => $i));
             } elseif (($d['rel'] == 'has' || $d['rel'] == 'not') && !empty($d['version'])) {
                 $this->_validateWarning(PEAR_PACKAGEFILE_ERROR_DEPVERSION_IGNORED, array('index' => $i, 'rel' => $d['rel']));
             }
             if ($d['type'] == 'php' && !empty($d['name'])) {
                 $this->_validateWarning(PEAR_PACKAGEFILE_ERROR_DEPNAME_IGNORED, array('index' => $i, 'name' => $d['name']));
             } elseif ($d['type'] != 'php' && empty($d['name'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPNAME, array('index' => $i));
             }
             if ($d['type'] == 'php' && empty($d['version'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPPHPVERSION, array('index' => $i));
             }
             if ($d['rel'] == 'not' && $d['type'] == 'php') {
                 $this->_validateError(PEAR_PACKAGEFILE_PHP_NO_NOT, array('index' => $i));
             }
             $i++;
         }
     }
     if (!empty($info['configure_options'])) {
         $i = 1;
         foreach ($info['configure_options'] as $c) {
             if (empty($c['name'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_CONFNAME, array('index' => $i));
             }
             if (empty($c['prompt'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_CONFPROMPT, array('index' => $i));
             }
             $i++;
         }
     }
     if (empty($info['filelist'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_FILES);
         $errors[] = 'no files';
     } else {
         foreach ($info['filelist'] as $file => $fa) {
             if (empty($fa['role'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_FILEROLE, array('file' => $file, 'roles' => PEAR_Common::getFileRoles()));
                 continue;
             } elseif (!in_array($fa['role'], PEAR_Common::getFileRoles())) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_FILEROLE, array('file' => $file, 'role' => $fa['role'], 'roles' => PEAR_Common::getFileRoles()));
             }
             if (preg_match('~/\\.\\.?(/|\\z)|^\\.\\.?/~', str_replace('\\', '/', $file))) {
                 // file contains .. parent directory or . cur directory references
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_FILENAME, array('file' => $file));
             }
             if (isset($fa['install-as']) && preg_match('~/\\.\\.?(/|\\z)|^\\.\\.?/~', str_replace('\\', '/', $fa['install-as']))) {
                 // install-as contains .. parent directory or . cur directory references
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_FILENAME, array('file' => $file . ' [installed as ' . $fa['install-as'] . ']'));
             }
             if (isset($fa['baseinstalldir']) && preg_match('~/\\.\\.?(/|\\z)|^\\.\\.?/~', str_replace('\\', '/', $fa['baseinstalldir']))) {
                 // install-as contains .. parent directory or . cur directory references
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_FILENAME, array('file' => $file . ' [baseinstalldir ' . $fa['baseinstalldir'] . ']'));
             }
         }
     }
     if (isset($this->_registry) && $this->_isValid) {
         $chan = $this->_registry->getChannel('pear.php.net');
         if (PEAR::isError($chan)) {
             $this->_validateError(PEAR_PACKAGEFILE_ERROR_CHANNELVAL, $chan->getMessage());
             return $this->_isValid = 0;
         }
         $validator = $chan->getValidationObject();
         $validator->setPackageFile($this);
         $validator->validate($state);
         $failures = $validator->getFailures();
         foreach ($failures['errors'] as $error) {
             $this->_validateError(PEAR_PACKAGEFILE_ERROR_CHANNELVAL, $error);
         }
         foreach ($failures['warnings'] as $warning) {
             $this->_validateWarning(PEAR_PACKAGEFILE_ERROR_CHANNELVAL, $warning);
         }
     }
     if ($this->_isValid && $state == PEAR_VALIDATE_PACKAGING && !$nofilechecking) {
         if ($this->_analyzePhpFiles()) {
             $this->_isValid = true;
         }
     }
     if ($this->_isValid) {
         return $this->_isValid = $state;
     }
     return $this->_isValid = 0;
 }
예제 #23
0
 /**
  * @param string url to the remote config file, like ftp://www.example.com/pear/config.ini
  * @return true|PEAR_Error
  */
 function readFTPConfigFile($path)
 {
     do {
         // poor man's try
         if (!class_exists('PEAR_FTP')) {
             if (!class_exists('PEAR_Common')) {
                 require_once 'PEAR/Common.php';
             }
             if (PEAR_Common::isIncludeable('PEAR/FTP.php')) {
                 require_once 'PEAR/FTP.php';
             }
         }
         if (!class_exists('PEAR_FTP')) {
             return PEAR::raiseError('PEAR_RemoteInstaller must be installed to use remote config');
         }
         $this->_ftp =& new PEAR_FTP();
         $this->_ftp->pushErrorHandling(PEAR_ERROR_RETURN);
         $e = $this->_ftp->init($path);
         if (PEAR::isError($e)) {
             $this->_ftp->popErrorHandling();
             return $e;
         }
         $tmp = System::mktemp('-d');
         PEAR_Common::addTempFile($tmp);
         $e = $this->_ftp->get(basename($path), $tmp . DIRECTORY_SEPARATOR . 'pear.ini', false, FTP_BINARY);
         if (PEAR::isError($e)) {
             $this->_ftp->popErrorHandling();
             return $e;
         }
         PEAR_Common::addTempFile($tmp . DIRECTORY_SEPARATOR . 'pear.ini');
         $this->_ftp->disconnect();
         $this->_ftp->popErrorHandling();
         $this->files['ftp'] = $tmp . DIRECTORY_SEPARATOR . 'pear.ini';
         $e = $this->readConfigFile(null, 'ftp');
         if (PEAR::isError($e)) {
             return $e;
         }
         $fail = array();
         foreach ($this->configuration_info as $key => $val) {
             if (in_array($this->getGroup($key), array('File Locations', 'File Locations (Advanced)')) && $this->getType($key) == 'directory') {
                 // any directory configs must be set for this to work
                 if (!isset($this->configuration['ftp'][$key])) {
                     $fail[] = $key;
                 }
             }
         }
         if (!count($fail)) {
             return true;
         }
         $fail = '"' . implode('", "', $fail) . '"';
         unset($this->files['ftp']);
         unset($this->configuration['ftp']);
         return PEAR::raiseError('ERROR: Ftp configuration file must set all ' . 'directory configuration variables.  These variables were not set: ' . $fail);
     } while (false);
     // poor man's catch
     unset($this->files['ftp']);
     return PEAR::raiseError('no remote host specified');
 }
예제 #24
0
 function doListUpgrades($command, $options, $params)
 {
     require_once 'PEAR/Common.php';
     if (isset($params[0]) && !is_array(PEAR_Common::betterStates($params[0]))) {
         return $this->raiseError($params[0] . ' is not a valid state (stable/beta/alpha/devel/etc.) try "pear help list-upgrades"');
     }
     $savechannel = $channel = $this->config->get('default_channel');
     $reg =& $this->config->getRegistry();
     foreach ($reg->listChannels() as $channel) {
         $inst = array_flip($reg->listPackages($channel));
         if (!count($inst)) {
             continue;
         }
         if ($channel == '__uri') {
             continue;
         }
         $this->config->set('default_channel', $channel);
         if (empty($params[0])) {
             $state = $this->config->get('preferred_state');
         } else {
             $state = $params[0];
         }
         $caption = $channel . ' Available Upgrades';
         $chan = $reg->getChannel($channel);
         if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) {
             return $e;
         }
         if ($chan->supportsREST($this->config->get('preferred_mirror')) && ($base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror')))) {
             $rest =& $this->config->getREST('1.0', array());
             if (empty($state) || $state == 'any') {
                 $state = false;
             } else {
                 $caption .= ' (' . implode(', ', PEAR_Common::betterStates($state, true)) . ')';
             }
             PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
             $latest = $rest->listLatestUpgrades($base, $state, $inst, $channel, $reg);
             PEAR::staticPopErrorHandling();
         } else {
             $remote =& $this->config->getRemote();
             $remote->pushErrorHandling(PEAR_ERROR_RETURN);
             if (empty($state) || $state == 'any') {
                 $latest = $remote->call("package.listLatestReleases");
             } else {
                 $latest = $remote->call("package.listLatestReleases", $state);
                 $caption .= ' (' . implode(', ', PEAR_Common::betterStates($state, true)) . ')';
             }
             $remote->popErrorHandling();
         }
         if (PEAR::isError($latest)) {
             $this->ui->outputData($latest->getMessage());
             continue;
         }
         $caption .= ':';
         if (PEAR::isError($latest)) {
             $this->config->set('default_channel', $savechannel);
             return $latest;
         }
         $data = array('caption' => $caption, 'border' => 1, 'headline' => array('Channel', 'Package', 'Local', 'Remote', 'Size'), 'channel' => $channel);
         foreach ((array) $latest as $pkg => $info) {
             $package = strtolower($pkg);
             if (!isset($inst[$package])) {
                 // skip packages we don't have installed
                 continue;
             }
             extract($info);
             $inst_version = $reg->packageInfo($package, 'version', $channel);
             $inst_state = $reg->packageInfo($package, 'release_state', $channel);
             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($channel, $pkg, "{$inst_version} ({$inst_state})", "{$version} ({$state})", $fs);
         }
         if (isset($options['channelinfo'])) {
             if (empty($data['data'])) {
                 unset($data['headline']);
                 if (count($inst) == 0) {
                     $data['data'] = '(no packages installed)';
                 } else {
                     $data['data'] = '(no upgrades available)';
                 }
             }
             $this->ui->outputData($data, $command);
         } else {
             if (empty($data['data'])) {
                 $this->ui->outputData('Channel ' . $channel . ': No upgrades available');
             } else {
                 $this->ui->outputData($data, $command);
             }
         }
     }
     $this->config->set('default_channel', $savechannel);
     return true;
 }
예제 #25
0
 function log($level, $msg, $append_crlf = true)
 {
     if ($this->current_callback) {
         if ($this->debug >= $level) {
             call_user_func($this->current_callback, 'output', $msg);
         }
         return;
     }
     return parent::log($level, $msg, $append_crlf);
 }