Added ability of specifing git repository for portages.

develop
Mike Hiretsky 13 years ago
parent e6ab451782
commit cc1b3e942e

@ -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

@ -34,7 +34,7 @@ DESCRIPTION = _("Configure for assembling Calculate Linux")
CMD_OPTIONS = [{'shortOption':"d",
'longOption':"disk",
'optVal':"DISK",
'help':_("partition intended for assemble")
'help':_("partition or directory intended for assemble")
},
{'shortOption':"p",
'longOption':"profile",
@ -126,7 +126,7 @@ class assemble_cmd(share_cmd):
rootDev in self.logicObj.clVars.Get('cl_assemble_dev')) and \
not self.logicObj.tryUseAvailable():
self.optobj.error(
_("disk must be specified with the '-d' option"))
_("partition must be specified with the '-d' option"))
if values.d:
self.logicObj.clVars.Set('os_assemble_root_dev',values.d,True)
if values.sync:

@ -339,6 +339,15 @@ class fillVars(installFillVars):
val = self.getValueFromConfig(makepath,"SYNC")
if val != False:
return val[6:]
return "git://git.calculate.ru/dev/portage.git"
def get_cl_assemble_branch(self):
"""Preferred branch of git portage mirror"""
fromEnv = self._getFromEnv('cl_assemble_branch')
if fromEnv:
return fromEnv
if self.Get('cl_assemble_sync').startswith('git:'):
return "master"
return ""
def get_cl_assemble_source(self):

@ -54,6 +54,9 @@ class Data:
# preferred rsync mirror for portages
cl_assemble_sync = {}
# preferred git branch for portages
cl_assemble_branch = {'mode':'w'}
# type of source (stage of system name)
cl_assemble_source = {}

Loading…
Cancel
Save