|
|
@ -23,7 +23,8 @@ import sys
|
|
|
|
import traceback
|
|
|
|
import traceback
|
|
|
|
from os import path
|
|
|
|
from os import path
|
|
|
|
from cl_utils import process,pathJoin,getRunCommands,getTupleVersion,\
|
|
|
|
from cl_utils import process,pathJoin,getRunCommands,getTupleVersion,\
|
|
|
|
childMounts,_toUNICODE,isMount
|
|
|
|
childMounts,_toUNICODE,isMount,typeFile, \
|
|
|
|
|
|
|
|
removeDir
|
|
|
|
from subprocess import STDOUT,PIPE
|
|
|
|
from subprocess import STDOUT,PIPE
|
|
|
|
from cl_print import color_print
|
|
|
|
from cl_print import color_print
|
|
|
|
from cl_datavars import DataVars
|
|
|
|
from cl_datavars import DataVars
|
|
|
@ -158,6 +159,59 @@ class cl_builder(color_print):
|
|
|
|
self.printERROR(failMessage)
|
|
|
|
self.printERROR(failMessage)
|
|
|
|
self.startMessage = ""
|
|
|
|
self.startMessage = ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _getCommand(self,commandlist):
|
|
|
|
|
|
|
|
return " ".join(map(lambda x:'"%s"'%x if " " in x else x,commandlist))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def runChroot(self,chroot,command):
|
|
|
|
|
|
|
|
"""Run command in chroot specified by cl_assemble_path"""
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
envdict = {'CHROOT':"on"}
|
|
|
|
|
|
|
|
envdict.update(os.environ)
|
|
|
|
|
|
|
|
commandLine = ["chroot",chroot,
|
|
|
|
|
|
|
|
"/bin/bash","-c",command]
|
|
|
|
|
|
|
|
chrootCommand = process(*commandLine,stderr=PIPE,
|
|
|
|
|
|
|
|
stdout=PIPE,envdict=envdict)
|
|
|
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
|
|
|
chrootCommand.kill()
|
|
|
|
|
|
|
|
raise BuilderError(
|
|
|
|
|
|
|
|
_("An interrupt occurred during the command executing")+
|
|
|
|
|
|
|
|
":\n %s"%self._getCommand(chrootCommand.command))
|
|
|
|
|
|
|
|
return chrootCommand
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def cleanNeedlessKernelData(self, distrPath):
|
|
|
|
|
|
|
|
"""Cleaning needless kernel files from /boot,/lib/modules,/usr/src"""
|
|
|
|
|
|
|
|
self.printMessageForTest(_("Cleaning %s directory")% "/boot")
|
|
|
|
|
|
|
|
bootDir = path.join(distrPath, "boot")
|
|
|
|
|
|
|
|
modulesDir = path.join(distrPath, "lib/modules")
|
|
|
|
|
|
|
|
reTrash =re.compile("^(?:config|initramfs|vmlinuz|System.map)")
|
|
|
|
|
|
|
|
rightKernelFiles = \
|
|
|
|
|
|
|
|
[self.clVars.Get('cl_builder_initrd_install'),
|
|
|
|
|
|
|
|
self.clVars.Get('cl_builder_kernel'),
|
|
|
|
|
|
|
|
self.clVars.Get('cl_builder_kernel_config'),
|
|
|
|
|
|
|
|
self.clVars.Get('cl_builder_kernel_systemmap')]
|
|
|
|
|
|
|
|
delFiles = filter(lambda x: not x in rightKernelFiles,
|
|
|
|
|
|
|
|
filter(reTrash.search,
|
|
|
|
|
|
|
|
os.listdir(bootDir)))
|
|
|
|
|
|
|
|
map(lambda x:os.unlink(path.join(bootDir,x)),delFiles)
|
|
|
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
|
|
|
self.printMessageForTest(_("Cleaning %s directory") % "/lib/modules")
|
|
|
|
|
|
|
|
reKernelVer = re.compile(" version (\S+)\s",re.S)
|
|
|
|
|
|
|
|
ftype = typeFile(magic=0x4).getMType
|
|
|
|
|
|
|
|
resReg = reKernelVer.search(ftype(path.join(bootDir,
|
|
|
|
|
|
|
|
self.clVars.Get('cl_builder_kernel'))))
|
|
|
|
|
|
|
|
if resReg:
|
|
|
|
|
|
|
|
kernelVersion = resReg.groups()[0]
|
|
|
|
|
|
|
|
map(lambda x:removeDir(path.join(modulesDir,x)),
|
|
|
|
|
|
|
|
filter(lambda x:x != kernelVersion,
|
|
|
|
|
|
|
|
os.listdir(modulesDir)))
|
|
|
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
|
|
|
self.printMessageForTest(_("Cleaning %s directory")% "/usr/src")
|
|
|
|
|
|
|
|
removeKernelSources = filter(lambda x:x and x != "/usr/src/linux",
|
|
|
|
|
|
|
|
self.runChroot(distrPath,"qfile -o /usr/src/*"))
|
|
|
|
|
|
|
|
map(lambda x:removeDir(path.join(distrPath,x)),
|
|
|
|
|
|
|
|
removeKernelSources)
|
|
|
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
|
|
|
|
|
|
|
def prepareSourceDistributive(self,distr):
|
|
|
|
def prepareSourceDistributive(self,distr):
|
|
|
|
"""Unmount all bind,proc mount points from source distribute"""
|
|
|
|
"""Unmount all bind,proc mount points from source distribute"""
|
|
|
|
mp = self.clVars.Get('cl_builder_path')
|
|
|
|
mp = self.clVars.Get('cl_builder_path')
|
|
|
@ -168,7 +222,9 @@ class cl_builder(color_print):
|
|
|
|
if umountProcess.failed():
|
|
|
|
if umountProcess.failed():
|
|
|
|
raise AssembleError(_("Can not umount %s")%target)
|
|
|
|
raise AssembleError(_("Can not umount %s")%target)
|
|
|
|
self.printByResult(True)
|
|
|
|
self.printByResult(True)
|
|
|
|
self.applyTemplatesForSquash(distr.convertToDirectory().getDirectory())
|
|
|
|
distrPath = distr.convertToDirectory().getDirectory()
|
|
|
|
|
|
|
|
self.cleanNeedlessKernelData(distrPath)
|
|
|
|
|
|
|
|
self.applyTemplatesForSquash(distrPath)
|
|
|
|
|
|
|
|
|
|
|
|
def isoPrepacking(self,directory):
|
|
|
|
def isoPrepacking(self,directory):
|
|
|
|
self.printByResult(True)
|
|
|
|
self.printByResult(True)
|
|
|
|