Исправление бага
master 3.7.3.5
root 1 year ago
parent 75a9f4cce9
commit 5efa64ed5a

@ -151,11 +151,19 @@ class Profile():
self.repository = repository self.repository = repository
self.profile = profile self.profile = profile
self.arch = arch self.arch = arch
self._path = None
@property @property
def path(self): def path(self):
if self._path:
return self._path
return path.join(self.repository.directory,"profiles", self.profile) return path.join(self.repository.directory,"profiles", self.profile)
@path.setter
def path(self, value):
self._path = value
return value
@classmethod @classmethod
def from_string(cls, repository, s): def from_string(cls, repository, s):
parts = [x for x in s.split() if x] parts = [x for x in s.split() if x]
@ -263,6 +271,11 @@ class ProfileRepository():
profiles_desc = path.join(self.directory, "profiles/profiles.desc") profiles_desc = path.join(self.directory, "profiles/profiles.desc")
return list(filter(None, (Profile.from_string(self, line) return list(filter(None, (Profile.from_string(self, line)
for line in readLinesFile(profiles_desc)))) for line in readLinesFile(profiles_desc))))
@staticmethod
def get_local_profiles(directory):
profiles_desc = path.join(directory, "profiles/profiles.desc")
return list(filter(None, (Profile.from_string(Profile, line)
for line in readLinesFile(profiles_desc))))
def __repr__(self): def __repr__(self):
return "<ProfileRepository %s url=%s>" % (self.directory, self.url) return "<ProfileRepository %s url=%s>" % (self.directory, self.url)

@ -426,24 +426,9 @@ class Update(MethodsInterface):
working_host, url, rpath, revision = self.checkUrl(host, host_urls, repname, dv, git) working_host, url, rpath, revision = self.checkUrl(host, host_urls, repname, dv, git)
if working_host: if working_host:
break break
# --------------DEPRECATED--------------# if not working_host:
if not all([working_host, rpath, revision, url]):
dv.Write('cl_update_rep_hosting', ' ') dv.Write('cl_update_rep_hosting', ' ')
if not dv.Get("cl_update_rep_url"): raise UpdateError(_("Git is unavailable"))
raise UpdateError(_("Git is unavailable"))
url, rpath, revision = (
dv.Select(["cl_update_rep_url", "cl_update_rep_path",
"cl_update_rep_rev"],
where="cl_update_rep_name", eq=repname, limit=1))
if not url or not rpath:
raise UpdateError(_("Configuration variables for repositories "
"are not setup"))
git = self.getGit()
if not git.checkUrl(url):
raise UpdateError(_("Git %s is unavailable") % url)
if working_host: if working_host:
dv.Write('cl_update_rep_hosting', working_host) dv.Write('cl_update_rep_hosting', working_host)

