diff options
author | Stig Bakken <ssb@php.net> | 2003-02-25 02:44:10 +0000 |
---|---|---|
committer | Stig Bakken <ssb@php.net> | 2003-02-25 02:44:10 +0000 |
commit | 04870428ab5a5179092a2ec66ff5c460aeb4eae6 (patch) | |
tree | 2c3ff3a364a5daa0858c52ca1d727f15fd0788b0 | |
parent | d4dff9e92a056662652a3752b105bff8d5fa8f27 (diff) | |
download | php-git-04870428ab5a5179092a2ec66ff5c460aeb4eae6.tar.gz |
* fixed <provides> generation, provides elements are now included for
every non-private class, function and method
-rw-r--r-- | pear/PEAR/Command/Package.php | 11 | ||||
-rw-r--r-- | pear/PEAR/Common.php | 23 | ||||
-rw-r--r-- | pear/PEAR/Packager.php | 43 | ||||
-rw-r--r-- | pear/package-PEAR.xml | 2 |
4 files changed, 45 insertions, 34 deletions
diff --git a/pear/PEAR/Command/Package.php b/pear/PEAR/Command/Package.php index 0391f6e6dd..9a92100cfe 100644 --- a/pear/PEAR/Command/Package.php +++ b/pear/PEAR/Command/Package.php @@ -251,21 +251,14 @@ Wrote: /usr/src/redhat/RPMS/i386/PEAR::Net_Socket-1.0-1.i386.rpm $this->output = ''; include_once 'PEAR/Packager.php'; $pkginfofile = isset($params[0]) ? $params[0] : 'package.xml'; - ob_start(); $packager =& new PEAR_Packager($this->config->get('php_dir'), $this->config->get('ext_dir'), $this->config->get('doc_dir')); $packager->debug = $this->config->get('verbose'); $err = $warn = array(); - $packager->validatePackageInfo($pkginfofile, $err, $warn); - if (!$this->_displayValidationResults($err, $warn, true)) { - $this->ui->outputData($this->output, $command); - return; - } + $dir = dirname($pkginfofile); $compress = empty($options['nocompress']) ? true : false; - $result = $packager->Package($pkginfofile, $compress); - $this->output = ob_get_contents(); - ob_end_clean(); + $result = $packager->package($pkginfofile, $compress); if (PEAR::isError($result)) { $this->ui->outputData($this->output, $command); return $this->raiseError($result); diff --git a/pear/PEAR/Common.php b/pear/PEAR/Common.php index 83c8d20f39..ae31207f46 100644 --- a/pear/PEAR/Common.php +++ b/pear/PEAR/Common.php @@ -983,13 +983,16 @@ class PEAR_Common extends PEAR /** * Validate XML package definition file. * - * @param string Filename of the package archive or of the package definition file - * @param array Array that will contain the errors - * @param array Array that will contain the warnings + * @param string $info Filename of the package archive or of the + * package definition file + * @param array $errors Array that will contain the errors + * @param array $warnings Array that will contain the warnings + * @param string $dir_prefix (optional) directory where source files + * may be found, or empty if they are not available * @access public * @return boolean */ - function validatePackageInfo($info, &$errors, &$warnings) + function validatePackageInfo($info, &$errors, &$warnings, $dir_prefix = '') { global $_PEAR_Common_maintainer_roles, $_PEAR_Common_release_states, @@ -1104,9 +1107,12 @@ class PEAR_Common extends PEAR } elseif (!in_array($fa['role'], $_PEAR_Common_file_roles)) { $errors[] = "file $file: invalid role, should be one of: ".implode(' ', $_PEAR_Common_file_roles); } - if ($fa['role'] == 'php') { - $srcinfo = $this->analyzeSourceCode($file); - $this->buildProvidesArray($srcinfo); + if ($fa['role'] == 'php' && $dir_prefix) { + $this->log(1, "Analyzing $file"); + $srcinfo = $this->analyzeSourceCode($dir_prefix . DIRECTORY_SEPARATOR . $file); + if ($srcinfo) { + $this->buildProvidesArray($srcinfo); + } } // (ssb) Any checks we can do for baseinstalldir? // (cox) Perhaps checks that either the target dir and @@ -1169,7 +1175,6 @@ class PEAR_Common extends PEAR } $this->pkginfo['provides'][$key] = array('type' => 'class', 'name' => $class); - //var_dump($key, $this->pkginfo['provides'][$key]); } foreach ($srcinfo['declared_methods'] as $class => $methods) { foreach ($methods as $method) { @@ -1181,7 +1186,6 @@ class PEAR_Common extends PEAR } $this->pkginfo['provides'][$key] = array('type' => 'function', 'name' => $function); - //var_dump($key, $this->pkginfo['provides'][$key]); } } foreach ($srcinfo['declared_functions'] as $function) { @@ -1191,7 +1195,6 @@ class PEAR_Common extends PEAR } $this->pkginfo['provides'][$key] = array('type' => 'function', 'name' => $function); - //var_dump($key, $this->pkginfo['provides'][$key]); } } diff --git a/pear/PEAR/Packager.php b/pear/PEAR/Packager.php index b82e080aaf..5929fe238e 100644 --- a/pear/PEAR/Packager.php +++ b/pear/PEAR/Packager.php @@ -37,7 +37,7 @@ class PEAR_Packager extends PEAR_Common function PEAR_Packager() { - $this->PEAR_Common(); + parent::PEAR_Common(); } // }}} @@ -45,7 +45,7 @@ class PEAR_Packager extends PEAR_Common function _PEAR_Packager() { - $this->_PEAR_Common(); + parent::_PEAR_Common(); } // }}} @@ -61,48 +61,63 @@ class PEAR_Packager extends PEAR_Common if (PEAR::isError($pkginfo)) { return $this->raiseError($pkginfo); } - if (empty($pkginfo['version'])) { + if (empty($this->pkginfo['version'])) { return $this->raiseError("No version info found in $pkgfile"); } // TMP DIR ------------------------------------------------- // We allow calls like "pear package /home/user/mypack/package.xml" $oldcwd = getcwd(); - if (!@chdir(dirname($pkgfile))) { - return $this->raiseError('Could not chdir to '.dirname($pkgfile)); + $dir = dirname($pkgfile); + if (!@chdir($dir)) { + return $this->raiseError('Could not chdir to '.$dir); } $pkgfile = basename($pkgfile); - if (@$pkginfo['release_state'] == 'snapshot' && empty($pkginfo['version'])) { - $pkginfo['version'] = date('Ymd'); + if (@$this->pkginfo['release_state'] == 'snapshot' && empty($this->pkginfo['version'])) { + $this->pkginfo['version'] = date('Ymd'); } // don't want strange characters - $pkgname = preg_replace('/[^a-z0-9._]/i', '_', $pkginfo['package']); - $pkgversion = preg_replace('/[^a-z0-9._-]/i', '_', $pkginfo['version']); + $pkgname = preg_replace('/[^a-z0-9._]/i', '_', $this->pkginfo['package']); + $pkgversion = preg_replace('/[^a-z0-9._-]/i', '_', $this->pkginfo['version']); $pkgver = $pkgname . '-' . $pkgversion; + $errors = $warnings = array(); + $this->validatePackageInfo($this->pkginfo, $errors, $warnings, $dir); + foreach ($warnings as $w) { + $this->log(1, "Warning: $w"); + } + foreach ($errors as $e) { + $this->log(0, "Error: $e"); + } + if (sizeof($errors) > 0) { + chdir($oldcwd); + return $this->raiseError('Errors in package'); + } + // ----- Create the package file list $filelist = array(); $i = 0; // Copy files ----------------------------------------------- - foreach ($pkginfo['filelist'] as $fname => $atts) { + foreach ($this->pkginfo['filelist'] as $fname => $atts) { if (!file_exists($fname)) { chdir($oldcwd); - return $this->raiseError("File $fname does not exist"); + return $this->raiseError("File does not exist: $fname"); } else { $filelist[$i++] = $fname; - if (empty($pkginfo['filelist'][$fname]['md5sum'])) { + if (empty($this->pkginfo['filelist'][$fname]['md5sum'])) { $md5sum = md5_file($fname); - $pkginfo['filelist'][$fname]['md5sum'] = $md5sum; + $this->pkginfo['filelist'][$fname]['md5sum'] = $md5sum; } $this->log(2, "Adding file $fname"); } } - $new_xml = $this->xmlFromInfo($pkginfo); + $new_xml = $this->xmlFromInfo($this->pkginfo); if (PEAR::isError($new_xml)) { chdir($oldcwd); return $this->raiseError($new_xml); } if (!($tmpdir = System::mktemp('-t '.getcwd().' -d'))) { + chdir($oldcwd); return $this->raiseError("PEAR_Packager: mktemp failed"); } $newpkgfile = $tmpdir . DIRECTORY_SEPARATOR . 'package.xml'; diff --git a/pear/package-PEAR.xml b/pear/package-PEAR.xml index fd7f71d27f..4a0de38b32 100644 --- a/pear/package-PEAR.xml +++ b/pear/package-PEAR.xml @@ -44,7 +44,7 @@ PEAR BASE CLASS: PEAR INSTALLER: -* Packaging and validation now tokenizes source code (unless +* Packaging and validation now parses PHP source code (unless ext/tokenizer is disabled) and does some coding standard conformance checks. Specifically, the names of classes and functions are checked to ensure that they are prefixed with the package name. If |