cvs: pear-core /PEAR/Command Mirror.php Registry.php Remote.php
| From: | Greg Beaver | Date: | Mon, 15 Nov 2004 22:11:57 +0000 |
| Subject: | cvs: pear-core /PEAR/Command Mirror.php Registry.php Remote.php | ||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-cvs+get-25994@lists.php.net to get a copy of this message | ||
cellog Mon Nov 15 17:11:57 2004 EDT
Modified files:
/pear-core/PEAR/Command Mirror.php Registry.php Remote.php
Log:
update all commands that use channels
refine both download (allow multiple arguments)
and download-all
http://cvs.php.net/diff.php/pear-core/PEAR/Command/Mirror.php?r1=1.6&r2=1.7&ty=u
Index: pear-core/PEAR/Command/Mirror.php
diff -u pear-core/PEAR/Command/Mirror.php:1.6 pear-core/PEAR/Command/Mirror.php:1.7
--- pear-core/PEAR/Command/Mirror.php:1.6 Sun Jul 4 00:25:08 2004
+++ pear-core/PEAR/Command/Mirror.php Mon Nov 15 17:11:56 2004
@@ -17,7 +17,7 @@
// | |
// +----------------------------------------------------------------------+
//
-// $Id: Mirror.php,v 1.6 2004/07/04 04:25:08 cellog Exp $
+// $Id: Mirror.php,v 1.7 2004/11/15 22:11:56 cellog Exp $
require_once "PEAR/Command/Common.php";
require_once "PEAR/Command.php";
@@ -37,7 +37,14 @@
'summary' => 'Downloads each available package from
master_server',
'function' => 'doDownloadAll',
'shortcut' => 'da',
- 'options' => array(),
+ 'options' => array(
+ 'channel' =>
+ array(
+ 'shortopt' => 'c',
+ 'doc' => 'specify a channel other than the default
channel',
+ 'arg' => 'CHAN',
+ )
+ ),
'doc' => '
Requests a list of available packages from the package server
(master_server) and downloads them to current working directory'
@@ -76,7 +83,15 @@
*/
function doDownloadAll($command, $options, $params)
{
- $this->config->set("php_dir", ".");
+ $savechannel = $this->config->get('default_channel');
+ $reg = &$this->config->getRegistry();
+ $channel = isset($options['channel']) ? $options['channel'] :
+ $this->config->get('default_channel');
+ if (!$reg->channelExists($channel)) {
+ $this->config->set('default_channel', $savechannel);
+ return $this->raiseError('Channel "' . $channel . '" does
not exist');
+ }
+ $this->config->set('default_channel', $channel);
$this->ui->outputData('Using Channel ' .
$this->config->get('default_channel'));
$remote = &new PEAR_Remote($this->config);
$remoteInfo = $remote->call("package.listAll");
@@ -87,14 +102,17 @@
if (PEAR::isError($cmd)) {
return $cmd;
}
- foreach ($remoteInfo as $pkgn => $pkg) {
- /**
- * Error handling not neccesary, because already done by
- * the download command
- */
- $cmd->run("download", array(), array($pkgn));
+ /**
+ * Error handling not necessary, because already done by
+ * the download command
+ */
+ PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
+ $err = $cmd->run('download', array(), array_keys($remoteInfo));
+ PEAR::staticPopErrorHandling();
+ $this->config->set('default_channel', $savechannel);
+ if (PEAR::isError($err)) {
+ $this->ui->outputData($err->getMessage());
}
-
return true;
}
http://cvs.php.net/diff.php/pear-core/PEAR/Command/Registry.php?r1=1.47&r2=1.48&ty=u
Index: pear-core/PEAR/Command/Registry.php
diff -u pear-core/PEAR/Command/Registry.php:1.47 pear-core/PEAR/Command/Registry.php:1.48
--- pear-core/PEAR/Command/Registry.php:1.47 Thu Nov 4 14:10:32 2004
+++ pear-core/PEAR/Command/Registry.php Mon Nov 15 17:11:56 2004
@@ -17,7 +17,7 @@
// | |
// +----------------------------------------------------------------------+
//
-// $Id: Registry.php,v 1.47 2004/11/04 19:10:32 cellog Exp $
+// $Id: Registry.php,v 1.48 2004/11/15 22:11:56 cellog Exp $
require_once 'PEAR/Command/Common.php';
require_once 'PEAR/Registry.php';
@@ -36,6 +36,7 @@
'channel' => array(
'shortopt' => 'c',
'doc' => 'list installed packages from this channel',
+ 'arg' => 'CHAN',
),
),
'doc' => '<package>
@@ -57,12 +58,7 @@
'summary' => 'List Files In Installed Package',
'function' => 'doFileList',
'shortcut' => 'fl',
- 'options' => array(
- 'channel' => array(
- 'shortopt' => 'c',
- 'doc' => 'package is in this channel',
- ),
- ),
+ 'options' => array(),
'doc' => '<package>
List the files in an installed package.
'
http://cvs.php.net/diff.php/pear-core/PEAR/Command/Remote.php?r1=1.46&r2=1.47&ty=u
Index: pear-core/PEAR/Command/Remote.php
diff -u pear-core/PEAR/Command/Remote.php:1.46 pear-core/PEAR/Command/Remote.php:1.47
--- pear-core/PEAR/Command/Remote.php:1.46 Mon Nov 15 16:48:03 2004
+++ pear-core/PEAR/Command/Remote.php Mon Nov 15 17:11:56 2004
@@ -17,7 +17,7 @@
// | |
// +----------------------------------------------------------------------+
//
-// $Id: Remote.php,v 1.46 2004/11/15 21:48:03 cellog Exp $
+// $Id: Remote.php,v 1.47 2004/11/15 22:11:56 cellog Exp $
require_once 'PEAR/Command/Common.php';
require_once 'PEAR/Common.php';
@@ -114,10 +114,10 @@
'doc' => 'download an uncompressed (.tar) file',
),
),
- 'doc' => '[channel/]{package|package-version}
-Download a package tarball. The file will be named as suggested by the
+ 'doc' => '<package>...
+Download package tarballs. The files will be named as suggested by the
server, for example if you download the DB package and the latest stable
-version of DB is 1.2, the downloaded file will be DB-1.2.tgz.',
+version of DB is 1.6.5, the downloaded file will be DB-1.6.5.tgz.',
),
'clear-cache' => array(
'summary' => 'Clear XML-RPC Cache',
@@ -386,21 +386,12 @@
function doDownload($command, $options, $params)
{
- if (count($params) != 1) {
- return PEAR::raiseError("download expects one argument: the package to
download");
- }
- //$params[0] -> The package to download
include_once 'PEAR/Downloader.php';
- $downloader = &new PEAR_Downloader($this->ui, array('force' => 1),
$this->config);
+ $options['force'] = 1;
+ $downloader = &new PEAR_Downloader($this->ui, $options, $this->config);
+ $downloader->setDownloadDir(getcwd());
$errors = array();
$downloaded = array();
- if (isset($options['nocompress'])) {
- foreach ($params as $i => $param) {
- if (!strpos($param, '.tar')) {
- $params[$i] .= '.tar';
- }
- }
- }
$downloader->download($params);
$errors = $downloader->getErrorMsgs();
if (count($errors)) {
@@ -411,8 +402,7 @@
}
$downloaded = $downloader->getDownloadedPackages();
foreach ($downloaded as $pkg) {
- @copy($pkg['file'], $fname = getcwd() . basename($pkg['file']));
- $this->ui->outputData("File $fname downloaded", $command);
+ $this->ui->outputData("File $pkg[file] downloaded", $command);
}
return true;
}