4 * Creates bin/pharext, invoked through the Makefile
7 $pkgname = __DIR__
."/../bin/pharext";
8 $tmpname = __DIR__
."/pharext.phar";
10 if (file_exists($tmpname)) {
11 if (!unlink($tmpname)) {
12 fprintf(STDERR
, "%s\n", error_get_last()["message"]);
17 $package = new \
Phar($tmpname, 0, "pharext.phar");
20 shell_exec("stty -echo");
22 $password = fgets(STDIN
, 1024);
24 shell_exec("stty echo");
25 if (substr($password, -1) == "\n") {
26 $password = substr($password, 0, -1);
29 $pkey = openssl_pkey_get_private("file://".__DIR__
."/pharext.key", $password);
30 if (!is_resource($pkey)) {
31 $this->error("Could not load private key %s/pharext.key", __DIR__
);
34 if (!openssl_pkey_export($pkey, $key)) {
39 $package->setSignatureAlgorithm(Phar
::OPENSSL
, $key);
42 $package->buildFromDirectory(dirname(__DIR__
)."/src", "/^.*\.php$/");
43 $package->setDefaultStub("pharext_packager.php");
44 $package->setStub("#!/usr/bin/php -dphar.readonly=0\n".$package->getStub());
47 if (!rename($tmpname, $pkgname)) {
48 fprintf(STDERR
, "%s\n", error_get_last()["message"]);