- $package = new Phar($pkgtemp, 0, "ext.phar");
- $package->startBuffering();
- $package->buildFromIterator($this->source, $this->source->getBaseDir());
- $package->buildFromIterator($this->bundle());
- $package->addFile(__DIR__."/../pharext_installer.php", "pharext_installer.php");
- $package->setDefaultStub("pharext_installer.php");
- $package->setStub("#!/usr/bin/php -dphar.readonly=1\n".$package->getStub());
- $package->stopBuffering();
-
- chmod($pkgtemp, 0770);
- if ($this->args->verbose) {
- $this->info("Created executable phar %s\n", $pkgtemp);
- } else {
- $this->info("OK\n");
+ $meta = array_merge($this->metadata(), [
+ "date" => date("Y-m-d"),
+ "name" => $this->args->name,
+ "release" => $this->args->release,
+ "license" => @file_get_contents(current(glob($this->source->getBaseDir()."/LICENSE*"))),
+ "stub" => "pharext_installer.php",
+ "type" => $this->args->zend ? "zend_extension" : "extension",
+ ]);
+ $file = (new Task\PharBuild($this->source, $meta))->run($this->verbosity());
+ } catch (\Exception $e) {
+ $this->error("%s\n", $e->getMessage());
+ exit(self::EBUILD);
+ }
+
+ try {
+ if ($this->args->sign) {
+ $this->info("Using private key to sign phar ...\n");
+ $pass = (new Task\Askpass)->run($this->verbosity());
+ $sign = new Task\PharSign($file, $this->args->sign, $pass);
+ $pkey = $sign->run($this->verbosity());