Merge branch 'backend_manual' into 'backend_uu'

Backend manual

See merge request kylin-desktop/update-manager-group/kylin-system-updater!440
This commit is contained in:
wangsong 2022-06-16 03:30:05 +00:00
commit da74781b0c
8 changed files with 110 additions and 78 deletions

View File

@ -18,8 +18,8 @@ import datetime
import threading
from email import message
from binascii import a2b_hex
from datetime import datetime
from binascii import a2b_hex
from Crypto.PublicKey import RSA
from urllib import parse, request
from PyQt5.QtCore import QSettings

View File

@ -3,11 +3,12 @@
"""enums - Enumerates for apt daemon dbus messages"""
__all__ = (
"ERROR_UPDATE_DEFAULT_FAILED",
"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_UPDATE_KEY_SIGNATURES","ERROR_UPDATE_NET_AUTHENTICATION","ERROR_UPDATE_NOTREAD_SOURCES",
"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")
@ -16,15 +17,19 @@ gettext.bindtextdomain('kylin-system-updater', '/usr/share/locale')
gettext.textdomain('kylin-system-updater')
_ = gettext.gettext
PRIORITY_UPGRADE_SUCCCESSED = "priority-upgrade-successed"
#更新阶段
ERROR_UPDATE_DEFAULT_FAILED = "error-update-default-failed"
ERROR_UPDATE_KEY_SIGNATURES = "The following signatures"
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"
ERROR_NETWORK_FAILED = "error-network-failed"
ERROR_NOT_GROUPS_CONFIG = "error-not-groups-config"
#自己的
ERROR_SOFTWARE_INDEX_RROKEN = "error-software-index-broken"
ERROR_NOT_INIT_PACKAGESINFIO = "error-not-init-packagesinfo"
ERROR_READ_IMPORTANTLIST_FAILED = "error-read-importantlist-failed"
@ -34,40 +39,48 @@ 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"),
PRIORITY_UPGRADE_SUCCCESSED: _("Update Manager upgrade is complete, please restart the control panel before performing the system update"),
#update
ERROR_UPDATE_DEFAULT_FAILED: _("Check for update exceptions,please check your network connection and retry."),
ERROR_UPDATE_SOURCE_FAILED: ERROR_UPDATE_DEFAULT_FAILED,
ERROR_NETWORK_FAILED: ERROR_UPDATE_DEFAULT_FAILED,
ERROR_NOT_GROUPS_CONFIG: ERROR_UPDATE_DEFAULT_FAILED,
ERROR_UPDATE_KEY_SIGNATURES: ERROR_UPDATE_DEFAULT_FAILED,
ERROR_READ_IMPORTANTLIST_FAILED: ERROR_UPDATE_DEFAULT_FAILED,
ERROR_SOFTWARE_INDEX_RROKEN: ERROR_UPDATE_DEFAULT_FAILED,
ERROR_NOT_INIT_PACKAGESINFIO: ERROR_UPDATE_DEFAULT_FAILED,
#install
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"),
#update
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: _("groups JSON ConfigPkgs install failed"),
ERROR_UPDATE_KEY_SIGNATURES: _("Check your source public key signature"),
ERROR_UPDATE_NOTREAD_SOURCES: _("Please check your source list and retry."),
ERROR_UPDATE_NET_AUTHENTICATION: _("Check if your network requires authentication?"),
ERROR_NOT_GROUPS_CONFIG: _("Unable to get group configuration package, please contact administrator to solve."),
ERROR_NOT_INIT_PACKAGESINFIO: _("An unresolvable problem occurred while "
"initializing the package information.\n\n"
"Please report this bug against the 'kylin-system-updater' "
"package and include the following error "
"message:\n"),
ERROR_SOFTWARE_INDEX_RROKEN: _("It is impossible to install or remove any software. "
ERROR_SOFTWARE_INDEX_RROKEN: _("Software index is broken") + _("It is impossible to install or remove any software. "
"Please use the package manager \"Synaptic\" or run "
"\"sudo apt-get install -f\" in a terminal to fix "
"this issue at first."),
ERROR_READ_IMPORTANTLIST_FAILED: _("tttttttttttttttttt"),
ERROR_READ_IMPORTANTLIST_FAILED: _("read important list failed"),
#install
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_UPDATE_KEY_SIGNATURES: _("Check your source public key signature"),
ERROR_UPDATE_NET_AUTHENTICATION: _("Check if your network requires authentication?"),
ERROR_UPDATE_NOTREAD_SOURCES: _("Please check your source list and retry.")
ERROR_NOT_DISK_SPACE: _("test")
}
#UPGRADE MONITOR STATUS

