summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Dickmann <dickmann@php.net>2002-06-01 18:39:36 +0000
committerChristian Dickmann <dickmann@php.net>2002-06-01 18:39:36 +0000
commit446f137bf411e6891b8b21e25b30ab91a53a803e (patch)
tree85f1d3044f053eb4f078ffb95e7cbd1ecf235b52
parent4c2fd27ecd21c2484518ec7ececb4a658649c87e (diff)
downloadphp-git-446f137bf411e6891b8b21e25b30ab91a53a803e.tar.gz
add 'pear search'. introduce type 'mask' to config.
-rw-r--r--pear/PEAR/Command/Config.php10
-rw-r--r--pear/PEAR/Command/Remote.php76
-rw-r--r--pear/PEAR/Config.php13
-rw-r--r--pear/PEAR/Frontend/CLI.php3
-rw-r--r--pear/PEAR/Installer.php4
5 files changed, 94 insertions, 12 deletions
diff --git a/pear/PEAR/Command/Config.php b/pear/PEAR/Command/Config.php
index 5b7675faf5..b64f0a2523 100644
--- a/pear/PEAR/Command/Config.php
+++ b/pear/PEAR/Command/Config.php
@@ -94,12 +94,8 @@ in. The default layer is "user".
$value = $this->config->get($key, @$params[0]);
if ($type == 'password' && $value) {
$value = '********';
- } elseif ($key == 'umask') {
- $value = sprintf("%03o", $value);
}
- if ($value === null || $value === '') {
- $value = '<not set>';
- } elseif ($value === false) {
+ if ($value === false) {
$value = 'false';
} elseif ($value === true) {
$value = 'true';
@@ -137,11 +133,11 @@ in. The default layer is "user".
$failmsg = '';
if (sizeof($params) < 2 || sizeof($params) > 3) {
$failmsg .= "config-set expects 2 or 3 parameters";
- break;
+ return PEAR::raiseError($failmsg);
}
if ($error = $this->_checkLayer(@$params[2])) {
$failmsg .= $error;
- break;
+ return PEAR::raiseError($failmsg);
}
if (!call_user_func_array(array(&$this->config, 'set'), $params))
{
diff --git a/pear/PEAR/Command/Remote.php b/pear/PEAR/Command/Remote.php
index f6b14881da..2550236be5 100644
--- a/pear/PEAR/Command/Remote.php
+++ b/pear/PEAR/Command/Remote.php
@@ -55,6 +55,15 @@ a newer version is available with the same release state (stable etc.).'
Lists the packages available on the configured server along with the
latest stable release of each package.',
),
+ 'search' => array(
+ 'summary' => 'Search Packagesdatabase',
+ 'function' => 'doSearch',
+ 'shortcut' => 'sp',
+ 'options' => array(),
+ 'doc' => '
+Lists all packages which match the search paramteres (first param
+is package name, second package info)',
+ ),
'list-all' => array(
'summary' => 'List All Packages',
'function' => 'doListAll',
@@ -100,7 +109,9 @@ version of DB is 1.2, the downloaded file will be DB-1.2.tgz.',
function doRemoteInfo($command, $options, $params)
{
+/*
return false; // coming soon
+
var_dump($params[0]);
$r = new PEAR_Remote($this->config);
$info = $r->call('package.info', $params[0]);
@@ -109,6 +120,20 @@ version of DB is 1.2, the downloaded file will be DB-1.2.tgz.',
}
var_dump($info);
+*/
+ $r = new PEAR_Remote($this->config);
+ $available = $r->call('package.listAll', true);
+ if (PEAR::isError($available)) {
+ return $this->raiseError($available);
+ }
+ $info = $available[$params[0]];
+ $info["name"] = $params[0];
+
+ $reg = new PEAR_Registry($this->config->get('php_dir'));
+ $installed = $reg->packageInfo($info['name']);
+ $info['installed'] = $installed['version'];
+
+ $this->ui->outputData($info, $command);
return false; // coming soon
}
@@ -174,6 +199,57 @@ version of DB is 1.2, the downloaded file will be DB-1.2.tgz.',
}
// }}}
+ // {{{ search
+
+ function doSearch($command, $options, $params)
+ {
+ if ((!isset($params[0]) || empty($params[0]))
+ && (!isset($params[1]) || empty($params[1])))
+ {
+ return $this->raiseError('no valid search string suppliedy<');
+ };
+
+ $r = new PEAR_Remote($this->config);
+ $reg = new PEAR_Registry($this->config->get('php_dir'));
+ $available = $r->call('package.listAll', true);
+ if (PEAR::isError($available)) {
+ return $this->raiseError($available);
+ }
+ $data = array(
+ 'caption' => 'Matched packages:',
+ 'border' => true,
+ 'headline' => array('Package', 'Latest', 'Local'),
+ );
+
+ foreach ($available as $name => $info) {
+ $found = (!empty($params[0]) && stristr($name, $params[0]) !== false);
+ if (!$found && !(isset($params[1]) && !empty($params[1])
+ && (stristr($info['summary'], $params[1]) !== false
+ || stristr($info['description'], $params[1]) !== false)))
+ {
+ continue;
+ };
+
+ $installed = $reg->packageInfo($name);
+ $desc = $info['summary'];
+ if (isset($params[$name]))
+ $desc .= "\n\n".$info['description'];
+
+ $data['data'][$info['category']][] = array(
+ $name,
+ $info['stable'],
+ $installed['version'],
+ $desc,
+ );
+ }
+ if (!isset($data['data'])) {
+ return $this->raiseError('no packages found');
+ };
+ $this->ui->outputData($data, $command);
+ return true;
+ }
+
+ // }}}
// {{{ download
function doDownload($command, $options, $params)
diff --git a/pear/PEAR/Config.php b/pear/PEAR/Config.php
index ec1cd8faac..e4549be3d6 100644
--- a/pear/PEAR/Config.php
+++ b/pear/PEAR/Config.php
@@ -188,7 +188,7 @@ class PEAR_Config extends PEAR
'group' => 'Advanced',
),
'umask' => array(
- 'type' => 'int',
+ 'type' => 'mask',
'default' => PEAR_DEFAULT_UMASK,
'doc' => 'umask used when creating files (Unix-like systems only)',
'prompt' => 'Unix file mask',
@@ -485,6 +485,10 @@ class PEAR_Config extends PEAR
$data[$key] = base64_encode($data[$key]);
break;
}
+ case 'mask': {
+ $data[$key] = octdec($data[$key]);
+ break;
+ }
}
}
return true;
@@ -519,6 +523,10 @@ class PEAR_Config extends PEAR
$data[$key] = base64_decode($data[$key]);
break;
}
+ case 'mask': {
+ $data[$key] = decoct($data[$key]);
+ break;
+ }
}
}
return true;
@@ -577,10 +585,9 @@ class PEAR_Config extends PEAR
}
extract($this->configuration_info[$key]);
switch ($type) {
- case 'integer': {
+ case 'integer':
$value = (int)$value;
break;
- }
case 'set': {
// If a valid_set is specified, require the value to
// be in the set. If there is no valid_set, accept
diff --git a/pear/PEAR/Frontend/CLI.php b/pear/PEAR/Frontend/CLI.php
index 4fdb1a79c8..3fe5e3336e 100644
--- a/pear/PEAR/Frontend/CLI.php
+++ b/pear/PEAR/Frontend/CLI.php
@@ -385,6 +385,9 @@ class PEAR_Frontend_CLI extends PEAR
foreach($data['data'] as $group) {
foreach($group as $value) {
+ if ($value === null || $value === '') {
+ $value = "<not set>";
+ };
$this->_tableRow($value, null, array(1 => array('wrap' => 55)));
}
};
diff --git a/pear/PEAR/Installer.php b/pear/PEAR/Installer.php
index db9ae28a1f..127658b2a3 100644
--- a/pear/PEAR/Installer.php
+++ b/pear/PEAR/Installer.php
@@ -243,10 +243,10 @@ class PEAR_Installer extends PEAR_Common
}
if (!OS_WINDOWS) {
if ($atts['role'] == 'script') {
- $mode = 0777 & ~$this->config->get('umask');
+ $mode = 0777 & ~(int)octdec($this->config->get('umask'));
$this->log(3, "+ chmod +x $dest_file");
} else {
- $mode = 0666 & ~$this->config->get('umask');
+ $mode = 0666 & ~(int)octdec($this->config->get('umask'));
}
if (!@chmod($dest_file, $mode)) {
$this->log(0, "failed to change mode of $dest_file");