|
|
|
@ -1380,20 +1380,12 @@ class Update(MethodsInterface):
|
|
|
|
|
"appropriate updates"))
|
|
|
|
|
else:
|
|
|
|
|
with writeFile(self.get_bin_cache_filename()) as f:
|
|
|
|
|
f.write(datas[0].strip()+"\n")
|
|
|
|
|
f.write(datas[0].strip() + "\n")
|
|
|
|
|
if write_binhost:
|
|
|
|
|
if hosts[0] != self.clVars.Get('update.cl_update_binhost'):
|
|
|
|
|
self.refresh_binhost = True
|
|
|
|
|
self.clVars.Set('cl_update_package_cache_set', 'on')
|
|
|
|
|
if self.clVars.GetBool('update.cl_update_binhost_recheck_set'):
|
|
|
|
|
self.clVars.Write('cl_update_binhost', hosts[0], location="system")
|
|
|
|
|
self.clVars.Write('cl_update_binhost_set', Variable.Off, location="system")
|
|
|
|
|
elif self.clVars.Get('cl_update_binhost_choice') and self.clVars.Get('cl_update_binhost_choice') != 'auto':
|
|
|
|
|
self.clVars.Write('cl_update_binhost', self.clVars.Get('cl_update_binhost_choice'), location="system")
|
|
|
|
|
self.clVars.Write('cl_update_binhost_set', Variable.On, location="system")
|
|
|
|
|
elif not self.clVars.GetBool('update.cl_update_binhost_set'):
|
|
|
|
|
self.clVars.Write('cl_update_binhost', hosts[0], location="system")
|
|
|
|
|
self.clVars.Write('cl_update_binhost_set', Variable.Off, location="system")
|
|
|
|
|
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]
|
|
|
|
@ -1410,6 +1402,54 @@ class Update(MethodsInterface):
|
|
|
|
|
location="system")
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
# def update_local_info_binhost(self, write_binhost=True):
|
|
|
|
|
# """
|
|
|
|
|
# Проверить, что доступен хотя бы один из binhost'ов
|
|
|
|
|
# :return:
|
|
|
|
|
# """
|
|
|
|
|
# hosts = self.clVars.Get("update.cl_update_binhost_host")
|
|
|
|
|
# datas = self.clVars.Get("update.cl_update_binhost_revisions")
|
|
|
|
|
# if not hosts:
|
|
|
|
|
# self.delete_binhost()
|
|
|
|
|
# raise UpdateError(_("Failed to find the server with "
|
|
|
|
|
# "appropriate updates"))
|
|
|
|
|
# else:
|
|
|
|
|
# with writeFile(self.get_bin_cache_filename()) as f:
|
|
|
|
|
# f.write(datas[0].strip()+"\n")
|
|
|
|
|
# if write_binhost:
|
|
|
|
|
# if hosts[0] != self.clVars.Get('update.cl_update_binhost'):
|
|
|
|
|
# self.refresh_binhost = True
|
|
|
|
|
# self.clVars.Set('cl_update_package_cache_set', 'on')
|
|
|
|
|
# if self.clVars.GetBool('update.cl_update_binhost_recheck_set'):
|
|
|
|
|
# self.clVars.Write('cl_update_binhost', hosts[0], location="system")
|
|
|
|
|
# self.clVars.Write('cl_update_binhost_set', Variable.Off, location="system")
|
|
|
|
|
# elif self.clVars.Get('cl_update_binhost_choice') and self.clVars.Get('cl_update_binhost_choice') != 'auto':
|
|
|
|
|
# cur_binhost = self.clVars.Get('cl_update_binhost_choice')
|
|
|
|
|
# if not cur_binhost.startswith("http://") \
|
|
|
|
|
# and not cur_binhost.startswith("ftp://")\
|
|
|
|
|
# and not cur_binhost.startswith("https://"):
|
|
|
|
|
# cur_binhost = f"https://{cur_binhost}"
|
|
|
|
|
# self.clVars.Write('cl_update_binhost', cur_binhost, location="system")
|
|
|
|
|
# self.clVars.Write('cl_update_binhost_set', Variable.On, location="system")
|
|
|
|
|
# elif not self.clVars.GetBool('update.cl_update_binhost_set'):
|
|
|
|
|
# self.clVars.Write('cl_update_binhost', hosts[0], location="system")
|
|
|
|
|
# self.clVars.Write('cl_update_binhost_set', Variable.Off, location="system")
|
|
|
|
|
# new_ts = self.clVars.Get("update.cl_update_binhost_timestamp")
|
|
|
|
|
# if new_ts:
|
|
|
|
|
# new_ts = new_ts[0]
|
|
|
|
|
# if new_ts.isdigit():
|
|
|
|
|
# ini = SystemIni(self.clVars)
|
|
|
|
|
# ini.setVar('system', {'last_update': new_ts})
|
|
|
|
|
# if self.is_update_action(self.clVars.Get("cl_action")):
|
|
|
|
|
# value = self.clVars.GetBool('update.cl_update_binhost_stable_set')
|
|
|
|
|
# new_value = self.clVars.GetBool('update.cl_update_binhost_stable_opt_set')
|
|
|
|
|
# if value != new_value:
|
|
|
|
|
# self.clVars.Write(
|
|
|
|
|
# 'cl_update_binhost_stable_set',
|
|
|
|
|
# self.clVars.Get('update.cl_update_binhost_stable_opt_set'),
|
|
|
|
|
# location="system")
|
|
|
|
|
# return True
|
|
|
|
|
|
|
|
|
|
def is_update_action(self, action):
|
|
|
|
|
return action == 'sync'
|
|
|
|
|
|
|
|
|
@ -1452,6 +1492,7 @@ class Update(MethodsInterface):
|
|
|
|
|
if not self.clVars.GetBool('update.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)
|
|
|
|
@ -1630,8 +1671,9 @@ class Update(MethodsInterface):
|
|
|
|
|
def create_binhost_data(self):
|
|
|
|
|
dv = self.clVars
|
|
|
|
|
last_ts = dv.Get('cl_update_last_timestamp')
|
|
|
|
|
if dv.Get('update.cl_update_binhost_choice') == 'auto'\
|
|
|
|
|
or not dv.Get('update.cl_update_binhost') and not dv.Get('update.cl_update_binhost_choice'):
|
|
|
|
|
if dv.Get('update.cl_update_binhost_choice') == 'auto' \
|
|
|
|
|
or (not dv.Get('update.cl_update_binhost') and not dv.Get('update.cl_update_binhost_choice'))\
|
|
|
|
|
or dv.GetBool('update.cl_update_binhost_recheck_set'):
|
|
|
|
|
dv.Write('cl_update_binhost_set', "off")
|
|
|
|
|
dv.Set('cl_update_binhost_set', 'off')
|
|
|
|
|
|
|
|
|
@ -1766,7 +1808,7 @@ class Update(MethodsInterface):
|
|
|
|
|
self.set_migration_mode(True)
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def check_current_binhost(self, binhost_url):
|
|
|
|
|
def check_current_binhost(self, binhost_url, rewrite_binhost=True):
|
|
|
|
|
"""
|
|
|
|
|
Проверка текущего сервера обновлений на валидность
|
|
|
|
|
"""
|
|
|
|
@ -1816,12 +1858,7 @@ class Update(MethodsInterface):
|
|
|
|
|
Binhosts.check_packages_signature(
|
|
|
|
|
None, pi.get_value(), self.binhosts_data.gpg,
|
|
|
|
|
sign=packages_sign)
|
|
|
|
|
if self.clVars.Get('cl_update_binhost_choice') and self.clVars.Get(
|
|
|
|
|
'cl_update_binhost_choice') != 'auto':
|
|
|
|
|
self.clVars.Write('cl_update_binhost_set', 'on')
|
|
|
|
|
self.clVars.Write('cl_update_binhost', self.clVars.Get('cl_update_binhost_choice'))
|
|
|
|
|
# else:
|
|
|
|
|
# self.clVars.Write('cl_update_binhost', self.)
|
|
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
except BinhostSignError:
|
|
|
|
|
for fn in (packages_fn, packages_sign_fn):
|
|
|
|
@ -1834,12 +1871,22 @@ class Update(MethodsInterface):
|
|
|
|
|
raise UpdateError(
|
|
|
|
|
_("Current binhost {} has wrong signature").format(
|
|
|
|
|
binhost_url))
|
|
|
|
|
self.clVars.Write('cl_update_binhost', binhost_url)
|
|
|
|
|
if self.clVars.Get('cl_update_binhost_choice') and self.clVars.Get('cl_update_binhost_choice') != 'auto':
|
|
|
|
|
self.clVars.Write('cl_update_binhost_set', 'on')
|
|
|
|
|
self.clVars.Write('cl_update_binhost', self.clVars.Get('cl_update_binhost_choice'))
|
|
|
|
|
if rewrite_binhost:
|
|
|
|
|
self.clVars.Write('cl_update_binhost', binhost_url)
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def check_chosen_binhost(self, binhost):
|
|
|
|
|
if not binhost.startswith('https://') and not binhost.startswith('ftp://') and not binhost.startswith(
|
|
|
|
|
'http://'):
|
|
|
|
|
binhost = f"https://{binhost}"
|
|
|
|
|
res = self.check_current_binhost(binhost, rewrite_binhost=False)
|
|
|
|
|
if binhost != self.clVars.Get('update.cl_update_binhost'):
|
|
|
|
|
self.refresh_binhost = True
|
|
|
|
|
self.clVars.Write('cl_update_binhost_set', 'on')
|
|
|
|
|
self.clVars.Write('cl_update_binhost', binhost)
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_migration_mirror_url(self, host, level):
|
|
|
|
|
level_required = int(level) + 1
|
|
|
|
|
return f"{host}level{level_required}"
|
|
|
|
|