View File

@ -306,7 +306,7 @@ class UpdateManager():
def _check_self_upgrade(self,cache):
need_upgrade = False
self_upgrade = []
with open(UpdateList.IMPORTANT_LIST_PATH, 'r') as f:
data = f.read()
important_list = data.split()
@ -315,16 +315,19 @@ class UpdateManager():
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,\
logging.info("Check: (%s) will upgrading From %s to %s...",pkg_name,\
self_pkg.installed.source_version,self_pkg.candidate.source_version)
if pkg_name in important_list:
try:
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()
self_upgrade.append(pkg_name)
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)
logging.info("Check: (%s:%s) No need to upgrade and duo to not pust...",pkg_name,self_pkg.installed.source_version)
else:
logging.info("Check: (%s:%s) No need to upgrade...",pkg_name,self_pkg.installed.source_version)
else:
@ -338,20 +341,28 @@ class UpdateManager():
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,\
pkg_json.installed.source_version,pkg_json.candidate.source_version)
pkg_json.mark_install()
need_upgrade = True
try:
pkg_json.mark_install()
self_upgrade.append(self.GROUPS_PKG_NAME)
need_upgrade = True
except SystemError:
logging.error("Check: mark %s to upgrade Failed...",pkg_name)
else:
logging.info("Check: ConfigPkgs(%s:%s) No need to upgrade...",self.GROUPS_PKG_NAME,pkg_json.installed.source_version)
else:
self.dbusController.UpdateDetectStatusChanged(95,_("Group configuration being updated"))
logging.info("Check: groups JSON ConfigPkgs(%s) start new installing...",self.GROUPS_PKG_NAME)
pkg_json.mark_install()
need_upgrade = True
try:
pkg_json.mark_install()
self_upgrade.append(self.GROUPS_PKG_NAME)
need_upgrade = True
except SystemError:
logging.error("Check: mark %s to upgrade Failed...",pkg_name)
else:
raise UpdateBaseError(ERROR_NOT_GROUPS_CONFIG)
if need_upgrade == True:
self.start_install(InstallBackend.MODE_INSTALL_SINGLE,True)
self.start_install(InstallBackend.MODE_INSTALL_SINGLE,True,upgrade_content=self_upgrade)
raise UpdateProgressExit()
def _check_system_broken(self,cache):

View File

@ -66,7 +66,8 @@ class UpdateManagerDbusController(dbus.service.Object):
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))
logging.error(str(retval))
self.DistUpdateDetectFinished(False,[''],get_error_string_from_enum(ERROR_UPDATE_SOURCE_FAILED))
#更新important.list的本次升级的列表
def on_update_important_list(self):

View File

