From bbe7d914ce2668bd03673eb210aad4670e72e99a Mon Sep 17 00:00:00 2001 From: root Date: Fri, 25 Nov 2022 16:11:57 +0300 Subject: [PATCH] cl-update: Fix: detect_best_binhost logic. Add tmp solution for bad update level bug. --- pym/update/update.py | 36 +++++++++++++++------------------- pym/update/variables/update.py | 3 --- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/pym/update/update.py b/pym/update/update.py index ea7707c..91a3c21 100644 --- a/pym/update/update.py +++ b/pym/update/update.py @@ -1575,6 +1575,8 @@ class Update(MethodsInterface): raise self.clVars.Write('cl_update_binhost', url_binhost.split('/grp/')[0]) self.clVars.Set('update.cl_update_binhost', url_binhost.split('/grp/')[0]) + if self.clVars.Get('update.cl_update_binhost_choice'): + self.clVars.Write('cl_update_binhost_set', Variable.On) return True class Reason(): @@ -1623,23 +1625,20 @@ class Update(MethodsInterface): if not dv.Get('update.cl_update_binhost') and not dv.Get('update.cl_update_binhost_choice'): dv.Write('cl_update_binhost_set', "off") dv.Set('cl_update_binhost_set', 'off') - if (not dv.Get('update.cl_update_binhost_choice') and not dv.GetBool('update.cl_update_binhost_set')) \ - or dv.Get('update.cl_update_binhost_choice') == 'auto' \ - or (dv.Get('update.cl_update_binhost') and not dv.GetBool('update.cl_update_binhost_set')): - 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: - # 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") + if dv.Get('update.cl_update_binhost_choice'): binhost = dv.Get('cl_update_binhost_choice') if not binhost.startswith('https://') and not binhost.startswith('ftp://') and not binhost.startswith( 'http://'): binhost = f"https://{binhost}" binhost_list = [binhost] + elif dv.Get('update.cl_update_binhost') and dv.GetBool('update.cl_update_binhost_set'): + binhost = dv.Get('cl_update_binhost') + binhost_list = [binhost] + else: + 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') self.binhosts_data = Binhosts( # значение малозначимо, поэтому берётся из собирающей системы @@ -1654,12 +1653,6 @@ class Update(MethodsInterface): @variable_module("update") def _search_best_binhost(self, binhosts_data, stabilization, ignore_level=False): - try: - if self.clVars.Get("cl_update_binhost_choice"): - self.clVars.Set('update.cl_update_binhost', self.clVars.Get("cl_update_binhost_choice")) - return self.clVars.Get("cl_update_binhost_choice") - except: - pass if not self.clVars.Get('cl_ebuild_phase'): logger = self._get_binhost_logger() if logger: @@ -1857,11 +1850,14 @@ class Update(MethodsInterface): self._set_update_level(best_binhost_level) else: cmpr = self.compare_update_level(best_binhost_level) - if cmpr > 0: + if cmpr is None: + self.printWARNING("Failed to find working binhost. As a temporary solution you can use " + "'cl-update --mirror-update https://mirror.calculate-linux.org/migrate' command") + elif cmpr > 0: self.set_migration_mode(True) raise UpdateError(_("Current level: {} Binhost level: {}").\ format(self.clVars.Get("update.cl_update_level"), best_binhost_level)) - if cmpr < 0: + elif cmpr < 0: self.delete_binhost() raise UpdateError(_("Failed to find binhost with level equal or higher than local level")) self.endTask() diff --git a/pym/update/variables/update.py b/pym/update/variables/update.py index 15c15e4..40c20de 100644 --- a/pym/update/variables/update.py +++ b/pym/update/variables/update.py @@ -1742,9 +1742,6 @@ class VariableClUpdateNewBinhost(Variable): binhost = self.Get('cl_update_binhost_choice') if binhost == 'auto': return self.Get('cl_update_binhost') - elif not binhost.startswith('https://') and not binhost.startswith('ftp://') and not binhost.startswith( - 'http://'): - binhost = f"https://{binhost}" return binhost return self.Get('cl_update_binhost')