diff --git a/i18n/cl_builder_ru.mo b/i18n/cl_builder_ru.mo index 8cb38be..c58ed19 100644 Binary files a/i18n/cl_builder_ru.mo and b/i18n/cl_builder_ru.mo differ diff --git a/pym/cl_builder.py b/pym/cl_builder.py index 95a0fd7..7e3cec2 100644 --- a/pym/cl_builder.py +++ b/pym/cl_builder.py @@ -38,6 +38,7 @@ from cl_kernel_utils import KernelConfig,InitRamFs from server.utils import dialogYesNo import cl_overriding +import hashlib from cl_lang import lang lang().setLanguage(sys.modules[__name__]) @@ -89,6 +90,7 @@ class cl_builder(color_print): self.clTempl = None self.force = False self.assembleIso = False + self.envFile = '/etc/calculate/assemble.env' def setNoColor(self): self.color = False @@ -325,6 +327,10 @@ class cl_builder(color_print): self.printMessageForTest(_("Creating squash image")) self.targetDistr.installFrom(self.sourceDistr) self.printByResult(True) + self.printMessageForTest(_("Creating installed package list")) + self.printByResult(self.createPackageList(sourceDirectory,isoFile+".list")) + self.printMessageForTest(_("Creating DIGESTS file")) + self.printByResult(self.createDigest(isoFile,isoFile+".DIGESTS")) #self.targetDistr = PartitionDistributive(rootPartdev,flagRemoveDir=False) #dd = DirectoryDistributive(mp,parent=self.targetDistr) @@ -469,13 +475,26 @@ class cl_builder(color_print): {'from':source,'to':target}) self.printByResult(True) - def setAssembleData(self): + def setAssembleData(self,shortname,march): """Get assemble data from assemble.env""" + envData = iniParser(self.envFile) + if shortname == None and march == None: + distros = self.clVars.Get('cl_builder_distro') + if len(distros) == 1: + section = distros[0].split(',') + var = 'os_assemble_linux_shortname' + shortname = \ + _toUNICODE(envData.getVar(section,var)).encode('utf-8') + var = 'os_assemble_arch_machine' + march = \ + _toUNICODE(envData.getVar(section,var)).encode('utf-8') + if shortname: + self.clVars.Set('os_builder_linux_shortname',shortname,True) + if march: + self.clVars.Set('os_builder_arch_machine',march,True) self.assembleIso = True section = (self.clVars.Get('os_builder_linux_shortname'), self.clVars.Get('os_builder_arch_machine')) - envFile = '/etc/calculate/assemble.env' - envData = iniParser(envFile) self.clVars.Set('cl_builder_path', _toUNICODE(envData.getVar(section, 'cl_assemble_path')).encode('utf-8'),True) linuxver = _toUNICODE(envData.getVar(section, @@ -484,3 +503,29 @@ class cl_builder(color_print): curdate = datetime.now() linuxver = "%04d%02d%02d"%(curdate.year,curdate.month,curdate.day) self.clVars.Set('os_builder_linux_ver',linuxver ,True) + + def createPackageList(self,chrootdir,filename): + """Create package list by chrootdir""" + pkgdir = path.join(chrootdir,'var/db/pkg') + if not path.exists(chrootdir): + return False + try: + packageList = sorted(reduce(lambda x,y:x+map(lambda x:path.join(y,x), + os.listdir(path.join(pkgdir,y))), os.listdir(pkgdir),[])) + open(filename,'w').writelines(packageList) + except (IOError,OSError),e: + return False + return True + + def createDigest(self,filename,digestfile): + """Create file with digest""" + template = """# %(alg)s HASH\n%(digest)s %(filename)s\n""" + try: + open(digestfile,'w').writelines(map(lambda x:template%{ + 'alg':x.upper(), + 'digest': \ + getattr(hashlib,x)(open(filename,'r').read()).hexdigest(), + 'filename':path.basename(filename)},["md5","sha1"])) + except (IOError,OSError),e: + return False + return True diff --git a/pym/cl_fill_builder.py b/pym/cl_fill_builder.py index 42886a5..da18a7e 100644 --- a/pym/cl_fill_builder.py +++ b/pym/cl_fill_builder.py @@ -22,7 +22,8 @@ from cl_kernel import cl_kernel from os import access, R_OK,W_OK from os import path from cl_distr import Distributive -from cl_utils import getTupleVersion,genpassword,pathJoin +from cl_utils import getTupleVersion,genpassword,pathJoin,_toUNICODE, \ + getFilesCount from operator import itemgetter from types import ListType from cl_datavars import iniParser @@ -284,3 +285,17 @@ class fillVars(object, varsShare): 'ver':self.Get('os_builder_linux_ver'), 'march':self.Get('os_builder_arch_machine')}) return "" + + def get_cl_builder_distro(self): + """Current assembling systems""" + envFile = '/etc/calculate/assemble.env' + envData = iniParser(envFile) + return filter(lambda x:envData.getVar(x.split(','), + 'os_assemble_root_dev'), + map(lambda x:_toUNICODE(x).encode('utf-8'), + envData.getAllSectionNames())) + + def get_cl_builder_filesnum(self): + """Get files num in assembled distro""" + #getFilesCount(self.Get('cl_builder_path')) + return "0" diff --git a/pym/cl_image_cmd.py b/pym/cl_image_cmd.py index 42604e7..a4fc37e 100644 --- a/pym/cl_image_cmd.py +++ b/pym/cl_image_cmd.py @@ -122,17 +122,13 @@ class image_cmd(share_cmd): if values.s: if self.isScratch(False): self.optobj.error(_("'-s' not used in scratch mode")) - self.logicObj.clVars.Set('os_builder_linux_shortname', - values.s.upper(),True) if values.march: if self.isScratch(False): self.optobj.error(_("'--march' not used in scratch mode")) - self.logicObj.clVars.Set('os_builder_arch_machine', - values.march.lower(),True) if not self.isScratch(False) \ - and path.exists(self.envFile): - self.logicObj.setAssembleData() + and self.logicObj.clVars.Get('cl_builder_distro'): + self.logicObj.setAssembleData(values.s,values.march) if args and args[0] == "squash": self.logicObj.clVars.Set('cl_builder_iso_path','/mnt/flash',True) diff --git a/pym/cl_vars_builder.py b/pym/cl_vars_builder.py index 0f72e51..4556945 100644 --- a/pym/cl_vars_builder.py +++ b/pym/cl_vars_builder.py @@ -118,6 +118,12 @@ class Data: # iso image full path cl_builder_image = {} + # distro created by assemble + cl_builder_distro = {} + + # count of files and directories in distributive + cl_builder_filesnum = {} + # path which contains images cl_builder_image_path = {'mode':'w', 'value':['/var/calculate/linux',