]> granicus.if.org Git - php/commitdiff
* Added "-s" (soft update) option to install/upgrade. Will make installs
authorStig Bakken <ssb@php.net>
Tue, 2 Apr 2002 09:21:48 +0000 (09:21 +0000)
committerStig Bakken <ssb@php.net>
Tue, 2 Apr 2002 09:21:48 +0000 (09:21 +0000)
  fail silently.

pear/PEAR/Command/Install.php
pear/PEAR/Installer.php

index cb75a30592c2ac310bbb2ad6bd75fb5363a56f57..2bb4f167e3ac174b0a0b2a8b0e00dc29d862e674 100644 (file)
@@ -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
index 0e9dbdaf191e03021ced5316d2eb7653ef7e918e..d632449a9a220baa3d857689a1dd3382b3b98b70 100644 (file)
@@ -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');
             }
         }