diff --git a/backend/SystemUpdater/UpdateManager.py b/backend/SystemUpdater/UpdateManager.py index 583e309..32f9c1c 100644 --- a/backend/SystemUpdater/UpdateManager.py +++ b/backend/SystemUpdater/UpdateManager.py @@ -181,27 +181,28 @@ class UpdateManager(): deb_cache = Cache() broken_count = deb_cache._depcache.broken_count if broken_count > 0: - errormsg = '' - pkg_list_str = " ".join(pkgs_list) - # args = ["dpkg", "-r"] - # args.extend([pkg_list_str]) - - # p = subprocess.Popen(args, stdout=subprocess.PIPE) - # (ver, error)= p.communicate() - # print(ver + error) - # print(p.returncode) - # # p.stdin.write(errormsg) - # # p.stdin.close() - # logging.error(p.stdin) - - # pkg_list_str = " ".join(pkgs_list) - return os.spawnlp(os.P_WAIT, "dpkg", "dpkg", "-r", pkg_list_str) + _success,header,desc = self._dpkg_purge_pkgs(pkgs_list) + if _success == True: + logging.info(header) + self.dbusController.PurgePackagesFinished(_success,'',desc) + else: + self.dbusController.PurgePackagesFinished(_success,header,desc) else: purge_backend = get_backend(self, InstallBackend.ACTION_REMOVE_PACKAGES) purge_backend.start(partial_upgrade_list = pkgs_list) except Exception as e: logging.error(e) + def _dpkg_purge_pkgs(self,pkgs_list): + success = False + pkg_list_str = " ".join(pkgs_list) + args = ["dpkg", "-r"] + args.extend([pkg_list_str]) + + p = subprocess.run(args, stdout=subprocess.PIPE,stderr=subprocess.STDOUT,text=True) + success = p.returncode == 0 + return success,p.stdout,'' + #更新结束之后会调到此获取要升级的列表 and 更新cache 生成升级组列表JSON def start_available(self): _success,header,desc = self.refresh_cache() diff --git a/backend/kylin-system-updater b/backend/kylin-system-updater index f229f07..7a1d7b8 100755 --- a/backend/kylin-system-updater +++ b/backend/kylin-system-updater @@ -76,4 +76,5 @@ if __name__ == "__main__": if app.configs.getWithDefault("SystemStatus", "isabnormalreboot", False) == True: app.start_update() + app.start_purge_pkgs(['kylin-video']) app.run() \ No newline at end of file