Fix atom checking on validation of packages v2.1.14
authorMike Pagano <mpagano@gentoo.org>
Thu, 14 Aug 2014 00:12:28 +0000 (20:12 -0400)
committerMike Pagano <mpagano@gentoo.org>
Thu, 14 Aug 2014 00:12:28 +0000 (20:12 -0400)
portpeek

index f96f5e0..10609d0 100755 (executable)
--- a/portpeek
+++ b/portpeek
@@ -16,7 +16,7 @@
 
 __author__ = "Michael Pagano"
 __email__ = "mpagano@gentoo.org"
-__version__ = "2.1.13"
+__version__ = "2.1.14"
 __productname__ = "portpeek"
 __description__ = "Displays user unmasked ebuilds and installable options from the portage tree"
 
@@ -471,6 +471,8 @@ def parse_package_use(line, filename):
     diffs_found = False
     package_installed = False
     fields = line.replace("\t", " ").split(" ")
+    less_than = False
+    less_than_or_equal = False
 
     if len(fields) > 0:
         check_pkg = fields[0] # this could be one of <>=
@@ -478,6 +480,11 @@ def parse_package_use(line, filename):
         if check_pkg[0] not in atom_check:
             has_atom = False
         else:
+            if check_pkg[0] == '<':
+                less_than = True;
+                if check_pkg[1] == '=':
+                    less_than_or_equal = True
+
             check_pkg = check_pkg[1:]
             if check_pkg[0] in atom_check:
                 check_pkg = check_pkg[1:]
@@ -501,6 +508,42 @@ def parse_package_use(line, filename):
                 if current_package.is_installed():
                     check_useflags(current_package,line)
                     return False
+        
+        if ((orig_pkg_name.find("<=") >=0) or (orig_pkg_name.find("<")>=0) or (orig_pkg_name.find(">=") >=0) or (orig_pkg_name.find(">") >=0)):
+            query = Query(check_pkg)
+            pkgs = []
+            try:
+                pkgs = query.smart_find(True,True,True,True,False,True)
+            except errors.GentoolkitException as err:
+                print_output(debug,portage.output.blue("parse_package_use: Package " + check_pkg + " not found."))
+                return False
+
+            if (pkgs != None):
+                pkg_length = len(pkgs)
+            for current_package in pkgs:
+                # on wildcard scenario, return False if one package is installed
+                if (orig_pkg_name.find("<=") >=0):
+                    if (pkgcmp(pkgsplit(check_pkg),pkgsplit(str(current_package.cpv))) <= 0):
+                        if current_package.is_installed():
+                            check_useflags(current_package,line)
+                        return False
+                else:
+                    if (orig_pkg_name.find("<") >=0):
+                        if (pkgcmp(pkgsplit(check_pkg),pkgsplit(str(current_package.cpv))) < 0):
+                            if current_package.is_installed():
+                                check_useflags(current_package,line)
+                            return False
+                if (orig_pkg_name.find(">=") >=0):
+                    if (pkgcmp(pkgsplit(check_pkg),pkgsplit(str(current_package.cpv))) == 0) or (pkgcmp(pkgsplit(check_pkg),pkgsplit(str(current_package.cpv))) == 2):
+                        if current_package.is_installed():
+                            check_useflags(current_package,line)
+                        return False
+                else:
+                    if (orig_pkg_name.find(">") >=0):
+                        if (pkgcmp(pkgsplit(check_pkg),pkgsplit(str(current_package.cpv))) == 2):
+                            if current_package.is_installed():
+                                check_useflags(current_package,line)
+                            return False
         else:
             # look for any version of check_pkg installed as there is 
             # no version specified in package.use
@@ -570,7 +613,7 @@ def parse_package_use(line, filename):
 
     if (package_installed == False):
         # package does not exists
-        print_output(info,portage.output.yellow("\n" + check_pkg + ": ") + portage.output.red("Not Installed"),current_package)
+        print_output(info,portage.output.yellow("\n" + orig_pkg_name + ": ") + portage.output.red(" Not Installed"),current_package)
         if "package.keywords" in filename:
             stable_list.append(check_pkg)
         if "package.accept_keywords" in filename: