com web/rmtools: upload basically works: client/include/PeclExt.php client/include/Tools.php client/script/pecl.php
| From: | Stephen A. Zarkos | Date: | Tue, 10 Sep 2013 11:04:02 +0000 |
| Subject: | com web/rmtools: upload basically works: client/include/PeclExt.php client/include/Tools.php client/script/pecl.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-16705@lists.php.net to get a copy of this message | ||
Commit: ca0c12fd24def3a60b1a1552a960fc4e55ccc367
Author: Anatol Belski <ab@php.net> Tue, 10 Sep 2013 13:04:02 +0200
Parents: 4c34bbdbfdec0e8af6e5f9b3f093d70c178cef37
Branches: master
Link: http://git.php.net/?p=web/rmtools.git;a=commitdiff;h=ca0c12fd24def3a60b1a1552a960fc4e55ccc367
Log:
upload basically works
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 06df224..d24f86b 100644
--- a/client/include/PeclExt.php
+++ b/client/include/PeclExt.php
@@ -364,7 +364,7 @@ class PeclExt
throw new \Exception("Unknown dynamic method called");
}
- public function cleanup()
+ public function cleanup($flag0 = false)
{
if ($this->tmp_extract_path) {
rmdir_rf(dirname($this->tmp_extract_path));
@@ -375,17 +375,15 @@ class PeclExt
}
- /* 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) {
+ $ext_pack = TMP_DIR . DIRECTORY_SEPARATOR . $this->getPackageName() . '.zip';
+ if ($flag0 && file_exists($ext_pack)) {
unlink($ext_pack);
}
$log_pack = TMP_DIR . DIRECTORY_SEPARATOR . $this->getPackageName() . '-logs' .
'.zip';
- if (file_exists($log_pack) {
+ if ($flag0 && file_exists($log_pack)) {
unlink($log_pack);
- }*/
+ }
}
public function check()
@@ -425,7 +423,7 @@ class PeclExt
}
- public function mailLogs(array $logs)
+ public function packLogs(array $logs)
{
foreach($logs as $k => $log) {
if (!$log || !file_exists($log) || !is_file($log) || !is_readable($log)) {
@@ -440,6 +438,12 @@ class PeclExt
throw new \Exception("Couldn't zip logs for $zip_file, cmd was
'$zip_cmd'");
}
+ return $zip_file;
+ }
+
+ public function mailMaintainers(array $logs)
+ {
+
// $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 f3bbb53..ec3a5f1 100644
--- a/client/include/Tools.php
+++ b/client/include/Tools.php
@@ -370,7 +370,7 @@ function xmail($from, $to, $subject, $text, array $attachment = array())
return mail($to, $subject, implode("\r\n", $mail), implode("\r\n", $header));
}
-function upload_pecl_pkg_ftp_curl($files, $target)
+function upload_pecl_pkg_ftp_curl($files, $logs, $target)
{
include __DIR__ . '/../data/config/credentials_ftps.php';
@@ -379,14 +379,14 @@ function upload_pecl_pkg_ftp_curl($files, $target)
echo "Cannot connect to $ftp_server\n";
return false;
}
- $login_result = ftp_login($ftp, $user_downloads, $password);
+ $login_result = ftp_login($ftp, $user_pecl, $password_pecl);
if (!$login_result) {
return false;
}
$try = 0;
do {
- $status = ftp_make_directory($ftp, $target);
+ $status = ftp_make_directory($ftp, $target . '/logs/');
$try++;
} while ( $status === false && $try < 10 );
ftp_close($ftp);
@@ -394,16 +394,16 @@ function upload_pecl_pkg_ftp_curl($files, $target)
$curl = array();
$ftp_path = $target;
- $ftp_user = $user_downloads;
- $ftp_password = $password;
+ $ftp_user = $user_pecl;
+ $ftp_password = $password_pecl;
if ($ftp_path[0] != '/') {
$ftp_path = '/' . $ftp_path;
}
$mh = \curl_multi_init();
- //$files = glob($src_dir . '/*.{zip,json}', GLOB_BRACE);
- $files = is_array($files) ? $u : array($files);
+ $files = is_array($files) ? $files : array($files);
+ $offset = 0;
foreach ($files as $i => $local_file) {
$curl[$i] = $ch = \curl_init();
@@ -419,10 +419,10 @@ function upload_pecl_pkg_ftp_curl($files, $target)
\curl_setopt($ch , CURLOPT_USERPWD, $ftp_user . ':' . $ftp_password);
\curl_multi_add_handle ($mh, $ch);
+ $offset++;
}
- /*$files = glob($src_dir . '/logs/*.*');
- $offset = $i + 1;
+ $files = is_array($logs) ? $logs : array($logs);
foreach ($files as $i => $local_file) {
$ch = $curl[$offset + $i] = \curl_init();
@@ -438,7 +438,7 @@ function upload_pecl_pkg_ftp_curl($files, $target)
\curl_setopt($ch , CURLOPT_USERPWD, $ftp_user . ':' . $ftp_password);
\curl_multi_add_handle ($mh, $ch);
- }*/
+ }
$retry = 0;
do {
diff --git a/client/script/pecl.php b/client/script/pecl.php
index e567eb2..868b6eb 100644
--- a/client/script/pecl.php
+++ b/client/script/pecl.php
@@ -50,13 +50,15 @@ if (!is_dir($build_dir_parent)) {
$builds = $branch->getBuildList('windows');
/* be optimistic */
-$build_error = 0;
+$was_errors = false;
echo "Using <$ext_tgz>\n";
/* Each windows configuration from the ini for the given PHP version will be built */
foreach ($builds as $build_name) {
+ $build_error = 0;
+
echo "Preparing to build \n";
$build_src_path = realpath($build_dir_parent . DIRECTORY_SEPARATOR .
$branch->config->getBuildSrcSubdir());
@@ -79,7 +81,7 @@ foreach ($builds as $build_name) {
);
$build->clean();
- $build_error++;
+ $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.
@@ -147,27 +149,16 @@ foreach ($builds as $build_name) {
}
try {
+ echo "Packaging the binaries\n";
$pkg_file = $ext->preparePackage();
-
} catch (Exception $e) {
echo $e->getMessage() . "\n";
$build_error++;
}
- if ($upload) {
- echo "Uploading '$pkg_file'\n";
- /* XXX check if the path will be correct with the login */
- $target = '/pecl/releases/' . $ext->getName() . '/' .
$ext->getVersion();
- if (rm\upload_pecl_pkg_ftp_curl($pkg_file, $target)) {
- echo "upload success\n";
- } else {
- echo "upload failed\n";
- }
- }
-
- echo "Mailing logs";
try {
- $ext->mailLogs(
+ echo "Packaging the logs\n";
+ $logs_zip = $ext->packLogs(
array(
$buildconf_log_fname,
$configure_log_fname,
@@ -177,16 +168,57 @@ foreach ($builds as $build_name) {
);
} catch (Exception $e) {
echo $e->getMessage() . "\n";
+ $build_error++;
}
+ $upload_success = true;
+ if ($upload) {
+ try {
+ $root = $is_snap ? 'snaps' : 'releases';
+ $target = '/' . $root . '/' . $ext->getName() . '/' .
$ext->getVersion();
+
+ $pkgs_to_upload = $build_error ? array() : array($pkg_file);
+
+ if ($build_error) {
+ echo "Uploading logs\n";
+ } else {
+ echo "Uploading '$pkg_file' and logs\n";
+ }
+
+ if ($build_error && !isset($logs_zip)) {
+ throw new Exception("Logs wasn't packaged, nothing to upload");
+ }
+
+ if (rm\upload_pecl_pkg_ftp_curl($pkgs_to_upload, array($logs_zip), $target)) {
+ echo "Upload succeeded\n";
+ } else {
+ echo "Upload failed\n";
+ }
+ } catch (Exception $e) {
+ echo $e->getMessage();
+ $upload_success = false;
+ }
+ }
+
+ if (0 && $mail_maintainers) {
+ echo "Mailing logs";
+ try {
+ $ext->mailLogs(array($logs_zip));
+ } catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+ }
+ }
+
$build->clean();
- $ext->cleanup();
+ $ext->cleanup($upload_success);
rm\rmdir_rf($toupload_dir);
echo "\n";
+
+ $was_errors = $was_errors || $build_error > 0;
}
echo "Done.\n";
-exit($build_error);
+exit((int)$was_errors);