commit:     a41c0f8b9081dad610e6e82ab57a5adce30789ae
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 13 08:04:55 2015 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Dec 20 17:38:49 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=a41c0f8b

doebuild: Support finding lib* for ccache/distcc/icecc masquerade dir

Gentoo ccache used to historically swap between storing its masquerade
in 'lib' and $(get_libdir). To prevent breakage with any version of it,
and prevent future breakages when other tools change places randomly
try all three of $(get_libdir), 'lib' and 'libexec' looking for
masquerade dir and use the one that's found. Additionally, warn if there
is no masquerade dir.

Fixes: https://bugs.gentoo.org/show_bug.cgi?id=567360
Reviewed-by: Zac Medico <zmedico <AT> gentoo.org>

 pym/portage/package/ebuild/doebuild.py | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/pym/portage/package/ebuild/doebuild.py 
b/pym/portage/package/ebuild/doebuild.py
index ff8958e..a4d4d9f 100644
--- a/pym/portage/package/ebuild/doebuild.py
+++ b/pym/portage/package/ebuild/doebuild.py
@@ -466,7 +466,6 @@ def doebuild_environment(myebuild, mydo, myroot=None, 
settings=None,
                icecream = "icecream" in mysettings.features
 
                if ccache or distcc or icecream:
-                       # Use default ABI libdir in accordance with bug #355283.
                        libdir = None
                        default_abi = mysettings.get("DEFAULT_ABI")
                        if default_abi:
@@ -474,17 +473,27 @@ def doebuild_environment(myebuild, mydo, myroot=None, 
settings=None,
                        if not libdir:
                                libdir = "lib"
 
+                       # The installation locations use to vary between 
versions...
+                       # Safer to look them up rather than assuming
+                       possible_libexecdirs = (libdir, "lib", "libexec")
+                       masquerades = []
                        if distcc:
-                               mysettings["PATH"] = os.path.join(os.sep, 
eprefix_lstrip,
-                                        "usr", libdir, "distcc", "bin") + ":" 
+ mysettings["PATH"]
-
+                               masquerades.append("distcc")
                        if icecream:
-                               mysettings["PATH"] = os.path.join(os.sep, 
eprefix_lstrip,
-                                       "usr", 'libexec', "icecc", "bin") + ":" 
+ mysettings["PATH"]
-
+                               masquerades.append("icecc")
                        if ccache:
-                               mysettings["PATH"] = os.path.join(os.sep, 
eprefix_lstrip,
-                                        "usr", libdir, "ccache", "bin") + ":" 
+ mysettings["PATH"]
+                               masquerades.append("ccache")
+
+                       for m in masquerades:
+                               for l in possible_libexecdirs:
+                                       p = os.path.join(os.sep, eprefix_lstrip,
+                                                       "usr", l, m, "bin")
+                                       if os.path.isdir(p):
+                                               mysettings["PATH"] = p + ":" + 
mysettings["PATH"]
+                                               break
+                               else:
+                                       writemsg(("Warning: %s requested but no 
masquerade dir"
+                                               + "can be found in 
/usr/lib*/%s/bin\n") % (m, m))
 
                if 'MAKEOPTS' not in mysettings:
                        nproc = get_cpu_count()

Reply via email to