@ -295,8 +295,7 @@ class InstallBackendAptdaemon(InstallBackend):
return
self.aptd_base.progress = progress
self._dist_status_changed(action,self.now_upgrade.upgrade_groups+self.now_upgrade.single_pkgs,\
self.aptd_base.progress,self.aptd_base.status,self.aptd_base.details)
self._dist_status_changed(action,self.now_upgrade.upgrade_content,self.aptd_base.progress,self.aptd_base.status,self.aptd_base.details)
#同步状态回调
@ -309,7 +308,7 @@ class InstallBackendAptdaemon(InstallBackend):
if self.aptd_base.status == None:
return
self._dist_status_changed(action,self.now_upgrade.upgrade_groups+self.now_upgrade.single_pkgs,\
self._dist_status_changed(action,self.now_upgrade.upgrade_content,\
self.aptd_base.progress,self.aptd_base.status,self.aptd_base.details)
#分发进度状态和细节信息

View File

@ -64,8 +64,12 @@ class NowUpgradeMeta:
return groups_list,pkg_list
def make_upgrade_content(self,content):
self.upgrade_groups,self.single_pkgs = self._make_groups_list(self.parent.upgrade_data,self.parent.action_mode,content)
self.upgrade_content = self.upgrade_groups + self.single_pkgs
if self.parent.action_mode != self.parent.MODE_INSTALL_SINGLE:
self.upgrade_groups,self.single_pkgs = self._make_groups_list(self.parent.upgrade_data,self.parent.action_mode,content)
self.upgrade_content = self.upgrade_groups + self.single_pkgs
else:
self.single_pkgs = content
self.upgrade_content = self.upgrade_groups + self.single_pkgs
class AptdBaseInformation:
@ -141,9 +145,8 @@ class InstallBackend():
try:
#安装升级包 首先必须调用ACTION_CHECK_RESOLVER 计算依赖解决方便 标记cache 进行升级
if self.action == self.ACTION_INSTALL or self.action == self.ACTION_DOWNLOADONLY:
if self.action_mode != self.MODE_INSTALL_SINGLE:
#拿到升级列表
self.now_upgrade.make_upgrade_content(partial_upgrade_list)
#拿到升级列表
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))
@ -157,8 +160,8 @@ class InstallBackend():
if len(pkgs_install) == 0 and len(pkgs_upgrade) == 0 and len(pkgs_remove) == 0:
raise UpdateBaseError(ERROR_NOT_UPGRADE_PACKAGES)
if self.action_mode == self.MODE_INSTALL_SINGLE:
logging.warning("MODE_INSTALL_SINGLE install:%s , upgrade:%s remove:%s",str(pkgs_install),str(pkgs_upgrade),str(pkgs_remove))
# if self.action_mode == self.MODE_INSTALL_SINGLE:
# logging.warning("MODE_INSTALL_SINGLE install:%s , upgrade:%s remove:%s",str(pkgs_install),str(pkgs_upgrade),str(pkgs_remove))
self.window_main.update_essential.check(pkgs_remove)
@ -495,6 +498,37 @@ class InstallBackend():
if error_code == ERROR_NOT_DISK_SPACE:
self.window_main.dbusController.InstallDetectStatus(False,error_code)
def _self_upgrade_finished(self,success,error_string='',error_desc=''):
if success:
if self.window_main.configs.getWithDefault("SystemStatus", "priority_upgrade_restart", False) == True:
error_string = get_error_string_from_enum(PRIORITY_UPGRADE_SUCCCESSED)
if self.window_main.APTD_PKG_NAME in self.now_upgrade.upgrade_content:
self.window_main.dbusController.DistUpdateDetectFinished(False,[self.window_main.BACKEND_PKG_NAME],error_string,'')
self.window_main.dbusController.make_aptdeamon_restart()
#当单包升级的时候 升级本身时,让程序退出,再重新启动
if self.window_main.FRONTEND_PKG_NAME in self.now_upgrade.upgrade_content:
self.window_main.dbusController.DistUpdateDetectFinished(False,[self.window_main.BACKEND_PKG_NAME],error_string,'')
#当单包升级的时候 升级本身时,让程序退出,再重新启动
if self.window_main.BACKEND_PKG_NAME in self.now_upgrade.upgrade_content:
self.window_main.dbusController.DistUpdateDetectFinished(False,[self.window_main.BACKEND_PKG_NAME],error_string,'')
#升级本身完成后 退出 有systemd 来进行重启服务
self.window_main.dbusController.Quit(None)
#当单包升级的时候 升级本身时,让程序退出,再重新启动
if self.window_main.GROUPS_PKG_NAME in self.now_upgrade.upgrade_content:
#只有安装配置文件包 才会走到此处
self.window_main.update_essential.update()
self.window_main.start_available()
else:
#只有安装配置文件包 才会走到此处
self.window_main.update_essential.update()
self.window_main.start_available()
else:
default_string = get_error_string_from_enum(ERROR_UPDATE_DEFAULT_FAILED)
self.window_main.dbusController.DistUpdateDetectFinished(success,[],default_string,error_string +' '+error_desc)
#调用aptdeamon结束之后处理的地方 不管是出错还是正常都在此处理
def _action_done(self, action, is_cancelled,success, error_string,error_desc,error_code=''):
#后端的状态 到空闲状态
@ -505,41 +539,8 @@ class InstallBackend():
self._release_install_lock()
self._send_error_code(error_code)
#单包安装模式 单独处理 目前 更新配置包和升级本身使用
if self.action_mode == self.MODE_INSTALL_SINGLE:
if success:
if self.window_main.APTD_PKG_NAME in self.cache and self.cache[self.window_main.APTD_PKG_NAME] in self.cache.get_changes():
error_string = _("Update Manager upgrade is complete, please restart the control panel before performing the system update")
self.window_main.dbusController.DistUpdateDetectFinished(False,[self.window_main.BACKEND_PKG_NAME],error_string,error_desc)
self.window_main.dbusController.make_aptdeamon_restart()
#当单包升级的时候 升级本身时,让程序退出,再重新启动
if self.window_main.FRONTEND_PKG_NAME in self.cache and self.cache[self.window_main.FRONTEND_PKG_NAME] in self.cache.get_changes():
error_string = _("Update Manager upgrade is complete, please restart the control panel before performing the system update")
self.window_main.dbusController.DistUpdateDetectFinished(False,[self.window_main.BACKEND_PKG_NAME],error_string,error_desc)
#当单包升级的时候 升级本身时,让程序退出,再重新启动
if self.window_main.BACKEND_PKG_NAME in self.cache and self.cache[self.window_main.BACKEND_PKG_NAME] in self.cache.get_changes():
error_string = _("Update Manager upgrade is complete, please restart the control panel before performing the system update")
self.window_main.dbusController.DistUpdateDetectFinished(False,[self.window_main.BACKEND_PKG_NAME],error_string,error_desc)
#升级本身完成后 退出 有systemd 来进行重启服务
self.window_main.dbusController.Quit(None)
#当单包升级的时候 升级本身时,让程序退出,再重新启动
if self.window_main.GROUPS_PKG_NAME in self.cache and self.cache[self.window_main.GROUPS_PKG_NAME] in self.cache.get_changes():
#只有安装配置文件包 才会走到此处
self.window_main.update_essential.update()
self.window_main.start_available()
return
else:
#当更新过程中安装配置包时 失败时发送错误信号
# 防止错误结果太长导致出现控制面板显示太多 目前最多20字符
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)
return
self._self_upgrade_finished()
else:
if self.now_upgrade.version_upgrade == True and self.now_upgrade.need_retry == True and success == False:
#增加重试次数的限制
@ -651,12 +652,14 @@ class InstallBackend():
#开始生成列表
self.window_main.start_available()
else:
self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string,error_desc)
self.window_main.dbusController.DistUpdateDetectFinished(success,[''],\
get_error_string_from_enum(ERROR_UPDATE_DEFAULT_FAILED),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)
self.window_main.dbusController.DistUpdateDetectFinished(success,[''],\
get_error_string_from_enum(ERROR_UPDATE_DEFAULT_FAILED),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...")
@ -665,7 +668,8 @@ class InstallBackend():
logging.info("Fix broken packages is complete to success...")
self.window_main.start_available()
else:
self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string,error_desc)
self.window_main.dbusController.DistUpdateDetectFinished(success,[],\
get_error_string_from_enum(ERROR_UPDATE_DEFAULT_FAILED),error_string+' '+error_desc)
logging.error("fix broken packages is complete to failed...")
elif action == self.ACTION_FIX_INCOMPLETE:

