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