|
|
|
@ -23,18 +23,21 @@ from calculate.lib.datavars import (Variable, VariableError,
|
|
|
|
|
SimpleDataVars, DataVarsError)
|
|
|
|
|
from calculate.lib.utils.portage import searchProfile
|
|
|
|
|
from calculate.lib.utils.files import readLinesFile, readFile, makeDirectory, \
|
|
|
|
|
listDirectory, process
|
|
|
|
|
listDirectory, process, pathJoin
|
|
|
|
|
|
|
|
|
|
from calculate.lib.configparser import ConfigParser
|
|
|
|
|
from calculate.lib.cl_lang import setLocalTranslate
|
|
|
|
|
from calculate.lib.utils.text import simplify_profiles
|
|
|
|
|
from calculate.lib.utils.portage import Git, GitError, Layman
|
|
|
|
|
from calculate.update.profile import RepositoryStorageSet, DEFAULT_BRANCH
|
|
|
|
|
from ..profile import RepositoryStorageSet, DEFAULT_BRANCH, \
|
|
|
|
|
LocalStorage, ProfileRepository, CacheStorage
|
|
|
|
|
|
|
|
|
|
from calculate.lib.variables.linux import VariableOsLinuxName, \
|
|
|
|
|
VariableOsLinuxSubname, VariableOsLinuxVer, VariableOsLinuxShortname
|
|
|
|
|
from calculate.lib.variables.env import VariableClTemplateLocation
|
|
|
|
|
from calculate.lib.variables import linux as lib_linux
|
|
|
|
|
from calculate.lib.variables import env
|
|
|
|
|
from calculate.update.update_info import UpdateInfo
|
|
|
|
|
from functools import partial
|
|
|
|
|
|
|
|
|
|
_ = lambda x:x
|
|
|
|
|
|
|
|
|
|
setLocalTranslate('cl_update3', sys.modules[__name__])
|
|
|
|
|
|
|
|
|
@ -107,7 +110,7 @@ class VariableClUpdateRep(Variable):
|
|
|
|
|
value = "rev"
|
|
|
|
|
|
|
|
|
|
def choice(self):
|
|
|
|
|
return ["last","rev"]
|
|
|
|
|
return ["last", "rev"]
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateRepData(ReadonlyTableVariable):
|
|
|
|
|
"""
|
|
|
|
@ -133,35 +136,46 @@ class VariableClUpdateRepUrl(Variable):
|
|
|
|
|
type = "list"
|
|
|
|
|
value = []
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateLaymanStorage(ReadonlyVariable):
|
|
|
|
|
class VariableClUpdateLaymanConfig(ReadonlyVariable):
|
|
|
|
|
"""
|
|
|
|
|
Объект конфига layman
|
|
|
|
|
"""
|
|
|
|
|
type = "object"
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
chroot = self.Get('cl_chroot_path')
|
|
|
|
|
cp = ConfigParser()
|
|
|
|
|
cp.read(path.join(chroot, 'etc/layman/layman.cfg'))
|
|
|
|
|
return cp
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateLaymanStorage(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Путь к репозиториям layman
|
|
|
|
|
"""
|
|
|
|
|
param_name = "storage"
|
|
|
|
|
fallback_value = "var/lib/layman"
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
laymanConf = "/etc/layman/layman.cfg"
|
|
|
|
|
reStorage = re.compile("^storage\s*:\s*(\S+)")
|
|
|
|
|
if path.exists(laymanConf):
|
|
|
|
|
for line in readLinesFile(laymanConf):
|
|
|
|
|
match = reStorage.search(line)
|
|
|
|
|
if match:
|
|
|
|
|
return match.group(1)
|
|
|
|
|
return "/var/lib/layman"
|
|
|
|
|
cp = self.Get('cl_update_layman_config')
|
|
|
|
|
res = cp.get('MAIN', self.param_name, fallback=self.fallback_value)
|
|
|
|
|
return pathJoin(self.Get('cl_chroot_path'), res)
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateRepPath(ReadonlyVariable):
|
|
|
|
|
"""
|
|
|
|
|
Пути до репозиториев
|
|
|
|
|
"""
|
|
|
|
|
type = "list"
|
|
|
|
|
mapPath = {'portage':'/usr/portage'}
|
|
|
|
|
mapPath = {'portage':'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:
|
|
|
|
|
yield self.mapPath[name]
|
|
|
|
|
yield path.join(chroot_path, self.mapPath[name])
|
|
|
|
|
else:
|
|
|
|
|
yield path.join(repPath,name)
|
|
|
|
|
yield path.join(repPath, name)
|
|
|
|
|
return list(generatePaths(self.Get('cl_update_rep_name')))
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateRepRev(Variable):
|
|
|
|
@ -171,6 +185,13 @@ class VariableClUpdateRepRev(Variable):
|
|
|
|
|
type = "list"
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
"""
|
|
|
|
|
Если cl_update_rep=rev, то профиль просматривается на нахождене
|
|
|
|
|
в нем rev файла (используется более частный вариант,
|
|
|
|
|
как с calculate.env), файл содержит строки ключ=значение, где
|
|
|
|
|
ключ - название репозитория, значение - ревизия до которой нужно
|
|
|
|
|
обновиться
|
|
|
|
|
"""
|
|
|
|
|
if self.Get('cl_update_rep') == 'rev':
|
|
|
|
|
revPaths = searchProfile(self.Get('cl_profile_system'),
|
|
|
|
|
"rev")
|
|
|
|
@ -409,25 +430,26 @@ class VariableClUpdateOtherRepPath(FieldValue,ReadonlyVariable):
|
|
|
|
|
source_variable = "cl_update_other_rep_data"
|
|
|
|
|
column = 1
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateLaymanInstalled(Variable):
|
|
|
|
|
class VariableClUpdateLaymanInstalled(VariableClUpdateLaymanStorage):
|
|
|
|
|
"""
|
|
|
|
|
Путь до файла layman installed.xml
|
|
|
|
|
"""
|
|
|
|
|
# TODO: извлечь из layman.cfg
|
|
|
|
|
value = "/var/lib/layman/installed.xml"
|
|
|
|
|
param_name = "installed"
|
|
|
|
|
fallback_value = "var/lib/layman/installed.xml"
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateLaymanMake(Variable):
|
|
|
|
|
class VariableClUpdateLaymanMake(VariableClUpdateLaymanStorage):
|
|
|
|
|
"""
|
|
|
|
|
Путь до файла make.conf изменяемого layman`ом
|
|
|
|
|
"""
|
|
|
|
|
# TODO: извлечь из layman.cfg
|
|
|
|
|
value = "/var/lib/layman/make.conf"
|
|
|
|
|
param_name = "make_conf"
|
|
|
|
|
fallback_value = "var/lib/layman/make.conf"
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateLaymanConf(Variable):
|
|
|
|
|
class VariableClUpdateLaymanConf(VariableClUpdateLaymanStorage):
|
|
|
|
|
"""
|
|
|
|
|
Путь до конфигурационного файла репозиториев для layman
|
|
|
|
|
"""
|
|
|
|
|
value = "/etc/portage/repos.conf/layman.conf"
|
|
|
|
|
param_name = "repos_conf"
|
|
|
|
|
fallback_value = "etc/portage/repos.conf/layman.conf"
|
|
|
|
|
|
|
|
|
|
class VariableClUpdatePretendSet(Variable):
|
|
|
|
|
"""
|
|
|
|
@ -480,7 +502,9 @@ class VariableClUpdateProfileStorage(ReadonlyVariable):
|
|
|
|
|
type = "object"
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
return RepositoryStorageSet()
|
|
|
|
|
return RepositoryStorageSet(
|
|
|
|
|
LocalStorage('/var/lib/layman'),
|
|
|
|
|
CacheStorage('/var/calculate/tmp/update'))
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateRepHost(Variable):
|
|
|
|
|
type = "list"
|
|
|
|
@ -493,11 +517,14 @@ class VariableClUpdateRepHostUrl(Variable):
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateProfileDatavars(ReadonlyVariable):
|
|
|
|
|
type = "object"
|
|
|
|
|
profile = "cl_update_profile_system"
|
|
|
|
|
profiles_path = "cl_update_profile_path"
|
|
|
|
|
profiles_shortname = "cl_update_profile_shortname"
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
profile = self.Get('cl_update_profile_system')
|
|
|
|
|
path_profile = self.Select('cl_profile_path',
|
|
|
|
|
where='cl_profile_shortname',
|
|
|
|
|
profile = self.Get(self.profile)
|
|
|
|
|
path_profile = self.Select(self.profiles_path,
|
|
|
|
|
where=self.profiles_shortname,
|
|
|
|
|
eq=profile, limit=1)
|
|
|
|
|
if path_profile:
|
|
|
|
|
return DataVarsUpdateProfile(path_profile)
|
|
|
|
@ -510,8 +537,10 @@ class VariableClUpdateProfileLinuxFullname(ReadonlyVariable):
|
|
|
|
|
def init(self):
|
|
|
|
|
self.label = _("Distribution name")
|
|
|
|
|
|
|
|
|
|
datavars = "cl_update_profile_datavars"
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
dv = self.Get('cl_update_profile_datavars')
|
|
|
|
|
dv = self.Get(self.datavars)
|
|
|
|
|
if dv:
|
|
|
|
|
try:
|
|
|
|
|
subname = dv.Get('os_linux_subname')
|
|
|
|
@ -531,21 +560,25 @@ class VariableClUpdateProfileDependData(ReadonlyTableVariable):
|
|
|
|
|
source = ['cl_update_profile_depend_name',
|
|
|
|
|
'cl_update_profile_depend_url']
|
|
|
|
|
|
|
|
|
|
datavars = "cl_update_profile_datavars"
|
|
|
|
|
|
|
|
|
|
def init(self):
|
|
|
|
|
self.label = _("Used repositories")
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def url_like(url1, url2):
|
|
|
|
|
match1 = VariableClUpdateProfileRep.re_url.search(url1)
|
|
|
|
|
match2 = VariableClUpdateProfileRep.re_url.search(url2)
|
|
|
|
|
match1 = VariableClUpdateProfileUrl.re_url.search(url1)
|
|
|
|
|
match2 = VariableClUpdateProfileUrl.re_url.search(url2)
|
|
|
|
|
if match1 and match2:
|
|
|
|
|
return match1.group(2).lower() == match2.group(2).lower()
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get(self, hr=False):
|
|
|
|
|
dv = self.Get('cl_update_profile_datavars')
|
|
|
|
|
url = self.Get('cl_update_profile_rep').lower()
|
|
|
|
|
dv = self.Get(self.datavars)
|
|
|
|
|
# TODO: неиспользуемая переменная возможно
|
|
|
|
|
# испольуется для инициализации
|
|
|
|
|
#url = self.Get('cl_update_profile_url').lower()
|
|
|
|
|
if dv:
|
|
|
|
|
return reversed(zip(dv.Get('cl_update_rep_name'),
|
|
|
|
|
dv.Get('cl_update_rep_url')))
|
|
|
|
@ -564,6 +597,8 @@ class VariableClUpdateTemplatesLocate(Variable):
|
|
|
|
|
untrusted = True
|
|
|
|
|
check_after = ['cl_update_profile_system']
|
|
|
|
|
|
|
|
|
|
profile_datevars = "update.cl_update_profile_datavars"
|
|
|
|
|
|
|
|
|
|
descriptionMap = {'overlay': _('Overlay templates'),
|
|
|
|
|
'local': _('Local templates'),
|
|
|
|
|
'calculate': _("Calculate overlay templates"),
|
|
|
|
@ -578,15 +613,16 @@ class VariableClUpdateTemplatesLocate(Variable):
|
|
|
|
|
%",".join(self.get())
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
dv = self.Get('update.cl_update_profile_datavars')
|
|
|
|
|
dv = self.Get(self.profile_datevars)
|
|
|
|
|
if dv:
|
|
|
|
|
return dv.Get('cl_template_location') + ['clt']
|
|
|
|
|
else:
|
|
|
|
|
return self.Get('cl_templates_locate')
|
|
|
|
|
|
|
|
|
|
def choice(self):
|
|
|
|
|
return map(lambda x:(x,self.descriptionMap.get(x,_("%s overlay templates")%x)),
|
|
|
|
|
self.get())
|
|
|
|
|
descr = lambda x: self.descriptionMap.get(x,
|
|
|
|
|
_("%s overlay templates" % x))
|
|
|
|
|
return map(lambda x: (x, descr(x)), self.get())
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateProfileDependName(FieldValue, ReadonlyVariable):
|
|
|
|
|
type = "list"
|
|
|
|
@ -652,9 +688,9 @@ class VariableClUpdateProfileLinuxName(ReadonlyVariable):
|
|
|
|
|
dv.Get('os_linux_name')
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateProfileRep(Variable):
|
|
|
|
|
class VariableClUpdateProfileUrl(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Текущий репозиторий
|
|
|
|
|
URL текущего репозитория
|
|
|
|
|
"""
|
|
|
|
|
untrusted = True
|
|
|
|
|
check_after = ["cl_update_profile_branch"]
|
|
|
|
@ -662,6 +698,17 @@ class VariableClUpdateProfileRep(Variable):
|
|
|
|
|
opt = ["--url"]
|
|
|
|
|
metavalue = "URL"
|
|
|
|
|
|
|
|
|
|
profile = "cl_profile_system"
|
|
|
|
|
branch = "cl_update_profile_branch"
|
|
|
|
|
storage = "cl_update_profile_storage"
|
|
|
|
|
default_url = "git://git.calculate.ru/calculate/distros.git"
|
|
|
|
|
profiles_shortname = 'cl_update_profile_shortname'
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def current_root(self):
|
|
|
|
|
return '/'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def init(self):
|
|
|
|
|
self.label = _("Profile repository")
|
|
|
|
|
self.help = _("set the profile repository")
|
|
|
|
@ -685,12 +732,12 @@ class VariableClUpdateProfileRep(Variable):
|
|
|
|
|
def url_by_shortname(self, value):
|
|
|
|
|
match = self.re_shortname.match(value)
|
|
|
|
|
if not match.group(1):
|
|
|
|
|
template = self.Get('cl_update_rep_host_url')
|
|
|
|
|
template = self.Get('update.cl_update_rep_host_url')
|
|
|
|
|
if template:
|
|
|
|
|
template = template[0]
|
|
|
|
|
else:
|
|
|
|
|
template = self.Select('cl_update_rep_host_url',
|
|
|
|
|
where='cl_update_rep_host',
|
|
|
|
|
template = self.Select('update.cl_update_rep_host_url',
|
|
|
|
|
where='update.cl_update_rep_host',
|
|
|
|
|
eq=match.group(1), limit=1)
|
|
|
|
|
if not template:
|
|
|
|
|
raise VariableError(_("Failed to determine the repository host"))
|
|
|
|
@ -709,32 +756,38 @@ class VariableClUpdateProfileRep(Variable):
|
|
|
|
|
if not value:
|
|
|
|
|
raise VariableError("Need to specify profile repository")
|
|
|
|
|
try:
|
|
|
|
|
branch = self.Get('cl_update_profile_branch')
|
|
|
|
|
self.Get('cl_update_profile_storage').get_profiles(value, branch)
|
|
|
|
|
branch = self.Get(self.branch)
|
|
|
|
|
self.Get(self.storage).get_profiles(value, branch)
|
|
|
|
|
except GitError as e:
|
|
|
|
|
raise VariableError(str(e))
|
|
|
|
|
if not self.Get('cl_profile_shortname'):
|
|
|
|
|
if not self.Get(self.profiles_shortname):
|
|
|
|
|
raise VariableError(_("Repository %s has no profiles")%value)
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
try:
|
|
|
|
|
profile = self.Get('cl_profile_system')
|
|
|
|
|
while profile != '/' and ".git" not in listDirectory(profile):
|
|
|
|
|
profile = path.dirname(profile)
|
|
|
|
|
if profile == '/':
|
|
|
|
|
return ""
|
|
|
|
|
git = Git()
|
|
|
|
|
return git.get_url(profile, "origin") or ""
|
|
|
|
|
profile = self.Get(self.profile)
|
|
|
|
|
if profile:
|
|
|
|
|
while (profile != self.current_root and
|
|
|
|
|
".git" not in listDirectory(profile)):
|
|
|
|
|
profile = path.dirname(profile)
|
|
|
|
|
if profile == self.current_root:
|
|
|
|
|
return ""
|
|
|
|
|
git = Git()
|
|
|
|
|
return git.get_url(profile, "origin") or ""
|
|
|
|
|
except:
|
|
|
|
|
return "git://git.calculate.ru/calculate/distros.git"
|
|
|
|
|
pass
|
|
|
|
|
return self.default_url
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateProfileRepoName(ReadonlyVariable):
|
|
|
|
|
def init(self):
|
|
|
|
|
self.label = _("Repository name")
|
|
|
|
|
|
|
|
|
|
storage = "cl_update_profile_storage"
|
|
|
|
|
url = "cl_update_profile_url"
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
rep_set = self.Get('cl_update_profile_storage')
|
|
|
|
|
url = self.Get('cl_update_profile_rep')
|
|
|
|
|
rep_set = self.Get(self.storage)
|
|
|
|
|
url = self.Get(self.url)
|
|
|
|
|
rep = rep_set.get_repository(url, branch=None)
|
|
|
|
|
if rep:
|
|
|
|
|
return rep.repo_name
|
|
|
|
@ -751,6 +804,9 @@ class VariableClUpdateProfileBranch(Variable):
|
|
|
|
|
opt = ["--branch"]
|
|
|
|
|
metavalue = "BRANCH"
|
|
|
|
|
|
|
|
|
|
storage = "cl_update_profile_storage"
|
|
|
|
|
url = "cl_update_profile_url"
|
|
|
|
|
|
|
|
|
|
def init(self):
|
|
|
|
|
self.label = _("Repository branch")
|
|
|
|
|
self.help = _("set the repository branch")
|
|
|
|
@ -759,14 +815,14 @@ class VariableClUpdateProfileBranch(Variable):
|
|
|
|
|
pass
|
|
|
|
|
## TODO: проверка ветки
|
|
|
|
|
#try:
|
|
|
|
|
# url = self.Get('cl_update_profile_rep')
|
|
|
|
|
# url = self.Get('cl_update_profile_url')
|
|
|
|
|
# self.Get('cl_update_profile_storage').get_profiles(url, value)
|
|
|
|
|
#except GitError as e:
|
|
|
|
|
# raise VariableError(str(e))
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
rep_set = self.Get('cl_update_profile_storage')
|
|
|
|
|
url = self.Get('cl_update_profile_rep')
|
|
|
|
|
rep_set = self.Get(self.storage)
|
|
|
|
|
url = self.Get(self.url)
|
|
|
|
|
#print url, rep_set.is_local(url, branch=None)
|
|
|
|
|
if rep_set.is_local(url, branch=None):
|
|
|
|
|
rep = rep_set.get_repository(url, branch=None)
|
|
|
|
@ -775,87 +831,121 @@ class VariableClUpdateProfileBranch(Variable):
|
|
|
|
|
return DEFAULT_BRANCH
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClProfileSystem(ReadonlyVariable):
|
|
|
|
|
class VariableClProfileRepository(ReadonlyVariable):
|
|
|
|
|
"""
|
|
|
|
|
Профиль системы (симлинк /etc/make.profile')
|
|
|
|
|
Репозиторий из которого будут получены профили
|
|
|
|
|
"""
|
|
|
|
|
type = "object"
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
try:
|
|
|
|
|
make_profile = self.Get('cl_make_profile')
|
|
|
|
|
return path.normpath(
|
|
|
|
|
path.join(path.dirname(make_profile),
|
|
|
|
|
os.readlink(make_profile)))
|
|
|
|
|
profile_dn = self.Get('cl_profile_system')
|
|
|
|
|
while profile_dn != '/' and ".git" not in listDirectory(profile_dn):
|
|
|
|
|
profile_dn = path.dirname(profile_dn)
|
|
|
|
|
if profile_dn == '/':
|
|
|
|
|
return ""
|
|
|
|
|
ls = LocalStorage(path.dirname(profile_dn))
|
|
|
|
|
return ProfileRepository(path.basename(profile_dn), ls)
|
|
|
|
|
except:
|
|
|
|
|
raise VariableError(_("Failed to determine the system profile"))
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClProfileData(ReadonlyTableVariable):
|
|
|
|
|
source = ["cl_profile_fullname",
|
|
|
|
|
"cl_profile_shortname",
|
|
|
|
|
"cl_profile_path",
|
|
|
|
|
"cl_profile_arch"]
|
|
|
|
|
"""
|
|
|
|
|
Таблица данных о текущих профилях системы
|
|
|
|
|
"""
|
|
|
|
|
source = []
|
|
|
|
|
repository = "cl_profile_repository"
|
|
|
|
|
|
|
|
|
|
def profile_filter(self, profiles):
|
|
|
|
|
arch = self.Get('os_arch_machine_gentoo')
|
|
|
|
|
return [x for x in profiles if x.arch == arch]
|
|
|
|
|
|
|
|
|
|
def get(self, hr=False):
|
|
|
|
|
url = self.Get('cl_update_profile_rep')
|
|
|
|
|
if not url:
|
|
|
|
|
rep = self.Get(self.repository)
|
|
|
|
|
if not rep:
|
|
|
|
|
return [[]]
|
|
|
|
|
profiles = rep.get_profiles()
|
|
|
|
|
if not profiles:
|
|
|
|
|
return [[]]
|
|
|
|
|
repo_name = profiles[0].repository.repo_name
|
|
|
|
|
filtered_profiles = self.profile_filter(profiles)
|
|
|
|
|
full_name = [x.profile for x in filtered_profiles]
|
|
|
|
|
profile_path = [x.path for x in filtered_profiles]
|
|
|
|
|
profile_arch = [x.arch for x in filtered_profiles]
|
|
|
|
|
short_name = simplify_profiles(full_name)
|
|
|
|
|
full_name = ["%s:%s" % (repo_name, x) for x in full_name]
|
|
|
|
|
return zip(full_name,
|
|
|
|
|
short_name,
|
|
|
|
|
profile_path,
|
|
|
|
|
profile_arch)
|
|
|
|
|
|
|
|
|
|
setValue = Variable.setValue
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateProfileRepository(ReadonlyVariable):
|
|
|
|
|
"""
|
|
|
|
|
Репозиторий из которого будет извлечён список профилей
|
|
|
|
|
"""
|
|
|
|
|
type = "object"
|
|
|
|
|
url = "cl_update_profile_url"
|
|
|
|
|
storage = "cl_update_profile_storage"
|
|
|
|
|
branch = "cl_update_profile_branch"
|
|
|
|
|
sync_set = "update.cl_update_profile_sync_set"
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
url = self.Get(self.url)
|
|
|
|
|
if not url:
|
|
|
|
|
return ""
|
|
|
|
|
try:
|
|
|
|
|
rep_set = self.Get('cl_update_profile_storage')
|
|
|
|
|
branch = self.Get('cl_update_profile_branch')
|
|
|
|
|
rep_set = self.Get(self.storage)
|
|
|
|
|
branch = self.Get(self.branch)
|
|
|
|
|
rep = rep_set.get_repository(url, branch)
|
|
|
|
|
if rep and self.Get('cl_update_profile_sync_set') == 'on':
|
|
|
|
|
if rep and self.Get(self.sync_set) == 'on':
|
|
|
|
|
rep.sync()
|
|
|
|
|
profiles = rep_set.get_profiles(url, branch)
|
|
|
|
|
return rep_set.get_repository(url, branch) or ""
|
|
|
|
|
except GitError:
|
|
|
|
|
return [[]]
|
|
|
|
|
arch = self.Get('os_arch_machine_gentoo')
|
|
|
|
|
if profiles:
|
|
|
|
|
repo_name = profiles[0].repository.repo_name
|
|
|
|
|
arch_profiles = [x for x in profiles if x.arch == arch]
|
|
|
|
|
full_name = [x.profile for x in arch_profiles]
|
|
|
|
|
profile_path = [x.path for x in arch_profiles]
|
|
|
|
|
profile_arch = [x.arch for x in arch_profiles]
|
|
|
|
|
short_name = simplify_profiles(full_name)
|
|
|
|
|
full_name = ["%s:%s"%(repo_name,x) for x in full_name]
|
|
|
|
|
return zip(full_name,
|
|
|
|
|
short_name,
|
|
|
|
|
profile_path,
|
|
|
|
|
profile_arch)
|
|
|
|
|
return [[]]
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
setValue = Variable.setValue
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateProfileData(VariableClProfileData):
|
|
|
|
|
source = ["cl_update_profile_fullname",
|
|
|
|
|
"cl_update_profile_shortname",
|
|
|
|
|
"cl_update_profile_path",
|
|
|
|
|
"cl_update_profile_arch"]
|
|
|
|
|
|
|
|
|
|
repository = "cl_update_profile_repository"
|
|
|
|
|
|
|
|
|
|
class VariableClProfileFullname(FieldValue, ReadonlyVariable):
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateProfileFullname(FieldValue, ReadonlyVariable):
|
|
|
|
|
"""
|
|
|
|
|
Полное название профиля
|
|
|
|
|
"""
|
|
|
|
|
type = "list"
|
|
|
|
|
source_variable = "cl_profile_data"
|
|
|
|
|
source_variable = "cl_update_profile_data"
|
|
|
|
|
column = 0
|
|
|
|
|
|
|
|
|
|
class VariableClProfileShortname(FieldValue, ReadonlyVariable):
|
|
|
|
|
class VariableClUpdateProfileShortname(FieldValue, ReadonlyVariable):
|
|
|
|
|
"""
|
|
|
|
|
Упрощенное название профиля
|
|
|
|
|
"""
|
|
|
|
|
type = "list"
|
|
|
|
|
source_variable = "cl_profile_data"
|
|
|
|
|
source_variable = "cl_update_profile_data"
|
|
|
|
|
column = 1
|
|
|
|
|
|
|
|
|
|
class VariableClProfilePath(FieldValue, ReadonlyVariable):
|
|
|
|
|
class VariableClUpdateProfilePath(FieldValue, ReadonlyVariable):
|
|
|
|
|
"""
|
|
|
|
|
Путь от корня до профиля
|
|
|
|
|
"""
|
|
|
|
|
type = "list"
|
|
|
|
|
source_variable = "cl_profile_data"
|
|
|
|
|
source_variable = "cl_update_profile_data"
|
|
|
|
|
column = 2
|
|
|
|
|
|
|
|
|
|
class VariableClProfileArch(FieldValue, ReadonlyVariable):
|
|
|
|
|
class VariableClUpdateProfileArch(FieldValue, ReadonlyVariable):
|
|
|
|
|
"""
|
|
|
|
|
Архитектура профиля
|
|
|
|
|
"""
|
|
|
|
|
type = "list"
|
|
|
|
|
source_variable = "cl_profile_data"
|
|
|
|
|
source_variable = "cl_update_profile_data"
|
|
|
|
|
column = 3
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateProfileSystem(Variable):
|
|
|
|
@ -867,6 +957,14 @@ class VariableClUpdateProfileSystem(Variable):
|
|
|
|
|
untrusted = True
|
|
|
|
|
metavalue = "PROFILE"
|
|
|
|
|
|
|
|
|
|
profiles_path = "cl_update_profile_path"
|
|
|
|
|
profiles_shortname = "cl_update_profile_shortname"
|
|
|
|
|
profiles_fullname = "cl_update_profile_fullname"
|
|
|
|
|
profiles_arch = "cl_update_profile_arch"
|
|
|
|
|
profile = "cl_profile_system"
|
|
|
|
|
url = "cl_update_profile_url"
|
|
|
|
|
gentoo_arch = 'os_arch_machine_gentoo'
|
|
|
|
|
|
|
|
|
|
def init(self):
|
|
|
|
|
self.label = _("System profile")
|
|
|
|
|
self.help = _("set the system profile")
|
|
|
|
@ -874,12 +972,12 @@ class VariableClUpdateProfileSystem(Variable):
|
|
|
|
|
def check(self, profile):
|
|
|
|
|
if not profile:
|
|
|
|
|
raise VariableError(_("You must specify the profile"))
|
|
|
|
|
path_profile = self.Select('cl_profile_path',
|
|
|
|
|
where='cl_profile_shortname',
|
|
|
|
|
eq=profile, limit=1)
|
|
|
|
|
profile_fullname = self.Select('cl_profile_fullname',
|
|
|
|
|
where='cl_profile_shortname',
|
|
|
|
|
path_profile = self.Select(self.profiles_path,
|
|
|
|
|
where=self.profiles_shortname,
|
|
|
|
|
eq=profile, limit=1)
|
|
|
|
|
profile_fullname = self.Select(self.profiles_fullname,
|
|
|
|
|
where=self.profiles_shortname,
|
|
|
|
|
eq=profile, limit=1)
|
|
|
|
|
if path_profile:
|
|
|
|
|
dv = DataVarsUpdateProfile(path_profile)
|
|
|
|
|
if ":" in profile_fullname:
|
|
|
|
@ -888,48 +986,49 @@ class VariableClUpdateProfileSystem(Variable):
|
|
|
|
|
repo_name = ""
|
|
|
|
|
try:
|
|
|
|
|
if (not dv.Get('cl_update_rep_name') or
|
|
|
|
|
not dv.Get('cl_update_rep_url')):
|
|
|
|
|
raise VariableError(_("Repository variables "
|
|
|
|
|
"were not configured for the profile"))
|
|
|
|
|
not dv.Get('cl_update_rep_url')):
|
|
|
|
|
raise VariableError(
|
|
|
|
|
_("Repository variables "
|
|
|
|
|
"were not configured for the profile"))
|
|
|
|
|
if not dv.Get('os_linux_name'):
|
|
|
|
|
raise VariableError("")
|
|
|
|
|
if repo_name not in list(self.Get('cl_update_profile_rep_name')):
|
|
|
|
|
if repo_name not in list(dv.Get('cl_update_rep_name')):
|
|
|
|
|
raise VariableError(
|
|
|
|
|
_("Overlay %s is not specified in cl_update_rep_name")%
|
|
|
|
|
repo_name)
|
|
|
|
|
_("Overlay %s is not specified "
|
|
|
|
|
"in cl_update_rep_name") % repo_name)
|
|
|
|
|
except (DataVarsError,VariableError) as e:
|
|
|
|
|
if str(e):
|
|
|
|
|
message = ". " + str(e)
|
|
|
|
|
else:
|
|
|
|
|
message = ""
|
|
|
|
|
raise VariableError(_("The selected profile is not Calculate")
|
|
|
|
|
+message)
|
|
|
|
|
+ message)
|
|
|
|
|
else:
|
|
|
|
|
raise VariableError(_("Wrong Calculate profile"))
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
try:
|
|
|
|
|
profile_system = self.Get('cl_profile_system')
|
|
|
|
|
profile = self.Select('cl_profile_shortname',
|
|
|
|
|
where='cl_profile_path',
|
|
|
|
|
profile_system = self.Get(self.profile)
|
|
|
|
|
profile = self.Select(self.profiles_shortname,
|
|
|
|
|
where=self.profiles_path,
|
|
|
|
|
eq=profile_system, limit=1)
|
|
|
|
|
if profile:
|
|
|
|
|
return profile
|
|
|
|
|
except VariableError:
|
|
|
|
|
pass
|
|
|
|
|
shortname = self.Get('cl_profile_shortname')
|
|
|
|
|
shortname = self.Get(self.profiles_shortname)
|
|
|
|
|
if len(shortname) == 1:
|
|
|
|
|
return shortname[0]
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
def choice(self):
|
|
|
|
|
url = self.Get('cl_update_profile_rep')
|
|
|
|
|
url = self.Get(self.url)
|
|
|
|
|
if not url:
|
|
|
|
|
return []
|
|
|
|
|
arch = self.Get('os_arch_machine_gentoo')
|
|
|
|
|
profiles = zip(*self.Select(['cl_profile_shortname',
|
|
|
|
|
'cl_profile_fullname'],
|
|
|
|
|
where='cl_profile_arch', eq=arch))
|
|
|
|
|
arch = self.Get(self.gentoo_arch)
|
|
|
|
|
profiles = zip(*self.Select([self.profiles_shortname,
|
|
|
|
|
self.profiles_fullname],
|
|
|
|
|
where=self.profiles_arch, eq=arch))
|
|
|
|
|
if profiles:
|
|
|
|
|
short_name, full_name = profiles
|
|
|
|
|
return zip(short_name, full_name)
|
|
|
|
@ -944,23 +1043,31 @@ class DataVarsUpdateProfile(SimpleDataVars):
|
|
|
|
|
'cl_update_rep_path',
|
|
|
|
|
'cl_update_rep_rev',
|
|
|
|
|
'cl_update_branch_name']
|
|
|
|
|
def __init__(self, profile):
|
|
|
|
|
def __init__(self, profile, chroot_path='/'):
|
|
|
|
|
SimpleDataVars.__init__(self,
|
|
|
|
|
VariableOsLinuxName(),
|
|
|
|
|
VariableOsLinuxShortname(),
|
|
|
|
|
VariableOsLinuxSubname(),
|
|
|
|
|
VariableOsLinuxVer(),
|
|
|
|
|
VariableClTemplateLocation(),
|
|
|
|
|
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"),
|
|
|
|
|
VariableClProfileSystem(section="update"),
|
|
|
|
|
VariableClUpdateLaymanConfig(section="update"),
|
|
|
|
|
VariableClUpdateLaymanStorage(section="update"),
|
|
|
|
|
VariableClUpdateRepName(section="update"),
|
|
|
|
|
VariableClUpdateRep(section="update"),
|
|
|
|
|
VariableClUpdateRepUrl(section="update"))
|
|
|
|
|
self.cache['cl_profile_system'] = profile
|
|
|
|
|
self.cache['cl_chroot_path'] = chroot_path
|
|
|
|
|
self.flIniFileFrom(profile)
|
|
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
@ -1023,6 +1130,7 @@ class VariableClUpdateAutocheckScheduleSet(Variable):
|
|
|
|
|
self.label = _("Consider the autocheck schedule")
|
|
|
|
|
self.help = _("consider the autocheck schedule")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateEmergelistSet(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Вывести список пакетов в формате emerge
|
|
|
|
@ -1035,6 +1143,7 @@ class VariableClUpdateEmergelistSet(Variable):
|
|
|
|
|
self.label = _("Emerge-like packages list")
|
|
|
|
|
self.help = _("display the packages list in emerge format")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateKernelVersion(ReadonlyVariable):
|
|
|
|
|
"""
|
|
|
|
|
Текущая версия ядра
|
|
|
|
@ -1042,6 +1151,7 @@ class VariableClUpdateKernelVersion(ReadonlyVariable):
|
|
|
|
|
def get(self):
|
|
|
|
|
return process('/bin/uname','-r').read().strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateKernelSrcPath(ReadonlyVariable):
|
|
|
|
|
"""
|
|
|
|
|
Каталог содержащий исходный код текущего ядра
|
|
|
|
@ -1106,12 +1216,14 @@ class VariableClUpdateCleanpkgSet(Variable):
|
|
|
|
|
self.label = _("Clean obsolete programs archives")
|
|
|
|
|
self.help = _("clean obsolete programs archives")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateOutdatedKernelPath(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Файл-флаг наличия устаревшего, неудаленного ядра
|
|
|
|
|
"""
|
|
|
|
|
value = "/var/lib/calculate/calculate-update/outdated_kernel"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateSkipRbSet(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Пропусить revdep-rebuild
|
|
|
|
@ -1125,6 +1237,7 @@ class VariableClUpdateSkipRbSet(Variable):
|
|
|
|
|
self.label = _("Skip reverse dependencies check")
|
|
|
|
|
self.help = _("skip reverse dependencies check")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateOutdatedKernelSet(ReadonlyVariable):
|
|
|
|
|
"""
|
|
|
|
|
Есть наличие устаревшего ядра
|
|
|
|
|