Commit:    c715de3de9e6cfd77c575b8e39de0c66015824a7
Author:    Anatol Belski <[email protected]>         Fri, 6 Sep 2013 19:23:03 +0200
Parents:   7b21ef85bb3b00273c14eb415cefaebe036f3b17
Branches:  master

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

Log:
further preparations for mailing

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


Diff:
diff --git a/client/include/PeclExt.php b/client/include/PeclExt.php
index 43eea6e..83c3f5c 100644
--- a/client/include/PeclExt.php
+++ b/client/include/PeclExt.php
@@ -340,9 +340,23 @@ class PeclExt
                if ($this->tmp_extract_path) {
                        rmdir_rf(dirname($this->tmp_extract_path));
                }
+
                if ($this->ext_dir_in_src_path) {
                        rmdir_rf($this->ext_dir_in_src_path);
                }
+
+
+               /* XXX don't do it yet as we don't mail yet and don't upload. 
+                  XXX also have to be sure it was mailed and uploaded first */
+               /*$ext_pack = TMP_DIR . DIRECTORY_SEPARATOR . 
$this->getPackageName() . '.zip';
+               if (file_exists($ext_pack) {
+                       unlink($ext_pack);
+               }
+
+               $log_pack = TMP_DIR . DIRECTORY_SEPARATOR . 
$this->getPackageName() . '-logs' . '.zip';
+               if (file_exists($log_pack) {
+                       unlink($log_pack);
+               }*/
        }
 
        public function check()
@@ -381,5 +395,25 @@ class PeclExt
                }
 
        }
+
+       public function mailLogs(array $logs)
+       {
+               foreach($logs as $k => $log) {
+                       if (!$log || !file_exists($log) || !is_file($log) || 
!is_readable($log)) {
+                               unset($logs[$k]);
+                       }
+               }
+
+               $zip_file = TMP_DIR . DIRECTORY_SEPARATOR . 
$this->getPackageName() . '-logs' . '.zip';
+               $zip_cmd = $this->zip_cmd . ' -9 -D -j ' . $zip_file . ' ' . 
implode(' ', $logs);
+               system($zip_cmd, $status);
+               if ($status) {
+                       throw new \Exception("Couldn't zip logs for $zip_file, 
cmd was '$zip_cmd'");
+               }
+
+               // $from is pecl@win
+               // $to is ext lead from package.xml
+               //xmail($from, $to, $subject, $text, $logs);
+       }
 }
 
diff --git a/client/include/Tools.php b/client/include/Tools.php
index e4068d2..3ea98b2 100644
--- a/client/include/Tools.php
+++ b/client/include/Tools.php
@@ -347,6 +347,10 @@ function xmail($from, $to, $subject, $text, array 
$attachment = array())
        $mail[] = $boundary;
 
        foreach($attachment as $att) {
+               if (!$att || !file_exists(!$att) || !is_file($att) || 
!is_readable($att)) {
+                       continue;
+               }
+
                $fname = basename($att);
                $fsize = filesize($att);
                if (function_exists('mime_content_type')) {
diff --git a/client/script/pecl.php b/client/script/pecl.php
index 74ac385..28e328a 100644
--- a/client/script/pecl.php
+++ b/client/script/pecl.php
@@ -67,6 +67,15 @@ foreach ($builds as $build_name) {
                $ext = new rm\PeclExt($ext_tgz, $build);
        } catch (Exception $e) {
                echo $e->getMessage() . "\n";
+
+               rm\xmail(
+                       'pecl@windows',
+                       '[email protected]', /* XXX try to get dev mails from the 
package.xml */
+                       'PECL windows build system: ' . basename($ext_tgz),
+                       "PECL build failed before it could start for the 
reasons below:\n\n" .
+                       $e->getMessage()
+               );
+
                $build->clean();
                $build_error++;
 
@@ -119,25 +128,44 @@ foreach ($builds as $build_name) {
        /* XXX PGO stuff would come here */
 
        $log_base = $toupload_dir . '/logs';
-       file_put_contents($log_base . '/buildconf-' . $ext->getPackageName() . 
'.txt', $build->log_buildconf);
-       file_put_contents($log_base . '/configure-' . $ext->getPackageName() . 
'.txt', $build->log_configure);
-       file_put_contents($log_base . '/make-' . $ext->getPackageName() . 
'.txt', $build->log_make);
+       $buildconf_log_fname = $log_base . '/buildconf-' . 
$ext->getPackageName() . '.txt';
+       $configure_log_fname = $log_base . '/configure-' . 
$ext->getPackageName() . '.txt';
+       $make_log_fname = $log_base . '/make-' . $ext->getPackageName() . 
'.txt';
+       $error_log_fname = NULL;
+
+       file_put_contents($buildconf_log_fname, $build->log_buildconf);
+       file_put_contents($configure_log_fname, $build->log_configure);
+       file_put_contents($make_log_fname, $build->log_make);
 
        $stats = $build->getStats();
 
        if ($stats['error'] > 0) {
-               file_put_contents($log_base . '/error-' . 
$ext->getPackageName() . '.txt', $build->compiler_log_parser->getErrors());
+               $error_log_fname = $log_base . '/error-' . 
$ext->getPackageName() . '.txt';
+               file_put_contents($error_log_fname, 
$build->compiler_log_parser->getErrors());
        }
 
        try {
                $pkg_file = $ext->preparePackage();
+
        } catch (Exception $e) {
                echo $e->getMessage() . "\n";
                $build_error++;
        }
 
        /*rm\upload_build_result_ftp_curl($toupload_dir, $branch_name . '/r' . 
$last_rev);*/
-       /* XXX mail the logs from above */
+
+       try {
+               $ext->mailLogs(
+                       array(
+                               $buildconf_log_fname,
+                               $configure_log_fname,
+                               $make_log_fname,
+                               $error_log_fname,
+                       )
+               );
+       } catch (Exception $e) {
+               echo $e->getMessage() . "\n";
+       }
 
        $build->clean();
        $ext->cleanup();


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

Reply via email to