From: Stig Bakken Date: Tue, 2 Apr 2002 09:21:48 +0000 (+0000) Subject: * Added "-s" (soft update) option to install/upgrade. Will make installs X-Git-Tag: php-4.3.0dev-ZendEngine2-Preview1~909 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d4dfead250bbb6b9718fa9f3021f1510019f2424;p=php * Added "-s" (soft update) option to install/upgrade. Will make installs fail silently. --- diff --git a/pear/PEAR/Command/Install.php b/pear/PEAR/Command/Install.php index cb75a30592..2bb4f167e3 100644 --- a/pear/PEAR/Command/Install.php +++ b/pear/PEAR/Command/Install.php @@ -77,10 +77,19 @@ class PEAR_Command_Install extends PEAR_Command_Common $ret[1] = "{$ret[1]}\n" . " -f forces the installation of the package\n". " when it is already installed\n". - " -n do not take care of package dependencies"; + " -n do not take care of package dependencies\n". + " -s soft update: install or upgrade only if needed"; return $ret; } + // }}} + // {{{ getOptions() + + function getOptions() + { + return array('f', 'n', 's'); + } + // }}} // {{{ run() @@ -89,6 +98,7 @@ class PEAR_Command_Install extends PEAR_Command_Common $installer = &new PEAR_Installer($this->config->get('php_dir'), $this->config->get('ext_dir'), $this->config->get('doc_dir')); + $installer->setFrontend($this->ui); $installer->debug = $this->config->get('verbose'); $failmsg = ''; @@ -99,6 +109,9 @@ class PEAR_Command_Install extends PEAR_Command_Common if (isset($options['n'])) { $opts['nodeps'] = true; } + if (isset($options['s'])) { + $opts['soft'] = true; + } switch ($command) { case 'upgrade': $opts['upgrade'] = true; @@ -130,11 +143,6 @@ class PEAR_Command_Install extends PEAR_Command_Common } // }}} - - function getOptions() - { - return array('f', 'n'); - } } ?> \ No newline at end of file diff --git a/pear/PEAR/Installer.php b/pear/PEAR/Installer.php index 0e9dbdaf19..d632449a9a 100644 --- a/pear/PEAR/Installer.php +++ b/pear/PEAR/Installer.php @@ -171,6 +171,7 @@ class PEAR_Installer extends PEAR_Common // recognized options: // - register_only : update registry but don't install files // - upgrade : upgrade existing install + // - soft : fail silently // if (empty($this->registry)) { $this->registry = new PEAR_Registry($this->phpdir); @@ -182,6 +183,9 @@ class PEAR_Installer extends PEAR_Common } elseif (!@is_file($pkgfile)) { if (preg_match('/^[A-Z][A-Za-z0-9_]+$/', $pkgfile)) { // valid package name + if ($this->registry->packageExists($pkgfile)) { + return $this->raiseError("$pkgfile already installed"); + } if ($config === null) { $pkgfile = "http://pear.php.net/get/$pkgfile"; } else { @@ -291,7 +295,9 @@ class PEAR_Installer extends PEAR_Common if (isset($pkginfo['release_deps']) && !isset($options['nodeps'])) { $error = $this->checkDeps($pkginfo); if ($error) { - $this->log(0, $error); + if (empty($options['soft'])) { + $this->log(0, $error); + } return $this->raiseError('Dependencies failed'); } }