From: Michael Wallner Date: Wed, 20 May 2015 07:11:35 +0000 (+0200) Subject: upgrade to pharext v4 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=4b2d3b750ceede9838bcf04040db6a7eacb253fe;p=m6w6%2Freplicator upgrade to pharext v4 --- diff --git a/bin/extract b/bin/extract deleted file mode 100755 index 21a08b1..0000000 --- a/bin/extract +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/php - 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); -} diff --git a/bin/fetch b/bin/fetch deleted file mode 100755 index c55e785..0000000 --- a/bin/fetch +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/php -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()); - } -} diff --git a/bin/package b/bin/package deleted file mode 100755 index ca90de2..0000000 --- a/bin/package +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/php - 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); -} diff --git a/bin/pecl b/bin/pecl index d6d5e9e..ef215ad 100755 --- a/bin/pecl +++ b/bin/pecl @@ -1,14 +1,81 @@ -#!/usr/bin/php +#!/usr/bin/php -dphar.readonly=0 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)) + ; + } + + diff --git a/composer.json b/composer.json index 3c23487..334a105 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,11 @@ { "require": { - "m6w6/pharext": "~3.0", + "m6w6/pharext": "^4.0", "concisecss/concise.css": "~2.1" - } + }, + "autoload": { + "psr-0": { + "pharext": "vendor/m6w6/pharext/src" + } + } } diff --git a/composer.lock b/composer.lock index ea9e938..5a09ce9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "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", @@ -51,16 +51,16 @@ }, { "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": [ @@ -80,7 +80,7 @@ "package", "phar" ], - "time": "2015-04-08 10:17:40" + "time": "2015-05-20 06:39:24" } ], "packages-dev": [],