4,18 → 4,11 |
* |
* PHP versions 4 and 5 |
* |
* LICENSE: This source file is subject to version 3.0 of the PHP license |
* that is available through the world-wide-web at the following URI: |
* http://www.php.net/license/3_0.txt. If you did not receive a copy of |
* the PHP License and are unable to obtain it through the web, please |
* send a note to license@php.net so we can mail you a copy immediately. |
* |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 2005-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version CVS: $Id: Pickle.php,v 1.6 2006/05/12 02:38:58 cellog Exp $ |
* @copyright 2005-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 1.4.1 |
*/ |
31,9 → 24,9 |
* @category pear |
* @package PEAR |
* @author Greg Beaver <cellog@php.net> |
* @copyright 2005-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.5.1 |
* @copyright 2005-2009 The Authors |
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
* @version Release: 1.10.1 |
* @link http://pear.php.net/package/PEAR |
* @since Class available since Release 1.4.1 |
*/ |
82,12 → 75,11 |
* |
* @access public |
*/ |
function PEAR_Command_Pickle(&$ui, &$config) |
function __construct(&$ui, &$config) |
{ |
parent::PEAR_Command_Common($ui, $config); |
parent::__construct($ui, $config); |
} |
|
|
/** |
* For unit-testing ease |
* |
98,7 → 90,8 |
if (!class_exists('PEAR_Packager')) { |
require_once 'PEAR/Packager.php'; |
} |
$a = &new PEAR_Packager; |
|
$a = new PEAR_Packager; |
return $a; |
} |
|
110,15 → 103,17 |
* @param string|null $tmpdir |
* @return PEAR_PackageFile |
*/ |
function &getPackageFile($config, $debug = false, $tmpdir = null) |
function &getPackageFile($config, $debug = false) |
{ |
if (!class_exists('PEAR_Common')) { |
require_once 'PEAR/Common.php'; |
} |
if (!class_exists('PEAR/PackageFile.php')) { |
|
if (!class_exists('PEAR_PackageFile')) { |
require_once 'PEAR/PackageFile.php'; |
} |
$a = &new PEAR_PackageFile($config, $debug, $tmpdir); |
|
$a = new PEAR_PackageFile($config, $debug); |
$common = new PEAR_Common; |
$common->ui = $this->ui; |
$a->setLogger($common); |
133,15 → 128,18 |
if (PEAR::isError($err = $this->_convertPackage($pkginfofile))) { |
return $err; |
} |
|
$compress = empty($options['nocompress']) ? true : false; |
$result = $packager->package($pkginfofile, $compress, 'package.xml'); |
if (PEAR::isError($result)) { |
return $this->raiseError($result); |
} |
|
// Don't want output, only the package file name just created |
if (isset($options['showname'])) { |
$this->ui->outputData($result, $command); |
} |
|
return true; |
} |
|
153,6 → 151,7 |
return $this->raiseError('Cannot process "' . |
$packagexml . '", is not a package.xml 2.0'); |
} |
|
require_once 'PEAR/PackageFile/v1.php'; |
$pf = new PEAR_PackageFile_v1; |
$pf->setConfig($this->config); |
161,16 → 160,19 |
'", is not an extension source package. Using a PEAR_PackageFileManager-based ' . |
'script is an option'); |
} |
|
if (is_array($pf2->getUsesRole())) { |
return $this->raiseError('Cannot safely convert "' . $packagexml . |
'", contains custom roles. Using a PEAR_PackageFileManager-based script or ' . |
'the convert command is an option'); |
} |
|
if (is_array($pf2->getUsesTask())) { |
return $this->raiseError('Cannot safely convert "' . $packagexml . |
'", contains custom tasks. Using a PEAR_PackageFileManager-based script or ' . |
'the convert command is an option'); |
} |
|
$deps = $pf2->getDependencies(); |
if (isset($deps['group'])) { |
return $this->raiseError('Cannot safely convert "' . $packagexml . |
177,6 → 179,7 |
'", contains dependency groups. Using a PEAR_PackageFileManager-based script ' . |
'or the convert command is an option'); |
} |
|
if (isset($deps['required']['subpackage']) || |
isset($deps['optional']['subpackage'])) { |
return $this->raiseError('Cannot safely convert "' . $packagexml . |
183,16 → 186,19 |
'", contains subpackage dependencies. Using a PEAR_PackageFileManager-based '. |
'script is an option'); |
} |
|
if (isset($deps['required']['os'])) { |
return $this->raiseError('Cannot safely convert "' . $packagexml . |
'", contains os dependencies. Using a PEAR_PackageFileManager-based '. |
'script is an option'); |
} |
|
if (isset($deps['required']['arch'])) { |
return $this->raiseError('Cannot safely convert "' . $packagexml . |
'", contains arch dependencies. Using a PEAR_PackageFileManager-based '. |
'script is an option'); |
} |
|
$pf->setPackage($pf2->getPackage()); |
$pf->setSummary($pf2->getSummary()); |
$pf->setDescription($pf2->getDescription()); |
200,6 → 206,7 |
$pf->addMaintainer($maintainer['role'], $maintainer['handle'], |
$maintainer['name'], $maintainer['email']); |
} |
|
$pf->setVersion($pf2->getVersion()); |
$pf->setDate($pf2->getDate()); |
$pf->setLicense($pf2->getLicense()); |
209,10 → 216,12 |
if (isset($deps['required']['php']['max'])) { |
$pf->addPhpDep($deps['required']['php']['max'], 'le'); |
} |
|
if (isset($deps['required']['package'])) { |
if (!isset($deps['required']['package'][0])) { |
$deps['required']['package'] = array($deps['required']['package']); |
} |
|
foreach ($deps['required']['package'] as $dep) { |
if (!isset($dep['channel'])) { |
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . |
219,31 → 228,40 |
' contains uri-based dependency on a package. Using a ' . |
'PEAR_PackageFileManager-based script is an option'); |
} |
if ($dep['channel'] != 'pear.php.net' && $dep['channel'] != 'pecl.php.net') { |
|
if ($dep['channel'] != 'pear.php.net' |
&& $dep['channel'] != 'pecl.php.net' |
&& $dep['channel'] != 'doc.php.net') { |
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . |
' contains dependency on a non-standard channel package. Using a ' . |
'PEAR_PackageFileManager-based script is an option'); |
} |
|
if (isset($dep['conflicts'])) { |
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . |
' contains conflicts dependency. Using a ' . |
'PEAR_PackageFileManager-based script is an option'); |
} |
|
if (isset($dep['exclude'])) { |
$this->ui->outputData('WARNING: exclude tags are ignored in conversion'); |
} |
|
if (isset($dep['min'])) { |
$pf->addPackageDep($dep['name'], $dep['min'], 'ge'); |
} |
|
if (isset($dep['max'])) { |
$pf->addPackageDep($dep['name'], $dep['max'], 'le'); |
} |
} |
} |
|
if (isset($deps['required']['extension'])) { |
if (!isset($deps['required']['extension'][0])) { |
$deps['required']['extension'] = array($deps['required']['extension']); |
} |
|
foreach ($deps['required']['extension'] as $dep) { |
if (isset($dep['conflicts'])) { |
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . |
250,21 → 268,26 |
' contains conflicts dependency. Using a ' . |
'PEAR_PackageFileManager-based script is an option'); |
} |
|
if (isset($dep['exclude'])) { |
$this->ui->outputData('WARNING: exclude tags are ignored in conversion'); |
} |
|
if (isset($dep['min'])) { |
$pf->addExtensionDep($dep['name'], $dep['min'], 'ge'); |
} |
|
if (isset($dep['max'])) { |
$pf->addExtensionDep($dep['name'], $dep['max'], 'le'); |
} |
} |
} |
|
if (isset($deps['optional']['package'])) { |
if (!isset($deps['optional']['package'][0])) { |
$deps['optional']['package'] = array($deps['optional']['package']); |
} |
|
foreach ($deps['optional']['package'] as $dep) { |
if (!isset($dep['channel'])) { |
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . |
271,72 → 294,90 |
' contains uri-based dependency on a package. Using a ' . |
'PEAR_PackageFileManager-based script is an option'); |
} |
if ($dep['channel'] != 'pear.php.net' && $dep['channel'] != 'pecl.php.net') { |
|
if ($dep['channel'] != 'pear.php.net' |
&& $dep['channel'] != 'pecl.php.net' |
&& $dep['channel'] != 'doc.php.net') { |
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . |
' contains dependency on a non-standard channel package. Using a ' . |
'PEAR_PackageFileManager-based script is an option'); |
} |
|
if (isset($dep['exclude'])) { |
$this->ui->outputData('WARNING: exclude tags are ignored in conversion'); |
} |
|
if (isset($dep['min'])) { |
$pf->addPackageDep($dep['name'], $dep['min'], 'ge', 'yes'); |
} |
|
if (isset($dep['max'])) { |
$pf->addPackageDep($dep['name'], $dep['max'], 'le', 'yes'); |
} |
} |
} |
|
if (isset($deps['optional']['extension'])) { |
if (!isset($deps['optional']['extension'][0])) { |
$deps['optional']['extension'] = array($deps['optional']['extension']); |
} |
|
foreach ($deps['optional']['extension'] as $dep) { |
if (isset($dep['exclude'])) { |
$this->ui->outputData('WARNING: exclude tags are ignored in conversion'); |
} |
|
if (isset($dep['min'])) { |
$pf->addExtensionDep($dep['name'], $dep['min'], 'ge', 'yes'); |
} |
|
if (isset($dep['max'])) { |
$pf->addExtensionDep($dep['name'], $dep['max'], 'le', 'yes'); |
} |
} |
} |
|
$contents = $pf2->getContents(); |
$release = $pf2->getReleases(); |
$release = $pf2->getReleases(); |
if (isset($releases[0])) { |
return $this->raiseError('Cannot safely process "' . $packagexml . '" contains ' |
return $this->raiseError('Cannot safely process "' . $packagexml . '" contains ' |
. 'multiple extsrcrelease/zendextsrcrelease tags. Using a PEAR_PackageFileManager-based script ' . |
'or the convert command is an option'); |
} |
|
if ($configoptions = $pf2->getConfigureOptions()) { |
foreach ($configoptions as $option) { |
$pf->addConfigureOption($option['name'], $option['prompt'], |
isset($option['default']) ? $option['default'] : false); |
$default = isset($option['default']) ? $option['default'] : false; |
$pf->addConfigureOption($option['name'], $option['prompt'], $default); |
} |
} |
|
if (isset($release['filelist']['ignore'])) { |
return $this->raiseError('Cannot safely process "' . $packagexml . '" contains ' |
return $this->raiseError('Cannot safely process "' . $packagexml . '" contains ' |
. 'ignore tags. Using a PEAR_PackageFileManager-based script or the convert' . |
' command is an option'); |
} |
|
if (isset($release['filelist']['install']) && |
!isset($release['filelist']['install'][0])) { |
$release['filelist']['install'] = array($release['filelist']['install']); |
} |
|
if (isset($contents['dir']['attribs']['baseinstalldir'])) { |
$baseinstalldir = $contents['dir']['attribs']['baseinstalldir']; |
} else { |
$baseinstalldir = false; |
} |
|
if (!isset($contents['dir']['file'][0])) { |
$contents['dir']['file'] = array($contents['dir']['file']); |
} |
|
foreach ($contents['dir']['file'] as $file) { |
if ($baseinstalldir && !isset($file['attribs']['baseinstalldir'])) { |
$file['attribs']['baseinstalldir'] = $baseinstalldir; |
} |
|
$processFile = $file; |
unset($processFile['attribs']); |
if (count($processFile)) { |
349,11 → 390,13 |
$file['attribs']['replace'][] = $task; |
} |
} |
|
if (!in_array($file['attribs']['role'], PEAR_Common::getFileRoles())) { |
return $this->raiseError('Cannot safely convert "' . $packagexml . |
'", contains custom roles. Using a PEAR_PackageFileManager-based script ' . |
'or the convert command is an option'); |
} |
|
if (isset($release['filelist']['install'])) { |
foreach ($release['filelist']['install'] as $installas) { |
if ($installas['attribs']['name'] == $file['attribs']['name']) { |
361,16 → 404,17 |
} |
} |
} |
|
$pf->addFile('/', $file['attribs']['name'], $file['attribs']); |
} |
|
if ($pf2->getChangeLog()) { |
$this->ui->outputData('WARNING: changelog is not translated to package.xml ' . |
'1.0, use PEAR_PackageFileManager-based script if you need changelog-' . |
'translation for package.xml 1.0'); |
} |
|
$gen = &$pf->getDefaultGenerator(); |
$gen->toPackageFile('.'); |
} |
} |
|
?> |