View File

@ -2,6 +2,7 @@
abnormal_reboot = False
close_source_filter = False
upload_upgrade_log = False
priority_upgrade_restart = True
[ConfigPkgStatus]
check_resover_remove = False

View File

@ -616,8 +616,8 @@ msgid "Checking package manager"
msgstr "正在检查软件包管理器"
#: ../DistUpgrade/DistUpgradeController.py:1593
msgid "Unable to get group configuration package, please contact administrator to solve"
msgstr "无法获取组配置软件包,请联系管理员解决"
msgid "Unable to get group configuration package, please contact administrator to solve."
msgstr "无法获取组配置软件包,请联系管理员解决"
#: ../DistUpgrade/DistUpgradeController.py:1594
msgid ""
@ -2599,7 +2599,7 @@ msgid "Installation failed, about to shut down"
msgstr "安装失败,即将关机"
msgid "groups JSON ConfigPkgs install failed"
msgstr "无法安装分组配置文件,请稍后再试"
msgstr "无法安装分组配置文件"
msgid "Installtion timeout to exit Due to inactivity"
msgstr "安装超时退出由于"
@ -2622,6 +2622,9 @@ msgstr "依赖关系不满足"
msgid "Disk space is insufficient, please clean the disk and then upgrade"
msgstr "磁盘空间不足,请清理磁盘后进行升级更新"
msgid "Check for update exceptions,please check your network connection and retry."
msgstr "检查更新异常,请检查您的网络连接后再试。"
msgid "Please check your network connection and retry."
msgstr "请检查您的网络连接后再试。"