|
|
|
@ -23,21 +23,23 @@ import sys
|
|
|
|
|
import traceback
|
|
|
|
|
from os import path
|
|
|
|
|
from cl_utils import process,pathJoin,getRunCommands,getTupleVersion,\
|
|
|
|
|
childMounts
|
|
|
|
|
childMounts,_toUNICODE,isMount
|
|
|
|
|
from subprocess import STDOUT,PIPE
|
|
|
|
|
from cl_print import color_print
|
|
|
|
|
from cl_datavars import DataVars
|
|
|
|
|
from shutil import copy2 as copy_with_perm
|
|
|
|
|
from cl_distr import IsoDistributive, DirectoryDistributive, \
|
|
|
|
|
DistributiveError
|
|
|
|
|
from cl_template import template
|
|
|
|
|
from cl_template import template,iniParser
|
|
|
|
|
from cl_vars_share import varsShare
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
|
|
from cl_kernel_utils import KernelConfig,InitRamFs
|
|
|
|
|
|
|
|
|
|
from cl_lang import lang
|
|
|
|
|
from server.utils import dialogYesNo
|
|
|
|
|
import cl_overriding
|
|
|
|
|
from cl_lang import lang
|
|
|
|
|
lang().setLanguage(sys.modules[__name__])
|
|
|
|
|
|
|
|
|
|
class printNoColor:
|
|
|
|
|
def colorPrint(self,attr,fg,bg,string):
|
|
|
|
@ -86,6 +88,7 @@ class cl_builder(color_print):
|
|
|
|
|
self.startMessage = ""
|
|
|
|
|
self.clTempl = None
|
|
|
|
|
self.force = False
|
|
|
|
|
self.assembleIso = False
|
|
|
|
|
|
|
|
|
|
def setNoColor(self):
|
|
|
|
|
self.color = False
|
|
|
|
@ -286,6 +289,7 @@ class cl_builder(color_print):
|
|
|
|
|
return False
|
|
|
|
|
elif not self.clVars.Get('cl_builder_kernel'):
|
|
|
|
|
self.printERROR(_("Can not detect kernel"))
|
|
|
|
|
return False
|
|
|
|
|
elif not self.clVars.Get('cl_builder_initrd_install'):
|
|
|
|
|
self.printERROR(_("Can not detect initramfs"))
|
|
|
|
|
return False
|
|
|
|
@ -322,13 +326,13 @@ class cl_builder(color_print):
|
|
|
|
|
self.targetDistr.installFrom(self.sourceDistr)
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
|
|
|
|
|
self.targetDistr = PartitionDistributive(rootPartdev,flagRemoveDir=False)
|
|
|
|
|
dd = DirectoryDistributive(mp,parent=self.targetDistr)
|
|
|
|
|
self.removeVars('os_assemble_linux_ver', 'os_assemble_linux_shortname',
|
|
|
|
|
'cl_assemble_image', 'cl_assemble_step_system',
|
|
|
|
|
'cl_assemble_make', 'cl_assemble_step_world',
|
|
|
|
|
'cl_assemble_step_newuse', 'cl_assemble_step_update',
|
|
|
|
|
'cl_assemble_path')
|
|
|
|
|
#self.targetDistr = PartitionDistributive(rootPartdev,flagRemoveDir=False)
|
|
|
|
|
#dd = DirectoryDistributive(mp,parent=self.targetDistr)
|
|
|
|
|
#self.removeVars('os_assemble_linux_ver', 'os_assemble_linux_shortname',
|
|
|
|
|
# 'cl_assemble_image', 'cl_assemble_step_system',
|
|
|
|
|
# 'cl_assemble_make', 'cl_assemble_step_world',
|
|
|
|
|
# 'cl_assemble_step_newuse', 'cl_assemble_step_update',
|
|
|
|
|
# 'cl_assemble_path')
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def removeVars(self,*varsname):
|
|
|
|
@ -424,6 +428,8 @@ class cl_builder(color_print):
|
|
|
|
|
self.printMessageForTest(_("Unmount built system volume"))
|
|
|
|
|
self.targetDistr.close()
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
if self.assembleIso:
|
|
|
|
|
self.restoreMount()
|
|
|
|
|
except (BuilderError,DistributiveError),e:
|
|
|
|
|
error = "%s\n%s" % (str(error),_("Unmounting error"))
|
|
|
|
|
except KeyboardInterrupt,e:
|
|
|
|
@ -437,3 +443,44 @@ class cl_builder(color_print):
|
|
|
|
|
return False
|
|
|
|
|
self.printSUCCESS(_("System has built successfully"))
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def restoreMount(self):
|
|
|
|
|
"""Mount /proc,/sys, remote, /dev to chroot"""
|
|
|
|
|
mountResources = (("/dev",None,None),
|
|
|
|
|
("/dev/shm",None,None),
|
|
|
|
|
("/dev/pts",None,None),
|
|
|
|
|
(None,"-t proc","/proc"),
|
|
|
|
|
(None,"-t sysfs","/sys"),
|
|
|
|
|
("/var/calculate/remote",None,None))
|
|
|
|
|
assemblePath = self.clVars.Get('cl_builder_path')
|
|
|
|
|
for source,opts,target in mountResources:
|
|
|
|
|
opts = opts or "-o bind"
|
|
|
|
|
target = target or source
|
|
|
|
|
self.printMessageForTest(_("Mounting %s")%(source or target))
|
|
|
|
|
target = pathJoin(assemblePath,target)
|
|
|
|
|
if not path.exists(target):
|
|
|
|
|
os.makedirs(target,mode=0755)
|
|
|
|
|
if source == isMount(target):
|
|
|
|
|
continue
|
|
|
|
|
args = ["mount"]+opts.split()+[str(source).lower(),target]
|
|
|
|
|
mountProcess = process(*args)
|
|
|
|
|
if mountProcess.failed():
|
|
|
|
|
raise BuilderError(_("Can not mount %(from)s to %(to)s")%
|
|
|
|
|
{'from':source,'to':target})
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
|
|
|
|
|
def setAssembleData(self):
|
|
|
|
|
"""Get assemble data from assemble.env"""
|
|
|
|
|
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,
|
|
|
|
|
'os_assemble_linux_ver')).encode('utf-8')
|
|
|
|
|
if not linuxver:
|
|
|
|
|
curdate = datetime.now()
|
|
|
|
|
linuxver = "%04d%02d%02d"%(curdate.year,curdate.month,curdate.day)
|
|
|
|
|
self.clVars.Set('os_builder_linux_ver',linuxver ,True)
|
|
|
|
|