@ -47,72 +47,32 @@ class ClUpdateProfileAction(Action):
'method': 'Update.migrateCacheRepository(' 'method': 'Update.migrateCacheRepository('
'cl_update_profile_url,cl_update_profile_branch,' 'cl_update_profile_url,cl_update_profile_branch,'
'cl_update_profile_storage)', 'cl_update_profile_storage)',
'message': __("Repository transfer"), 'condition': lambda Get: Get('cl_update_profile_url')},
'condition': lambda Get: not ( {'name': 'profile_from_url',
Get('cl_update_profile_storage').is_local( 'group': __('setting up from url'),
Get('cl_update_profile_url'),
Get('cl_update_profile_branch'))) and Get('cl_update_profile_check_sync_allowed')
},
{'name': 'reconfigure_vars1',
'method': 'Update.invalidateVariables("cl_update_profile_storage")',
'depend': Tasks.has('migrate_repository')
},
{'name': 'check_datavars',
'error': _("Profile not found in master"),
'condition': lambda Get: not Get('update.cl_update_profile_datavars')
},
{'name': 'drop_binhosts',
'method': 'Update.drop_binhosts(update.cl_update_profile_datavars)'
},
{'name': 'reconfigure_vars',
'method': 'Update.reconfigureProfileVars(cl_update_profile_datavars,'
'cl_chroot_path)'
},
{'name': 'reps_synchronization',
'group': __("Repositories synchronization"),
'tasks': [ 'tasks': [
{'name': 'sync_reps', {'message': __("Repository transfer"),
'foreach': 'cl_update_profile_sync_rep', 'condition': lambda Get: not (
'message': __("Checking {eachvar:capitalize} updates"), Get('cl_update_profile_storage').is_local(
'method': 'Update.syncRepositories(eachvar)', Get('cl_update_profile_url'),
'condition': lambda Get: Get('cl_update_profile_check_sync_allowed') Get('cl_update_profile_branch'))) and Get('cl_update_profile_check_sync_allowed'),
}, },
{'name': 'sync_reps:regen_cache', {'name': 'reconfigure_vars1',
'foreach': 'cl_update_sync_overlay_rep', 'method': 'Update.invalidateVariables("cl_update_profile_storage")',
'message': __("Updating the {eachvar:capitalize} repository cache"), },
'essential': False, {'name': 'check_datavars',
'method': 'Update.regenCache(eachvar)', 'error': _("Profile not found in master"),
'condition': ( 'condition': lambda Get: not Get('update.cl_update_profile_datavars'),
lambda Get: (Get('cl_update_outdate_set') == 'on' and },
Get('cl_update_metadata_force') != 'skip' or {'name': 'drop_binhosts',
Get('cl_update_metadata_force') == 'force')) 'method': 'Update.drop_binhosts(update.cl_update_profile_datavars)',
}, },
{'name': 'emerge_metadata', {'name': 'reconfigure_vars',
'message': __("Metadata transfer"), 'method': 'Update.reconfigureProfileVars(cl_update_profile_datavars,'
'method': 'Update.emergeMetadata()', 'cl_chroot_path)',
'condition': ( },
lambda Get: (Get('cl_update_outdate_set') == 'on' and ],
Get('cl_update_metadata_force') != 'skip' or 'depend': Tasks.has('migrate_repository')
Get('cl_update_metadata_force') == 'force'))
},
{'name': 'eix_update',
'message': __("Updating the eix cache for "
"{cl_update_eix_repositories}"),
'method': 'Update.eixUpdate(cl_repository_name)',
'condition': (
lambda Get: (Get('cl_update_outdate_set') == 'on' and
Get('cl_update_eixupdate_force') != 'skip' or
Get('cl_update_eixupdate_force') == 'force'))
},
# сообщение удачного завершения при обновлении репозиториев
{'name': 'success_syncrep',
'message': __("Synchronization finished"),
'depend': (Tasks.success() & Tasks.has_any("sync_reps",
"sync_other_reps",
"emerge_metadata",
"eix_update")),
}
]
}, },
{'name': 'reps_synchronization', {'name': 'reps_synchronization',
'group': __("Setting up the profile"), 'group': __("Setting up the profile"),

@ -28,7 +28,7 @@ from calculate.lib.datavars import (Variable, VariableError,
SimpleDataVars, DataVarsError) SimpleDataVars, DataVarsError)
from calculate.lib.utils.binhosts import (Binhosts, PackagesIndex, HOURS, from calculate.lib.utils.binhosts import (Binhosts, PackagesIndex, HOURS,
BinhostSignError) 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.configparser import ConfigParser
from calculate.lib.cl_lang import setLocalTranslate 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.git import Git, GitError
from calculate.lib.utils.portage import ReposConf, PortageState from calculate.lib.utils.portage import ReposConf, PortageState
from ..profile import (RepositoryStorageSet, DEFAULT_BRANCH, 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 linux as lib_linux
from calculate.lib.variables import env from calculate.lib.variables import env
@ -1031,7 +1031,7 @@ class VariableClUpdateProfileUrl(Variable):
""" """
URL текущего репозитория URL текущего репозитория
""" """
untrusted = True #untrusted = True
check_after = ["cl_update_profile_branch"] check_after = ["cl_update_profile_branch"]
check_action = "update_profile" check_action = "update_profile"
value = '' value = ''
@ -1066,7 +1066,8 @@ class VariableClUpdateProfileUrl(Variable):
def normalize_url(cls, url): def normalize_url(cls, url):
url = Git.normalize_url(url) url = Git.normalize_url(url)
if not url: if not url:
raise VariableError(_("Wrong repository URL")) return ''
#raise VariableError(_("Wrong repository URL"))
return url return url
def url_by_shortname(self, value): def url_by_shortname(self, value):
@ -1094,7 +1095,7 @@ class VariableClUpdateProfileUrl(Variable):
def check(self, value): def check(self, value):
if not value: if not value:
raise VariableError(_("Need to specify profile repository")) return True
try: try:
branch = self.Get(self.branch) branch = self.Get(self.branch)
self.Get(self.storage).get_profiles(value, branch) self.Get(self.storage).get_profiles(value, branch)
@ -1104,31 +1105,33 @@ class VariableClUpdateProfileUrl(Variable):
raise VariableError(_("Repository %s has no profiles") % raise VariableError(_("Repository %s has no profiles") %
value) value)
def get(self): # def get(self):
try: # try:
profile = self.Get(self.profile) # if not self.value:
if profile: # return self.value
while (profile != self.current_root and # profile = self.Get(self.profile)
".git" not in listDirectory(profile) and # if profile:
"repo_name" not in listDirectory( # while (profile != self.current_root and
path.join(profile,"profiles"))): # ".git" not in listDirectory(profile) and
profile = path.dirname(profile) # "repo_name" not in listDirectory(
if profile == self.current_root: # path.join(profile,"profiles"))):
return self.value # profile = path.dirname(profile)
if ".git" not in listDirectory(profile): # if profile == self.current_root:
repo_name = readFile(path.join( # return self.value
profile,"profiles/repo_name")).strip() # if ".git" not in listDirectory(profile):
if (repo_name in self.rep_names and # repo_name = readFile(path.join(
self.Get('cl_action') == self.check_action): # profile,"profiles/repo_name")).strip()
raise CriticalError( # if (repo_name in self.rep_names and
_("You need to update the repositories before " # self.Get('cl_action') == self.check_action):
"you change the profile")) # raise CriticalError(
return Git.get_url(profile, "origin") # _("You need to update the repositories before "
except CriticalError as e: # "you change the profile"))
raise VariableError(str(e)) # return Git.get_url(profile, "origin")
except Exception as e: # except CriticalError as e:
pass # raise VariableError(str(e))
return self.value # except Exception as e:
# pass
# return self.value
class VariableClUpdateProfileRepoName(ReadonlyVariable): class VariableClUpdateProfileRepoName(ReadonlyVariable):
@ -1205,19 +1208,34 @@ class VariableClProfileData(ReadonlyTableVariable):
return [x for x in profiles if x.arch == arch] return [x for x in profiles if x.arch == arch]
def get(self, hr=HumanReadable.No): def get(self, hr=HumanReadable.No):
rep = self.Get(self.repository) try:
if not rep: self.Get('cl_update_profile_url')
return [[]] except:
profiles = rep.get_profiles()
if not profiles:
return [[]] 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) filtered_profiles = self.profile_filter(profiles)
full_name = [x.profile for x in filtered_profiles] full_name = [x.profile for x in filtered_profiles]
profile_path = [x.path for x in filtered_profiles] profile_path = [x.path for x in filtered_profiles]
profile_arch = [x.arch for x in filtered_profiles] profile_arch = [x.arch for x in filtered_profiles]
short_name = simplify_profiles(full_name) short_name = simplify_profiles(full_name)
full_name = ["%s:%s" % (repo_name, x) for x in full_name]
return list(zip(full_name, return list(zip(full_name,
short_name, short_name,
profile_path, profile_path,
@ -1350,10 +1368,6 @@ class VariableClUpdateProfileSystem(Variable):
return True return True
if not dv.Get('os_linux_name'): if not dv.Get('os_linux_name'):
raise VariableError("") 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)
except (DataVarsError, VariableError) as e: except (DataVarsError, VariableError) as e:
if str(e): if str(e):
message = ". " + str(e) message = ". " + str(e)
@ -1380,9 +1394,6 @@ class VariableClUpdateProfileSystem(Variable):
return "" return ""
def choice(self): def choice(self):
url = self.Get(self.url)
if not url:
return []
arch = self.Get(self.gentoo_arch) arch = self.Get(self.gentoo_arch)
profiles = list(zip(*self.Select([self.profiles_shortname, profiles = list(zip(*self.Select([self.profiles_shortname,
self.profiles_fullname], self.profiles_fullname],

Loading…
Cancel
Save