Add exclude portage tree from image.

master
Mike Hiretsky 13 years ago
parent 676fb23991
commit 78e8a943c7

Binary file not shown.

@ -24,7 +24,7 @@ import traceback
from os import path
from cl_utils import process,pathJoin,getRunCommands,getTupleVersion,\
childMounts,_toUNICODE,isMount,typeFile, \
removeDir, pathJoin
removeDir, pathJoin,listDirectory
from subprocess import STDOUT,PIPE
from cl_print import color_print
from cl_datavars import DataVars
@ -87,7 +87,6 @@ class cl_builder(color_print):
def __init__(self):
self.clVars = None
self.startMessage = ""
self.startMessage = ""
self.clTempl = None
self.force = False
self.assembleIso = False
@ -213,6 +212,38 @@ class cl_builder(color_print):
removeKernelSources)
self.printByResult(True)
def restorePortageTree(self,distrPath):
"""Move {distrPath}/usr/portage/EXCLUDE/* to /usr/portage/"""
try:
portagePath = pathJoin(distrPath,'usr/portage')
excludeDir = pathJoin(portagePath,"EXCLUDE")
if path.exists(excludeDir):
mvList = listDirectory(excludeDir)
for obj in mvList:
os.rename(pathJoin(excludeDir,obj),
pathJoin(portagePath,obj))
os.rmdir(excludeDir)
except OSError,e:
return False
return True
def movePortageTree(self,distrPath):
"""Move {distrPath}/usr/portage/* to /usr/portage/EXCLUDE"""
try:
portagePath = pathJoin(distrPath,'usr/portage')
excludeDir = pathJoin(portagePath,"EXCLUDE")
if not path.exists(excludeDir):
os.makedirs(excludeDir)
mvList = filter(lambda x: not x in
('eclass','licenses','profiles','EXCLUDE'),
listDirectory(portagePath))
for obj in mvList:
os.rename(pathJoin(portagePath,obj),
pathJoin(excludeDir,obj))
except OSError,e:
raise BuilderError(_("Can not remove portage tree: %s\n")%e)
def prepareSourceDistributive(self,distr):
"""Unmount all bind,proc mount points from source distribute"""
mp = self.clVars.Get('cl_builder_path')
@ -231,6 +262,11 @@ class cl_builder(color_print):
updateLayman = self.runChroot(distrPath,"layman -s calculate")
self.printByResult(updateLayman.success())
# move portage to EXCLUDE directory
if self.clVars.Get('cl_builder_tree') == 'off':
self.printMessageForTest(_("Removing portage tree"))
self.movePortageTree(distrPath)
self.applyTemplatesForSquash(distrPath)
# change make.profile
builderPath = self.clVars.Get('cl_builder_path')
@ -569,6 +605,10 @@ class cl_builder(color_print):
if self.clTempl:
self.clTempl.closeFiles()
if self.sourceDistr:
if self.clVars.Get('cl_builder_tree') == 'off':
self.printMessageForTest(_("Restoring portage tree"))
distrPath = self.sourceDistr.convertToDirectory().getDirectory()
self.printByResult(self.restorePortageTree(distrPath))
self.printMessageForTest(_("Releasing source data"))
self.sourceDistr.close()
self.printByResult(True)

@ -38,6 +38,9 @@ CMD_OPTIONS = [{'shortOption':"p",
'optVal':"PROFILE",
'help':_("system profile")
},
{'longOption':'notree',
'help':_("exclude portage tree from image")
},
{'longOption':"set"},
{'shortOption':"f",
'longOption':"force",
@ -122,6 +125,9 @@ class image_cmd(share_cmd):
if not self.logicObj.setAssembleData(values.p,values.v):
sys.exit(1)
if values.notree:
self.logicObj.clVars.Set('cl_builder_tree','off',True)
if args and args[0] == "squash":
self.logicObj.clVars.Set('cl_builder_iso_path','/mnt/flash',True)
self.optobj.checkVarSyntax(values)

@ -97,6 +97,9 @@ class Data:
# kernel suffix for builder
cl_builder_kernel_suffix = {}
# include portage directory from image
cl_builder_tree = {'value':'on'}
# build system name
os_builder_linux_name = {}

Loading…
Cancel
Save