summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-06-05 05:51:58 +0000
committerZac Medico <zmedico@gentoo.org>2006-06-05 05:51:58 +0000
commitc0264e60a99bad2664b3d787756d0aae9ff11b5c (patch)
treed00500b75ffd359299e2202255d63ccfae3e6f99
parent0584f619d25f65d9770a6f40cdcc3d246aadd22c (diff)
downloadportage-c0264e60a99bad2664b3d787756d0aae9ff11b5c.tar.gz
portage-c0264e60a99bad2664b3d787756d0aae9ff11b5c.tar.bz2
portage-c0264e60a99bad2664b3d787756d0aae9ff11b5c.zip
Fix getgccversion() logic for bug #108393. Thanks to eradicator for suggesting this logic.
svn path=/main/trunk/; revision=3459
-rwxr-xr-xbin/emerge61
1 files changed, 16 insertions, 45 deletions
diff --git a/bin/emerge b/bin/emerge
index 7c4a3d0e1..40f1ae56b 100755
--- a/bin/emerge
+++ b/bin/emerge
@@ -526,63 +526,34 @@ def getgccversion():
return: the current in-use gcc version
"""
- gcc_env_dir = os.path.join('/', 'etc', 'env.d', 'gcc')
- gcc_config_config = os.path.join(gcc_env_dir, 'config')
gcc_ver_command = 'gcc -dumpversion'
gcc_ver_prefix = 'gcc-'
gcc_not_found_error = red(
"!!! No gcc found. You probably need to 'source /etc/profile'\n" +
"!!! to update the environment of this terminal and possibly\n" +
- "!!! other terminals also."
+ "!!! other terminals also.\n"
)
- gcc_distcc_broken_error = green(
- '!!! Relying on the shell to locate gcc, this may break\n' +
- '!!! DISTCC, installing gcc-config and setting your current gcc\n' +
- '!!! profile will fix this'
- )
-
- def fallback():
+ mystatus, myoutput = commands.getstatusoutput("gcc-config -c")
+ if mystatus == os.EX_OK and len(myoutput.split("-")) > 0:
+ return gcc_ver_prefix + myoutput.split("-")[-1]
- print >>sys.stderr, gcc_distcc_broken_error
+ mystatus, myoutput = commands.getstatusoutput("eselect compiler show")
+ if mystatus == os.EX_OK and len(myoutput.split("-")) > 0:
+ return gcc_ver_prefix + myoutput.split("-")[-1]
- gccout = commands.getstatusoutput(gcc_ver_command)
-
- if gccout[0] != 0:
- print >>sys.stderr, gcc_not_found_error
- gccver = "[unavailable]"
- else:
- gccver = gcc_ver_prefix + gccout[1]
-
- return gccver
-
- if os.path.isfile(gcc_config_config):
- try:
- gccver_str = open(gcc_config_config).read().strip()
- gccver = gcc_ver_prefix + string.join(gccver_str.split('-')[4:], '-')
- except IndexError:
- gccver = fallback()
-
- else:
- import glob
- dir_l = glob.glob(os.path.join(gcc_env_dir, '*-*'))
-
- if len(dir_l) == 1:
- try:
- gccver = gcc_ver_prefix + dir_l[0].split('-')[-1]
- except IndexError:
- gccver = fallback()
-
- else:
- # There was no "config" file in /etc/env.d/gcc and there was more
- # than one profile in /etc/env.d/gcc so we can't actively
- # determine what version of gcc we are using so we fall back on the
- # old way that breaks distcc
+ mystatus, myoutput = commands.getstatusoutput(
+ portage.settings["CHOST"] + "-" + gcc_ver_command)
+ if mystatus == os.EX_OK:
+ return gcc_ver_prefix + myoutput
- gccver = fallback()
+ mystatus, myoutput = commands.getstatusoutput(gcc_ver_command)
+ if mystatus == os.EX_OK:
+ return gcc_ver_prefix + myoutput
- return gccver
+ portage.writemsg(gcc_not_found_error, noiselevel=-1)
+ return "[unavailable]"
def getportageversion():
try: