This commit is contained in:
luoxueyi 2021-11-26 14:32:57 +08:00
commit 797270bd04
10 changed files with 321 additions and 181 deletions

View File

@ -11,21 +11,11 @@ import datetime
from gettext import gettext as _
import apt_pkg
from ..backend import InstallBackend
DB_FILE = os.path.join("/var/cache/kylin-system-updater/kylin-system-updater.db")
INSTALLED_LIST = [{"item": "errorcode", "type": "int", "default": "0"}]
DISPALY_LIST = []
MODE_DEFAULT_STATUS = -1
#部分升级
MODE_UPGRADE_PARTIAL = 0
#全部升级
MODE_UPGRADE_ALL = 1
#系统全盘升级
MODE_UPGRADE_SYSTEM = 2
#后端内部安装包使用
MODE_UPGRADE_SINGLE = 3
class Sqlite3Server(object):
def __init__(self, window_main):
self.connect = None
@ -158,7 +148,7 @@ class Sqlite3Server(object):
status = 'failed'
# 判断更新方式
if mode == MODE_UPGRADE_PARTIAL: # 部分更新
if mode == InstallBackend.MODE_UPGRADE_PARTIAL: # 部分更新
pkg_adj = ""
# 判断更新包为单包或更新组
if pkg_group:
@ -205,7 +195,7 @@ class Sqlite3Server(object):
self.insert_into_updateinfo(pkgname, pkgversion, pkgdescription, timestr, status, "1", errstr)
# FIXME: 这里也需要, 发送插入数据库成功的信号
self.window_main.dbusController.UpdateSqlitSingle(pkgname, timestr)
elif mode == MODE_UPGRADE_ALL: # 系统升级
elif mode == InstallBackend.MODE_UPGRADE_ALL: # 系统升级
# # insert signal deb first
for i in pkg_list:
try:
@ -239,7 +229,7 @@ class Sqlite3Server(object):
self.init_sqlit()
self.insert_into_updateinfo(str(i), pkgversion, pkgdescription, timestr, status, "1", errstr)
self.window_main.dbusController.UpdateSqlitSingle(str(i), timestr)
elif mode == MODE_UPGRADE_SYSTEM: # 全盘升级
elif mode == InstallBackend.MODE_UPGRADE_SYSTEM: # 全盘升级
pkgs_install,pkgs_upgrade,pkgs_remove = self.refreshpkglist()
pkg_list = list(set(pkgs_upgrade).union(set(pkgs_install)))
for i in pkg_list:

View File

@ -475,6 +475,115 @@ def error(parent, summary, message):
d.destroy()
return False
def get_lis_from_cache(cache):
pkgs_install = []
pkgs_upgrade = []
pkgs_remove = []
#计算修复破损包 方案 需要删除 新装那些包
for pkg in cache:
try:
if pkg.marked_install :
pkgs_install.append(pkg.name)
elif pkg.marked_upgrade:
pkgs_upgrade.append(pkg.name)
elif pkg.marked_delete:
pkgs_remove.append(pkg.name)
except KeyError:
# pkg missing from fresh_cache can't be modified
pass
return pkgs_install,pkgs_upgrade,pkgs_remove
def get_broken_details(cache,now=True):
"""Return a message which provides debugging information about
broken packages.
This method is basically a Python implementation of apt-get.cc's
ShowBroken.
Keyword arguments:
trans -- the corresponding transaction
now -- if we check currently broken dependecies or the installation
candidate
"""
msg = _("The following packages have unmet dependencies:")
msg += "\n\n"
for pkg in cache:
if not ((now and pkg.is_now_broken) or
(not now and pkg.is_inst_broken)):
continue
msg += "%s: " % pkg.name
if now:
version = pkg.installed
else:
version = pkg.candidate
indent = " " * (len(pkg.name) + 2)
dep_msg = ""
for dep in version.dependencies:
or_msg = ""
for base_dep in dep.or_dependencies:
if or_msg:
or_msg += "or\n"
or_msg += indent
# Check if it's an important dependency
# See apt-pkg/depcache.cc IsImportantDep
# See apt-pkg/pkgcache.cc IsCritical()
if not (base_dep.rawtype in ["Depends", "PreDepends",
"Obsoletes", "DpkgBreaks",
"Conflicts"] or
(apt_pkg.config.find_b("APT::Install-Recommends",
False) and
base_dep.rawtype == "Recommends") or
(apt_pkg.config.find_b("APT::Install-Suggests",
False) and
base_dep.rawtype == "Suggests")):
continue
# Get the version of the target package
try:
pkg_dep = cache[base_dep.name]
except KeyError:
dep_version = None
else:
if now:
dep_version = pkg_dep.installed
else:
dep_version = pkg_dep.candidate
# We only want to display dependencies which cannot
# be satisfied
if dep_version and not apt_pkg.check_dep(base_dep.version,
base_dep.relation,
version.version):
break
or_msg = "%s: %s " % (base_dep.rawtype, base_dep.name)
if base_dep.version:
or_msg += "(%s %s) " % (base_dep.relation,
base_dep.version)
if cache.is_virtual_package(base_dep.name):
or_msg += _("but it is a virtual package")
elif not dep_version:
if now:
or_msg += _("but it is not installed")
else:
or_msg += _("but it is not going to "
"be installed")
elif now:
# TRANSLATORS: %s is a version number
or_msg += (_("but %s is installed") %
dep_version.version)
else:
# TRANSLATORS: %s is a version number
or_msg += (_("but %s is to be installed") %
dep_version.version)
else:
# Only append an or-group if at least one of the
# dependencies cannot be satisfied
if dep_msg:
dep_msg += indent
dep_msg += or_msg
dep_msg += "\n"
msg += dep_msg
return msg
def check_free_space(cache):
from .DistUpgradeCache import NotEnoughFreeSpaceError
err_sum = _("Not enough free disk space")

