diff --git a/i18n/cl_builder_ru.mo b/i18n/cl_builder_ru.mo index a31c597..fb7542d 100644 Binary files a/i18n/cl_builder_ru.mo and b/i18n/cl_builder_ru.mo differ diff --git a/pym/cl_builder.py b/pym/cl_builder.py index 72a3304..cbe6263 100644 --- a/pym/cl_builder.py +++ b/pym/cl_builder.py @@ -22,7 +22,8 @@ import re import sys import traceback from os import path -from cl_utils import process,pathJoin,getRunCommands,getTupleVersion +from cl_utils import process,pathJoin,getRunCommands,getTupleVersion,\ + childMounts from subprocess import STDOUT,PIPE from cl_print import color_print from cl_datavars import DataVars @@ -153,6 +154,15 @@ class cl_builder(color_print): self.startMessage = "" def prepareSourceDistributive(self,distr): + """Unmount all bind,proc mount points from source distribute""" + mp = self.clVars.Get('cl_builder_path') + mps = filter(lambda x:x!=mp,map(lambda x:x[1],childMounts(mp))) + for target in sorted(mps, reverse=True): + self.printMessageForTest(_("Unmounting %s")%(target[len(mp):])) + umountProcess = process("umount",target) + if umountProcess.failed(): + raise AssembleError(_("Can not umount %s")%target) + self.printByResult(True) self.applyTemplatesForSquash(distr.convertToDirectory().getDirectory()) def isoPrepacking(self,directory): @@ -311,8 +321,23 @@ class cl_builder(color_print): self.printMessageForTest(_("Creating squash image")) 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') return True + def removeVars(self,*varsname): + """Remove vars specified by varsname""" + res = True + for var in varsname: + res = res and self.clVars.Delete(var,True,'default','assemble') + return bool(res) + def _rescratchLogic(self,force=False): self.clVars.Set('cl_builder_iso_path','/mnt/flash',True) self.clVars.Get('cl_builder_remove_squash') diff --git a/pym/cl_fill_builder.py b/pym/cl_fill_builder.py index ac643a9..42886a5 100644 --- a/pym/cl_fill_builder.py +++ b/pym/cl_fill_builder.py @@ -25,6 +25,8 @@ from cl_distr import Distributive from cl_utils import getTupleVersion,genpassword,pathJoin from operator import itemgetter from types import ListType +from cl_datavars import iniParser +from cl_vars import Data as libData class fillVars(object, varsShare): @@ -136,6 +138,18 @@ class fillVars(object, varsShare): return "up" return "" + def get_cl_builder_path(self): + """Get path for image""" + paths = map(lambda x:x[1],reversed(libData.cl_env_data['value'])) + for inifile in paths: + if os.access(inifile,os.R_OK): + inidata = iniParser(inifile) + res = inidata.getVar("assemble","cl_assemble_path", + checkExistVar=True) + if res[0]: + return _toUNICODE(res[1]).encode('utf-8') + return "/mnt/builder" + def get_cl_builder_kernel(self): """Kernel image""" bootdir = path.join(self.Get('cl_builder_path'),'boot') diff --git a/pym/cl_image_cmd.py b/pym/cl_image_cmd.py index 53a9a0c..154577a 100644 --- a/pym/cl_image_cmd.py +++ b/pym/cl_image_cmd.py @@ -23,10 +23,12 @@ from os import access,R_OK import re import sys from types import ListType +from cl_template import iniParser from cl_lang import lang lang().setLanguage(sys.modules[__name__]) + DESCRIPTION = _("The Calculate Linux image builder") CMD_OPTIONS = [{'shortOption':"f", 'longOption':"force", @@ -58,6 +60,21 @@ class image_cmd(share_cmd): self.printERROR(_("You should load system in the builder mode.")) return False + def isAssemble(self): + """Detect system assembling""" + detectAssemble = re.compile("^\[assemble\]",re.S) + if filter(detectAssemble.search, + open("/etc/calculate/calculate2.env",'r')): + inidata = iniParser(inifile) + res = inidata.getVar("assemble","cl_assemble_step_world", + checkExistVar=True) + if not res[0] or not "finish" in _toUNICODE(res[1]).encode('utf-8'): + self.printERROR(_("System assembling was not completed.")) + return False + return True + else: + return False + def checkOpts(self, values, args): """Check values all specified options.""" if len(args) > 1: diff --git a/scripts/cl-image b/scripts/cl-image index afa2cc6..75f46dd 100644 --- a/scripts/cl-image +++ b/scripts/cl-image @@ -53,7 +53,7 @@ if __name__ == "__main__": # check root if not image.isRoot(): sys.exit(1) - if not image.isScratch(): + if not image.isAssemble() and not image.isScratch(): sys.exit(1) if not image.performActionByCommand(options,args): sys.exit(1)