def updateCcache(self): value = FmUtil.getMakeConfVar(FmConst.portageCfgMakeConf, "FEATURES") if value != "": valueList = value.split(" ") else: valueList = [] c = CcacheLocalService() if c.is_enabled(): if "ccache" not in valueList: valueList.append("ccache") FmUtil.setMakeConfVar(FmConst.portageCfgMakeConf, "FEATURES", " ".join(valueList)) else: if "ccache" in valueList: valueList.remove("ccache") FmUtil.setMakeConfVar(FmConst.portageCfgMakeConf, "FEATURES", " ".join(valueList))
def updateParallelism(self, hwInfo): # gather system information cpuNum = hwInfo.hwDict["cpu"]["cores"] memSize = hwInfo.hwDict["memory"]["size"] bFanless = ("fan" not in hwInfo.hwDict) bHugeMemory = (memSize >= 24) # determine parallelism parameters if bFanless: jobcountMake = 1 jobcountEmerge = 1 loadavg = 1 else: if bHugeMemory: jobcountMake = cpuNum + 2 jobcountEmerge = cpuNum loadavg = cpuNum else: jobcountMake = cpuNum jobcountEmerge = cpuNum loadavg = max(1, cpuNum - 1) # check/fix MAKEOPTS variable # for bug 559064 and 592660, we need to add -j and -l, it sucks value = FmUtil.getMakeConfVar(FmConst.portageCfgMakeConf, "MAKEOPTS") if True: m = re.search("\\B--jobs(=([0-9]+))?\\b", value) if m is None: value += " --jobs=%d" % (jobcountMake) FmUtil.setMakeConfVar(FmConst.portageCfgMakeConf, "MAKEOPTS", value.lstrip()) elif m.group(2) is None or int(m.group(2)) != jobcountMake: value = value.replace(m.group(0), "--jobs=%d" % (jobcountMake)) FmUtil.setMakeConfVar(FmConst.portageCfgMakeConf, "MAKEOPTS", value.lstrip()) value = FmUtil.getMakeConfVar(FmConst.portageCfgMakeConf, "MAKEOPTS") if True: m = re.search("\\B--load-average(=([0-9\\.]+))?\\b", value) if m is None: value += " --load-average=%d" % (loadavg) FmUtil.setMakeConfVar(FmConst.portageCfgMakeConf, "MAKEOPTS", value.lstrip()) elif m.group(2) is None or int(m.group(2)) != loadavg: value = value.replace(m.group(0), "--load-average=%d" % (loadavg)) FmUtil.setMakeConfVar(FmConst.portageCfgMakeConf, "MAKEOPTS", value.lstrip()) value = FmUtil.getMakeConfVar(FmConst.portageCfgMakeConf, "MAKEOPTS") if True: m = re.search("\\B-j([0-9]+)?\\b", value) if m is None: value += " -j%d" % (jobcountMake) FmUtil.setMakeConfVar(FmConst.portageCfgMakeConf, "MAKEOPTS", value.lstrip()) elif m.group(1) is None or int(m.group(1)) != jobcountMake: value = value.replace(m.group(0), "-j%d" % (jobcountMake)) FmUtil.setMakeConfVar(FmConst.portageCfgMakeConf, "MAKEOPTS", value.lstrip()) value = FmUtil.getMakeConfVar(FmConst.portageCfgMakeConf, "MAKEOPTS") if True: m = re.search("\\B-l([0-9]+)?\\b", value) if m is None: value += " -l%d" % (loadavg) FmUtil.setMakeConfVar(FmConst.portageCfgMakeConf, "MAKEOPTS", value.lstrip()) elif m.group(1) is None or int(m.group(1)) != loadavg: value = value.replace(m.group(0), "-l%d" % (loadavg)) FmUtil.setMakeConfVar(FmConst.portageCfgMakeConf, "MAKEOPTS", value.lstrip()) # check/fix EMERGE_DEFAULT_OPTS variable value = FmUtil.getMakeConfVar(FmConst.portageCfgMakeConf, "EMERGE_DEFAULT_OPTS") if True: m = re.search("\\B--jobs(=([0-9]+))?\\b", value) if m is None: value += " --jobs=%d" % (jobcountEmerge) FmUtil.setMakeConfVar(FmConst.portageCfgMakeConf, "EMERGE_DEFAULT_OPTS", value.lstrip()) elif m.group(2) is None or int(m.group(2)) != jobcountEmerge: value = value.replace(m.group(0), "--jobs=%d" % (jobcountEmerge)) FmUtil.setMakeConfVar(FmConst.portageCfgMakeConf, "EMERGE_DEFAULT_OPTS", value.lstrip()) value = FmUtil.getMakeConfVar(FmConst.portageCfgMakeConf, "EMERGE_DEFAULT_OPTS") if True: m = re.search("\\B--load-average(=([0-9\\.]+))?\\b", value) if m is None: value += " --load-average=%d" % (loadavg) FmUtil.setMakeConfVar(FmConst.portageCfgMakeConf, "EMERGE_DEFAULT_OPTS", value.lstrip()) elif m.group(2) is None or int(m.group(2)) != loadavg: value = value.replace(m.group(0), "--load-average=%d" % (loadavg)) FmUtil.setMakeConfVar(FmConst.portageCfgMakeConf, "EMERGE_DEFAULT_OPTS", value.lstrip())