|
|
|
@ -197,7 +197,7 @@ class cl_builder(color_print):
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
chrootCommand.kill()
|
|
|
|
|
raise BuilderError(
|
|
|
|
|
_("An interrupt occurred during the command executing")+
|
|
|
|
|
_("Interrupted while executing the command")+
|
|
|
|
|
":\n %s"%self._getCommand(chrootCommand.command))
|
|
|
|
|
return chrootCommand
|
|
|
|
|
|
|
|
|
@ -250,7 +250,7 @@ class cl_builder(color_print):
|
|
|
|
|
self.printMessageForTest(_("Unmounting %s")%(target[len(mp):]))
|
|
|
|
|
umountProcess = process("umount",target)
|
|
|
|
|
if umountProcess.failed():
|
|
|
|
|
raise BuilderError(_("Can not umount %s")%target)
|
|
|
|
|
raise BuilderError(_("Failed to unmount %s")%target)
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
distrPath = distr.convertToDirectory().getDirectory()
|
|
|
|
|
self.cleanNeedlessKernelData(distrPath)
|
|
|
|
@ -283,7 +283,7 @@ class cl_builder(color_print):
|
|
|
|
|
"""Restore profile"""
|
|
|
|
|
if not self.curProfile:
|
|
|
|
|
return
|
|
|
|
|
self.printMessageForTest(_("Restore system profile"))
|
|
|
|
|
self.printMessageForTest(_("Restoring the system profile"))
|
|
|
|
|
builderPath = self.clVars.Get('cl_builder_path')
|
|
|
|
|
curProfileFile = pathJoin(builderPath,"etc/make.profile")
|
|
|
|
|
profile = self.clVars.Get('os_builder_profile')
|
|
|
|
@ -301,7 +301,7 @@ class cl_builder(color_print):
|
|
|
|
|
self.sourceDistr.close()
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
self.sourceDistr = None
|
|
|
|
|
self.printMessageForTest(_("Creating iso image"))
|
|
|
|
|
self.printMessageForTest(_("Creating the iso image"))
|
|
|
|
|
|
|
|
|
|
def flashPrepacking(self,directory):
|
|
|
|
|
self.printByResult(True)
|
|
|
|
@ -358,17 +358,18 @@ class cl_builder(color_print):
|
|
|
|
|
open(configPath,'r'))
|
|
|
|
|
if not res:
|
|
|
|
|
self.printERROR(_("ERROR") +": " +
|
|
|
|
|
_("kernel not support '%s' compression format for squashfs")%
|
|
|
|
|
_("the kernel does not support '%s' "
|
|
|
|
|
"compression format for squashfs")%
|
|
|
|
|
self.compression)
|
|
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def printInfo(self):
|
|
|
|
|
self.printSUCCESS(_("Creating image of") + " Calculate Linux")
|
|
|
|
|
self.printSUCCESS(_("Creating an image of") + " Calculate Linux")
|
|
|
|
|
self.defaultPrint("%s\n"%_("System information"))
|
|
|
|
|
subname = self.clVars.Get('os_builder_linux_subname')
|
|
|
|
|
subname = (" %s"%subname) if subname else ""
|
|
|
|
|
self.printSUCCESS(_("Building system")+": %s"%
|
|
|
|
|
self.printSUCCESS(_("System to be built")+": %s"%
|
|
|
|
|
self.clVars.Get('os_builder_linux_name')+subname)
|
|
|
|
|
self.printSUCCESS(_("System version")+": %s"%
|
|
|
|
|
self.clVars.Get('os_builder_linux_ver'))
|
|
|
|
@ -377,33 +378,35 @@ class cl_builder(color_print):
|
|
|
|
|
self.printSUCCESS(_("Free disk space for iso building: %s")%
|
|
|
|
|
self.getFreeFor(path.dirname(path.normpath(
|
|
|
|
|
self.clVars.Get('cl_builder_iso_path')))))
|
|
|
|
|
self.printSUCCESS(_("Free disk space for iso image: %s")%
|
|
|
|
|
self.printSUCCESS(_("Free disk space for the iso image: %s")%
|
|
|
|
|
self.getFreeFor(path.dirname(path.normpath(
|
|
|
|
|
self.clVars.Get('cl_builder_image')))))
|
|
|
|
|
self.defaultPrint("%s\n"%_("Perform pre-install checkups"))
|
|
|
|
|
self.defaultPrint("%s\n"%_("Performing pre-install checkups"))
|
|
|
|
|
|
|
|
|
|
imagefile = self.clVars.Get('cl_builder_image')
|
|
|
|
|
if imagefile:
|
|
|
|
|
self.printSUCCESS(_("Image will be created at: %s")% imagefile)
|
|
|
|
|
self.printSUCCESS(_("Image to be created at: %s")% imagefile)
|
|
|
|
|
if not self.checkSquashCompress():
|
|
|
|
|
return False
|
|
|
|
|
if path.exists(imagefile):
|
|
|
|
|
self.printWARNING(_("WARNING") +": " +
|
|
|
|
|
_("image already exists") + ", "+
|
|
|
|
|
_("continuation of the operation will overwrite it"))
|
|
|
|
|
_("this image already exists") + ", "+
|
|
|
|
|
_("continuing the operation will overwrite it"))
|
|
|
|
|
if self.getParentMountFor(path.dirname(path.normpath(
|
|
|
|
|
imagefile))) == "/":
|
|
|
|
|
if self.clVars.Get('os_root_type')=='livecd':
|
|
|
|
|
self.printWARNING(_("WARNING") +": " +
|
|
|
|
|
_("image will be created on temporary filesystem"))
|
|
|
|
|
_("the image will be created on a "
|
|
|
|
|
"temporary filesystem"))
|
|
|
|
|
else:
|
|
|
|
|
self.printWARNING(_("WARNING") +": " +
|
|
|
|
|
_("image will be created on disk which mounted to root"))
|
|
|
|
|
_("the image will be created on the disk mounted to root"))
|
|
|
|
|
warningProc = \
|
|
|
|
|
self.getProcessByRoot(self.clVars.Get('cl_builder_path'))
|
|
|
|
|
if warningProc:
|
|
|
|
|
self.printWARNING(_("WARNING") +": " +
|
|
|
|
|
_("continuation of the operation will kill follow process:"))
|
|
|
|
|
_("continuing the operation will kill the "
|
|
|
|
|
"following processes:"))
|
|
|
|
|
for procObj in warningProc:
|
|
|
|
|
self.printWARNING(
|
|
|
|
|
" %s"%" ".join(
|
|
|
|
@ -416,11 +419,12 @@ class cl_builder(color_print):
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def printRescratchInfo(self):
|
|
|
|
|
self.printSUCCESS(_("Rebuilding live image of") + " Calculate Linux")
|
|
|
|
|
self.printSUCCESS(_("Rebuilding the live image of") +
|
|
|
|
|
" Calculate Linux")
|
|
|
|
|
self.defaultPrint("%s\n"%_("System information"))
|
|
|
|
|
subname = self.clVars.Get('os_builder_linux_subname')
|
|
|
|
|
subname = (" %s"%subname) if subname else ""
|
|
|
|
|
self.printSUCCESS(_("Building system")+": %s"%
|
|
|
|
|
self.printSUCCESS(_("System to be built")+": %s"%
|
|
|
|
|
self.clVars.Get('os_builder_linux_name')+subname)
|
|
|
|
|
self.printSUCCESS(_("System version")+": %s"%
|
|
|
|
|
self.clVars.Get('os_builder_linux_ver'))
|
|
|
|
@ -429,15 +433,15 @@ class cl_builder(color_print):
|
|
|
|
|
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.defaultPrint("%s\n"%_("Performing pre-install checkups"))
|
|
|
|
|
|
|
|
|
|
self.printSUCCESS(_("Image will be created in: %s")%
|
|
|
|
|
self.printSUCCESS(_("Image to be created in: %s")%
|
|
|
|
|
self.clVars.Get('cl_builder_iso_path'))
|
|
|
|
|
if not self.checkSquashCompress():
|
|
|
|
|
return False
|
|
|
|
|
if self.clVars.Get('cl_builder_remove_squash'):
|
|
|
|
|
self.printSUCCESS(
|
|
|
|
|
_("Follow squash images will be removed: %s\n")%
|
|
|
|
|
_("The following squash images will be removed: %s\n")%
|
|
|
|
|
", ".join(self.clVars.Get('cl_builder_remove_squash')))
|
|
|
|
|
else:
|
|
|
|
|
self.defaultPrint("\n")
|
|
|
|
@ -448,30 +452,30 @@ class cl_builder(color_print):
|
|
|
|
|
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"))
|
|
|
|
|
_("Before proceeding, complete the cl-builder program"))
|
|
|
|
|
return False
|
|
|
|
|
if path.realpath(self.clVars.Get('cl_builder_path')) == "/":
|
|
|
|
|
self.printERROR(_("Source system should not be '/'"))
|
|
|
|
|
self.printERROR(_("The source system should not be '/'"))
|
|
|
|
|
return False
|
|
|
|
|
minver = "10.8"
|
|
|
|
|
if getTupleVersion(self.clVars.Get('os_builder_linux_ver')) < \
|
|
|
|
|
getTupleVersion(minver):
|
|
|
|
|
self.printERROR(_("Command is supported for system not less version"
|
|
|
|
|
" %s") % minver )
|
|
|
|
|
self.printERROR(_("Command supported only on system %s and higher")
|
|
|
|
|
% minver )
|
|
|
|
|
return False
|
|
|
|
|
elif not self.clVars.Get('os_builder_linux_shortname') in \
|
|
|
|
|
varsShare.dictNameSystem.keys():
|
|
|
|
|
self.printERROR(_("Distributive is not Calculate Linux"))
|
|
|
|
|
self.printERROR(_("This distribution is not Calculate Linux"))
|
|
|
|
|
return False
|
|
|
|
|
elif not self.clVars.Get('cl_builder_kernel'):
|
|
|
|
|
self.printERROR(_("Can not detect kernel"))
|
|
|
|
|
self.printERROR(_("Cannot detect the kernel"))
|
|
|
|
|
return False
|
|
|
|
|
elif not self.clVars.Get('cl_builder_initrd_install'):
|
|
|
|
|
self.printERROR(_("Can not detect initramfs"))
|
|
|
|
|
self.printERROR(_("Cannot detect initramfs"))
|
|
|
|
|
return False
|
|
|
|
|
elif not rescratch and path.exists(buildDirectory):
|
|
|
|
|
self.printWARNING(
|
|
|
|
|
_("Directory '%s' for building iso is already exists")%
|
|
|
|
|
_("Directory '%s' for iso building already exists")%
|
|
|
|
|
buildDirectory)
|
|
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
@ -503,18 +507,18 @@ class cl_builder(color_print):
|
|
|
|
|
self.sourceDistr = DirectoryDistributive(sourceDirectory,
|
|
|
|
|
mdirectory=bindDirectory)
|
|
|
|
|
if not force:
|
|
|
|
|
dialogMessage = _("Continue the creating image of the system") \
|
|
|
|
|
dialogMessage = _("Continue creating the system image") \
|
|
|
|
|
+ " (yes/no)"
|
|
|
|
|
dialogRes = dialogYesNo(dialogMessage)
|
|
|
|
|
if dialogRes in (None,False):
|
|
|
|
|
self.assembleIso = False
|
|
|
|
|
self.printERROR(_("Interrupting the image creating"))
|
|
|
|
|
self.printERROR(_("Image creating interrupted"))
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
killMap = [(0,15,_("Terminating %s processes")),
|
|
|
|
|
(4,9,_("Kill %s processes")),
|
|
|
|
|
(2,0,None),
|
|
|
|
|
(10,9,_("Repeat kill %s processes"))]
|
|
|
|
|
(10,9,_("Killing again %s processes"))]
|
|
|
|
|
listing = self.getProcessByRoot(self.clVars.Get('cl_builder_path'))
|
|
|
|
|
for waitTime,killCode,msg in killMap:
|
|
|
|
|
sleep(waitTime)
|
|
|
|
@ -529,30 +533,22 @@ class cl_builder(color_print):
|
|
|
|
|
continue
|
|
|
|
|
for i in listing:
|
|
|
|
|
os.kill(int(i['pid']),killCode)
|
|
|
|
|
self.printMessageForTest(_("Prepare data for live image"))
|
|
|
|
|
self.printMessageForTest(_("Preparing data for the live image"))
|
|
|
|
|
self.prepareSourceDistributive(self.sourceDistr)
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
self.targetDistr.prepareIso = self.isoPrepacking
|
|
|
|
|
self.printMessageForTest(_("Creating squash image"))
|
|
|
|
|
self.printMessageForTest(_("Creating the squash image"))
|
|
|
|
|
self.targetDistr.installFrom(self.sourceDistr)
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
if self.clVars.Get('cl_builder_isohybrid_set') == 'on':
|
|
|
|
|
self.printMessageForTest(_("Performing isohybrid"))
|
|
|
|
|
processIsoHybrid = process("/usr/bin/isohybrid",isoFile)
|
|
|
|
|
self.printByResult(processIsoHybrid.success())
|
|
|
|
|
self.printMessageForTest(_("Creating installed package list"))
|
|
|
|
|
self.printMessageForTest(_("Generating the list of installed packages"))
|
|
|
|
|
self.printByResult(self.createPackageList(sourceDirectory,
|
|
|
|
|
isoFile[:-4]+".list"))
|
|
|
|
|
self.printMessageForTest(_("Creating DIGESTS file"))
|
|
|
|
|
self.printMessageForTest(_("Creating the DIGESTS file"))
|
|
|
|
|
self.printByResult(self.createDigest(isoFile,isoFile+".DIGESTS"))
|
|
|
|
|
|
|
|
|
|
#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):
|
|
|
|
@ -572,7 +568,7 @@ class cl_builder(color_print):
|
|
|
|
|
if not (self.clVars.Get('os_root_type') == 'livecd' \
|
|
|
|
|
and os.access(self.clVars.Get('cl_builder_iso_path'),os.W_OK)):
|
|
|
|
|
self.printERROR(
|
|
|
|
|
_("The computer must be load from the flash in Builder mode"))
|
|
|
|
|
_("Your computer must be booted from flash in Builder mode"))
|
|
|
|
|
return False
|
|
|
|
|
if not self.printRescratchInfo():
|
|
|
|
|
return False
|
|
|
|
@ -586,7 +582,7 @@ class cl_builder(color_print):
|
|
|
|
|
self.sourceDistr = DirectoryDistributive(sourceDirectory,
|
|
|
|
|
mdirectory=bindDirectory)
|
|
|
|
|
if not force:
|
|
|
|
|
dialogMessage = _("Continue the rebuilding flash live system") \
|
|
|
|
|
dialogMessage = _("Continue rebuilding the flash live system") \
|
|
|
|
|
+ " (yes/no)"
|
|
|
|
|
dialogRes = dialogYesNo(dialogMessage)
|
|
|
|
|
if dialogRes in (None,False):
|
|
|
|
@ -598,18 +594,18 @@ class cl_builder(color_print):
|
|
|
|
|
try:
|
|
|
|
|
map(lambda x:os.unlink(x),oldImages)
|
|
|
|
|
except (Exception,KeyboardInterrupt),e:
|
|
|
|
|
raise BuilderError(_("Can not remove old files")+":\n%s"%str(e))
|
|
|
|
|
raise BuilderError(_("Failed to remove old files")+":\n%s"%str(e))
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
|
|
|
|
|
self.printMessageForTest(_("Prepare data for live image"))
|
|
|
|
|
self.printMessageForTest(_("Preparing data for the live image"))
|
|
|
|
|
self.prepareSourceDistributive(self.sourceDistr)
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
self.targetDistr.prepareIso = self.flashPrepacking
|
|
|
|
|
self.printMessageForTest(_("Creating squash image"))
|
|
|
|
|
self.printMessageForTest(_("Creating the squash image"))
|
|
|
|
|
self.targetDistr.installFrom(self.sourceDistr)
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
|
|
|
|
|
self.printMessageForTest(_("Performing syncronization"))
|
|
|
|
|
self.printMessageForTest(_("Synchronizing"))
|
|
|
|
|
processSync = process("/bin/sync")
|
|
|
|
|
self.printByResult(processSync.success())
|
|
|
|
|
return True
|
|
|
|
@ -639,7 +635,7 @@ class cl_builder(color_print):
|
|
|
|
|
except KeyboardInterrupt,e:
|
|
|
|
|
self.printByResult(False)
|
|
|
|
|
self.printWARNING("Interrupting the iso building")
|
|
|
|
|
error = _("Iso building manually interrupt")
|
|
|
|
|
error = _("Iso building interrupted manually")
|
|
|
|
|
if error:
|
|
|
|
|
self.printByResult(False)
|
|
|
|
|
try:
|
|
|
|
@ -650,7 +646,8 @@ class cl_builder(color_print):
|
|
|
|
|
self.sourceDistr.close()
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
if self.targetDistr:
|
|
|
|
|
self.printMessageForTest(_("Unmount built system volume"))
|
|
|
|
|
self.printMessageForTest(
|
|
|
|
|
_("Unmount the partition bound for assemble"))
|
|
|
|
|
self.targetDistr.close()
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
if self.assembleIso:
|
|
|
|
@ -665,12 +662,12 @@ class cl_builder(color_print):
|
|
|
|
|
if error:
|
|
|
|
|
for line in filter(lambda x: x,str(error).split('\n')):
|
|
|
|
|
self.printERROR(line)
|
|
|
|
|
self.printERROR(_("System building failed"))
|
|
|
|
|
self.printERROR(_("Failed to build the system"))
|
|
|
|
|
return False
|
|
|
|
|
self.printSUCCESS(_("System has built successfully"))
|
|
|
|
|
self.printSUCCESS(_("System built successfully"))
|
|
|
|
|
if self.assembleIso:
|
|
|
|
|
self.printWARNING(_("If you want emerge packages manually in "
|
|
|
|
|
"assembling system, please perform:"))
|
|
|
|
|
self.printWARNING(_("If you want to emerge packages manually "
|
|
|
|
|
"on the system you are assembling, please execute:"))
|
|
|
|
|
self.printWARNING(" cl-make -p %s -T"%
|
|
|
|
|
self.clVars.Get('os_builder_profile'))
|
|
|
|
|
return True
|
|
|
|
@ -696,7 +693,7 @@ class cl_builder(color_print):
|
|
|
|
|
args = ["mount"]+opts.split()+[str(source).lower(),target]
|
|
|
|
|
mountProcess = process(*args)
|
|
|
|
|
if mountProcess.failed():
|
|
|
|
|
raise BuilderError(_("Can not mount %(from)s to %(to)s")%
|
|
|
|
|
raise BuilderError(_("Failed to mount %(from)s to %(to)s")%
|
|
|
|
|
{'from':source,'to':target})
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
|
|
|
|
@ -728,17 +725,18 @@ class cl_builder(color_print):
|
|
|
|
|
elif not likeProfile:
|
|
|
|
|
self.printERROR(_("wrong value for '--profile'"))
|
|
|
|
|
self.printERROR(
|
|
|
|
|
_("specify '-p list' for print "
|
|
|
|
|
"all available assembled distro"))
|
|
|
|
|
_("specify '-p list' to print all available "
|
|
|
|
|
"distributions to be built"))
|
|
|
|
|
return False
|
|
|
|
|
else:
|
|
|
|
|
self.printERROR(
|
|
|
|
|
_("specified value of '--profile' is ambiguous. "
|
|
|
|
|
"Please specify profile more exactly."))
|
|
|
|
|
self.defaultPrint(_("Select profile from")+":\n")
|
|
|
|
|
"Please specify profile with more precision."))
|
|
|
|
|
self.defaultPrint(_("Select a profile from")+":\n")
|
|
|
|
|
else:
|
|
|
|
|
likeProfile = self.clVars.Get('cl_builder_distro')
|
|
|
|
|
self.defaultPrint(_("Available assembled distro")+":\n")
|
|
|
|
|
self.defaultPrint(
|
|
|
|
|
_("Available distributions to be built")+":\n")
|
|
|
|
|
for profile in likeProfile:
|
|
|
|
|
self.printSUCCESS(profile)
|
|
|
|
|
return False
|
|
|
|
@ -760,8 +758,9 @@ class cl_builder(color_print):
|
|
|
|
|
if not path.exists(chrootdir):
|
|
|
|
|
return False
|
|
|
|
|
try:
|
|
|
|
|
packageList = sorted(reduce(lambda x,y:x+map(lambda x:path.join(y,x),
|
|
|
|
|
os.listdir(path.join(pkgdir,y))), os.listdir(pkgdir),[]))
|
|
|
|
|
packageList = \
|
|
|
|
|
sorted(reduce(lambda x,y:x+map(lambda x:path.join(y,x),
|
|
|
|
|
os.listdir(path.join(pkgdir,y))), os.listdir(pkgdir),[]))
|
|
|
|
|
open(filename,'w').writelines(map(lambda x:"%s\n"%x,packageList))
|
|
|
|
|
except (IOError,OSError),e:
|
|
|
|
|
return False
|
|
|
|
|