Add calculate package list and digest.

master
Mike Hiretsky 14 years ago
parent 5d201923aa
commit 1fa4e0d09b

Binary file not shown.

@ -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

@ -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"

@ -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)

@ -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',

Loading…
Cancel
Save