cvs: pear-core /PEAR Validate.php /PEAR/PackageFile v1.php v2.php
| From: | Greg Beaver | Date: | Fri, 10 Sep 2004 21:56:43 +0000 |
| Subject: | cvs: pear-core /PEAR Validate.php /PEAR/PackageFile v1.php v2.php | ||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-cvs+get-23810@lists.php.net to get a copy of this message | ||
cellog Fri Sep 10 17:56:43 2004 EDT
Modified files:
/pear-core/PEAR/PackageFile v1.php v2.php
/pear-core/PEAR Validate.php
Log:
complete validation skeleton
http://cvs.php.net/diff.php/pear-core/PEAR/PackageFile/v1.php?r1=1.5&r2=1.6&ty=u Index: pear-core/PEAR/PackageFile/v1.php diff -u pear-core/PEAR/PackageFile/v1.php:1.5 pear-core/PEAR/PackageFile/v1.php:1.6 --- pear-core/PEAR/PackageFile/v1.php:1.5 Fri Sep 10 16:35:25 2004 +++ pear-core/PEAR/PackageFile/v1.php Fri Sep 10 17:56:43 2004 @@ -544,42 +544,22 @@ function _getErrorMessage() { return array( - PEAR_PACKAGEFILE_ERROR_INVALID_PACKAGEVERSION => - 'While parsing package.xml, an invalid <package> version number "%version% was passed in, expecting one of %versions%', - PEAR_PACKAGEFILE_ERROR_NO_PACKAGEVERSION => - 'No version number found in <package> tag', - PEAR_PACKAGEFILE_ERROR_NO_XML_EXT => - '%error%', - PEAR_PACKAGEFILE_ERROR_CANT_MAKE_PARSER => - 'Unable to create XML parser', - PEAR_PACKAGEFILE_ERROR_PARSER_ERROR => - '%error%', PEAR_PACKAGEFILE_ERROR_NO_NAME => 'Missing Package Name', - PEAR_PACKAGEFILE_ERROR_INVALID_NAME => - 'Invalid Package Name "%name%"', PEAR_PACKAGEFILE_ERROR_NO_SUMMARY => 'No summary found', - PEAR_PACKAGEFILE_ERROR_UNKNOWN_CHANNEL => - 'Unknown channel, "%channel%"', PEAR_PACKAGEFILE_ERROR_MULTILINE_SUMMARY => 'Summary should be on one line', PEAR_PACKAGEFILE_ERROR_NO_DESCRIPTION => 'Missing description', PEAR_PACKAGEFILE_ERROR_NO_LICENSE => 'Missing license', - PEAR_PACKAGEFILE_ERROR_INVALID_VERSION => - 'Invalid <version> version "%version%"', PEAR_PACKAGEFILE_ERROR_NO_VERSION => - 'No <version> version found', + 'No release version found', PEAR_PACKAGEFILE_ERROR_NO_STATE => - 'No state found', - PEAR_PACKAGEFILE_ERROR_INVALID_STATE => - 'Invalid state "%state%", expecting one of "%states%"', + 'No release state found', PEAR_PACKAGEFILE_ERROR_NO_DATE => 'No release date found', - PEAR_PACKAGEFILE_ERROR_INVALID_DATE => - 'Invalid release date "%date%", format is YYYY-MM-DD', PEAR_PACKAGEFILE_ERROR_NO_NOTES => 'No release notes found', PEAR_PACKAGEFILE_ERROR_NO_MAINTAINERS => @@ -587,35 +567,21 @@ PEAR_PACKAGEFILE_ERROR_NO_MAINTHANDLE => 'Maintainer %index% has no handle (user ID at channel server)', PEAR_PACKAGEFILE_ERROR_NO_MAINTROLE => - 'Maintainer %index% has no role, must be one of %roles%', + 'Maintainer %index% has no role', PEAR_PACKAGEFILE_ERROR_NO_MAINTNAME => 'Maintainer %index% has no name', PEAR_PACKAGEFILE_ERROR_NO_MAINTEMAIL => 'Maintainer %index% has no email', - PEAR_PACKAGEFILE_ERROR_INVALID_MAINTROLE => - 'Maintainer %index% has invalid role "%role%", must be one of %roles%', PEAR_PACKAGEFILE_ERROR_NO_DEPNAME => 'Dependency %index% is not a php dependency, and has no name', PEAR_PACKAGEFILE_ERROR_NO_DEPREL => - 'Dependency %index% has no relation, expecting one of %rels%', + 'Dependency %index% has no relation', PEAR_PACKAGEFILE_ERROR_NO_DEPTYPE => - 'Dependency %index% has no type, expecting one of %types%', + 'Dependency %index% has no type', PEAR_PACKAGEFILE_ERROR_NO_DEPVERSION => 'Dependency %index% is not a rel="has" dependency, and has no version', - PEAR_PACKAGEFILE_ERROR_INVALID_DEPREL => - 'Dependency %index% has invalid relation "%rel%", expecting one of %rels%', - PEAR_PACKAGEFILE_ERROR_INVALID_DEPTYPE => - 'Dependency %index% has invalid type "%type%", expecting one of %types%', - PEAR_PACKAGEFILE_ERROR_INVALID_DEPNAME => - 'Dependency %index% has a package dependency with invalid package name "%name%"', PEAR_PACKAGEFILE_ERROR_INVALID_DEPOPTIONAL => 'Dependency %index% has invalid optional value "%opt%", should be yes or no', - PEAR_PACKAGEFILE_ERROR_UNKNOWN_DEPCHANNEL => - 'Dependency %index% requires unknown channel "%channel%"', - PEAR_PACKAGEFILE_ERROR_DEPNAME_IGNORED => - 'Dependency %index% is type="php", name "%name%" will be ignored', - PEAR_PACKAGEFILE_ERROR_DEPVERSION_IGNORED => - 'Dependency %index% is rel="has", version "%version%" will be ignored', PEAR_PACKAGEFILE_ERROR_NO_CONFNAME => 'Configure Option %index% has no name', PEAR_PACKAGEFILE_ERROR_NO_CONFPROMPT => @@ -624,8 +590,6 @@ 'No files in <filelist> section of package.xml', PEAR_PACKAGEFILE_ERROR_NO_FILEROLE => 'File "%file%" has no role, expecting one of "%roles%"', - PEAR_PACKAGEFILE_ERROR_INVALID_FILEROLE => - 'File "%file%" has invalid role "%role%", expecting one of "%roles%"', PEAR_PACKAGEFILE_ERROR_INVALID_PHPFILE => 'Parser error: Invalid PHP file "%file%"', PEAR_PACKAGEFILE_ERROR_NO_PNAME_PREFIX => @@ -659,22 +623,12 @@ } if (empty($info['version'])) { $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_VERSION); - } elseif (!PEAR_Common::validPackageVersion($info['version'])) { - $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_VERSION, - array('version' => $info['version'])); } if (empty($info['release_state'])) { $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_STATE); - } elseif (!in_array($info['release_state'], PEAR_Common::getReleaseStates())) { - $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_STATE, - array('state' => $info['release_state'], - 'states' => PEAR_Common::getReleaseStates())); } if (empty($info['release_date'])) { $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DATE); - } elseif (!preg_match('/^\d{4}-\d\d-\d\d$/', $info['release_date'])) { - $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_DATE, - array('date' => $info['release_date'])); } if (empty($info['release_notes'])) { $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_NOTES); @@ -691,10 +645,6 @@ if (empty($m['role'])) { $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_MAINTROLE, array('index' => $i, 'roles' => PEAR_Common::getUserRoles())); - } elseif (!in_array($m['role'], PEAR_Common::getUserRoles())) { - $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_MAINTROLE, - array('index' => $i, 'role' => $m['role'], 'roles' => - PEAR_Common::getUserRoles())); } if (empty($m['name'])) { $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_MAINTNAME, @@ -713,18 +663,10 @@ if (empty($d['type'])) { $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPTYPE, array('index' => $i, 'types' => PEAR_Common::getDependencyTypes())); - } elseif (!in_array($d['type'], PEAR_Common::getDependencyTypes())) { - $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_DEPTYPE, - array('index' => $i, 'types' => PEAR_Common::getDependencyTypes(), - 'type' => $d['type'])); } if (empty($d['rel'])) { $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPREL, array('index' => $i, 'rels' => PEAR_Common::getDependencyRelations())); - } elseif (!in_array($d['rel'], PEAR_Common::getDependencyRelations())) { - $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_DEPREL, - array('index' => $i, 'types' => PEAR_Common::getDependencyRelations(), - 'type' => $d['rel'])); } if (!empty($d['optional'])) { if (!in_array($d['optional'], array('yes', 'no'))) { @@ -745,38 +687,6 @@ } elseif ($d['type'] != 'php' && empty($d['name'])) { $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPNAME, array('index' => $i)); - } - if (isset($this->_registry)) { - if (isset($d['channel'])) { - if (!$this->_registry->channelExists($d['channel'])) { - $this->_validateError(PEAR_PACKAGEFILE_ERROR_UNKNOWN_DEPCHANNEL, - array('index' => $i, 'channel' => $d['channel'])); - } else { - if ($d['type'] == 'pkg' && !empty($d['name'])) { - $channel = $this->_registry->getChannel($d['channel']); - if ($channel) { - if (!$channel->validPackageName($d['name'])) { - $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_DEPNAME, - array('index' => $i, 'name' => $d['name'])); - } - } - } - } - } else { - if ($d['type'] == 'pkg' && !empty($d['name'])) { - if (!PEAR_Common::validPackageName($d['name'])) { - $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_DEPNAME, - array('index' => $i, 'name' => $d['name'])); - } - } - } - } else { - if ($d['type'] == 'pkg' && !empty($d['name'])) { - if (!PEAR_Common::validPackageName($d['name'])) { - $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_DEPNAME, - array('index' => $i, 'name' => $d['name'])); - } - } } $i++; } http://cvs.php.net/diff.php/pear-core/PEAR/PackageFile/v2.php?r1=1.3&r2=1.4&ty=u Index: pear-core/PEAR/PackageFile/v2.php diff -u pear-core/PEAR/PackageFile/v2.php:1.3 pear-core/PEAR/PackageFile/v2.php:1.4 --- pear-core/PEAR/PackageFile/v2.php:1.3 Fri Sep 10 16:21:42 2004 +++ pear-core/PEAR/PackageFile/v2.php Fri Sep 10 17:56:43 2004 @@ -120,7 +120,7 @@ if (isset($this->_packageInfo['name']['attribs']['channel'])) { return $this->_packageInfo['name']['attribs']['channel']; } - return 'pear'; + return false; } function getName() @@ -135,6 +135,14 @@ } return false; } + + function getExtends() + { + if (isset($this->_packageInfo['extends']['_content'])) { + return $this->_packageInfo['extends']['_content']; + } + return false; + } /** * @param package|api version category to return @@ -354,6 +362,7 @@ $structure = array( 'name->channel', + 'extends?', 'summary', 'description', '+lead->user->email->name->active', http://cvs.php.net/diff.php/pear-core/PEAR/Validate.php?r1=1.11&r2=1.12&ty=u Index: pear-core/PEAR/Validate.php diff -u pear-core/PEAR/Validate.php:1.11 pear-core/PEAR/Validate.php:1.12 --- pear-core/PEAR/Validate.php:1.11 Fri Sep 10 16:37:51 2004 +++ pear-core/PEAR/Validate.php Fri Sep 10 17:56:43 2004 @@ -16,7 +16,7 @@ // | Authors: Gregory Beaver <cellog@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Validate.php,v 1.11 2004/09/10 20:37:51 cellog Exp $ +// $Id: Validate.php,v 1.12 2004/09/10 21:56:43 cellog Exp $ define('PEAR_VALIDATE_INSTALLING', 1); define('PEAR_VALIDATE_NORMAL', 3); define('PEAR_VALIDATE_PACKAGING', 7); @@ -38,6 +38,18 @@ */ var $_validStates = array('alpha','beta','stable','snapshot','devel'); /** + * Valid file installation roles + * @var array + * @access private + */ + var $_validInstallRoles = array('php','ext','test','doc','data','src','script'); + /** + * Valid dependency relations + * @var array + * @access private + */ + var $_validDepRelations = array('has','eq','lt','le','gt','ge','not'); + /** * Format: ('error' => array('field' => name, 'reason' => reason), 'warning' => same) * @var array * @access private @@ -59,16 +71,42 @@ return (bool)preg_match('/^' . $this->packageregex . '$/', $name); } + function validState($state) + { + return in_array($state, $this->_validStates); + } + + function getValidStates() + { + return $this->_validStates; + } + + function validInstallRole($role) + { + return in_array($role, $this->_validInstallRoles); + } + + function validDepRelation($rel) + { + return in_array($rel, $this->_validDepRelations); + } + function setPackageFile(&$pf) { $this->_packagexml = &$pf; } + /** + * @access private + */ function _addFailure($field, $reason) { $this->_failures['error'] = array('field' => $field, 'reason' => $reason); } + /** + * @access private + */ function _addWarning($field, $reason) { $this->_failures['warning'] = array('field' => $field, 'reason' => $reason); @@ -89,14 +127,28 @@ $this->validateVersion(); $this->validateMaintainers(); $this->validateDate(); + $this->validateSummary(); + $this->validateDescription(); + $this->validateLicense(); + $this->validateNotes(); if ($this->_packagexml->getPackagexmlVersion() == '1.0') { $this->validateState(); + $this->validateFilelist(); } elseif ($this->_packagexml->getPackagexmlVersion() == '2.0') { $this->validateTime(); $this->validateStability(); + $this->validateDeps(); + $this->validateMainFilelist(); + $this->validateReleaseFilelist(); + $this->validateBundles(); + $this->validateGlobalTasks(); + $this->validateChangelog(); } } + /** + * @access protected + */ function validatePackageName() { if ($this->_state == PEAR_VALIDATE_PACKAGING || @@ -120,6 +172,9 @@ } } + /** + * @access protected + */ function validateVersion() { if ($this->_state != PEAR_VALIDATE_PACKAGING) { @@ -211,6 +266,9 @@ } } + /** + * @access protected + */ function validateMaintainers() { // maintainers can only be truly validated server-side for most channels @@ -218,6 +276,9 @@ return true; } + /** + * @access protected + */ function validateDate() { // packager automatically sets date, so only validate if @@ -238,6 +299,9 @@ return true; } + /** + * @access protected + */ function validateTime() { if (!$this->_packagexml->getTime()) { @@ -262,35 +326,118 @@ return true; } + /** + * @access protected + */ function validateState() { - if (!in_array($this->_packagexml->getState(), $this->_validStates)) { + // this is the closest to "final" php4 can get + if (!PEAR_Validate::validState($this->_packagexml->getState())) { $this->_addFailure('state', 'release state "' . $this->_packagexml->getState() . '" is not valid, must be one of: ' . - implode(', ', $this->_validStates)); + implode(', ', PEAR_Validate::getValidStates())); return false; } return true; } + /** + * @access protected + */ function validateStability() { $ret = true; $packagestability = $this->_packagexml->getState(); $apistability = $this->_packagexml->getState('api'); - if (!in_array($packagestability, $this->_validStates)) { + if (!PEAR_Validate::validState($packagestability)) { $this->_addFailure('state', 'package stability "' . $this->_packagexml->getState() . '" is not valid, must be one of: ' . - implode(', ', $this->_validStates)); + implode(', ', PEAR_Validate::getValidStates())); $ret = false; } - if (!in_array($apistability, $this->_validStates)) { + if (!PEAR_Validate::validState($apistability)) { $this->_addFailure('state', 'API stability "' . $this->_packagexml->getState() . '" is not valid, must be one of: ' . - implode(', ', $this->_validStates)); + implode(', ', PEAR_Validate::getValidStates())); $ret = false; } return $ret; + } + + /** + * @access protected + */ + function validateSummary() + { + return true; + } + + /** + * @access protected + */ + function validateDescription() + { + return true; + } + + /** + * @access protected + */ + function validateLicense() + { + return true; + } + + /** + * @access protected + */ + function validateNotes() + { + return true; + } + + /** + * for package.xml 2.0 only - channels can't use package.xml 1.0 + * @access protected + */ + function validateDependencies() + { + return true; + } + + /** + * for package.xml 1.0 only + * @access private + */ + function _validateFilelist() + { + return true; // placeholder for now + } + + /** + * for package.xml 2.0 only + * @access protected + */ + function validateMainFilelist() + { + return true; // placeholder for now + } + + /** + * for package.xml 2.0 only + * @access protected + */ + function validateReleaseFilelist() + { + return true; // placeholder for now + } + + /** + * @access protected + */ + function validateChangelog() + { + return true; } } ?>
http://cvs.php.net/diff.php/pear-core/PEAR/PackageFile/v1.php?r1=1.5&r2=1.6&ty=u Index: pear-core/PEAR/PackageFile/v1.php diff -u pear-core/PEAR/PackageFile/v1.php:1.5 pear-core/PEAR/PackageFile/v1.php:1.6 --- pear-core/PEAR/PackageFile/v1.php:1.5 Fri Sep 10 16:35:25 2004 +++ pear-core/PEAR/PackageFile/v1.php Fri Sep 10 17:56:43 2004 @@ -544,42 +544,22 @@ function _getErrorMessage() { return array( - PEAR_PACKAGEFILE_ERROR_INVALID_PACKAGEVERSION => - 'While parsing package.xml, an invalid <package> version number "%version% was passed in, expecting one of %versions%', - PEAR_PACKAGEFILE_ERROR_NO_PACKAGEVERSION => - 'No version number found in <package> tag', - PEAR_PACKAGEFILE_ERROR_NO_XML_EXT => - '%error%', - PEAR_PACKAGEFILE_ERROR_CANT_MAKE_PARSER => - 'Unable to create XML parser', - PEAR_PACKAGEFILE_ERROR_PARSER_ERROR => - '%error%', PEAR_PACKAGEFILE_ERROR_NO_NAME => 'Missing Package Name', - PEAR_PACKAGEFILE_ERROR_INVALID_NAME => - 'Invalid Package Name "%name%"', PEAR_PACKAGEFILE_ERROR_NO_SUMMARY => 'No summary found', - PEAR_PACKAGEFILE_ERROR_UNKNOWN_CHANNEL => - 'Unknown channel, "%channel%"', PEAR_PACKAGEFILE_ERROR_MULTILINE_SUMMARY => 'Summary should be on one line', PEAR_PACKAGEFILE_ERROR_NO_DESCRIPTION => 'Missing description', PEAR_PACKAGEFILE_ERROR_NO_LICENSE => 'Missing license', - PEAR_PACKAGEFILE_ERROR_INVALID_VERSION => - 'Invalid <version> version "%version%"', PEAR_PACKAGEFILE_ERROR_NO_VERSION => - 'No <version> version found', + 'No release version found', PEAR_PACKAGEFILE_ERROR_NO_STATE => - 'No state found', - PEAR_PACKAGEFILE_ERROR_INVALID_STATE => - 'Invalid state "%state%", expecting one of "%states%"', + 'No release state found', PEAR_PACKAGEFILE_ERROR_NO_DATE => 'No release date found', - PEAR_PACKAGEFILE_ERROR_INVALID_DATE => - 'Invalid release date "%date%", format is YYYY-MM-DD', PEAR_PACKAGEFILE_ERROR_NO_NOTES => 'No release notes found', PEAR_PACKAGEFILE_ERROR_NO_MAINTAINERS => @@ -587,35 +567,21 @@ PEAR_PACKAGEFILE_ERROR_NO_MAINTHANDLE => 'Maintainer %index% has no handle (user ID at channel server)', PEAR_PACKAGEFILE_ERROR_NO_MAINTROLE => - 'Maintainer %index% has no role, must be one of %roles%', + 'Maintainer %index% has no role', PEAR_PACKAGEFILE_ERROR_NO_MAINTNAME => 'Maintainer %index% has no name', PEAR_PACKAGEFILE_ERROR_NO_MAINTEMAIL => 'Maintainer %index% has no email', - PEAR_PACKAGEFILE_ERROR_INVALID_MAINTROLE => - 'Maintainer %index% has invalid role "%role%", must be one of %roles%', PEAR_PACKAGEFILE_ERROR_NO_DEPNAME => 'Dependency %index% is not a php dependency, and has no name', PEAR_PACKAGEFILE_ERROR_NO_DEPREL => - 'Dependency %index% has no relation, expecting one of %rels%', + 'Dependency %index% has no relation', PEAR_PACKAGEFILE_ERROR_NO_DEPTYPE => - 'Dependency %index% has no type, expecting one of %types%', + 'Dependency %index% has no type', PEAR_PACKAGEFILE_ERROR_NO_DEPVERSION => 'Dependency %index% is not a rel="has" dependency, and has no version', - PEAR_PACKAGEFILE_ERROR_INVALID_DEPREL => - 'Dependency %index% has invalid relation "%rel%", expecting one of %rels%', - PEAR_PACKAGEFILE_ERROR_INVALID_DEPTYPE => - 'Dependency %index% has invalid type "%type%", expecting one of %types%', - PEAR_PACKAGEFILE_ERROR_INVALID_DEPNAME => - 'Dependency %index% has a package dependency with invalid package name "%name%"', PEAR_PACKAGEFILE_ERROR_INVALID_DEPOPTIONAL => 'Dependency %index% has invalid optional value "%opt%", should be yes or no', - PEAR_PACKAGEFILE_ERROR_UNKNOWN_DEPCHANNEL => - 'Dependency %index% requires unknown channel "%channel%"', - PEAR_PACKAGEFILE_ERROR_DEPNAME_IGNORED => - 'Dependency %index% is type="php", name "%name%" will be ignored', - PEAR_PACKAGEFILE_ERROR_DEPVERSION_IGNORED => - 'Dependency %index% is rel="has", version "%version%" will be ignored', PEAR_PACKAGEFILE_ERROR_NO_CONFNAME => 'Configure Option %index% has no name', PEAR_PACKAGEFILE_ERROR_NO_CONFPROMPT => @@ -624,8 +590,6 @@ 'No files in <filelist> section of package.xml', PEAR_PACKAGEFILE_ERROR_NO_FILEROLE => 'File "%file%" has no role, expecting one of "%roles%"', - PEAR_PACKAGEFILE_ERROR_INVALID_FILEROLE => - 'File "%file%" has invalid role "%role%", expecting one of "%roles%"', PEAR_PACKAGEFILE_ERROR_INVALID_PHPFILE => 'Parser error: Invalid PHP file "%file%"', PEAR_PACKAGEFILE_ERROR_NO_PNAME_PREFIX => @@ -659,22 +623,12 @@ } if (empty($info['version'])) { $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_VERSION); - } elseif (!PEAR_Common::validPackageVersion($info['version'])) { - $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_VERSION, - array('version' => $info['version'])); } if (empty($info['release_state'])) { $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_STATE); - } elseif (!in_array($info['release_state'], PEAR_Common::getReleaseStates())) { - $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_STATE, - array('state' => $info['release_state'], - 'states' => PEAR_Common::getReleaseStates())); } if (empty($info['release_date'])) { $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DATE); - } elseif (!preg_match('/^\d{4}-\d\d-\d\d$/', $info['release_date'])) { - $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_DATE, - array('date' => $info['release_date'])); } if (empty($info['release_notes'])) { $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_NOTES); @@ -691,10 +645,6 @@ if (empty($m['role'])) { $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_MAINTROLE, array('index' => $i, 'roles' => PEAR_Common::getUserRoles())); - } elseif (!in_array($m['role'], PEAR_Common::getUserRoles())) { - $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_MAINTROLE, - array('index' => $i, 'role' => $m['role'], 'roles' => - PEAR_Common::getUserRoles())); } if (empty($m['name'])) { $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_MAINTNAME, @@ -713,18 +663,10 @@ if (empty($d['type'])) { $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPTYPE, array('index' => $i, 'types' => PEAR_Common::getDependencyTypes())); - } elseif (!in_array($d['type'], PEAR_Common::getDependencyTypes())) { - $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_DEPTYPE, - array('index' => $i, 'types' => PEAR_Common::getDependencyTypes(), - 'type' => $d['type'])); } if (empty($d['rel'])) { $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPREL, array('index' => $i, 'rels' => PEAR_Common::getDependencyRelations())); - } elseif (!in_array($d['rel'], PEAR_Common::getDependencyRelations())) { - $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_DEPREL, - array('index' => $i, 'types' => PEAR_Common::getDependencyRelations(), - 'type' => $d['rel'])); } if (!empty($d['optional'])) { if (!in_array($d['optional'], array('yes', 'no'))) { @@ -745,38 +687,6 @@ } elseif ($d['type'] != 'php' && empty($d['name'])) { $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPNAME, array('index' => $i)); - } - if (isset($this->_registry)) { - if (isset($d['channel'])) { - if (!$this->_registry->channelExists($d['channel'])) { - $this->_validateError(PEAR_PACKAGEFILE_ERROR_UNKNOWN_DEPCHANNEL, - array('index' => $i, 'channel' => $d['channel'])); - } else { - if ($d['type'] == 'pkg' && !empty($d['name'])) { - $channel = $this->_registry->getChannel($d['channel']); - if ($channel) { - if (!$channel->validPackageName($d['name'])) { - $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_DEPNAME, - array('index' => $i, 'name' => $d['name'])); - } - } - } - } - } else { - if ($d['type'] == 'pkg' && !empty($d['name'])) { - if (!PEAR_Common::validPackageName($d['name'])) { - $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_DEPNAME, - array('index' => $i, 'name' => $d['name'])); - } - } - } - } else { - if ($d['type'] == 'pkg' && !empty($d['name'])) { - if (!PEAR_Common::validPackageName($d['name'])) { - $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_DEPNAME, - array('index' => $i, 'name' => $d['name'])); - } - } } $i++; } http://cvs.php.net/diff.php/pear-core/PEAR/PackageFile/v2.php?r1=1.3&r2=1.4&ty=u Index: pear-core/PEAR/PackageFile/v2.php diff -u pear-core/PEAR/PackageFile/v2.php:1.3 pear-core/PEAR/PackageFile/v2.php:1.4 --- pear-core/PEAR/PackageFile/v2.php:1.3 Fri Sep 10 16:21:42 2004 +++ pear-core/PEAR/PackageFile/v2.php Fri Sep 10 17:56:43 2004 @@ -120,7 +120,7 @@ if (isset($this->_packageInfo['name']['attribs']['channel'])) { return $this->_packageInfo['name']['attribs']['channel']; } - return 'pear'; + return false; } function getName() @@ -135,6 +135,14 @@ } return false; } + + function getExtends() + { + if (isset($this->_packageInfo['extends']['_content'])) { + return $this->_packageInfo['extends']['_content']; + } + return false; + } /** * @param package|api version category to return @@ -354,6 +362,7 @@ $structure = array( 'name->channel', + 'extends?', 'summary', 'description', '+lead->user->email->name->active', http://cvs.php.net/diff.php/pear-core/PEAR/Validate.php?r1=1.11&r2=1.12&ty=u Index: pear-core/PEAR/Validate.php diff -u pear-core/PEAR/Validate.php:1.11 pear-core/PEAR/Validate.php:1.12 --- pear-core/PEAR/Validate.php:1.11 Fri Sep 10 16:37:51 2004 +++ pear-core/PEAR/Validate.php Fri Sep 10 17:56:43 2004 @@ -16,7 +16,7 @@ // | Authors: Gregory Beaver <cellog@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Validate.php,v 1.11 2004/09/10 20:37:51 cellog Exp $ +// $Id: Validate.php,v 1.12 2004/09/10 21:56:43 cellog Exp $ define('PEAR_VALIDATE_INSTALLING', 1); define('PEAR_VALIDATE_NORMAL', 3); define('PEAR_VALIDATE_PACKAGING', 7); @@ -38,6 +38,18 @@ */ var $_validStates = array('alpha','beta','stable','snapshot','devel'); /** + * Valid file installation roles + * @var array + * @access private + */ + var $_validInstallRoles = array('php','ext','test','doc','data','src','script'); + /** + * Valid dependency relations + * @var array + * @access private + */ + var $_validDepRelations = array('has','eq','lt','le','gt','ge','not'); + /** * Format: ('error' => array('field' => name, 'reason' => reason), 'warning' => same) * @var array * @access private @@ -59,16 +71,42 @@ return (bool)preg_match('/^' . $this->packageregex . '$/', $name); } + function validState($state) + { + return in_array($state, $this->_validStates); + } + + function getValidStates() + { + return $this->_validStates; + } + + function validInstallRole($role) + { + return in_array($role, $this->_validInstallRoles); + } + + function validDepRelation($rel) + { + return in_array($rel, $this->_validDepRelations); + } + function setPackageFile(&$pf) { $this->_packagexml = &$pf; } + /** + * @access private + */ function _addFailure($field, $reason) { $this->_failures['error'] = array('field' => $field, 'reason' => $reason); } + /** + * @access private + */ function _addWarning($field, $reason) { $this->_failures['warning'] = array('field' => $field, 'reason' => $reason); @@ -89,14 +127,28 @@ $this->validateVersion(); $this->validateMaintainers(); $this->validateDate(); + $this->validateSummary(); + $this->validateDescription(); + $this->validateLicense(); + $this->validateNotes(); if ($this->_packagexml->getPackagexmlVersion() == '1.0') { $this->validateState(); + $this->validateFilelist(); } elseif ($this->_packagexml->getPackagexmlVersion() == '2.0') { $this->validateTime(); $this->validateStability(); + $this->validateDeps(); + $this->validateMainFilelist(); + $this->validateReleaseFilelist(); + $this->validateBundles(); + $this->validateGlobalTasks(); + $this->validateChangelog(); } } + /** + * @access protected + */ function validatePackageName() { if ($this->_state == PEAR_VALIDATE_PACKAGING || @@ -120,6 +172,9 @@ } } + /** + * @access protected + */ function validateVersion() { if ($this->_state != PEAR_VALIDATE_PACKAGING) { @@ -211,6 +266,9 @@ } } + /** + * @access protected + */ function validateMaintainers() { // maintainers can only be truly validated server-side for most channels @@ -218,6 +276,9 @@ return true; } + /** + * @access protected + */ function validateDate() { // packager automatically sets date, so only validate if @@ -238,6 +299,9 @@ return true; } + /** + * @access protected + */ function validateTime() { if (!$this->_packagexml->getTime()) { @@ -262,35 +326,118 @@ return true; } + /** + * @access protected + */ function validateState() { - if (!in_array($this->_packagexml->getState(), $this->_validStates)) { + // this is the closest to "final" php4 can get + if (!PEAR_Validate::validState($this->_packagexml->getState())) { $this->_addFailure('state', 'release state "' . $this->_packagexml->getState() . '" is not valid, must be one of: ' . - implode(', ', $this->_validStates)); + implode(', ', PEAR_Validate::getValidStates())); return false; } return true; } + /** + * @access protected + */ function validateStability() { $ret = true; $packagestability = $this->_packagexml->getState(); $apistability = $this->_packagexml->getState('api'); - if (!in_array($packagestability, $this->_validStates)) { + if (!PEAR_Validate::validState($packagestability)) { $this->_addFailure('state', 'package stability "' . $this->_packagexml->getState() . '" is not valid, must be one of: ' . - implode(', ', $this->_validStates)); + implode(', ', PEAR_Validate::getValidStates())); $ret = false; } - if (!in_array($apistability, $this->_validStates)) { + if (!PEAR_Validate::validState($apistability)) { $this->_addFailure('state', 'API stability "' . $this->_packagexml->getState() . '" is not valid, must be one of: ' . - implode(', ', $this->_validStates)); + implode(', ', PEAR_Validate::getValidStates())); $ret = false; } return $ret; + } + + /** + * @access protected + */ + function validateSummary() + { + return true; + } + + /** + * @access protected + */ + function validateDescription() + { + return true; + } + + /** + * @access protected + */ + function validateLicense() + { + return true; + } + + /** + * @access protected + */ + function validateNotes() + { + return true; + } + + /** + * for package.xml 2.0 only - channels can't use package.xml 1.0 + * @access protected + */ + function validateDependencies() + { + return true; + } + + /** + * for package.xml 1.0 only + * @access private + */ + function _validateFilelist() + { + return true; // placeholder for now + } + + /** + * for package.xml 2.0 only + * @access protected + */ + function validateMainFilelist() + { + return true; // placeholder for now + } + + /** + * for package.xml 2.0 only + * @access protected + */ + function validateReleaseFilelist() + { + return true; // placeholder for now + } + + /** + * @access protected + */ + function validateChangelog() + { + return true; } } ?>