|
|
|
@ -25,7 +25,7 @@ from os import path
|
|
|
|
|
from cl_template import template,iniParser
|
|
|
|
|
from cl_utils import process,pathJoin,getRunCommands,getTupleVersion,isMount,\
|
|
|
|
|
isFstabMount,childMounts,_toUNICODE,cmpVersion, \
|
|
|
|
|
listDirectory
|
|
|
|
|
listDirectory, readFile, removeDir, isPkgInstalled
|
|
|
|
|
from subprocess import STDOUT,PIPE
|
|
|
|
|
from cl_print import color_print
|
|
|
|
|
from cl_datavars import DataVars
|
|
|
|
@ -122,6 +122,12 @@ class cl_assemble(color_print):
|
|
|
|
|
'hideout':True,
|
|
|
|
|
'message':_("Configuring with %s templates")% "assemble"
|
|
|
|
|
},
|
|
|
|
|
{'command':"_migratePortage()",
|
|
|
|
|
'foraction':('syncupdate',),
|
|
|
|
|
'step':"migrate",
|
|
|
|
|
'hideout':True,
|
|
|
|
|
'message':_("Checking portage repository")
|
|
|
|
|
},
|
|
|
|
|
{'command':'eix-sync',
|
|
|
|
|
'progname':'eix-sync',
|
|
|
|
|
'message':_("Updating portages"),
|
|
|
|
@ -330,11 +336,12 @@ class cl_assemble(color_print):
|
|
|
|
|
self.printSUCCESS(_("File system: %s")%
|
|
|
|
|
self.clVars.Get('os_assemble_root_format'))
|
|
|
|
|
if self.clVars.Get('cl_assemble_sync'):
|
|
|
|
|
self.printSUCCESS(_("Portage rsync mirror: %s")%
|
|
|
|
|
self.printSUCCESS(_("Portage mirror: %s")%
|
|
|
|
|
self.clVars.Get('cl_assemble_sync'))
|
|
|
|
|
self.printSUCCESS(_("Stage for assembling: %s")%
|
|
|
|
|
(self.clVars.Get('cl_assemble_image') or _("none")))
|
|
|
|
|
if self.clVars.Get('cl_assemble_image_type') == "stage":
|
|
|
|
|
if self.clVars.Get('cl_assemble_image_type') == "stage" and \
|
|
|
|
|
self.clVars.Get('cl_assemble_branch') == '':
|
|
|
|
|
self.printSUCCESS(_("Portage snapshot for assemble: %s")%
|
|
|
|
|
(self.clVars.Get('cl_assemble_snapshot_portage') or _("none")))
|
|
|
|
|
self.defaultPrint("%s\n"%_("Checking up before assemble"))
|
|
|
|
@ -464,6 +471,7 @@ class cl_assemble(color_print):
|
|
|
|
|
'os_assemble_root_dev',
|
|
|
|
|
'cl_assemble_path',
|
|
|
|
|
'cl_assemble_sync',
|
|
|
|
|
'cl_assemble_branch',
|
|
|
|
|
'cl_assemble_buildpkg_set',
|
|
|
|
|
'cl_assemble_pkgdir')
|
|
|
|
|
|
|
|
|
@ -510,8 +518,44 @@ class cl_assemble(color_print):
|
|
|
|
|
DirectoryDistributive(target,parent=self.targetDistr)
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
|
|
|
|
|
def _migratePortage(self):
|
|
|
|
|
if self.clVars.Get('cl_assemble_branch'):
|
|
|
|
|
if not isPkgInstalled('dev-vcs/git',prefix=self.assemblePath):
|
|
|
|
|
self.printMessageForTest(_("Installing %s")%'dev-vcs/git')
|
|
|
|
|
self.runChroot("emerge -1 git")
|
|
|
|
|
portagePath = pathJoin(self.assemblePath,'usr/portage')
|
|
|
|
|
gitConfig = pathJoin(portagePath, '.git/config')
|
|
|
|
|
# check for repository contains .git and
|
|
|
|
|
# this git from cl_assemble_sync url
|
|
|
|
|
reUrl = re.compile('url\s*=\s*(.*)')
|
|
|
|
|
gitUrl = reUrl.search(readFile(gitConfig))
|
|
|
|
|
# need remove portage and reget from sync address
|
|
|
|
|
self.printMessageForTest(_("Fetching portages"))
|
|
|
|
|
if not gitUrl or \
|
|
|
|
|
gitUrl.group(1).strip() != self.clVars.Get('cl_assemble_sync'):
|
|
|
|
|
removeDir(portagePath)
|
|
|
|
|
getPortage = "git clone --depth 1 -n {gitrep} {portage}".format(
|
|
|
|
|
gitrep=self.clVars.Get('cl_assemble_sync'),
|
|
|
|
|
portage='/usr/portage')
|
|
|
|
|
self.runChroot(getPortage)
|
|
|
|
|
else:
|
|
|
|
|
getPortage = "cd {portage};git fetch".format(
|
|
|
|
|
gitrep=self.clVars.Get('cl_assemble_sync'),
|
|
|
|
|
portage='/usr/portage')
|
|
|
|
|
self.runChroot(getPortage)
|
|
|
|
|
updateBranch= "cd {portage};git checkout {branch}".format(
|
|
|
|
|
portage='/usr/portage',
|
|
|
|
|
branch=self.clVars.Get('cl_assemble_branch'))
|
|
|
|
|
self.runChroot(updateBranch)
|
|
|
|
|
else:
|
|
|
|
|
portagePath = pathJoin(self.assemblePath,'usr/portage')
|
|
|
|
|
gitConfig = pathJoin(portagePath, '.git/config')
|
|
|
|
|
if path.exists(gitConfig):
|
|
|
|
|
removeDir(portagePath)
|
|
|
|
|
|
|
|
|
|
def _updatePackages(self):
|
|
|
|
|
"""Update portage and calculate overlay"""
|
|
|
|
|
self._migratePortage()
|
|
|
|
|
emergeSync = "emerge --sync"
|
|
|
|
|
self.printMessageForTest(_("Updating portages"))
|
|
|
|
|
self.runChroot(emergeSync)
|
|
|
|
@ -611,7 +655,8 @@ class cl_assemble(color_print):
|
|
|
|
|
pathAppMisc = pathJoin(self.assemblePath,'/var/db/pkg/app-misc')
|
|
|
|
|
metaPackage = self.clVars.Get('cl_assemble_meta').rpartition('/')[2]
|
|
|
|
|
|
|
|
|
|
if not isinstance(self.sourceDistr,IsoDistributive):
|
|
|
|
|
if not isinstance(self.sourceDistr,IsoDistributive) and \
|
|
|
|
|
self.clVars.Get('cl_assemble_branch') == '':
|
|
|
|
|
self._unpackPortage()
|
|
|
|
|
|
|
|
|
|
self._prepareMount()
|
|
|
|
@ -739,10 +784,13 @@ class cl_assemble(color_print):
|
|
|
|
|
|
|
|
|
|
def setSyncMirror(self,mirror):
|
|
|
|
|
"""Set sync mirror"""
|
|
|
|
|
reMirror = re.compile("^(rsync:)?/?/?([^:]+)$",re.S)
|
|
|
|
|
reMirror = re.compile("^(rsync:|git:)?/?/?([^:]+)$",re.S)
|
|
|
|
|
res = reMirror.search(mirror)
|
|
|
|
|
if res:
|
|
|
|
|
self.clVars.Set('cl_assemble_sync',"//%s"%res.groups()[1],True)
|
|
|
|
|
if res.groups()[0] == "git:":
|
|
|
|
|
self.clVars.Set('cl_assemble_sync',"git://%s"%res.groups()[1],True)
|
|
|
|
|
else:
|
|
|
|
|
self.clVars.Set('cl_assemble_sync',"//%s"%res.groups()[1],True)
|
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
return False
|
|
|
|
|