From a3e69ca216bc02783ec1904b21a9178bffc74819 Mon Sep 17 00:00:00 2001 From: Xueyi Luo Date: Wed, 8 Jun 2022 09:50:38 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E5=88=A0=E6=8E=89=E6=B2=A1=E7=94=A8?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- debian/kylin-system-updater.install | 1 - debian/postinst | 4 ---- 2 files changed, 5 deletions(-) diff --git a/debian/kylin-system-updater.install b/debian/kylin-system-updater.install index 961e3da..8bed34d 100644 --- a/debian/kylin-system-updater.install +++ b/debian/kylin-system-updater.install @@ -15,7 +15,6 @@ backend/build/mo/* /usr/share/locale/ backend/data/system-updater.conf /var/lib/kylin-system-updater/ backend/data/unattended-upgrades-policy.conf /var/lib/unattended-upgrades/ backend/data/cn.kylinos.KylinSystemUpdater.policy /usr/share/polkit-1/actions/ -backend/data/system-updater-uncoverable.conf /usr/share/kylin-system-updater/ #uu unattended-upgrades/*.service /lib/systemd/system/ diff --git a/debian/postinst b/debian/postinst index d2476cd..b3049a5 100644 --- a/debian/postinst +++ b/debian/postinst @@ -19,7 +19,3 @@ if [ -f /usr/share/kylin-system-updater/SystemUpdater/Core/DataMigration.py ];th /usr/share/kylin-system-updater/SystemUpdater/Core/DataMigration.py -u appname_cn= /usr/share/kylin-system-updater/SystemUpdater/Core/DataMigration.py -t=tid_search fi - -if [ ! -f /var/lib/kylin-system-updater/system-updater-uncoverable.conf ];then - cp /usr/share/kylin-system-updater/system-updater-uncoverable.conf /var/lib/kylin-system-updater/ -fi From 8ee315bc549485068e064a55a7176d6104642b4e Mon Sep 17 00:00:00 2001 From: Xueyi Luo Date: Wed, 8 Jun 2022 09:51:26 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=E5=88=A0=E9=99=A4conf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/data/system-updater-uncoverable.conf | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 backend/data/system-updater-uncoverable.conf diff --git a/backend/data/system-updater-uncoverable.conf b/backend/data/system-updater-uncoverable.conf deleted file mode 100644 index 3305344..0000000 --- a/backend/data/system-updater-uncoverable.conf +++ /dev/null @@ -1,6 +0,0 @@ -[UpdaterStatus] -first_run = yes - -[SYSTEM] -version = -kylin_release_id = \ No newline at end of file From c65620d466c78395e3fe2e9e8bb6d8145ea83ad3 Mon Sep 17 00:00:00 2001 From: wangsong Date: Mon, 13 Jun 2022 13:42:48 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E8=AF=8D=E6=9D=A1=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E5=A2=9E=E5=8A=A0=E6=96=B0=E4=BF=A1=E5=8F=B7?= =?UTF-8?q?=E5=8F=91=E9=80=81=E9=94=99=E8=AF=AF=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/Core/enums.py | 47 ++++++++++++---------- backend/SystemUpdater/UpdateManager.py | 17 +++++++- backend/SystemUpdater/UpdateManagerDbus.py | 8 +++- backend/SystemUpdater/backend/__init__.py | 46 ++++++++++++--------- backend/interface.md | 21 ++++++++++ backend/kylin-system-updater | 21 +++++----- backend/po/zh_CN.po | 3 ++ 7 files changed, 107 insertions(+), 56 deletions(-) diff --git a/backend/SystemUpdater/Core/enums.py b/backend/SystemUpdater/Core/enums.py index 874bb97..d9bf694 100644 --- a/backend/SystemUpdater/Core/enums.py +++ b/backend/SystemUpdater/Core/enums.py @@ -7,7 +7,7 @@ __all__ = ( "ERROR_NOT_INIT_PACKAGESINFIO","ERROR_READ_IMPORTANTLIST_FAILED","ERROR_RESOLVER_FAILED","ERROR_NOT_UPGRADE_PACKAGES", "ERROR_REMOVE_ESSENTIAL_PACKAGES","ERROR_NOT_DISK_SPACE", - "ERROR_UPDATE_KEY_SIGNATURES", + "ERROR_UPDATE_KEY_SIGNATURES","ERROR_UPDATE_NET_AUTHENTICATION","ERROR_UPDATE_NOTREAD_SOURCES", "get_error_description_from_enum", "get_error_string_from_enum", "get_source_name_from_enum") @@ -18,14 +18,8 @@ _ = gettext.gettext #更新阶段 ERROR_UPDATE_KEY_SIGNATURES = "The following signatures" - - -#UPGRADE MONITOR STATUS -MONIT_DETECT = "step-updatedetect" -MONIT_DEPRESOLUT = "step-depresolution" -MONIT_DOWNLOAD = "step-downloading" -MONIT_INSTALL = "step-installing" -MONIT_FINISH = "step-finish" +ERROR_UPDATE_NET_AUTHENTICATION ="does the network require authentication?" +ERROR_UPDATE_NOTREAD_SOURCES = "The list of sources could not be read" #自己的 ERROR_UPDATE_SOURCE_FAILED = "error-update-source-failed" @@ -39,6 +33,17 @@ ERROR_NOT_UPGRADE_PACKAGES = "error-not-upgrade-packages" ERROR_REMOVE_ESSENTIAL_PACKAGES = "error-remove-essential-packages" ERROR_NOT_DISK_SPACE = "error-not-disk-space" +_STRINGS_ERROR = { + ERROR_UPDATE_SOURCE_FAILED: _("Unable to access the source management server"), + ERROR_NETWORK_FAILED: _("Please check your network connection and retry."), + ERROR_NOT_GROUPS_CONFIG: _("Unable to get group configuration package, please contact administrator to solve"), + ERROR_SOFTWARE_INDEX_RROKEN: _("Software index is broken"), + ERROR_NOT_INIT_PACKAGESINFIO: _("Could not initialize the package information"), + ERROR_READ_IMPORTANTLIST_FAILED: _("read important list failed"), + ERROR_RESOLVER_FAILED: _("Could not calculate the upgrade"), + ERROR_NOT_UPGRADE_PACKAGES: _("There is an exception in the update package."), + ERROR_REMOVE_ESSENTIAL_PACKAGES: _("There is an exception in the update package."), + ERROR_NOT_DISK_SPACE: _("Disk space is insufficient, please clean the disk and then upgrade")} _DESCS_ERROR = { ERROR_UPDATE_SOURCE_FAILED: _("Check your source management server config"), @@ -57,20 +62,20 @@ _DESCS_ERROR = { ERROR_RESOLVER_FAILED: _("nothing"), ERROR_NOT_UPGRADE_PACKAGES: _("This update cannot detect the upgradeable package."), ERROR_REMOVE_ESSENTIAL_PACKAGES: _("You request the removal of a system-essential package."), - ERROR_NOT_DISK_SPACE: _("test")} + ERROR_NOT_DISK_SPACE: _("test"), + ERROR_UPDATE_KEY_SIGNATURES: _("Check your source public key signature"), + ERROR_UPDATE_NET_AUTHENTICATION: _("Check if your network requires authentication?"), -_STRINGS_ERROR = { - ERROR_UPDATE_SOURCE_FAILED: _("Unable to access the source management server"), - ERROR_NETWORK_FAILED: _("Please check your network connection and retry."), - ERROR_NOT_GROUPS_CONFIG: _("Unable to get group configuration package, please contact administrator to solve"), - ERROR_SOFTWARE_INDEX_RROKEN: _("Software index is broken"), - ERROR_NOT_INIT_PACKAGESINFIO: _("Could not initialize the package information"), - ERROR_READ_IMPORTANTLIST_FAILED: _("read important list failed"), - ERROR_RESOLVER_FAILED: _("Could not calculate the upgrade"), - ERROR_NOT_UPGRADE_PACKAGES: _("There is an exception in the update package."), - ERROR_REMOVE_ESSENTIAL_PACKAGES: _("There is an exception in the update package."), - ERROR_NOT_DISK_SPACE: _("Disk space is insufficient, please clean the disk and then upgrade")} + ERROR_UPDATE_NOTREAD_SOURCES: _("Please check your source list and retry.") + } + +#UPGRADE MONITOR STATUS +MONIT_DETECT = "step-updatedetect" +MONIT_DEPRESOLUT = "step-depresolution" +MONIT_DOWNLOAD = "step-downloading" +MONIT_INSTALL = "step-installing" +MONIT_FINISH = "step-finish" SOURCE_NAME = { 'kylin-installer':_("Kylin Installer"), diff --git a/backend/SystemUpdater/UpdateManager.py b/backend/SystemUpdater/UpdateManager.py index 6278a30..1f7e06f 100644 --- a/backend/SystemUpdater/UpdateManager.py +++ b/backend/SystemUpdater/UpdateManager.py @@ -77,9 +77,11 @@ class UpdateManager(): self.install_mode = UpdateInstallMode(self) self.apt_p2p_config = AptP2pConfigManager() - #加载Cache - self.refresh_cache() + self._reload_options_config() + #加载Cache + self._refresh_cache_only() + def _reload_options_config(self): #添加默认保留旧配置 @@ -277,6 +279,17 @@ class UpdateManager(): logging.error(str(e)) raise UpdateBaseError(ERROR_NOT_INIT_PACKAGESINFIO) + def _refresh_cache_only(self): + try: + #第一次进入 之后update不进入 + if self.cache is None: + self.cache = MyCache(None) + else: + self.cache.open(None) + self.cache._initDepCache() + except Exception as e: + logging.error(e) + def _check_self_upgrade(self,cache): need_upgrade = False diff --git a/backend/SystemUpdater/UpdateManagerDbus.py b/backend/SystemUpdater/UpdateManagerDbus.py index 34f1843..541d03b 100755 --- a/backend/SystemUpdater/UpdateManagerDbus.py +++ b/backend/SystemUpdater/UpdateManagerDbus.py @@ -894,7 +894,13 @@ class UpdateManagerDbusController(dbus.service.Object): @dbus.service.signal(UPDATER_DBUS_INTERFACE) def ChangeUpgradePolicy(self): logging.info(COLORLOG_PREFIX + "Emitting" + COLORLOG_SUFFIX +" ChangeUpgradePolicy") - + + #下载安装前的状态检查信号 + @dbus.service.signal(UPDATER_DBUS_INTERFACE,signature='bs') + def InstallDetectStatus(self, success,error_code=''): + logging.info(COLORLOG_PREFIX + "Emitting"+ COLORLOG_SUFFIX + " InstallDetectStatus success = %r , error_code = %s",\ + success,error_code) + WRITABLE_PROPERTIES = () # pylint: disable-msg=C0103,C0322 diff --git a/backend/SystemUpdater/backend/__init__.py b/backend/SystemUpdater/backend/__init__.py index 027ec2a..0ea24b7 100644 --- a/backend/SystemUpdater/backend/__init__.py +++ b/backend/SystemUpdater/backend/__init__.py @@ -286,7 +286,7 @@ class InstallBackend(): self.window_main.check_conifg_aptdeamon() self.update() except UpdateBaseError as excep: - self._action_done(self.action,True,False,excep.header,excep.desc) + self._action_done(self.action,True,False,excep.header,excep.desc,excep.code) except UpdateProgressExit as excep: pass except Exception as e: @@ -521,18 +521,23 @@ class InstallBackend(): logging.error("Package("+pkg+") "+ str(e)) return [],[] - #调用aptdeamon结束之后处理的地方 不管是出错还是正常都在此处理 - def _action_done(self, action, is_cancelled,success, error_string,error_desc): - #后端的状态 到空闲状态 - self.window_main.now_working = self.ACTION_DEFUALT_STATUS + def _send_error_code(self,error_code): + if error_code == ERROR_NOT_DISK_SPACE: + self.window_main.dbusController.InstallDetectStatus(False,error_code) + #调用aptdeamon结束之后处理的地方 不管是出错还是正常都在此处理 + def _action_done(self, action, is_cancelled,success, error_string,error_desc,error_code=''): + #后端的状态 到空闲状态 + self.window_main.now_working = self.ACTION_DEFUALT_STATUS + #升级完成后走的分支 if action == self.ACTION_INSTALL: #记录这个过程中是否关机 self.window_main.configs.setValue("SystemStatus","abnormal_reboot",str(False),True) #解锁 禁止关机 unLockedEnableShutdown() - + self._send_error_code(error_code) + #单包安装模式 单独处理 目前 更新配置包和升级本身使用 if self.action_mode == self.MODE_INSTALL_SINGLE: if success: @@ -673,27 +678,28 @@ class InstallBackend(): self.window_main.dbusController.UpdateDownloadFinished(success,self.now_upgrade.upgrade_content,error_string,error_desc) - elif action == self.ACTION_UPDATE: - if success == False and ERROR_UPDATE_KEY_SIGNATURES in self.aptd_base.error_details: - error_desc = _("Check your source public key signature") - #网络认证错误 - elif success == False and 'does the network require authentication?' in self.aptd_base.error_details: - error_desc = _("Check if your network requires authentication?") + elif action == self.ACTION_UPDATE and self.action_mode == self.MODE_UPDATE_ALL: + if success == False: + threading_emulate = threading.Thread(target=self.emulate_update) + threading_emulate.start() + + if ERROR_UPDATE_KEY_SIGNATURES in self.aptd_base.error_details: + error_desc = get_error_description_from_enum(ERROR_UPDATE_KEY_SIGNATURES) + elif ERROR_UPDATE_NET_AUTHENTICATION in self.aptd_base.error_details: + error_desc = get_error_description_from_enum(ERROR_UPDATE_NET_AUTHENTICATION) + elif ERROR_UPDATE_NOTREAD_SOURCES in self.aptd_base.error_details: + error_desc = get_error_description_from_enum(ERROR_UPDATE_NOTREAD_SOURCES) - if success and self.action_mode == self.MODE_UPDATE_ALL: + if success: #开始生成列表 self.window_main.start_available() else: self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string+','+error_desc,error_desc) - if self.action_mode == self.MODE_UPDATE_ALL: - #记录本次更新时间插入数据库 - self.window_main.sqlite3_server.insert_into_display("check_time",get_east_8_time()) - - if success == False and self.action_mode == self.MODE_UPDATE_ALL: - threading_emulate = threading.Thread(target=self.emulate_update) - threading_emulate.start() + self.window_main.sqlite3_server.insert_into_display("check_time",get_east_8_time()) + elif action == self.ACTION_UPDATE and self.action_mode == self.MODE_UPDATE_CACHE: + self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string+','+error_desc,error_desc) elif action == self.ACTION_FIX_BROKEN: self.window_main.dbusController.FixBrokenStatusChanged(True,success,100,'',error_string,error_desc) logging.warning("fix broken packages is complete...") diff --git a/backend/interface.md b/backend/interface.md index abf739b..c7536ee 100755 --- a/backend/interface.md +++ b/backend/interface.md @@ -520,6 +520,27 @@ +#### InstallDetectStatus + +- `介绍:`下载安装前的状态检查 + +- `出参`: `b:`检查出错时为`False`,没有错误`success`,`s:`产生错误的码 + +- 错误码示例: + + ```python + ERROR_NOT_DISK_SPACE = "error-not-disk-space" + ``` + +- `示例:` + + ```sh + #表示出现磁盘已满的错误z + InstallDetectStatus success = False , error_code = "error-not-disk-space" + ``` + + + diff --git a/backend/kylin-system-updater b/backend/kylin-system-updater index 206a5b2..98d8999 100755 --- a/backend/kylin-system-updater +++ b/backend/kylin-system-updater @@ -85,18 +85,15 @@ if __name__ == "__main__": logging.info('kylin-system-updater(lang:%s) starting ...',os.environ["LANGUAGE"]) - try: - app = UpdateManager(options) + app = UpdateManager(options) - #当出现安装过程中异常的重启时 开机直接进行修复操作 - if app.configs.getWithDefault("ConfigPkgStatus", "check_frontend_pkg", False) == True: - app.configs.setValue("ConfigPkgStatus","check_frontend_pkg",str(False),True) - app.check_frontend_pkg() + #当出现安装过程中异常的重启时 开机直接进行修复操作 + if app.configs.getWithDefault("ConfigPkgStatus", "check_frontend_pkg", False) == True: + app.configs.setValue("ConfigPkgStatus","check_frontend_pkg",str(False),True) + app.check_frontend_pkg() - #当出现安装过程中异常的重启时 开机直接进行修复操作 - if app.configs.getWithDefault("SystemStatus", "abnormal_reboot", False) == True: - app.start_update() + #当出现安装过程中异常的重启时 开机直接进行修复操作 + if app.configs.getWithDefault("SystemStatus", "abnormal_reboot", False) == True: + app.start_update() - app.run() - except Exception as e: - logging.error(e) \ No newline at end of file + app.run() \ No newline at end of file diff --git a/backend/po/zh_CN.po b/backend/po/zh_CN.po index 6b587ca..3e1e070 100644 --- a/backend/po/zh_CN.po +++ b/backend/po/zh_CN.po @@ -2625,6 +2625,9 @@ msgstr "磁盘空间不足,请清理磁盘后进行升级更新" msgid "Please check your network connection and retry." msgstr "请检查您的网络连接后再试。" +msgid "Please check your source list and retry." +msgstr "请检查您的源列表后再试。" + msgid "Checking network connection" msgstr "检查网络连接中" From 98aa64840fd3532fdc4dd633aab9fe6fa5b1bc5b Mon Sep 17 00:00:00 2001 From: Xueyi Luo Date: Mon, 13 Jun 2022 14:15:54 +0800 Subject: [PATCH 04/13] =?UTF-8?q?=E5=A2=9E=E5=8A=A0upload=5Fupgrade=5Flog?= =?UTF-8?q?=EF=BC=8C=E6=98=AF=E5=90=A6=E5=BC=80=E5=90=AF=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/Core/DataAcquisition.py | 41 +++++++++++-------- backend/SystemUpdater/Core/Database.py | 17 +++++--- backend/SystemUpdater/UpdateManager.py | 6 +-- backend/SystemUpdater/UpdateManagerDbus.py | 7 +++- backend/data/system-updater.conf | 1 + 5 files changed, 45 insertions(+), 27 deletions(-) diff --git a/backend/SystemUpdater/Core/DataAcquisition.py b/backend/SystemUpdater/Core/DataAcquisition.py index 57840b1..af5226c 100644 --- a/backend/SystemUpdater/Core/DataAcquisition.py +++ b/backend/SystemUpdater/Core/DataAcquisition.py @@ -104,7 +104,7 @@ class UpdateMsgCollector(): self.upgrade_list = [] self.waitSendList = [] self.cache = None - + self.Send_log = False self.updateManager = manager # 转换 & 加密 self.convertor = FormatConvert(self) @@ -189,22 +189,23 @@ class UpdateMsgCollector(): logging.error(e) def Upgrade_Process_Msg(self, action, dict_msg = {}): - tmp_dict = {} - tmp_dict.update(dict_msg) - try: - self.UpdateInfos.update({"step":self.action_map.get(action, "")}) - if self.upgrade_mode == self.MODE_INSTALL_SYSTEM: - self.UpdateInfos.update({"appname":"Upgrade System"}) - tmp_dict.update(self.UpdateInfos) - 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() + if self.Send_log == True: + tmp_dict = {} + tmp_dict.update(dict_msg) + try: + self.UpdateInfos.update({"step":self.action_map.get(action, "")}) + if self.upgrade_mode == self.MODE_INSTALL_SYSTEM: + self.UpdateInfos.update({"appname":"Upgrade System"}) + tmp_dict.update(self.UpdateInfos) + 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() def make_background_version(self,pkg): if pkg.is_installed == True: @@ -217,6 +218,9 @@ class UpdateMsgCollector(): self.UploadMessage = {} self.PackageInfo = {} self.UpdateInfos = {} + + def _set_Send_log(self, flag): + self.Send_log = flag class FormatConvert(): def __init__(self, DataCollector): @@ -549,7 +553,8 @@ class PHPServer(threading.Thread): if os.path.isfile(log_file_gzip): os.remove(log_file_gzip) -def PHPSeverSend(_appname="", _appversion="", _statue="", _errorcode=""): +def PHPSeverSend(_send_log = False, _appname="", _appversion="", _statue="", _errorcode=""): + if _send_log == True: send_thread = PHPServer() send_thread.get_values(_appname=_appname, _appversion=_appversion, _state=_statue, _errorcode=_errorcode) send_thread.start() diff --git a/backend/SystemUpdater/Core/Database.py b/backend/SystemUpdater/Core/Database.py index b1e0671..baa4947 100644 --- a/backend/SystemUpdater/Core/Database.py +++ b/backend/SystemUpdater/Core/Database.py @@ -29,7 +29,14 @@ class Sqlite3Server(object): # uncoverable配置文件 self.ucconfigs = UpgradeConfig(datadir = "/etc/kylin-version", name = "kylin-system-version.conf") self._system_version_config() - + + #发送日志 + self.upload_upgrade_log = self.window_main.configs.getWithDefault("SystemStatus", "upload_upgrade_log", False) + if self.upload_upgrade_log == False: + logging.warning("Log sending is not enabled, and the server will not receive your update records .") + else: + self.window_main.collector._set_Send_log(self.upload_upgrade_log) + # 初始化连接数据库 def init_sqlit(self): logging.info(_("Initialize the connection to the database ...")) @@ -211,7 +218,7 @@ class Sqlite3Server(object): self._refresh_system_version(version) #FIXME: 临时方案 PHP - PHPSeverSend(_appname=pkgname, _appversion=pkgversion, _statue=status, _errorcode="10000100") + PHPSeverSend(_send_log = self.upload_upgrade_log, _appname=pkgname, _appversion=pkgversion, _statue=status, _errorcode="10000100") elif pkg_list: # 单包更新 # 获取单包数据插入数据库 pkgname = pkg_list.pop(0) @@ -261,7 +268,7 @@ class Sqlite3Server(object): # 软件商店获取中文名 appname_cn = self.get_cn_appname(str(pkgname)) #FIXME: 临时方案 PHP - PHPSeverSend(_appname=pkgname, _appversion=pkgversion, _statue=status, _errorcode="10000100") + PHPSeverSend(_send_log = self.upload_upgrade_log, _appname=pkgname, _appversion=pkgversion, _statue=status, _errorcode="10000100") try: self.insert_into_updateinfo(pkgname, pkgversion, pkgdescription, timestr, status, "1", errstr, appname_cn) # FIXME: 发送插入数据库成功的信号local_upgrade_list @@ -314,7 +321,7 @@ class Sqlite3Server(object): self.insert_into_updateinfo(str(i), pkgversion, pkgdescription, timestr, status, "1", errstr, appname_cn) self.window_main.dbusController.UpdateSqlitSingle(str(i), timestr) #FIXME: 临时方案 PHP - PHPSeverSend(_appname=pkg.name, _appversion=pkgversion, _statue=status, _errorcode="10000100") + PHPSeverSend(_send_log = self.upload_upgrade_log, _appname=pkg.name, _appversion=pkgversion, _statue=status, _errorcode="10000100") # insert group deb next for i in pkg_group: # FIXME: 获取组信息 @@ -336,7 +343,7 @@ class Sqlite3Server(object): InstallInfos.update({"errorCode":str(error_string+" "+error_desc)}) self.window_main.collector.Upgrade_Process_Msg("finish-install", InstallInfos.copy()) #FIXME: 临时方案 PHP - PHPSeverSend(_appname=i, _appversion=pkgversion, _statue=status, _errorcode="10000100") + PHPSeverSend(_send_log = self.upload_upgrade_log, _appname=i, _appversion=pkgversion, _statue=status, _errorcode="10000100") try: self.insert_into_updateinfo(str(i), pkgversion, pkgdescription, timestr, status, "1", errstr, appname_cn) self.window_main.dbusController.UpdateSqlitSingle(str(i), timestr) diff --git a/backend/SystemUpdater/UpdateManager.py b/backend/SystemUpdater/UpdateManager.py index 2ceeee9..136d1a9 100644 --- a/backend/SystemUpdater/UpdateManager.py +++ b/backend/SystemUpdater/UpdateManager.py @@ -54,15 +54,15 @@ class UpdateManager(): self.configs = UpgradeConfig("/var/lib/kylin-system-updater/") self.uuconfigs = UpgradeConfig(datadir = "/var/lib/unattended-upgrades/", name = "unattended-upgrades-policy.conf") + #数据采集器 + self.collector = UpdateMsgCollector(self) + #连接数据库 self.sqlite3_server = Sqlite3Server(self) #是否重启apt self.init_config_aptdeamon = False - #数据采集器 - self.collector = UpdateMsgCollector(self) - #后台aptdaemon的语言环境 self.aptdaemonLang = os.environ["LANGUAGE"] diff --git a/backend/SystemUpdater/UpdateManagerDbus.py b/backend/SystemUpdater/UpdateManagerDbus.py index 34f1843..7ea7369 100755 --- a/backend/SystemUpdater/UpdateManagerDbus.py +++ b/backend/SystemUpdater/UpdateManagerDbus.py @@ -1006,6 +1006,8 @@ class UpdateManagerDbusController(dbus.service.Object): self.parent.configs.setValue("InstallMode","shutdown_install",str(bool(value))) elif name == "P2pBootstrap": self.parent.apt_p2p_config.set_bootstrap(str(value)) + elif name == "UploadUpgradeLog": + self.parent.configs.setValue("SystemStatus","upload_upgrade_log",str(bool(value))) else: raise dbus.exceptions.DBusException("Unknown or read only " "property: %s" % name) @@ -1020,7 +1022,10 @@ class UpdateManagerDbusController(dbus.service.Object): "ShutdownInstall": dbus.Boolean( self.parent.configs.getWithDefault("InstallMode", "shutdown_install", False)), - "P2pBootstrap": dbus.String(self.parent.apt_p2p_config.get_bootstrap()) + "P2pBootstrap": dbus.String(self.parent.apt_p2p_config.get_bootstrap()), + + "UploadUpgradeLog": dbus.Boolean( + self.parent.configs.getWithDefault("SystemStatus", "upload_upgrade_log", False)) } else: return {} \ No newline at end of file diff --git a/backend/data/system-updater.conf b/backend/data/system-updater.conf index ebfed79..dbf428c 100644 --- a/backend/data/system-updater.conf +++ b/backend/data/system-updater.conf @@ -4,6 +4,7 @@ upgradelist = [SystemStatus] abnormal_reboot = False close_source_filter = False +upload_upgrade_log = False [ConfigPkgStatus] check_resover_remove = False From 1f3aa755a57a0c159f372c26c6b2346081c4fd28 Mon Sep 17 00:00:00 2001 From: wangsong Date: Mon, 13 Jun 2022 15:21:49 +0800 Subject: [PATCH 05/13] =?UTF-8?q?=E5=AF=B9=E6=89=80=E6=9C=89=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E8=BD=AF=E4=BB=B6=E5=8C=85=E7=9A=84=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E9=83=BD=E6=9E=B7=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/InstallBackendAptdaemon.py | 5 +--- backend/SystemUpdater/backend/__init__.py | 28 ++++++++++++------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/backend/SystemUpdater/backend/InstallBackendAptdaemon.py b/backend/SystemUpdater/backend/InstallBackendAptdaemon.py index a9ebb8e..160f9e1 100644 --- a/backend/SystemUpdater/backend/InstallBackendAptdaemon.py +++ b/backend/SystemUpdater/backend/InstallBackendAptdaemon.py @@ -329,10 +329,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 - LockedPreventShutdown() - - #进度安装阶段标志位,使用鉴别是否出现安装过程中强制关闭 之后进行修复使用得 - self.window_main.configs.setValue("SystemStatus","abnormal_reboot",str(True),True) + self._start_install_lock() #只处理从下载切换到安装时出现的网络问题 #当网络波动时下载某些软件包失败时属于异常状态进行重试时 不发送后续进度 等待重试正常是 进行下载安装 diff --git a/backend/SystemUpdater/backend/__init__.py b/backend/SystemUpdater/backend/__init__.py index 0ea24b7..bc0669e 100644 --- a/backend/SystemUpdater/backend/__init__.py +++ b/backend/SystemUpdater/backend/__init__.py @@ -12,7 +12,7 @@ import apt_pkg import json from SystemUpdater.Core.utils import ( unLockedEnableShutdown, - get_broken_details + LockedPreventShutdown ) from SystemUpdater.Core.DataAcquisition import get_east_8_time from apt import Cache @@ -184,8 +184,7 @@ class InstallBackend(): self.now_upgrade,pkgs_install,pkgs_upgrade,pkgs_remove = self._config_to_upgrade() logging.info("ACTION_INSTALL_SHUTDOWN install:%d , upgrade:%d remove:%d",len(pkgs_install),len(pkgs_upgrade),len(pkgs_remove)) - #进度安装阶段标志位,使用鉴别是否出现安装过程中强制关闭 之后进行修复使用得 - self.window_main.configs.setValue("SystemStatus","abnormal_reboot",str(True),True) + # self._start_install_lock() self.commit(self.action,pkgs_install, pkgs_upgrade, pkgs_remove) #计算依赖解决方案 @@ -275,6 +274,7 @@ class InstallBackend(): # self._action_done(self.action,False,False,header,desc) # return # else: + self._start_install_lock() self.purge_packages(partial_upgrade_list) #清空所有下载的文件 @@ -290,13 +290,13 @@ class InstallBackend(): except UpdateProgressExit as excep: pass except Exception as e: - logging.error(e) - + logging.error(e) def start_alone(self,partial_upgrade_list = [],_is_install = False): # 安装本地deb包的接口 if self.action == self.ACTION_INSTALL_DEB: try: + self._start_install_lock() self.install_deb(install_path = partial_upgrade_list, install_force = _is_install) except Exception as e: logging.error(str(e)) @@ -532,10 +532,7 @@ class InstallBackend(): #升级完成后走的分支 if action == self.ACTION_INSTALL: - #记录这个过程中是否关机 - self.window_main.configs.setValue("SystemStatus","abnormal_reboot",str(False),True) - #解锁 禁止关机 - unLockedEnableShutdown() + self._release_install_lock() self._send_error_code(error_code) #单包安装模式 单独处理 目前 更新配置包和升级本身使用 @@ -614,7 +611,7 @@ class InstallBackend(): self.window_main.refresh_cache() elif action == self.ACTION_INSTALL_SHUTDOWN: - self.window_main.configs.setValue("SystemStatus","abnormal_reboot",str(False)) + # self._release_install_lock() #插入数据库 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) @@ -718,15 +715,18 @@ class InstallBackend(): logging.warning("fix incomplete install failed.") elif action == self.ACTION_REMOVE_PACKAGES: + self._release_install_lock() self.window_main.dbusController.PurgePackagesFinished(success,error_string,error_desc) elif action == self.ACTION_INSTALL_DEB: + 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.") error_desc = '' self.window_main.dbusController.InstalldebFinished(success,error_string,error_desc) elif action == self.ACTION_BACKGROUND_UPGRADE: + self._release_install_lock() UpdateMsg = {} if success: status = 'Success' @@ -746,6 +746,14 @@ class InstallBackend(): self.window_main.dbusController.UpdateInstallFinished(success,self.now_upgrade.upgrade_content,error_string,error_desc) + def _start_install_lock(self): + self.window_main.configs.setValue("SystemStatus","abnormal_reboot",str(True)) + LockedPreventShutdown() + + def _release_install_lock(self): + self.window_main.configs.setValue("SystemStatus","abnormal_reboot",str(False)) + unLockedEnableShutdown() + def _message_to_plymouth(self,message): subprocess.call(["/bin/plymouth", "message", "--text", message]) From d0664cb9e0913b7b95151f402a90cffef4520c10 Mon Sep 17 00:00:00 2001 From: wangsong Date: Mon, 13 Jun 2022 15:48:26 +0800 Subject: [PATCH 06/13] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E4=B9=8B=E5=90=8E=E6=A3=80=E6=9F=A5=E5=89=8D=E7=AB=AF=E8=BD=AF?= =?UTF-8?q?=E4=BB=B6=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/kylin-system-updater | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/kylin-system-updater b/backend/kylin-system-updater index 98d8999..021f8a4 100755 --- a/backend/kylin-system-updater +++ b/backend/kylin-system-updater @@ -88,9 +88,9 @@ if __name__ == "__main__": app = UpdateManager(options) #当出现安装过程中异常的重启时 开机直接进行修复操作 - if app.configs.getWithDefault("ConfigPkgStatus", "check_frontend_pkg", False) == True: - app.configs.setValue("ConfigPkgStatus","check_frontend_pkg",str(False),True) - app.check_frontend_pkg() + # if app.configs.getWithDefault("ConfigPkgStatus", "check_frontend_pkg", False) == True: + # app.configs.setValue("ConfigPkgStatus","check_frontend_pkg",str(False),True) + # app.check_frontend_pkg() #当出现安装过程中异常的重启时 开机直接进行修复操作 if app.configs.getWithDefault("SystemStatus", "abnormal_reboot", False) == True: From caf0670ddba296883e5b5723c91cc2e1f19ac7ce Mon Sep 17 00:00:00 2001 From: wangsong Date: Mon, 13 Jun 2022 16:24:12 +0800 Subject: [PATCH 07/13] =?UTF-8?q?=E5=AF=B9=E5=85=B3=E6=9C=BA=E9=94=81?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E5=BD=92=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/Core/utils.py | 37 ---------------- backend/SystemUpdater/UpdateManager.py | 42 +++++++++++++++++++ backend/SystemUpdater/UpdateManagerDbus.py | 8 +--- .../backend/InstallBackendAptdaemon.py | 7 +--- backend/SystemUpdater/backend/__init__.py | 8 +--- 5 files changed, 48 insertions(+), 54 deletions(-) diff --git a/backend/SystemUpdater/Core/utils.py b/backend/SystemUpdater/Core/utils.py index 8395409..fbbaabc 100644 --- a/backend/SystemUpdater/Core/utils.py +++ b/backend/SystemUpdater/Core/utils.py @@ -660,43 +660,6 @@ def get_package_label(pkg): name = getattr(pkg.candidate, "summary", "") return capitalize_first_word(name) -#安装时禁止关机 进行加锁 -def LockedPreventShutdown(): - global inhibit_lock - """ - Send a dbus signal to logind to not suspend the system, it will be - released when the return value drops out of scope - """ - try: - from gi.repository import Gio, GLib - connection = Gio.bus_get_sync(Gio.BusType.SYSTEM) - - var, fdlist = connection.call_with_unix_fd_list_sync( - 'org.freedesktop.login1', '/org/freedesktop/login1', - 'org.freedesktop.login1.Manager', 'Inhibit', - GLib.Variant('(ssss)', - ('shutdown', - 'Kylin System Updater', 'Installing Packages', - 'block')), - None, 0, -1, None, None) - inhibit_lock = Gio.UnixInputStream(fd=fdlist.steal_fds()[var[0]]) - logging.info("Shutdown Has been locked...") - except Exception as e: - logging.error(e) - -#解锁禁止关机 -def unLockedEnableShutdown(): - global inhibit_lock - try: - if inhibit_lock != None: - inhibit_lock.close() - logging.info("Shutdown Has been unlocked...") - inhibit_lock == None - else: - logging.info("Not locked and Quitting ...") - except Exception as e: - logging.error("unlock failed." + str(e)) - # 查看uu进程是否需要kill def kill_process(path): try: diff --git a/backend/SystemUpdater/UpdateManager.py b/backend/SystemUpdater/UpdateManager.py index a786c58..4264a1e 100644 --- a/backend/SystemUpdater/UpdateManager.py +++ b/backend/SystemUpdater/UpdateManager.py @@ -77,6 +77,8 @@ class UpdateManager(): self.install_mode = UpdateInstallMode(self) self.apt_p2p_config = AptP2pConfigManager() + + self.inhibit_shutdown = InhibitShutdownLock() self._reload_options_config() #加载Cache @@ -888,6 +890,46 @@ class AptP2pConfigManager(): self.p2pConfigs.setValue("apt_p2p_Khashmir","BOOTSTRAP",str(value)) +class InhibitShutdownLock(): + + def __init__(self): + self.inhibit_lock = None + + #安装时禁止关机 进行加锁 + def lock(self): + """ + Send a dbus signal to logind to not suspend the system, it will be + released when the return value drops out of scope + """ + try: + from gi.repository import Gio, GLib + connection = Gio.bus_get_sync(Gio.BusType.SYSTEM) + + var, fdlist = connection.call_with_unix_fd_list_sync( + 'org.freedesktop.login1', '/org/freedesktop/login1', + 'org.freedesktop.login1.Manager', 'Inhibit', + GLib.Variant('(ssss)', + ('shutdown', + 'Kylin System Updater', 'Installing Packages', + 'block')), + None, 0, -1, None, None) + self.inhibit_lock = Gio.UnixInputStream(fd=fdlist.steal_fds()[var[0]]) + logging.info("Shutdown Has been locked...") + except Exception as e: + logging.error(e) + + #解锁禁止关机 + def unlock(self): + try: + if self.inhibit_lock != None: + self.inhibit_lock.close() + self.inhibit_lock == None + logging.info("Shutdown Has been unlocked...") + else: + logging.info("Not locked and Quitting ...") + except Exception as e: + logging.error("unlock failed." + str(e)) + class UpdateInstallMode(): def __init__(self,parent): self.parent = parent diff --git a/backend/SystemUpdater/UpdateManagerDbus.py b/backend/SystemUpdater/UpdateManagerDbus.py index f27ecb1..463e8fa 100755 --- a/backend/SystemUpdater/UpdateManagerDbus.py +++ b/backend/SystemUpdater/UpdateManagerDbus.py @@ -11,7 +11,7 @@ from .Core.loop import mainloop from .Core.errors import * from .Core.enums import * from .Core.utils import humanize_size -from SystemUpdater.Core.utils import unLockedEnableShutdown,get_proc_from_dbus_name,PolicyKit_Authority +from SystemUpdater.Core.utils import get_proc_from_dbus_name,PolicyKit_Authority import locale from xml.etree import ElementTree from .Core.MyCache import MyCache @@ -127,11 +127,7 @@ class UpdateManagerDbusController(dbus.service.Object): """Request a shutdown of the daemon.""" #如果在下载就请求 取消 self.CancelDownload() - try: - #尝试接触 关闭枷锁 - unLockedEnableShutdown() - except: - logging.error("File lock release failure") + self.window_main.inhibit_shutdown.unlock() logging.info("Quitting was requested") logging.debug("Quitting main loop...") mainloop.quit() diff --git a/backend/SystemUpdater/backend/InstallBackendAptdaemon.py b/backend/SystemUpdater/backend/InstallBackendAptdaemon.py index 160f9e1..51021ca 100644 --- a/backend/SystemUpdater/backend/InstallBackendAptdaemon.py +++ b/backend/SystemUpdater/backend/InstallBackendAptdaemon.py @@ -21,7 +21,6 @@ import dbus,time from gi.repository import GLib import os from importlib import reload -from SystemUpdater.Core.utils import unLockedEnableShutdown,LockedPreventShutdown # 超时检测 秒单位 UPDATER_IDLE_CHECK_INTERVAL = 5 @@ -30,7 +29,6 @@ INSTALL_IDLE_TIMEOUT = 20 * 60 #更新超时检查 5分钟 UPDATE_IDLE_TIMEOUT = 5 * 60 - class InstallBackendAptdaemon(InstallBackend): """Makes use of aptdaemon to refresh the cache and to install updates.""" @@ -99,14 +97,13 @@ class InstallBackendAptdaemon(InstallBackend): if (time.time() - timestamp > INSTALL_IDLE_TIMEOUT and self.on_install_stage == True): logging.error("Quitting due to inactivity(%s)",self.aptd_base.details) - if self.action == self.ACTION_INSTALL_SHUTDOWN: #关机安装模式 解除禁止关机锁 - self.window_maininhibit_lock.close() + self.window_main.inhibit_lock.close() logging.info("Installtion timeout to exit Due to inactivity and Releasing the shutdown lock...") else: #超时只单独进行解锁关机 - unLockedEnableShutdown() + self.window_main.inhibit_shutdown.unlock() # self._action_done(self.ACTION_INSTALL, # is_cancelled=False, success=False, # #FIXME: 安装超时退出 diff --git a/backend/SystemUpdater/backend/__init__.py b/backend/SystemUpdater/backend/__init__.py index bc0669e..d709e93 100644 --- a/backend/SystemUpdater/backend/__init__.py +++ b/backend/SystemUpdater/backend/__init__.py @@ -10,10 +10,6 @@ from gettext import gettext as _ import apt import apt_pkg import json -from SystemUpdater.Core.utils import ( - unLockedEnableShutdown, - LockedPreventShutdown -) from SystemUpdater.Core.DataAcquisition import get_east_8_time from apt import Cache import subprocess @@ -748,11 +744,11 @@ class InstallBackend(): def _start_install_lock(self): self.window_main.configs.setValue("SystemStatus","abnormal_reboot",str(True)) - LockedPreventShutdown() + self.window_main.inhibit_shutdown.lock() def _release_install_lock(self): self.window_main.configs.setValue("SystemStatus","abnormal_reboot",str(False)) - unLockedEnableShutdown() + self.window_main.inhibit_shutdown.unlock() def _message_to_plymouth(self,message): subprocess.call(["/bin/plymouth", "message", "--text", message]) From 870b31f79e09109a057150ef31d8faf1c19fa59e Mon Sep 17 00:00:00 2001 From: wangsong Date: Tue, 14 Jun 2022 10:05:22 +0800 Subject: [PATCH 08/13] =?UTF-8?q?=E5=AF=B9=E4=BC=98=E5=85=88=E5=8D=87?= =?UTF-8?q?=E7=BA=A7=E5=8A=9F=E8=83=BD=E5=81=9A=E5=87=BA=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=94=B9=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/UpdateManager.py | 68 ++++------------------- backend/SystemUpdater/backend/__init__.py | 14 ++--- 2 files changed, 17 insertions(+), 65 deletions(-) diff --git a/backend/SystemUpdater/UpdateManager.py b/backend/SystemUpdater/UpdateManager.py index 4264a1e..10c2230 100644 --- a/backend/SystemUpdater/UpdateManager.py +++ b/backend/SystemUpdater/UpdateManager.py @@ -299,72 +299,26 @@ class UpdateManager(): data = f.read() important_list = data.split() - #self - if self.BACKEND_PKG_NAME in cache: - self_pkg = cache[self.BACKEND_PKG_NAME] - #是否安装 - if self_pkg.is_installed and self_pkg.is_upgradable: - logging.info("Check: Updater(%s) start upgrading From %s to %s...",self.BACKEND_PKG_NAME,\ - self_pkg.installed.source_version,self_pkg.candidate.source_version) - if self.BACKEND_PKG_NAME in important_list: - self_pkg.mark_install() - need_upgrade = True - else: - logging.info("Check: Updater(%s:%s) No need to upgrade...",self.BACKEND_PKG_NAME,self_pkg.installed.source_version) - else: - logging.info("Check: Updater(%s:%s) No need to upgrade...",self.BACKEND_PKG_NAME,self_pkg.installed.source_version) - else: - #没有在cache中就认为不需要升级 - logging.error("Check: Updater(%s) The upgrade package is not in Cache...",self.BACKEND_PKG_NAME) - - #Aptdaemon - if self.APTD_PKG_NAME in cache: - self_pkg = cache[self.APTD_PKG_NAME] - #是否安装 - if self_pkg.is_installed and self_pkg.is_upgradable: - logging.info("Check: Aptdaemon(%s) start upgrading From %s to %s...",self.APTD_PKG_NAME,\ - self_pkg.installed.source_version,self_pkg.candidate.source_version) - if self.BACKEND_PKG_NAME in important_list: - self_pkg.mark_install() - need_upgrade = True - else: - logging.info("Check: Aptdaemon(%s:%s) No need to upgrade...",self.APTD_PKG_NAME,self_pkg.installed.source_version) - else: - logging.info("Check: Aptdaemon(%s:%s) No need to upgrade...",self.APTD_PKG_NAME,self_pkg.installed.source_version) - else: - #没有在cache中就认为不需要升级 - logging.error("Check: Aptdaemon(%s) The upgrade package is not in Cache...",self.APTD_PKG_NAME) - - #控制面板前端包的检查升级 - if self.FRONTEND_PKG_NAME in cache: - self_pkg = cache[self.FRONTEND_PKG_NAME] - - if self_pkg.is_installed: - #是否可升级 - if self_pkg.is_upgradable: - logging.info("Check: Frontend(%s) start upgrading From %s to %s...",self.FRONTEND_PKG_NAME,\ + for pkg_name in (self.BACKEND_PKG_NAME,self.APTD_PKG_NAME,self.FRONTEND_PKG_NAME): + if pkg_name in cache: + self_pkg = cache[pkg_name] + if self_pkg.is_installed and self_pkg.is_upgradable: + logging.info("Check: Updater(%s) start upgrading From %s to %s...",pkg_name,\ self_pkg.installed.source_version,self_pkg.candidate.source_version) - if self.FRONTEND_PKG_NAME in important_list: + if pkg_name in important_list: self_pkg.mark_install() need_upgrade = True else: - logging.info("Check: Frontend(%s:%s) No need to upgrade...",self.FRONTEND_PKG_NAME,self_pkg.installed.source_version) + logging.info("Check: (%s:%s) No need to upgrade...",pkg_name,self_pkg.installed.source_version) else: - logging.info("Check: Frontend(%s:%s) No need to upgrade...",self.FRONTEND_PKG_NAME,self_pkg.installed.source_version) + logging.info("Check: (%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: Frontend(%s) start new installing...",self.FRONTEND_PKG_NAME) - self_pkg.mark_install() - need_upgrade = True - else: - #没有在cache中就认为不需要升级 - logging.error("Check: Frontend(%s) The upgrade package is not in Cache...",self.FRONTEND_PKG_NAME) - + logging.error("Check: (%s) The upgrade package is not in Cache...",pkg_name) + + #config包 if self.GROUPS_PKG_NAME in cache: pkg_json = cache[self.GROUPS_PKG_NAME] - #是否安装 if pkg_json.is_installed: - #是否可升级 if pkg_json.is_upgradable: self.dbusController.UpdateDetectStatusChanged(95,_("Group configuration being updated")) logging.info("Check: groups JSON ConfigPkgs(%s) start upgrading From %s to %s...",self.GROUPS_PKG_NAME,\ diff --git a/backend/SystemUpdater/backend/__init__.py b/backend/SystemUpdater/backend/__init__.py index d709e93..05359b6 100644 --- a/backend/SystemUpdater/backend/__init__.py +++ b/backend/SystemUpdater/backend/__init__.py @@ -3,21 +3,19 @@ """Integration of package managers into SystemUpdater""" -import logging import os -from gettext import gettext as _ - import apt import apt_pkg import json -from SystemUpdater.Core.DataAcquisition import get_east_8_time -from apt import Cache +import logging import subprocess -from SystemUpdater.Core.UpdateList import LocalUpgradeDataList -from SystemUpdater.Core.errors import * import threading +from apt import Cache +from gettext import gettext as _ from SystemUpdater.Core.errors import * from SystemUpdater.Core.enums import * +from SystemUpdater.Core.DataAcquisition import get_east_8_time +from SystemUpdater.Core.UpdateList import LocalUpgradeDataList from SystemUpdater.Core.DistUpgradeCache import NotEnoughFreeSpaceError class NowUpgradeMeta: @@ -39,7 +37,7 @@ class NowUpgradeMeta: self.single_pkgs = single_pkgs self.version_upgrade = version_upgrade self.need_retry = need_retry - self.upgrade_content = upgrade_groups + single_pkgs + self.upgrade_content = self.upgrade_groups + self.single_pkgs #获取当前升级的升级列表 def _make_groups_list(self,upgrade_data,_upgrade_mode,partial_upgrade_list): From 59c7867a34c7e629e214b6baecd864eda831c231 Mon Sep 17 00:00:00 2001 From: Xueyi Luo Date: Tue, 14 Jun 2022 10:47:45 +0800 Subject: [PATCH 09/13] version:2.0.5.1 --- debian/changelog | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/debian/changelog b/debian/changelog index 15f1901..7e770cd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,16 @@ +kylin-system-updater (2.0.5.1) v101; urgency=medium + + * BUG: # 121890 【更新升级】部分应用更新完成后,在“查看历史更新”中查不到数据 + # 123985 【在线更新】系统存在可选更新且在设置中开启了自动下载和安装更新,系统到达定时下载的时间未进行自动下载 + # 110370 【更新升级】 【自动更新】出现一次,自动更新安装服务,将本地安装包地址检测成源地址导致安装报错 + * 需求号: # 12722 【更新升级】系统更新全流程监控 + # 12720 【更新升级】升级环境检测 + # 12721 【更新升级】系统版本号体系 + * 其他改动说明: 无 + * 其他改动影响域:系统更新 + + -- luoxueyi Mon, 13 Jun 2022 16:25:38 +0800 + kylin-system-updater (2.0.4.3) v101; urgency=medium * BUG: # 118021 【在线更新】中文环境下,安装和卸载应用时弹出授权界面,提示内容未汉化 From 3b42b538174cfb4de8b652cfbd1039fcfc8216b1 Mon Sep 17 00:00:00 2001 From: wangsong Date: Tue, 14 Jun 2022 10:58:29 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=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 | 8 ++++++-- backend/SystemUpdater/UpdateManagerDbus.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/backend/SystemUpdater/UpdateManager.py b/backend/SystemUpdater/UpdateManager.py index 10c2230..c759cfd 100644 --- a/backend/SystemUpdater/UpdateManager.py +++ b/backend/SystemUpdater/UpdateManager.py @@ -2,6 +2,7 @@ # -*- Mode: Python; indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*- import os import subprocess +from unicodedata import lookup from apt import Cache import apt_pkg import sys @@ -306,8 +307,11 @@ class UpdateManager(): logging.info("Check: Updater(%s) start upgrading From %s to %s...",pkg_name,\ self_pkg.installed.source_version,self_pkg.candidate.source_version) if pkg_name in important_list: - self_pkg.mark_install() - need_upgrade = True + try: + self_pkg.mark_install() + need_upgrade = True + except SystemError: + logging.error("Check: mark %s to upgrade Failed...",pkg_name) else: logging.info("Check: (%s:%s) No need to upgrade...",pkg_name,self_pkg.installed.source_version) else: diff --git a/backend/SystemUpdater/UpdateManagerDbus.py b/backend/SystemUpdater/UpdateManagerDbus.py index 463e8fa..344fdf8 100755 --- a/backend/SystemUpdater/UpdateManagerDbus.py +++ b/backend/SystemUpdater/UpdateManagerDbus.py @@ -127,7 +127,7 @@ class UpdateManagerDbusController(dbus.service.Object): """Request a shutdown of the daemon.""" #如果在下载就请求 取消 self.CancelDownload() - self.window_main.inhibit_shutdown.unlock() + self.parent.inhibit_shutdown.unlock() logging.info("Quitting was requested") logging.debug("Quitting main loop...") mainloop.quit() From f752ae8ba03e21befd76c0523e3918a186aeb543 Mon Sep 17 00:00:00 2001 From: wangsong Date: Tue, 14 Jun 2022 10:59:10 +0800 Subject: [PATCH 11/13] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A8=A1=E6=8B=9F?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/UpdateManager.py | 47 ++++++++++++++++++++--- backend/SystemUpdater/backend/__init__.py | 23 ----------- 2 files changed, 41 insertions(+), 29 deletions(-) diff --git a/backend/SystemUpdater/UpdateManager.py b/backend/SystemUpdater/UpdateManager.py index c759cfd..224cb88 100644 --- a/backend/SystemUpdater/UpdateManager.py +++ b/backend/SystemUpdater/UpdateManager.py @@ -1,9 +1,6 @@ # UpdateManager.py # -*- Mode: Python; indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*- import os -import subprocess -from unicodedata import lookup -from apt import Cache import apt_pkg import sys import time @@ -12,10 +9,16 @@ import dbus import logging import dbus.service import json +import threading +import subprocess +from apt import Cache +from gettext import gettext as _ from apt.debfile import DebPackage from dbus.mainloop.glib import DBusGMainLoop DBusGMainLoop(set_as_default=True) +from .Core.errors import * +from .Core.enums import * from .Core.MyCache import MyCache from .UpdateManagerDbus import UpdateManagerDbusController,UPDATER_DBUS_INTERFACE,UPDATER_DBUS_PATH,UPDATER_DBUS_SERVICE from .Core.UpdateList import UpdateList @@ -24,14 +27,12 @@ from .Core.Database import Sqlite3Server from .Core.loop import mainloop from .Core.DataAcquisition import UpdateMsgCollector -from gettext import gettext as _ from SystemUpdater.Core.UpdaterConfigParser import UpgradeConfig from SystemUpdater.Core.utils import get_broken_details,kill_process from SystemUpdater.Core.DpkgInstallProgress import LogInstallProgress from SystemUpdater.Core.utils import deb_verify,PolicyKit_Authority,get_proc_from_dbus_name -from .Core.errors import * -from .Core.enums import * + class UpdateManager(): BACKEND_PKG_NAME = 'kylin-system-updater' @@ -888,6 +889,40 @@ class InhibitShutdownLock(): except Exception as e: logging.error("unlock failed." + str(e)) +class SimulateUpdateInstall(): + + def __init__(self): + pass + + def emulate_install(self,pkgs): + args = ["apt-get", "install","--simulate"] + args = args + pkgs + + p = subprocess.run(args, stdout=subprocess.PIPE,stderr=subprocess.STDOUT,text=True) + logging.info(str(p.stdout)) + return p.stdout + + def emulate_update(self): + args = ["apt-get", "update"] + + p = subprocess.run(args, stdout=subprocess.PIPE,stderr=subprocess.STDOUT,text=True) + logging.info(str(p.stdout)) + return p.stdout + + def thread_install(self): + threading_emulate = threading.Thread(target=self.emulate_update) + threading_emulate.start() + + def thread_update(self): + threading_emulate = threading.Thread(target=self.emulate_update) + threading_emulate.start() + + def emulate_install_broken(self,pkgs): + self.emulate_install(pkgs) + + + pass + class UpdateInstallMode(): def __init__(self,parent): self.parent = parent diff --git a/backend/SystemUpdater/backend/__init__.py b/backend/SystemUpdater/backend/__init__.py index 05359b6..1492531 100644 --- a/backend/SystemUpdater/backend/__init__.py +++ b/backend/SystemUpdater/backend/__init__.py @@ -250,28 +250,8 @@ class InstallBackend(): self.fix_incomplete() #卸载包 elif self.action == self.ACTION_REMOVE_PACKAGES: - # remove_pkgs = [] - # for pkg in partial_upgrade_list: - # if pkg in self.cache: - # pkg_cache = self.cache[pkg] - # pkg_cache.mark_delete(True, True) - # else: - # #没有在cache中就认为不需要升级 - # logging.error("Check: (%s) The reomve package is not in Cache...",pkg) - - # for pkg_obj in self.cache.get_changes(): - # if pkg_obj.marked_delete: - # remove_pkgs.append(pkg_obj.name) - - # success,header,desc = self.check_essential_pkgs(remove_pkgs) - # if success == False: - # self._action_done(self.action,False,False,header,desc) - # return - # else: self._start_install_lock() self.purge_packages(partial_upgrade_list) - - #清空所有下载的文件 elif self.action == self.ACTION_CLEAN: self.clean() #更新cache @@ -481,13 +461,10 @@ class InstallBackend(): for pkg in pkgs_install + pkgs_upgrade: pkg_string = pkg_string + ' ' + str(pkg) logging.info('Resolver calculation Packages List: '+pkg_string+'\n') - # logging.error('\n' + msg) terminal_msg = self.emulate_calcul_broken(pkgs_install + pkgs_upgrade) logging.error(terminal_msg) raise UpdateBaseError(ERROR_RESOLVER_FAILED, desc= terminal_msg) - # threading_emulate = threading.Thread(target=emulate_calcul_broken,args=(pkgs_install + pkgs_upgrade,)) - # threading_emulate.start() def _emulate_calcul_delete(self,pkg,cache): try: From dd94f1153a52971f4f2af2dcf38c0edfd6200dae Mon Sep 17 00:00:00 2001 From: wangsong Date: Tue, 14 Jun 2022 15:14:26 +0800 Subject: [PATCH 12/13] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=A8=A1=E6=8B=9F?= =?UTF-8?q?=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/UpdateManager.py | 24 ++++++++++++++++------- backend/SystemUpdater/backend/__init__.py | 19 ++++-------------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/backend/SystemUpdater/UpdateManager.py b/backend/SystemUpdater/UpdateManager.py index 224cb88..4d1402a 100644 --- a/backend/SystemUpdater/UpdateManager.py +++ b/backend/SystemUpdater/UpdateManager.py @@ -71,6 +71,7 @@ class UpdateManager(): #失败后重启进行安装的限制次数 目前在自适应升级上面使用 self.retry_limit = self.RETRY_LIMIT_NUM + self.simulate_mode = SimulateTerminal() #光盘源 self.source_info = UpdateSourceInfo() @@ -889,12 +890,13 @@ class InhibitShutdownLock(): except Exception as e: logging.error("unlock failed." + str(e)) -class SimulateUpdateInstall(): - +class SimulateTerminal(): + ZH_UNMET_DEPENDENCIES = '下列软件包有未满足的依赖关系:' + EN_UNMET_DEPENDENCIES = 'The following packages have unmet dependencies:' def __init__(self): pass - def emulate_install(self,pkgs): + def _emulate_install(self,pkgs): args = ["apt-get", "install","--simulate"] args = args + pkgs @@ -910,18 +912,26 @@ class SimulateUpdateInstall(): return p.stdout def thread_install(self): - threading_emulate = threading.Thread(target=self.emulate_update) + threading_emulate = threading.Thread(target=self._emulate_install) threading_emulate.start() def thread_update(self): threading_emulate = threading.Thread(target=self.emulate_update) threading_emulate.start() - def emulate_install_broken(self,pkgs): - self.emulate_install(pkgs) + def dependencies_broken(self,pkgs): + terminal_msg = self._emulate_install(pkgs) + if len(terminal_msg) > 500: + terminal_msg = '' + if self.ZH_UNMET_DEPENDENCIES in terminal_msg: + terminal_msg = '\n' + self.ZH_UNMET_DEPENDENCIES + terminal_msg.split(self.ZH_UNMET_DEPENDENCIES)[1] + elif self.EN_UNMET_DEPENDENCIES in terminal_msg: + terminal_msg = '\n' + self.EN_UNMET_DEPENDENCIES + terminal_msg.split(self.EN_UNMET_DEPENDENCIES)[1] + else: + terminal_msg = '' - pass + return terminal_msg class UpdateInstallMode(): def __init__(self,parent): diff --git a/backend/SystemUpdater/backend/__init__.py b/backend/SystemUpdater/backend/__init__.py index 1492531..f0a61b8 100644 --- a/backend/SystemUpdater/backend/__init__.py +++ b/backend/SystemUpdater/backend/__init__.py @@ -456,12 +456,11 @@ class InstallBackend(): return delete_pkgs,delete_desc except Exception as e: logging.info(str(e)) - # msg = get_broken_details(cache,False) pkg_string = '' for pkg in pkgs_install + pkgs_upgrade: pkg_string = pkg_string + ' ' + str(pkg) logging.info('Resolver calculation Packages List: '+pkg_string+'\n') - terminal_msg = self.emulate_calcul_broken(pkgs_install + pkgs_upgrade) + terminal_msg = self.window_main.simulate_mode.dependencies_broken(pkgs_install + pkgs_upgrade) logging.error(terminal_msg) raise UpdateBaseError(ERROR_RESOLVER_FAILED, desc= terminal_msg) @@ -539,7 +538,7 @@ class InstallBackend(): if len(error_string + error_desc) > 20: self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string,error_desc) else: - self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string+','+error_desc,error_desc) + self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string,error_desc) return else: if self.now_upgrade.version_upgrade == True and self.now_upgrade.need_retry == True and success == False: @@ -602,17 +601,7 @@ class InstallBackend(): self.window_main.dbusController.Quit(None) elif action == self.ACTION_CHECK_RESOLVER: - zh_desc = '下列软件包有未满足的依赖关系:' - en_desc = 'The following packages have unmet dependencies:' - if success == False: - if len(error_desc) > 500: - error_desc = '' - if zh_desc in error_desc: - error_desc = '\n' + zh_desc + error_desc.split(zh_desc)[1] - elif en_desc in error_desc: - error_desc = '\n' + en_desc + error_desc.split(en_desc)[1] - self.window_main.sqlite3_server.insert_info(self.action_mode,self.now_upgrade.single_pkgs,\ self.now_upgrade.upgrade_groups,[],success,error_string,error_desc) @@ -662,12 +651,12 @@ class InstallBackend(): #开始生成列表 self.window_main.start_available() else: - self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string+','+error_desc,error_desc) + self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string,error_desc) self.window_main.sqlite3_server.insert_into_display("check_time",get_east_8_time()) elif action == self.ACTION_UPDATE and self.action_mode == self.MODE_UPDATE_CACHE: - self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string+','+error_desc,error_desc) + self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string,error_desc) elif action == self.ACTION_FIX_BROKEN: self.window_main.dbusController.FixBrokenStatusChanged(True,success,100,'',error_string,error_desc) logging.warning("fix broken packages is complete...") From 06c2272f6753035099d055625bbb18bc2234b18c Mon Sep 17 00:00:00 2001 From: wangsong Date: Tue, 14 Jun 2022 16:10:17 +0800 Subject: [PATCH 13/13] =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=BC=82=E6=AD=A5?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E7=9A=84=E6=96=B9=E5=BC=8F=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/UpdateManager.py | 13 ++++++++--- backend/SystemUpdater/UpdateManagerDbus.py | 25 ++++++++++++---------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/backend/SystemUpdater/UpdateManager.py b/backend/SystemUpdater/UpdateManager.py index 4d1402a..3e3b61d 100644 --- a/backend/SystemUpdater/UpdateManager.py +++ b/backend/SystemUpdater/UpdateManager.py @@ -220,15 +220,14 @@ class UpdateManager(): if self.options.no_update_source is False: self.dbusController.on_update_important_list() + return #不进行update if self.options.no_update: self.start_available() return - #调用aptdeamon进行update - update_backend = get_backend(self, InstallBackend.ACTION_UPDATE,update_mode) - update_backend.start() + self.start_update_backend() except UpdateBaseError as excep: self.dbusController.DistUpdateDetectFinished(False,[],excep.header,excep.desc) @@ -237,6 +236,14 @@ class UpdateManager(): except Exception as e: logging.error(e) + def start_update_backend(self,update_mode = InstallBackend.MODE_UPDATE_ALL): + try: + #调用aptdeamon进行update + update_backend = get_backend(self, InstallBackend.ACTION_UPDATE,update_mode) + update_backend.start() + except Exception as e: + logging.error(e) + def start_available(self): try: self.refresh_cache() diff --git a/backend/SystemUpdater/UpdateManagerDbus.py b/backend/SystemUpdater/UpdateManagerDbus.py index 344fdf8..b83c59f 100755 --- a/backend/SystemUpdater/UpdateManagerDbus.py +++ b/backend/SystemUpdater/UpdateManagerDbus.py @@ -58,19 +58,22 @@ class UpdateManagerDbusController(dbus.service.Object): self.transaction = None + def _update_important_reply(self,retval): + if bool(retval) == False: + self.DistUpdateDetectFinished(False,[''],get_error_string_from_enum(ERROR_UPDATE_SOURCE_FAILED),\ + get_error_description_from_enum(ERROR_UPDATE_SOURCE_FAILED)) + else: + self.parent.start_update_backend() + + def _update_important_error(self,retval): + self.DistUpdateDetectFinished(False,[''],get_error_string_from_enum(ERROR_UPDATE_SOURCE_FAILED),str(retval)) + #更新important.list的本次升级的列表 def on_update_important_list(self): - try: - self.UpdateDetectStatusChanged(10,_("Updating Source Template")) - obj = self.bus.get_object('com.kylin.software.properties', '/com/kylin/software/properties') - interface = dbus.Interface(obj, dbus_interface='com.kylin.software.properties.interface') - retval = interface.updateSourceTemplate(timeout=20) - except Exception as excep: - raise UpdateBaseError(ERROR_UPDATE_SOURCE_FAILED, - details= str(excep)) - if retval == False: - raise UpdateBaseError(ERROR_UPDATE_SOURCE_FAILED) - return + self.UpdateDetectStatusChanged(10,_("Updating Source Template")) + obj = self.bus.get_object('com.kylin.software.properties', '/com/kylin/software/properties') + interface = dbus.Interface(obj, dbus_interface='com.kylin.software.properties.interface') + interface.updateSourceTemplate(timeout=1,reply_handler=self._update_important_reply,error_handler=self._update_important_error) def is_reboot_required(self): """If a reboot is required to get all changes into effect."""