|
|
|
@ -35,6 +35,8 @@ from ..profile import RepositoryStorageSet, DEFAULT_BRANCH, \
|
|
|
|
|
from calculate.lib.variables import linux as lib_linux
|
|
|
|
|
from calculate.lib.variables import env
|
|
|
|
|
from calculate.update.update_info import UpdateInfo
|
|
|
|
|
import urllib2
|
|
|
|
|
import time
|
|
|
|
|
from functools import partial
|
|
|
|
|
|
|
|
|
|
_ = lambda x:x
|
|
|
|
@ -165,11 +167,13 @@ class VariableClUpdateRepPath(ReadonlyVariable):
|
|
|
|
|
Пути до репозиториев
|
|
|
|
|
"""
|
|
|
|
|
type = "list"
|
|
|
|
|
mapPath = {'portage':'usr/portage'}
|
|
|
|
|
mapPath = {'portage': 'usr/portage',
|
|
|
|
|
'gentoo': '/usr/portage'}
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
repPath = self.Get('cl_update_layman_storage')
|
|
|
|
|
chroot_path = self.Get('cl_chroot_path')
|
|
|
|
|
|
|
|
|
|
def generatePaths(names):
|
|
|
|
|
for name in names:
|
|
|
|
|
if name in self.mapPath:
|
|
|
|
@ -217,8 +221,7 @@ class VariableClUpdateBranch(TableVariable):
|
|
|
|
|
self.help = _("set branches for repository (REPOSITORY:BRANCH)")
|
|
|
|
|
self.label = _("Repositories branches")
|
|
|
|
|
|
|
|
|
|
def raiseReadonlyIndexError(self,fieldname="",variablename="",
|
|
|
|
|
value=""):
|
|
|
|
|
def raiseReadonlyIndexError(self, fieldname="", variablename="", value=""):
|
|
|
|
|
"""
|
|
|
|
|
Неизвестный оврелей
|
|
|
|
|
"""
|
|
|
|
@ -236,6 +239,94 @@ class VariableClUpdateBranchRep(ReadonlyVariable):
|
|
|
|
|
def get(self):
|
|
|
|
|
return self.Get('cl_update_rep_name')
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateBinhostData(ReadonlyTableVariable):
|
|
|
|
|
"""
|
|
|
|
|
Содержимое файла revisions
|
|
|
|
|
"""
|
|
|
|
|
source = ["cl_update_binhost_host",
|
|
|
|
|
"cl_update_binhost_revisions",
|
|
|
|
|
"cl_update_binhost_time"]
|
|
|
|
|
|
|
|
|
|
def check_binhost(self, binhost):
|
|
|
|
|
revision_files = [path.join(binhost, x)
|
|
|
|
|
for x in self.Get('cl_update_revision_path')]
|
|
|
|
|
timeout = self.GetInteger('cl_update_binhost_timeout')
|
|
|
|
|
try:
|
|
|
|
|
data = None
|
|
|
|
|
t = time.time()
|
|
|
|
|
for fn in revision_files:
|
|
|
|
|
if data is None:
|
|
|
|
|
data = urllib2.urlopen(fn, timeout=timeout).read()
|
|
|
|
|
elif data != urllib2.urlopen(fn, timeout=timeout).read():
|
|
|
|
|
return "", str(-1)
|
|
|
|
|
return data, str(int((time.time() - t)*1000))
|
|
|
|
|
except urllib2.URLError:
|
|
|
|
|
return "", str(-1)
|
|
|
|
|
|
|
|
|
|
re_revison = re.compile("\w+=(\w+)")
|
|
|
|
|
|
|
|
|
|
def binhost_key(self, data):
|
|
|
|
|
host, data, time = data
|
|
|
|
|
try:
|
|
|
|
|
cp = ConfigParser()
|
|
|
|
|
cp.read_string(data.decode('utf-8'))
|
|
|
|
|
data = sum(int(x) for x in cp['vcs'].values())
|
|
|
|
|
except (TypeError, KeyError) as e:
|
|
|
|
|
data = 0
|
|
|
|
|
return (1 if int(time) >= 0 else 0,
|
|
|
|
|
data,
|
|
|
|
|
-int(time))
|
|
|
|
|
|
|
|
|
|
def get(self, hr=False):
|
|
|
|
|
def generate():
|
|
|
|
|
recheck = self.GetBool('cl_update_binhost_recheck_set')
|
|
|
|
|
base_dn = self.Get('cl_update_binhost')
|
|
|
|
|
for host in [base_dn] + [x for x in self.Get('cl_update_binhosts')
|
|
|
|
|
if x != base_dn]:
|
|
|
|
|
if host:
|
|
|
|
|
data, t = self.check_binhost(host)
|
|
|
|
|
yield host, data, str(t)
|
|
|
|
|
if not recheck and t >= 0 and base_dn == host:
|
|
|
|
|
break
|
|
|
|
|
return list(sorted(generate(), key=self.binhost_key, reverse=True))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateBinhostRecheckSet(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Принудительно обновить binhost
|
|
|
|
|
"""
|
|
|
|
|
value = "off"
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateBinhostHost(FieldValue,ReadonlyVariable):
|
|
|
|
|
"""
|
|
|
|
|
Список имен прочих репозиториев
|
|
|
|
|
"""
|
|
|
|
|
type = "list"
|
|
|
|
|
source_variable = "cl_update_binhost_data"
|
|
|
|
|
column = 0
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateBinhostRevisions(FieldValue,ReadonlyVariable):
|
|
|
|
|
"""
|
|
|
|
|
Список имен прочих репозиториев
|
|
|
|
|
"""
|
|
|
|
|
type = "list"
|
|
|
|
|
source_variable = "cl_update_binhost_data"
|
|
|
|
|
column = 1
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateBinhostTime(FieldValue,ReadonlyVariable):
|
|
|
|
|
"""
|
|
|
|
|
Список имен прочих репозиториев
|
|
|
|
|
"""
|
|
|
|
|
type = "list"
|
|
|
|
|
source_variable = "cl_update_binhost_data"
|
|
|
|
|
column = 2
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateRepoTagSet(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Флаг принудительного использования тэгов вместо веток
|
|
|
|
|
"""
|
|
|
|
|
type = "bool"
|
|
|
|
|
value = "on"
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateBranchName(Variable):
|
|
|
|
|
"""
|
|
|
|
@ -250,13 +341,24 @@ class VariableClUpdateBranchName(Variable):
|
|
|
|
|
return ["master", "develop", "update"]
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
cp = ConfigParser()
|
|
|
|
|
cp.read_string(unicode(
|
|
|
|
|
self.Get('update.cl_update_binhost_revisions')[0]))
|
|
|
|
|
repo_tag = self.GetBool('update.cl_update_repo_tag_set')
|
|
|
|
|
|
|
|
|
|
def generateBranch():
|
|
|
|
|
git = Git()
|
|
|
|
|
for reppath in self.Get('cl_update_rep_path'):
|
|
|
|
|
for reppath, repname in zip(self.Get('cl_update_rep_path'),
|
|
|
|
|
self.Get('cl_update_rep_name')):
|
|
|
|
|
tag = cp.get("vcs", repname, fallback="master")
|
|
|
|
|
try:
|
|
|
|
|
yield git.getBranch(reppath) or "master"
|
|
|
|
|
if (repo_tag or git.isTagRepository(
|
|
|
|
|
reppath) or not git.is_git(reppath)):
|
|
|
|
|
yield tag
|
|
|
|
|
else:
|
|
|
|
|
yield git.getBranch(reppath) or tag
|
|
|
|
|
except GitError:
|
|
|
|
|
yield "master"
|
|
|
|
|
yield tag
|
|
|
|
|
|
|
|
|
|
return list(generateBranch())
|
|
|
|
|
|
|
|
|
@ -271,20 +373,24 @@ class VariableClUpdateSyncRep(Variable):
|
|
|
|
|
metavalue = "REPOSITORIES"
|
|
|
|
|
untrusted = True
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def rep_name(self):
|
|
|
|
|
return self.Get('update.cl_update_rep_name')
|
|
|
|
|
|
|
|
|
|
def init(self):
|
|
|
|
|
self.help = _("synchronized repositories (all by default)")
|
|
|
|
|
self.label = _("Synchronized repositories")
|
|
|
|
|
|
|
|
|
|
def set(self,value):
|
|
|
|
|
orderList = self.Get('cl_update_rep_name')
|
|
|
|
|
return sorted(value,key=lambda x:
|
|
|
|
|
(orderList.index(x) if x in orderList else -1),reverse=True)
|
|
|
|
|
def set(self, value):
|
|
|
|
|
orderList = self.rep_name
|
|
|
|
|
return sorted(value, key=lambda x:
|
|
|
|
|
(orderList.index(x) if x in orderList else -1), reverse=True)
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
return list(reversed(self.Get('cl_update_rep_name')))
|
|
|
|
|
return list(reversed(self.rep_name))
|
|
|
|
|
|
|
|
|
|
def choice(self):
|
|
|
|
|
return self.Get('cl_update_rep_name')
|
|
|
|
|
return self.rep_name
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateSyncOverlayRep(ReadonlyVariable):
|
|
|
|
|
"""
|
|
|
|
@ -293,7 +399,7 @@ class VariableClUpdateSyncOverlayRep(ReadonlyVariable):
|
|
|
|
|
type = "list"
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
return filter(lambda x:x!="portage",self.Get('cl_update_sync_rep'))
|
|
|
|
|
return filter(lambda x: x != "portage", self.Get('cl_update_sync_rep'))
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateOutdateSet(ReadonlyVariable):
|
|
|
|
|
"""
|
|
|
|
@ -399,16 +505,18 @@ class VariableClUpdateOtherRepData(ReadonlyTableVariable):
|
|
|
|
|
source = ['cl_update_other_rep_name',
|
|
|
|
|
'cl_update_other_rep_path']
|
|
|
|
|
|
|
|
|
|
portdir_overlay = "main.cl_portdir_overlay"
|
|
|
|
|
|
|
|
|
|
def generator(self):
|
|
|
|
|
repNames = self.Get('cl_update_rep_name')
|
|
|
|
|
layman = Layman(self.Get('cl_update_layman_installed'),
|
|
|
|
|
self.Get('cl_update_layman_make'),
|
|
|
|
|
self.Get('cl_update_layman_conf'))
|
|
|
|
|
repNames = self.Get('update.cl_update_rep_name')
|
|
|
|
|
layman = Layman(self.Get('update.cl_update_layman_installed'),
|
|
|
|
|
self.Get('update.cl_update_layman_make'),
|
|
|
|
|
self.Get('update.cl_update_layman_conf'))
|
|
|
|
|
layman_overlays = layman.get_installed()
|
|
|
|
|
for rpath in self.Get('cl_portdir_overlay'):
|
|
|
|
|
for rpath in self.Get(self.portdir_overlay):
|
|
|
|
|
repo_file = path.join(rpath, "profiles/repo_name")
|
|
|
|
|
rname = readFile(repo_file).strip() or path.basename(rpath)
|
|
|
|
|
if rname in layman_overlays and not rname in repNames:
|
|
|
|
|
if rname in layman_overlays and rname not in repNames:
|
|
|
|
|
yield (rname, rpath)
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
@ -1043,31 +1151,45 @@ class DataVarsUpdateProfile(SimpleDataVars):
|
|
|
|
|
'cl_update_rep_path',
|
|
|
|
|
'cl_update_rep_rev',
|
|
|
|
|
'cl_update_branch_name']
|
|
|
|
|
def __init__(self, profile, chroot_path='/'):
|
|
|
|
|
SimpleDataVars.__init__(self,
|
|
|
|
|
lib_linux.VariableOsLinuxName(),
|
|
|
|
|
lib_linux.VariableOsLinuxShortname(),
|
|
|
|
|
lib_linux.VariableOsLinuxSubname(),
|
|
|
|
|
lib_linux.VariableOsLinuxVer(),
|
|
|
|
|
lib_linux.VariableClProfileSystem(),
|
|
|
|
|
env.VariableClRepositoryData(),
|
|
|
|
|
env.VariableClRepositoryName(),
|
|
|
|
|
env.VariableClRepositoryLocation(),
|
|
|
|
|
env.VariableClChrootPath(),
|
|
|
|
|
env.VariableClTemplateLocation(),
|
|
|
|
|
env.VariableClTemplatePath(),
|
|
|
|
|
env.VariableClEmergeConfig(systemRoot=chroot_path),
|
|
|
|
|
VariableClUpdateRepData(section="update"),
|
|
|
|
|
VariableClUpdateRepPath(section="update"),
|
|
|
|
|
VariableClUpdateRepRev(section="update"),
|
|
|
|
|
VariableClUpdateBranchName(section="update"),
|
|
|
|
|
VariableClUpdateLaymanConfig(section="update"),
|
|
|
|
|
VariableClUpdateLaymanStorage(section="update"),
|
|
|
|
|
VariableClUpdateRepName(section="update"),
|
|
|
|
|
VariableClUpdateRep(section="update"),
|
|
|
|
|
VariableClUpdateRepUrl(section="update"))
|
|
|
|
|
def __init__(self, profile, chroot_path='/', recheck=None):
|
|
|
|
|
SimpleDataVars.__init__(
|
|
|
|
|
self,
|
|
|
|
|
lib_linux.VariableOsLinuxName(),
|
|
|
|
|
lib_linux.VariableOsLinuxShortname(),
|
|
|
|
|
lib_linux.VariableOsLinuxSubname(),
|
|
|
|
|
lib_linux.VariableOsLinuxVer(),
|
|
|
|
|
lib_linux.VariableClProfileSystem(),
|
|
|
|
|
env.VariableClRepositoryData(),
|
|
|
|
|
env.VariableClRepositoryName(),
|
|
|
|
|
env.VariableClRepositoryLocation(),
|
|
|
|
|
env.VariableClChrootPath(),
|
|
|
|
|
env.VariableClTemplateLocation(),
|
|
|
|
|
env.VariableClTemplatePath(),
|
|
|
|
|
env.VariableClEmergeConfig(systemRoot=chroot_path),
|
|
|
|
|
VariableClUpdateRepData(section="update"),
|
|
|
|
|
VariableClUpdateRepPath(section="update"),
|
|
|
|
|
VariableClUpdateRepRev(section="update"),
|
|
|
|
|
VariableClUpdateBranchName(section="update"),
|
|
|
|
|
VariableClUpdateLaymanConfig(section="update"),
|
|
|
|
|
VariableClUpdateLaymanStorage(section="update"),
|
|
|
|
|
VariableClUpdateRepName(section="update"),
|
|
|
|
|
VariableClUpdateRep(section="update"),
|
|
|
|
|
VariableClUpdateRepUrl(section="update"),
|
|
|
|
|
VariableClUpdateBinhost(section="update"),
|
|
|
|
|
VariableClUpdateBinhostData(section="update"),
|
|
|
|
|
VariableClUpdateBinhostHost(section="update"),
|
|
|
|
|
VariableClUpdateBinhostRecheckSet(section="update"),
|
|
|
|
|
VariableClUpdateBinhostRevisions(section="update"),
|
|
|
|
|
VariableClUpdateBinhostTime(section="update"),
|
|
|
|
|
VariableClUpdateBinhostTimeout(section="update"),
|
|
|
|
|
VariableClUpdateBinhosts(section="update"),
|
|
|
|
|
VariableClUpdateRepoTagSet(section="update"),
|
|
|
|
|
VariableClUpdateRevisionPath(section="update"),
|
|
|
|
|
)
|
|
|
|
|
self.cache['cl_profile_system'] = profile
|
|
|
|
|
self.cache['cl_chroot_path'] = chroot_path
|
|
|
|
|
if recheck is not None:
|
|
|
|
|
self.cache['cl_update_binhost_recheck_set'] = recheck
|
|
|
|
|
self.flIniFileFrom(profile)
|
|
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
@ -1247,3 +1369,40 @@ class VariableClUpdateOutdatedKernelSet(ReadonlyVariable):
|
|
|
|
|
def get(self):
|
|
|
|
|
ui = UpdateInfo(self.parent)
|
|
|
|
|
return "on" if ui.outdated_kernel else "off"
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateBinhosts(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Список хостов с бинарными обновлениями
|
|
|
|
|
"""
|
|
|
|
|
type = "list"
|
|
|
|
|
value = ["ftp://ftp.calculate.ru/pub", 'ftp://localhost/pub']
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateBinhost(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Хост с бинарными обновлениями
|
|
|
|
|
"""
|
|
|
|
|
def get(self):
|
|
|
|
|
return ""
|
|
|
|
|
#binhosts = self.Get('cl_update_binhosts')
|
|
|
|
|
#if binhosts:
|
|
|
|
|
# return self.Get('cl_update_binhosts')[0]
|
|
|
|
|
#return ""
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateRevisionPath(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Путь до revisions файлов
|
|
|
|
|
"""
|
|
|
|
|
type = "list"
|
|
|
|
|
value = [
|
|
|
|
|
"calculate/grp/default/ini.env",
|
|
|
|
|
"calculate/grp/kde/ini.env",
|
|
|
|
|
"calculate/grp/server/ini.env",
|
|
|
|
|
"calculate/grp/x/ini.env"
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateBinhostTimeout(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Таймаут на проверку одного binhost
|
|
|
|
|
"""
|
|
|
|
|
type = "int"
|
|
|
|
|
value = "15"
|
|
|
|
|