изменено: pym/update/update.py

изменено:      pym/update/variables/update.py
	изменено:      pym/update/wsdl_update.py
master 3.7.2.29
root 1 year ago
parent 8534ea0481
commit 98bbebd1f6

@ -385,17 +385,42 @@ class Update(MethodsInterface):
"""
dv = self.clVars
check_status = dv.GetBool('update.cl_update_check_rep_set')
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)
working_host = ''
if 'cl_update_rep_list' in dv.allVars and dv.Get('cl_update_rep_list'):
# Берем первый доступный хостинг из списка
for host_urls, host in dv.Get('cl_update_inner_rep_list'):
url, rpath, revision = (
dv.Select([host_urls, "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 for %s") % host)
if git.checkUrl(url):
working_host = host
break
else:
self.printWARNING(_("Git %s is unavailable, scaning next host") % url)
if not working_host:
raise UpdateError(_("Git is unavailable"))
dv.Write('cl_update_rep_hosting', working_host)
#--------------DEPRECATED--------------#
else:
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)
# --------------DEPRECATED--------------#
chroot_path = path.normpath(self.clVars.Get('cl_chroot_path'))
if chroot_path == '/':
rpath_orig = rpath
@ -452,6 +477,7 @@ class Update(MethodsInterface):
"{repname} repository").format(
repname=repname) + _(": ") + str(e))
finally:
self.clVars.Write('cl_update_rep_hosting', val='', header='update')
if path.exists(rpath_new):
removeDir(rpath_new)
else:
@ -1315,7 +1341,8 @@ class Update(MethodsInterface):
if hosts[0] != self.clVars.Get('update.cl_update_binhost'):
self.refresh_binhost = True
self.clVars.Set('cl_update_package_cache_set', 'on')
self.clVars.Write('cl_update_binhost', hosts[0], location="system")
if not self.clVars.GetBool('cl_update_binhost_set'):
self.clVars.Write('cl_update_binhost', hosts[0], location="system")
new_ts = self.clVars.Get("update.cl_update_binhost_timestamp")
if new_ts:
new_ts = new_ts[0]
@ -1371,28 +1398,29 @@ class Update(MethodsInterface):
return True
def delete_binhost(self):
self.clVars.Delete('cl_update_binhost', location="system")
try:
bin_cache_fn = self.get_bin_cache_filename()
if path.exists(bin_cache_fn):
os.unlink(bin_cache_fn)
except OSError:
raise UpdateError(
_("Failed to remove cached ini.env of binary repository"))
try:
for varname in ('update.cl_update_package_cache',
'update.cl_update_package_cache_sign'):
fn = self.clVars.Get(varname)
if path.exists(fn):
os.unlink(fn)
except OSError:
raise UpdateError(
_("Failed to remove cached Package index"))
# удалить binhost
binhost_fn = self.inchroot(
self.clVars.Get("update.cl_update_portage_binhost_path"))
if path.exists(binhost_fn):
os.unlink(binhost_fn)
if not self.clVars.GetBool('cl_update_binhost_set'):
self.clVars.Write('cl_update_binhost', ' ', location="system")
try:
bin_cache_fn = self.get_bin_cache_filename()
if path.exists(bin_cache_fn):
os.unlink(bin_cache_fn)
except OSError:
raise UpdateError(
_("Failed to remove cached ini.env of binary repository"))
try:
for varname in ('update.cl_update_package_cache',
'update.cl_update_package_cache_sign'):
fn = self.clVars.Get(varname)
if path.exists(fn):
os.unlink(fn)
except OSError:
raise UpdateError(
_("Failed to remove cached Package index"))
# удалить binhost
binhost_fn = self.inchroot(
self.clVars.Get("update.cl_update_portage_binhost_path"))
if path.exists(binhost_fn):
os.unlink(binhost_fn)
return False
def update_binhost_list(self, dv=None):
@ -1420,7 +1448,7 @@ class Update(MethodsInterface):
if not changes:
return False
self.create_binhost_data()
self.create_binhost_data(a)
return True
def drop_binhosts(self, dv):
@ -1546,10 +1574,24 @@ class Update(MethodsInterface):
def create_binhost_data(self):
dv = self.clVars
last_ts = dv.Get('cl_update_last_timestamp')
if dv.GetBool('cl_update_binhost_stable_opt_set'):
binhost_list = dv.Get('cl_update_binhost_list')
a = dv.Get('cl_update_binhost')
c = self.clVars.getIniVar('cl_update_binhost')
d = dv.Get('cl_update_binhost_choice')
b = dv.GetBool('cl_update_binhost_set')
if (not dv.Get('cl_update_binhost_choice') and not dv.GetBool('cl_update_binhost_set')) \
or dv.Get('cl_update_binhost_choice') == 'auto':
if dv.Get('cl_update_binhost_stable_opt_set'):
binhost_list = dv.Get('cl_update_binhost_list')
else:
binhost_list = dv.Get('cl_update_binhost_unstable_list')
dv.Write('cl_update_binhost_set', "off")
else:
binhost_list = dv.Get('cl_update_binhost_unstable_list')
if dv.Get('cl_update_binhost_choice'):
dv.Write('cl_update_binhost', dv.Get('cl_update_binhost_choice'))
dv.Write('cl_update_binhost_set', "on")
binhost_list = [dv.Get('cl_update_binhost')]
#dv.Write('cl_update_binhost_set', "off")
self.binhosts_data = Binhosts(
# значение малозначимо, поэтому берётся из собирающей системы
dv.GetInteger('cl_update_binhost_timeout'),

@ -165,6 +165,35 @@ class VariableClUpdateRepUrl(Variable):
value = []
class VariableClUpdateRepList(Variable):
"""
Список путей до репозиториев
"""
type = "list"
value = []
class VariableClUpdateInnerRepList(Variable):
value = []
def get(self):
val = self.Get('cl_update_rep_list')
prev_host = self.Get('cl_update_rep_hosting')
if prev_host:
for dct in val:
for key, value in dct.items():
if key == prev_host:
yield value, key
for dct in val:
for key, value in dct.items():
if key != prev_host:
yield value, key
class VariableClUpdateRepHosting(Variable):
value = ''
class VariableClUpdateLaymanStorage(Variable):
"""
Путь к репозиториям
@ -288,6 +317,12 @@ class VariableClUpdateBranchRep(ReadonlyVariable):
def get(self):
return self.Get('cl_update_rep_name')
class VariableClUpdateBinhostSet(Variable):
type = "bool"
value = 'off'
class VariableClUpdateBinhostsInfo(ReadonlyVariable):
"""
Объект для получения информации о серверах обновлений
@ -372,6 +407,7 @@ class VariableClUpdateBinhostTime(FieldValue, Variable):
source_variable = "cl_update_binhost_data"
column = 3
class VariableClUpdateBinhostLevel(FieldValue, Variable):
"""
Список имен прочих репозиториев
@ -1622,11 +1658,23 @@ class VariableClUpdateBinhostStableOptSet(Variable):
return self.Get('cl_update_binhost_stable_set')
class VariableClUpdateBinhostChoice(Variable):
type = "choiceedit"
value = ''
opt = ["--binhost"]
def init(self):
self.label = _("Mirror url")
def choice(self):
return self.Get("cl_update_binhost_list")
class VariableClUpdateBinhost(Variable):
"""
Хост с бинарными обновлениями
"""
value = ""
value = ''
class VariableClUpdateBinhostRevisionPath(Variable):

@ -68,7 +68,8 @@ class Wsdl(WsdlBase):
normal=(
'cl_update_binhost_stable_opt_set',
'cl_update_binhost_recheck_set',
'cl_update_with_bdeps_opt_set'
'cl_update_with_bdeps_opt_set',
'cl_update_binhost_choice'
),
expert=(
'cl_update_sync_only_set',

Loading…
Cancel
Save