Clean up getportageversion() profile logic and fix a ValueError that occurs when...
authorZac Medico <zmedico@gentoo.org>
Thu, 6 Jul 2006 16:40:01 +0000 (16:40 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 6 Jul 2006 16:40:01 +0000 (16:40 -0000)
svn path=/main/trunk/; revision=3798

bin/emerge

index 1fd46d019d8aa86bc579931a30f86ceb12d72074..b5f203cb07f40c3abf9f6faf8ab2c3456dcd48a7 100755 (executable)
@@ -311,17 +311,19 @@ def getgccversion(chost):
        return "[unavailable]"
 
 def getportageversion(portdir, target_root, profile, chost, vardb):
-       try:
-               import re
-               profilever = os.path.normpath("///"+os.readlink(profile))
-               basepath   = os.path.normpath("///" + portdir + "/profiles")
-               if re.match(basepath,profilever):
-                       profilever = profilever[len(basepath)+1:]
+       profilever = "unavailable"
+       if profile:
+               realpath = os.path.realpath(profile)
+               basepath   = os.path.realpath(os.path.join(portdir, "profiles"))
+               if realpath.startswith(basepath):
+                       profilever = realpath[1 + len(basepath):]
                else:
-                       profilever = "!"+profilever
-               del basepath
-       except (OSError,IOError):
-               profilever="unavailable"
+                       try:
+                               profilever = "!" + os.readlink(profile)
+                       except (OSError):
+                               pass
+               del realpath, basepath
+
        libcver=[]
        libclist  = vardb.match("virtual/libc")
        libclist += vardb.match("virtual/glibc")