From: Michael Wallner Date: Fri, 13 Mar 2015 20:36:38 +0000 (+0100) Subject: initial commit X-Git-Url: https://git.m6w6.name/?p=m6w6%2Freplicator;a=commitdiff_plain;h=bfae1cb655977d9990d555b297c791b276ef0453 initial commit --- bfae1cb655977d9990d555b297c791b276ef0453 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9c3ad39 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +/nbproject/ +build/replicator.key +*~ +tmp* +*.tmp +public/phars/* +!public/phars/.gitkeep +build/* +!build/.gitkeep +vendor diff --git a/README.md b/README.md new file mode 100644 index 0000000..3f66d63 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Replicator + +Packages latest PECL releases with [pharext](https://github.com/m6w6/pharext) diff --git a/bin/extract b/bin/extract new file mode 100755 index 0000000..21a08b1 --- /dev/null +++ b/bin/extract @@ -0,0 +1,43 @@ +#!/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 new file mode 100755 index 0000000..0523c96 --- /dev/null +++ b/bin/fetch @@ -0,0 +1,47 @@ +#!/usr/bin/php +setOptions([ + "timetout" => 60, + "connecttimeout" => 6 +]); + +while (!feof(STDIN)) { + if (strlen($url = rtrim(fgets(STDIN)))) { + $url = new Url($url, null, 0); + $ver = basename($url->path); + $pkg = basename(dirname($url->path)); + $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/latest b/bin/latest new file mode 100755 index 0000000..7fa187e --- /dev/null +++ b/bin/latest @@ -0,0 +1,11 @@ +#!/usr/bin/php +item as $item) { + printf("%s\n", $item->link); + } +} diff --git a/bin/package b/bin/package new file mode 100755 index 0000000..ca90de2 --- /dev/null +++ b/bin/package @@ -0,0 +1,49 @@ +#!/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/build/.gitkeep b/build/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..4789533 --- /dev/null +++ b/composer.json @@ -0,0 +1,6 @@ +{ + "require": { + "m6w6/pharext": "~2.0", + "concisecss/concise.css": "~2.1" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..c462fdd --- /dev/null +++ b/composer.lock @@ -0,0 +1,94 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "2ababbd1d8bcdc4e489021e43199b3ee", + "packages": [ + { + "name": "concisecss/concise.css", + "version": "v2.1.0", + "source": { + "type": "git", + "url": "https://github.com/ConciseCSS/concise.css.git", + "reference": "1e093f3c26b13e08d1cb1836088fa0752db0af31" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ConciseCSS/concise.css/zipball/1e093f3c26b13e08d1cb1836088fa0752db0af31", + "reference": "1e093f3c26b13e08d1cb1836088fa0752db0af31", + "shasum": "" + }, + "replace": { + "concisecss/concise.css": "self.version" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Keenan Payne", + "email": "contact@keenanpayne.com" + } + ], + "description": "A lightweight front-end framework that provides functionality without the bloat.", + "homepage": "http://concisecss.com", + "keywords": [ + "JS", + "css", + "framework", + "front-end", + "mobile-first", + "responsive", + "sass", + "scss", + "web" + ], + "time": "2015-02-17 06:23:04" + }, + { + "name": "m6w6/pharext", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/m6w6/pharext.git", + "reference": "e3ff870fe1f8a3b3eb8f55eea68f6f61d99e640c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/m6w6/pharext/zipball/e3ff870fe1f8a3b3eb8f55eea68f6f61d99e640c", + "reference": "e3ff870fe1f8a3b3eb8f55eea68f6f61d99e640c", + "shasum": "" + }, + "bin": [ + "bin/pharext", + "bin/pharext.pubkey" + ], + "type": "project", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "description": "Package PHP extensions as self-installing PHARs", + "keywords": [ + "ext", + "extension", + "install", + "package", + "phar" + ], + "time": "2015-03-10 10:38:16" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} diff --git a/public/concise b/public/concise new file mode 120000 index 0000000..ef949cf --- /dev/null +++ b/public/concise @@ -0,0 +1 @@ +../vendor/concisecss/concise.css/dist \ No newline at end of file diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..7918e92 --- /dev/null +++ b/public/index.php @@ -0,0 +1,127 @@ + + + + + Replicator + + + + + + +
+
+

+ Replicator
+ Replicating PECL releases as pharext packages since 2015 +

+
+
+
+ + + + +

+ + + + + + + + + + + + + + + + + +
PackageDateSize
+ + "today", "yesterday"]; + do { + for ($i = 1; $i < 7; ++$i) { + if ($lmod > $time - $dsec * $i) { + switch ($i) { + case 1: + echo "today"; + break 3; + case 2: + echo "yesterday"; + break 3; + default: + echo "$i days ago"; + break 3; + } + } + } + echo date("Y-m-d", $lmod); + } while (false); + + ?> + + +
+ + +

Available Packages

+ + + + +
+ + diff --git a/public/phars/.gitkeep b/public/phars/.gitkeep new file mode 100644 index 0000000..e69de29