diff --git a/backend/SystemUpdater/Core/DataAcquisition.py b/backend/SystemUpdater/Core/DataAcquisition.py index ef77b12..560c758 100644 --- a/backend/SystemUpdater/Core/DataAcquisition.py +++ b/backend/SystemUpdater/Core/DataAcquisition.py @@ -75,6 +75,7 @@ class UpdateMsgCollector(): action_map = { ACTION_CHECK_RESOLVER:enums.MONIT_DEPRESOLUT, ACTION_INSTALL:enums.MONIT_INSTALL, + ACTION_INSTALL_DEB:enums.MONIT_INSTALLDEB, 10:enums.MONIT_FINISH, "finish-update":enums.MONIT_FINISH, "finish-install":enums.MONIT_FINISH @@ -85,7 +86,8 @@ class UpdateMsgCollector(): # InstallBackend.ACTION_CHECK_RESOLVER:"Downloading", ACTION_INSTALL:"Installing", # InstallBackend.ACTION_CHECK_RESOLVER:"UpgradeFinish", - 10:"Background-upgrade", + ACTION_INSTALL_DEB:"InstallerInfo", + 10:"Background-Upgrade", "finish-update":"UpdateInfos", "finish-install":"InstallInfos" } @@ -116,6 +118,8 @@ class UpdateMsgCollector(): # 获取将要上传的数据,获取东八区时间 UploadMessage['createTimeStamp'] = get_east_8_time() try: + if "packageName" in dict_message.keys(): + dict_message.pop("packageName") for key in dict_message.keys(): UploadMessage[key] = dict_message[key] if local_uuid != '': @@ -200,9 +204,14 @@ class UpdateMsgCollector(): json_file = json.dumps(tmp_dict.copy()) self.UpdateMsg(self.messageType_map.get(action, ""), json_file, self.uuid) else: - tmp_dict.update(self.UpdateInfos) - json_file = json.dumps(tmp_dict.copy()) - self.UpdateMsg(self.messageType_map.get(action, ""), json_file, self.uuid) + if action == self.ACTION_INSTALL_DEB: + tmp_dict.update({"step":self.action_map.get(action, "")}) + json_file = json.dumps(tmp_dict.copy()) + self.UpdateMsg(self.messageType_map.get(action, ""), json_file, self.uuid) + else: + tmp_dict.update(self.UpdateInfos) + json_file = json.dumps(tmp_dict.copy()) + self.UpdateMsg(self.messageType_map.get(action, ""), json_file, self.uuid) except Exception as e: logging.error(e) tmp_dict.clear() diff --git a/backend/SystemUpdater/UpdateManager.py b/backend/SystemUpdater/UpdateManager.py index 4909df3..641864b 100644 --- a/backend/SystemUpdater/UpdateManager.py +++ b/backend/SystemUpdater/UpdateManager.py @@ -483,6 +483,8 @@ class UpdateManager(): header = '' desc = '' absolute_path, debname = os.path.split(deb_path) + self.deb_obj = {} + UpdateMsg = {} try: if not os.path.isfile(deb_path): logging.info("No such file or directory: %s.",deb_path) @@ -496,14 +498,29 @@ class UpdateManager(): if not status: self.dbusController.InstalldebFinished(False,error_string,'') return + self.deb_obj.update({"debname":str(debname)}) + self.deb_obj.update({"old_version":""}) + self.deb_obj.update({"source":str(caller)}) + UpdateMsg.update({"appname":str(self.deb_obj.get("debname","None").split("_")[0])}) + UpdateMsg.update({"source":str(self.deb_obj.get("source","kylin-system-updater"))}) + UpdateMsg.update({"new_version":str(self.deb_obj.get("debname","None").split("_")[1])}) deb_cache, ins, _isinstall = self._suit_install_mode(deb_path) if self._is_broken > 0 or not self.cacheSatisfy or self._need_downgrade: # 走 dpkg 安装流程,说明本地apt环境已经损坏,or dep not satisfied or need downgrade dep_satisfy, header, desc = self._deb_install(deb_cache, deb_path, _check_local_dep, ins) - if dep_satisfy: + if dep_satisfy: self.dbusController.InstalldebFinished(True, header, desc) + UpdateMsg.update({"status":"success"}) + UpdateMsg.update({"errorCode":" "}) else: self.dbusController.InstalldebFinished(False, header, desc) + UpdateMsg.update({"status":"failed"}) + UpdateMsg.update({"errorCode":str(header+", "+desc)}) + #dpkg发送数据 + if self.configs_uncover.getWithDefault("SystemStatus", "upload_installer_log", False) == True: + UpdateMsg.update({"old_version":str(self.deb_obj.get("old_version","None"))}) + self.collector.Upgrade_Process_Msg(InstallBackend.ACTION_INSTALL_DEB, UpdateMsg.copy()) + self.deb_obj = {} else: # apt 安装流程 dep_satisfy, header, desc = self._attempt_depends(deb_cache, deb_path, _check_local_dep,_auto_satisfy, ins) @@ -514,10 +531,18 @@ class UpdateManager(): self.dbusController.InstalldebFinished(False, header, desc) except UpdateBaseError as excep: self.dbusController.InstalldebFinished(False,excep.header,excep.desc) + UpdateMsg.update({"old_version":str(self.deb_obj.get("old_version","None"))}) + UpdateMsg.update({"errorCode":str(excep.header+", "+excep.desc)}) + UpdateMsg.update({"status":"failed"}) + self.collector.Upgrade_Process_Msg(InstallBackend.ACTION_INSTALL_DEB, UpdateMsg.copy()) except Exception as e: logging.info(str(e)) traceback.print_exc() self.dbusController.InstalldebFinished(False, str(e), desc) + UpdateMsg.update({"old_version":str(self.deb_obj.get("old_version","None"))}) + UpdateMsg.update({"errorCode":str(e)}) + UpdateMsg.update({"status":"failed"}) + self.collector.Upgrade_Process_Msg(InstallBackend.ACTION_INSTALL_DEB, UpdateMsg.copy()) #进行删除的操作 def start_purge_pkgs(self,pkgs_list): @@ -627,7 +652,6 @@ class UpdateManager(): satisfy_list = [] noSatisfyList = [] depends_count = 0 - _status = False error_string = '' header = '' desc = '' @@ -666,7 +690,6 @@ class UpdateManager(): satisfy_list.append(debfile) if depends_count < len(noSatisfyList): #本地依赖不满足 - _status = False error_string = str(debname.split("_")[0])+_("dependency is not satisfied")+", ".join(noSatisfyList) logging.error(error_string) header = error_string @@ -687,7 +710,6 @@ class UpdateManager(): return False, str(e), desc return True, header, desc elif not _check_local_dep: - _status = False if _install: error_string = str(debname.split("_")[0])+_("dependency is not satisfied")+":".join(_install) logging.error(error_string) @@ -713,18 +735,21 @@ class UpdateManager(): absolute_path, debname = os.path.split(deb_path) # 检查本地破损 try: - logging.info("Install deb package, open cache") deb_cache = Cache() logging.info("Install deb package, check broken") broken_count = deb_cache._depcache.broken_count deb = DebPackage(deb_path, deb_cache) deb.check(allow_downgrade=True) - logging.info("Install package, required changes") + logging.info("Install deb package, required changes") (install, remove, unauth) = deb.required_changes # need in cach if broken_count > 0: self._is_broken = True else : self._is_broken = False + if debname.split("_")[0] in deb_cache: + pkg = deb_cache[debname.split("_")[0]] + if pkg.is_installed: + self.deb_obj.update({"old_version":str(pkg.installed.version)}) except apt_pkg.Error as e: logging.error(str(e)) if "E:read" in str(e): diff --git a/backend/SystemUpdater/UpdateManagerDbus.py b/backend/SystemUpdater/UpdateManagerDbus.py index f973ac5..6f34431 100755 --- a/backend/SystemUpdater/UpdateManagerDbus.py +++ b/backend/SystemUpdater/UpdateManagerDbus.py @@ -1079,7 +1079,6 @@ class UpdateManagerDbusControllerUtils(dbus.service.Object): self.parent.collector.UpdateMsg(messageType, uploadMessage) except Exception as e: logging.error(str(e)) - # 检查更新 @dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='as', out_signature='as', sender_keyword='sender') diff --git a/backend/SystemUpdater/backend/InstallBackendAptdaemon.py b/backend/SystemUpdater/backend/InstallBackendAptdaemon.py index 4176310..5038959 100644 --- a/backend/SystemUpdater/backend/InstallBackendAptdaemon.py +++ b/backend/SystemUpdater/backend/InstallBackendAptdaemon.py @@ -228,11 +228,10 @@ class InstallBackendAptdaemon(InstallBackend): self._action_done(self.ACTION_INSTALL_DEB, authorized=False, success=False, error_string='', error_desc='') - except Exception: - pass - # self._action_done(self.ACTION_INSTALL_DEB, - # is_cancelled=False, success=False, - # error_string='', error_desc='') + except Exception as e: + self._action_done(self.ACTION_INSTALL_DEB, + is_cancelled=False, success=False, + error_string=str(e), error_desc='') # raise @inline_callbacks diff --git a/backend/SystemUpdater/backend/__init__.py b/backend/SystemUpdater/backend/__init__.py index 827d63f..b16f383 100644 --- a/backend/SystemUpdater/backend/__init__.py +++ b/backend/SystemUpdater/backend/__init__.py @@ -784,13 +784,30 @@ class InstallBackend(): error_string = _("Package validation failed and installation was rejected.") error_desc = '' self.window_main.dbusController.InstalldebFinished(success,error_string,error_desc) + UpdateMsg = {} + if success: + status = 'success' + UpdateMsg.update({"errorCode":" "}) + else: + status = 'failed' + UpdateMsg.update({"errorCode":str(error_string+" "+error_desc)}) + #apt发送数据 + if self.window_main.configs_uncover.getWithDefault("SystemStatus", "upload_installer_log", False) == True: + + UpdateMsg.update({"appname":str(self.window_main.deb_obj.get("debname","None").split("_")[0])}) + UpdateMsg.update({"source":str(self.window_main.deb_obj.get("source","kylin-system-updater"))}) + UpdateMsg.update({"status":str(status)}) + UpdateMsg.update({"new_version":str(self.window_main.deb_obj.get("debname","None").split("_")[1])}) + UpdateMsg.update({"old_version":str(self.window_main.deb_obj.get("old_version","None"))}) + self.window_main.collector.Upgrade_Process_Msg(self.action, UpdateMsg.copy()) + self.window_main.deb_obj = {} elif action == self.ACTION_BACKGROUND_UPGRADE: self._release_install_lock() UpdateMsg = {} if success: - status = 'Success' + status = 'success' else: - status = 'Failed' + status = 'failed' self.window_main.collector.Generate_Msg(self.window_main.collector.background_list, self.action_mode) for bl in self.window_main.collector.background_list: pkg = self.window_main.collector.cache[bl] @@ -804,6 +821,7 @@ class InstallBackend(): # self.window_main.collector.Upgrade_Process_Msg(self.action, UpdateMsg.copy()) self.window_main.dbusController.UpdateInstallFinished(success,self.now_upgrade.upgrade_content,error_string,error_desc) + def _start_install_lock(self, caller='Kylin System Updater'): self.window_main.configs_uncover.setValue("SystemStatus","abnormal_reboot",str(True)) diff --git a/backend/kylin-system-updater b/backend/kylin-system-updater index 2fe08b5..783bd47 100755 --- a/backend/kylin-system-updater +++ b/backend/kylin-system-updater @@ -83,7 +83,7 @@ if __name__ == "__main__": signal.signal(signal.SIGINT,signal_handler_term) if options.debug: - logging.basicConfig(format=FORMAT,level=logging.INFO,datefmt='%m-%d,%H:%M:%S') + logging.basicConfig(format=FORMAT,level=logging.DEBUG,datefmt='%m-%d,%H:%M:%S') else: logging.basicConfig(format=FORMAT,level=logging.DEBUG,datefmt='%m-%d,%H:%M:%S',filename = logfile(),filemode = 'a')