2011-11-11 18:41:59 +01:00
|
|
|
import os
|
2012-04-20 01:15:40 +02:00
|
|
|
import re
|
2011-11-11 18:41:59 +01:00
|
|
|
import subprocess
|
|
|
|
from entropy.const import etpConst
|
|
|
|
|
|
|
|
def configure_correct_gcc():
|
2011-11-23 08:04:23 +01:00
|
|
|
gcc_targets = ["4.8", "4.7", "4.6"]
|
2011-11-11 18:41:59 +01:00
|
|
|
uname_arch = os.uname()[4]
|
|
|
|
gcc_dir = etpConst['systemroot'] + "/etc/env.d/gcc"
|
|
|
|
gcc_profile_file = None
|
2011-11-23 08:04:23 +01:00
|
|
|
for gcc_target in gcc_targets:
|
|
|
|
gcc_profile_file_pfx = uname_arch + "-pc-linux-gnu-" + gcc_target
|
2012-04-20 01:15:40 +02:00
|
|
|
regex = re.compile(gcc_profile_file_pfx + "((.[0-30])?)$")
|
|
|
|
|
2011-11-23 08:04:23 +01:00
|
|
|
for curdir, subs, files in os.walk(gcc_dir):
|
|
|
|
for fname in files:
|
2012-04-20 01:15:40 +02:00
|
|
|
if regex.match(fname):
|
2012-03-22 22:46:50 +01:00
|
|
|
gcc_profile_file = os.path.join(curdir, fname)
|
2011-11-23 08:04:23 +01:00
|
|
|
break
|
|
|
|
break
|
|
|
|
if gcc_profile_file is not None:
|
|
|
|
break
|
2011-11-11 18:41:59 +01:00
|
|
|
if gcc_profile_file is not None:
|
2012-03-22 22:46:50 +01:00
|
|
|
# if we're hardened, we want the vanilla one by default
|
|
|
|
# to avoid stressing the user too much
|
|
|
|
vanilla_profile_file = gcc_profile_file + "-vanilla"
|
|
|
|
if os.path.isfile(vanilla_profile_file):
|
|
|
|
gcc_profile_file = vanilla_profile_file
|
|
|
|
profile_name = os.path.basename(gcc_profile_file)
|
|
|
|
subprocess.call(("gcc-config", profile_name))
|
2011-11-11 18:41:59 +01:00
|
|
|
|
|
|
|
if stage == "postinstall":
|
|
|
|
configure_correct_gcc()
|
|
|
|
|
|
|
|
my_ext_status = 0
|