]> granicus.if.org Git - php/commitdiff
* fix up package dependency check
authorStig Bakken <ssb@php.net>
Sun, 12 May 2002 14:53:54 +0000 (14:53 +0000)
committerStig Bakken <ssb@php.net>
Sun, 12 May 2002 14:53:54 +0000 (14:53 +0000)
pear/PEAR/Dependency.php

index 3fc035ee9b47fbb1126435aef4bdbde87f786c65..3b6f6a76843c50ded59bfec4e4cf097ef337b39f 100644 (file)
@@ -75,7 +75,7 @@ class PEAR_Dependency
                 return $this->checkSAPI($name);
                 break;
             default:
-                return "'{$opts['type']}' dependencie type not supported";
+                return "'{$opts['type']}' dependency type not supported";
         }
     }
 
@@ -90,21 +90,30 @@ class PEAR_Dependency
      */
     function checkPackage($name, $req = null, $relation = 'has')
     {
-        if (!$this->registry->packageExists($name)) {
-            return "'$name' PEAR package is not installed";
-        }
-        if (substr($relation, 0, 2) == 'v.') {
-            $pkg_ver = $this->registry->packageInfo($name, 'version');
-            $operator = substr($relation, 2);
-            if (!version_compare($pkg_ver, $req, $operator)) {
-                return "'$name' PEAR package version " .
-                        $this->signOperator($operator) . " $req is required";
-            }
-            return false;
-        } elseif ($relation == 'has') {
-            return false;
+        switch ($relation) {
+            case 'has':
+                if (!$this->registry->packageExists($name)) {
+                    return "requires package `$name'";
+                }
+                return false;
+            case 'not':
+                if (!$this->registry->packageExists($name)) {
+                    return "conflicts with package `$name'";
+                }
+                return false;
+            case 'lt':
+            case 'le':
+            case 'eq':
+            case 'ne':
+            case 'ge':
+            case 'gt':
+                $version = $this->registry->packageInfo($name, 'version');
+                if (!version_compare($version, $req, $relation)) {
+                    return "requires package `$name' " .
+                        $this->signOperator($relation) . " $req";
+                }
         }
-        return "Relation '$relation' with requirement '$req' is not supported";
+        return "Relation '$relation' with requirement '$req' is not supported (name=$name)";
     }
 
     /**