+++ /dev/null
-#!/usr/bin/php
-<?php
-
-ini_set("display_errors", 0);
-ini_set("log_errors", 1);
-
-$procs = [];
-
-function check(&$procs) {
- foreach ($procs as $dir => list($prc, $fds, $pkg)) {
- $status = proc_get_status($prc);
- if (!$status["running"]) {
- array_map("fclose", $fds);
- proc_close($prc);
- if (!$status["exitcode"]) {
- printf("%s\t%s\n", $pkg, $dir);
- }
- unset($procs[$dir]);
- }
- }
- return count($procs);
-}
-
-while (!feof(STDIN)) {
- if (strlen($line = rtrim(fgets(STDIN)))) {
- if (list($pkg, $ver, $tgz) = explode("\t", $line)) {
- $dir = basename($tgz, ".tgz");
- $ext = sprintf("%s/../public/phars/%s/%s-%s.ext.phar", __DIR__, $pkg, $pkg, $ver);
-
- if (!is_file($ext)) {
- $prc = proc_open("tar -xf $tgz --transform='s#^package\\(2\\)\\{0,1\\}\\.xml$#$dir/package.xml#' 2>&1", [
- ["pipe","r"],STDERR
- ], $fds, __DIR__."/../build");
- $procs[$dir] = [$prc, $fds, $pkg];
- }
- check($procs);
- }
- }
-}
-
-while (check($procs)) {
- usleep(1000);
-}
+++ /dev/null
-#!/usr/bin/php
-<?php
-
-ini_set("display_errors", 0);
-ini_set("log_errors", 1);
-
-use http\Url;
-use http\Client;
-use http\Client\Request;
-
-$procs = [];
-$client = new Client;
-$client->setOptions([
- "timetout" => 60,
- "redirect" => 1,
- "connecttimeout" => 6
-]);
-
-while (!feof(STDIN)) {
- if (strlen($line = rtrim(fgets(STDIN)))) {
- if (list($pkg, $ver, $url) = explode("\t", $line)) {
- $url = new Url($url, null, 0);
- $skp = sprintf("%s/../build/%s-%s.skip", __DIR__, $pkg, $ver);
- $tgz = sprintf("%s/../build/%s-%s.tgz", __DIR__, $pkg, $ver);
- $ext = sprintf("%s/../public/phars/%s/%s-%s.ext.phar", __DIR__, $pkg, $pkg, $ver);
-
- if (is_file($skp)) {
- // skip
- } elseif (is_file($tgz) || is_file($ext)) {
- printf("%s\t%s\t%s\n", $pkg, $ver, $tgz);
- } else {
- $client->enqueue(new Request("GET", $url), function($res) use($tgz, $pkg, $ver) {
- $res->getBody()->toStream(fopen($tgz, "w"));
- printf("%s\t%s\t%s\n", $pkg, $ver, $tgz);
- return true;
- });
- }
- }
- }
-}
-
-while (count($client)) {
- try {
- $client->send();
- } catch (Exception $e) {
- error_log($e->getMessage());
- }
-}
+++ /dev/null
-#!/usr/bin/php
-<?php
-
-ini_set("display_errors", 0);
-ini_set("log_errors", 1);
-
-$procs = [];
-
-function check(&$procs) {
- foreach ($procs as $dir => list($prc, $fds, $pkg, $src, $dst)) {
- $status = proc_get_status($prc);
- if (!$status["running"]) {
- array_map("fclose", $fds);
- proc_close($prc);
- if ($status["exitcode"] || !is_file("$dst/$dir.ext.phar")) {
- touch("$src.skip");
- } else {
- printf("%s\t%s.ext.phar\n", $pkg, $dir);
- }
- system("rm -r $src.tgz $src");
- unset($procs[$dir]);
- }
- }
- return count($procs);
-}
-
-while (!feof(STDIN)) {
- if (strlen($line = rtrim(fgets(STDIN)))) {
- if (list($pkg, $dir) = explode("\t", $line)) {
- $src = __DIR__."/../build/$dir";
- $dst = __DIR__."/../public/phars/$pkg";
-
- if (!is_dir($dst) && !mkdir($dst, 0777, true)) {
- continue;
- }
-
- $prc = proc_open(__DIR__."/../vendor/bin/pharext -qps $src -zZd $dst 2>&1", [
- ["pipe","r"],STDERR
- ], $fds
- );
- $procs[$dir] = [$prc, $fds, $pkg, $src, $dst];
- check($procs);
- }
- }
-}
-
-while (check($procs)) {
- usleep(1000);
-}
-#!/usr/bin/php
+#!/usr/bin/php -dphar.readonly=0
<?php
ini_set("display_errors", 0);
ini_set("log_errors", 1);
$what = !empty($argv[1]) ? $argv[1] : "latest";
+$pids = [];
+
+function fail($pkg, $ver, $skp, $fmt) {
+ $msg = call_user_func_array("sprintf", array_slice(func_get_args(), 3));
+ fprintf(STDERR, "FAILURE: %s-%s, %s; skipping next time\n", $pkg, $ver, $msg);
+ touch($skp);
+}
+
+function wait(&$pids) {
+ $status = null;
+ switch ($pid = pcntl_wait($status)) {
+ case -1:
+ // meh
+ break;
+ default:
+ extract($pids[$pid]);
+ unset($pids[$pid]);
+ if (pcntl_wifexited($status) && ($rc = pcntl_wexitstatus($status))) {
+ fail($pkg, $ver, $skp, "exit code: %d", $rc);
+ } elseif (pcntl_wifsignaled($status) && ($rc = pcntl_wtermsig($status))) {
+ fail($pkg, $ver, $skp, "signal: %d", $rc);
+ } else {
+ printf("SUCCESS: %s-%s\n", $pkg, $ver);
+ }
+ break;
+ }
+ return $pid > 0;
+};
+
+function work($url, $dir) {
+ is_dir($dir) || mkdir($dir, 0777, true);
+ require_once __DIR__."/../vendor/autoload.php";
+ $packager = new pharext\Packager;
+ $packager->run(5, [
+ $_SERVER["argv"][0],
+ "-qps",
+ $url,
+ "-Zzd",
+ $dir
+ ]);
+};
if (($sxe = simplexml_load_file("http://pecl.php.net/feeds/$what.rss"))) {
foreach ($sxe->item as $item) {
$url = (string) $item->link;
- printf("%s\t%s\t%s\n", basename(dirname($url)), basename($url), $url);
+ $pkg = basename(dirname($url));
+ $ver = basename($url);
+ $skp = sprintf("%s/../build/%s-%s.skip", __DIR__, $pkg, $ver);
+ $ext = sprintf("%s/../public/phars/%s/%s-%s.ext.phar", __DIR__, $pkg, $pkg, $ver);
+ $dir = dirname($ext);
+
+ if (!is_file($skp) && !is_file($ext)) {
+ switch ($pid = pcntl_fork()) {
+ case -1:
+ exit;
+ case 0:
+ work($url, $dir);
+ exit;
+ default:
+ $pids[$pid] = compact("url", "pkg", "ver", "skp", "ext", "dir");
+ break;
+ }
+ }
+
+ if (count($pids) > 5) {
+ wait($pids);
+ }
}
+ while (wait($pids))
+ ;
+
}
+
+
{
"require": {
- "m6w6/pharext": "~3.0",
+ "m6w6/pharext": "^4.0",
"concisecss/concise.css": "~2.1"
- }
+ },
+ "autoload": {
+ "psr-0": {
+ "pharext": "vendor/m6w6/pharext/src"
+ }
+ }
}
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "hash": "d612932710d4d8912e7fdabc8f15eefc",
+ "hash": "6536f75724f1b6738b441c05cd7d65e5",
"packages": [
{
"name": "concisecss/concise.css",
},
{
"name": "m6w6/pharext",
- "version": "v3.0.1",
+ "version": "v4.0.0",
"source": {
"type": "git",
"url": "https://github.com/m6w6/pharext.git",
- "reference": "3dcc326aa922ce4b70d07049572c6f15a744869c"
+ "reference": "d017df1dcb270773804bbed4628397a9c7df30c4"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/m6w6/pharext/zipball/3dcc326aa922ce4b70d07049572c6f15a744869c",
- "reference": "3dcc326aa922ce4b70d07049572c6f15a744869c",
+ "url": "https://api.github.com/repos/m6w6/pharext/zipball/d017df1dcb270773804bbed4628397a9c7df30c4",
+ "reference": "d017df1dcb270773804bbed4628397a9c7df30c4",
"shasum": ""
},
"bin": [
"package",
"phar"
],
- "time": "2015-04-08 10:17:40"
+ "time": "2015-05-20 06:39:24"
}
],
"packages-dev": [],