Add mulitiple assembling.

develop
parent 6ee2e79d7b
commit c1ee36b6e5

Binary file not shown.

@ -22,7 +22,7 @@ import re
import sys
import traceback
from os import path
from cl_template import template
from cl_template import template,iniParser
from cl_utils import process,pathJoin,getRunCommands,getTupleVersion,isMount,\
isFstabMount,childMounts
from subprocess import STDOUT,PIPE
@ -91,6 +91,7 @@ class cl_assemble(color_print):
self.lenStartMessage = 0
self.clTempl = None
self.force = False
self.assembleEnvFile = '/etc/calculate/assemble.env'
def setNoColor(self):
self.color = False
@ -159,10 +160,13 @@ class cl_assemble(color_print):
self.clVars.Get('os_assemble_arch_machine'))
self.printSUCCESS(_("Partition for assembling: %s")%
self.clVars.Get('os_assemble_root_dev'))
self.printSUCCESS(_("File system: %s")%
self.clVars.Get('os_assemble_root_format'))
self.printSUCCESS(_("Stage for assembling: %s")%
self.clVars.Get('cl_assemble_image'))
self.printSUCCESS(_("Portage snapshot for assembling: %s")%
self.clVars.Get('cl_assemble_snapshot_portage'))
self.clVars.Get('cl_assemble_image'))
if self.clVars.Get('cl_assemble_image_type') == "stage":
self.printSUCCESS(_("Portage snapshot for assembling: %s")%
self.clVars.Get('cl_assemble_snapshot_portage'))
self.defaultPrint("%s\n"%_("Perform pre-assemble checkups"))
self.defaultPrint("\n")
@ -187,8 +191,22 @@ class cl_assemble(color_print):
self.defaultPrint("\n")
def _checkAlreadyAssembling(self):
section = "%s-%s"%(self.clVars.Get('os_assemble_linux_shortname'),
self.clVars.Get('os_assemble_arch_machine'))
if section in self.clVars.Get('cl_assemble_distro'):
return False
return True
def preassembleCheckups(self):
dev = self.clVars.Get('os_assemble_root_dev')
if not self._checkAlreadyAssembling():
self.printERROR(_("%(system)s(%(arch)s) is assembling in"
" '%(dir)s' now")%
{'system':self.clVars.Get('os_assemble_linux_shortname'),
'arch':self.clVars.Get('os_assemble_arch_machine'),
'dir':self.clVars.Get('cl_assemble_path')})
return False
mp = isFstabMount(dev)
if mp:
self.printERROR(
@ -218,11 +236,15 @@ class cl_assemble(color_print):
self.printMessageForTest(_("Unpacking stage image into target"))
self.targetDistr.installFrom(self.sourceDistr)
self.assemblePath = \
self.targetDistr.convertToDirectory().getDirectory()
self.clVars.Set('cl_assemble_path', self.assemblePath, True)
self.saveVars('os_assemble_linux_shortname',
'os_assemble_linux_ver',
'os_assemble_arch_machine',
'cl_assemble_image',
'os_assemble_root_dev')
'os_assemble_root_dev',
'cl_assemble_path')
def _getTarget(self):
rootPartdev = self.clVars.Get('os_assemble_root_dev')
@ -337,9 +359,6 @@ class cl_assemble(color_print):
return False
# format partion
self._formatAndUnpackStage()
self.assemblePath = \
self.targetDistr.convertToDirectory().getDirectory()
self.clVars.Set('cl_assemble_path', self.assemblePath, True)
if nounmount:
self.targetDistr = None
@ -390,7 +409,7 @@ class cl_assemble(color_print):
self._updateMan()
self.printMessageForTest(_("Executing %s")%"etc-update")
self.runChroot("etc-update")
self.runChroot("OVERWRITE_ALL='yes' etc-update")
if not isinstance(self.sourceDistr,IsoDistributive):
if self.clVars.Get('os_assemble_linux_system')=='desktop':
@ -489,16 +508,20 @@ class cl_assemble(color_print):
def configureSystem(self,force,nounmount):
"""Unpack stage or cls|css and prepare for assemble"""
self.msgOperationComplete = \
_("System was have prepared for assembling successfully")
self.msgOperationComplete = ""
self.msgOperationFailed = \
_("Preparing for assembling failed")
return self.make(self.configureFunc,force,nounmount)
res = self.make(self.configureFunc,force,nounmount)
if res:
self.printSUCCESS(
_("System was have prepared for assembling successfully in %s")%
self.clVars.Get('cl_assemble_path'))
return res
def breakFunc(self,force):
rootPartdev = self.clVars.Get('os_assemble_root_dev')
mp = isMount(rootPartdev)
if not mp:
if self._checkAlreadyAssembling() or not mp:
self.printERROR(_("For performance of operation it is "
"necessary to configure system")+".")
self.printERROR(_('Execute with parameter')+' "--configure".')
@ -518,9 +541,34 @@ class cl_assemble(color_print):
self.printByResult(True)
self.targetDistr = PartitionDistributive(rootPartdev,flagRemoveDir=False)
dd = DirectoryDistributive(mp,parent=self.targetDistr)
return True
def checkDependence(self):
rootPartdev = self.clVars.Get('os_assemble_root_dev')
mp = isMount(rootPartdev)
if self._checkAlreadyAssembling() or not mp:
self.printERROR(_("For performance of operation it is "
"necessary to configure system")+".")
self.printERROR(_('Execute with parameter')+' "--configure".')
return False
self.printConfInfo()
command = "emerge -pv %s"%self.clVars.Get('cl_assemble_meta')
self.printSUCCESS(_("Executing %s")% command + " ...")
import ipdb
ipdb.set_trace()
if self.runChroot(command, showProcess=True,
raiseError=False).success():
self.printSUCCESS(_("%(system)s(%(arch)s) ready for compile")%
{'system':self.clVars.Get('os_assemble_linux_shortname'),
'arch':self.clVars.Get('os_assemble_arch_machine')})
return True
else:
self.printSUCCESS(_("%(system)s(%(arch)s) have wrong dependence")%
{'system':self.clVars.Get('os_assemble_linux_shortname'),
'arch':self.clVars.Get('os_assemble_arch_machine')})
return False
def breakAssembling(self,force):
self.msgOperationComplete = \
_("Break of system assembling is successfully")
@ -538,7 +586,7 @@ class cl_assemble(color_print):
def makeFunc(self,force):
rootPartdev = self.clVars.Get('os_assemble_root_dev')
mp = isMount(rootPartdev)
if not mp:
if self._checkAlreadyAssembling() or not mp:
self.printERROR(_("For performance of operation it is "
"necessary to configure system")+".")
self.printERROR(_('Execute with parameter')+' "--configure".')
@ -590,6 +638,9 @@ class cl_assemble(color_print):
self.clVars.Get('cl_assemble_meta'),"meta")
self._printCheckExecute("emerge -D --newuse world","newuse")
self._printCheckExecute("python-updater","python")
if path.exists(pathJoin(self.clVars.Get('cl_assemble_path'),
"/usr/bin/perl-cleaner")):
self._printCheckExecute("perl-cleaner all","perl")
if path.exists(pathJoin(self.clVars.Get('cl_assemble_path'),
"/usr/sbin/module-rebuild")):
self._printCheckExecute("module-rebuild -X rebuild","modules")
@ -598,6 +649,7 @@ class cl_assemble(color_print):
if path.exists(pathJoin(self.clVars.Get('cl_assemble_path'),
"/usr/bin/revdep-rebuild")):
self._printCheckExecute("revdep-rebuild","revdep")
self._appendToStep("world","finish")
def _compileNewuse(self):
"""New use compiling"""
@ -632,20 +684,37 @@ class cl_assemble(color_print):
else:
return False
def __sectionName(self):
"""Get section name of assemble.env by shortname and arch"""
return "%s-%s"%(self.clVars.Get('os_assemble_linux_shortname'),
self.clVars.Get('os_assemble_arch_machine'))
def writeVar(self,varname,varvalue):
"""Write variable to default env file"""
chrootPath = self.clVars.Get('cl_chroot_path')
res = self.clVars.Write(varname,varvalue,True,'default')
self.clVars.Set('cl_chroot_path',chrootPath,True)
return res
assembleEnv = iniParser(self.assembleEnvFile)
self.clVars.Set(varname,varvalue)
return assembleEnv.setVar(self.__sectionName(),{varname:varvalue})
def saveVars(self,*varsname):
chrootPath = self.clVars.Get('cl_chroot_path')
"""Save vars with it current values"""
assembleEnv = iniParser(self.assembleEnvFile)
return assembleEnv.setVar(self.__sectionName(),
dict(map(lambda x:(x,self.clVars.Get(x)),varsname)))
def removeDistroInfo(self,distro):
assembleEnv = iniParser(self.assembleEnvFile)
assembleEnv.delArea(self.__sectionName())
def removeVars(self,*varsname):
"""Remove vars specified by varsname"""
res = True
assembleEnv = iniParser(self.assembleEnvFile)
for var in varsname:
res = res and self.clVars.Write(var,self.clVars.Get(var),
True,'default')
self.clVars.Set('cl_chroot_path',chrootPath,True)
res = res and assembleEnv.delVar(self.__sectionName(),var)
if not assembleEnv.getAllSectionNames():
os.unlink(self.assembleEnvFile)
elif not self.__sectionName() in assembleEnv.getAllSectionNames():
assembleEnv.delArea(self.__sectionName())
return bool(res)
def _getStepCount(self,stepname):
@ -702,6 +771,7 @@ class cl_assemble(color_print):
if error or logicFunc == self.breakFunc:
self.printByResult(False)
if self.targetDistr:
self.removeDistroInfo()
self.printMessageForTest(
_("Releasing partition for assembling"))
assemblePath = \
@ -730,7 +800,8 @@ class cl_assemble(color_print):
self.printERROR(line)
self.printERROR(self.msgOperationFailed)
return False
self.printSUCCESS(self.msgOperationComplete)
if self.msgOperationComplete:
self.printSUCCESS(self.msgOperationComplete)
return True
def setAction(self,action):
@ -738,5 +809,7 @@ class cl_assemble(color_print):
self.clVars.Set("cl_action","break",True)
elif action == "make":
self.clVars.Set("cl_action","make",True)
elif action == "dependence":
self.clVars.Set("cl_action","dependence",True)
else:
self.clVars.Set("cl_action","configure",True)

