summaryrefslogtreecommitdiff
path: root/pear/PEAR/Command/Package.php
diff options
context:
space:
mode:
authorStig Bakken <ssb@php.net>2002-04-07 10:38:04 +0000
committerStig Bakken <ssb@php.net>2002-04-07 10:38:04 +0000
commitdc974a0299621cab657756b4048b781716da0490 (patch)
tree4554ccdb13eead5ce9a19664b0a88218f717bf8a /pear/PEAR/Command/Package.php
parentefbb9949a5a4835161f54feef45c38a6fe3b9c76 (diff)
downloadphp-git-dc974a0299621cab657756b4048b781716da0490.tar.gz
* support for .tar files in PEAR_Installer
* new command: package-verify * "package" command now sanity-checks the package information before making the tarball * -Z option to the install/update commands for downloading non-compressed packages
Diffstat (limited to 'pear/PEAR/Command/Package.php')
-rw-r--r--pear/PEAR/Command/Package.php61
1 files changed, 59 insertions, 2 deletions
diff --git a/pear/PEAR/Command/Package.php b/pear/PEAR/Command/Package.php
index 84be4056c4..54a144698c 100644
--- a/pear/PEAR/Command/Package.php
+++ b/pear/PEAR/Command/Package.php
@@ -48,12 +48,15 @@ class PEAR_Command_Package extends PEAR_Command_Common
function getCommands()
{
return array('package',
+ 'package-info',
'package-list',
- 'package-info');
+ 'package-verify');
}
// }}}
+ // {{{ getHelp()
+
function getHelp($command)
{
switch ($command) {
@@ -67,9 +70,13 @@ class PEAR_Command_Package extends PEAR_Command_Common
case 'packge-info':
return array('<pear package>',
'Shows information about a PEAR package');
+ case 'package-verify':
+ return array('<package.(tgz|tar|xml)>',
+ 'Verifies a package or description file');
}
}
+ // }}}
// {{{ run()
@@ -94,12 +101,26 @@ class PEAR_Command_Package extends PEAR_Command_Common
// {{{ package
case 'package': {
- $pkginfofile = isset($params[0]) ? $params[0] : null;
+ $pkginfofile = isset($params[0]) ? $params[0] : 'package.xml';
ob_start();
$packager =& new PEAR_Packager($this->config->get('php_dir'),
$this->config->get('ext_dir'),
$this->config->get('doc_dir'));
$packager->debug = $this->config->get('verbose');
+ $err = $warn = array();
+ $packager->validateInfo($pkginfofile, $err, $warn);
+ foreach ($err as $e) {
+ $this->ui->displayLine("Error: $e");
+ }
+ foreach ($warn as $w) {
+ $this->ui->displayLine("Warning: $w");
+ }
+ $this->ui->displayLine(sprintf('%d error(s), %d warning(s)',
+ sizeof($err), sizeof($warn)));
+ if (sizeof($err) > 0) {
+ $this->ui->displayLine("Fix these errors and try again.");
+ break;
+ }
$result = $packager->Package($pkginfofile);
$output = ob_get_contents();
ob_end_clean();
@@ -241,6 +262,42 @@ class PEAR_Command_Package extends PEAR_Command_Common
}
// }}}
+ // {{{ package-verify
+
+ case 'package-verify': {
+ if (sizeof($params) < 1) {
+ $help = $this->getHelp($command);
+ return $this->raiseError("$command: missing parameter: $help[0]");
+ }
+ $obj = new PEAR_Common;
+ $info = null;
+ $validate_result = $obj->validatePackageInfo($info, $err, $warn);
+ if (file_exists($params[0])) {
+ $fp = fopen($params[0], "r");
+ $test = fread($fp, 5);
+ fclose($fp);
+ if ($test == "<?xml") {
+ $info = $obj->infoFromDescriptionFile($params[0]);
+ }
+ }
+ if (empty($info)) {
+ $info = $obj->infoFromTgzFile($params[0]);
+ }
+ if (PEAR::isError($info)) {
+ return $this->raiseError($info);
+ }
+ foreach ($err as $e) {
+ $this->ui->displayLine("Error: $e");
+ }
+ foreach ($warn as $w) {
+ $this->ui->displayLine("Warning: $w");
+ }
+ $this->ui->displayLine(sprintf('%d error(s), %d warning(s)',
+ sizeof($err), sizeof($warn)));
+ break;
+ }
+
+ // }}}
default: {
return false;
}