296c8036c5f1753c070ea98c16b64adf355132b0
1 #!/usr/bin/php -dphar.readonly=0
4 ini_set("display_errors", 0);
5 ini_set("log_errors", 1);
7 /* needed for the packager, so the pharstub task can find includes */
8 set_include_path(__DIR__
."/../vendor/m6w6/pharext/src:".get_include_path());
10 $what = !empty($argv[1]) ?
$argv[1] : "latest";
13 function fail($pkg, $ver, $skp, $fmt) {
14 $msg = call_user_func_array("sprintf", array_slice(func_get_args(), 3));
15 fprintf(STDERR
, "FAILURE: %s-%s, %s; skipping next time\n", $pkg, $ver, $msg);
19 function wait(&$pids) {
21 switch ($pid = pcntl_wait($status)) {
28 if (pcntl_wifexited($status) && ($rc = pcntl_wexitstatus($status))) {
29 fail($pkg, $ver, $skp, "exit code: %d", $rc);
30 } elseif (pcntl_wifsignaled($status) && ($rc = pcntl_wtermsig($status))) {
31 fail($pkg, $ver, $skp, "signal: %d", $rc);
33 printf("SUCCESS: %s-%s\n", $pkg, $ver);
34 /* create skipfile, ensuring we do not build a package with
35 * different name in registry/package.xml again
44 function work($url, $dir) {
45 is_dir($dir) ||
mkdir($dir, 0777, true);
46 require_once __DIR__
."/../vendor/autoload.php";
47 $packager = new pharext\Packager
;
57 if (($sxe = simplexml_load_file("http://pecl.php.net/feeds/$what.rss"))) {
58 foreach ($sxe->item
as $item) {
59 $url = (string) $item->link
;
60 $pkg = basename(dirname($url));
61 $ver = basename($url);
62 $skp = sprintf("%s/../build/%s-%s.skip", __DIR__
, $pkg, $ver);
63 $ext = sprintf("%s/../public/phars/%s/%s-%s.ext.phar", __DIR__
, $pkg, $pkg, $ver);
66 if (!is_file($skp) && !is_file($ext)) {
67 switch ($pid = pcntl_fork()) {
74 $pids[$pid] = compact("url", "pkg", "ver", "skp", "ext", "dir");
79 if (count($pids) > 5) {