From a9e5b78c6495eb863e5827053015c6e33641c448 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 11 Nov 2022 14:57:26 +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=20=09=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=BE:=20?= =?UTF-8?q?=20=20=20=20=20pym/update/wsdl=5Fupdate.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pym/update/update.py | 21 ++++++++++++++------- pym/update/utils/cl_update.py | 2 +- pym/update/variables/update.py | 27 +++++++++++++++++++++------ pym/update/wsdl_update.py | 6 +++--- 4 files changed, 39 insertions(+), 17 deletions(-) diff --git a/pym/update/update.py b/pym/update/update.py index 1d611e6..8801b47 100644 --- a/pym/update/update.py +++ b/pym/update/update.py @@ -1490,7 +1490,7 @@ class Update(MethodsInterface): if not changes: return False - self.create_binhost_data(a) + self.create_binhost_data() return True def drop_binhosts(self, dv): @@ -1624,10 +1624,14 @@ class Update(MethodsInterface): 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") - binhost_list = [dv.Get('cl_update_binhost')] + # 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 = 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] self.binhosts_data = Binhosts( # значение малозначимо, поэтому берётся из собирающей системы @@ -1637,6 +1641,7 @@ class Update(MethodsInterface): last_ts, binhost_list, self.get_arch_machine(), gpg=dv.Get('update.cl_update_gpg')) + return True @variable_module("update") @@ -1742,8 +1747,8 @@ class Update(MethodsInterface): """ Проверка текущего сервера обновлений на валидность """ - if not binhost_url in self.binhosts_data.binhost_list: - raise UpdateError(_("Current binhost is absent in list of update servers")) + # if not binhost_url in self.binhosts_data.binhost_list: + # raise UpdateError(_("Current binhost is absent in list of update servers")) binhost = self.binhosts_data.get_binhost(binhost_url) ignore_level = self.clVars.Get("cl_update_ignore_level") == Variable.On cur_level_valid = self.is_current_level_a_digit() if not ignore_level else None @@ -1800,6 +1805,8 @@ class Update(MethodsInterface): raise UpdateError( _("Current binhost {} has wrong signature").format( binhost_url)) + self.clVars.Write('cl_update_binhost', binhost_url) + self.clVars.Write('cl_update_binhost_set', 'on') 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 4d1b0bd..61b0a94 100644 --- a/pym/update/utils/cl_update.py +++ b/pym/update/utils/cl_update.py @@ -56,7 +56,7 @@ def get_synchronization_tasks(object_name): {'name': 'check_current_binhost', 'message': __("Checking current binhost"), 'essential': False, - 'method': Object('check_current_binhost(update.cl_update_binhost)'), + 'method': Object('check_current_binhost(update.cl_update_new_binhost)'), 'condition': lambda GetBool, Get: ( not GetBool('update.cl_update_binhost_recheck_set') and Get('update.cl_update_sync_rep') and diff --git a/pym/update/variables/update.py b/pym/update/variables/update.py index 0890b69..1f46e69 100644 --- a/pym/update/variables/update.py +++ b/pym/update/variables/update.py @@ -199,16 +199,17 @@ class VariableClUpdateRepHosting(Variable): class VariableClUpdateRepHostingChoice(Variable): type = "choice" value = '' - opt = ["--hosting"] + opt = ["--repo-update"] + metavalue = (_("REPOSITORY URL")) def init(self): - self.label = (_("Hosting name")) - self.help = (_("Hosting to download from")) + self.label = (_("Update repository")) + self.help = (_("Hosting to download repository from")) def choice(self): a = [x[1] for x in self.Get('cl_update_inner_rep_list')] b = self.Get('cl_update_inner_rep_list') - return [x[1] for x in self.Get('cl_update_inner_rep_list')] + return [x[1] for x in self.Get('cl_update_inner_rep_list')] or ['Default'] class VariableClUpdateLaymanStorage(Variable): @@ -1695,15 +1696,29 @@ class VariableClUpdateBinhostStableOptSet(Variable): class VariableClUpdateBinhostChoice(Variable): type = "choiceedit" value = '' - opt = ["--binhost"] + opt = ["-m", "--mirror-update"] + metavalue = "MIRROR_URL" def init(self): - self.label = _("Mirror url") + self.label = _("Packages mirror") + self.help = _("Url to download binary packages from") def choice(self): return 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') + 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') + class VariableClUpdateBinhost(Variable): """ diff --git a/pym/update/wsdl_update.py b/pym/update/wsdl_update.py index 3ad3921..a4d9077 100644 --- a/pym/update/wsdl_update.py +++ b/pym/update/wsdl_update.py @@ -69,13 +69,13 @@ class Wsdl(WsdlBase): 'cl_update_binhost_stable_opt_set', 'cl_update_binhost_recheck_set', 'cl_update_with_bdeps_opt_set', + 'cl_update_binhost_choice', + 'cl_update_rep_hosting_choice', ), expert=( 'cl_update_inner_other_set', 'cl_update_sync_only_set', 'cl_update_pretend_set', - 'cl_update_binhost_choice', - 'cl_update_rep_hosting_choice', 'cl_update_sync_rep', 'cl_update_emergelist_set', 'cl_update_check_rep_set', @@ -125,7 +125,7 @@ class Wsdl(WsdlBase): 'native_error': (VariableError, DataVarsError, InstallError, UpdateError, GitError), # значения по умолчанию для переменных этого метода - 'setvars': {'cl_action!': 'update_profile', 'cl_update_world_default': 'rebuild'}, + 'setvars': {'cl_action!': 'update_profile', 'cl_update_world_default': "rebuild"}, # описание груп (список лямбда функций) 'groups': [ lambda group: group(_("Repository"),