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