|
|
|
@ -28,7 +28,7 @@ from calculate.lib.datavars import (Variable, VariableError,
|
|
|
|
|
SimpleDataVars, DataVarsError)
|
|
|
|
|
from calculate.lib.utils.binhosts import (Binhosts, PackagesIndex, HOURS,
|
|
|
|
|
BinhostSignError)
|
|
|
|
|
from calculate.lib.utils.files import readFile, listDirectory, process, pathJoin
|
|
|
|
|
from calculate.lib.utils.files import readFile, listDirectory, process, pathJoin, readLinesFile
|
|
|
|
|
|
|
|
|
|
from calculate.lib.configparser import ConfigParser
|
|
|
|
|
from calculate.lib.cl_lang import setLocalTranslate
|
|
|
|
@ -36,7 +36,7 @@ from calculate.lib.utils.text import simplify_profiles, _u8
|
|
|
|
|
from calculate.lib.utils.git import Git, GitError
|
|
|
|
|
from calculate.lib.utils.portage import ReposConf, PortageState
|
|
|
|
|
from ..profile import (RepositoryStorageSet, DEFAULT_BRANCH,
|
|
|
|
|
LocalStorage, ProfileRepository, CacheStorage)
|
|
|
|
|
LocalStorage, ProfileRepository, CacheStorage, Profile)
|
|
|
|
|
|
|
|
|
|
from calculate.lib.variables import linux as lib_linux
|
|
|
|
|
from calculate.lib.variables import env
|
|
|
|
@ -942,6 +942,7 @@ class VariableClUpdateTemplatesLocate(Variable):
|
|
|
|
|
def choice(self):
|
|
|
|
|
descr = lambda x: self.descriptionMap.get(x,
|
|
|
|
|
_("%s overlay templates" % x))
|
|
|
|
|
a = self.get()
|
|
|
|
|
return [(x, descr(x)) for x in self.get()]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -963,7 +964,6 @@ class VariableClUpdateProfileDependUrl(FieldValue, ReadonlyVariable):
|
|
|
|
|
self.label = _("URL")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateProfileCheckSyncAllowed(Variable):
|
|
|
|
|
path = 'cl_update_repos_storage'
|
|
|
|
|
|
|
|
|
@ -1093,43 +1093,45 @@ class VariableClUpdateProfileUrl(Variable):
|
|
|
|
|
value = self.url_by_shortname(value)
|
|
|
|
|
return self.normalize_url(value)
|
|
|
|
|
|
|
|
|
|
def check(self, value):
|
|
|
|
|
if not value:
|
|
|
|
|
raise VariableError(_("Need to specify profile repository"))
|
|
|
|
|
try:
|
|
|
|
|
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(self.profiles_shortname):
|
|
|
|
|
raise VariableError(_("Repository %s has no profiles") %
|
|
|
|
|
value)
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
try:
|
|
|
|
|
profile = self.Get(self.profile)
|
|
|
|
|
if profile:
|
|
|
|
|
while (profile != self.current_root and
|
|
|
|
|
".git" not in listDirectory(profile) and
|
|
|
|
|
"repo_name" not in listDirectory(
|
|
|
|
|
path.join(profile,"profiles"))):
|
|
|
|
|
profile = path.dirname(profile)
|
|
|
|
|
if profile == self.current_root:
|
|
|
|
|
return self.value
|
|
|
|
|
if ".git" not in listDirectory(profile):
|
|
|
|
|
repo_name = readFile(path.join(
|
|
|
|
|
profile,"profiles/repo_name")).strip()
|
|
|
|
|
if (repo_name in self.rep_names and
|
|
|
|
|
self.Get('cl_action') == self.check_action):
|
|
|
|
|
raise CriticalError(
|
|
|
|
|
_("You need to update the repositories before "
|
|
|
|
|
"you change the profile"))
|
|
|
|
|
return Git.get_url(profile, "origin")
|
|
|
|
|
except CriticalError as e:
|
|
|
|
|
raise VariableError(str(e))
|
|
|
|
|
except Exception as e:
|
|
|
|
|
pass
|
|
|
|
|
return self.value
|
|
|
|
|
# def check(self, value):
|
|
|
|
|
# if not value:
|
|
|
|
|
# return True
|
|
|
|
|
# try:
|
|
|
|
|
# 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(self.profiles_shortname):
|
|
|
|
|
# raise VariableError(_("Repository %s has no profiles") %
|
|
|
|
|
# value)
|
|
|
|
|
|
|
|
|
|
# def get(self):
|
|
|
|
|
# try:
|
|
|
|
|
# if not self.value:
|
|
|
|
|
# return self.value
|
|
|
|
|
# profile = self.Get(self.profile)
|
|
|
|
|
# if profile:
|
|
|
|
|
# while (profile != self.current_root and
|
|
|
|
|
# ".git" not in listDirectory(profile) and
|
|
|
|
|
# "repo_name" not in listDirectory(
|
|
|
|
|
# path.join(profile,"profiles"))):
|
|
|
|
|
# profile = path.dirname(profile)
|
|
|
|
|
# if profile == self.current_root:
|
|
|
|
|
# return self.value
|
|
|
|
|
# if ".git" not in listDirectory(profile):
|
|
|
|
|
# repo_name = readFile(path.join(
|
|
|
|
|
# profile,"profiles/repo_name")).strip()
|
|
|
|
|
# if (repo_name in self.rep_names and
|
|
|
|
|
# self.Get('cl_action') == self.check_action):
|
|
|
|
|
# raise CriticalError(
|
|
|
|
|
# _("You need to update the repositories before "
|
|
|
|
|
# "you change the profile"))
|
|
|
|
|
# return Git.get_url(profile, "origin")
|
|
|
|
|
# except CriticalError as e:
|
|
|
|
|
# raise VariableError(str(e))
|
|
|
|
|
# except Exception as e:
|
|
|
|
|
# pass
|
|
|
|
|
# return self.value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClUpdateProfileRepoName(ReadonlyVariable):
|
|
|
|
@ -1206,19 +1208,30 @@ class VariableClProfileData(ReadonlyTableVariable):
|
|
|
|
|
return [x for x in profiles if x.arch == arch]
|
|
|
|
|
|
|
|
|
|
def get(self, hr=HumanReadable.No):
|
|
|
|
|
rep = self.Get(self.repository)
|
|
|
|
|
if not rep:
|
|
|
|
|
return [[]]
|
|
|
|
|
profiles = rep.get_profiles()
|
|
|
|
|
if not profiles:
|
|
|
|
|
return [[]]
|
|
|
|
|
repo_name = profiles[0].repository.repo_name
|
|
|
|
|
if self.Get('cl_update_profile_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
|
|
|
|
|
else:
|
|
|
|
|
full_path = self.Get('cl_profile_system')
|
|
|
|
|
storage_path = self.Get('cl_update_repos_storage')
|
|
|
|
|
if storage_path in full_path:
|
|
|
|
|
repo_name = full_path.split(storage_path)[1].replace('/', ' ').split()[0]
|
|
|
|
|
profiles_desc = path.join(storage_path, repo_name, "profiles/profiles.desc")
|
|
|
|
|
profiles = ProfileRepository.get_local_profiles(path.join(storage_path, repo_name))
|
|
|
|
|
for profile in profiles:
|
|
|
|
|
profile.path = path.join(storage_path, repo_name, 'profiles', profile.profile)
|
|
|
|
|
|
|
|
|
|
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 list(zip(full_name,
|
|
|
|
|
short_name,
|
|
|
|
|
profile_path,
|
|
|
|
@ -1351,10 +1364,11 @@ class VariableClUpdateProfileSystem(Variable):
|
|
|
|
|
return True
|
|
|
|
|
if not dv.Get('os_linux_name'):
|
|
|
|
|
raise VariableError("")
|
|
|
|
|
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)
|
|
|
|
|
a = list(dv.Get('cl_update_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)
|
|
|
|
|
except (DataVarsError, VariableError) as e:
|
|
|
|
|
if str(e):
|
|
|
|
|
message = ". " + str(e)
|
|
|
|
@ -1381,9 +1395,6 @@ class VariableClUpdateProfileSystem(Variable):
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
def choice(self):
|
|
|
|
|
url = self.Get(self.url)
|
|
|
|
|
if not url:
|
|
|
|
|
return []
|
|
|
|
|
arch = self.Get(self.gentoo_arch)
|
|
|
|
|
profiles = list(zip(*self.Select([self.profiles_shortname,
|
|
|
|
|
self.profiles_fullname],
|
|
|
|
|