// $Id$
require_once 'PEAR/Common.php';
+require_once 'PEAR/Registry.php';
/**
* Administration class used to install PEAR packages and maintain the
{
// XXX FIXME Add here code to manage packages database
//$this->loadPackageList("$this->statedir/packages.lst");
+ $registry = new PEAR_Registry;
$oldcwd = getcwd();
$need_download = false;
if (preg_match('#^(http|ftp)://#', $pkgfile)) {
// Assume the decompressed dir name
if (($pos = strrpos($file, '.')) === false) {
chdir($oldcwd);
- return $this->raiseError('package doesn\'t follow the package name convention');
+ return $this->raiseError("package doesn't follow the package name convention");
}
$pkgdir = substr($file, 0, $pos);
$descfile = $tmpdir . DIRECTORY_SEPARATOR . $pkgdir . DIRECTORY_SEPARATOR . 'package.xml';
return $pkginfo;
}
+ if ($registry->packageExists($pkginfo['package'])) {
+ return $this->raiseError("package already installed");
+ }
+
// Copy files to dest dir ---------------------------------------
if (!is_dir($this->phpdir)) {
chdir($oldcwd);
$fname = $tmp_path . DIRECTORY_SEPARATOR . $fname;
$this->_installFile($fname, $dest_dir, $atts);
}
+ $registry->addPackage($pkginfo['package'], $pkginfo);
chdir($oldcwd);
return true;
}
#!@prefix@/bin/php -Cq
-<?php // -*- C++ -*-
+<?php // -*- PHP -*-
//
// +----------------------------------------------------------------------+
// | PHP version 4.0 |
// +----------------------------------------------------------------------+
//
require_once 'PEAR.php';
+require_once 'PEAR/Common.php';
require_once 'PEAR/Config.php';
require_once 'PEAR/Remote.php';
require_once 'PEAR/Registry.php';
// {{{ config file and option parsing
-$options = Console_Getopt::getopt($argv, "c:C:d:D:h?sSqv");
+$options = Console_Getopt::getopt($argv, "c:C:d:D:h?sSqu:v");
if (PEAR::isError($options)) {
usage($options);
}
case 'S':
$store_default_config = true;
break;
+ case 'u':
+ $config->toDefault($param);
+ break;
case 'v':
$verbose++;
break;
}
$fallback_config = array(
- 'php_dir' => PEAR_INSTALL_DIR,
- 'ext_dir' => PEAR_EXTENSION_DIR,
- 'doc_dir' => '',
- 'verbose' => true,
+ 'master_server' => 'pear.php.net',
+ 'php_dir' => PEAR_INSTALL_DIR,
+ 'ext_dir' => PEAR_EXTENSION_DIR,
+ 'doc_dir' => '',
+ 'verbose' => true,
);
+$fallback_done = array();
foreach ($fallback_config as $key => $value) {
if (!$config->isDefined($key)) {
$config->set($key, $value);
+ $fallback_done[$key] = true;
}
}
include_once 'PEAR/Packager.php';
$pkginfofile = $options[1][2];
$packager =& new PEAR_Packager($script_dir, $ext_dir, $doc_dir);
+ $packager->setErrorHandling(PEAR_ERROR_DIE, "pear page: %s\n");
$packager->debug = $verbose;
if (PEAR::isError($packager->Package($pkginfofile))) {
print "\npackage failed\n";
break;
}
+ // }}}
+ // {{{ info
+
+ case 'info': {
+ $parser = new PEAR_Common;
+ $parser->setErrorHandling(PEAR_ERROR_DIE, "pear info: %s\n");
+ $info = $parser->infoFromTgzFile($options[1][2]);
+ unset($info['filelist']);
+ present_array($info);
+ break;
+ }
+
// }}}
// {{{ list
break;
}
+ // }}}
+ // {{{ show-config
+
+ case 'show-config': {
+ $keys = $config->getKeys();
+ foreach ($keys as $key) {
+ $value = $config->get($key);
+ $xi = "";
+ if ($config->isDefaulted($key)) {
+ $xi .= " (default)";
+ }
+ if ($fallback_done[$key]) {
+ $xi .= " (fallback)";
+ }
+ printf("%s = %s%s\n", $key, $value, $xi);
+ }
+ break;
+ }
+
// }}}
default: {
if (!$store_default_config && !$store_user_config) {
" -D foo=bar set system config variable `foo' to `bar'\n".
" -s store user configuration\n".
" -s store system configuration\n".
+ " -u foo unset `foo' in the user configuration\n".
" -h, -? display help/usage (this message)\n".
"Commands:\n".
" install <package file>\n".
" package [package info file]\n".
" list\n".
" list-remote\n".
+ " show-config\n".
"\n");
fclose($stderr);
exit;
// }}}
+function present_array(&$arr, $keys = null)
+{
+ if ($keys === null) {
+ $keys = array_keys($arr);
+ }
+ $longest_key = max(array_map("strlen", array_keys($arr)));
+ $format_string = "%{$longest_key}s : %s\n";
+ foreach ($keys as $k) {
+ if (is_array($arr[$k])) {
+ $v = implode(", ", $arr[$k]);
+ } else {
+ $v = $arr[$k];
+ }
+ printf($format_string, $k, $v);
+ }
+}
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
?>