From 920838364f437f686b2de6e210ad846f85a67128 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Fri, 1 Apr 2016 16:12:40 +0200 Subject: [PATCH] use separate skip dir --- .gitignore | 2 ++ bin/pecl | 2 +- public/mirror.php | 70 ----------------------------------------------- skip/.gitkeep | 0 4 files changed, 3 insertions(+), 71 deletions(-) delete mode 100644 public/mirror.php create mode 100644 skip/.gitkeep diff --git a/.gitignore b/.gitignore index 9c3ad39..27c8379 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,6 @@ public/phars/* !public/phars/.gitkeep build/* !build/.gitkeep +skip/* +!skip/.gitkeep vendor diff --git a/bin/pecl b/bin/pecl index 296c803..a696acb 100755 --- a/bin/pecl +++ b/bin/pecl @@ -59,7 +59,7 @@ if (($sxe = simplexml_load_file("http://pecl.php.net/feeds/$what.rss"))) { $url = (string) $item->link; $pkg = basename(dirname($url)); $ver = basename($url); - $skp = sprintf("%s/../build/%s-%s.skip", __DIR__, $pkg, $ver); + $skp = sprintf("%s/../skip/%s/%s", __DIR__, $pkg, $ver); $ext = sprintf("%s/../public/phars/%s/%s-%s.ext.phar", __DIR__, $pkg, $pkg, $ver); $dir = dirname($ext); diff --git a/public/mirror.php b/public/mirror.php deleted file mode 100644 index 27f3c61..0000000 --- a/public/mirror.php +++ /dev/null @@ -1,70 +0,0 @@ -setResponseCode(500); -ob_start($response); - -$owners = explode(",", getenv("owners") ?: "m6w6"); -$mirror = getenv("mirror") ?: "/var/github"; -$secret = getenv("secret") ?: trim(file_get_contents("$mirror/.secret")); - -$sig = $request->getHeader("X-Hub-Signature"); -$evt = $request->getHeader("X-Github-Event"); - -if (!$sig || !$evt) { - $response->setResponseCode(400); - $response->setContentType("message/http"); - $response->getBody()->append($request); - return $response->send(); -} - -foreach ((new Params($sig))->params as $algo => $mac) { - if ($mac["value"] !== hash_hmac($algo, $request->getBody(), $secret)) { - $response->setResponseCode(403); - $response->getBody()->append("Invalid signature"); - return $response->send(); - } -} - -switch ($evt) { - default: - $response->setResponseCode(202); - $response->getBody()->append("Not a configured event"); - break; - case "ping"; - case "push": - if (!($json = json_decode($request->getBody()))) { - $response->setResponseCode(415); - $response->setContentType($request->getHeader("Content-Type")); - $response->getBody()->append($request->getBody()); - } elseif (!in_array(isset($json->repository->owner->name)?$json->repository->owner->name:$json->repository->owner->login, $owners, true)) { - $response->setResponseCode(403); - $response->getBody()->append("Invalid owner"); - } else { - $repo = $json->repository->full_name; - $path = $mirror . "/" . $repo; - if (is_dir($path) && chdir($path)) { - passthru("git fetch -vp 2>&1", $rv); - if ($rv == 0) { - $response->setResponseCode(200); - } - } elseif (mkdir($path, 0755, true) && chdir($path)) { - $source = escapeshellarg($json->repository->clone_url); - $description = escapeshellarg($json->repository->description); - passthru("git clone --mirror $source . 2>&1", $rv); - passthru("git config gitweb.description $description 2>&1"); - unlink("description"); - if ($rv == 0) { - $response->setResponseCode(200); - } - } - } - break; -} - -$response->send(); diff --git a/skip/.gitkeep b/skip/.gitkeep new file mode 100644 index 0000000..e69de29 -- 2.30.2