@ -42,6 +42,12 @@ CMD_OPTIONS = [{'shortOption':"d",
'choices':['cld','cds','cls','css','cldg','cldx'],
'help':_("select operation system")
},
{'longOption':"march",
'optVal':"ARCH",
'type':'choice',
'choices':['x86_64','i686'],
'help':_("select arch for operation system")
},
{'shortOption':"c",
'longOption':"configure",
'help':_("prepare system for building")
@ -50,10 +56,14 @@ CMD_OPTIONS = [{'shortOption':"d",
'longOption':"make",
'help':_("make system")
},
{'shortOption':"D",
'longOption':"dependence",
'help':_("check of dependences")
},
{'longOption':"break",
'help':_("break system assembling")
},
{'longOption':"linuxver",
{'longOption':"ver",
'optVal':"VER",
'help':_("version of assembling system")
},
@ -62,7 +72,7 @@ CMD_OPTIONS = [{'shortOption':"d",
"when an error occurs")
},
{'longOption':"skipfirst",
'help':_("remove the first package in the resume list")
'help':_("skip the first package in the resume assemblihg")
}]
USAGE = _("%prog [options] --make|--configure|--break")
@ -78,14 +88,21 @@ class assemble_cmd(share_cmd):
check_values=self.checkOpts)
self.logicObj = cl_assemble()
self.optionsMakeIncompatible=["c","break","no_unmount"]
self.optionsBreakIncompatible=["skipfirst","m","c","s","linuxver",
self.optionsBreakIncompatible=["skipfirst","m","c","ver",
"no_unmount"]
self.optionsConfigureIncompatible=["skipfirst","m","break"]
self.optionsDependenceIncompatible=["skipfirst","m","break","c"]
def checkOpts(self, values, args):
"""Check values all specified options."""
if len(args) > 0:
self.optobj.error(_("unrecognized option") + ": %s"% "".join(args))
if values.s:
self.logicObj.clVars.Set('os_assemble_linux_shortname',
values.s.upper(),True)
if values.march:
self.logicObj.clVars.Set('os_assemble_arch_machine',
values.march,True)
if not values.v:
if values.m:
self.checkIncompatibleParam("make")
@ -93,22 +110,23 @@ class assemble_cmd(share_cmd):
self.checkIncompatibleParam("break")
if values.c:
self.checkIncompatibleParam("configure")
if not (values.c or values.m or getattr(values,"break")):
self.optobj.error(
_("need specify action: configure (-c), make (-m) or"
" break (--break)"))
if values.c and not values.d and \
not self.logicObj.clVars.Get('os_assemble_root_dev'):
if values.D:
self.checkIncompatibleParam("dependence")
if not (values.c or values.m or getattr(values,"break") or
values.D):
self.optobj.error(
_("need specify disk by '-d' option"))
_("need specify action: configure (-c), make (-m),"
" break (--break) or check dependence (-D)"))
rootDev = self.logicObj.clVars.Get('os_assemble_root_dev')
if self.logicObj._checkAlreadyAssembling() and \
(values.c and not values.d) and ( not rootDev or \
rootDev in self.logicObj.clVars.Get('cl_assemble_dev')):
self.optobj.error(_("need specify disk by '-d' option"))
if values.d:
self.logicObj.clVars.Set('os_assemble_root_dev',values.d,True)
if values.s:
self.logicObj.clVars.Set('os_assemble_linux_shortname',
values.s.upper(),True)
if values.linuxver:
if values.ver:
self.logicObj.clVars.Set('os_assemble_linux_ver',
values.linuxver,True)
values.ver,True)
self.optobj.checkVarSyntax(values)
return (values, args)
@ -121,6 +139,8 @@ class assemble_cmd(share_cmd):
if self.optobj.values.skipfirst:
self.logicObj.clVars.Set('cl_assemble_skipfirst',
"yes",True)
elif self.optobj.values.D:
self.logicObj.setAction("dependence")
else:
self.logicObj.setAction("configure")
@ -141,3 +161,9 @@ class assemble_cmd(share_cmd):
if not self.logicObj.breakAssembling(force):
return False
return True
def checkDependence(self):
"""Check dependence of assembling distributive"""
if not self.logicObj.checkDependence():
return False
return True

@ -46,12 +46,7 @@ class fillVars(installFillVars):
"""Get short system name"""
if self.Get('cl_action') in ('configure','setup'):
return self.Get('os_linux_shortname')
else:
systemRoot = self.Get('cl_assemble_path')
return self.getShortnameByMakeprofile(systemRoot) or \
self.getShortnameByIni(systemRoot) or \
self.detectOtherShortname(systemRoot) or \
"Linux"
return ""
def get_os_assemble_linux_name(self):
"""Get full system name"""
@ -63,8 +58,19 @@ class fillVars(installFillVars):
linuxShortName = self.Get("os_assemble_linux_shortname")
return self.dictLinuxSubName.get(linuxShortName,"")
def _getFromEnv(self,var):
"""Get variable from env"""
section = "%s-%s"%(self.Get('os_assemble_linux_shortname'),
self.Get('os_assemble_arch_machine'))
envFile = '/etc/calculate/assemble.env'
envData = iniParser(envFile)
return _toUNICODE(envData.getVar(section,var)).encode('utf-8')
def get_os_assemble_linux_ver(self):
"""Get system version"""
fromEnv = self._getFromEnv('os_assemble_linux_ver')
if fromEnv:
return fromEnv
imagename = self.getImage(self.Get('cl_assemble_image_path'),
self.Get('os_assemble_arch_machine'),
self.Get('os_assemble_linux_shortname'))
@ -128,6 +134,9 @@ class fillVars(installFillVars):
def get_cl_assemble_image(self):
"""Get image file from distributive repository"""
fromEnv = self._getFromEnv('cl_assemble_image')
if fromEnv:
return fromEnv
if self.Get('cl_action') in ('configure','setup'):
return self.getImage(self.Get('cl_assemble_image_path'),
self.Get('os_assemble_arch_machine'),
@ -160,6 +169,9 @@ class fillVars(installFillVars):
def get_os_assemble_root_dev(self):
"""Get device for assembling"""
fromEnv = self._getFromEnv('os_assemble_root_dev')
if fromEnv:
return fromEnv
paths = map(lambda x:x[1],reversed(libData.cl_env_data['value']))
for inifile in paths:
if os.access(inifile,os.R_OK):
@ -171,6 +183,9 @@ class fillVars(installFillVars):
return ""
def get_cl_assemble_path(self):
fromEnv = self._getFromEnv('cl_assemble_path')
if fromEnv:
return fromEnv
rootDev = self.Get('os_assemble_root_dev')
if rootDev:
mp = isMount(rootDev)
@ -201,3 +216,32 @@ class fillVars(installFillVars):
return ""
else:
return "/developer"
def get_cl_assemble_step_system(self):
"""action: emerge -e system"""
fromEnv = self._getFromEnv('cl_assemble_step_system')
if fromEnv:
return fromEnv
return ""
def get_cl_assemble_step_world(self):
"""action full update"""
fromEnv = self._getFromEnv('cl_assemble_step_world')
if fromEnv:
return fromEnv
return ""
def get_cl_assemble_distro(self):
"""Current assembling systems"""
envFile = '/etc/calculate/assemble.env'
envData = iniParser(envFile)
return map(lambda x:_toUNICODE(x).encode('utf-8'),
envData.getAllSectionNames())
def get_cl_assemble_dev(self):
"""Used devices for system assembling"""
envFile = '/etc/calculate/assemble.env'
envData = iniParser(envFile)
return map(lambda x:_toUNICODE(envData.getVar(x,
'os_assemble_root_dev')).encode('utf-8'),
self.Get('cl_assemble_distro'))

@ -69,6 +69,7 @@ class share_cmd(color_print, _error):
k,o,v = val.partition('=')
if self.logicObj.clVars.exists(k):
if self.logicObj.clVars.SetWriteVar(k,v) == False:
self.printERROR(get_install_errors(),printBR=False)
return False
else:
self.printERROR(_('variable %s not found')%k)

@ -34,6 +34,11 @@ class Data:
# current action for make process
cl_assemble_make = {'value':""}
# current assembling systems
cl_assemble_distro = {}
# used devices for system assembling
cl_assemble_dev = {}
# step of make action
# action: emerge -e system
cl_assemble_step_system = {}
@ -56,7 +61,7 @@ class Data:
cl_assemble_setup_action = {}
# system image for installation
cl_assemble_image = {}
cl_assemble_image = {'mode':'w'}
# type of stage (iso or tarball)
cl_assemble_image_type = {}

@ -49,6 +49,9 @@ if __name__ == "__main__":
# check root
if not assemble.isRoot():
sys.exit(1)
if options.D:
if not assemble.checkDependence():
sys.exit(1)
if options.c:
if not assemble.configureSystem(options.f,options.no_unmount):
sys.exit(1)

Loading…
Cancel
Save