From 7644f43bd82df4f25a3951c4cd952c977b385c45 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 28 Nov 2022 16:45:32 +0300 Subject: [PATCH] =?UTF-8?q?=09=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE:=20=20=20=20=20=20pym/update/update.py=20=09=D0=B8=D0=B7?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=BE:=20=20=20=20=20=20pym/upda?= =?UTF-8?q?te/utils/cl=5Fupdate.py=20=09=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE:=20=20=20=20=20=20pym/update/variables/updat?= =?UTF-8?q?e.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pym/update/update.py | 42 ++++++++++++++++++++++++++-------- pym/update/utils/cl_update.py | 9 +++++--- pym/update/variables/update.py | 20 ++++++++++++---- 3 files changed, 54 insertions(+), 17 deletions(-) diff --git a/pym/update/update.py b/pym/update/update.py index 91a3c21..2300a5a 100644 --- a/pym/update/update.py +++ b/pym/update/update.py @@ -1385,8 +1385,15 @@ 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') - if not self.clVars.GetBool('update.cl_update_binhost_set'): + 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") new_ts = self.clVars.Get("update.cl_update_binhost_timestamp") if new_ts: new_ts = new_ts[0] @@ -1573,10 +1580,11 @@ class Update(MethodsInterface): self.clVars.Set('update.cl_update_binhost_recheck_set', Variable.On) self.clVars.Set('cl_update_package_cache_set', Variable.Off, force=True) 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) + # 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') \ + # and self.clVars.Get('update.cl_update_binhost_choice') != 'auto': + # self.clVars.Write('cl_update_binhost_set', Variable.On) return True class Reason(): @@ -1622,16 +1630,24 @@ class Update(MethodsInterface): def create_binhost_data(self): dv = self.clVars last_ts = dv.Get('cl_update_last_timestamp') - if 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'): dv.Write('cl_update_binhost_set', "off") dv.Set('cl_update_binhost_set', 'off') - if dv.Get('update.cl_update_binhost_choice'): + + if dv.GetBool('update.cl_update_binhost_recheck_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') + elif dv.Get('update.cl_update_binhost_choice') and dv.Get('update.cl_update_binhost_choice') != 'auto': 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'): + elif dv.Get('update.cl_update_binhost') and dv.GetBool('update.cl_update_binhost_set') \ + and dv.Get('update.cl_update_binhost_choice') != 'auto': binhost = dv.Get('cl_update_binhost') binhost_list = [binhost] else: @@ -1800,6 +1816,12 @@ 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): @@ -1813,7 +1835,9 @@ class Update(MethodsInterface): _("Current binhost {} has wrong signature").format( binhost_url)) self.clVars.Write('cl_update_binhost', binhost_url) - self.clVars.Write('cl_update_binhost_set', 'on') + 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')) return True def get_migration_mirror_url(self, host, level): diff --git a/pym/update/utils/cl_update.py b/pym/update/utils/cl_update.py index 62652f0..4d07afe 100644 --- a/pym/update/utils/cl_update.py +++ b/pym/update/utils/cl_update.py @@ -84,8 +84,9 @@ def get_synchronization_tasks(object_name): 'depend': (Tasks.success() & ~AllTasks.has_any("not_use_search") & (~AllTasks.success_one_of("check_current_binhost") | AllTasks.success_all("sync_reps"))), - 'condition': lambda Get: Get('update.cl_update_use_migration_host') == 'off' and - not Get("update.cl_update_binhost_choice") + 'condition': lambda Get: Get('update.cl_update_use_migration_host') == 'off'# or + #(not Get("update.cl_update_binhost_recheck_set") and (not Get("update.cl_update_binhost_choice") != 'auto' + #or not Get("update.cl_update_binhost_choice"))) }, {'name': 'interrupt_on_no_leveled_binhost', 'method': Object("interrupt_on_no_leveled_binhost()"), @@ -129,7 +130,9 @@ def get_synchronization_tasks(object_name): }, {'name': 'sync_reps:update_local_info_binhost', 'method': Object('update_local_info_binhost()'), - 'condition': lambda Get: not Get("update.cl_update_binhost_choice") + 'condition': lambda Get: Get("update.cl_update_binhost_choice") == 'auto' + or not Get("update.cl_update_binhost_choice") + or Get("update.cl_update_binhost_recheck_set") }, {'name': 'sync_reps:update_binhost_list', 'essential': False, diff --git a/pym/update/variables/update.py b/pym/update/variables/update.py index 40c20de..7802802 100644 --- a/pym/update/variables/update.py +++ b/pym/update/variables/update.py @@ -1732,17 +1732,25 @@ class VariableClUpdateBinhostChoice(Variable): self.label = _("Packages mirror") self.help = _("Url to download binary packages from") + def get(self): + if not self.value: + if self.GetBool("cl_update_binhost_set") and self.Get("cl_update_binhost"): + return self.Get("cl_update_binhost") + return self.value + def choice(self): - return self.Get("cl_update_binhost_list") + ['auto'] + if self.GetBool("cl_update_binhost_set") and self.Get("cl_update_binhost"): + if self.Get("cl_update_binhost") not in self.Get("cl_update_binhost_list"): + return ['auto'] + [self.Get("cl_update_binhost")] + self.Get("cl_update_binhost_list") + return ['auto'] + self.Get("cl_update_binhost_list") class VariableClUpdateNewBinhost(Variable): def get(self): if self.Get('cl_update_binhost_choice'): binhost = self.Get('cl_update_binhost_choice') - if binhost == 'auto': - return self.Get('cl_update_binhost') - return binhost + if binhost != 'auto': + return binhost return self.Get('cl_update_binhost') @@ -1839,7 +1847,9 @@ class VariableClUpdatePortageBinhost(ReadonlyVariable): #value_format = "{update.cl_update_binhost}/grp/{os_arch_machine}" def get(self): - if self.Get('update.cl_update_binhost_choice'): + if not self.Get('update.cl_update_binhost_recheck_set') \ + and self.Get('update.cl_update_binhost_choice') \ + and self.Get('update.cl_update_binhost_choice') != 'auto': return f"{self.Get('update.cl_update_binhost_choice')}/grp/{self.Get('os_arch_machine')}" return f"{self.Get('update.cl_update_binhost')}/grp/{self.Get('os_arch_machine')}"