|
|
|
@ -22,7 +22,7 @@ import re
|
|
|
|
|
import sys
|
|
|
|
|
import traceback
|
|
|
|
|
from os import path
|
|
|
|
|
from cl_utils import process,pathJoin
|
|
|
|
|
from cl_utils import process,pathJoin,getRunCommands
|
|
|
|
|
from subprocess import STDOUT,PIPE
|
|
|
|
|
from cl_print import color_print
|
|
|
|
|
from cl_datavars import DataVars
|
|
|
|
@ -82,6 +82,9 @@ class cl_builder(color_print):
|
|
|
|
|
def __init__(self):
|
|
|
|
|
self.clVars = None
|
|
|
|
|
self.startMessage = ""
|
|
|
|
|
self.startMessage = ""
|
|
|
|
|
self.clTempl = None
|
|
|
|
|
self.force = False
|
|
|
|
|
|
|
|
|
|
def setNoColor(self):
|
|
|
|
|
self.color = False
|
|
|
|
@ -91,9 +94,6 @@ class cl_builder(color_print):
|
|
|
|
|
self.clVars = DataVarsBuilder()
|
|
|
|
|
self.clVars.importBuilder()
|
|
|
|
|
self.clVars.flIniFile()
|
|
|
|
|
self.startMessage = ""
|
|
|
|
|
self.clTempl = None
|
|
|
|
|
self.force = False
|
|
|
|
|
|
|
|
|
|
def applyTemplatesForSquash(self,directory):
|
|
|
|
|
"""Apply templates for root of system."""
|
|
|
|
@ -104,8 +104,7 @@ class cl_builder(color_print):
|
|
|
|
|
dirsFiles = self.clTempl.applyTemplates()
|
|
|
|
|
self.clTempl.closeFiles()
|
|
|
|
|
if self.clTempl.getError():
|
|
|
|
|
self.printERROR(self.clTempl.getError())
|
|
|
|
|
return False
|
|
|
|
|
raise BuilderError(self.clTempl.getError())
|
|
|
|
|
else:
|
|
|
|
|
return dirsFiles
|
|
|
|
|
|
|
|
|
@ -121,8 +120,7 @@ class cl_builder(color_print):
|
|
|
|
|
dirsFiles = self.clTempl.applyTemplates()
|
|
|
|
|
self.clTempl.closeFiles()
|
|
|
|
|
if self.clTempl.getError():
|
|
|
|
|
self.printERROR(self.clTempl.getError())
|
|
|
|
|
return False
|
|
|
|
|
raise BuilderError(self.clTempl.getError())
|
|
|
|
|
else:
|
|
|
|
|
return dirsFiles
|
|
|
|
|
|
|
|
|
@ -183,6 +181,15 @@ class cl_builder(color_print):
|
|
|
|
|
return data[3]
|
|
|
|
|
return "Unknown"
|
|
|
|
|
|
|
|
|
|
def getParentMountFor(self,pathname):
|
|
|
|
|
dfProcess = process("/bin/df","-h",pathname)
|
|
|
|
|
data = dfProcess.readlines()
|
|
|
|
|
if len(data)>1:
|
|
|
|
|
data = filter(lambda x:x,"\t".join(data[1:]).split())
|
|
|
|
|
if len(data)>5:
|
|
|
|
|
return data[5]
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
def printInfo(self):
|
|
|
|
|
self.printSUCCESS(_("Creating image of") + " Calculate Linux")
|
|
|
|
|
self.defaultPrint("%s\n"%_("System information"))
|
|
|
|
@ -202,10 +209,23 @@ class cl_builder(color_print):
|
|
|
|
|
self.clVars.Get('cl_builder_image')))))
|
|
|
|
|
self.defaultPrint("%s\n"%_("Perform pre-install checkups"))
|
|
|
|
|
|
|
|
|
|
if self.clVars.Get('cl_builder_image'):
|
|
|
|
|
self.printSUCCESS(_("Image will be created at: %s\n")%
|
|
|
|
|
self.clVars.Get('cl_builder_image'))
|
|
|
|
|
|
|
|
|
|
imagefile = self.clVars.Get('cl_builder_image')
|
|
|
|
|
if imagefile:
|
|
|
|
|
self.printSUCCESS(_("Image will be created at: %s")% imagefile)
|
|
|
|
|
if self.getParentMountFor(path.dirname(path.normpath(
|
|
|
|
|
imagefile))) == "/":
|
|
|
|
|
if path.exists(imagefile):
|
|
|
|
|
self.printWARNING(_("WARNING") +": " +
|
|
|
|
|
_("image already exists") + ", "+
|
|
|
|
|
_("continuation of the operation will overwrite it"))
|
|
|
|
|
if self.clVars.Get('os_root_type')=='livecd':
|
|
|
|
|
self.printWARNING(_("WARNING") +": " +
|
|
|
|
|
_("image will be created on temporary filesystem"))
|
|
|
|
|
else:
|
|
|
|
|
self.printWARNING(_("WARNING") +": " +
|
|
|
|
|
_("image will be created on disk which mounted to root"))
|
|
|
|
|
|
|
|
|
|
self.defaultPrint("\n")
|
|
|
|
|
else:
|
|
|
|
|
self.printWARNING("No path for image creating.")
|
|
|
|
|
|
|
|
|
@ -220,6 +240,9 @@ class cl_builder(color_print):
|
|
|
|
|
self.clVars.Get('os_builder_linux_ver'))
|
|
|
|
|
self.printSUCCESS(_("Machine hardware name")+": %s"%
|
|
|
|
|
self.clVars.Get('os_builder_arch_machine'))
|
|
|
|
|
self.printSUCCESS(_("Free disk space on flash: %s")%
|
|
|
|
|
self.getFreeFor(path.normpath(
|
|
|
|
|
self.clVars.Get('cl_builder_iso_path'))))
|
|
|
|
|
self.defaultPrint("%s\n"%_("Perform pre-install checkups"))
|
|
|
|
|
|
|
|
|
|
self.printSUCCESS(_("Image will be created in: %s")%
|
|
|
|
@ -234,20 +257,24 @@ class cl_builder(color_print):
|
|
|
|
|
def checkVariables(self,rescratch=False):
|
|
|
|
|
"""Check values of variables"""
|
|
|
|
|
buildDirectory = self.clVars.Get('cl_builder_iso_path')
|
|
|
|
|
if len(filter(lambda x:"cl-builder" in x,getRunCommands()))>2:
|
|
|
|
|
self.printERROR(
|
|
|
|
|
_("Before proceeding, complete the program cl-builder"))
|
|
|
|
|
return False
|
|
|
|
|
if path.realpath(self.clVars.Get('cl_builder_path')) == "/":
|
|
|
|
|
self.printERROR("Source system should not be '/'")
|
|
|
|
|
self.printERROR(_("Source system should not be '/'"))
|
|
|
|
|
return False
|
|
|
|
|
if self.clVars.Get('os_builder_linux_ver') == "0":
|
|
|
|
|
self.printERROR("Can not found distributive version")
|
|
|
|
|
self.printERROR(_("Can not found distributive version"))
|
|
|
|
|
return False
|
|
|
|
|
elif not self.clVars.Get('os_builder_linux_shortname') in \
|
|
|
|
|
varsShare.dictNameSystem.keys():
|
|
|
|
|
self.printERROR("Distributive is not Calculate Linux")
|
|
|
|
|
self.printERROR(_("Distributive is not Calculate Linux"))
|
|
|
|
|
return False
|
|
|
|
|
elif not self.clVars.Get('cl_builder_kernel'):
|
|
|
|
|
self.printERROR("Can not detect kernel")
|
|
|
|
|
self.printERROR(_("Can not detect kernel"))
|
|
|
|
|
elif not self.clVars.Get('cl_builder_initrd_install'):
|
|
|
|
|
self.printERROR("Can not detect initramfs")
|
|
|
|
|
self.printERROR(_("Can not detect initramfs"))
|
|
|
|
|
return False
|
|
|
|
|
elif not rescratch and path.exists(buildDirectory):
|
|
|
|
|
self.printWARNING(
|
|
|
|
|