X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=build%2Fcreate-phar.php;h=26ac6e93899ece94ad582c5fa6359e19be51cc97;hb=975b503f8cb6e5f4621057712edc3ff6273366c6;hp=c03ba8e2f3aac586a15256c57eb212be83ec700d;hpb=0ff7b26bce8f0dfbd1d4d45313705a94f2ac5e28;p=pharext%2Fpharext diff --git a/build/create-phar.php b/build/create-phar.php index c03ba8e..26ac6e9 100644 --- a/build/create-phar.php +++ b/build/create-phar.php @@ -4,24 +4,22 @@ * Creates bin/pharext, invoked through the Makefile */ -$pkguniq = uniqid(); -$pkgname = __DIR__."/../bin/pharext"; -$tmpname = "$pkgname.$pkguniq.phar.tmp"; +set_include_path(dirname(__DIR__)."/src:".get_include_path()); +spl_autoload_register(function($c) { + return include strtr($c, "\\_", "//") . ".php"; +}); -if (file_exists($tmpname)) { - if (!unlink($tmpname)) { - fprintf(STDERR, "%s\n", error_get_last()["message"]); - exit(3); - } -} - -$package = new \Phar($tmpname, 0, "pharext.phar"); -$package->buildFromDirectory(dirname(__DIR__)."/src", "/^.*\.php$/"); -$package->setDefaultStub("pharext_packager.php"); -$package->setStub("#!/usr/bin/php -dphar.readonly=0\n".$package->getStub()); -unset($package); +$file = (new pharext\Task\PharBuild(null, __DIR__."/../src/pharext_packager.php", pharext\Metadata::all() + [ + "name" => "pharext", + "license" => file_get_contents(__DIR__."/../LICENSE") +], false))->run(); -if (!rename($tmpname, $pkgname)) { - fprintf(STDERR, "%s\n", error_get_last()["message"]); - exit(4); +if (getenv("SIGN")) { + $pass = (new pharext\Task\Askpass)->run(); + $sign = new pharext\Task\PharSign($file, __DIR__."/pharext.key", $pass); + $pkey = $sign->run(); + $pkey->exportPublicKey(__DIR__."/../bin/pharext.pubkey"); } + +/* we do not need the extra logic of Task\PharRename */ +rename($file, __DIR__."/../bin/pharext");