X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Fpharext%2FInstaller.php;h=83a40ad9769d4babb16dfd063c27d10f3dd6d5f0;hb=d829063e596c6fffc4c30fb30f6d462ac9ba2928;hp=10486d2d69ceb0b9293c7abe1b1d8b3e982c2481;hpb=34284101c2aa60ec1e824a54de543148aaa28b58;p=pharext%2Fpharext diff --git a/src/pharext/Installer.php b/src/pharext/Installer.php index 10486d2..83a40ad 100644 --- a/src/pharext/Installer.php +++ b/src/pharext/Installer.php @@ -38,12 +38,14 @@ class Installer implements Command "sudo -S %s"], ["i", "ini", "Activate in this php.ini instead of loaded default php.ini", CliArgs::OPTIONAL|CliArgs::SINGLE|CliArgs::REQARG], - [null, "signature", "Dump package signature", + [null, "signature", "Show package signature", CliArgs::OPTIONAL|CliArgs::SINGLE|CliArgs::NOARG|CliArgs::HALT], [null, "license", "Show package license", CliArgs::OPTIONAL|CliArgs::SINGLE|CliArgs::NOARG|CliArgs::HALT], [null, "name", "Show package name", CliArgs::OPTIONAL|CliArgs::SINGLE|CliArgs::NOARG|CliArgs::HALT], + [null, "date", "Show package release date", + CliArgs::OPTIONAL|CliArgs::SINGLE|CliArgs::NOARG|CliArgs::HALT], [null, "release", "Show package release version", CliArgs::OPTIONAL|CliArgs::SINGLE|CliArgs::NOARG|CliArgs::HALT], [null, "version", "Show pharext version", @@ -74,22 +76,27 @@ class Installer implements Command * @see \pharext\Command::run() */ public function run($argc, array $argv) { - $list = new SplObjectStorage(); - $phar = new Phar(Phar::running(false)); - $temp = $this->extract($phar); - - foreach ($phar as $entry) { - $dep_file = $entry->getBaseName(); - if (fnmatch("*.ext.phar*", $dep_file)) { - $dep_phar = new Phar("$temp/$dep_file"); - $list[$dep_phar] = $this->extract($dep_phar); + try { + $list = new SplObjectStorage(); + $phar = new Phar(Phar::running(false)); + $temp = $this->extract($phar); + + foreach ($phar as $entry) { + $dep_file = $entry->getBaseName(); + if (fnmatch("*.ext.phar*", $dep_file)) { + $dep_phar = new Phar("$temp/$dep_file"); + $list[$dep_phar] = $this->extract($dep_phar); + } } - } - /* the actual ext.phar at last */ - $list[$phar] = $temp; + /* the actual ext.phar at last */ + $list[$phar] = $temp; - /* installer hooks */ - $hook = $this->hooks($list); + /* installer hooks */ + $hook = $this->hooks($list); + } catch (\Exception $e) { + $this->error("%s\n", $e->getMessage()); + exit(self::EEXTRACT); + } /* standard arg stuff */ $errs = []; @@ -104,7 +111,7 @@ class Installer implements Command exit; } try { - foreach (["signature", "name", "license", "release", "version"] as $opt) { + foreach (["signature", "name", "date", "license", "release", "version"] as $opt) { if ($this->args[$opt]) { printf("%s\n", $this->metadata($opt)); exit; @@ -112,7 +119,7 @@ class Installer implements Command } } catch (\Exception $e) { $this->error("%s\n", $e->getMessage()); - exit(2); + exit(self::EARGS); } foreach ($this->args->validate() as $error) { @@ -129,23 +136,33 @@ class Installer implements Command if (!$this->args["quiet"]) { $this->help($prog); } - exit(1); + exit(self::EARGS); } - /* post process hooks */ - foreach ($hook as $callback) { - if (is_callable($callback)) { - $callback($this); + try { + /* post process hooks */ + foreach ($hook as $callback) { + if (is_callable($callback)) { + $callback($this); + } } + } catch (\Exception $e) { + $this->error("%s\n", $e->getMessage()); + exit(self::EARGS); } /* install packages */ - foreach ($list as $phar) { - $this->info("Installing %s ...\n", basename($phar->getPath())); - $this->install($list[$phar]); - $this->activate($list[$phar]); - $this->cleanup($list[$phar]); - $this->info("Successfully installed %s!\n", basename($phar->getPath())); + try { + foreach ($list as $phar) { + $this->info("Installing %s ...\n", basename($phar->getPath())); + $this->install($list[$phar]); + $this->activate($list[$phar]); + $this->cleanup($list[$phar]); + $this->info("Successfully installed %s!\n", basename($phar->getPath())); + } + } catch (\Exception $e) { + $this->error("%s\n", $e->getMessage()); + exit(self::EINSTALL); } } @@ -153,32 +170,26 @@ class Installer implements Command * Phpize + trinity */ private function install($temp) { - try { - // phpize - $this->info("Running phpize ...\n"); - $phpize = new Task\Phpize($temp, $this->args->prefix, $this->args->{"common-name"}); - $phpize->run($this->args->verbose); - - // configure - $this->info("Running configure ...\n"); - $configure = new Task\Configure($temp, $this->args->configure, $this->args->prefix, $this->args{"common-name"}); - $configure->run($this->args->verbose); - - // make - $this->info("Running make ...\n"); - $make = new Task\Make($temp); - $make->run($this->args->verbose); - - // install - $this->info("Running make install ...\n"); - $sudo = isset($this->args->sudo) ? $this->args->sudo : null; - $install = new Task\Make($temp, ["install"], $sudo); - $install->run($this->args->verbose); - - } catch (\Exception $e) { - $this->error("%s\n", $e->getMessage()); - exit(2); - } + // phpize + $this->info("Running phpize ...\n"); + $phpize = new Task\Phpize($temp, $this->args->prefix, $this->args->{"common-name"}); + $phpize->run($this->args->verbose); + + // configure + $this->info("Running configure ...\n"); + $configure = new Task\Configure($temp, $this->args->configure, $this->args->prefix, $this->args{"common-name"}); + $configure->run($this->args->verbose); + + // make + $this->info("Running make ...\n"); + $make = new Task\Make($temp); + $make->run($this->args->verbose); + + // install + $this->info("Running make install ...\n"); + $sudo = isset($this->args->sudo) ? $this->args->sudo : null; + $install = new Task\Make($temp, ["install"], $sudo); + $install->run($this->args->verbose); } private function cleanup($temp) { @@ -198,17 +209,12 @@ class Installer implements Command } $sudo = isset($this->args->sudo) ? $this->args->sudo : null; - $type = $this->metadata("type") ?: "php"; + $type = $this->metadata("type") ?: "extension"; - try { - $this->info("Running INI activation ...\n"); - $activate = new Task\Activate($temp, $files, $type, $this->args->prefix, $this->args{"common-name"}, $sudo); - if (!$activate->run($this->args->verbose)) { - $this->info("Extension already activated ...\n"); - } - } catch (\Exception $e) { - $this->error("%s\n", $e->getMessage()); - exit(3); + $this->info("Running INI activation ...\n"); + $activate = new Task\Activate($temp, $files, $type, $this->args->prefix, $this->args{"common-name"}, $sudo); + if (!$activate->run($this->args->verbose)) { + $this->info("Extension already activated ...\n"); } } }