]> granicus.if.org Git - php/commitdiff
* fixed <provides> generation, provides elements are now included for
authorStig Bakken <ssb@php.net>
Tue, 25 Feb 2003 02:44:10 +0000 (02:44 +0000)
committerStig Bakken <ssb@php.net>
Tue, 25 Feb 2003 02:44:10 +0000 (02:44 +0000)
  every non-private class, function and method

pear/PEAR/Command/Package.php
pear/PEAR/Common.php
pear/PEAR/Packager.php
pear/package-PEAR.xml

index 0391f6e6ddb3ed73cca5738097f7a0ba3a5a4a41..9a92100cfef274e60a58998dc1c8b3fd727cf1be 100644 (file)
@@ -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);
index 83c8d20f3903fb02fe958b6bf869d91c53b5afaa..ae31207f463683c904986a99ac7be38c8d18defd 100644 (file)
@@ -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]);
         }
     }
 
index b82e080aafda402ad7e07bb82734efba78965f5b..5929fe238ec02930ecebebcba854b1c74a5700bf 100644 (file)
@@ -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';
index fd7f71d27f182d39cd69da54eede8cd7dec11313..4a0de38b3207ffefcc82ec5c238017e34e239cbf 100644 (file)
@@ -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