Commit:    06011f14f67a6c4fd66d7232a791289d46432dbf
Author:    Anatol Belski <a...@php.net>         Thu, 10 Oct 2013 16:38:47 +0200
Parents:   6b5e1892c4e30814d34164cc2560d6018987b671
Branches:  master

Link:       
http://git.php.net/?p=web/rmtools.git;a=commitdiff;h=06011f14f67a6c4fd66d7232a791289d46432dbf

Log:
implemented packaging the "doc" files

this actually replaces any search for LICENSE

Changed paths:
  M  client/include/PeclExt.php
  M  client/script/pecl.php


Diff:
diff --git a/client/include/PeclExt.php b/client/include/PeclExt.php
index f492885..0ddc2b9 100644
--- a/client/include/PeclExt.php
+++ b/client/include/PeclExt.php
@@ -530,6 +530,7 @@ if (!function_exists('rmtools\combinations')) {
                return $this->buildConfigureLine($config);
        }
 
+       /* No errors here, the license presence should be done by PECL site */
        public function prepareLicenseSimple($source, $target, $suffix = NULL)
        {
                $ret = array();
@@ -717,17 +718,71 @@ if (!function_exists('rmtools\combinations')) {
                }
 
                /* care about extension license */
-                $files_to_zip = array_merge(
+               /* lack of license s not an error for us, this has to be 
checked on pecl pkg upload */
+               /* The ext license will be copied based on the info from 
package.xml, but let these lines stay */
+               /*$files_to_zip = array_merge(
                        $files_to_zip,
                        $this->prepareExtLicense($this->tmp_extract_path, 
$target, "php." . $this->name)
-               );
+               );*/
+
+               /* care about the files marked as "doc" in the package.xml */
+               $dirs = $this->getPackageXmlProperty("contents", "dir");
+               if ($dirs) {
+                       $root = NULL;
+                       foreach ($dirs as $dir) {
+                               if (isset($dir["name"]) && "/" == 
(string)$dir["name"]) {
+                                       $root = $dir;
+                                       break;
+                               }
+                       }
+
+                       if (!$root || !isset($root->file)) {
+                               goto nodoc;
+                       }
+
+                       foreach ($root->file as $file) {
+                               if (!isset($file["role"]) || "doc" != 
(string)$file["role"]) {
+                                       continue;
+                               }
+
+                               if (!isset($file["name"])) {
+                                       continue;
+                               }
+
+                               $src_fl = $this->tmp_extract_path
+                                       . DIRECTORY_SEPARATOR
+                                       . (string)$file["name"];
+
+                               if (!file_exists($src_fl)) {
+                                       continue;
+                               }
+
+                               $tgt_fl = $target
+                                       . DIRECTORY_SEPARATOR
+                                       . basename((string)$file["name"]);
+
+                               /* this could already done while checking 
license */
+                               if (in_array($tgt_fl, $files_to_zip)) {
+                                       continue;
+                               }
+       
+                               if (!copy($src_fl, $tgt_fl)) {
+                                       /* XXX actually it's not fatal, lets 
observe */
+                                       throw new \Exception("Failed to copy 
doc file '$src_fl' "
+                                               . "from the distribution into 
'$tgt_fl'");
+                               }
+
+                               $files_to_zip[] = $tgt_fl;
+                       }
+               }
+nodoc:
 
                /* pack */
                $zip_file = TMP_DIR . DIRECTORY_SEPARATOR . 
$this->getPackageName() . '.zip';
                $zip_cmd = $this->zip_cmd . ' -9 -D -j ' . $zip_file . ' ' . 
implode(' ', $files_to_zip);
                system($zip_cmd, $status);
                if ($status) {
-                       throw new \Exception("Couldn't zip files for 
$zip_file");
+                       throw new \Exception("Couldn't zip files for 
'$zip_file'");
                }
 
                return $zip_file;
diff --git a/client/script/pecl.php b/client/script/pecl.php
index 0c68e15..bf6cefa 100644
--- a/client/script/pecl.php
+++ b/client/script/pecl.php
@@ -171,7 +171,9 @@ foreach ($builds as $build_name) {
                }
 
                $build->clean();
-               $ext->cleanup();
+               if (isset($ext)) {
+                       $ext->cleanup();
+               }
                $was_errors = true;
 
                unset($ext);


--
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to