com web/rmtools: improved the current workflow with regard to mailing: client/include/PeclExt.php client/script/pecl.php
| From: | Stephen A. Zarkos | Date: | Sat, 14 Sep 2013 19:21:59 +0000 |
| Subject: | com web/rmtools: improved the current workflow with regard to mailing: client/include/PeclExt.php client/script/pecl.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-16683@lists.php.net to get a copy of this message | ||
Commit: 416e4c399497215ca495ec8c383762658dc43caa
Author: Anatol Belski <ab@php.net> Sat, 14 Sep 2013 21:21:59 +0200
Parents: 9a053e3caa3633f448f5a5d7ea456efb1cdb2d10
Branches: master
Link: http://git.php.net/?p=web/rmtools.git;a=commitdiff;h=416e4c399497215ca495ec8c383762658dc43caa
Log:
improved the current workflow with regard to mailing
Changed paths:
M client/include/PeclExt.php
M client/script/pecl.php
diff --git a/client/include/PeclExt.php b/client/include/PeclExt.php index fc5a550..222b0ef 100644 --- a/client/include/PeclExt.php +++ b/client/include/PeclExt.php @@ -7,7 +7,7 @@ include_once __DIR__ . '/../include/PeclBranch.php'; class PeclExt { - protected $pgk_path; + protected $pkg_path; protected $pkg_basename; protected $pkg_comp; protected $name; @@ -24,32 +24,35 @@ class PeclExt protected $configure_data = NULL; protected $non_core_ext_deps = array(); - public function __construct($pgk_path, $build, $force_name = NULL, $force_version = NULL) + public function __construct($pkg_path, $build) { - if (!file_exists($pgk_path)) { - throw new \Exception("'$pgk_path' does not exist"); + if (!file_exists($pkg_path)) { + throw new \Exception("'$pkg_path' does not exist"); } - if ('.tgz' == substr($pgk_path, -4)) { - $this->pkg_basename = basename($pgk_path, '.tgz'); + if ('.tgz' == substr($pkg_path, -4)) { + $this->pkg_basename = basename($pkg_path, '.tgz'); $this->pkg_comp = 'tgz'; - } else if ('.tar.gz' == substr($pgk_path, -7)) { - $this->pkg_basename = basename($pgk_path, '.tar.gz'); + } else if ('.tar.gz' == substr($pkg_path, -7)) { + $this->pkg_basename = basename($pkg_path, '.tar.gz'); $this->pkg_comp = 'tgz'; - } else if ('.zip' == substr($pgk_path, -4)) { - $this->pkg_basename = basename($pgk_path, '.zip'); + } else if ('.zip' == substr($pkg_path, -4)) { + $this->pkg_basename = basename($pkg_path, '.zip'); $this->pkg_comp = 'zip'; } else { throw new \Exception("Unsupported compression format, please pass tgz, tar.gz or zip"); } - $this->pgk_path = $pgk_path; + $this->pkg_path = $pkg_path; $this->build = $build; + } + + public function init($force_name = NULL, $force_version = NULL) + { $this->unpack(); $this->check(); - $this->name = $force_name; $this->version = $force_version; @@ -100,7 +103,6 @@ class PeclExt $this->name = strtolower($this->name); $this->version = strtolower($this->version); - } public function getPackageName() @@ -122,8 +124,8 @@ class PeclExt throw new \Exception("Couldn't create temporary dir"); } - $tmp_name = $tmp_path . DIRECTORY_SEPARATOR . basename($this->pgk_path); - if (!copy($this->pgk_path, $tmp_name)) { + $tmp_name = $tmp_path . DIRECTORY_SEPARATOR . basename($this->pkg_path); + if (!copy($this->pkg_path, $tmp_name)) { throw new \Exception("Couldn't copy the tarball to '$tmp_name'"); } @@ -135,7 +137,7 @@ class PeclExt chdir($tmp_path); - $gzip_cmd = $this->gzip_cmd . ' -df ' . escapeshellarg(basename($this->pgk_path)); + $gzip_cmd = $this->gzip_cmd . ' -df ' . escapeshellarg(basename($this->pkg_path)); system($gzip_cmd, $ret); if ($ret) { throw new \Exception("Failed to guzip the tarball"); @@ -161,7 +163,7 @@ class PeclExt throw new \Exception("Couldn't create temporary dir"); } - $unzip_cmd = $this->unzip_cmd . ' ' . escapeshellarg($this->pgk_path) . ' -d ' . $tmp_path; + $unzip_cmd = $this->unzip_cmd . ' ' . escapeshellarg($this->pkg_path) . ' -d ' . $tmp_path; system($unzip_cmd, $ret); if ($ret) { throw new \Exception("Failed to unzip the package"); @@ -213,7 +215,7 @@ class PeclExt $this->package_xml = new \SimpleXMLElement($package_xml_path, 0, true); } - $this->pgk_path = NULL; + $this->pkg_path = NULL; return $this->tmp_extract_path; } @@ -540,23 +542,43 @@ class PeclExt return $zip_file; } - public function mailMaintainers($success, array $logs) + public function getToEmail() { - $url = 'http://windows.php.net/downloads/pecl/' . $this->name . '/' . $this->version; + $to = NULL; + $leads = $this->getPackageXmlProperty("lead"); + foreach ($leads as $lead) { + if ((string)$lead->active == 'yes') { + $to = (string)$lead->email; + } + } + + return $to; + } + + public function mailMaintainers($success, $is_snap, array $logs, $force_email = NULL) + { + $seg = $is_snap ? 'snaps' : 'releases'; + $url = 'http://windows.php.net/downloads/pecl/' . $seg . '/' . $this->name . '/' . $this->version; + if ($success) { - $msg = "PECL Windows build succeeded\n\n"; - $msg .= "The package was uploaded to $url/" . $this->getPackageName() . ".zip\n"; + $msg = "PECL Windows build for " . $this->getPackageName() . " succeeded\n\n"; + $msg .= "The package was uploaded to $url/" . $this->getPackageName() . ".zip\n\n"; } else { - $msg = "PECL Windows build failed\n\n"; + $msg = "PECL Windows build for " . $this->getPackageName() . " failed\n\n"; + } + $msg .= "The logs was uploaded to $url/logs/" . $this->getPackageName() . "-logs.zip\n\n"; + if (!$success) { + $msg .= "Please look into the logs for what's to be fixed. "; + $msg .= "You can ask for help on pecl-dev@lists.php.net or internals-win@lists.php.net. \n"; } - $msg .= "For logs see $url/logs/" . $this->getPackageName() . "-logs.zip\n"; + $msg .= "Have a nice day :)\n"; - $msg . "\nHave a nice day\n"; + $to = $force_email ? $force_email : $this->getToEmail(); - rm\xmail( - 'pecl@windows', - 'ab@php.net', /* XXX try to get dev mails from the package.xml */ - '[PECL-DEV] Windows build: ' . $this->name . '-' . $this->version, + return xmail( + MAIL_FROM, + $to, + '[PECL-DEV] Windows build: ' . $this->getPackageName(), $msg, $logs ); diff --git a/client/script/pecl.php b/client/script/pecl.php index 1f9a4c1..f55a505 100644 --- a/client/script/pecl.php +++ b/client/script/pecl.php @@ -8,7 +8,7 @@ use rmtools as rm; $shortopts = NULL; //"c:p:mu"; -$longopts = array("config:", "package:", "mail", "upload", "is-snap", "force-name:", "force-version:"); +$longopts = array("config:", "package:", "mail", "upload", "is-snap", "force-name:", "force-version:", "force-email:"); $options = getopt($shortopts, $longopts); @@ -19,6 +19,7 @@ $upload = isset($options['upload']); $is_snap = isset($options['is-snap']); $force_name = isset($options['force-name']) ? $options['force-name'] : NULL; $force_version = isset($options['force-version']) ? $options['force-version'] : NULL; +$force_email = isset($options['force-email']) ? $options['force-email'] : NULL; if (NULL == $branch_name || NULL == $pkg_path) { echo "Usage: pecl.php [OPTION] ..." . PHP_EOL; @@ -29,20 +30,24 @@ if (NULL == $branch_name || NULL == $pkg_path) { echo " --is-snap We upload to releases by default, but this one goes to snaps, optional." . PHP_EOL; echo " --force-name Force this name instead of reading the package data, optional." . PHP_EOL; echo " --force-version Force this name instead of reading the package data, optional." . PHP_EOL; + echo " --force-email Send the results to this email instead of any from package.xml, optional." . PHP_EOL; echo PHP_EOL; echo "Example: pecl --config=php55_x64 --package=c:\pecl_in_pkg\some-1.0.0.tgz" . PHP_EOL; echo PHP_EOL; exit(0); } +define('MAIL_FROM', 'pecl-dev@lists.php.net'); +define('MAIL_TO_FALLBACK', 'ab@php.net'); + $config_path = __DIR__ . '/../data/config/pecl/' . $branch_name . '.ini'; $branch = new rm\PeclBranch($config_path); $branch_name = $branch->config->getName(); -echo "Running <$config_path>" . PHP_EOL; -echo "\t$branch_name" . PHP_EOL; +echo "Run started for <$config_path>" . PHP_EOL; +echo "Branch <$branch_name>" . PHP_EOL; $build_dir_parent = $branch->config->getBuildLocation(); @@ -56,7 +61,7 @@ $builds = $branch->getBuildList('windows'); /* be optimistic */ $was_errors = false; -echo "Using <$pkg_path>" . PHP_EOL; +echo "Using <$pkg_path>" . PHP_EOL . PHP_EOL; /* Each windows configuration from the ini for the given PHP version will be built */ foreach ($builds as $build_name) { @@ -72,24 +77,63 @@ foreach ($builds as $build_name) { $build->setSourceDir($build_src_path); try { - $ext = new rm\PeclExt($pkg_path, $build, $force_name, $force_version); + $ext = new rm\PeclExt($pkg_path, $build); + } catch (Exception $e) { + echo 'Error: ' . $e->getMessage() . PHP_EOL; + + if ($mail_maintainers) { + rm\xmail( + MAIL_FROM, + /* no chance to have the maintainers mailto at this stage */ + $force_email ? $force_email: MAIL_TO_FALLBACK, + '[PECL-DEV] Windows build: ' . basename($pkg_path), + "PECL build failed before it could start for the reasons below:\n\n" . $e->getMessage() + ); + } + + $build->clean(); + $was_errors = true; + + unset($ext); + unset($build); + + /* no sense to continue as something in ext setup went wrong */ + continue; + } + + try { + $ext->init($force_name, $force_version); $ext->setupNonCoreExtDeps(); + $ext->putSourcesIntoBranch(); } catch (Exception $e) { - echo $e->getMessage() . PHP_EOL; + echo 'Error: ' . $e->getMessage() . PHP_EOL; + $was_errors = true; - rm\xmail( - 'pecl@windows', - 'ab@php.net', /* XXX try to get dev mails from the package.xml */ - '[PECL-DEV] Windows build: ' . basename($pkg_path), - "PECL build failed before it could start for the reasons below:\n\n" . $e->getMessage() - ); + if ($mail_maintainers) { + $maintainer_mailto = $force_email; + if (!$maintainer_mailto) { + $maintainer_mailto = $ext->getToEmail(); + if (!$maintainer_mailto) { + $maintainer_mailto = MAIL_TO_FALLBACK; + } + } + + rm\xmail( + MAIL_FROM, + $maintainer_mailto, + '[PECL-DEV] Windows build: ' . basename($pkg_path), + "PECL build failed before it could start for the reasons below:\n\n" . $e->getMessage() + ); + } $build->clean(); + $ext->clean(); $was_errors = true; - /* XXX mail the ext dev what the error was, if it's something in the check - phase like missing config.w32, it's interesting for sure. - and no sense to continue as something in ext setup went wrong */ + unset($ext); + unset($build); + + /* no sense to continue as something in ext setup went wrong */ continue; } @@ -105,11 +149,9 @@ foreach ($builds as $build_name) { mkdir($toupload_dir . '/logs', 0655, true); } - echo "Configured for '$ext_build_name'" . PHP_EOL; + echo "Configured for <$ext_build_name>" . PHP_EOL; echo "Running build in <$build_src_path>" . PHP_EOL; try { - $ext->putSourcesIntoBranch(); - $build->buildconf(); $ext_conf_line = $ext->getConfigureLine(); @@ -129,7 +171,7 @@ foreach ($builds as $build_name) { $build->make(); //$html_make_log = $build->getMakeLogParsed(); } catch (Exception $e) { - echo $e->getMessage() . PHP_EOL; + echo 'Error: ' . $e->getMessage() . PHP_EOL; $build_error++; } @@ -156,7 +198,7 @@ foreach ($builds as $build_name) { echo "Packaging the binaries" . PHP_EOL; $pkg_file = $ext->preparePackage(); } catch (Exception $e) { - echo $e->getMessage() . PHP_EOL; + echo 'Error: ' . $e->getMessage() . PHP_EOL; $build_error++; } @@ -171,7 +213,7 @@ foreach ($builds as $build_name) { ) ); } catch (Exception $e) { - echo $e->getMessage() . PHP_EOL; + echo 'Error: ' . $e->getMessage() . PHP_EOL; $build_error++; } @@ -199,17 +241,28 @@ foreach ($builds as $build_name) { echo "Upload failed" . PHP_EOL; } } catch (Exception $e) { - echo $e->getMessage(); + echo 'Error . ' . $e->getMessage() . PHP_EOL; $upload_success = false; } } - if (0 && $mail_maintainers) { - echo "Mailing logs"; + if ($mail_maintainers) { + echo "Mailing logs" . PHP_EOL; try { - $ext->mailMaintainers(0 == $build_error, array($logs_zip)); + $maintainer_mailto = $force_email; + if (!$maintainer_mailto) { + $maintainer_mailto = $ext->getToEmail(); + if (!$maintainer_mailto) { + $maintainer_mailto = MAIL_TO_FALLBACK; + } + } + + $res = $ext->mailMaintainers(0 == $build_error, $is_snap, array($logs_zip), $maintainer_mailto); + if (!$res) { + throw new \Exception("Mail operation failed"); + } } catch (Exception $e) { - echo $e->getMessage() . PHP_EOL; + echo 'Error: ' . $e->getMessage() . PHP_EOL; } } @@ -220,12 +273,12 @@ foreach ($builds as $build_name) { unset($ext); unset($build); - echo PHP_EOL; + echo "Done." . PHP_EOL . PHP_EOL; $was_errors = $was_errors || $build_error > 0; } -echo "Done." . PHP_EOL; +echo "Run finished." . PHP_EOL . PHP_EOL; exit((int)$was_errors);
diff --git a/client/include/PeclExt.php b/client/include/PeclExt.php index fc5a550..222b0ef 100644 --- a/client/include/PeclExt.php +++ b/client/include/PeclExt.php @@ -7,7 +7,7 @@ include_once __DIR__ . '/../include/PeclBranch.php'; class PeclExt { - protected $pgk_path; + protected $pkg_path; protected $pkg_basename; protected $pkg_comp; protected $name; @@ -24,32 +24,35 @@ class PeclExt protected $configure_data = NULL; protected $non_core_ext_deps = array(); - public function __construct($pgk_path, $build, $force_name = NULL, $force_version = NULL) + public function __construct($pkg_path, $build) { - if (!file_exists($pgk_path)) { - throw new \Exception("'$pgk_path' does not exist"); + if (!file_exists($pkg_path)) { + throw new \Exception("'$pkg_path' does not exist"); } - if ('.tgz' == substr($pgk_path, -4)) { - $this->pkg_basename = basename($pgk_path, '.tgz'); + if ('.tgz' == substr($pkg_path, -4)) { + $this->pkg_basename = basename($pkg_path, '.tgz'); $this->pkg_comp = 'tgz'; - } else if ('.tar.gz' == substr($pgk_path, -7)) { - $this->pkg_basename = basename($pgk_path, '.tar.gz'); + } else if ('.tar.gz' == substr($pkg_path, -7)) { + $this->pkg_basename = basename($pkg_path, '.tar.gz'); $this->pkg_comp = 'tgz'; - } else if ('.zip' == substr($pgk_path, -4)) { - $this->pkg_basename = basename($pgk_path, '.zip'); + } else if ('.zip' == substr($pkg_path, -4)) { + $this->pkg_basename = basename($pkg_path, '.zip'); $this->pkg_comp = 'zip'; } else { throw new \Exception("Unsupported compression format, please pass tgz, tar.gz or zip"); } - $this->pgk_path = $pgk_path; + $this->pkg_path = $pkg_path; $this->build = $build; + } + + public function init($force_name = NULL, $force_version = NULL) + { $this->unpack(); $this->check(); - $this->name = $force_name; $this->version = $force_version; @@ -100,7 +103,6 @@ class PeclExt $this->name = strtolower($this->name); $this->version = strtolower($this->version); - } public function getPackageName() @@ -122,8 +124,8 @@ class PeclExt throw new \Exception("Couldn't create temporary dir"); } - $tmp_name = $tmp_path . DIRECTORY_SEPARATOR . basename($this->pgk_path); - if (!copy($this->pgk_path, $tmp_name)) { + $tmp_name = $tmp_path . DIRECTORY_SEPARATOR . basename($this->pkg_path); + if (!copy($this->pkg_path, $tmp_name)) { throw new \Exception("Couldn't copy the tarball to '$tmp_name'"); } @@ -135,7 +137,7 @@ class PeclExt chdir($tmp_path); - $gzip_cmd = $this->gzip_cmd . ' -df ' . escapeshellarg(basename($this->pgk_path)); + $gzip_cmd = $this->gzip_cmd . ' -df ' . escapeshellarg(basename($this->pkg_path)); system($gzip_cmd, $ret); if ($ret) { throw new \Exception("Failed to guzip the tarball"); @@ -161,7 +163,7 @@ class PeclExt throw new \Exception("Couldn't create temporary dir"); } - $unzip_cmd = $this->unzip_cmd . ' ' . escapeshellarg($this->pgk_path) . ' -d ' . $tmp_path; + $unzip_cmd = $this->unzip_cmd . ' ' . escapeshellarg($this->pkg_path) . ' -d ' . $tmp_path; system($unzip_cmd, $ret); if ($ret) { throw new \Exception("Failed to unzip the package"); @@ -213,7 +215,7 @@ class PeclExt $this->package_xml = new \SimpleXMLElement($package_xml_path, 0, true); } - $this->pgk_path = NULL; + $this->pkg_path = NULL; return $this->tmp_extract_path; } @@ -540,23 +542,43 @@ class PeclExt return $zip_file; } - public function mailMaintainers($success, array $logs) + public function getToEmail() { - $url = 'http://windows.php.net/downloads/pecl/' . $this->name . '/' . $this->version; + $to = NULL; + $leads = $this->getPackageXmlProperty("lead"); + foreach ($leads as $lead) { + if ((string)$lead->active == 'yes') { + $to = (string)$lead->email; + } + } + + return $to; + } + + public function mailMaintainers($success, $is_snap, array $logs, $force_email = NULL) + { + $seg = $is_snap ? 'snaps' : 'releases'; + $url = 'http://windows.php.net/downloads/pecl/' . $seg . '/' . $this->name . '/' . $this->version; + if ($success) { - $msg = "PECL Windows build succeeded\n\n"; - $msg .= "The package was uploaded to $url/" . $this->getPackageName() . ".zip\n"; + $msg = "PECL Windows build for " . $this->getPackageName() . " succeeded\n\n"; + $msg .= "The package was uploaded to $url/" . $this->getPackageName() . ".zip\n\n"; } else { - $msg = "PECL Windows build failed\n\n"; + $msg = "PECL Windows build for " . $this->getPackageName() . " failed\n\n"; + } + $msg .= "The logs was uploaded to $url/logs/" . $this->getPackageName() . "-logs.zip\n\n"; + if (!$success) { + $msg .= "Please look into the logs for what's to be fixed. "; + $msg .= "You can ask for help on pecl-dev@lists.php.net or internals-win@lists.php.net. \n"; } - $msg .= "For logs see $url/logs/" . $this->getPackageName() . "-logs.zip\n"; + $msg .= "Have a nice day :)\n"; - $msg . "\nHave a nice day\n"; + $to = $force_email ? $force_email : $this->getToEmail(); - rm\xmail( - 'pecl@windows', - 'ab@php.net', /* XXX try to get dev mails from the package.xml */ - '[PECL-DEV] Windows build: ' . $this->name . '-' . $this->version, + return xmail( + MAIL_FROM, + $to, + '[PECL-DEV] Windows build: ' . $this->getPackageName(), $msg, $logs ); diff --git a/client/script/pecl.php b/client/script/pecl.php index 1f9a4c1..f55a505 100644 --- a/client/script/pecl.php +++ b/client/script/pecl.php @@ -8,7 +8,7 @@ use rmtools as rm; $shortopts = NULL; //"c:p:mu"; -$longopts = array("config:", "package:", "mail", "upload", "is-snap", "force-name:", "force-version:"); +$longopts = array("config:", "package:", "mail", "upload", "is-snap", "force-name:", "force-version:", "force-email:"); $options = getopt($shortopts, $longopts); @@ -19,6 +19,7 @@ $upload = isset($options['upload']); $is_snap = isset($options['is-snap']); $force_name = isset($options['force-name']) ? $options['force-name'] : NULL; $force_version = isset($options['force-version']) ? $options['force-version'] : NULL; +$force_email = isset($options['force-email']) ? $options['force-email'] : NULL; if (NULL == $branch_name || NULL == $pkg_path) { echo "Usage: pecl.php [OPTION] ..." . PHP_EOL; @@ -29,20 +30,24 @@ if (NULL == $branch_name || NULL == $pkg_path) { echo " --is-snap We upload to releases by default, but this one goes to snaps, optional." . PHP_EOL; echo " --force-name Force this name instead of reading the package data, optional." . PHP_EOL; echo " --force-version Force this name instead of reading the package data, optional." . PHP_EOL; + echo " --force-email Send the results to this email instead of any from package.xml, optional." . PHP_EOL; echo PHP_EOL; echo "Example: pecl --config=php55_x64 --package=c:\pecl_in_pkg\some-1.0.0.tgz" . PHP_EOL; echo PHP_EOL; exit(0); } +define('MAIL_FROM', 'pecl-dev@lists.php.net'); +define('MAIL_TO_FALLBACK', 'ab@php.net'); + $config_path = __DIR__ . '/../data/config/pecl/' . $branch_name . '.ini'; $branch = new rm\PeclBranch($config_path); $branch_name = $branch->config->getName(); -echo "Running <$config_path>" . PHP_EOL; -echo "\t$branch_name" . PHP_EOL; +echo "Run started for <$config_path>" . PHP_EOL; +echo "Branch <$branch_name>" . PHP_EOL; $build_dir_parent = $branch->config->getBuildLocation(); @@ -56,7 +61,7 @@ $builds = $branch->getBuildList('windows'); /* be optimistic */ $was_errors = false; -echo "Using <$pkg_path>" . PHP_EOL; +echo "Using <$pkg_path>" . PHP_EOL . PHP_EOL; /* Each windows configuration from the ini for the given PHP version will be built */ foreach ($builds as $build_name) { @@ -72,24 +77,63 @@ foreach ($builds as $build_name) { $build->setSourceDir($build_src_path); try { - $ext = new rm\PeclExt($pkg_path, $build, $force_name, $force_version); + $ext = new rm\PeclExt($pkg_path, $build); + } catch (Exception $e) { + echo 'Error: ' . $e->getMessage() . PHP_EOL; + + if ($mail_maintainers) { + rm\xmail( + MAIL_FROM, + /* no chance to have the maintainers mailto at this stage */ + $force_email ? $force_email: MAIL_TO_FALLBACK, + '[PECL-DEV] Windows build: ' . basename($pkg_path), + "PECL build failed before it could start for the reasons below:\n\n" . $e->getMessage() + ); + } + + $build->clean(); + $was_errors = true; + + unset($ext); + unset($build); + + /* no sense to continue as something in ext setup went wrong */ + continue; + } + + try { + $ext->init($force_name, $force_version); $ext->setupNonCoreExtDeps(); + $ext->putSourcesIntoBranch(); } catch (Exception $e) { - echo $e->getMessage() . PHP_EOL; + echo 'Error: ' . $e->getMessage() . PHP_EOL; + $was_errors = true; - rm\xmail( - 'pecl@windows', - 'ab@php.net', /* XXX try to get dev mails from the package.xml */ - '[PECL-DEV] Windows build: ' . basename($pkg_path), - "PECL build failed before it could start for the reasons below:\n\n" . $e->getMessage() - ); + if ($mail_maintainers) { + $maintainer_mailto = $force_email; + if (!$maintainer_mailto) { + $maintainer_mailto = $ext->getToEmail(); + if (!$maintainer_mailto) { + $maintainer_mailto = MAIL_TO_FALLBACK; + } + } + + rm\xmail( + MAIL_FROM, + $maintainer_mailto, + '[PECL-DEV] Windows build: ' . basename($pkg_path), + "PECL build failed before it could start for the reasons below:\n\n" . $e->getMessage() + ); + } $build->clean(); + $ext->clean(); $was_errors = true; - /* XXX mail the ext dev what the error was, if it's something in the check - phase like missing config.w32, it's interesting for sure. - and no sense to continue as something in ext setup went wrong */ + unset($ext); + unset($build); + + /* no sense to continue as something in ext setup went wrong */ continue; } @@ -105,11 +149,9 @@ foreach ($builds as $build_name) { mkdir($toupload_dir . '/logs', 0655, true); } - echo "Configured for '$ext_build_name'" . PHP_EOL; + echo "Configured for <$ext_build_name>" . PHP_EOL; echo "Running build in <$build_src_path>" . PHP_EOL; try { - $ext->putSourcesIntoBranch(); - $build->buildconf(); $ext_conf_line = $ext->getConfigureLine(); @@ -129,7 +171,7 @@ foreach ($builds as $build_name) { $build->make(); //$html_make_log = $build->getMakeLogParsed(); } catch (Exception $e) { - echo $e->getMessage() . PHP_EOL; + echo 'Error: ' . $e->getMessage() . PHP_EOL; $build_error++; } @@ -156,7 +198,7 @@ foreach ($builds as $build_name) { echo "Packaging the binaries" . PHP_EOL; $pkg_file = $ext->preparePackage(); } catch (Exception $e) { - echo $e->getMessage() . PHP_EOL; + echo 'Error: ' . $e->getMessage() . PHP_EOL; $build_error++; } @@ -171,7 +213,7 @@ foreach ($builds as $build_name) { ) ); } catch (Exception $e) { - echo $e->getMessage() . PHP_EOL; + echo 'Error: ' . $e->getMessage() . PHP_EOL; $build_error++; } @@ -199,17 +241,28 @@ foreach ($builds as $build_name) { echo "Upload failed" . PHP_EOL; } } catch (Exception $e) { - echo $e->getMessage(); + echo 'Error . ' . $e->getMessage() . PHP_EOL; $upload_success = false; } } - if (0 && $mail_maintainers) { - echo "Mailing logs"; + if ($mail_maintainers) { + echo "Mailing logs" . PHP_EOL; try { - $ext->mailMaintainers(0 == $build_error, array($logs_zip)); + $maintainer_mailto = $force_email; + if (!$maintainer_mailto) { + $maintainer_mailto = $ext->getToEmail(); + if (!$maintainer_mailto) { + $maintainer_mailto = MAIL_TO_FALLBACK; + } + } + + $res = $ext->mailMaintainers(0 == $build_error, $is_snap, array($logs_zip), $maintainer_mailto); + if (!$res) { + throw new \Exception("Mail operation failed"); + } } catch (Exception $e) { - echo $e->getMessage() . PHP_EOL; + echo 'Error: ' . $e->getMessage() . PHP_EOL; } } @@ -220,12 +273,12 @@ foreach ($builds as $build_name) { unset($ext); unset($build); - echo PHP_EOL; + echo "Done." . PHP_EOL . PHP_EOL; $was_errors = $was_errors || $build_error > 0; } -echo "Done." . PHP_EOL; +echo "Run finished." . PHP_EOL . PHP_EOL; exit((int)$was_errors);