cvs: pear-core /PEAR/Command Package.php

From: Date: Mon, 20 Feb 2006 15:21:38 +0000
Subject: cvs: pear-core /PEAR/Command Package.php
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-cvs+get-38400@lists.php.net to get a copy of this message
timj Mon Feb 20 15:21:38 2006 UTC Modified files: /pear-core/PEAR/Command Package.php Log: Add transparent passthru from 'makerpm' command to PEAR_Command_Packaging 'make-rpm-spec' command, if PEAR_Command_Packaging is installed; else fallback to old code http://cvs.php.net/viewcvs.cgi/pear-core/PEAR/Command/Package.php?r1=1.116&r2=1.117&diff_format=u Index: pear-core/PEAR/Command/Package.php diff -u pear-core/PEAR/Command/Package.php:1.116 pear-core/PEAR/Command/Package.php:1.117 --- pear-core/PEAR/Command/Package.php:1.116 Mon Feb 20 10:50:46 2006 +++ pear-core/PEAR/Command/Package.php Mon Feb 20 15:21:38 2006 @@ -18,7 +18,7 @@ * @author Greg Beaver <cellog@php.net> * @copyright 1997-2006 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Package.php,v 1.116 2006/02/20 10:50:46 timj Exp $ + * @version CVS: $Id: Package.php,v 1.117 2006/02/20 15:21:38 timj Exp $ * @link http://pear.php.net/package/PEAR * @since File available since Release 0.1 */ @@ -730,6 +730,23 @@ $a = &new PEAR_Installer($ui); return $a; } + + /** + * For unit testing purposes + */ + function &getCommandPackaging(&$ui, &$config) + { + if (!class_exists('PEAR_Command_Packaging')) { + @include_once 'PEAR/Command/Packaging.php'; + } + + if (class_exists('PEAR_Command_Packaging')) { + $a = &new PEAR_Command_Packaging($ui, $config); + } else { + $a = null; + } + return $a; + } // {{{ doMakeRPM() @@ -737,6 +754,22 @@ { require_once 'System.php'; require_once 'Archive/Tar.php'; + + // Check to see if PEAR_Command_Packaging is installed, and + // transparently switch to use the "make-rpm-spec" command from it + // instead, if it does. Otherwise, continue to use the old version + // of "makerpm" supplied with this package (PEAR). + $packaging_cmd = $this->getCommandPackaging($this->ui, $this->config); + if ($packaging_cmd !== null) { + $this->ui->outputData('PEAR_Command_Packaging is installed; using '. + 'newer "make-rpm-spec" command instead'); + return $packaging_cmd->run('make-rpm-spec', $options, $params); + } else { + $this->ui->outputData('WARNING: "pear makerpm" is now deprecated; an '. + 'improved version is available via "pear make-rpm-spec", which '. + 'is part of PEAR_Command_Packaging'); + } + if (sizeof($params) != 1) { return $this->raiseError("bad parameter(s), try \"help $command\""); }

« previous php.pear.cvs (#38400) next »