X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Fpharext%2FInstaller.php;h=a90eb28e9acc97350465be252d22d20589568a3d;hb=337e76964be2ed6724633ac477affc3a28426c97;hp=60ca2262ce7316c76c1d911d283dec549fcfadd7;hpb=23b4f263e68ae8d0a34292ed6215350483fe8451;p=pharext%2Fpharext diff --git a/src/pharext/Installer.php b/src/pharext/Installer.php index 60ca226..a90eb28 100644 --- a/src/pharext/Installer.php +++ b/src/pharext/Installer.php @@ -15,6 +15,12 @@ class Installer implements Command { use CliCommand; + /** + * Cleanups + * @var array + */ + private $cleanup = []; + /** * Create the command */ @@ -53,9 +59,19 @@ class Installer implements Command ]); } + /** + * Perform cleaniup + */ + function __destruct() { + foreach ($this->cleanup as $cleanup) { + $cleanup->run(); + } + } + private function extract(Phar $phar) { - $this->debug("Extracting %s ...\n", basename($phar->getPath())); - return (new Task\Extract($phar))->run($this->verbosity()); + $temp = (new Task\Extract($phar))->run($this->verbosity()); + $this->cleanup[] = new Task\Cleanup($temp); + return $temp; } private function hooks(SplObjectStorage $phars) { @@ -162,7 +178,6 @@ class Installer implements Command $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) { @@ -176,31 +191,23 @@ class Installer implements Command */ private function install($temp) { // phpize - $this->info("Running phpize ...\n"); $phpize = new Task\Phpize($temp, $this->args->prefix, $this->args->{"common-name"}); $phpize->run($this->verbosity()); // configure - $this->info("Running configure ...\n"); $configure = new Task\Configure($temp, $this->args->configure, $this->args->prefix, $this->args{"common-name"}); $configure->run($this->verbosity()); // make - $this->info("Running make ...\n"); $make = new Task\Make($temp); $make->run($this->verbosity()); // 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->verbosity()); } - private function cleanup($temp) { - (new Task\Cleanup($temp))->run(); - } - private function activate($temp) { if ($this->args->ini) { $files = [realpath($this->args->ini)]; @@ -212,7 +219,6 @@ class Installer implements Command $sudo = isset($this->args->sudo) ? $this->args->sudo : null; $type = $this->metadata("type") ?: "extension"; - $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->verbosity())) { $this->info("Extension already activated ...\n");