cvs: pear-core /PEAR/PackageFile v2.php /PEAR/PackageFile/v2 Validator.php
| From: | Greg Beaver | Date: | Tue, 09 Nov 2004 05:06:04 +0000 |
| Subject: | cvs: pear-core /PEAR/PackageFile v2.php /PEAR/PackageFile/v2 Validator.php | ||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-core+get-1265@lists.php.net to get a copy of this message | ||
cellog Tue Nov 9 00:06:04 2004 EDT
Modified files:
/pear-core/PEAR/PackageFile v2.php
/pear-core/PEAR/PackageFile/v2 Validator.php
Log:
move <providesextension> and <srcpackage/channel> to top-level
instead of release-level.
add methods for manipulating installconditions
http://cvs.php.net/diff.php/pear-core/PEAR/PackageFile/v2.php?r1=1.48&r2=1.49&ty=u Index: pear-core/PEAR/PackageFile/v2.php diff -u pear-core/PEAR/PackageFile/v2.php:1.48 pear-core/PEAR/PackageFile/v2.php:1.49 --- pear-core/PEAR/PackageFile/v2.php:1.48 Mon Nov 8 23:22:53 2004 +++ pear-core/PEAR/PackageFile/v2.php Tue Nov 9 00:06:03 2004 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: v2.php,v 1.48 2004/11/09 04:22:53 cellog Exp $ +// $Id: v2.php,v 1.49 2004/11/09 05:06:03 cellog Exp $ require_once 'PEAR/ErrorStack.php'; require_once 'PEAR/Validate.php'; require_once 'PEAR/PackageFile/Generator/v2.php'; @@ -89,7 +89,7 @@ { if ($this->getPackageType() == 'extsrc') { foreach ($installer->getInstallPackages() as $p) { - if ($p->isExtension($this->_packageInfo['extsrcrelease']['providesextension'])) { + if ($p->isExtension($this->_packageInfo['providesextension'])) { if ($p->getPackage() != $this->getPackage() && $p->getChannel() != $this->getChannel()) { return false; // the user probably downloaded it separately @@ -98,7 +98,7 @@ } if (isset($this->_packageInfo['extsrcrelease']['binarypackage'])) { $installer->log(0, 'Attempting to download binary version of extension "' . - $this->_packageInfo['extsrcrelease']['providesextension'] . '"'); + $this->_packageInfo['providesextension'] . '"'); $params = $this->_packageInfo['extsrcrelease']['binarypackage']; if (!isset($params[0])) { $params = array($params); @@ -153,8 +153,7 @@ function setProvidesExtension($extension) { if (in_array($this->getPackageType(), array('extsrc', 'extbin'))) { - $this->_packageInfo[$this->getPackageType() . 'release'] - ['providesextension'] = $extension; + $this->_packageInfo['providesextension'] = $extension; return true; } return false; @@ -166,9 +165,8 @@ function getProvidesExtension() { if (in_array($this->getPackageType(), array('extsrc', 'extbin'))) { - if (isset($this->_packageInfo[$this->getPackageType() . 'release'] - ['providesextension'])) { - return $this->_packageInfo[$this->getPackageType() . 'release']['providesextension']; + if (isset($this->_packageInfo['providesextension'])) { + return $this->_packageInfo['providesextension']; } } return false; @@ -181,8 +179,7 @@ function isExtension($extension) { if (in_array($this->getPackageType(), array('extsrc', 'extbin'))) { - return $this->_packageInfo[$this->getPackageType() . 'release'] - ['providesextension'] == $extension; + return $this->_packageInfo['providesextension'] == $extension; } return false; } @@ -1900,7 +1897,6 @@ )); } - /** * @param optional|required optional, required * @param string extension name @@ -1967,6 +1963,9 @@ )); } + /** + * @return php|extsrc|extbin|bundle|false + */ function getPackageType() { if (isset($this->_packageInfo['phprelease'])) { @@ -1985,7 +1984,7 @@ } /** - * Set the kind of package + * 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 @@ -2004,9 +2003,7 @@ $type .= 'release'; } foreach (array('phprelease', 'extbinrelease', 'extsrcrelease', 'bundle') as $test) { - if ($type != $test) { - unset($this->_packageInfo[$test]); - } + unset($this->_packageInfo[$test]); } if (!isset($this->_packageInfo[$type])) { // ensure that the release tag is set up @@ -2016,6 +2013,145 @@ return true; } + /** + * @return bool true if package type is set up + */ + function addRelease() + { + if ($type = $this->getPackageType()) { + $this->_mergeTag($this->_packageInfo, array(), + array($this->getPackageType() => array('changelog'))); + return true; + } + return false; + } + + /** + * Get the current release tag in order to add to it + * @param bool returns only releases that have installcondition if true + * @return array|null + */ + function &_getCurrentRelease($strict = true) + { + if ($p = $this->getPackageType()) { + if ($strict) { + if ($p == 'extsrc' || $p == 'bundle') { + $a = null; + return $a; + } + } + $p .= 'release'; + if (isset($this->_packageInfo[$p][0])) { + return $this->_packageInfo[$p][count($this->_packageInfo[$p]) - 1]; + } else { + return $this->_packageInfo[$p]; + } + } else { + $a = null; + return $a; + } + } + + /** + * Set an installation condition based on php version for the current release set + * @param string minimum version + * @param string maximum version + * @param false|array incompatible versions of PHP + */ + function setPhpInstallCondition($min, $max, $exclude = false) + { + $r = &$this->_getCurrentRelease(); + if ($r === null) { + return false; + } + $this->_isValid = 0; + unset($r['installconditions']['php']); + $dep = array('min' => $min, 'max' => $max); + if ($exclude) { + if (is_array($exclude) && count($exclude) == 1) { + $exclude = $exclude[0]; + } + $dep['exclude'] = $exclude; + } + $this->_mergeTag($r['installconditions'], $dep, + array( + 'installconditions' => array('filelist'), + 'php' => array('extension', 'os', 'arch') + )); + } + + /** + * @param optional|required optional, required + * @param string extension name + * @param string minimum version + * @param string maximum version + * @param string recommended version + * @param array incompatible versions + */ + function addExtensionInstallCondition($name, $min = false, $max = false, $recommended = false, + $exclude = false) + { + $r = &$this->_getCurrentRelease(); + if ($r === null) { + return false; + } + $this->_isValid = 0; + $dep = $this->_constructDep($name, false, false, $min, $max, $recommended, $exclude); + $this->_mergeTag($r['installconditions'], $dep, + array( + 'installconditions' => array('filelist'), + 'extension' => array('os', 'arch') + )); + } + + /** + * Set an installation condition based on operating system for the current release set + * @param string OS name + * @param bool whether this OS is incompatible with the current release + */ + function setOsInstallCondition($name, $conflicts = false) + { + $r = &$this->_getCurrentRelease(); + if ($r === null) { + return false; + } + $this->_isValid = 0; + unset($r['installconditions']['os']); + $dep = array('name' => $name); + if ($conflicts) { + $dep['conflicts'] = 'yes'; + } + $this->_mergeTag($r['installconditions'], $dep, + array( + 'installconditions' => array('filelist'), + 'os' => array('arch') + )); + } + + /** + * 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 + */ + function setArchInstallCondition($pattern, $conflicts = false) + { + $r = &$this->_getCurrentRelease(); + if ($r === null) { + return false; + } + $this->_isValid = 0; + unset($r['installconditions']['arch']); + $dep = array('pattern' => $pattern); + if ($conflicts) { + $dep['conflicts'] = 'yes'; + } + $this->_mergeTag($r['installconditions'], $dep, + array( + 'installconditions' => array('filelist'), + 'arch' => array() + )); + } + function hasDeps() { return isset($this->_packageInfo['dependencies']); @@ -2029,8 +2165,8 @@ function getSourcePackage() { if (isset($this->_packageInfo['extbinrelease'])) { - return array('channel' => $this->_packageInfo['extbinrelease']['srcchannel'], - 'package' => $this->_packageInfo['extbinrelease']['srcpackage']); + return array('channel' => $this->_packageInfo['srcchannel'], + 'package' => $this->_packageInfo['srcpackage']); } return false; } http://cvs.php.net/diff.php/pear-core/PEAR/PackageFile/v2/Validator.php?r1=1.7&r2=1.8&ty=u Index: pear-core/PEAR/PackageFile/v2/Validator.php diff -u pear-core/PEAR/PackageFile/v2/Validator.php:1.7 pear-core/PEAR/PackageFile/v2/Validator.php:1.8 --- pear-core/PEAR/PackageFile/v2/Validator.php:1.7 Mon Nov 8 20:29:37 2004 +++ pear-core/PEAR/PackageFile/v2/Validator.php Tue Nov 9 00:06:04 2004 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: Validator.php,v 1.7 2004/11/09 01:29:37 cellog Exp $ +// $Id: Validator.php,v 1.8 2004/11/09 05:06:04 cellog Exp $ /** * Private validation class used by PEAR_PackageFile_v2 - do not use directly, its * sole purpose is to split up the PEAR/PackageFile/v2.php file to make it smaller @@ -82,6 +82,9 @@ 'contents', //special validation needed '*compatible', 'dependencies', //special validation needed + '*providesextension', + '*srcpackage', + '*srcchannel|*srcuri', '+phprelease|extsrcrelease|+extbinrelease|bundle' //special validation needed ); $test = $this->_packageInfo; @@ -853,9 +856,18 @@ { if (isset($this->_packageInfo['phprelease'])) { $release = 'phprelease'; + if (isset($this->_packageInfo['providesextension'])) { + $this->_cannotProvideExtension($release); + } + if (isset($this->_packageInfo['srcpackage'])) { + $this->_cannotHaveSrcpackage($release); + } } if (isset($this->_packageInfo['extsrcrelease'])) { $release = 'extsrcrelease'; + if (!isset($this->_packageInfo['providesextension'])) { + $this->_mustProvideExtension($release); + } if (isset($this->_packageInfo['extsrcrelease'][0])) { return $this->_extsrcCanOnlyHaveOneRelease(); } @@ -884,33 +896,23 @@ } if (isset($this->_packageInfo['extbinrelease'])) { $release = 'extbinrelease'; + if (!isset($this->_packageInfo['providesextension'])) { + $this->_mustProvideExtension($release); + } + if (!isset($this->_packageInfo['srcpackage'])) { + $this->_mustSrcPackage(); + } + if (!isset($this->_packageInfo['srcchannel']) && !isset($this->_packageInfo['srcuri'])) { + $this->_mustSrcChannelOrUri(); + } + if (isset($this->_packageInfo['srcchannel']) && isset($this->_packageInfo['srcuri'])) { + $this->_mustSrcChannelXorUri(); + } $r = $this->_packageInfo['extbinrelease']; if (!isset($r[0])) { $r = array($r); } foreach ($r as $rel) { - if (isset($rel['srcuri'])) { - if (isset($rel['srcpackage'])) { - return $this->_invalidTagOrder(array('providesextension'), 'srcpackage', - '<extbinrelease>'); - } - if (isset($rel['srcchannel'])) { - return $this->_invalidTagOrder(array('providesextension'), 'srcchannel', - '<extbinrelease>'); - } - } else { - if (!isset($rel['srcpackage'])) { - return $this->_invalidTagOrder(array('srcpackage', 'srcuri'), '', - '<extbinrelease>'); - } - if (!isset($rel['srcchannel'])) { - return $this->_invalidTagOrder(array('srcchannel'), '', - '<extbinrelease>'); - } - } - if (!isset($rel['providesextension'])) { - return $this->_invalidTagOrder(array('providesextension'), '', '<extbinrelease>'); - } if (!isset($rel['installconditions'])) { return $this->_invalidTagOrder(array('installconditions'), '', '<extbinrelease>'); } @@ -921,6 +923,12 @@ } if (isset($this->_packageInfo['bundle'])) { $release = 'bundle'; + if (isset($this->_packageInfo['providesextension'])) { + $this->_cannotProvideExtension($release); + } + if (isset($this->_packageInfo['srcpackage'])) { + $this->_cannotHaveSrcpackage($release); + } } if (is_array($this->_packageInfo[$release]) && isset($this->_packageInfo[$release][0])) { @@ -1138,6 +1146,42 @@ 'Only one <extsrcrelease> tag may exist in a package.xml'); } + function _cannotProvideExtension($release) + { + $this->_stack->push(__FUNCTION__, 'error', array('release' => $release), + '<%release%> packages cannot use <providesextension>, only extbinrelease and extsrcrelease can provide a PHP extension'); + } + + function _mustProvideExtension($release) + { + $this->_stack->push(__FUNCTION__, 'error', array('release' => $release), + '<%release%> packages must use <providesextension> to indicate which PHP extension is provided'); + } + + function _cannotHaveSrcpackage($release) + { + $this->_stack->push(__FUNCTION__, 'error', array('release' => $release), + '<%release%> packages cannot specify a source code package, only extension binaries may use the <srcpackage> tag'); + } + + function _mustSrcPackage() + { + $this->_stack->push(__FUNCTION__, 'error', array('release' => $release), + '<extbinrelease> packages must specify a source code package'); + } + + function _mustSrcChannelOrUri() + { + $this->_stack->push(__FUNCTION__, 'error', array('release' => $release), + '<srcpackage> must be accompanied by <srcchannel> or <srcuri>'); + } + + function _mustSrcChannelXorUri() + { + $this->_stack->push(__FUNCTION__, 'error', array('release' => $release), + '<srcpackage> must be accompanied by <srcchannel> or <srcuri>, and not both'); + } + function _analyzePhpFiles() { if (!$this->_isValid) {
http://cvs.php.net/diff.php/pear-core/PEAR/PackageFile/v2.php?r1=1.48&r2=1.49&ty=u Index: pear-core/PEAR/PackageFile/v2.php diff -u pear-core/PEAR/PackageFile/v2.php:1.48 pear-core/PEAR/PackageFile/v2.php:1.49 --- pear-core/PEAR/PackageFile/v2.php:1.48 Mon Nov 8 23:22:53 2004 +++ pear-core/PEAR/PackageFile/v2.php Tue Nov 9 00:06:03 2004 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: v2.php,v 1.48 2004/11/09 04:22:53 cellog Exp $ +// $Id: v2.php,v 1.49 2004/11/09 05:06:03 cellog Exp $ require_once 'PEAR/ErrorStack.php'; require_once 'PEAR/Validate.php'; require_once 'PEAR/PackageFile/Generator/v2.php'; @@ -89,7 +89,7 @@ { if ($this->getPackageType() == 'extsrc') { foreach ($installer->getInstallPackages() as $p) { - if ($p->isExtension($this->_packageInfo['extsrcrelease']['providesextension'])) { + if ($p->isExtension($this->_packageInfo['providesextension'])) { if ($p->getPackage() != $this->getPackage() && $p->getChannel() != $this->getChannel()) { return false; // the user probably downloaded it separately @@ -98,7 +98,7 @@ } if (isset($this->_packageInfo['extsrcrelease']['binarypackage'])) { $installer->log(0, 'Attempting to download binary version of extension "' . - $this->_packageInfo['extsrcrelease']['providesextension'] . '"'); + $this->_packageInfo['providesextension'] . '"'); $params = $this->_packageInfo['extsrcrelease']['binarypackage']; if (!isset($params[0])) { $params = array($params); @@ -153,8 +153,7 @@ function setProvidesExtension($extension) { if (in_array($this->getPackageType(), array('extsrc', 'extbin'))) { - $this->_packageInfo[$this->getPackageType() . 'release'] - ['providesextension'] = $extension; + $this->_packageInfo['providesextension'] = $extension; return true; } return false; @@ -166,9 +165,8 @@ function getProvidesExtension() { if (in_array($this->getPackageType(), array('extsrc', 'extbin'))) { - if (isset($this->_packageInfo[$this->getPackageType() . 'release'] - ['providesextension'])) { - return $this->_packageInfo[$this->getPackageType() . 'release']['providesextension']; + if (isset($this->_packageInfo['providesextension'])) { + return $this->_packageInfo['providesextension']; } } return false; @@ -181,8 +179,7 @@ function isExtension($extension) { if (in_array($this->getPackageType(), array('extsrc', 'extbin'))) { - return $this->_packageInfo[$this->getPackageType() . 'release'] - ['providesextension'] == $extension; + return $this->_packageInfo['providesextension'] == $extension; } return false; } @@ -1900,7 +1897,6 @@ )); } - /** * @param optional|required optional, required * @param string extension name @@ -1967,6 +1963,9 @@ )); } + /** + * @return php|extsrc|extbin|bundle|false + */ function getPackageType() { if (isset($this->_packageInfo['phprelease'])) { @@ -1985,7 +1984,7 @@ } /** - * Set the kind of package + * 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 @@ -2004,9 +2003,7 @@ $type .= 'release'; } foreach (array('phprelease', 'extbinrelease', 'extsrcrelease', 'bundle') as $test) { - if ($type != $test) { - unset($this->_packageInfo[$test]); - } + unset($this->_packageInfo[$test]); } if (!isset($this->_packageInfo[$type])) { // ensure that the release tag is set up @@ -2016,6 +2013,145 @@ return true; } + /** + * @return bool true if package type is set up + */ + function addRelease() + { + if ($type = $this->getPackageType()) { + $this->_mergeTag($this->_packageInfo, array(), + array($this->getPackageType() => array('changelog'))); + return true; + } + return false; + } + + /** + * Get the current release tag in order to add to it + * @param bool returns only releases that have installcondition if true + * @return array|null + */ + function &_getCurrentRelease($strict = true) + { + if ($p = $this->getPackageType()) { + if ($strict) { + if ($p == 'extsrc' || $p == 'bundle') { + $a = null; + return $a; + } + } + $p .= 'release'; + if (isset($this->_packageInfo[$p][0])) { + return $this->_packageInfo[$p][count($this->_packageInfo[$p]) - 1]; + } else { + return $this->_packageInfo[$p]; + } + } else { + $a = null; + return $a; + } + } + + /** + * Set an installation condition based on php version for the current release set + * @param string minimum version + * @param string maximum version + * @param false|array incompatible versions of PHP + */ + function setPhpInstallCondition($min, $max, $exclude = false) + { + $r = &$this->_getCurrentRelease(); + if ($r === null) { + return false; + } + $this->_isValid = 0; + unset($r['installconditions']['php']); + $dep = array('min' => $min, 'max' => $max); + if ($exclude) { + if (is_array($exclude) && count($exclude) == 1) { + $exclude = $exclude[0]; + } + $dep['exclude'] = $exclude; + } + $this->_mergeTag($r['installconditions'], $dep, + array( + 'installconditions' => array('filelist'), + 'php' => array('extension', 'os', 'arch') + )); + } + + /** + * @param optional|required optional, required + * @param string extension name + * @param string minimum version + * @param string maximum version + * @param string recommended version + * @param array incompatible versions + */ + function addExtensionInstallCondition($name, $min = false, $max = false, $recommended = false, + $exclude = false) + { + $r = &$this->_getCurrentRelease(); + if ($r === null) { + return false; + } + $this->_isValid = 0; + $dep = $this->_constructDep($name, false, false, $min, $max, $recommended, $exclude); + $this->_mergeTag($r['installconditions'], $dep, + array( + 'installconditions' => array('filelist'), + 'extension' => array('os', 'arch') + )); + } + + /** + * Set an installation condition based on operating system for the current release set + * @param string OS name + * @param bool whether this OS is incompatible with the current release + */ + function setOsInstallCondition($name, $conflicts = false) + { + $r = &$this->_getCurrentRelease(); + if ($r === null) { + return false; + } + $this->_isValid = 0; + unset($r['installconditions']['os']); + $dep = array('name' => $name); + if ($conflicts) { + $dep['conflicts'] = 'yes'; + } + $this->_mergeTag($r['installconditions'], $dep, + array( + 'installconditions' => array('filelist'), + 'os' => array('arch') + )); + } + + /** + * 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 + */ + function setArchInstallCondition($pattern, $conflicts = false) + { + $r = &$this->_getCurrentRelease(); + if ($r === null) { + return false; + } + $this->_isValid = 0; + unset($r['installconditions']['arch']); + $dep = array('pattern' => $pattern); + if ($conflicts) { + $dep['conflicts'] = 'yes'; + } + $this->_mergeTag($r['installconditions'], $dep, + array( + 'installconditions' => array('filelist'), + 'arch' => array() + )); + } + function hasDeps() { return isset($this->_packageInfo['dependencies']); @@ -2029,8 +2165,8 @@ function getSourcePackage() { if (isset($this->_packageInfo['extbinrelease'])) { - return array('channel' => $this->_packageInfo['extbinrelease']['srcchannel'], - 'package' => $this->_packageInfo['extbinrelease']['srcpackage']); + return array('channel' => $this->_packageInfo['srcchannel'], + 'package' => $this->_packageInfo['srcpackage']); } return false; } http://cvs.php.net/diff.php/pear-core/PEAR/PackageFile/v2/Validator.php?r1=1.7&r2=1.8&ty=u Index: pear-core/PEAR/PackageFile/v2/Validator.php diff -u pear-core/PEAR/PackageFile/v2/Validator.php:1.7 pear-core/PEAR/PackageFile/v2/Validator.php:1.8 --- pear-core/PEAR/PackageFile/v2/Validator.php:1.7 Mon Nov 8 20:29:37 2004 +++ pear-core/PEAR/PackageFile/v2/Validator.php Tue Nov 9 00:06:04 2004 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: Validator.php,v 1.7 2004/11/09 01:29:37 cellog Exp $ +// $Id: Validator.php,v 1.8 2004/11/09 05:06:04 cellog Exp $ /** * Private validation class used by PEAR_PackageFile_v2 - do not use directly, its * sole purpose is to split up the PEAR/PackageFile/v2.php file to make it smaller @@ -82,6 +82,9 @@ 'contents', //special validation needed '*compatible', 'dependencies', //special validation needed + '*providesextension', + '*srcpackage', + '*srcchannel|*srcuri', '+phprelease|extsrcrelease|+extbinrelease|bundle' //special validation needed ); $test = $this->_packageInfo; @@ -853,9 +856,18 @@ { if (isset($this->_packageInfo['phprelease'])) { $release = 'phprelease'; + if (isset($this->_packageInfo['providesextension'])) { + $this->_cannotProvideExtension($release); + } + if (isset($this->_packageInfo['srcpackage'])) { + $this->_cannotHaveSrcpackage($release); + } } if (isset($this->_packageInfo['extsrcrelease'])) { $release = 'extsrcrelease'; + if (!isset($this->_packageInfo['providesextension'])) { + $this->_mustProvideExtension($release); + } if (isset($this->_packageInfo['extsrcrelease'][0])) { return $this->_extsrcCanOnlyHaveOneRelease(); } @@ -884,33 +896,23 @@ } if (isset($this->_packageInfo['extbinrelease'])) { $release = 'extbinrelease'; + if (!isset($this->_packageInfo['providesextension'])) { + $this->_mustProvideExtension($release); + } + if (!isset($this->_packageInfo['srcpackage'])) { + $this->_mustSrcPackage(); + } + if (!isset($this->_packageInfo['srcchannel']) && !isset($this->_packageInfo['srcuri'])) { + $this->_mustSrcChannelOrUri(); + } + if (isset($this->_packageInfo['srcchannel']) && isset($this->_packageInfo['srcuri'])) { + $this->_mustSrcChannelXorUri(); + } $r = $this->_packageInfo['extbinrelease']; if (!isset($r[0])) { $r = array($r); } foreach ($r as $rel) { - if (isset($rel['srcuri'])) { - if (isset($rel['srcpackage'])) { - return $this->_invalidTagOrder(array('providesextension'), 'srcpackage', - '<extbinrelease>'); - } - if (isset($rel['srcchannel'])) { - return $this->_invalidTagOrder(array('providesextension'), 'srcchannel', - '<extbinrelease>'); - } - } else { - if (!isset($rel['srcpackage'])) { - return $this->_invalidTagOrder(array('srcpackage', 'srcuri'), '', - '<extbinrelease>'); - } - if (!isset($rel['srcchannel'])) { - return $this->_invalidTagOrder(array('srcchannel'), '', - '<extbinrelease>'); - } - } - if (!isset($rel['providesextension'])) { - return $this->_invalidTagOrder(array('providesextension'), '', '<extbinrelease>'); - } if (!isset($rel['installconditions'])) { return $this->_invalidTagOrder(array('installconditions'), '', '<extbinrelease>'); } @@ -921,6 +923,12 @@ } if (isset($this->_packageInfo['bundle'])) { $release = 'bundle'; + if (isset($this->_packageInfo['providesextension'])) { + $this->_cannotProvideExtension($release); + } + if (isset($this->_packageInfo['srcpackage'])) { + $this->_cannotHaveSrcpackage($release); + } } if (is_array($this->_packageInfo[$release]) && isset($this->_packageInfo[$release][0])) { @@ -1138,6 +1146,42 @@ 'Only one <extsrcrelease> tag may exist in a package.xml'); } + function _cannotProvideExtension($release) + { + $this->_stack->push(__FUNCTION__, 'error', array('release' => $release), + '<%release%> packages cannot use <providesextension>, only extbinrelease and extsrcrelease can provide a PHP extension'); + } + + function _mustProvideExtension($release) + { + $this->_stack->push(__FUNCTION__, 'error', array('release' => $release), + '<%release%> packages must use <providesextension> to indicate which PHP extension is provided'); + } + + function _cannotHaveSrcpackage($release) + { + $this->_stack->push(__FUNCTION__, 'error', array('release' => $release), + '<%release%> packages cannot specify a source code package, only extension binaries may use the <srcpackage> tag'); + } + + function _mustSrcPackage() + { + $this->_stack->push(__FUNCTION__, 'error', array('release' => $release), + '<extbinrelease> packages must specify a source code package'); + } + + function _mustSrcChannelOrUri() + { + $this->_stack->push(__FUNCTION__, 'error', array('release' => $release), + '<srcpackage> must be accompanied by <srcchannel> or <srcuri>'); + } + + function _mustSrcChannelXorUri() + { + $this->_stack->push(__FUNCTION__, 'error', array('release' => $release), + '<srcpackage> must be accompanied by <srcchannel> or <srcuri>, and not both'); + } + function _analyzePhpFiles() { if (!$this->_isValid) {