diff --git a/pym/cl_distr.py b/pym/cl_distr.py index faaa575..16381e6 100644 --- a/pym/cl_distr.py +++ b/pym/cl_distr.py @@ -24,7 +24,7 @@ import re import sys import operator from cl_utils import runOsCommand,isMount,removeDir,typeFile,pathJoin, \ - process,getRunCommands,getTupleVersion + process,getRunCommands,getTupleVersion,cmpVersion from shutil import copyfile,copytree from cl_template import _terms from subprocess import Popen,PIPE,STDOUT @@ -154,6 +154,19 @@ class DistributiveRepository: d['ver'] = \ varsShare.getVersionFromMetapackage(filename,d["name"]) or \ varsShare.getVersionFromCalculateIni(filename) or "0" + reOsLinuxBuild = re.compile("^os_linux_build\s*=\s*(\S+)\s*$") + os_linux_build = \ + map(lambda x:x.groups()[0], + filter(lambda x:x, + map(reOsLinuxBuild.search, + reduce(lambda x,y:x+y, + map(lambda x:open(x,"r").readlines(), + filter(path.exists, + [path.join(filename,"etc/calculate/calculate2.env")])),[])))) + if os_linux_build: + d['build'] = os_linux_build[-1] + else: + d['build'] = "" if distr: distr.close() return d @@ -168,7 +181,13 @@ class DistributiveRepository: match = self.reDistName.match(filename) if not match: return {} - return match.groupdict() + distdic = match.groupdict() + distdic["build"] = "" + if "ver" in distdic: + if re.match("^\d{8}$", distdic["ver"]): + distdic["build"] = distdic["ver"] + distdic["ver"] = "" + return distdic def _getAvailableShortnames(self): """Get available distributives shortnames""" @@ -256,10 +275,13 @@ class DistributiveRepository: def sortdistrfunc(self,x,y): """Func of comparing two distributive""" - ver1,ver2 = self.term._convertVers(x[1].get('ver',""), - y[1].get('ver',"")) - if ver1 != ver2: - return cmp(ver1,ver2) + ver1, ver2 = x[1].get('ver',""), y[1].get('ver',"") + if ver1 and ver2 and ver1 != "0" and ver2 != "0" and ver1 != ver2: + return cmpVersion(ver1,ver2) + build1,build2 = self.term._convertVers(x[1].get('build',""), + y[1].get('build',"")) + if build1 != build2: + return cmp(build1,build2) else: ext1 = x[1].get('ext',"") ext2 = y[1].get('ext',"")