View File

@ -22,9 +22,9 @@ from .Core.loop import mainloop
import time
from gettext import gettext as _
from SystemUpdater.backend import DownloadBackend as downb
from SystemUpdater.Core.Database import MODE_UPGRADE_SINGLE
import apt_pkg
from SystemUpdater.Core.UpdaterConfigParser import UpgradeConfig
from SystemUpdater.Core.utils import get_broken_details,get_lis_from_cache
class UpdateManager():
SELF_PKG_NAME = 'kylin-system-updater'
@ -120,7 +120,7 @@ class UpdateManager():
self.dbusController.UpdateDetectStatusChanged(5,_("Checking network connection"))
_success,header,desc = self.dbusController.check_connectivity()
if _success == False:
self.dbusController.UpdateDetectFinished(_success,[],header,desc)
self.dbusController.DistUpdateDetectFinished(_success,[],header,desc)
return
#从服务器端更新摸板
@ -128,7 +128,7 @@ class UpdateManager():
self.dbusController.UpdateDetectStatusChanged(10,_("Updating Source Template"))
_success,header,desc = self.dbusController.on_update_important_list()
if _success == False:
self.dbusController.UpdateDetectFinished(_success,[],header,desc)
self.dbusController.DistUpdateDetectFinished(_success,[],header,desc)
return
#调用aptdeamon进行update
update_backend = get_backend(self, InstallBackend.ACTION_UPDATE)
@ -188,7 +188,7 @@ class UpdateManager():
if self.update_list != None:
upgrade_list = self.update_list.local_upgrade_data.upgrade_groups + self.update_list.local_upgrade_data.single_pkgs
#发送更新升级列表完成的标志
self.dbusController.UpdateDetectFinished(_success,upgrade_list,header,desc)
self.dbusController.DistUpdateDetectFinished(_success,upgrade_list,header,desc)
#检查安装完成之后需要重启吗
self.is_reboot_required()
#清空cache
@ -208,7 +208,7 @@ class UpdateManager():
logging.info("Self-Updater(%s) start upgrading...",self.SELF_PKG_NAME)
pkg_json.mark_upgrade()
self.start_install(MODE_UPGRADE_SINGLE,True)
self.start_install(InstallBackend.MODE_UPGRADE_SINGLE,True)
#直接退出 进行安装程序
_success = False
header = self.INSTALL_ALONE_PROGRESS
@ -246,7 +246,7 @@ class UpdateManager():
logging.info("groups JSON ConfigPkgs(%s) start upgrading...",self.GROUPS_PKG_NAME)
pkg_json.mark_upgrade()
self.start_install(MODE_UPGRADE_SINGLE,True)
self.start_install(InstallBackend.MODE_UPGRADE_SINGLE,True)
#直接退出
_success = False
header = self.INSTALL_ALONE_PROGRESS
@ -256,7 +256,7 @@ class UpdateManager():
else:
logging.info("groups JSON ConfigPkgs(%s) start new installing...",self.GROUPS_PKG_NAME)
pkg_json.mark_install()
self.start_install(MODE_UPGRADE_SINGLE,True)
self.start_install(InstallBackend.MODE_UPGRADE_SINGLE,True)
#直接退出
_success = False
header = self.INSTALL_ALONE_PROGRESS
@ -316,6 +316,8 @@ class UpdateManager():
"message:\n") + str(e)
_success = False
return _success,header,desc
self._check_cache_broken(self.cache)
#检查出现安装过程异常重启 出现的话 进行异常修复
if self.configs.getWithDefault("SystemStatus", "isabnormalreboot", False) == True:
@ -347,6 +349,30 @@ class UpdateManager():
return os.path.exists(os.path.join(apt_pkg.config.find_dir("Dir"),
"var/run/reboot-required"))
def _check_cache_broken(self,cache):
with cache.actiongroup():
if cache.get_changes():
cache.clear()
#获取出现破损状态包的数量
wouldDelete = cache._depcache.broken_count
if wouldDelete > 0:
#获取那些依赖关系不满足导致的问题
logging.info(get_broken_details(cache))
else:
return
try:
#计算依赖的解决方案
cache.fix_broken()
except SystemError as e:
logging.error(e)
return
pkgs_install,pkgs_upgrade,pkgs_remove = get_lis_from_cache(cache)
logging.warning("Fix broken Packages is need to install:%a and upgrade:%a and remove:%a",pkgs_install,pkgs_upgrade,pkgs_remove)
if cache.get_changes():
cache.clear()
def _setup_dbus(self):
# check if there is another g-a-i already and if not setup one

View File

