|
|
|
@ -23,15 +23,18 @@ import sys
|
|
|
|
|
import traceback
|
|
|
|
|
from os import path
|
|
|
|
|
from cl_template import template
|
|
|
|
|
from cl_utils import process,pathJoin,getRunCommands,getTupleVersion
|
|
|
|
|
from cl_utils import process,pathJoin,getRunCommands,getTupleVersion,isMount,\
|
|
|
|
|
isFstabMount
|
|
|
|
|
from subprocess import STDOUT,PIPE
|
|
|
|
|
from cl_print import color_print
|
|
|
|
|
from cl_datavars import DataVars
|
|
|
|
|
from cl_distr import IsoDistributive, DirectoryDistributive, \
|
|
|
|
|
DistributiveError
|
|
|
|
|
DistributiveError, PartitionDistributive, \
|
|
|
|
|
DistributiveRepository, ArchiveDistributive
|
|
|
|
|
from cl_vars_share import varsShare
|
|
|
|
|
|
|
|
|
|
from cl_lang import lang
|
|
|
|
|
lang().setLanguage(sys.modules[__name__])
|
|
|
|
|
from server.utils import dialogYesNo
|
|
|
|
|
import cl_overriding
|
|
|
|
|
|
|
|
|
@ -136,6 +139,100 @@ class cl_assemble(color_print):
|
|
|
|
|
self.startMessage = ""
|
|
|
|
|
self.lenStartMessage = 0
|
|
|
|
|
|
|
|
|
|
def printInfo(self):
|
|
|
|
|
self.printSUCCESS(_("Preparing for assembling of") + " Calculate Linux")
|
|
|
|
|
self.defaultPrint("%s\n"%_("System information"))
|
|
|
|
|
subname = self.clVars.Get('os_assemble_linux_subname')
|
|
|
|
|
subname = (" %s"%subname) if subname else ""
|
|
|
|
|
self.printSUCCESS(_("Assembling system")+": %s"%
|
|
|
|
|
self.clVars.Get('os_assemble_linux_name')+subname)
|
|
|
|
|
self.printSUCCESS(_("System version")+": %s"%
|
|
|
|
|
self.clVars.Get('os_assemble_linux_ver'))
|
|
|
|
|
self.printSUCCESS(_("Machine hardware name")+": %s"%
|
|
|
|
|
self.clVars.Get('os_assemble_arch_machine'))
|
|
|
|
|
self.printSUCCESS(_("Partition for assembling: %s")%
|
|
|
|
|
self.clVars.Get('os_assemble_root_dev'))
|
|
|
|
|
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.defaultPrint("%s\n"%_("Perform pre-assemble checkups"))
|
|
|
|
|
|
|
|
|
|
self.defaultPrint("\n")
|
|
|
|
|
if not self.clVars.Get('cl_assemble_image'):
|
|
|
|
|
self.printWARNING("No path for image creating.")
|
|
|
|
|
|
|
|
|
|
def preassembleCheckups(self):
|
|
|
|
|
dev = self.clVars.Get('os_assemble_root_dev')
|
|
|
|
|
mp = isFstabMount(dev)
|
|
|
|
|
if mp:
|
|
|
|
|
self.printERROR(
|
|
|
|
|
_("'%(dev)s' is used as '%(mp)s' in current system")%
|
|
|
|
|
{'dev':dev,'mp':mp})
|
|
|
|
|
return False
|
|
|
|
|
mp = isMount(dev)
|
|
|
|
|
if mp:
|
|
|
|
|
self.printERROR(_("'%(dev)s' already mounted to '%(mp)s'")%
|
|
|
|
|
{'dev':dev,'mp':mp})
|
|
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def configureFunc(self,force=False):
|
|
|
|
|
rootPartdev = self.clVars.Get('os_assemble_root_dev')
|
|
|
|
|
formatId = PartitionDistributive.formatId
|
|
|
|
|
fileSystem = self.clVars.Get('os_assemble_root_format')
|
|
|
|
|
|
|
|
|
|
self.printInfo()
|
|
|
|
|
if not self.preassembleCheckups():
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
self.targetDistr = PartitionDistributive(rootPartdev,
|
|
|
|
|
mdirectory=self.clVars.Get('cl_assemble_path'),
|
|
|
|
|
check=True, fileSystem=fileSystem, isFormat=True,
|
|
|
|
|
systemId=formatId.get(fileSystem,"83"),
|
|
|
|
|
rootLabel="%s-%s"%
|
|
|
|
|
(self.clVars.Get('os_assemble_linux_shortname'),
|
|
|
|
|
self.clVars.Get('os_assemble_linux_ver')))
|
|
|
|
|
distRep = DistributiveRepository()
|
|
|
|
|
distName = self.clVars.Get('cl_assemble_image')
|
|
|
|
|
stageName = self.clVars.Get('cl_assemble_snapshot_portage')
|
|
|
|
|
if distName:
|
|
|
|
|
# print info
|
|
|
|
|
self.sourceDistr = distRep.getDistributiveByFile(distName)
|
|
|
|
|
if not force:
|
|
|
|
|
dialogMessage = \
|
|
|
|
|
_("Continue with the assembling of the system") + \
|
|
|
|
|
" (yes/no)"
|
|
|
|
|
try:
|
|
|
|
|
dialogRes = dialogYesNo(dialogMessage)
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
self.defaultPrint("\n")
|
|
|
|
|
raise KeyboardInterrupt
|
|
|
|
|
if dialogRes in (None,False):
|
|
|
|
|
self.printERROR(_("Interrupting the assembling"))
|
|
|
|
|
return False
|
|
|
|
|
self.printMessageForTest(_("Formating partitions"))
|
|
|
|
|
self.targetDistr.performFormat()
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
self.printMessageForTest(_("Unpacking stage image into target"))
|
|
|
|
|
self.targetDistr.installFrom(self.sourceDistr)
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
assemblePath = self.targetDistr.convertToDirectory().getDirectory()
|
|
|
|
|
self.clVars.Set('cl_assemble_path', assemblePath, True)
|
|
|
|
|
|
|
|
|
|
self.printMessageForTest(_("Unpacking portage"))
|
|
|
|
|
portageSources = ArchiveDistributive(stageName)
|
|
|
|
|
portageTarget = DirectoryDistributive(
|
|
|
|
|
path.join(assemblePath+"usr/portage"))
|
|
|
|
|
portageTarget.installFrom(portageSources)
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
return True
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
def configureSystem(self,force):
|
|
|
|
|
"""Unpack stage or cls|css and prepare for assemble"""
|
|
|
|
|
return self.make(self.configureFunc,force)
|
|
|
|
|
|
|
|
|
|
def make(self,logicFunc,*argv):
|
|
|
|
|
"""Make iso image by variables"""
|
|
|
|
|
self.sourceDistr = None
|
|
|
|
@ -156,9 +253,14 @@ class cl_assemble(color_print):
|
|
|
|
|
self.printByResult(False)
|
|
|
|
|
self.printWARNING("Interrupting the system assembling")
|
|
|
|
|
error = _("System assembling manually interrupt")
|
|
|
|
|
if error:
|
|
|
|
|
self.printByResult(False)
|
|
|
|
|
try:
|
|
|
|
|
if error:
|
|
|
|
|
self.printByResult(False)
|
|
|
|
|
if self.targetDistr:
|
|
|
|
|
self.printMessageForTest(
|
|
|
|
|
_("Releasing partition for assembling"))
|
|
|
|
|
self.targetDistr.close()
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
if self.clTempl:
|
|
|
|
|
self.clTempl.closeFiles()
|
|
|
|
|
if self.sourceDistr:
|
|
|
|
|