'installroot' => array(
'shortopt' => 'R',
'arg' => 'DIR',
- 'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT)',
+ 'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT), use packagingroot for RPM',
+ ),
+ 'packagingroot' => array(
+ 'shortopt' => 'P',
+ 'arg' => 'DIR',
+ 'doc' => 'root directory used when packaging files, like RPM packaging',
),
'ignore-errors' => array(
'doc' => 'force install even if there were errors',
'installroot' => array(
'shortopt' => 'R',
'arg' => 'DIR',
- 'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT)',
+ 'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT), use packagingroot for RPM',
+ ),
+ 'packagingroot' => array(
+ 'shortopt' => 'P',
+ 'arg' => 'DIR',
+ 'doc' => 'root directory used when packaging files, like RPM packaging',
),
'ignore-errors' => array(
'doc' => 'force install even if there were errors',
'installroot' => array(
'shortopt' => 'R',
'arg' => 'DIR',
- 'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT)',
+ 'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT), use packagingroot for RPM',
+ ),
+ 'packagingroot' => array(
+ 'shortopt' => 'P',
+ 'arg' => 'DIR',
+ 'doc' => 'root directory used when packaging files, like RPM packaging',
),
'ignore-errors' => array(
'doc' => 'force install even if there were errors',
if ($command == 'upgrade') {
$options['upgrade'] = true;
}
+ if (isset($options['installroot']) && isset($options['packagingroot'])) {
+ return $this->raiseError('ERROR: cannot use both --installroot and --packagingroot');
+ }
+ if (isset($options['packagingroot']) && $this->config->get('verbose') > 2) {
+ $this->ui->outputData('using package root: ' . $options['packagingroot']);
+ }
$reg = &$this->config->getRegistry();
if ($command == 'upgrade-all') {
$options['upgrade'] = true;
$state = PEAR_VALIDATE_INSTALLING)
{
$this->_config = &$config;
- $this->_registry = &$config->getRegistry();
if (!class_exists('PEAR_DependencyDB')) {
require_once 'PEAR/DependencyDB.php';
}
+ if (isset($installoptions['packagingroot'])) {
+ // make sure depdb is in the right location
+ $config->setInstallRoot($installoptions['packagingroot']);
+ }
+ $this->_registry = &$config->getRegistry();
$this->_dependencydb = &PEAR_DependencyDB::singleton($config);
+ if (isset($installoptions['packagingroot'])) {
+ $config->setInstallRoot(false);
+ }
$this->_options = $installoptions;
$this->_state = $state;
if (!class_exists('OS_Guess')) {
* @var PEAR_Registry
*/
var $_registry;
+ /**
+ * Used to implement packagingroot properly
+ * @var PEAR_Registry
+ */
+ var $_installRegistry;
/**
* @var PEAR_PackageFile_v1|PEAR_PackageFile|v2
*/
var $_validated = false;
/**
- * @param PEAR_Config
+ * @param PEAR_Downloader
*/
function PEAR_Downloader_Package(&$downloader)
{
$this->_downloader = &$downloader;
$this->_config = &$this->_downloader->config;
$this->_registry = &$this->_config->getRegistry();
+ $options = $downloader->getOptions();
+ if (isset($options['packagingroot'])) {
+ $this->_config->setInstallRoot($options['packagingroot']);
+ $this->_installRegistry = &$this->_config->getRegistry();
+ $this->_config->setInstallRoot(false);
+ } else {
+ $this->_installRegistry = &$this->_registry;
+ }
$this->_valid = $this->_analyzed = false;
}
foreach ($params as $i => $param) {
// remove self if already installed with this version
// this does not need any pecl magic - we only remove exact matches
- if ($param->_registry->packageExists($param->getPackage(), $param->getChannel())) {
- if (version_compare($param->_registry->packageInfo($param->getPackage(), 'version',
+ if ($param->_installRegistry->packageExists($param->getPackage(), $param->getChannel())) {
+ if (version_compare($param->_installRegistry->packageInfo($param->getPackage(), 'version',
$param->getChannel()), $param->getVersion(), '==')) {
if (!isset($options['force'])) {
$info = $param->getParsedPackage();
$param->_downloader->log(1, 'Skipping package "' .
$param->getShortName() .
'", already installed as version ' .
- $param->_registry->packageInfo($param->getPackage(),
+ $param->_installRegistry->packageInfo($param->getPackage(),
'version', $param->getChannel()));
}
$params[$i] = false;
$param->_downloader->log(1, 'Skipping package "' .
$param->getShortName() .
'", already installed as version ' .
- $param->_registry->packageInfo($param->getPackage(), 'version',
+ $param->_installRegistry->packageInfo($param->getPackage(), 'version',
$param->getChannel()));
$params[$i] = false;
}
// we can't determine whether upgrade is necessary until we know what
// version would be downloaded
if (!isset($options['force']) && $this->isInstalled($ret, $oper)) {
- $version = $this->_registry->packageInfo($dep['name'], 'version',
+ $version = $this->_installRegistry->packageInfo($dep['name'], 'version',
$dep['channel']);
$dep['package'] = $dep['name'];
if (!isset($options['soft'])) {
$chan = 'pecl.php.net';
$url =
$this->_downloader->_getDepPackageDownloadUrl($newdep, $pname);
- $obj = &$this->_registry->getPackage($dep['name']);
+ $obj = &$this->_installRegistry->getPackage($dep['name']);
if (PEAR::isError($url)) {
PEAR::popErrorHandling();
if ($obj !== null && $this->isInstalled($obj, $dep['rel'])) {
'optional';
$dep['package'] = $dep['name'];
if (isset($newdep)) {
- $version = $this->_registry->packageInfo($newdep['name'], 'version',
+ $version = $this->_installRegistry->packageInfo($newdep['name'], 'version',
$newdep['channel']);
} else {
- $version = $this->_registry->packageInfo($dep['name'], 'version');
+ $version = $this->_installRegistry->packageInfo($dep['name'], 'version');
}
$dep['version'] = $url['version'];
if (!isset($options['soft'])) {
}
}
$options = $this->_downloader->getOptions();
- $test = $this->_registry->packageExists($package, $channel);
+ $test = $this->_installRegistry->packageExists($package, $channel);
if (!$test && $channel == 'pecl.php.net') {
// do magic to allow upgrading from old pecl packages to new ones
- $test = $this->_registry->packageExists($package, 'pear.php.net');
+ $test = $this->_installRegistry->packageExists($package, 'pear.php.net');
$channel = 'pear.php.net';
}
if ($test) {
if (isset($dep['uri'])) {
- if ($this->_registry->packageInfo($package, 'uri', '__uri') == $dep['uri']) {
+ if ($this->_installRegistry->packageInfo($package, 'uri', '__uri') == $dep['uri']) {
return true;
}
}
if (isset($options['upgrade'])) {
if ($oper == 'has') {
- if (version_compare($this->_registry->packageInfo(
+ if (version_compare($this->_installRegistry->packageInfo(
$package, 'version', $channel),
$dep['version'], '>=')) {
return true;
return false;
}
} else {
- if (version_compare($this->_registry->packageInfo(
+ if (version_compare($this->_installRegistry->packageInfo(
$package, 'version', $channel),
$dep['version'], '>=')) {
return true;
DIRECTORY_SEPARATOR),
array($dest_file, $orig_file));
$final_dest_file = $installed_as = $dest_file;
+ if (isset($this->_options['packagingroot'])) {
+ $installedas_dest_dir = dirname($final_dest_file);
+ $installedas_dest_file = $dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file);
+ $final_dest_file = $this->_prependPath($final_dest_file,
+ $this->_options['packagingroot']);
+ } else {
+ $installedas_dest_dir = dirname($final_dest_file);
+ $installedas_dest_file = $installedas_dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file);
+ }
$dest_dir = dirname($final_dest_file);
$dest_file = $dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file);
// }}}
$atts['role'] == 'ext'));
// Store the full path where the file was installed for easy unistall
$this->addFileOperation("installed_as", array($file, $installed_as,
- $save_destdir, dirname(substr($dest_file, strlen($save_destdir)))));
+ $save_destdir, dirname(substr($installedas_dest_file, strlen($save_destdir)))));
//$this->log(2, "installed: $dest_file");
return PEAR_INSTALLER_OK;
list($save_destdir, $dest_dir, $dest_file, $orig_file) = $info;
}
$final_dest_file = $installed_as = $dest_file;
+ if (isset($this->_options['packagingroot'])) {
+ $final_dest_file = $this->_prependPath($final_dest_file,
+ $this->_options['packagingroot']);
+ }
$dest_dir = dirname($final_dest_file);
$dest_file = $dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file);
// }}}
$pkgname = $pkg->getName();
$channel = $pkg->getChannel();
+ if (isset($this->_options['packagingroot'])) {
+ $packrootphp_dir = $this->_prependPath(
+ $this->config->get('php_dir', null, 'pear.php.net'),
+ $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
} else {
$this->config->setInstallRoot(false);
$this->_registry = &$this->config->getRegistry();
+ if (isset($this->_options['packagingroot'])) {
+ $installregistry = &new PEAR_Registry($packrootphp_dir);
+ $php_dir = $packrootphp_dir;
+ } else {
+ $installregistry = &$this->_registry;
+ $php_dir = $this->config->get('php_dir', null, $channel);
+ }
$this->installroot = '';
}
- $php_dir = $this->config->get('php_dir', null, $channel);
// {{{ checks to do when not in "force" mode
if (empty($options['force']) && @is_dir($this->config->get('php_dir'))) {
$testp = $channel == 'pear.php.net' ? $pkgname : array($channel, $pkgname);
- $test = $this->_registry->checkFileMap($pkg->getInstallationFileList(true), $testp, '1.1');
+ $instfilelist = $pkg->getInstallationFileList(true);
+ if (PEAR::isError($instfilelist)) {
+ return $instfilelist;
+ }
+ $test = $installregistry->checkFileMap($instfilelist, $testp, '1.1');
if (PEAR::isError($test)) {
return $test;
}
}
if ($found) {
// subpackages can conflict with earlier versions of parent packages
- $parentreg = $this->_registry->packageInfo($param->getPackage(), null, $param->getChannel());
+ $parentreg = $installregistry->packageInfo($param->getPackage(), null, $param->getChannel());
$tmp = $test;
foreach ($tmp as $file => $info) {
if (is_array($info)) {
}
$pfk = &new PEAR_PackageFile($this->config);
$parentpkg = &$pfk->fromArray($parentreg);
- $this->_registry->updatePackage2($parentpkg);
+ $installregistry->updatePackage2($parentpkg);
}
if ($param->getChannel() == 'pecl.php.net' && isset($options['upgrade'])) {
$tmp = $test;
if (empty($options['upgrade']) && empty($options['soft'])) {
// checks to do only when installing new packages
if ($channel == 'pecl.php.net') {
- $test = $this->_registry->packageExists($pkgname, $channel);
+ $test = $installregistry->packageExists($pkgname, $channel);
if (!$test) {
- $test = $this->_registry->packageExists($pkgname, 'pear.php.net');
+ $test = $installregistry->packageExists($pkgname, 'pear.php.net');
}
} else {
- $test = $this->_registry->packageExists($pkgname, $channel);
+ $test = $installregistry->packageExists($pkgname, $channel);
}
if (empty($options['force']) && $test) {
return $this->raiseError("$channel/$pkgname is already installed");
} else {
$usechannel = $channel;
if ($channel == 'pecl.php.net') {
- $test = $this->_registry->packageExists($pkgname, $channel);
+ $test = $installregistry->packageExists($pkgname, $channel);
if (!$test) {
- $test = $this->_registry->packageExists($pkgname, 'pear.php.net');
+ $test = $installregistry->packageExists($pkgname, 'pear.php.net');
$usechannel = 'pear.php.net';
}
} else {
- $test = $this->_registry->packageExists($pkgname, $channel);
+ $test = $installregistry->packageExists($pkgname, $channel);
}
if ($test) {
- $v1 = $this->_registry->packageInfo($pkgname, 'version', $usechannel);
+ $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 $filelist;
}
$pkg->resetFilelist();
- $pkg->setLastInstalledVersion($this->_registry->packageInfo($pkg->getPackage(),
+ $pkg->setLastInstalledVersion($installregistry->packageInfo($pkg->getPackage(),
'version', $pkg->getChannel()));
foreach ($filelist as $file => $atts) {
if ($pkg->getPackagexmlVersion() == '1.0') {
// if 'force' is used, replace the info in registry
$usechannel = $channel;
if ($channel == 'pecl.php.net') {
- $test = $this->_registry->packageExists($pkgname, $channel);
+ $test = $installregistry->packageExists($pkgname, $channel);
if (!$test) {
- $test = $this->_registry->packageExists($pkgname, 'pear.php.net');
+ $test = $installregistry->packageExists($pkgname, 'pear.php.net');
$usechannel = 'pear.php.net';
}
} else {
- $test = $this->_registry->packageExists($pkgname, $channel);
+ $test = $installregistry->packageExists($pkgname, $channel);
}
if (!empty($options['force']) && $test) {
- $oldversion = $this->_registry->packageInfo($pkgname, 'version', $usechannel);
- $this->_registry->deletePackage($pkgname, $usechannel);
+ $oldversion = $installregistry->packageInfo($pkgname, 'version', $usechannel);
+ $installregistry->deletePackage($pkgname, $usechannel);
}
- $ret = $this->_registry->addPackage2($pkg);
+ $ret = $installregistry->addPackage2($pkg);
} else {
$usechannel = $channel;
if ($channel == 'pecl.php.net') {
- $test = $this->_registry->packageExists($pkgname, $channel);
+ $test = $installregistry->packageExists($pkgname, $channel);
if (!$test) {
- $test = $this->_registry->packageExists($pkgname, 'pear.php.net');
+ $test = $installregistry->packageExists($pkgname, 'pear.php.net');
$usechannel = 'pear.php.net';
}
} else {
- $test = $this->_registry->packageExists($pkgname, $channel);
+ $test = $installregistry->packageExists($pkgname, $channel);
}
// new: upgrade installs a package if it isn't installed
if (!$test) {
- $ret = $this->_registry->addPackage2($pkg);
+ $ret = $installregistry->addPackage2($pkg);
} else {
if ($usechannel != $channel) {
- $this->_registry->deletePackage($pkgname, $usechannel);
- $ret = $this->_registry->addPackage2($pkg);
+ $installregistry->deletePackage($pkgname, $usechannel);
+ $ret = $installregistry->addPackage2($pkg);
} else {
- $ret = $this->_registry->updatePackage2($pkg);
+ $ret = $installregistry->updatePackage2($pkg);
}
$installphase = 'upgrade';
}
{
$fp = @fopen($this->filemap, 'r');
if (!$fp) {
- return $this->raiseError('PEAR_Registry: could not open filemap', PEAR_REGISTRY_ERROR_FILE, null, null, $php_errormsg);
+ return $this->raiseError('PEAR_Registry: could not open filemap "' . $this->filemap . '"', PEAR_REGISTRY_ERROR_FILE, null, null, $php_errormsg);
}
clearstatcache();
$rt = get_magic_quotes_runtime();
} elseif ($arg == '-b') {
$bin_dir = $argv[$i+1];
$i++;
+ } elseif ($arg == '-p') {
+ $php_bin = $argv[$i+1];
+ $i++;
} elseif ($arg == '--debug') {
$debug = 1;
} elseif ($arg == '--extremedebug') {
$config->set('cache_dir', $cdir);
}
}
+if (!empty($php_bin)) {
+ $config->set('php_bin', $php_bin);
+}
/* Print PEAR Conf (useful for debuging do NOT REMOVE) */
if ($debug) {
sort($keys);
$options['upgrade'] = true;
$install_root = getenv('INSTALL_ROOT');
if (!empty($install_root)) {
- $options['installroot'] = $install_root;
- $config->setInstallRoot($install_root);
+ $options['packagingroot'] = $install_root;
+ $reg = &new PEAR_Registry($options['packagingroot']);
+} else {
+ $reg = $config->getRegistry('default');
}
-$reg = $config->getRegistry('default');
$ui = &PEAR_Frontend::singleton('PEAR_Frontend_CLI');
$installer = &new PEAR_Installer($ui);
$pkg = &new PEAR_PackageFile($config, $debug);