cvs: php4 /pear/PEAR Packager.php /pear/PEAR/Command Package.php /pear/PEAR/Frontend CLI.php

From: Date: Sun, 07 Apr 2002 19:42:05 +0000
Subject: cvs: php4 /pear/PEAR Packager.php /pear/PEAR/Command Package.php /pear/PEAR/Frontend CLI.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-3114@lists.php.net to get a copy of this message
ssb Sun Apr 7 15:42:05 2002 EDT Modified files: /php4/pear/PEAR Packager.php /php4/pear/PEAR/Command Package.php /php4/pear/PEAR/Frontend CLI.php Log: * added "cvstag" command

Index: php4/pear/PEAR/Packager.php diff -u php4/pear/PEAR/Packager.php:1.34 php4/pear/PEAR/Packager.php:1.35 --- php4/pear/PEAR/Packager.php:1.34 Sun Apr 7 13:07:49 2002 +++ php4/pear/PEAR/Packager.php Sun Apr 7 15:42:05 2002 @@ -17,7 +17,7 @@ // | Tomas V.V.Cox <cox@idecnet.com> | // +----------------------------------------------------------------------+ // -// $Id: Packager.php,v 1.34 2002/04/07 17:07:49 ssb Exp $ +// $Id: Packager.php,v 1.35 2002/04/07 19:42:05 ssb Exp $ require_once 'PEAR/Common.php'; @@ -137,7 +137,8 @@ $this->log(1, "Package $dest_package done"); $cvsversion = preg_replace('/[^a-z0-9]/i', '_', $pkgversion); $cvstag = "RELEASE_$cvsversion"; - $this->log(0, "Tag the released code with: cvs tag $cvstag"); + $this->log(0, "Tag the released code with `pear cvstag'"); + $this->log(0, "(or set the CVS tag $cvstag by hand)"); return $dest_package; } Index: php4/pear/PEAR/Command/Package.php diff -u php4/pear/PEAR/Command/Package.php:1.15 php4/pear/PEAR/Command/Package.php:1.16 --- php4/pear/PEAR/Command/Package.php:1.15 Sun Apr 7 09:22:21 2002 +++ php4/pear/PEAR/Command/Package.php Sun Apr 7 15:42:05 2002 @@ -16,7 +16,7 @@ // | Author: Stig Bakken <ssb@fast.no> | // +----------------------------------------------------------------------+ // -// $Id: Package.php,v 1.15 2002/04/07 13:22:21 ssb Exp $ +// $Id: Package.php,v 1.16 2002/04/07 19:42:05 ssb Exp $ require_once 'PEAR/Command/Common.php'; require_once 'PEAR/Packager.php'; @@ -38,6 +38,26 @@ // }}} + // {{{ _displayValidationResults() + + function _displayValidationResults($err, $warn, $strict = false) + { + foreach ($err as $e) { + $this->ui->displayLine("Error: $e"); + } + foreach ($warn as $w) { + $this->ui->displayLine("Warning: $w"); + } + $this->ui->displayLine(sprintf('Validation: %d error(s), %d warning(s)', + sizeof($err), sizeof($warn))); + if ($strict && sizeof($err) > 0) { + $this->ui->displayLine("Fix these errors and try again."); + return false; + } + return true; + } + + // }}} // {{{ getCommands() /** @@ -50,11 +70,19 @@ return array('package', 'package-info', 'package-list', - 'package-validate'); + 'package-validate', + 'cvstag'); } // }}} + // {{{ getOptions() + function getOptions() + { + return array('Z', 'n' /*, 'f', 'd', 'q', 'Q'*/); + } + + // }}} // {{{ getHelp() function getHelp($command) @@ -73,11 +101,13 @@ case 'package-validate': return array('<package.(tgz|tar|xml)>', 'Verifies a package or description file'); + case 'cvstag': + return array('<package.xml>', + 'Runs "cvs tag" on files contained in a release'); } } // }}} - // {{{ run() /** @@ -109,19 +139,11 @@ $packager->debug = $this->config->get('verbose'); $err = $warn = array(); $packager->validatePackageInfo($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."); + if (!$this->_displayValidationResults($err, $warn, true)) { break; } - $result = $packager->Package($pkginfofile); + $compress = empty($options['Z']) ? true : false; + $result = $packager->Package($pkginfofile, $compress); $output = ob_get_contents(); ob_end_clean(); $lines = explode("\n", $output); @@ -129,9 +151,7 @@ $this->ui->displayLine($line); } if (PEAR::isError($result)) { - $this->ui->displayLine("Package failed!"); - } else { - $this->ui->displayLine("Package ok."); + $this->ui->displayLine("Package failed: ".$result->getMessage()); } break; } @@ -271,7 +291,6 @@ } $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); @@ -286,14 +305,63 @@ if (PEAR::isError($info)) { return $this->raiseError($info); } - foreach ($err as $e) { - $this->ui->displayLine("Error: $e"); + $obj->validatePackageInfo($info, $err, $warn); + $this->_displayValidationResults($err, $warn); + break; + } + + // }}} + // {{{ cvstag + + case 'cvstag': { + if (sizeof($params) < 1) { + $help = $this->getHelp($command); + return $this->raiseError("$command: missing parameter: $help[0]"); } - foreach ($warn as $w) { - $this->ui->displayLine("Warning: $w"); + $obj = new PEAR_Common; + $info = $obj->infoFromDescriptionFile($params[0]); + if (PEAR::isError($info)) { + return $this->raiseError($info); + } + $err = $warn = array(); + $obj->validatePackageInfo($info, $err, $warn); + if (!$this->_displayValidationResults($err, $warn, true)) { + break; + } + $version = $info['version']; + $cvsversion = preg_replace('/[^a-z0-9]/i', '_', $version); + $cvstag = "RELEASE_$cvsversion"; + $files = array_keys($info['filelist']); + $command = "cvs"; + /* until the getopt bug is fixed, these won't work: + if (isset($options['q'])) { + $command .= ' -q'; + } + if (isset($options['Q'])) { + $command .= ' -Q'; + } + */ + $command .= ' tag'; + if (isset($options['f'])) { + $command .= ' -f'; + } + /* neither will this one: + if (isset($options['d'])) { + $command .= ' -d'; + } + */ + $command .= ' ' . $cvstag . ' ' . escapeshellarg($params[0]); + foreach ($files as $file) { + $command .= ' ' . escapeshellarg($file); + } + $this->ui->displayLine("+ $command"); + if (empty($options['n'])) { + $fp = popen($command, "r"); + while ($line = fgets($fp, 1024)) { + $this->ui->displayLine(rtrim($line)); + } + pclose($fp); } - $this->ui->displayLine(sprintf('%d error(s), %d warning(s)', - sizeof($err), sizeof($warn))); break; } Index: php4/pear/PEAR/Frontend/CLI.php diff -u php4/pear/PEAR/Frontend/CLI.php:1.9 php4/pear/PEAR/Frontend/CLI.php:1.10 --- php4/pear/PEAR/Frontend/CLI.php:1.9 Sun Apr 7 12:47:36 2002 +++ php4/pear/PEAR/Frontend/CLI.php Sun Apr 7 15:42:05 2002 @@ -16,7 +16,7 @@ | Author: Stig Sæther Bakken <ssb@fast.no> | +----------------------------------------------------------------------+ - $Id: CLI.php,v 1.9 2002/04/07 16:47:36 ssb Exp $ + $Id: CLI.php,v 1.10 2002/04/07 19:42:05 ssb Exp $ */ require_once "PEAR.php"; @@ -31,6 +31,7 @@ * @access public */ var $type = 'CLI'; + var $lp = ''; // line prefix var $omode = 'plain'; var $params = array(); @@ -63,16 +64,11 @@ // }}} - // For now, all the display functions print a "| " at the - // beginning of the line. This is just a temporary thing, it - // is for discovering commands that use print instead of - // the UI layer. - // {{{ displayLine(text) function displayLine($text) { - print "| $text\n"; + print "$this->lp$text\n"; } // }}} @@ -97,8 +93,8 @@ function displayHeading($title) { - print "| ".$this->bold($title)."\n"; - print "| ".str_repeat("=", strlen($title))."\n"; + print $this->lp.$this->bold($title)."\n"; + print $this->lp.str_repeat("=", strlen($title))."\n"; } // }}} @@ -109,7 +105,7 @@ if ($type == 'password') { system('stty -echo'); } - print "| $prompt "; + print "$this->lp$prompt "; if ($default) { print "[$default] "; } @@ -134,7 +130,7 @@ { static $positives = array('y', 'yes', 'on', '1'); static $negatives = array('n', 'no', 'off', '0'); - print "| $prompt [$default] : "; + print "$this->lp$prompt [$default] : "; $fp = fopen("php://stdin", "r"); $line = fgets($fp, 2048); fclose($fp);
« previous php.pear.cvs (#3114) next »