Source for file rw.php
Documentation is available at rw.php
* PEAR_PackageFile_v2, package.xml version 2.0, read/write version
* @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: rw.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a8
require_once 'PEAR/PackageFile/v2.php';
* @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.0a8
* @param string Extension name
* @return bool success of operation
array ('extsrc', 'extbin', 'zendextsrc', 'zendextbin'))) {
if (!isset ($this->_packageInfo['providesextension'])) {
// ensure that the channel tag is set up in the right location
$this->_packageInfo = $this->_insertBefore ($this->_packageInfo,
array ('usesrole', 'usestask', 'srcpackage', 'srcuri', 'phprelease',
'extsrcrelease', 'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease',
$extension, 'providesextension');
$this->_packageInfo['providesextension'] = $extension;
if (!isset ($this->_packageInfo['attribs'])) {
$this->_packageInfo = array_merge(array ('attribs' => array (
'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
http://pear.php.net/dtd/tasks-1.0.xsd
http://pear.php.net/dtd/package-2.0
http://pear.php.net/dtd/package-2.0.xsd',
)), $this->_packageInfo);
if (!isset ($this->_packageInfo['name'])) {
return $this->_packageInfo = array_merge(array ('name' => $package),
$this->_packageInfo['name'] = $package;
* set this as a package.xml version 2.1
function _setPackageVersion2_1 ()
'xmlns' => 'http://pear.php.net/dtd/package-2.1',
'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
http://pear.php.net/dtd/tasks-1.0.xsd
http://pear.php.net/dtd/package-2.1
http://pear.php.net/dtd/package-2.1.xsd',
if (!isset ($this->_packageInfo['attribs'])) {
$this->_packageInfo = array_merge(array ('attribs' => $info), $this->_packageInfo);
$this->_packageInfo['attribs'] = $info;
unset ($this->_packageInfo['channel']);
if (!isset ($this->_packageInfo['uri'])) {
// ensure that the uri tag is set up in the right location
$this->_packageInfo = $this->_insertBefore ($this->_packageInfo,
array ('extends', 'summary', 'description', 'lead',
'developer', 'contributor', 'helper', 'date', 'time', 'version',
'stability', 'license', 'notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
'extbinrelease', 'bundle', 'changelog'), $uri, 'uri');
$this->_packageInfo['uri'] = $uri;
unset ($this->_packageInfo['uri']);
if (!isset ($this->_packageInfo['channel'])) {
// ensure that the channel tag is set up in the right location
$this->_packageInfo = $this->_insertBefore ($this->_packageInfo,
array ('extends', 'summary', 'description', 'lead',
'developer', 'contributor', 'helper', 'date', 'time', 'version',
'stability', 'license', 'notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
'extbinrelease', 'bundle', 'changelog'), $channel, 'channel');
$this->_packageInfo['channel'] = $channel;
if (!isset ($this->_packageInfo['extends'])) {
// ensure that the extends tag is set up in the right location
$this->_packageInfo = $this->_insertBefore ($this->_packageInfo,
array ('summary', 'description', 'lead',
'developer', 'contributor', 'helper', 'date', 'time', 'version',
'stability', 'license', 'notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
'extbinrelease', 'bundle', 'changelog'), $extends, 'extends');
$this->_packageInfo['extends'] = $extends;
if (!isset ($this->_packageInfo['summary'])) {
// ensure that the summary tag is set up in the right location
$this->_packageInfo = $this->_insertBefore ($this->_packageInfo,
array ('description', 'lead',
'developer', 'contributor', 'helper', 'date', 'time', 'version',
'stability', 'license', 'notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
'extbinrelease', 'bundle', 'changelog'), $summary, 'summary');
$this->_packageInfo['summary'] = $summary;
if (!isset ($this->_packageInfo['description'])) {
// ensure that the description tag is set up in the right location
$this->_packageInfo = $this->_insertBefore ($this->_packageInfo,
'developer', 'contributor', 'helper', 'date', 'time', 'version',
'stability', 'license', 'notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
'extbinrelease', 'bundle', 'changelog'), $desc, 'description');
$this->_packageInfo['description'] = $desc;
* Adds a new maintainer - no checking of duplicates is performed, use
* updatemaintainer for that purpose.
function addMaintainer($role, $handle, $name, $email, $active = 'yes')
if (!in_array($role, array ('lead', 'developer', 'contributor', 'helper'))) {
if (isset ($this->_packageInfo[$role])) {
if (!isset ($this->_packageInfo[$role][0 ])) {
$this->_packageInfo[$role] = array ($this->_packageInfo[$role]);
$this->_packageInfo[$role][] =
'developer', 'contributor', 'helper', 'date', 'time', 'version',
'stability', 'license', 'notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease',
'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog');
foreach (array ('lead', 'developer', 'contributor', 'helper') as $testrole) {
if ($role == $testrole) {
if (!isset ($this->_packageInfo[$role])) {
// ensure that the extends tag is set up in the right location
$this->_packageInfo = $this->_insertBefore ($this->_packageInfo, $testarr,
$this->_packageInfo[$role] =
foreach (array ('lead', 'developer', 'contributor', 'helper') as $role) {
if (!isset ($this->_packageInfo[$role])) {
$info = $this->_packageInfo[$role];
if ($info['user'] == $handle) {
foreach ($info as $i => $maintainer) {
if ($maintainer['user'] == $handle) {
return $this->addMaintainer($newrole, $handle, $name, $email, $active);
unset ($this->_packageInfo[$role]);
unset ($this->_packageInfo[$role][$found]);
$this->_packageInfo[$role] = array_values($this->_packageInfo[$role]);
foreach (array ('lead', 'developer', 'contributor', 'helper') as $role) {
if (!isset ($this->_packageInfo[$role])) {
if (!isset ($this->_packageInfo[$role][0 ])) {
$this->_packageInfo[$role] = array ($this->_packageInfo[$role]);
foreach ($this->_packageInfo[$role] as $i => $maintainer) {
if ($maintainer['user'] == $handle) {
unset ($this->_packageInfo[$role][$found]);
if (!count($this->_packageInfo[$role]) && $role == 'lead') {
if (!count($this->_packageInfo[$role])) {
unset ($this->_packageInfo[$role]);
$this->_packageInfo[$role] =
if (count($this->_packageInfo[$role]) == 1 ) {
$this->_packageInfo[$role] = $this->_packageInfo[$role][0 ];
if (count($this->_packageInfo[$role]) == 1 ) {
$this->_packageInfo[$role] = $this->_packageInfo[$role][0 ];
if (isset ($this->_packageInfo['version']) &&
isset ($this->_packageInfo['version']['release'])) {
unset ($this->_packageInfo['version']['release']);
$this->_packageInfo = $this->_mergeTag ($this->_packageInfo, $version, array (
'version' => array ('stability', 'license', 'notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
'extbinrelease', 'bundle', 'changelog'),
'release' => array ('api')));
if (isset ($this->_packageInfo['version']) &&
isset ($this->_packageInfo['version']['api'])) {
unset ($this->_packageInfo['version']['api']);
$this->_packageInfo = $this->_mergeTag ($this->_packageInfo, $version, array (
'version' => array ('stability', 'license', 'notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
'extbinrelease', 'bundle', 'changelog'),
* snapshot|devel|alpha|beta|stable
if (isset ($this->_packageInfo['stability']) &&
isset ($this->_packageInfo['stability']['release'])) {
unset ($this->_packageInfo['stability']['release']);
$this->_packageInfo = $this->_mergeTag ($this->_packageInfo, $state, array (
'stability' => array ('license', 'notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
'extbinrelease', 'bundle', 'changelog'),
'release' => array ('api')));
* @param devel|alpha|beta|stable
if (isset ($this->_packageInfo['stability']) &&
isset ($this->_packageInfo['stability']['api'])) {
unset ($this->_packageInfo['stability']['api']);
$this->_packageInfo = $this->_mergeTag ($this->_packageInfo, $state, array (
'stability' => array ('license', 'notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
'extbinrelease', 'bundle', 'changelog'),
function setLicense($license, $uri = false , $filesource = false )
if (!isset ($this->_packageInfo['license'])) {
// ensure that the license tag is set up in the right location
$this->_packageInfo = $this->_insertBefore ($this->_packageInfo,
array ('notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
'extbinrelease', 'bundle', 'changelog'), 0 , 'license');
if ($uri || $filesource) {
$uri = true; // for test below
$attribs['filesource'] = $filesource;
$license = $uri ? array ('attribs' => $attribs, '_content' => $license) : $license;
$this->_packageInfo['license'] = $license;
if (!isset ($this->_packageInfo['notes'])) {
// ensure that the notes tag is set up in the right location
$this->_packageInfo = $this->_insertBefore ($this->_packageInfo,
array ('contents', 'compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
'extbinrelease', 'bundle', 'changelog'), $notes, 'notes');
$this->_packageInfo['notes'] = $notes;
* This is only used at install-time, after all serialization
* @param string file name
* @param string installed path
return $this->_packageInfo['filelist'][$file]['installed_as'] = $path;
unset ($this->_packageInfo['filelist'][$file]['installed_as']);
* This is only used at install-time, after all serialization
if (isset ($this->_packageInfo['filelist'][$file])) {
$this->_packageInfo['filelist'][$file] =
array_merge($this->_packageInfo['filelist'][$file], $atts['attribs']);
$this->_packageInfo['filelist'][$file] = $atts['attribs'];
* Reset the listing of package contents
* @param string base installation dir for the whole package, if any
$this->_filesValid = false;
if (!isset ($this->_packageInfo['contents'])) {
$this->_packageInfo = $this->_insertBefore ($this->_packageInfo,
'dependencies', 'providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease',
'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease',
'bundle', 'changelog'), array (), 'contents');
$this->_packageInfo['contents'] =
array ('dir' => array ('attribs' => array ('name' => '/')));
$this->_packageInfo['contents']['dir']['attribs']['baseinstalldir'] = $baseinstall;
$this->_packageInfo['contents'] = array ('bundledpackage' => array ());
* @param string relative path of the bundled package.
$this->_filesValid = false;
$this->_packageInfo = $this->_mergeTag ($this->_packageInfo, $path, array (
'contents' => array ('compatible', 'dependencies', 'providesextension',
'usesrole', 'usestask', 'srcpackage', 'srcuri', 'phprelease',
'extsrcrelease', 'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease',
'bundledpackage' => array ()));
* @param string file name
* @param PEAR_Task_Common a read/write task
if (!$task->validate ()) {
if (!isset ($this->_packageInfo['contents']['dir']['file'])) {
$this->getTasksNs(); // discover the tasks namespace if not done already
$files = $this->_packageInfo['contents']['dir']['file'];
foreach ($files as $i => $file) {
if (isset ($file['attribs'])) {
if ($file['attribs']['name'] == $filename) {
$t = isset ($this->_packageInfo['contents']['dir']['file'][$i]
['attribs'][$this->_tasksNs .
':' . $task->getName ()]) ?
$this->_packageInfo['contents']['dir']['file'][$i]
['attribs'][$this->_tasksNs .
':' . $task->getName ()] : false;
if ($t && !isset ($t[0 ])) {
$this->_packageInfo['contents']['dir']['file'][$i]
[$this->_tasksNs . ':' . $task->getName ()] = array ($t);
$this->_packageInfo['contents']['dir']['file'][$i][$this->_tasksNs .
':' . $task->getName ()][] = $task->getXml ();
$t = isset ($this->_packageInfo['contents']['dir']['file']
['attribs'][$this->_tasksNs .
':' . $task->getName ()]) ? $this->_packageInfo['contents']['dir']['file']
['attribs'][$this->_tasksNs .
':' . $task->getName ()] : false;
if ($t && !isset ($t[0 ])) {
$this->_packageInfo['contents']['dir']['file']
[$this->_tasksNs . ':' . $task->getName ()] = array ($t);
$this->_packageInfo['contents']['dir']['file'][$this->_tasksNs .
':' . $task->getName ()][] = $task->getXml ();
* @param string path to the file
* @param array extra attributes
function addFile($dir, $file, $attrs)
$this->_filesValid = false;
$dir = preg_replace(array ('!\\\\+!', '!/+!'), array ('/', '/'), $dir);
if ($dir == '/' || $dir == '') {
$attrs['name'] = $dir . $file;
if (!isset ($this->_packageInfo['contents'])) {
// ensure that the contents tag is set up
$this->_packageInfo = $this->_insertBefore ($this->_packageInfo,
array ('compatible', 'dependencies', 'providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease',
'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease',
'bundle', 'changelog'), array (), 'contents');
if (isset ($this->_packageInfo['contents']['dir']['file'])) {
if (!isset ($this->_packageInfo['contents']['dir']['file'][0 ])) {
$this->_packageInfo['contents']['dir']['file'] =
array ($this->_packageInfo['contents']['dir']['file']);
$this->_packageInfo['contents']['dir']['file'][]['attribs'] = $attrs;
$this->_packageInfo['contents']['dir']['file']['attribs'] = $attrs;
* @param string Dependent package name
* @param string Dependent package's channel name
* @param string minimum version of specified package that this release is guaranteed to be
* @param string maximum version of specified package that this release is guaranteed to be
* @param string versions of specified package that this release is not compatible with
$set['exclude'] = $exclude;
$this->_packageInfo = $this->_mergeTag ($this->_packageInfo, $set, array (
'compatible' => array ('dependencies', 'providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog')
* Removes the <usesrole> tag entirely
if (isset ($this->_packageInfo['usesrole'])) {
unset ($this->_packageInfo['usesrole']);
* @param string package name or uri
* @param string channel name if non-uri
function addUsesrole($role, $packageOrUri, $channel = false ) {
$set = array ('role' => $role);
$set['package'] = $packageOrUri;
$set['channel'] = $channel;
$set['uri'] = $packageOrUri;
$this->_packageInfo = $this->_mergeTag ($this->_packageInfo, $set, array (
'usesrole' => array ('usestask', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease', 'extbinrelease',
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog')
* Removes the <usestask> tag entirely
if (isset ($this->_packageInfo['usestask'])) {
unset ($this->_packageInfo['usestask']);
* @param string package name or uri
* @param string channel name if non-uri
function addUsestask($task, $packageOrUri, $channel = false ) {
$set = array ('task' => $task);
$set['package'] = $packageOrUri;
$set['channel'] = $channel;
$set['uri'] = $packageOrUri;
$this->_packageInfo = $this->_mergeTag ($this->_packageInfo, $set, array (
'usestask' => array ('srcpackage', 'srcuri',
'phprelease', 'extsrcrelease', 'extbinrelease',
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog')
* Remove all compatible tags
unset ($this->_packageInfo['compatible']);
* Reset dependencies prior to adding new ones
if (!isset ($this->_packageInfo['dependencies'])) {
$this->_packageInfo = $this->_mergeTag ($this->_packageInfo, array (),
'dependencies' => array ('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog')));
$this->_packageInfo['dependencies'] = array ();
* @param string minimum PHP version allowed
* @param string maximum PHP version allowed
* @param array $exclude incompatible PHP versions
function setPhpDep($min, $max = false , $exclude = false )
if (count($exclude) == 1 ) {
$dep['exclude'] = $exclude;
if (isset ($this->_packageInfo['dependencies']['required']['php'])) {
$this->_stack->push (__FUNCTION__ , 'warning', array ('dep' =>
$this->_packageInfo['dependencies']['required']['php']),
'warning: PHP dependency already exists, overwriting');
unset ($this->_packageInfo['dependencies']['required']['php']);
$this->_packageInfo = $this->_mergeTag ($this->_packageInfo, $dep,
'dependencies' => array ('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
'required' => array ('optional', 'group'),
'php' => array ('pearinstaller', 'package', 'subpackage', 'extension', 'os', 'arch')
* @param string minimum allowed PEAR installer version
* @param string maximum allowed PEAR installer version
* @param string recommended PEAR installer version
* @param array incompatible version of the PEAR installer
$dep['recommended'] = $recommended;
if (count($exclude) == 1 ) {
$dep['exclude'] = $exclude;
if (isset ($this->_packageInfo['dependencies']['required']['pearinstaller'])) {
$this->_stack->push (__FUNCTION__ , 'warning', array ('dep' =>
$this->_packageInfo['dependencies']['required']['pearinstaller']),
'warning: PEAR Installer dependency already exists, overwriting');
unset ($this->_packageInfo['dependencies']['required']['pearinstaller']);
$this->_packageInfo = $this->_mergeTag ($this->_packageInfo, $dep,
'dependencies' => array ('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
'required' => array ('optional', 'group'),
'pearinstaller' => array ('package', 'subpackage', 'extension', 'os', 'arch')
* Mark a package as conflicting with this package
* @param string package name
* @param string package channel
* @param string extension this package provides, if any
* @param string|falseminimum version required
* @param string|falsemaximum version allowed
* @param array|falseversions to exclude from installation
$providesextension = false , $min = false , $max = false , $exclude = false )
$dep = $this->_constructDep ($name, $channel, false , $min, $max, false ,
$exclude, $providesextension, false , true );
$this->_packageInfo = $this->_mergeTag ($this->_packageInfo, $dep,
'dependencies' => array ('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
'required' => array ('optional', 'group'),
'package' => array ('subpackage', 'extension', 'os', 'arch')
* Mark a package as conflicting with this package
* @param string package name
* @param string package channel
* @param string extension this package provides, if any
if ($providesextension) {
$dep['providesextension'] = $providesextension;
$this->_packageInfo = $this->_mergeTag ($this->_packageInfo, $dep,
'dependencies' => array ('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
'required' => array ('optional', 'group'),
'package' => array ('subpackage', 'extension', 'os', 'arch')
$this->_packageInfo = $this->_mergeTag ($this->_packageInfo,
array ('attribs' => array ('name' => $name, 'hint' => $hint)),
'dependencies' => array ('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
* @param string package name
* @param string|falsechannel name, false if this is a uri
* @param string|falseuri name, false if this is a channel
* @param string|falseminimum version required
* @param string|falsemaximum version allowed
* @param string|falserecommended installation version
* @param array|falseversions to exclude from installation
* @param string extension this package provides, if any
* @param bool if true, tells the installer to ignore the default optional dependency group
* when installing this package
* @param bool if true, tells the installer to negate this dependency (conflicts)
function _constructDep ($name, $channel, $uri, $min, $max, $recommended, $exclude,
$providesextension = false , $nodefault = false ,
$dep['channel'] = $channel;
$dep['recommended'] = $recommended;
$dep['exclude'] = $exclude;
if ($providesextension) {
$dep['providesextension'] = $providesextension;
* @param package|subpackage
* @param string group name
* @param string package name
* @param string package channel
* @param string minimum version
* @param string maximum version
* @param string recommended version
* @param array|falseoptional excluded versions
* @param string extension this package provides, if any
* @param bool if true, tells the installer to ignore the default optional dependency group
* when installing this package
* @return bool false if the dependency group has not been initialized with
* {@link addDependencyGroup()}, or a subpackage is added with
$max = false , $recommended = false , $exclude = false ,
$providesextension = false , $nodefault = false )
if ($type == 'subpackage' && $providesextension) {
return false; // subpackages must be php packages
$dep = $this->_constructDep ($name, $channel, false , $min, $max, $recommended, $exclude,
$providesextension, $nodefault);
return $this->_addGroupDependency ($type, $dep, $groupname);
* @param package|subpackage
* @param string group name
* @param string package name
* @param string package uri
* @param string extension this package provides, if any
* @param bool if true, tells the installer to ignore the default optional dependency group
* when installing this package
* @return bool false if the dependency group has not been initialized with
* {@link addDependencyGroup()}
if ($type == 'subpackage' && $providesextension) {
return false; // subpackages must be php packages
$dep = $this->_constructDep ($name, false , $uri, false , false , false , false ,
$providesextension, $nodefault);
return $this->_addGroupDependency ($type, $dep, $groupname);
* @param string group name (must be pre-existing)
* @param string extension name
* @param string minimum version allowed
* @param string maximum version allowed
* @param string recommended version
* @param array incompatible versions
$recommended = false , $exclude = false )
$dep = $this->_constructDep ($name, false , false , $min, $max, $recommended, $exclude);
return $this->_addGroupDependency ('extension', $dep, $groupname);
* @param package|subpackage|extension
* @param array dependency contents
* @param string name of the dependency group to add this to
function _addGroupDependency ($type, $dep, $groupname)
$arr = array ('subpackage', 'extension');
if ($type != 'package') {
if ($type == 'extension') {
if (!isset ($this->_packageInfo['dependencies']['group'])) {
if (!isset ($this->_packageInfo['dependencies']['group'][0 ])) {
if ($this->_packageInfo['dependencies']['group']['attribs']['name'] == $groupname) {
$this->_packageInfo['dependencies']['group'] = $this->_mergeTag (
$this->_packageInfo['dependencies']['group'], $dep,
foreach ($this->_packageInfo['dependencies']['group'] as $i => $group) {
if ($group['attribs']['name'] == $groupname) {
$this->_packageInfo['dependencies']['group'][$i] = $this->_mergeTag (
$this->_packageInfo['dependencies']['group'][$i], $dep,
* @param optional|required
* @param string package name
* @param string package channel
* @param string minimum version
* @param string maximum version
* @param string recommended version
* @param string extension this package provides, if any
* @param bool if true, tells the installer to ignore the default optional dependency group
* when installing this package
* @param array|falseoptional excluded versions
$recommended = false , $exclude = false ,
$providesextension = false , $nodefault = false )
if (!in_array($type, array ('optional', 'required'), true )) {
$arr = array ('optional', 'group');
if ($type != 'required') {
$dep = $this->_constructDep ($name, $channel, false , $min, $max, $recommended, $exclude,
$providesextension, $nodefault);
$this->_packageInfo = $this->_mergeTag ($this->_packageInfo, $dep,
'dependencies' => array ('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
'package' => array ('subpackage', 'extension', 'os', 'arch')
* @param optional|required
* @param string name of the package
* @param string uri of the package
* @param string extension this package provides, if any
* @param bool if true, tells the installer to ignore the default optional dependency group
* when installing this package
$arr = array ('optional', 'group');
if ($type != 'required') {
$dep = $this->_constructDep ($name, false , $uri, false , false , false , false ,
$providesextension, $nodefault);
$this->_packageInfo = $this->_mergeTag ($this->_packageInfo, $dep,
'dependencies' => array ('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
'package' => array ('subpackage', 'extension', 'os', 'arch')
* @param optional|requiredoptional, required
* @param string package name
* @param string package channel
* @param string minimum version
* @param string maximum version
* @param string recommended version
* @param array incompatible versions
* @param bool if true, tells the installer to ignore the default optional dependency group
* when installing this package
$recommended = false , $exclude = false ,
$arr = array ('optional', 'group');
if ($type != 'required') {
$dep = $this->_constructDep ($name, $channel, false , $min, $max, $recommended, $exclude,
$this->_packageInfo = $this->_mergeTag ($this->_packageInfo, $dep,
'dependencies' => array ('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
'subpackage' => array ('extension', 'os', 'arch')
* @param optional|requiredoptional, required
* @param string package name
* @param string package uri for download
* @param bool if true, tells the installer to ignore the default optional dependency group
* when installing this package
$arr = array ('optional', 'group');
if ($type != 'required') {
$dep = $this->_constructDep ($name, false , $uri, false , false , false , false , $nodefault);
$this->_packageInfo = $this->_mergeTag ($this->_packageInfo, $dep,
'dependencies' => array ('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
'subpackage' => array ('extension', 'os', 'arch')
* @param optional|requiredoptional, required
* @param string extension name
* @param string minimum version
* @param string maximum version
* @param string recommended version
* @param array incompatible versions
function addExtensionDep($type, $name, $min = false , $max = false , $recommended = false ,
$arr = array ('optional', 'group');
if ($type != 'required') {
$dep = $this->_constructDep ($name, false , false , $min, $max, $recommended, $exclude);
$this->_packageInfo = $this->_mergeTag ($this->_packageInfo, $dep,
'dependencies' => array ('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
'extension' => array ('os', 'arch')
* @param string Operating system name
* @param boolean true if this package cannot be installed on this OS
function addOsDep($name, $conflicts = false )
$dep = array ('name' => $name);
$this->_packageInfo = $this->_mergeTag ($this->_packageInfo, $dep,
'dependencies' => array ('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
'required' => array ('optional', 'group'),
* @param string Architecture matching pattern
* @param boolean true if this package cannot be installed on this architecture
$dep = array ('pattern' => $pattern);
$this->_packageInfo = $this->_mergeTag ($this->_packageInfo, $dep,
'dependencies' => array ('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
'required' => array ('optional', 'group'),
* Set the kind of package, and erase all release tags
* - a php package is a PEAR-style package
* - an extbin package is a PECL-style extension binary
* - an extsrc package is a PECL-style source for a binary
* - an zendextbin package is a PECL-style zend extension binary
* - an zendextsrc package is a PECL-style source for a zend extension binary
* - a bundle package is a collection of other pre-packaged packages
* @param php|extbin|extsrc|zendextsrc|zendextbin|bundle
if (!in_array($type, array ('php', 'extbin', 'extsrc', 'zendextsrc',
'zendextbin', 'bundle'))) {
if (in_array($type, array ('zendextsrc', 'zendextbin'))) {
$this->_setPackageVersion2_1 ();
foreach (array ('phprelease', 'extbinrelease', 'extsrcrelease',
'zendextsrcrelease', 'zendextbinrelease', 'bundle') as $test) {
unset ($this->_packageInfo[$test]);
if (!isset ($this->_packageInfo[$type])) {
// ensure that the release tag is set up
$this->_packageInfo = $this->_insertBefore ($this->_packageInfo, array ('changelog'),
$this->_packageInfo[$type] = array ();
* @return bool true if package type is set up
$this->_packageInfo = $this->_mergeTag ($this->_packageInfo, array (),
array ($type => array ('changelog')));
* Get the current release tag in order to add to it
* @param bool returns only releases that have installcondition if true
function &_getCurrentRelease ($strict = true )
if ($p == 'extsrc' || $p == 'zendextsrc') {
if (isset ($this->_packageInfo[$p][0 ])) {
return $this->_packageInfo[$p][count($this->_packageInfo[$p]) - 1 ];
return $this->_packageInfo[$p];
* Add a file to the current release that should be installed under a different name
* @param string <contents> path to file
* @param string name the file should be installed as
$r = &$this->_getCurrentRelease ();
$r = $this->_mergeTag ($r, array ('attribs' => array ('name' => $path, 'as' => $as)),
'install' => array ('ignore')
* Add a file to the current release that should be ignored
* @param string <contents> path to file
* @return bool success of operation
$r = &$this->_getCurrentRelease ();
$r = $this->_mergeTag ($r, array ('attribs' => array ('name' => $path)),
* Add an extension binary package for this extension source code release
* Note that the package must be from the same channel as the extension source package
$r = &$this->_getCurrentRelease (false );
$r = $this->_mergeTag ($r, $package,
'binarypackage' => array ('filelist'),
* Add a configureoption to an extension source package
$r = &$this->_getCurrentRelease (false );
$opt = array ('attribs' => array ('name' => $name, 'prompt' => $prompt));
$opt['attribs']['default'] = $default;
$r = $this->_mergeTag ($r, $opt,
'configureoption' => array ('binarypackage', 'filelist'),
* Set an installation condition based on php version for the current release set
* @param string minimum version
* @param string maximum version
* @param false|arrayincompatible versions of PHP
$r = &$this->_getCurrentRelease ();
if (isset ($r['installconditions']['php'])) {
unset ($r['installconditions']['php']);
$dep = array ('min' => $min, 'max' => $max);
$dep['exclude'] = $exclude;
$r = $this->_mergeTag ($r, $dep,
'installconditions' => array ('configureoption', 'binarypackage',
'php' => array ('extension', 'os', 'arch')
$r = $this->_mergeTag ($r, $dep,
'installconditions' => array ('filelist'),
'php' => array ('extension', 'os', 'arch')
* @param optional|requiredoptional, required
* @param string extension name
* @param string minimum version
* @param string maximum version
* @param string recommended version
* @param array incompatible versions
$r = &$this->_getCurrentRelease ();
$dep = $this->_constructDep ($name, false , false , $min, $max, $recommended, $exclude);
$r = $this->_mergeTag ($r, $dep,
'installconditions' => array ('configureoption', 'binarypackage',
'extension' => array ('os', 'arch')
$r = $this->_mergeTag ($r, $dep,
'installconditions' => array ('filelist'),
'extension' => array ('os', 'arch')
* Set an installation condition based on operating system for the current release set
* @param bool whether this OS is incompatible with the current release
$r = &$this->_getCurrentRelease ();
if (isset ($r['installconditions']['os'])) {
unset ($r['installconditions']['os']);
$dep = array ('name' => $name);
$r = $this->_mergeTag ($r, $dep,
'installconditions' => array ('configureoption', 'binarypackage',
$r = $this->_mergeTag ($r, $dep,
'installconditions' => array ('filelist'),
* Set an installation condition based on architecture for the current release set
* @param string architecture pattern
* @param bool whether this arch is incompatible with the current release
$r = &$this->_getCurrentRelease ();
if (isset ($r['installconditions']['arch'])) {
unset ($r['installconditions']['arch']);
$dep = array ('pattern' => $pattern);
$r = $this->_mergeTag ($r, $dep,
'installconditions' => array ('configureoption', 'binarypackage',
$r = $this->_mergeTag ($r, $dep,
'installconditions' => array ('filelist'),
* For extension binary releases, this is used to specify either the
* static URI to a source package, or the package name and channel of the extsrc/zendextsrc
* package it is based on.
* @param string Package name, or full URI to source package (extsrc/zendextsrc type)
if (isset ($this->_packageInfo['channel'])) {
$this->_packageInfo = $this->_insertBefore ($this->_packageInfo, array ('phprelease',
'extsrcrelease', 'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease',
$packageOrUri, 'srcpackage');
$this->_packageInfo = $this->_insertBefore ($this->_packageInfo, array ('phprelease',
'extsrcrelease', 'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease',
'bundle', 'changelog'), $packageOrUri, 'srcuri');
* Generate a valid change log entry from the current package.xml
'notes' => $notes ? $notes : $this->getNotes()
* @param string release version to set change log notes for
* @param array output of {@link generateChangeLogEntry()}
if (!isset ($this->_packageInfo['changelog'])) {
$this->_packageInfo['changelog']['release'] = $contents;
if (!isset ($this->_packageInfo['changelog']['release'][0 ])) {
if ($this->_packageInfo['changelog']['release']['version']['release'] == $releaseversion) {
$this->_packageInfo['changelog']['release'] = array (
$this->_packageInfo['changelog']['release']);
$this->_packageInfo['changelog']['release'] = array (
$this->_packageInfo['changelog']['release']);
return $this->_packageInfo['changelog']['release'][] = $contents;
foreach($this->_packageInfo['changelog']['release'] as $index => $changelog) {
if (isset ($changelog['version']) &&
strnatcasecmp($changelog['version']['release'], $releaseversion) == 0 ) {
$this->_packageInfo['changelog']['release'][$curlog] = $contents;
$this->_packageInfo['changelog']['release'][] = $contents;
* Remove the changelog entirely
unset ($this->_packageInfo['changelog']);
Documentation generated on Wed, 06 Jul 2011 23:31:23 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.
|