Add support for displaying profile listed in make.profile/parent when
authorZac Medico <zmedico@gentoo.org>
Tue, 9 Mar 2010 04:24:16 +0000 (04:24 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 9 Mar 2010 04:24:16 +0000 (04:24 -0000)
make.profile is not a symlink. The first parent with a path inside
$PORTDIR is displayed.

svn path=/main/trunk/; revision=15787

pym/_emerge/actions.py

index 9b5931181568c5342d87e6445ab52d4434974418..bf26881bf171712c34f7a09b63e8135d8665ed15 100644 (file)
@@ -2429,19 +2429,38 @@ def display_missing_pkg_set(root_config, set_name):
        writemsg_level("".join("%s\n" % l for l in msg),
                level=logging.ERROR, noiselevel=-1)
 
+def relative_profile_path(portdir, abs_profile):
+       realpath = os.path.realpath(abs_profile)
+       basepath   = os.path.realpath(os.path.join(portdir, "profiles"))
+       if realpath.startswith(basepath):
+               profilever = realpath[1 + len(basepath):]
+       else:
+               profilever = None
+       return profilever
+
 def getportageversion(portdir, target_root, profile, chost, vardb):
-       profilever = "unavailable"
+       profilever = None
        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 = relative_profile_path(portdir, profile)
+               if profilever is None:
                        try:
-                               profilever = "!" + os.readlink(profile)
-                       except (OSError):
+                               for parent in portage.grabfile(
+                                       os.path.join(profile, 'parent')):
+                                       profilever = relative_profile_path(portdir,
+                                               os.path.join(profile, parent))
+                                       if profilever is not None:
+                                               break
+                       except portage.exception.PortageException:
                                pass
-               del realpath, basepath
+
+                       if profilever is None:
+                               try:
+                                       profilever = "!" + os.readlink(profile)
+                               except (OSError):
+                                       pass
+
+       if profilever is None:
+               profilever = "unavailable"
 
        libcver=[]
        libclist  = vardb.match("virtual/libc")