config: fix /etc/portage/make.profile error msg
authorZac Medico <zmedico@gentoo.org>
Wed, 16 May 2012 04:54:58 +0000 (21:54 -0700)
committerZac Medico <zmedico@gentoo.org>
Wed, 16 May 2012 04:54:58 +0000 (21:54 -0700)
pym/portage/package/ebuild/config.py

index aa4a62ea286da7c9b5597143de470156a3f8fc47..97cbd99605c766dff5001231d5fc06acd6c8a3c1 100644 (file)
@@ -919,11 +919,26 @@ class config(object):
                                        writemsg(_("!!! INVALID ACCEPT_KEYWORDS: %s\n") % str(group),
                                                noiselevel=-1)
 
-               abs_profile_path = os.path.join(self["PORTAGE_CONFIGROOT"],
-                       PROFILE_PATH)
-               if (not self.profile_path or \
-                       not os.path.exists(os.path.join(self.profile_path, "parent"))) and \
-                       os.path.exists(os.path.join(self["PORTDIR"], "profiles")):
+               profile_broken = not self.profile_path or \
+                       not os.path.exists(os.path.join(self.profile_path, "parent")) and \
+                       os.path.exists(os.path.join(self["PORTDIR"], "profiles"))
+
+               if profile_broken:
+                       abs_profile_path = None
+                       for x in (PROFILE_PATH, 'etc/portage/make.profile'):
+                               x = os.path.join(self["PORTAGE_CONFIGROOT"], x)
+                               try:
+                                       os.lstat(x)
+                               except OSError:
+                                       pass
+                               else:
+                                       abs_profile_path = x
+                                       break
+
+                       if abs_profile_path is None:
+                               abs_profile_path = os.path.join(self["PORTAGE_CONFIGROOT"],
+                                       PROFILE_PATH)
+
                        writemsg(_("\n\n!!! %s is not a symlink and will probably prevent most merges.\n") % abs_profile_path,
                                noiselevel=-1)
                        writemsg(_("!!! It should point into a profile within %s/profiles/\n") % self["PORTDIR"])