Commit: dc11dd60386737a00a69bea763ec006077e23a2b Author: Anatol Belski <[email protected]> Mon, 9 Sep 2013 11:49:39 +0200 Parents: c715de3de9e6cfd77c575b8e39de0c66015824a7 Branches: master
Link: http://git.php.net/?p=web/rmtools.git;a=commitdiff;h=dc11dd60386737a00a69bea763ec006077e23a2b Log: prepared for uploads Changed paths: M client/bin/pecl.bat M client/data/config/credentials_ftps.php-dist M client/include/PeclExt.php M client/include/Tools.php M client/script/pecl.php Diff: diff --git a/client/bin/pecl.bat b/client/bin/pecl.bat index 9049072..fe48593 100644 --- a/client/bin/pecl.bat +++ b/client/bin/pecl.bat @@ -74,10 +74,10 @@ SET VC11_X64_SHELL=%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio REM Run pecl.php SET BISON_SIMPLE=c:\php-sdk\bin\bison.simple rem XXX iterate the c:\pecl_in_pkg here and delete the packages after successful build -c:\php-sdk\php\php.exe %BAT_DIR%\..\script\pecl.php --config=pecl55_x64 --package=C:\pecl_in_pkg\amqp-1.2.0.tgz -c:\php-sdk\php\php.exe %BAT_DIR%\..\script\pecl.php --config=pecl55_x86 --package=C:\pecl_in_pkg\amqp-1.2.0.tgz -c:\php-sdk\php\php.exe %BAT_DIR%\..\script\pecl.php --config=pecl54 --package=C:\pecl_in_pkg\amqp-1.2.0.tgz -c:\php-sdk\php\php.exe %BAT_DIR%\..\script\pecl.php --config=pecl53 --package=C:\pecl_in_pkg\amqp-1.2.0.tgz +c:\php-sdk\php\php.exe -d extension_dir=c:\php-sdk\php\ext -d extension=php_openssl.dll -d extension=php_curl.dll %BAT_DIR%\..\script\pecl.php --config=pecl55_x64 --package=C:\pecl_in_pkg\amqp-1.2.0.tgz +c:\php-sdk\php\php.exe -d extension_dir=c:\php-sdk\php\ext -d extension=php_openssl.dll -d extension=php_curl.dll %BAT_DIR%\..\script\pecl.php --config=pecl55_x86 --package=C:\pecl_in_pkg\amqp-1.2.0.tgz +c:\php-sdk\php\php.exe -d extension_dir=c:\php-sdk\php\ext -d extension=php_openssl.dll -d extension=php_curl.dll %BAT_DIR%\..\script\pecl.php --config=pecl54 --package=C:\pecl_in_pkg\amqp-1.2.0.tgz +c:\php-sdk\php\php.exe -d extension_dir=c:\php-sdk\php\ext -d extension=php_openssl.dll -d extension=php_curl.dll %BAT_DIR%\..\script\pecl.php --config=pecl53 --package=C:\pecl_in_pkg\amqp-1.2.0.tgz SET PATH=%OLD_PATH% echo Done.>> %LOG_FILE% diff --git a/client/data/config/credentials_ftps.php-dist b/client/data/config/credentials_ftps.php-dist index fc0faca..be07478 100644 --- a/client/data/config/credentials_ftps.php-dist +++ b/client/data/config/credentials_ftps.php-dist @@ -1,4 +1,5 @@ <?php $ftp_server = 'ftp.example.com'; $user_snaps = 'johndoe'; +$user_downloads = 'johndoe'; $password = '123456'; diff --git a/client/include/PeclExt.php b/client/include/PeclExt.php index 83c3f5c..e1f9e20 100644 --- a/client/include/PeclExt.php +++ b/client/include/PeclExt.php @@ -47,7 +47,7 @@ class PeclExt $this->version = !$this->version ?: $tmp[1]; if (!$this->name || !$this->version) { - throw new \Exception("Couldn't parse extension name or version from the filename"); + throw new \Exception("Couldn't parse extension name or version neither from package.xml nor from the filename"); } } @@ -415,5 +415,6 @@ class PeclExt // $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 3ea98b2..f3bbb53 100644 --- a/client/include/Tools.php +++ b/client/include/Tools.php @@ -370,3 +370,103 @@ 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) +{ + include __DIR__ . '/../data/config/credentials_ftps.php'; + + $ftp = ftp_connect($ftp_server); + if (!$ftp) { + echo "Cannot connect to $ftp_server\n"; + return false; + } + $login_result = ftp_login($ftp, $user_downloads, $password); + if (!$login_result) { + return false; + } + + $try = 0; + do { + $status = ftp_make_directory($ftp, $target); + $try++; + } while ( $status === false && $try < 10 ); + ftp_close($ftp); + + $curl = array(); + + $ftp_path = $target; + $ftp_user = $user_downloads; + $ftp_password = $password; + + 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); + foreach ($files as $i => $local_file) { + + $curl[$i] = $ch = \curl_init(); + $fp = fopen($local_file, "rb"); + $local_file = basename($local_file); + + $remoteurl = "ftps://${ftp_user}:${ftp_password}@${ftp_server}${ftp_path}/${local_file}"; + + \curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); + \curl_setopt($ch, CURLOPT_URL, $remoteurl); + \curl_setopt($ch, CURLOPT_UPLOAD, 1); + \curl_setopt($ch, CURLOPT_INFILE, $fp); + \curl_setopt($ch , CURLOPT_USERPWD, $ftp_user . ':' . $ftp_password); + + \curl_multi_add_handle ($mh, $ch); + } + + /*$files = glob($src_dir . '/logs/*.*'); + $offset = $i + 1; + foreach ($files as $i => $local_file) { + + $ch = $curl[$offset + $i] = \curl_init(); + $fp = fopen($local_file, "rb"); + $local_file = basename($local_file); + + $remoteurl = "ftps://${ftp_user}:${ftp_password}@${ftp_server}${ftp_path}/logs/${local_file}"; + + \curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); + \curl_setopt($ch, CURLOPT_URL, $remoteurl); + \curl_setopt($ch, CURLOPT_UPLOAD, 1); + \curl_setopt($ch, CURLOPT_INFILE, $fp); + \curl_setopt($ch , CURLOPT_USERPWD, $ftp_user . ':' . $ftp_password); + + \curl_multi_add_handle ($mh, $ch); + }*/ + + $retry = 0; + do { + $err = 0; + do { + \curl_multi_exec($mh,$active); + $info = curl_multi_info_read($mh); + if ($info !== false) { + curl_multi_remove_handle($mh, $info['handle']); + if ($info['result'] != 0) { + $err = 1; +// echo curl_getinfo($info['handle'], CURLINFO_EFFECTIVE_URL) . "\n"; +// echo curl_error($info['handle']) . "\n\n"; + curl_multi_add_handle($mh, $info['handle']); + } + } + } while ($active); + $retry++; + } while ($err != 0 && $retry < 10); + + foreach ($curl as $ch) { + \curl_multi_remove_handle($mh, $ch); + if (\curl_errno($ch) != 0) { + echo \curl_error($ch) . "\n"; + } + \curl_close($ch); + } + //\curl_multi_close($mh); + return true; +} + diff --git a/client/script/pecl.php b/client/script/pecl.php index 28e328a..cb32e00 100644 --- a/client/script/pecl.php +++ b/client/script/pecl.php @@ -152,8 +152,18 @@ foreach ($builds as $build_name) { $build_error++; } - /*rm\upload_build_result_ftp_curl($toupload_dir, $branch_name . '/r' . $last_rev);*/ + 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( array( -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