@ -11,7 +11,6 @@ from .Core.utils import humanize_size
from SystemUpdater.Core.utils import (
unLockedEnableShutdown,
)
from SystemUpdater.Core.Database import MODE_UPGRADE_PARTIAL,MODE_UPGRADE_ALL,MODE_UPGRADE_SYSTEM
UPDATER_DBUS_INTERFACE = 'com.kylin.systemupgrade.interface'
UPDATER_DBUS_PATH = '/com/kylin/systemupgrade'
@ -211,7 +210,7 @@ class UpdateManagerDbusController(dbus.service.Object):
return False,'In the process of updating or Upgrading...'
else:
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' DistUpgradeAll and is_install:%r...',is_install)
self.parent.start_install(MODE_UPGRADE_ALL,is_install)
self.parent.start_install(InstallBackend.MODE_UPGRADE_ALL,is_install)
return True,'success'
except Exception as e:
return False,str(e)
@ -237,7 +236,7 @@ class UpdateManagerDbusController(dbus.service.Object):
new_upgrade_list = list(set(partial_upgrade_list) & set(local_upgrade_groups + local_single_pkgs))
if new_upgrade_list:
self.parent.start_install(MODE_UPGRADE_PARTIAL,is_install,partial_upgrade_list)
self.parent.start_install(InstallBackend.MODE_UPGRADE_PARTIAL,is_install,partial_upgrade_list)
return True,'dbus upgrading'
else:
logging.warning('input upgrade list(%s) not in local upgrade_list(%s)',partial_upgrade_list,local_upgrade_groups+local_single_pkgs)
@ -290,7 +289,7 @@ class UpdateManagerDbusController(dbus.service.Object):
return False,'In the process of updating or Upgrading...'
else:
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' DistUpgradeSystem and is_install:%r...',is_install)
self.parent.start_install(MODE_UPGRADE_SYSTEM,is_install)
self.parent.start_install(InstallBackend.MODE_UPGRADE_SYSTEM,is_install)
return True,'success'
except Exception as e:
logging.error(False, str(e))
@ -402,9 +401,14 @@ class UpdateManagerDbusController(dbus.service.Object):
def UpdateDetectStatusChanged(self,progress,status):
logging.info(COLORLOG_PREFIX+"emit"+COLORLOG_SUFFIX+" UpdateDetectStatusChanged progress = %d , status = %s",progress,status)
#替代UpdateDetectFinished 分发更新完成信号,为了解决发送空列表时 控制面板出段错误
def DistUpdateDetectFinished(self, success, upgrade_group,error_string='',error_desc=''):
if success == False and upgrade_group == []:
upgrade_group = ['']
self.UpdateDetectFinished(success,upgrade_group,error_string,error_desc)
#更新完成的信号
@dbus.service.signal(UPDATER_DBUS_INTERFACE,signature='basss')
def UpdateDetectFinished(self, success, upgrade_group,error_string='',error_desc='',):
def UpdateDetectFinished(self, success, upgrade_group,error_string='',error_desc=''):
logging.info(COLORLOG_PREFIX + "emit"+ COLORLOG_SUFFIX + " UpdateDetectFinished success = %r , upgrade_group = %a, error_string = %s , error_desc = %s ",\
success,upgrade_group,error_string,error_desc)
@ -416,35 +420,36 @@ class UpdateManagerDbusController(dbus.service.Object):
#升级完成的信号
@dbus.service.signal(UPDATER_DBUS_INTERFACE,signature='basss')
def UpdateInstallFinished(self, success, upgrade_group,error_string='',error_desc='',):
def UpdateInstallFinished(self, success, upgrade_group,error_string='',error_desc=''):
logging.info(COLORLOG_PREFIX + "emit" + COLORLOG_SUFFIX +" UpdateInstallFinished success = %r , upgrade_group = %a, error_string = %s , error_desc = %s ",\
success,upgrade_group, error_string,error_desc)
#发送下载包信息 fix bug 字节大小改成u 无符号32位
@dbus.service.signal(UPDATER_DBUS_INTERFACE, signature='iiuui')
def UpdateDownloadInfo(self, current_items, total_items, currenty_bytes, total_bytes, current_cps):
logging.info(COLORLOG_PREFIX + "emit" + COLORLOG_SUFFIX +" UpdateDownloadInfo current_items = %d, total_items = %d, currenty_bytes = %s, total_bytes = %s, current_cps = %s/s",\
@dbus.service.signal(UPDATER_DBUS_INTERFACE, signature='asiiuui')
def UpdateDownloadInfo(self,upgrade_group,current_items, total_items, currenty_bytes, total_bytes, current_cps):
logging.info(COLORLOG_PREFIX + "emit" + COLORLOG_SUFFIX +" UpdateDownloadInfo upgrade_group = %a,current_items = %d, total_items = %d, currenty_bytes = %s, total_bytes = %s, current_cps = %s/s",\
upgrade_group,\
current_items, total_items, \
humanize_size(currenty_bytes), humanize_size(total_bytes),\
humanize_size(current_cps))
#查询解决依赖 信号
@dbus.service.signal(UPDATER_DBUS_INTERFACE,signature='bbasasasss')
def UpdateDependResloveStatus(self, resolver_status, remove_status,remove_pkgs,pkg_raw_description,delete_desc,error_string='',error_desc='',):
def UpdateDependResloveStatus(self, resolver_status, remove_status,remove_pkgs,pkg_raw_description,delete_desc,error_string='',error_desc=''):
logging.info(COLORLOG_PREFIX + "emit" + COLORLOG_SUFFIX +" UpdateDependResloveStatus:resolver_status = %r , resolver_status = %r , remove_pkgs = %a,pkg_raw_description = %a ,delete_desc = %s,error_string = %s , error_desc = %s ",\
resolver_status,remove_status,remove_pkgs,pkg_raw_description,delete_desc,error_string,error_desc)
#查询dist-upgrade解决依赖
@dbus.service.signal(UPDATER_DBUS_INTERFACE,signature='bbasasss')
def DistupgradeDependResloveStatus(self, resolver_status, remove_status,remove_pkgs,pkg_raw_description,error_string='',error_desc='',):
def DistupgradeDependResloveStatus(self, resolver_status, remove_status,remove_pkgs,pkg_raw_description,error_string='',error_desc=''):
logging.info(COLORLOG_PREFIX + "emit" + COLORLOG_SUFFIX +" DistupgradeDependResloveStatus:resolver_status = %r , resolver_status = %r , remove_pkgs = %a,pkg_raw_description = %a ,error_string = %s , error_desc = %s ",\
resolver_status,remove_status,remove_pkgs,pkg_raw_description,error_string,error_desc)
# 信号是否可取消
@dbus.service.signal(UPDATER_DBUS_INTERFACE, signature='b')
def Cancelable(self, Cancelable):
logging.info(COLORLOG_PREFIX + "emit" + COLORLOG_SUFFIX +" Cancelable: %r",\
Cancelable)
pass
# logging.info(COLORLOG_PREFIX + "emit" + COLORLOG_SUFFIX +" Cancelable: %r",Cancelable)
# 插入数据库完成后发送
@dbus.service.signal(UPDATER_DBUS_INTERFACE, signature='ss')
@ -452,8 +457,8 @@ class UpdateManagerDbusController(dbus.service.Object):
logging.info(COLORLOG_PREFIX + "emit" + COLORLOG_SUFFIX +" UpdateSqlitSingle: [ %s ]: date: %s .",\
appname, date)
#修复破损包进度信息 0~100 进度信息 101为非预期的信号
@dbus.service.signal(UPDATER_DBUS_INTERFACE,signature='is')
def FixBrokenStatusChanged(self,progress,status):
logging.info(COLORLOG_PREFIX+"emit"+COLORLOG_SUFFIX+" FixBrokenStatusChanged progress = %d , status = %s",progress,status)
#更新进度信息 0~100 进度信息 101为非预期的信号
@dbus.service.signal(UPDATER_DBUS_INTERFACE,signature='iiisss')
def FixBrokenStatusChanged(self,finished,success,progress,status,error_string='',error_desc=''):
logging.info(COLORLOG_PREFIX+"emit"+COLORLOG_SUFFIX+" FixBrokenStatusChanged finished = %r , success = %r,progress = %d , status = %s,error_string = %s , error_desc = %s",\
finished,success,progress,status,error_string,error_desc)

View File

@ -12,7 +12,7 @@ from aptdaemon.enums import (EXIT_SUCCESS,
from SystemUpdater.backend import InstallBackend
import logging
from gettext import gettext as _
from ..Core.utils import humanize_size
from SystemUpdater.Core.utils import humanize_size
import dbus,time
from gi.repository import GLib
@ -37,8 +37,8 @@ class InstallBackendAptdaemon(InstallBackend):
self.static_progress = 0
self.trans_status = ''
self.details = ''
self.is_enter_install = False
self.on_install_stage = False
self.trans_cancelable = False
self.last_action_timestamp = time.time()
if self.action == self.ACTION_INSTALL:
@ -259,16 +259,18 @@ class InstallBackendAptdaemon(InstallBackend):
if self.trans_progress != 100:
self.window_main.dbusController.UpdateDetectStatusChanged(progress,status)
elif action == self.ACTION_INSTALL:
if progress >= 50 and self.is_enter_install == False:
self.is_enter_install = True
#50%时候 属于下载状态切换到安装状态的过程
if progress >= 51 and self.on_install_stage == False:
self.on_install_stage = True
#进度安装阶段标志位,使用鉴别是否出现安装过程中强制关闭 之后进行修复使用得
self.window_main.configs.setValue("SystemStatus","isabnormalreboot",str(True),True)
pass #LockedPreventShutdown()
#此处发不发信号一样 频率很低
#在下载阶段发送取消信号
if self.on_install_stage == False:
self.window_main.dbusController.Cancelable(self.trans_cancelable)
self.window_main.dbusController.UpdateDloadAndInstStaChanged(upgrade_content,progress,status,details)
# elif action == self.ACTION_FIX_BROKEN:
# self.window_main.dbusController.FixBrokenStatusChanged(progress,status)
elif action == self.ACTION_FIX_BROKEN:
self.window_main.dbusController.FixBrokenStatusChanged(False,True,progress,status,'','')
else:
logging.info("Other Action:progress = %d , status = %s ,details = %s",progress,status,details)
@ -282,19 +284,23 @@ class InstallBackendAptdaemon(InstallBackend):
def _on_progress_download_changed(self,trans,current_items, total_items, currenty_bytes, total_bytes, current_cps, eta):
if self.action == self.ACTION_INSTALL:
self.window_main.dbusController.UpdateDownloadInfo(\
self.now_upgrade.upgrade_groups+self.now_upgrade.single_pkgs,\
current_items, total_items, \
currenty_bytes, total_bytes, \
current_cps)
else:
if self.action == self.ACTION_UPDATE:
return
# if self.action == self.ACTION_UPDATE:
# return
logging.info("Other Action:current_items = %d, total_items = %d, currenty_bytes = %s, total_bytes = %s, current_cps = %s/s",\
current_items, total_items, \
humanize_size(currenty_bytes), humanize_size(total_bytes),\
humanize_size(current_cps))
def _on_cancellable_changed(self, trans, Cancelable):
logging.info("\033[43;1m" + "emit" + "\033[0m" +" Cancelable: %r",Cancelable)
self.window_main.dbusController.Cancelable(Cancelable)
#增加取消信号的频发机制
self.trans_cancelable = Cancelable
#增加记录当产生错误的时候 详细信息
def _on_error_changed(self, trans,error_code, error_details):
@ -322,7 +328,7 @@ class InstallBackendAptdaemon(InstallBackend):
error_desc = ''
#退出
self.is_enter_install = False
self.on_install_stage = False
if status == EXIT_FAILED:
error_string = get_error_string_from_enum(trans.error.code)
error_desc = get_error_description_from_enum(trans.error.code)

View File

@ -3,8 +3,6 @@
"""Integration of package managers into SystemUpdater"""
from __future__ import absolute_import
import logging
import os
from gettext import gettext as _
@ -12,10 +10,10 @@ from gettext import gettext as _
import apt_pkg
from SystemUpdater.Core.utils import (
unLockedEnableShutdown,
check_free_space
check_free_space,
get_broken_details
)
import time
from ..Core.Database import MODE_DEFAULT_STATUS,MODE_UPGRADE_PARTIAL,MODE_UPGRADE_ALL,MODE_UPGRADE_SYSTEM,MODE_UPGRADE_SINGLE
class NowUpgradePara:
"""
@ -23,9 +21,9 @@ class NowUpgradePara:
run
"""
def __init__(self,
upgrade_groups=[],
upgrade_mode=MODE_DEFAULT_STATUS,
single_pkgs=[],
upgrade_groups,
upgrade_mode,
single_pkgs,
):
#组列表中包含的包
self.upgrade_groups = upgrade_groups
@ -47,27 +45,39 @@ class InstallBackend():
ACTION_FIX_INCOMPLETE = 7
ACTION_CLEAN = 8
#ACTION_INSTALL 的子类
MODE_DEFAULT_STATUS = -1
#部分升级
MODE_UPGRADE_PARTIAL = 0
#全部升级
MODE_UPGRADE_ALL = 1
#系统全盘升级
MODE_UPGRADE_SYSTEM = 2
#后端内部安装包使用
MODE_UPGRADE_SINGLE = 3
def __init__(self, window_main, action):
self.window_main = window_main
self.cache = window_main.cache
self.action = action
#对所有的操作进行枷锁 当执行完毕后返回到_action_done 进行解锁,除了计算依赖模式 不进入_action_done 单独解锁
self.window_main.is_working = action
#更新的时候此对象还未生成
if self.window_main.update_list != None:
#本地维护的升级列表和需要升级的包
self.upgrade_data = window_main.update_list.local_upgrade_data
#要拿到升级列表必须调用_make_upgrade_list
self.now_upgrade = NowUpgradePara([],MODE_DEFAULT_STATUS,[])
self.now_upgrade = NowUpgradePara([],self.MODE_DEFAULT_STATUS,[])
def start(self,_upgrade_mode = MODE_DEFAULT_STATUS,partial_upgrade_list = []):
#对所有的操作进行枷锁 当执行完毕后返回到_action_done 进行解锁,除了计算依赖模式 不进入_action_done 单独解锁
self.window_main.is_working = self.action
#安装升级包 首先必须调用ACTION_CHECK_RESOLVER 计算依赖解决方便 标记cache 进行升级
if self.action == self.ACTION_INSTALL:
self.now_upgrade.upgrade_mode = _upgrade_mode
if _upgrade_mode != MODE_UPGRADE_SINGLE:
if _upgrade_mode != self.MODE_UPGRADE_SINGLE:
#拿到升级列表
self.now_upgrade.upgrade_groups,self.now_upgrade.single_pkgs = self._make_groups_list(self.upgrade_data,_upgrade_mode,partial_upgrade_list)
@ -87,7 +97,7 @@ class InstallBackend():
if _success == False:
header = _("Disk space is insufficient, please clean the disk and then upgrade")
#当单包安装检查内存不够的时候,报错到控制面板 单包安装属于更新才使用的所以直接赋值为更新 再进行之后的报错处理
if self.now_upgrade.upgrade_mode == MODE_UPGRADE_SINGLE:
if self.now_upgrade.upgrade_mode == self.MODE_UPGRADE_SINGLE:
self.action = self.ACTION_UPDATE
self._action_done(self.action,True,False,header,desc)
@ -105,7 +115,7 @@ class InstallBackend():
#检查依赖之前 判断是否需要重启aptdeamon
self.window_main.restart_aptdeamon()
time.sleep(0.5)
if _upgrade_mode != MODE_UPGRADE_SYSTEM:
if _upgrade_mode != self.MODE_UPGRADE_SYSTEM:
#获取要升级的组列表
self.now_upgrade.upgrade_groups,self.now_upgrade.single_pkgs = self._make_groups_list(self.upgrade_data,_upgrade_mode,partial_upgrade_list)
#获取要升级和安装的包列表
@ -141,7 +151,7 @@ class InstallBackend():
raw_description.append(getattr(pkg_obj.candidate, "summary", ''))
#解锁忙碌
self.window_main.is_working = self.ACTION_DEFUALT_STATUS
if _upgrade_mode != MODE_UPGRADE_SYSTEM:
if _upgrade_mode != self.MODE_UPGRADE_SYSTEM:
self.window_main.dbusController.UpdateDependResloveStatus(_success,is_remove_pkgs,pkgs_remove,raw_description,delete_desc,header,desc)
else:
self.window_main.dbusController.DistupgradeDependResloveStatus(_success,is_remove_pkgs,pkgs_remove,raw_description,header,desc)
@ -210,7 +220,7 @@ class InstallBackend():
pkgs_remove = []
#全盘升级不做任何的调整 修复bug出现调整版本报错不需要更新升级退出
if upgrade_mode == MODE_UPGRADE_SYSTEM:
if upgrade_mode == self.MODE_UPGRADE_SYSTEM:
adjust_pkgs = []
else:
#获取调整包列表 去掉版本号
@ -243,7 +253,7 @@ class InstallBackend():
pkg_list = []
#可选升级
if _upgrade_mode == MODE_UPGRADE_PARTIAL:
if _upgrade_mode == self.MODE_UPGRADE_PARTIAL:
for i in partial_upgrade_list:
#组升级方式
if i in upgrade_data.upgrade_groups:
@ -255,7 +265,7 @@ class InstallBackend():
logging.warning("this package(%s) not in selected list",i)
#全部升级列表
elif _upgrade_mode == MODE_UPGRADE_ALL:
elif _upgrade_mode == self.MODE_UPGRADE_ALL:
groups_list = upgrade_data.upgrade_groups
pkg_list = upgrade_data.single_pkgs
@ -344,100 +354,10 @@ class InstallBackend():
desc = str(e)
logging.error(header + desc)
msg = self._get_broken_details(self.cache)
msg = get_broken_details(self.cache,False)
logging.error(msg)
return _success,[],[],header,desc
def _get_broken_details(self,cache,now=False):
"""Return a message which provides debugging information about
broken packages.
This method is basically a Python implementation of apt-get.cc's
ShowBroken.
Keyword arguments:
trans -- the corresponding transaction
now -- if we check currently broken dependecies or the installation
candidate
"""
msg = _("The following packages have unmet dependencies:")
msg += "\n\n"
for pkg in cache:
if not ((now and pkg.is_now_broken) or
(not now and pkg.is_inst_broken)):
continue
msg += "%s: " % pkg.name
if now:
version = pkg.installed
else:
version = pkg.candidate
indent = " " * (len(pkg.name) + 2)
dep_msg = ""
for dep in version.dependencies:
or_msg = ""
for base_dep in dep.or_dependencies:
if or_msg:
or_msg += "or\n"
or_msg += indent
# Check if it's an important dependency
# See apt-pkg/depcache.cc IsImportantDep
# See apt-pkg/pkgcache.cc IsCritical()
if not (base_dep.rawtype in ["Depends", "PreDepends",
"Obsoletes", "DpkgBreaks",
"Conflicts"] or
(apt_pkg.config.find_b("APT::Install-Recommends",
False) and
base_dep.rawtype == "Recommends") or
(apt_pkg.config.find_b("APT::Install-Suggests",
False) and
base_dep.rawtype == "Suggests")):
continue
# Get the version of the target package
try:
pkg_dep = cache[base_dep.name]
except KeyError:
dep_version = None
else:
if now:
dep_version = pkg_dep.installed
else:
dep_version = pkg_dep.candidate
# We only want to display dependencies which cannot
# be satisfied
if dep_version and not apt_pkg.check_dep(base_dep.version,
base_dep.relation,
version.version):
break
or_msg = "%s: %s " % (base_dep.rawtype, base_dep.name)
if base_dep.version:
or_msg += "(%s %s) " % (base_dep.relation,
base_dep.version)
if self.cache.is_virtual_package(base_dep.name):
or_msg += _("but it is a virtual package")
elif not dep_version:
if now:
or_msg += _("but it is not installed")
else:
or_msg += _("but it is not going to "
"be installed")
elif now:
# TRANSLATORS: %s is a version number
or_msg += (("but %s is installed") %
dep_version.version)
else:
# TRANSLATORS: %s is a version number
or_msg += (("but %s is to be installed") %
dep_version.version)
else:
# Only append an or-group if at least one of the
# dependencies cannot be satisfied
if dep_msg:
dep_msg += indent
dep_msg += or_msg
dep_msg += "\n"
msg += dep_msg
return msg
#调用aptdeamon结束之后处理的地方 不管是出错还是正常都在此处理
def _action_done(self, action, authorized, success, error_string,error_desc):
self.window_main.is_working = self.ACTION_DEFUALT_STATUS
@ -459,7 +379,7 @@ class InstallBackend():
error_string, error_desc)
if success:
#当组列表为空时 表示现在的单独进行安装某些包或卸载,不发信号到控制面板
if self.now_upgrade.upgrade_mode != MODE_UPGRADE_SINGLE:
if self.now_upgrade.upgrade_mode != self.MODE_UPGRADE_SINGLE:
#升级完成后从升级列表删除
for groups in self.now_upgrade.upgrade_groups:
self.upgrade_data.upgrade_groups.remove(groups)
@ -469,15 +389,15 @@ class InstallBackend():
else:
#当单包升级的时候 升级本身时,让程序退出,再重新启动
if self.window_main.SELF_PKG_NAME in self.cache and self.cache[self.window_main.SELF_PKG_NAME] in self.cache.get_changes():
self.window_main.dbusController.UpdateDetectFinished(False,[self.window_main.SELF_PKG_NAME],"更新管理器升级完成,请重启控制面板进行系统更新",error_desc)
self.window_main.dbusController.DistUpdateDetectFinished(False,[self.window_main.SELF_PKG_NAME],"更新管理器升级完成,请重启控制面板进行系统更新",error_desc)
self.window_main.dbusController.Quit(None)
else:
#只有安装配置文件包 才会走到此处
self.window_main.start_available()
return
#当更新过程中安装配置包时 失败时发送错误信号
elif success == False and self.now_upgrade.upgrade_mode == MODE_UPGRADE_SINGLE:
self.window_main.dbusController.UpdateDetectFinished(success,upgrade_content,error_string+''+error_desc,error_desc)
elif success == False and self.now_upgrade.upgrade_mode == self.MODE_UPGRADE_SINGLE:
self.window_main.dbusController.DistUpdateDetectFinished(success,upgrade_content,error_string+''+error_desc,error_desc)
if error_string != '' or error_desc != '':
logging.info(error_string + error_desc)
@ -492,10 +412,11 @@ class InstallBackend():
#开始生成列表
self.window_main.start_available()
else:
self.window_main.dbusController.UpdateDetectFinished(success,[],error_string+''+error_desc,error_desc)
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...")
self.window_main.start_available()
# self.window_main.start_available()
elif action == self.ACTION_FIX_INCOMPLETE:
if success:
logging.info("fix incomplete install success.")

View File

@ -208,26 +208,31 @@
后端日志:`/var/log/kylin-system-updater/kylin-system-updater.log.1`
### 更新过程报错信息总结
| 错误信息 | 错误原因 | 解决办法 |
| -------------------- | ---------------------------------- | -------------------------------------------- |
| 下载软件仓库信息失败 | 源存在问题使用apt update检查 | 检查源是否正确或者检查网络DNS等等 |
| 无法访问源管理服务器 | 源管理服务器存在问题 | 源管理服务器是否通或者检查源服务器与客户端版 |
| 软件索引已经损坏 | 当前系统中cache被破坏apt无法使用 | 终端检查错误原因进行解决 |
| 无法初始化软件包信息 | apt存在某些问题 | 具体错误原因查看日志相应解决 |
| | | |
| | | |
| 错误信息 | 错误原因 | 解决办法 |
| -------------------- | ------------------------------------------------------------ | ---------------------------------------- |
| 下载软件仓库信息失败 | 源存在问题使用apt update检查若存在报错则更新管理器无问题 | 检查源是否可以使用 |
| 无法访问源管理服务器 | 源管理服务器存在问题 | 源管理服务器是否可用或者检查源服务器配置 |
| 软件索引已经损坏 | 当前系统中cache被破坏apt无法使用 | 终端检查错误原因进行解决 |
| 无法初始化软件包信息 | apt存在某些问题 | 具体错误原因查看日志相应解决 |
| 无法获取组配置软件包 | 源中不存在kylin-update-desktop-config | 将此包放入源仓库或者写配置文件不强制安装 |
| 无法读取推送升级列表 | 读取推送列表出现问题 | 检查important.list是否存在 |
| 获取软件推送失败 | 老版本文案同 无法访问源管理服务器解决 | |
### 安装过程报错信息总结
| 错误信息 | 错误原因 | 解决办法 |
| ------------------ | ------------------------------ | --------------------------------- |
| 软件包操作失败 | 被升级的软件包有问题 | 检查后端log日志查看那个包存在问题 |
| 下载软件包文件失败 | 网络原因的或者这个软件包的仓库 | 检查网络以及源仓库 |
| | | |
| 错误信息 | 错误原因 | 解决办法 |
| ------------------ | ------------------------------ | ---------------------------------- |
| 软件包操作失败 | 被升级的软件包有问题 | 检查后端log日志查看那个包存在问题 |
| 下载软件包文件失败 | 网络原因的或者这个软件包的仓库 | 检查网络以及源仓库 |
| 磁盘空间不足 | 磁盘的空间不足 | 查看日志那些目录空间不足 |
| 不能计算升级 | 无法计算依赖关系 | 检查日志那个包出现的问题,相应解决 |
| | | |

View File

@ -2590,4 +2590,32 @@ msgid "Checking network connection"
msgstr "检查网络连接中"
msgid "Updating Source Template"
msgstr "更新源摸板中"
msgstr "更新源摸板中"
#: ../aptdaemon/worker/aptworker.py:1353
msgid "The following packages have unmet dependencies:"
msgstr "下列软件包未满足的依赖关系:"
#: ../aptdaemon/worker/aptworker.py:1406
msgid "but it is a virtual package"
msgstr "但是它是虚拟软件包"
#: ../aptdaemon/worker/aptworker.py:1409
msgid "but it is not installed"
msgstr "但是 %s 没有安装"
#: ../aptdaemon/worker/aptworker.py:1411
msgid "but it is not going to be installed"
msgstr "但是无法安装 %s"
#. TRANSLATORS: %s is a version number
#: ../aptdaemon/worker/aptworker.py:1415
#, python-format
msgid "but %s is installed"
msgstr "但是 %s 已经安装"
#. TRANSLATORS: %s is a version number
#: ../aptdaemon/worker/aptworker.py:1419
#, python-format
msgid "but %s is to be installed"
msgstr "但是将要安装 %s"

51
debian/changelog vendored
View File

@ -1,13 +1,62 @@
kylin-system-updater (1.2.11.2kord) v101; urgency=medium
kylin-system-updater (1.2.13.1kord) v101; urgency=medium
* BUG: #89461:【系统更新】全部更新过程中,点击详情无更新进度;安装过程中点击详情不会显示安装进度
* #93309:【系统升级】更新过程中,取消按钮置灰无法点击
* #89535:【更新升级-需求-9002】【系统更新】全部更新-备份及更新过程中需屏蔽单个更新按键
* 需求号: 无
* 其他改动说明:增加获取破损包的依赖错误描述,状态保留增加取消功能
* 其他改动影响域:系统更新
-- luoxueyi <luoxueyi@kylinos.cn> Thu, 25 Nov 2021 23:36:16 +0800
kylin-system-updater (1.2.13kord) v101; urgency=medium
* BUG: #89461:【系统更新】全部更新过程中,点击详情无更新进度;安装过程中点击详情不会显示安装进度
* #93309:【系统升级】更新过程中,取消按钮置灰无法点击
* #89535:【更新升级-需求-9002】【系统更新】全部更新-备份及更新过程中需屏蔽单个更新按键
* 需求号: 无
* 其他改动说明:增加获取破损包的依赖错误描述,状态保留增加取消功能
* 其他改动影响域:系统更新
-- luoxueyi <luoxueyi@kylinos.cn> Thu, 25 Nov 2021 23:36:16 +0800
kylin-system-updater (1.2.12.2kord) v101; urgency=medium
* BUG: 无
* 需求号: 无
* 其他改动说明:增加获取破损包的依赖错误描述,状态保留增加取消功能,优化静态变量
* 其他改动影响域:
-- luoxueyi <luoxueyi@kylinos.cn> Thu, 25 Nov 2021 20:44:05 +0800
kylin-system-updater (1.2.12.1kord) v101; urgency=medium
* BUG: 无
* 需求号: 无
* 其他改动说明:增加获取破损包的依赖错误描述,状态保留增加取消功能,优化静态变量
* 其他改动影响域:
-- luoxueyi <luoxueyi@kylinos.cn> Thu, 25 Nov 2021 16:43:54 +0800
kylin-system-updater (1.2.12kord) v101; urgency=medium
* BUG: #89818:【系统更新】将系统字体调整为最大,控制面板-更新界面"您的系统已是最新未跟随改变";且界面显示不全
* #89554:【系统更新】控制面板-更新界面没有兼容ukui3.1
* #89817:【系统更新】控制面板-更新界面未进行汉化
<<<<<<< HEAD
* 需求号: 无
* 其他改动说明:增加自主升级功能
* 其他改动影响域: 影响更新检测功能,在更新检测时将更新系统升级包本身
-- luoxueyi <luoxueyi@kylinos.cn> Wed, 24 Nov 2021 09:42:59 +0800
=======
* #89810:【系统更新】全部更新缺少错误原因提示,且取消全部下载建议提示下载取消。将依赖冲突的包以虚包形式进行全部更新,提示部分更新失败;空间少于备份空间或者安装包的空间,全部更新后提示部分更新失败。都未展示实际原因
* 需求号: 无
* 其他改动说明:增加自主升级功能,优化进度显示保持功能
* 其他改动影响域: 影响更新检测功能,在更新检测时将更新系统升级包本身
-- luoxueyi <luoxueyi@kylinos.cn> Wed, 24 Nov 2021 17:41:34 +0800
>>>>>>> b4b42855e832b7d7c19d53959296fda1cf68b54a
kylin-system-updater (1.2.9kord) v101; urgency=medium

3
debian/control vendored
View File

@ -52,7 +52,8 @@ Depends: ${python3:Depends},
python3-dbus,
python3-gi (>= 3.8),
python3-yaml,
ukui-control-center (>= 3.1.1+1103)
aptdaemon,
ukui-control-center (>= 3.1.1+1103)
Breaks:
Recommends: python3-launchpadlib
Suggests: gir1.2-dbusmenu-glib-0.4,