Source for file v1.php
Documentation is available at v1.php
* package.xml generation class, package.xml version 1.0
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version CVS: $Id: v1.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
* needed for PEAR_VALIDATE_* constants
require_once 'PEAR/Validate.php';
require_once 'System.php';
require_once 'PEAR/PackageFile/v2.php';
* This class converts a PEAR_PackageFile_v1 object into any output format.
* Supported output formats include array, XML string, and a PEAR_PackageFile_v2
* object, for converting package.xml 1.0 into package.xml 2.0 with no sweat.
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version Release: 1.9.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
* @var PEAR_PackageFile_v1
$this->_packagefile = &$packagefile;
* @param bool if true, a .tgz is written, otherwise a .tar is written
* @param string|nulldirectory in which to save the .tgz
* @return string|PEAR_Errorlocation of package or error object
function toTgz(&$packager, $compress = true , $where = null )
require_once 'Archive/Tar.php';
return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: "' . $where . '" could' .
if (file_exists($where . DIRECTORY_SEPARATOR . 'package.xml') &&
!is_file($where . DIRECTORY_SEPARATOR . 'package.xml')) {
return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: unable to save package.xml as' .
' "' . $where . DIRECTORY_SEPARATOR . 'package.xml"');
return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: invalid package file');
$pkginfo = $this->_packagefile->getArray();
$ext = $compress ? '.tgz' : '.tar';
$pkgver = $pkginfo['package'] . '-' . $pkginfo['version'];
$dest_package = getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext;
return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: cannot create tgz file "' .
getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext . '"');
return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: package file object must ' .
'be created from a real file');
// {{{ Create the package file list
foreach ($this->_packagefile->getFilelist() as $fname => $atts) {
$file = $pkgdir . DIRECTORY_SEPARATOR . $fname;
if (!isset ($atts['md5sum'])) {
$packager->log (2 , " Adding file $fname" );
$tar = & new Archive_Tar ($dest_package, $compress);
// ----- Creates with the package.xml file
$ok = $tar->createModify (array ($packagexml), '', $where);
return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: tarball creation failed');
// ----- Add the content of the package
if (!$tar->addModify ($filelist, $pkgver, $pkgdir)) {
return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: tarball creation failed');
* @param string|nulldirectory to place the package.xml in, or null for a temporary dir
* @param int one of the PEAR_VALIDATE_* constants
* @param string name of the generated file
* @param bool if true, then no analysis will be performed on role="php" files
* @return string|PEAR_Errorpath to the created file on success
function toPackageFile($where = null , $state = PEAR_VALIDATE_NORMAL , $name = 'package.xml',
if (!$this->_packagefile->validate($state, $nofilechecking)) {
return PEAR::raiseError('PEAR_Packagefile_v1::toPackageFile: invalid package.xml',
return PEAR::raiseError('PEAR_Packagefile_v1::toPackageFile: mktemp failed');
return PEAR::raiseError('PEAR_Packagefile_v1::toPackageFile: "' . $where . '" could' .
$newpkgfile = $where . DIRECTORY_SEPARATOR . $name;
$np = @fopen($newpkgfile, 'wb');
return PEAR::raiseError('PEAR_Packagefile_v1::toPackageFile: unable to save ' .
* fix both XML encoding to be UTF8, and replace standard XML entities < > " & '
function _fixXmlEncoding ($string)
return strtr($string, array (
* Return an XML document based on the package info (as returned
* by the PEAR_Common::infoFrom* methods).
* @return string XML data
function toXml($state = PEAR_VALIDATE_NORMAL , $nofilevalidation = false )
if (!$this->_packagefile->validate($state, $nofilevalidation)) {
$pkginfo = $this->_packagefile->getArray();
static $maint_map = array (
$ret = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
$ret .= "<!DOCTYPE package SYSTEM \"http://pear.php.net/dtd/package-1.0\">\n";
$ret .= "<package version=\"1.0\" packagerversion=\"1.9.4\">\n" .
" <name>$pkginfo[package]</name>";
if (isset ($pkginfo['extends'])) {
$ret .= " \n<extends>$pkginfo[extends]</extends>";
"\n <summary>". $this->_fixXmlEncoding ($pkginfo['summary']). "</summary>\n" .
" <description>". trim($this->_fixXmlEncoding ($pkginfo['description'])). "\n </description>\n" .
foreach ($pkginfo['maintainers'] as $maint) {
$ret .= " <maintainer>\n";
foreach ($maint_map as $idx => $elm) {
$ret .= $this->_fixXmlEncoding ($maint[$idx]);
$ret .= " </maintainer>\n";
$ret .= " </maintainers>\n";
$ret .= $this->_makeReleaseXml ($pkginfo, false , $state);
if (isset ($pkginfo['changelog']) && count($pkginfo['changelog']) > 0 ) {
$ret .= " <changelog>\n";
foreach ($pkginfo['changelog'] as $oldrelease) {
$ret .= $this->_makeReleaseXml ($oldrelease, true );
$ret .= " </changelog>\n";
* Generate part of an XML description with release information.
* @param array $pkginfo array with release information
* @param bool $changelog whether the result will be in a changelog element
* @return string XML data
function _makeReleaseXml ($pkginfo, $changelog = false , $state = PEAR_VALIDATE_NORMAL )
// XXX QUOTE ENTITIES IN PCDATA, OR EMBED IN CDATA BLOCKS!!
$indent = $changelog ? " " : "";
$ret = " $indent <release>\n";
if (!empty ($pkginfo['version'])) {
$ret .= " $indent <version>$pkginfo[version]</version>\n";
if (!empty ($pkginfo['release_date'])) {
$ret .= " $indent <date>$pkginfo[release_date]</date>\n";
if (!empty ($pkginfo['release_license'])) {
$ret .= " $indent <license>$pkginfo[release_license]</license>\n";
if (!empty ($pkginfo['release_state'])) {
$ret .= " $indent <state>$pkginfo[release_state]</state>\n";
if (!empty ($pkginfo['release_notes'])) {
$ret .= " $indent <notes>". trim($this->_fixXmlEncoding ($pkginfo['release_notes']))
if (!empty ($pkginfo['release_warnings'])) {
$ret .= " $indent <warnings>". $this->_fixXmlEncoding ($pkginfo['release_warnings']). "</warnings>\n";
if (isset ($pkginfo['release_deps']) && sizeof($pkginfo['release_deps']) > 0 ) {
$ret .= " $indent <deps>\n";
foreach ($pkginfo['release_deps'] as $dep) {
$ret .= " $indent <dep type=\"$dep[type]\" rel=\"$dep[rel]\"";
if (isset ($dep['version'])) {
$ret .= " version=\"$dep[version]\"";
if (isset ($dep['optional'])) {
$ret .= " optional=\"$dep[optional]\"";
if (isset ($dep['name'])) {
$ret .= " >$dep[name]</dep>\n";
$ret .= " $indent </deps>\n";
if (isset ($pkginfo['configure_options'])) {
$ret .= " $indent <configureoptions>\n";
foreach ($pkginfo['configure_options'] as $c) {
$ret .= " $indent <configureoption name=\"".
$this->_fixXmlEncoding ($c['name']) . "\"";
if (isset ($c['default'])) {
$ret .= " default=\"" . $this->_fixXmlEncoding ($c['default']) . "\"";
$ret .= " prompt=\"" . $this->_fixXmlEncoding ($c['prompt']) . "\"";
$ret .= " $indent </configureoptions>\n";
if (isset ($pkginfo['provides'])) {
foreach ($pkginfo['provides'] as $key => $what) {
$ret .= " $indent <provides type=\"$what[type]\" ";
$ret .= " name=\"$what[name]\" ";
if (isset ($what['extends'])) {
$ret .= " extends=\"$what[extends]\" ";
if (isset ($pkginfo['filelist'])) {
$ret .= " $indent <filelist>\n";
foreach ($pkginfo['filelist'] as $file => $fa) {
if (!isset ($fa['role'])) {
$ret .= " $indent <file role=\"$fa[role]\"";
if (isset ($fa['baseinstalldir'])) {
$ret .= ' baseinstalldir="' .
$this->_fixXmlEncoding ($fa['baseinstalldir']) . '"';
if (isset ($fa['md5sum'])) {
$ret .= " md5sum=\"$fa[md5sum]\"";
if (isset ($fa['platform'])) {
$ret .= " platform=\"$fa[platform]\"";
if (!empty ($fa['install-as'])) {
$ret .= ' install-as="' .
$this->_fixXmlEncoding ($fa['install-as']) . '"';
$ret .= ' name="' . $this->_fixXmlEncoding ($file) . '"';
if (empty ($fa['replacements'])) {
foreach ($fa['replacements'] as $r) {
$ret .= " $indent <replace";
foreach ($r as $k => $v) {
$ret .= " $k=\"" . $this->_fixXmlEncoding ($v) . '"';
$ret .= " $indent </file>\n";
$ret .= " $indent </filelist>\n";
$ret .= " $indent </release>\n";
foreach ($list as $file => $attributes) {
$this->_addDir ($this->_dirs, explode('/', dirname($file)), $file, $attributes);
return $this->_formatDir ($this->_dirs);
function _addDir (&$dirs, $dir, $file = null , $attributes = null )
if ($dir == array () || $dir == array ('.')) {
$dirs['files'][basename($file)] = $attributes;
if (!isset ($dirs['dirs'][$curdir])) {
$dirs['dirs'][$curdir] = array ();
$this->_addDir ($dirs['dirs'][$curdir], $dir, $file, $attributes);
function _formatDir ($dirs, $indent = '', $curdir = '')
if (isset ($dirs['dirs'])) {
uksort($dirs['dirs'], 'strnatcasecmp');
foreach ($dirs['dirs'] as $dir => $contents) {
$usedir = " $curdir/$dir";
$ret .= " $indent <dir name=\"$dir\">\n";
$ret .= $this->_formatDir ($contents, " $indent " , $usedir);
$ret .= " $indent </dir> <!-- $usedir -->\n";
if (isset ($dirs['files'])) {
uksort($dirs['files'], 'strnatcasecmp');
foreach ($dirs['files'] as $file => $attribs) {
$ret .= $this->_formatFile ($file, $attribs, $indent);
function _formatFile ($file, $attributes, $indent)
$ret = " $indent <file role=\"$attributes[role]\"";
if (isset ($attributes['baseinstalldir'])) {
$ret .= ' baseinstalldir="' .
$this->_fixXmlEncoding ($attributes['baseinstalldir']) . '"';
if (isset ($attributes['md5sum'])) {
$ret .= " md5sum=\"$attributes[md5sum]\"";
if (isset ($attributes['platform'])) {
$ret .= " platform=\"$attributes[platform]\"";
if (!empty ($attributes['install-as'])) {
$ret .= ' install-as="' .
$this->_fixXmlEncoding ($attributes['install-as']) . '"';
$ret .= ' name="' . $this->_fixXmlEncoding ($file) . '"';
if (empty ($attributes['replacements'])) {
foreach ($attributes['replacements'] as $r) {
$ret .= " $indent <replace";
foreach ($r as $k => $v) {
$ret .= " $k=\"" . $this->_fixXmlEncoding ($v) . '"';
$ret .= " $indent </file>\n";
* Unindent given string (?)
* @param string $str The string that has to be unindented.
// remove leading newlines
// find whitespace at the beginning of the first line
$indent_len = strspn($str, " \t");
$indent = substr($str, 0 , $indent_len);
// remove the same amount of whitespace from following lines
foreach (explode("\n", $str) as $line) {
if (substr($line, 0 , $indent_len) == $indent) {
$data .= substr($line, $indent_len) . "\n";
$this->_convertDependencies2_0 ($arr);
return $arr['dependencies'];
* Convert a package.xml version 1.0 into version 2.0
* Note that this does a basic conversion, to allow more advanced
* features like bundles and multiple releases
* @param string the classname to instantiate and return. This must be
* PEAR_PackageFile_v2 or a descendant
* @param boolean if true, only valid, deterministic package.xml 1.0 as defined by the
* strictest parameters will be converted
* @return PEAR_PackageFile_v2|PEAR_Error
function &toV2($class = 'PEAR_PackageFile_v2', $strict = false )
$a = PEAR::raiseError('invalid package.xml version 1.0 cannot be converted' .
' to version 2.0', null , null , null ,
'xmlns' => 'http://pear.php.net/dtd/package-2.0',
'xmlns:tasks' => 'http://pear.php.net/dtd/tasks-1.0',
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation' => "http://pear.php.net/dtd/tasks-1.0\n" .
"http://pear.php.net/dtd/tasks-1.0.xsd\n" .
"http://pear.php.net/dtd/package-2.0\n" .
'http://pear.php.net/dtd/package-2.0.xsd',
'channel' => 'pear.php.net',
$arr['summary'] = $this->_packagefile->getSummary();
foreach ($maintainers as $maintainer) {
if ($maintainer['role'] != 'lead') {
'name' => $maintainer['name'],
'user' => $maintainer['handle'],
'email' => $maintainer['email'],
if (!isset ($arr['lead'])) { // some people... you know?
'email' => 'noleadmaintainer@example.com',
if (count($arr['lead']) == 1 ) {
$arr['lead'] = $arr['lead'][0 ];
foreach ($maintainers as $maintainer) {
if ($maintainer['role'] == 'lead') {
'name' => $maintainer['name'],
'user' => $maintainer['handle'],
'email' => $maintainer['email'],
$arr[$maintainer['role']][] = $new;
if (isset ($arr['developer']) && count($arr['developer']) == 1 ) {
$arr['developer'] = $arr['developer'][0 ];
if (isset ($arr['contributor']) && count($arr['contributor']) == 1 ) {
$arr['contributor'] = $arr['contributor'][0 ];
if (isset ($arr['helper']) && count($arr['helper']) == 1 ) {
$arr['helper'] = $arr['helper'][0 ];
$arr['date'] = $this->_packagefile->getDate();
'release' => $this->_packagefile->getState(),
'api' => $this->_packagefile->getState(),
'php' => 'http://www.php.net/license',
'php license' => 'http://www.php.net/license',
'lgpl' => 'http://www.gnu.org/copyleft/lesser.html',
'bsd' => 'http://www.opensource.org/licenses/bsd-license.php',
'bsd style' => 'http://www.opensource.org/licenses/bsd-license.php',
'bsd-style' => 'http://www.opensource.org/licenses/bsd-license.php',
'mit' => 'http://www.opensource.org/licenses/mit-license.php',
'gpl' => 'http://www.gnu.org/copyleft/gpl.html',
'apache' => 'http://www.opensource.org/licenses/apache2.0.php'
'attribs' => array ('uri' =>
$arr['license'] = $this->_packagefile->getLicense();
$arr['notes'] = $this->_packagefile->getNotes();
$arr['contents'] = $this->_convertFilelist2_0 ($temp);
$this->_convertDependencies2_0 ($arr);
'extsrcrelease' : 'phprelease';
if ($release == 'extsrcrelease') {
$arr['channel'] = 'pecl.php.net';
$arr['providesextension'] = $arr['name']; // assumption
$arr[$release] = array ();
foreach ($arr[$release]['configureoption'] as $i => $opt) {
$arr[$release]['configureoption'][$i] = array ('attribs' => $opt);
if (count($arr[$release]['configureoption']) == 1 ) {
$arr[$release]['configureoption'] = $arr[$release]['configureoption'][0 ];
$this->_convertRelease2_0 ($arr[$release], $temp);
if ($release == 'extsrcrelease' && count($arr[$release]) > 1 ) {
// multiple extsrcrelease tags added in PEAR 1.4.1
$arr['dependencies']['required']['pearinstaller']['min'] = '1.4.1';
foreach ($cl as $release) {
'release' => $release['version'],
'api' => $release['version'],
if (!isset ($release['release_state'])) {
$release['release_state'] = 'stable';
'release' => $release['release_state'],
'api' => $release['release_state'],
if (isset ($release['release_date'])) {
$rel['date'] = $release['release_date'];
$rel['date'] = date('Y-m-d');
if (isset ($release['release_license'])) {
if (isset ($licensemap[strtolower($release['release_license'])])) {
$uri = $licensemap[strtolower($release['release_license'])];
$uri = 'http://www.example.com';
'attribs' => array ('uri' => $uri),
'_content' => $release['release_license']
$rel['license'] = $arr['license'];
if (!isset ($release['release_notes'])) {
$release['release_notes'] = 'no release notes';
$rel['notes'] = $release['release_notes'];
$arr['changelog']['release'][] = $rel;
$ret->setConfig ($this->_packagefile->_config);
if (isset ($this->_packagefile->_logger) && is_object($this->_packagefile->_logger)) {
$ret->setLogger ($this->_packagefile->_logger);
function _convertDependencies2_0 (&$release, $internal = false )
$peardep = array ('pearinstaller' =>
array ('min' => '1.4.0b1')); // this is a lot safer
$required = $optional = array ();
$release['dependencies'] = array ('required' => array ());
if ($this->_packagefile->hasDeps()) {
foreach ($this->_packagefile->getDeps() as $dep) {
if (!isset ($dep['optional']) || $dep['optional'] == 'no') {
foreach (array ('required', 'optional') as $arr) {
foreach ($ $arr as $dep) {
// organize deps by dependency type and name
if (!isset ($deps[$dep['type']])) {
$deps[$dep['type']] = array ();
if (isset ($dep['name'])) {
$deps[$dep['type']][$dep['name']][] = $dep;
$deps[$dep['type']][] = $dep;
if (isset ($deps['php'])) {
if (count($deps['php']) > 1 ) {
$php = $this->_processPhpDeps ($deps['php']);
if (!isset ($deps['php'][0 ])) {
list ($key, $blah) = each ($deps['php']); // stupid buggy versions
$deps['php'] = array ($blah[0 ]);
$php = $this->_processDep ($deps['php'][0 ]);
break; // poor mans throw
$release['dependencies'][$arr]['php'] = $php;
if (isset ($deps['pkg'])) {
$pkg = $this->_processMultipleDepsName ($deps['pkg']);
break; // poor mans throw
$release['dependencies'][$arr]['package'] = $pkg;
if (isset ($deps['ext'])) {
$pkg = $this->_processMultipleDepsName ($deps['ext']);
$release['dependencies'][$arr]['extension'] = $pkg;
// skip sapi - it's not supported so nobody will have used it
// skip os - it's not supported in 1.0
if (isset ($release['dependencies']['required'])) {
$release['dependencies']['required'] =
array_merge($peardep, $release['dependencies']['required']);
$release['dependencies']['required'] = $peardep;
if (!isset ($release['dependencies']['required']['php'])) {
$release['dependencies']['required']['php'] =
$bewm = $release['dependencies']['required'];
$order['php'] = $bewm['php'];
$order['pearinstaller'] = $bewm['pearinstaller'];
isset ($bewm['package']) ? $order['package'] = $bewm['package'] :0;
isset ($bewm['extension']) ? $order['extension'] = $bewm['extension'] :0;
$release['dependencies']['required'] = $order;
function _convertFilelist2_0 (&$package)
'attribs' => array ('name' => '/'),
$package['install-as'] = array ();
$this->_isExtension = false;
foreach ($this->_packagefile->getFilelist() as $name => $file) {
if (isset ($file['role']) && $file['role'] == 'src') {
$this->_isExtension = true;
if (isset ($file['replacements'])) {
$repl = $file['replacements'];
unset ($file['replacements']);
if (isset ($file['install-as'])) {
$package['install-as'][$name] = $file['install-as'];
unset ($file['install-as']);
if (isset ($file['platform'])) {
$package['platform'][$name] = $file['platform'];
unset ($file['platform']);
$file = array ('attribs' => $file);
foreach ($repl as $replace ) {
$file['tasks:replace'][] = array ('attribs' => $replace);
$file['tasks:replace'] = $file['tasks:replace'][0 ];
$ret['dir']['file'][] = $file;
* Post-process special files with install-as/platform attributes and
* This complex method follows this work-flow to create the release tags:
* - if any install-as/platform exist, create a generic release and fill it with
* o <install as=..> tags for <file name=... install-as=...>
* o <install as=..> tags for <file name=... platform=!... install-as=..>
* o <ignore> tags for <file name=... platform=...>
* o <ignore> tags for <file name=... platform=... install-as=..>
* - create a release for each platform encountered and fill with
* o <install as..> tags for <file name=... install-as=...>
* o <install as..> tags for <file name=... platform=this platform install-as=..>
* o <install as..> tags for <file name=... platform=!other platform install-as=..>
* o <ignore> tags for <file name=... platform=!this platform>
* o <ignore> tags for <file name=... platform=other platform>
* o <ignore> tags for <file name=... platform=other platform install-as=..>
* o <ignore> tags for <file name=... platform=!this platform install-as=..>
* It does this by accessing the $package parameter, which contains an array with
* - platform: mapping of file => OS the file should be installed on
* - install-as: mapping of file => installed name
* - osmap: mapping of OS => list of files that should be installed
* - notosmap: mapping of OS => list of files that should not be
function _convertRelease2_0 (&$release, $package)
//- if any install-as/platform exist, create a generic release and fill it with
if (count($package['platform']) || count($package['install-as'])) {
$genericIgnore = array ();
foreach ($package['install-as'] as $file => $as) {
//o <install as=..> tags for <file name=... install-as=...>
if (!isset ($package['platform'][$file])) {
//o <install as=..> tags for <file name=... platform=!... install-as=..>
if (isset ($package['platform'][$file]) &&
$package['platform'][$file]{0 } == '!') {
//o <ignore> tags for <file name=... platform=... install-as=..>
if (isset ($package['platform'][$file]) &&
$package['platform'][$file]{0 } != '!') {
$genericIgnore[] = $file;
foreach ($package['platform'] as $file => $platform) {
if (isset ($package['install-as'][$file])) {
if ($platform{0 } != '!') {
//o <ignore> tags for <file name=... platform=...>
$genericIgnore[] = $file;
if (count($package['platform'])) {
$oses = $notplatform = $platform = array ();
foreach ($package['platform'] as $file => $os) {
if (isset ($oses[substr($os, 1 )])) {
$oses[$os] = count($oses);
//- create a release for each platform encountered and fill with
foreach ($oses as $os => $releaseNum) {
$release[$releaseNum]['installconditions']['os']['name'] = $os;
$release[$releaseNum]['filelist'] = array ('install' => array (),
foreach ($package['install-as'] as $file => $as) {
//o <install as=..> tags for <file name=... install-as=...>
if (!isset ($package['platform'][$file])) {
$release[$releaseNum]['filelist']['install'][] =
//o <install as..> tags for
// <file name=... platform=this platform install-as=..>
if (isset ($package['platform'][$file]) &&
$package['platform'][$file] == $os) {
$release[$releaseNum]['filelist']['install'][] =
//o <install as..> tags for
// <file name=... platform=!other platform install-as=..>
if (isset ($package['platform'][$file]) &&
$package['platform'][$file] != " !$os" &&
$package['platform'][$file]{0 } == '!') {
$release[$releaseNum]['filelist']['install'][] =
// <file name=... platform=!this platform install-as=..>
if (isset ($package['platform'][$file]) &&
$package['platform'][$file] == " !$os" ) {
$release[$releaseNum]['filelist']['ignore'][] =
// <file name=... platform=other platform install-as=..>
if (isset ($package['platform'][$file]) &&
$package['platform'][$file]{0 } != '!' &&
$package['platform'][$file] != $os) {
$release[$releaseNum]['filelist']['ignore'][] =
foreach ($package['platform'] as $file => $platform) {
if (isset ($package['install-as'][$file])) {
//o <ignore> tags for <file name=... platform=!this platform>
if ($platform == " !$os" ) {
$release[$releaseNum]['filelist']['ignore'][] =
//o <ignore> tags for <file name=... platform=other platform>
if ($platform{0 } != '!' && $platform != $os) {
$release[$releaseNum]['filelist']['ignore'][] =
if (!count($release[$releaseNum]['filelist']['install'])) {
unset ($release[$releaseNum]['filelist']['install']);
if (!count($release[$releaseNum]['filelist']['ignore'])) {
unset ($release[$releaseNum]['filelist']['ignore']);
$release[count($oses)] = array ();
foreach ($generic as $file) {
if (isset ($package['install-as'][$file])) {
$installas = $package['install-as'][$file];
$release[count($oses)]['filelist']['install'][] =
if (count($genericIgnore)) {
foreach ($genericIgnore as $file) {
$release[count($oses)]['filelist']['ignore'][] =
foreach ($release as $i => $rel) {
if (isset ($rel['filelist']['install']) &&
count($rel['filelist']['install']) == 1 ) {
$release[$i]['filelist']['install'] =
$release[$i]['filelist']['install'][0 ];
if (isset ($rel['filelist']['ignore']) &&
count($rel['filelist']['ignore']) == 1 ) {
$release[$i]['filelist']['ignore'] =
$release[$i]['filelist']['ignore'][0 ];
if (count($release) == 1 ) {
// no platform atts, but some install-as atts
foreach ($package['install-as'] as $file => $value) {
$release['filelist']['install'][] =
if (count($release['filelist']['install']) == 1 ) {
$release['filelist']['install'] = $release['filelist']['install'][0 ];
function _processDep ($dep)
if ($dep['type'] == 'php') {
if ($dep['rel'] == 'has') {
// come on - everyone has php!
if ($dep['type'] != 'php') {
$php['name'] = $dep['name'];
if ($dep['type'] == 'pkg') {
$php['channel'] = 'pear.php.net';
$php['min'] = $dep['version'];
$php['exclude'] = $dep['version'];
if (!isset ($dep['version'])) {
if ($dep['type'] == 'php') {
if (isset ($dep['name'])) {
$dep['version'] = $dep['name'];
$php['min'] = $dep['version'];
$php['max'] = $dep['version'];
$php['exclude'] = $dep['version'];
$php['max'] = $dep['version'];
$php['min'] = $dep['version'];
$php['max'] = $dep['version'];
$php['exclude'] = $dep['version'];
$php['conflicts'] = 'yes';
function _processPhpDeps ($deps)
foreach ($deps as $dep) {
$test[] = $this->_processDep ($dep);
foreach ($test as $dep) {
if (isset ($dep['min'])) {
$min[$dep['min']] = count($min);
if (isset ($dep['max'])) {
$max[$dep['max']] = count($max);
uksort($min, 'version_compare');
uksort($max, 'version_compare');
// get the highest minimum
// get the lowest maximum
foreach ($test as $dep) {
if (!isset ($dep['exclude'])) {
$exclude[] = $dep['exclude'];
$php['exclude'] = $exclude;
* process multiple dependencies that have a name, like package deps
function _processMultipleDepsName ($deps)
foreach ($deps as $name => $dep) {
$tests[$name][] = $this->_processDep ($d);
foreach ($tests as $name => $test) {
$max = $min = $php = array ();
foreach ($test as $dep) {
if (isset ($dep['channel'])) {
$php['channel'] = 'pear.php.net';
if (isset ($dep['conflicts']) && $dep['conflicts'] == 'yes') {
$php['conflicts'] = 'yes';
if (isset ($dep['min'])) {
$min[$dep['min']] = count($min);
if (isset ($dep['max'])) {
$max[$dep['max']] = count($max);
uksort($min, 'version_compare');
uksort($max, 'version_compare');
// get the highest minimum
// get the lowest maximum
foreach ($test as $dep) {
if (!isset ($dep['exclude'])) {
$exclude[] = $dep['exclude'];
$php['exclude'] = $exclude;
Documentation generated on Wed, 06 Jul 2011 23:31:30 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.
|