From 9c0507adcdb864475dd4982c41acf3c85501fb40 Mon Sep 17 00:00:00 2001 From: wangsong Date: Wed, 22 Jun 2022 02:16:00 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E5=BC=BA=E5=88=B6?= =?UTF-8?q?=E9=99=8D=E7=BA=A7=E7=B3=BB=E7=BB=9F=E8=BD=AF=E4=BB=B6=E5=8C=85?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E7=9A=84=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/Core/UpdateList.py | 123 +++++++++--------- backend/SystemUpdater/UpdateManager.py | 1 + .../backend/InstallBackendAptdaemon.py | 8 +- backend/SystemUpdater/backend/__init__.py | 56 ++++++-- 4 files changed, 110 insertions(+), 78 deletions(-) diff --git a/backend/SystemUpdater/Core/UpdateList.py b/backend/SystemUpdater/Core/UpdateList.py index f8ca9f2..13735e8 100644 --- a/backend/SystemUpdater/Core/UpdateList.py +++ b/backend/SystemUpdater/Core/UpdateList.py @@ -276,7 +276,7 @@ class UpdateList(): except Exception as e: logging.error(e) - def _split_package_id(package): + def _split_package_id(self,package): """Return the name, the version number and the release of the specified package.""" if "=" in package: @@ -290,68 +290,56 @@ class UpdateList(): version = release = None return name, version, release - def _mark_packages_for_downgrade(self, packages, resolver): - """Mark packages for downgrade.""" - for pkg_name, pkg_ver, pkg_rel in [self._split_package_id(pkg) - for pkg in packages]: - try: - pkg = self.cache[pkg_name] - except KeyError: - pass - # raise TransactionFailed(ERROR_NO_PACKAGE, - # _("Package %s isn't available"), - # pkg_name) - if not pkg.is_installed: - pass - # raise TransactionFailed(ERROR_PACKAGE_NOT_INSTALLED, - # _("Package %s isn't installed"), - # pkg_name) - auto = pkg.is_auto_installed - - if pkg_ver: - if pkg.installed and pkg.installed.version < pkg_ver: - pass - # FIXME: We need a new error enum - # raise TransactionFailed(ERROR_NO_PACKAGE, - # _("The former version %s of %s " - # "is already installed"), - # pkg.installed.version, pkg.name) - elif pkg.installed and pkg.installed.version == pkg_ver: - pass - # raise TransactionFailed(ERROR_PACKAGE_ALREADY_INSTALLED, - # _("The version %s of %s " - # "is already installed"), - # pkg.installed.version, pkg.name) - try: - pkg.candidate = pkg.versions[pkg_ver] - except KeyError: - pass - # raise TransactionFailed(ERROR_NO_PACKAGE, - # _("The version %s of %s isn't " - # "available"), pkg_ver, pkg_name) - else: - pass - # raise TransactionFailed(ERROR_NO_PACKAGE, - # _("You need to specify a version to " - # "downgrade %s to"), - # pkg_name) - - # pkg.mark_install(False, False, True) - # pkg.mark_auto(auto) - # resolver.clear(pkg) - # resolver.protect(pkg) - - def _make_downgrade(self,cache,data): - downgrade_pkgs = data["force_downgrade"] + def _make_downgrade(self,cache,downgrade_pkgs): + output_downgrade = [] + adjust_pkgs = [] for pkg_name, pkg_ver, pkg_rel in [self._split_package_id(pkg) for pkg in downgrade_pkgs]: try: pkg = cache[pkg_name] except KeyError: logging.warning("Package %s isn't available",pkg_name) + continue if not pkg.is_installed: logging.warning("Package %s isn't installed",pkg_name) - pass + + if pkg_ver: + if pkg.installed and pkg.installed.version < pkg_ver: + logging.warning("The former version %s of %s is already installed",pkg.installed.version, pkg.name) + continue + elif pkg.installed and pkg.installed.version == pkg_ver: + logging.warning("The version %s of %s is already installed",pkg.installed.version, pkg.name) + continue + + try: + pkg.candidate = pkg.versions[pkg_ver] + except KeyError: + logging.warning("The version %s of %s isn't available",pkg_ver, pkg_name) + continue + + output_downgrade.append(pkg_name) + adjust_pkgs.append(pkg_name+'='+pkg_ver) + + return output_downgrade,adjust_pkgs + + def _get_downgrade_list(self,cache,data): + downgrade_pkgs = [] + + try: + downgrade_raw = data['force_downgrade'] + except Exception as e: + downgrade_raw = [] + + for pkg_name, pkg_ver, pkg_rel in [self._split_package_id(pkg) + for pkg in downgrade_raw]: + + if pkg_name in cache: + downgrade_pkgs.append(pkg_name) + else: + logging.warning("Package %s isn't available",pkg_name) + continue + + return downgrade_raw,downgrade_pkgs def _make_groups_upgrade(self,cache,group_list, pkgs_upgrade = []): try: @@ -385,17 +373,34 @@ class UpdateList(): if not group_name in group_list: continue upgrade_pkgs_list = data['upgrade_list'] - #检查包是否在cache中 以及是否已经安装 没有安装的话才添加到列表 new_install_list = self._check_pkg_in_cache(cache,data['install_list']) + + downgrade_raw,downgrade_pkgs = self._get_downgrade_list(cache,data) + #被降级的软件包优先级最高 + for pkg in downgrade_pkgs: + if pkg in upgrade_pkgs_list: + upgrade_pkgs_list.remove(pkg) + if pkg in new_install_list: + new_install_list.remove(pkg) + if pkg in self.upgrade_meta.single_pkgs: + self.upgrade_meta.single_pkgs.remove(pkg) + #进行交集 升级列表 new_upgrade_list = list(set(pkgs_upgrade) & set(upgrade_pkgs_list)) #进行源过滤 new_install_list,new_upgrade_list,adjust_pkgs = self._make_fiter_origin([cache[pkg] for pkg in new_install_list + new_upgrade_list],False) - self.upgrade_meta.adjust_pkgs.extend(adjust_pkgs) + #在总升级列表中移除这些包 + for pkg in new_upgrade_list: + pkgs_upgrade.remove(pkg) + + downgrade_pkg,adjust_pkgs = self._make_downgrade(cache,downgrade_raw) + self.upgrade_meta.adjust_pkgs.extend(adjust_pkgs) + new_upgrade_list.extend(downgrade_pkg) + #单包的优先级最高 从组中剔除此包 for pkg in self.upgrade_meta.single_pkgs: if pkg in new_install_list: @@ -404,9 +409,7 @@ class UpdateList(): #判断当前是否可升级或者新装的包 if len(new_install_list) == 0 and len(new_upgrade_list) == 0: continue - #在总升级列表中移除这些包 - for pkg in new_upgrade_list: - pkgs_upgrade.remove(pkg) + #3、生成升级的包列表JSON upgrade_pkgs_json = self._make_pkg_info_json(cache,new_upgrade_list) #2、生成安装的软件列表 diff --git a/backend/SystemUpdater/UpdateManager.py b/backend/SystemUpdater/UpdateManager.py index 3314c69..1033919 100644 --- a/backend/SystemUpdater/UpdateManager.py +++ b/backend/SystemUpdater/UpdateManager.py @@ -36,6 +36,7 @@ class UpdateManager(): BACKEND_PKG_NAME = 'kylin-system-updater' FRONTEND_PKG_NAME = "kylin-update-frontend" GROUPS_PKG_NAME = 'kylin-update-desktop-config' + SOURCES_UPDATE_NAME = "kylin-software-properties" APTD_PKG_NAME = "aptdaemon" RUN_UNATTENDED_UPGRADE = '/var/run/unattended-upgrades.pid' RETRY_LIMIT_NUM = 2 diff --git a/backend/SystemUpdater/backend/InstallBackendAptdaemon.py b/backend/SystemUpdater/backend/InstallBackendAptdaemon.py index 3b8a713..e62e223 100644 --- a/backend/SystemUpdater/backend/InstallBackendAptdaemon.py +++ b/backend/SystemUpdater/backend/InstallBackendAptdaemon.py @@ -158,13 +158,13 @@ class InstallBackendAptdaemon(InstallBackend): raise @inline_callbacks - def commit(self,model,pkgs_install, pkgs_upgrade, pkgs_remove,pkgs_purge = []): + def commit(self,model,pkgs_install, pkgs_upgrade, pkgs_remove,pkgs_downgrade = []): """Commit a list of package adds and removes""" try: - reinstall = downgrade = [] + reinstall = purge = [] trans = yield self.client.commit_packages( - pkgs_install, reinstall, pkgs_remove, purge = pkgs_purge, upgrade = pkgs_upgrade, - downgrade = downgrade,download = model, defer=True) + pkgs_install, reinstall, pkgs_remove, purge = purge, upgrade = pkgs_upgrade, + downgrade = pkgs_downgrade,download = model, defer=True) self.window_main.dbusController.transaction = trans yield self._show_transaction(trans, self.action, diff --git a/backend/SystemUpdater/backend/__init__.py b/backend/SystemUpdater/backend/__init__.py index 22703dd..282d45b 100644 --- a/backend/SystemUpdater/backend/__init__.py +++ b/backend/SystemUpdater/backend/__init__.py @@ -148,8 +148,9 @@ class InstallBackend(): #拿到升级列表 self.now_upgrade.make_upgrade_content(partial_upgrade_list) - pkgs_install,pkgs_upgrade,pkgs_remove = self._get_mark_from_cache(self.cache,self.upgrade_data.adjust_pkgs,self.action_mode) - logging.info("INSTALL install:%d , upgrade:%d remove:%d",len(pkgs_install),len(pkgs_upgrade),len(pkgs_remove)) + pkgs_install,pkgs_upgrade,pkgs_remove,pkgs_downgrade = self._get_mark_from_cache(self.cache,self.upgrade_data.adjust_pkgs,self.action_mode) + logging.info("INSTALL install:%d , upgrade:%d remove:%d pkgs_downgrade:%d",len(pkgs_install),\ + len(pkgs_upgrade),len(pkgs_remove),len(pkgs_downgrade)) #当下载数量大于200个包时 就认为属于大版本升级 开启重试机制 if len(pkgs_install) + len(pkgs_upgrade) > 100: @@ -157,7 +158,7 @@ class InstallBackend(): self.now_upgrade.version_upgrade = True #检查是否存在可升级的包 - if len(pkgs_install) == 0 and len(pkgs_upgrade) == 0 and len(pkgs_remove) == 0: + if len(pkgs_install) == 0 and len(pkgs_upgrade) == 0 and len(pkgs_remove) == 0 and len(pkgs_downgrade) == 0: raise UpdateBaseError(ERROR_NOT_UPGRADE_PACKAGES) # if self.action_mode == self.MODE_INSTALL_SINGLE: @@ -172,10 +173,10 @@ class InstallBackend(): self.window_main.collector.Upgrade_Process_Msg(self.action, {"appname":ul}) if self.action == self.ACTION_INSTALL: - self.commit(self.action,pkgs_install, pkgs_upgrade, pkgs_remove) + self.commit(self.action,pkgs_install, pkgs_upgrade, pkgs_remove,pkgs_downgrade) elif self.action == self.ACTION_DOWNLOADONLY: self._update_to_config(self.now_upgrade,pkgs_install,pkgs_upgrade,pkgs_remove) - self.commit(self.action,pkgs_install, pkgs_upgrade, pkgs_remove) + self.commit(self.action,pkgs_install, pkgs_upgrade, pkgs_remove,pkgs_downgrade) elif self.action == self.ACTION_INSTALL_SHUTDOWN: self.now_upgrade,pkgs_install,pkgs_upgrade,pkgs_remove = self._config_to_upgrade() @@ -202,8 +203,8 @@ class InstallBackend(): #获取要升级和安装的包列表 pkgs_install,pkgs_upgrade = self._make_pkgs_list(self.cache,self.upgrade_data.groups_pkgs,self.now_upgrade.upgrade_groups,self.now_upgrade.single_pkgs) #计算解决依赖关系 - delete_pkgs,delete_desc = self._make_problem_resolver(self.cache,pkgs_install,pkgs_upgrade) - pkgs_install,pkgs_upgrade,pkgs_remove = self._get_mark_from_cache(self.cache,self.upgrade_data.adjust_pkgs,self.action_mode) + delete_pkgs,delete_desc = self._make_problem_resolver(self.cache,pkgs_install,pkgs_upgrade,self.upgrade_data.adjust_pkgs) + pkgs_install,pkgs_upgrade,pkgs_remove,pkgs_downgrade = self._get_mark_from_cache(self.cache,self.upgrade_data.adjust_pkgs,self.action_mode) if len(pkgs_remove) != len(delete_pkgs): logging.warning("Simulation of the deletion package list:%s",str(delete_pkgs)) @@ -220,13 +221,14 @@ class InstallBackend(): except Exception as e: logging.error(str(e)) raise UpdateBaseError(ERROR_RESOLVER_FAILED,desc= str(e)) - pkgs_install,pkgs_upgrade,pkgs_remove = self._get_mark_from_cache(self.cache,self.upgrade_data.adjust_pkgs,self.action_mode) + pkgs_install,pkgs_upgrade,pkgs_remove,pkgs_downgrade = self._get_mark_from_cache(self.cache,self.upgrade_data.adjust_pkgs,self.action_mode) self.window_main.collector.Generate_Msg(self.now_upgrade.upgrade_groups+self.now_upgrade.single_pkgs, self.action_mode) for ul in self.window_main.collector.upgrade_list: self.window_main.collector.Upgrade_Process_Msg(self.action, {"appname":ul}) - logging.info("RESOLVER install:%d , upgrade:%d remove:%d",len(pkgs_install),len(pkgs_upgrade),len(pkgs_remove)) + logging.info("RESOLVER install:%d , upgrade:%d remove:%d pkgs_downgrade:%d",len(pkgs_install),len(pkgs_upgrade),\ + len(pkgs_remove),len(pkgs_downgrade)) is_remove_pkgs = len(pkgs_remove) != 0 #添加关于删除包的描述信息 @@ -292,7 +294,7 @@ class InstallBackend(): """Remove all downloaded files.t""" raise NotImplementedError - def commit(self,model,pkgs_install, pkgs_upgrade, pkgs_remove,pkgs_purge = []): + def commit(self,model,pkgs_install, pkgs_upgrade, pkgs_remove,pkgs_downgrade = []): """Commit the cache changes """ raise NotImplementedError @@ -317,6 +319,7 @@ class InstallBackend(): pkgs_install = [] pkgs_upgrade = [] pkgs_remove = [] + pkgs_downgrade = [] #全盘升级不做任何的调整 if upgrade_mode == self.MODE_INSTALL_SYSTEM or upgrade_mode == self.MODE_INSTALL_SINGLE: @@ -342,9 +345,11 @@ class InstallBackend(): pkgs_upgrade.append(pkg.name) elif pkg.marked_delete: pkgs_remove.append(pkg.name) + elif pkg.marked_downgrade: + pkgs_downgrade.append(pkg.name+'='+pkg.candidate.source_version) except KeyError: pass - return pkgs_install,pkgs_upgrade,pkgs_remove + return pkgs_install,pkgs_upgrade,pkgs_remove,pkgs_downgrade #获取当前升级的升级列表 def _make_groups_list(self,upgrade_data,_upgrade_mode,partial_upgrade_list): @@ -417,13 +422,26 @@ class InstallBackend(): pass return all_deps + def _split_package_id(self,package): + """Return the name, the version number and the release of the + specified package.""" + if "=" in package: + name, version = package.split("=", 1) + release = None + elif "/" in package: + name, release = package.split("/", 1) + version = None + else: + name = package + version = release = None + return name, version, release + #将获取本次升级的包 进行计算依赖关系 解决依赖问题 - def _make_problem_resolver(self,cache,pkgs_install = [],pkgs_upgrade = []): + def _make_problem_resolver(self,cache,pkgs_install = [],pkgs_upgrade = [],adjust_pkgs = []): last_broken_count = 0 #计算出来的需要删除的包列表 delete_pkgs = [] delete_desc = [] - fresh_cache = Cache() try: logging.info("ProblemResolver install:%d , upgrade:%d",len(pkgs_install),len(pkgs_upgrade)) logging.info("Start calculating dependencies...") @@ -433,12 +451,21 @@ class InstallBackend(): if cache.get_changes(): cache.clear() resolver = apt.cache.ProblemResolver(cache) + #调整候选版本强制更改版本 + for pkg_name, pkg_ver, pkg_rel in [self._split_package_id(pkg) + for pkg in adjust_pkgs]: + try: + pkg = cache[pkg_name] + pkg.candidate = pkg.versions[pkg_ver] + except KeyError: + logging.warning("The version %s of %s isn't available",pkg_ver, pkg_name) + continue #标记计算所有需要安装的 for pkg in pkgs_upgrade + pkgs_install: pkg_cache = cache[pkg] - #将第二个参数调整为False 当为True时就不能检查缺少依赖的包 默认自动移除掉了 + #将第二个参数调整为False 当为True时就不能检查缺少依赖的包 默认自动移除掉了 pkg_cache.mark_install(False, False, True) #将可自动升级的标记为自动安装 @@ -452,6 +479,7 @@ class InstallBackend(): if cache._depcache.broken_count != last_broken_count and \ self.window_main.configs_cover.getWithDefault("ConfigPkgStatus", "check_resover_remove", False) == True: last_broken_count = cache._depcache.broken_count + fresh_cache = Cache() tmp_pkgs,tmp_desc = self._emulate_calcul_delete(pkg,fresh_cache) delete_pkgs.extend(tmp_pkgs) delete_desc.extend(tmp_desc) From 2fe1b3c5bb328e1efedb094d6973526c0fad7e27 Mon Sep 17 00:00:00 2001 From: wangsong Date: Wed, 22 Jun 2022 03:07:47 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9json=E9=A1=B9=E7=9A=84?= =?UTF-8?q?=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/Core/UpdateList.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/SystemUpdater/Core/UpdateList.py b/backend/SystemUpdater/Core/UpdateList.py index 13735e8..8ead941 100644 --- a/backend/SystemUpdater/Core/UpdateList.py +++ b/backend/SystemUpdater/Core/UpdateList.py @@ -326,7 +326,7 @@ class UpdateList(): downgrade_pkgs = [] try: - downgrade_raw = data['force_downgrade'] + downgrade_raw = data['force_install_list'] except Exception as e: downgrade_raw = [] From 7b675e6049f237004674a564a92a42fe509d96e3 Mon Sep 17 00:00:00 2001 From: wangsong Date: Wed, 22 Jun 2022 19:58:11 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BC=98=E5=85=88?= =?UTF-8?q?=E5=8D=87=E7=BA=A7=E4=BB=A3=E7=A0=81=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/UpdateManager.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/SystemUpdater/UpdateManager.py b/backend/SystemUpdater/UpdateManager.py index 1033919..5f410d3 100644 --- a/backend/SystemUpdater/UpdateManager.py +++ b/backend/SystemUpdater/UpdateManager.py @@ -319,7 +319,7 @@ class UpdateManager(): try: logging.info("Check: (%s) start upgrading From %s to %s...",pkg_name,\ self_pkg.installed.source_version,self_pkg.candidate.source_version) - pkg_json.mark_install(True,False,True) + self_pkg.mark_install(True,False,True) self_upgrade.append(pkg_name) need_upgrade = True except SystemError: @@ -336,14 +336,14 @@ class UpdateManager(): #config包 for pkg_name in [self.GROUPS_PKG_NAME]: if pkg_name in cache: - pkg_json = cache[pkg_name] - if pkg_json.is_installed: - if pkg_json.is_upgradable: + self_pkg = cache[pkg_name] + if self_pkg.is_installed: + if self_pkg.is_upgradable: self.dbusController.UpdateDetectStatusChanged(95,_("Group configuration being updated")) logging.info("Check: groups JSON ConfigPkgs(%s) start upgrading From %s to %s...",pkg_name,\ - pkg_json.installed.source_version,pkg_json.candidate.source_version) + self_pkg.installed.source_version,self_pkg.candidate.source_version) try: - pkg_json.mark_install() + self_pkg.mark_install() self_upgrade.append(pkg_name) need_upgrade = True except SystemError: @@ -351,12 +351,12 @@ class UpdateManager(): self.simulate_mode.thread_install([pkg_name]) raise UpdateBaseError(ERROR_NOT_CONFIGPKG_DEPENDENCIES) else: - logging.info("Check: ConfigPkgs(%s:%s) No need to upgrade...",pkg_name,pkg_json.installed.source_version) + logging.info("Check: ConfigPkgs(%s:%s) No need to upgrade...",pkg_name,self_pkg.installed.source_version) else: self.dbusController.UpdateDetectStatusChanged(95,_("Group configuration being updated")) logging.info("Check: groups JSON ConfigPkgs(%s) start new installing...",pkg_name) try: - pkg_json.mark_install(True,False,True) + self_pkg.mark_install(True,False,True) self_upgrade.append(pkg_name) need_upgrade = True except SystemError: From d25742c0c2ddc418b575831fd275176f3a44e13e Mon Sep 17 00:00:00 2001 From: wangsong Date: Wed, 22 Jun 2022 23:49:33 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E5=85=B3=E6=9C=BA=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E7=9A=84=E6=A8=A1=E5=BC=8F=E5=A2=9E=E5=8A=A0=E5=8F=91=E9=80=81?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/backend/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/SystemUpdater/backend/__init__.py b/backend/SystemUpdater/backend/__init__.py index 282d45b..06d5e59 100644 --- a/backend/SystemUpdater/backend/__init__.py +++ b/backend/SystemUpdater/backend/__init__.py @@ -612,6 +612,7 @@ class InstallBackend(): elif action == self.ACTION_INSTALL_SHUTDOWN: # self._release_install_lock() + self._send_error_code(error_code) #插入数据库 self.window_main.sqlite3_server.insert_info(self.ACTION_INSTALL,self.now_upgrade.single_pkgs,\ self.now_upgrade.upgrade_groups,[],success,error_string,error_desc) From 229f57d6e5e119b36aaf7fa8e307955e04479a3b Mon Sep 17 00:00:00 2001 From: wangsong Date: Mon, 27 Jun 2022 21:37:43 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BD=93=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E7=B3=BB=E7=BB=9F=E7=8E=AF=E5=A2=83=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=97=B6=EF=BC=8C=E6=8A=A5=E9=94=99=E9=80=80?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/Core/enums.py | 9 +++++++-- backend/SystemUpdater/backend/__init__.py | 2 +- backend/po/zh_CN.po | 6 ++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/backend/SystemUpdater/Core/enums.py b/backend/SystemUpdater/Core/enums.py index 742de1b..4191724 100644 --- a/backend/SystemUpdater/Core/enums.py +++ b/backend/SystemUpdater/Core/enums.py @@ -7,7 +7,7 @@ __all__ = ( "ERROR_UPDATE_SOURCE_FAILED","ERROR_NETWORK_FAILED","ERROR_NOT_GROUPS_CONFIG","ERROR_SOFTWARE_INDEX_RROKEN", "ERROR_NOT_INIT_PACKAGESINFIO","ERROR_READ_IMPORTANTLIST_FAILED","ERROR_RESOLVER_FAILED","ERROR_NOT_UPGRADE_PACKAGES", "ERROR_REMOVE_ESSENTIAL_PACKAGES","ERROR_NOT_DISK_SPACE","ERROR_NOT_CONFIGPKG_DEPENDENCIES","ERROR_NOT_SELFPKG_DEPENDENCIES", - + "ERROR_NOT_FIX_SYSTEM", "ERROR_UPDATE_KEY_SIGNATURES","ERROR_UPDATE_NET_AUTHENTICATION","ERROR_UPDATE_NOTREAD_SOURCES","PRIORITY_UPGRADE_SUCCCESSED", "get_error_description_from_enum", "get_error_string_from_enum", "get_source_name_from_enum") @@ -31,6 +31,8 @@ ERROR_NOT_GROUPS_CONFIG = "error-not-groups-config" ERROR_NOT_CONFIGPKG_DEPENDENCIES = "error-not-configpkg-dependencies" ERROR_NOT_SELFPKG_DEPENDENCIES = "error-not-selfpkg-dependencies" +ERROR_NOT_FIX_SYSTEM = "error-not-fix-system" + #自己的 ERROR_SOFTWARE_INDEX_RROKEN = "error-software-index-broken" ERROR_NOT_INIT_PACKAGESINFIO = "error-not-init-packagesinfo" @@ -56,7 +58,8 @@ _STRINGS_ERROR = { ERROR_NOT_GROUPS_CONFIG: _("Upgrade configuration acquisition exception."), ERROR_NOT_CONFIGPKG_DEPENDENCIES: _("Upgrade configuration acquisition exception."), ERROR_NOT_SELFPKG_DEPENDENCIES: _("Priority upgrade status exception."), - + + ERROR_NOT_FIX_SYSTEM: _("Check for update exceptions,fix system APT environment error."), #install ERROR_RESOLVER_FAILED: _("Could not calculate the upgrade"), @@ -85,6 +88,8 @@ _DESCS_ERROR = { ERROR_NOT_CONFIGPKG_DEPENDENCIES: _("Unable to install group configuration package, Please check the configuration package related dependencies."), ERROR_NOT_SELFPKG_DEPENDENCIES: _("Unable to perform priority upgrade, please check the dependency related to the priority upgrade package."), + ERROR_NOT_FIX_SYSTEM: _("The system APT environment is abnormal, please check the system APT environment."), + #install ERROR_RESOLVER_FAILED: _("nothing"), ERROR_NOT_UPGRADE_PACKAGES: _("This update cannot detect the upgradeable package."), diff --git a/backend/SystemUpdater/backend/__init__.py b/backend/SystemUpdater/backend/__init__.py index 06d5e59..7d1092e 100644 --- a/backend/SystemUpdater/backend/__init__.py +++ b/backend/SystemUpdater/backend/__init__.py @@ -696,7 +696,7 @@ class InstallBackend(): self.window_main.start_available() else: self.window_main.dbusController.UpdateDetectFinished(success,[''],\ - get_error_string_from_enum(ERROR_UPDATE_DEFAULT_FAILED),error_string+' '+error_desc) + get_error_string_from_enum(ERROR_NOT_FIX_SYSTEM),error_string+' '+error_desc) logging.error("fix broken packages is complete to failed...") elif action == self.ACTION_FIX_INCOMPLETE: diff --git a/backend/po/zh_CN.po b/backend/po/zh_CN.po index ef8d84a..fba9f18 100644 --- a/backend/po/zh_CN.po +++ b/backend/po/zh_CN.po @@ -2632,6 +2632,12 @@ msgstr "磁盘空间不足,请清理磁盘后进行升级更新" msgid "Check for update exceptions,please check your network connection." msgstr "检查更新异常,请检查您的网络连接。" +msgid "Check for update exceptions,fix system APT environment error." +msgstr "检查更新异常,修复系统APT环境出现错误。" + +msgid "The system APT environment is abnormal, please check the system APT environment." +msgstr "系统APT环境异常,请检查系统APT环境。" + msgid "Priority upgrade status exception." msgstr "优先升级异常。" From 8fc87ceb05223e4a20d3982d843fba94280b57a5 Mon Sep 17 00:00:00 2001 From: wangsong Date: Tue, 28 Jun 2022 00:16:53 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=AF=B9=E9=BA=92?= =?UTF-8?q?=E9=BA=9F=E5=AE=89=E8=A3=85=E5=99=A8=E7=9A=84=E6=9E=B7=E9=94=81?= =?UTF-8?q?=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/backend/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/SystemUpdater/backend/__init__.py b/backend/SystemUpdater/backend/__init__.py index 7d1092e..e34d2f3 100644 --- a/backend/SystemUpdater/backend/__init__.py +++ b/backend/SystemUpdater/backend/__init__.py @@ -255,7 +255,7 @@ class InstallBackend(): self.fix_incomplete() #卸载包 elif self.action == self.ACTION_REMOVE_PACKAGES: - self._start_install_lock() + # self._start_install_lock() self.purge_packages(partial_upgrade_list) elif self.action == self.ACTION_CLEAN: self.clean() @@ -275,7 +275,7 @@ class InstallBackend(): # 安装本地deb包的接口 if self.action == self.ACTION_INSTALL_DEB: try: - self._start_install_lock() + # self._start_install_lock() self.install_deb(install_path = partial_upgrade_list, install_force = _is_install) except Exception as e: logging.error(str(e)) @@ -706,11 +706,11 @@ class InstallBackend(): logging.warning("fix incomplete install failed.") elif action == self.ACTION_REMOVE_PACKAGES: - self._release_install_lock() + # self._release_install_lock() self.window_main.dbusController.PurgePackagesFinished(success,error_string,error_desc) elif action == self.ACTION_INSTALL_DEB: - self._release_install_lock() + # self._release_install_lock() #FIXME: '\r\n: \r\n\r\n'就认为是验证失败 if success == False and '\r\n: \r\n\r\n' in self.aptd_base.error_details: error_string = _("Package validation failed and installation was rejected.") From 5b3a4f3928db5e3717c847d4d5e4a43f2dfd4a5c Mon Sep 17 00:00:00 2001 From: wangsong Date: Tue, 28 Jun 2022 21:16:26 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=8B=E6=9C=BAapt?= =?UTF-8?q?=E7=9A=84=E4=B8=80=E4=BA=9B=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/backend/InstallBackendAptdaemon.py | 3 ++- backend/SystemUpdater/backend/__init__.py | 3 ++- backend/report-updater-bug | 5 +++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/backend/SystemUpdater/backend/InstallBackendAptdaemon.py b/backend/SystemUpdater/backend/InstallBackendAptdaemon.py index e62e223..cb82687 100644 --- a/backend/SystemUpdater/backend/InstallBackendAptdaemon.py +++ b/backend/SystemUpdater/backend/InstallBackendAptdaemon.py @@ -325,7 +325,8 @@ class InstallBackendAptdaemon(InstallBackend): if progress > 51 and progress < 90 and self.on_install_stage == False: logging.info("The process is now in the installtion phase") self.on_install_stage = True - self._start_install_lock() + if self.action_mode != self.MODE_INSTALL_SINGLE: + self._start_install_lock() #只处理从下载切换到安装时出现的网络问题 #当网络波动时下载某些软件包失败时属于异常状态进行重试时 不发送后续进度 等待重试正常是 进行下载安装 diff --git a/backend/SystemUpdater/backend/__init__.py b/backend/SystemUpdater/backend/__init__.py index e34d2f3..b6d796e 100644 --- a/backend/SystemUpdater/backend/__init__.py +++ b/backend/SystemUpdater/backend/__init__.py @@ -565,7 +565,8 @@ class InstallBackend(): #升级完成后走的分支 if action == self.ACTION_INSTALL: - self._release_install_lock() + if self.action_mode != self.MODE_INSTALL_SINGLE: + self._release_install_lock() self._send_error_code(error_code) if self.action_mode == self.MODE_INSTALL_SINGLE: diff --git a/backend/report-updater-bug b/backend/report-updater-bug index c20998b..486e085 100755 --- a/backend/report-updater-bug +++ b/backend/report-updater-bug @@ -14,6 +14,11 @@ echo $1 >> updaterlog/base-info echo "记录BUG产生时间(系统当前时间)以及升级相关的版本信息:" cat updaterlog/base-info +cp /etc/apt/sources.list updaterlog || true + +cp -r /etc/apt/sources.list.d/ updaterlog || true +cp -r /etc/apt/apt.conf.d / updaterlog || true + #复制后端的日志 cp -r /var/log/kylin-system-updater/ updaterlog || true From 4234e8dc3d5113ef7e4e9fe963687c437c0744d7 Mon Sep 17 00:00:00 2001 From: wangsong Date: Tue, 28 Jun 2022 23:43:14 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E5=AF=B9=E4=BC=98=E5=85=88=E5=8D=87?= =?UTF-8?q?=E7=BA=A7=E7=9A=84=E5=8A=9F=E8=83=BD=20=E7=BB=8F=E8=BF=87?= =?UTF-8?q?=E6=BA=90=E8=BF=87=E6=BB=A4=E7=9A=84=E6=99=92=E5=85=88=20?= =?UTF-8?q?=E9=98=B2=E6=AD=A2=E7=AC=AC=E4=B8=89=E6=96=B9=E6=BA=90=E9=80=A0?= =?UTF-8?q?=E6=88=90=E5=BD=B1=E5=93=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/UpdateManager.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/backend/SystemUpdater/UpdateManager.py b/backend/SystemUpdater/UpdateManager.py index 5f410d3..39279be 100644 --- a/backend/SystemUpdater/UpdateManager.py +++ b/backend/SystemUpdater/UpdateManager.py @@ -317,6 +317,11 @@ class UpdateManager(): self_pkg.installed.source_version,self_pkg.candidate.source_version) if pkg_name in important_list: try: + after_pkgs_list,adjust_pkgs = self.update_list.fu.check_in_allowed_origin([self_pkg],True) + if after_pkgs_list == [] and adjust_pkgs == []: + logging.info("Check: (%s) will not upgrading From %s to %s,duo to not locate at Allowed origins...",pkg_name,\ + self_pkg.installed.source_version,self_pkg.candidate.source_version) + continue logging.info("Check: (%s) start upgrading From %s to %s...",pkg_name,\ self_pkg.installed.source_version,self_pkg.candidate.source_version) self_pkg.mark_install(True,False,True) @@ -339,6 +344,11 @@ class UpdateManager(): self_pkg = cache[pkg_name] if self_pkg.is_installed: if self_pkg.is_upgradable: + after_pkgs_list,adjust_pkgs = self.update_list.fu.check_in_allowed_origin([self_pkg],True) + if after_pkgs_list == [] and adjust_pkgs == []: + logging.info("Check: (%s) will not upgrading From %s to %s,duo to not locate at Allowed origins...",pkg_name,\ + self_pkg.installed.source_version,self_pkg.candidate.source_version) + continue self.dbusController.UpdateDetectStatusChanged(95,_("Group configuration being updated")) logging.info("Check: groups JSON ConfigPkgs(%s) start upgrading From %s to %s...",pkg_name,\ self_pkg.installed.source_version,self_pkg.candidate.source_version) @@ -354,6 +364,11 @@ class UpdateManager(): logging.info("Check: ConfigPkgs(%s:%s) No need to upgrade...",pkg_name,self_pkg.installed.source_version) else: self.dbusController.UpdateDetectStatusChanged(95,_("Group configuration being updated")) + after_pkgs_list,adjust_pkgs = self.update_list.fu.check_in_allowed_origin([self_pkg],True) + if after_pkgs_list == [] and adjust_pkgs == []: + logging.info("Check: (%s) will not upgrading From %s to %s,duo to not locate at Allowed origins...",pkg_name,\ + self_pkg.installed.source_version,self_pkg.candidate.source_version) + continue logging.info("Check: groups JSON ConfigPkgs(%s) start new installing...",pkg_name) try: self_pkg.mark_install(True,False,True) From a9786e492818c68f63f9a57d63da16008f1241d6 Mon Sep 17 00:00:00 2001 From: wangsong Date: Wed, 29 Jun 2022 01:45:20 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=BA=90=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E7=9A=84=E6=89=A7=E8=A1=8C=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/Core/UpdateList.py | 25 +++++++++-------- backend/SystemUpdater/UpdateManager.py | 33 ++++++++++++----------- backend/SystemUpdater/backend/__init__.py | 1 + 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/backend/SystemUpdater/Core/UpdateList.py b/backend/SystemUpdater/Core/UpdateList.py index 8ead941..a05a656 100644 --- a/backend/SystemUpdater/Core/UpdateList.py +++ b/backend/SystemUpdater/Core/UpdateList.py @@ -59,11 +59,10 @@ class UpdateList(): if self.parent.options.close_filter == False and self.parent.source_info.is_disc == False and \ self.parent.configs_cover.getWithDefault("SystemStatusCover", "close_source_filter", False) == False : #开启原过滤 - self.close_filter = False self.fu = UpdateListFilterCache(self.parent) else: + self.fu = None logging.info("Close to Allowed origin fiter...") - self.close_filter = True #清空上次输出的分组JSON文件 @@ -106,13 +105,11 @@ class UpdateList(): tmp.append(pkg_obj) else: upgradeable_groups.append(pkg_name) - - if tmp != [] or self.close_filter == False: + + if tmp != []: install_list,upgrade_list,adjust_pkgs = self._make_fiter_origin(tmp,True) self.upgrade_meta.adjust_pkgs.extend(adjust_pkgs) upgradeable_pkgs = install_list + upgrade_list - else: - upgradeable_pkgs = tmp logging.info("Push Single Packages: %a, Push Groups:%a",upgradeable_pkgs,upgradeable_groups) return upgradeable_groups,upgradeable_pkgs @@ -193,19 +190,25 @@ class UpdateList(): def _make_fiter_origin(self,pkgs_list,adjust_versions): install_pkgs = [] upgrade_pkgs = [] - adjust_pkgs = [] - try: - after_pkgs_list,adjust_pkgs = self.fu.check_in_allowed_origin(pkgs_list,adjust_versions) - except Exception as e: - logging.error(str(e)) + #是否进行源过滤的选项 + if self.fu != None: + try: + after_pkgs_list,adjust_pkgs = self.fu.check_in_allowed_origin(pkgs_list,adjust_versions) + except Exception as e: + after_pkgs_list = pkgs_list + logging.error("Check Allowed origin is occur error:" + str(e)) + else: + after_pkgs_list = pkgs_list + adjust_pkgs = [] for pkg_obj in after_pkgs_list: if pkg_obj.is_installed: upgrade_pkgs.append(pkg_obj.name) else: install_pkgs.append(pkg_obj.name) + return install_pkgs,upgrade_pkgs,adjust_pkgs #从本地中获取本次升级需要升级的包 部分升级和全部升级使用 全盘升级不适用 diff --git a/backend/SystemUpdater/UpdateManager.py b/backend/SystemUpdater/UpdateManager.py index 39279be..b21b6f6 100644 --- a/backend/SystemUpdater/UpdateManager.py +++ b/backend/SystemUpdater/UpdateManager.py @@ -317,11 +317,12 @@ class UpdateManager(): self_pkg.installed.source_version,self_pkg.candidate.source_version) if pkg_name in important_list: try: - after_pkgs_list,adjust_pkgs = self.update_list.fu.check_in_allowed_origin([self_pkg],True) - if after_pkgs_list == [] and adjust_pkgs == []: - logging.info("Check: (%s) will not upgrading From %s to %s,duo to not locate at Allowed origins...",pkg_name,\ - self_pkg.installed.source_version,self_pkg.candidate.source_version) - continue + if self.update_list.fu != None: + after_pkgs_list,adjust_pkgs = self.update_list.fu.check_in_allowed_origin([self_pkg],True) + if after_pkgs_list == [] and adjust_pkgs == []: + logging.info("Check: (%s) will not upgrading From %s to %s,duo to not locate at Allowed origins...",pkg_name,\ + self_pkg.installed.source_version,self_pkg.candidate.source_version) + continue logging.info("Check: (%s) start upgrading From %s to %s...",pkg_name,\ self_pkg.installed.source_version,self_pkg.candidate.source_version) self_pkg.mark_install(True,False,True) @@ -344,11 +345,12 @@ class UpdateManager(): self_pkg = cache[pkg_name] if self_pkg.is_installed: if self_pkg.is_upgradable: - after_pkgs_list,adjust_pkgs = self.update_list.fu.check_in_allowed_origin([self_pkg],True) - if after_pkgs_list == [] and adjust_pkgs == []: - logging.info("Check: (%s) will not upgrading From %s to %s,duo to not locate at Allowed origins...",pkg_name,\ - self_pkg.installed.source_version,self_pkg.candidate.source_version) - continue + if self.update_list.fu != None: + after_pkgs_list,adjust_pkgs = self.update_list.fu.check_in_allowed_origin([self_pkg],True) + if after_pkgs_list == [] and adjust_pkgs == []: + logging.info("Check: (%s) will not upgrading From %s to %s,duo to not locate at Allowed origins...",pkg_name,\ + self_pkg.installed.source_version,self_pkg.candidate.source_version) + continue self.dbusController.UpdateDetectStatusChanged(95,_("Group configuration being updated")) logging.info("Check: groups JSON ConfigPkgs(%s) start upgrading From %s to %s...",pkg_name,\ self_pkg.installed.source_version,self_pkg.candidate.source_version) @@ -364,11 +366,12 @@ class UpdateManager(): logging.info("Check: ConfigPkgs(%s:%s) No need to upgrade...",pkg_name,self_pkg.installed.source_version) else: self.dbusController.UpdateDetectStatusChanged(95,_("Group configuration being updated")) - after_pkgs_list,adjust_pkgs = self.update_list.fu.check_in_allowed_origin([self_pkg],True) - if after_pkgs_list == [] and adjust_pkgs == []: - logging.info("Check: (%s) will not upgrading From %s to %s,duo to not locate at Allowed origins...",pkg_name,\ - self_pkg.installed.source_version,self_pkg.candidate.source_version) - continue + if self.update_list.fu != None: + after_pkgs_list,adjust_pkgs = self.update_list.fu.check_in_allowed_origin([self_pkg],True) + if after_pkgs_list == [] and adjust_pkgs == []: + logging.info("Check: (%s) will not upgrading From %s to %s,duo to not locate at Allowed origins...",pkg_name,\ + self_pkg.installed.source_version,self_pkg.candidate.source_version) + continue logging.info("Check: groups JSON ConfigPkgs(%s) start new installing...",pkg_name) try: self_pkg.mark_install(True,False,True) diff --git a/backend/SystemUpdater/backend/__init__.py b/backend/SystemUpdater/backend/__init__.py index b6d796e..d8d4e54 100644 --- a/backend/SystemUpdater/backend/__init__.py +++ b/backend/SystemUpdater/backend/__init__.py @@ -544,6 +544,7 @@ class InstallBackend(): self.window_main.dbusController.UpdateDetectFinished(False,[self.window_main.BACKEND_PKG_NAME],error_string,'') #升级本身完成后 退出 有systemd 来进行重启服务 self.window_main.dbusController.Quit(None) + return #当单包升级的时候 升级本身时,让程序退出,再重新启动 if self.window_main.GROUPS_PKG_NAME in self.now_upgrade.upgrade_content: From 9c08129778c663de4278ea35d392d560f01f9c8e Mon Sep 17 00:00:00 2001 From: wangsong Date: Wed, 29 Jun 2022 02:34:58 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E5=86=99=E5=85=A5=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=97=B6=20=E9=87=8D=E6=96=B0=E8=AF=BB?= =?UTF-8?q?=E5=8F=96=E5=86=8D=E5=86=99=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/Core/UpdaterConfigParser.py | 3 ++- backend/SystemUpdater/backend/InstallBackendAptdaemon.py | 3 +-- backend/SystemUpdater/backend/__init__.py | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/backend/SystemUpdater/Core/UpdaterConfigParser.py b/backend/SystemUpdater/Core/UpdaterConfigParser.py index f7af471..bfef7bd 100755 --- a/backend/SystemUpdater/Core/UpdaterConfigParser.py +++ b/backend/SystemUpdater/Core/UpdaterConfigParser.py @@ -32,8 +32,9 @@ class UpgradeConfig(SafeConfigParser): def setValue(self, section, option, value=None,is_write = True): if option != 'upgradelist': logging.info("SetValue Section:%s Option:%s Value:%s",section, option, value) - try: + self.reReadConfigFiles() + self.set(section, option,value) except Exception as e: logging.error("Error: setValue section:%s option:%s value:%s",section, option, value) diff --git a/backend/SystemUpdater/backend/InstallBackendAptdaemon.py b/backend/SystemUpdater/backend/InstallBackendAptdaemon.py index cb82687..e62e223 100644 --- a/backend/SystemUpdater/backend/InstallBackendAptdaemon.py +++ b/backend/SystemUpdater/backend/InstallBackendAptdaemon.py @@ -325,8 +325,7 @@ class InstallBackendAptdaemon(InstallBackend): if progress > 51 and progress < 90 and self.on_install_stage == False: logging.info("The process is now in the installtion phase") self.on_install_stage = True - if self.action_mode != self.MODE_INSTALL_SINGLE: - self._start_install_lock() + self._start_install_lock() #只处理从下载切换到安装时出现的网络问题 #当网络波动时下载某些软件包失败时属于异常状态进行重试时 不发送后续进度 等待重试正常是 进行下载安装 diff --git a/backend/SystemUpdater/backend/__init__.py b/backend/SystemUpdater/backend/__init__.py index d8d4e54..23a8a53 100644 --- a/backend/SystemUpdater/backend/__init__.py +++ b/backend/SystemUpdater/backend/__init__.py @@ -566,8 +566,7 @@ class InstallBackend(): #升级完成后走的分支 if action == self.ACTION_INSTALL: - if self.action_mode != self.MODE_INSTALL_SINGLE: - self._release_install_lock() + self._release_install_lock() self._send_error_code(error_code) if self.action_mode == self.MODE_INSTALL_SINGLE: