Merge branch 'backend_manual' into 'backend_uu'

修改dpkg装包错误信息

See merge request kylin-desktop/update-manager-group/kylin-system-updater!452
This commit is contained in:
luoxueyi 2022-06-28 10:17:09 +00:00
commit 660c2d4812
12 changed files with 374 additions and 108 deletions

View File

@ -579,7 +579,7 @@ def get_east_8_time():
return now_time
# return 0
if __name__ == "__name__":
if __name__ == "__main__":
# 执行定时发送
ms = MessageSend()
ms._ReadFromFile("/var/lib/kylin-system-updater/sendinfos/testMsg.json")

View File

@ -19,13 +19,9 @@ class LogInstallProgress(apt.progress.base.InstallProgress):
self.errormsg=""
def error(self,pkg, errormsg):
logging.info(("errormsg:%s"),errormsg)
logging.error(("Install mode - dpkg, Install error: %s"), errormsg)
self.error_pkg=self.filename
self.errormsg = errormsg
global error_status
global error_msg
error_status=1
error_msg=errormsg
def status_change(self, pkg, percent, status):
# type: (str, float, str) -> None
@ -114,14 +110,11 @@ class LogInstallProgress(apt.progress.base.InstallProgress):
os.close(logfd)
def finish_update(self):
# type: () -> None
# logging.info("finished")
# if error_status == 1:
# os._exit(1)
pass
def fork(self):
# type: () -> int
pid = os.fork()
if pid == 0:
self._fixup_fds()

View File

@ -59,11 +59,10 @@ class UpdateList():
if self.parent.options.close_filter == False and self.parent.source_info.is_disc == False and \
self.parent.configs_cover.getWithDefault("SystemStatusCover", "close_source_filter", False) == False :
#开启原过滤
self.close_filter = False
self.fu = UpdateListFilterCache(self.parent)
else:
self.fu = None
logging.info("Close to Allowed origin fiter...")
self.close_filter = True
#清空上次输出的分组JSON文件
@ -106,13 +105,11 @@ class UpdateList():
tmp.append(pkg_obj)
else:
upgradeable_groups.append(pkg_name)
if tmp != [] or self.close_filter == False:
if tmp != []:
install_list,upgrade_list,adjust_pkgs = self._make_fiter_origin(tmp,True)
self.upgrade_meta.adjust_pkgs.extend(adjust_pkgs)
upgradeable_pkgs = install_list + upgrade_list
else:
upgradeable_pkgs = tmp
logging.info("Push Single Packages: %a, Push Groups:%a",upgradeable_pkgs,upgradeable_groups)
return upgradeable_groups,upgradeable_pkgs
@ -193,19 +190,25 @@ class UpdateList():
def _make_fiter_origin(self,pkgs_list,adjust_versions):
install_pkgs = []
upgrade_pkgs = []
adjust_pkgs = []
try:
after_pkgs_list,adjust_pkgs = self.fu.check_in_allowed_origin(pkgs_list,adjust_versions)
except Exception as e:
logging.error(str(e))
#是否进行源过滤的选项
if self.fu != None:
try:
after_pkgs_list,adjust_pkgs = self.fu.check_in_allowed_origin(pkgs_list,adjust_versions)
except Exception as e:
after_pkgs_list = pkgs_list
logging.error("Check Allowed origin is occur error:" + str(e))
else:
after_pkgs_list = pkgs_list
adjust_pkgs = []
for pkg_obj in after_pkgs_list:
if pkg_obj.is_installed:
upgrade_pkgs.append(pkg_obj.name)
else:
install_pkgs.append(pkg_obj.name)
return install_pkgs,upgrade_pkgs,adjust_pkgs
#从本地中获取本次升级需要升级的包 部分升级和全部升级使用 全盘升级不适用

View File

@ -32,8 +32,9 @@ class UpgradeConfig(SafeConfigParser):
def setValue(self, section, option, value=None,is_write = True):
if option != 'upgradelist':
logging.info("SetValue Section:%s Option:%s Value:%s",section, option, value)
try:
self.reReadConfigFiles()
self.set(section, option,value)
except Exception as e:
logging.error("Error: setValue section:%s option:%s value:%s",section, option, value)

View File

@ -7,7 +7,7 @@ __all__ = (
"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_NOT_CONFIGPKG_DEPENDENCIES","ERROR_NOT_SELFPKG_DEPENDENCIES",
"ERROR_NOT_FIX_SYSTEM",
"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")
@ -31,6 +31,8 @@ ERROR_NOT_GROUPS_CONFIG = "error-not-groups-config"
ERROR_NOT_CONFIGPKG_DEPENDENCIES = "error-not-configpkg-dependencies"
ERROR_NOT_SELFPKG_DEPENDENCIES = "error-not-selfpkg-dependencies"
ERROR_NOT_FIX_SYSTEM = "error-not-fix-system"
#自己的
ERROR_SOFTWARE_INDEX_RROKEN = "error-software-index-broken"
ERROR_NOT_INIT_PACKAGESINFIO = "error-not-init-packagesinfo"
@ -56,7 +58,8 @@ _STRINGS_ERROR = {
ERROR_NOT_GROUPS_CONFIG: _("Upgrade configuration acquisition exception."),
ERROR_NOT_CONFIGPKG_DEPENDENCIES: _("Upgrade configuration acquisition exception."),
ERROR_NOT_SELFPKG_DEPENDENCIES: _("Priority upgrade status exception."),
ERROR_NOT_FIX_SYSTEM: _("Check for update exceptions,fix system APT environment error."),
#install
ERROR_RESOLVER_FAILED: _("Could not calculate the upgrade"),
@ -85,6 +88,8 @@ _DESCS_ERROR = {
ERROR_NOT_CONFIGPKG_DEPENDENCIES: _("Unable to install group configuration package, Please check the configuration package related dependencies."),
ERROR_NOT_SELFPKG_DEPENDENCIES: _("Unable to perform priority upgrade, please check the dependency related to the priority upgrade package."),
ERROR_NOT_FIX_SYSTEM: _("The system APT environment is abnormal, please check the system APT environment."),
#install
ERROR_RESOLVER_FAILED: _("nothing"),
ERROR_NOT_UPGRADE_PACKAGES: _("This update cannot detect the upgradeable package."),

View File

@ -20,7 +20,7 @@ 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 .UpdateManagerDbus import UpdateManagerDbusController,UpdateManagerDbusControllerUtils,UPDATER_DBUS_INTERFACE,UPDATER_DBUS_PATH,UPDATER_DBUS_SERVICE
from .Core.UpdateList import UpdateList
from .backend import InstallBackend,get_backend
from .Core.Database import Sqlite3Server
@ -50,6 +50,7 @@ class UpdateManager():
self.config_path = self.check_config_patch()
#建立dbus
self.dbusController = self._setup_dbus()
self.dbusControllerUtils = self._setup_dbus_utils()
#配置文件
self.configs_uncover = UpgradeConfig(defaults_dir="system-updater-defaults.conf")
@ -236,7 +237,7 @@ class UpdateManager():
except Exception as e:
logging.error(e)
def start_update_backend(self,update_mode = InstallBackend.MODE_UPDATE_ALL):
def start_update_backend(self,update_mode = InstallBackend.MODE_UPDATE_CACHE):
try:
#调用aptdeamon进行update
update_backend = get_backend(self, InstallBackend.ACTION_UPDATE,update_mode)
@ -317,9 +318,15 @@ class UpdateManager():
self_pkg.installed.source_version,self_pkg.candidate.source_version)
if pkg_name in important_list:
try:
if self.update_list.fu != None:
after_pkgs_list,adjust_pkgs = self.update_list.fu.check_in_allowed_origin([self_pkg],True)
if after_pkgs_list == [] and adjust_pkgs == []:
logging.info("Check: (%s) will not upgrading From %s to %s,duo to not locate at Allowed origins...",pkg_name,\
self_pkg.installed.source_version,self_pkg.candidate.source_version)
continue
logging.info("Check: (%s) start upgrading From %s to %s...",pkg_name,\
self_pkg.installed.source_version,self_pkg.candidate.source_version)
pkg_json.mark_install(True,False,True)
self_pkg.mark_install(True,False,True)
self_upgrade.append(pkg_name)
need_upgrade = True
except SystemError:
@ -336,14 +343,20 @@ class UpdateManager():
#config包
for pkg_name in [self.GROUPS_PKG_NAME]:
if pkg_name in cache:
pkg_json = cache[pkg_name]
if pkg_json.is_installed:
if pkg_json.is_upgradable:
self_pkg = cache[pkg_name]
if self_pkg.is_installed:
if self_pkg.is_upgradable:
if self.update_list.fu != None:
after_pkgs_list,adjust_pkgs = self.update_list.fu.check_in_allowed_origin([self_pkg],True)
if after_pkgs_list == [] and adjust_pkgs == []:
logging.info("Check: (%s) will not upgrading From %s to %s,duo to not locate at Allowed origins...",pkg_name,\
self_pkg.installed.source_version,self_pkg.candidate.source_version)
continue
self.dbusController.UpdateDetectStatusChanged(95,_("Group configuration being updated"))
logging.info("Check: groups JSON ConfigPkgs(%s) start upgrading From %s to %s...",pkg_name,\
pkg_json.installed.source_version,pkg_json.candidate.source_version)
self_pkg.installed.source_version,self_pkg.candidate.source_version)
try:
pkg_json.mark_install()
self_pkg.mark_install()
self_upgrade.append(pkg_name)
need_upgrade = True
except SystemError:
@ -351,12 +364,18 @@ class UpdateManager():
self.simulate_mode.thread_install([pkg_name])
raise UpdateBaseError(ERROR_NOT_CONFIGPKG_DEPENDENCIES)
else:
logging.info("Check: ConfigPkgs(%s:%s) No need to upgrade...",pkg_name,pkg_json.installed.source_version)
logging.info("Check: ConfigPkgs(%s:%s) No need to upgrade...",pkg_name,self_pkg.installed.source_version)
else:
self.dbusController.UpdateDetectStatusChanged(95,_("Group configuration being updated"))
if self.update_list.fu != None:
after_pkgs_list,adjust_pkgs = self.update_list.fu.check_in_allowed_origin([self_pkg],True)
if after_pkgs_list == [] and adjust_pkgs == []:
logging.info("Check: (%s) will not upgrading From %s to %s,duo to not locate at Allowed origins...",pkg_name,\
self_pkg.installed.source_version,self_pkg.candidate.source_version)
continue
logging.info("Check: groups JSON ConfigPkgs(%s) start new installing...",pkg_name)
try:
pkg_json.mark_install(True,False,True)
self_pkg.mark_install(True,False,True)
self_upgrade.append(pkg_name)
need_upgrade = True
except SystemError:
@ -438,6 +457,7 @@ class UpdateManager():
bus,
do_not_queue=True)
logging.info("Initiate dbus success ...")
UpdateManagerDbusControllerUtils(self, bus_name)
return UpdateManagerDbusController(self, bus_name)
except dbus.exceptions.NameExistsException:
if self.options.replace is False:
@ -470,20 +490,57 @@ class UpdateManager():
timeout=300)
logging.error("Dbus has not withdrawn and retry reboot times:%d...",retry_reboot_times)
time.sleep(1)
def start_back_upgrade(self, pkglist, update_cache = False):
def _setup_dbus_utils(self):
# check if there is another g-a-i already and if not setup one
# listening on dbus
bus = dbus.SystemBus()
try:
if (update_cache):
update_backend = get_backend(self, InstallBackend.ACTION_UPDATE, InstallBackend.MODE_UPDATE_CACHE)
update_backend.start(partial_upgrade_list = pkglist)
else:
install_backend = get_backend(self, InstallBackend.ACTION_BACKGROUND_UPGRADE)
install_backend.start_alone(partial_upgrade_list = pkglist)
bus_name = dbus.service.BusName(UPDATER_DBUS_SERVICE,
bus,
do_not_queue=True)
return UpdateManagerDbusControllerUtils(self, bus_name)
except dbus.exceptions.NameExistsException:
if self.options.replace is False:
logging.critical("Another daemon is already running")
sys.exit(1)
logging.warning("Replacing already running daemon")
retry_reboot_times = 0
the_other_guy = bus.get_object(UPDATER_DBUS_SERVICE,
UPDATER_DBUS_PATH)
the_other_guy.Quit(dbus_interface=UPDATER_DBUS_INTERFACE,
timeout=300)
time.sleep(1)
while True:
retry_reboot_times = retry_reboot_times + 1
#当重试次数超过5次时退出程序
if retry_reboot_times > 5:
logging.critical("Reboot backend is Failed...")
sys.exit(1)
try:
bus_name = dbus.service.BusName(UPDATER_DBUS_SERVICE,
bus,
do_not_queue=True)
logging.warning("Replacing already running daemon to Success...")
return UpdateManagerDbusController(self, bus_name)
except dbus.exceptions.NameExistsException:
the_other_guy = bus.get_object(UPDATER_DBUS_SERVICE,
UPDATER_DBUS_PATH)
the_other_guy.Quit(dbus_interface=UPDATER_DBUS_INTERFACE,
timeout=300)
logging.error("Dbus has not withdrawn and retry reboot times:%d...",retry_reboot_times)
time.sleep(1)
def start_back_upgrade(self, pkglist):
try:
install_backend = get_backend(self, InstallBackend.ACTION_BACKGROUND_UPGRADE)
install_backend.start_alone(partial_upgrade_list = pkglist)
except Exception as e:
logging.error(str(e))
# 进行本地deb包安装的操作
def start_deb_install(self, deb_path = "", _check_local_dep = False, _auto_satisfy = False, sender=None):
def start_deb_install(self, deb_path = "", _check_local_dep = False, _auto_satisfy = False, source = '', sender=None):
# _check_local_dep : 是否查询本地依赖
# _auto_satisfy : 是否通过网络下载依赖
header = ''
@ -685,6 +742,8 @@ class UpdateManager():
deb = DebPackage(os.path.join(absolute_path,satisfy))
iprogress = LogInstallProgress(deb_path)
ret = deb.install(install_progress=iprogress)
if ret != 0:
return False, iprogress.errormsg, desc
except Exception as e:
logging.error(e)
return False, str(e), desc

View File

@ -23,6 +23,7 @@ UPDATER_DBUS_PATH = '/com/kylin/systemupgrade'
UPDATER_DBUS_SERVICE = 'com.kylin.systemupgrade'
RUN_UNATTENDED_UPGRADE = '/var/run/unattended-upgrades.pid'
SYSTEM_VERSION = '/etc/kylin-version/kylin-system-version.conf'
UPDATER_DBUS_PATH_UTILS = '/com/kylin/systemupgrade/utils'
#颜色设置
COLORLOG_SUFFIX = "\033[0m"
@ -60,6 +61,7 @@ class UpdateManagerDbusController(dbus.service.Object):
self.transaction = None
def _update_important_reply(self,retval):
if bool(retval) == False:
self.UpdateDetectFinished(False,[''],enums.get_error_string_from_enum(enums.ERROR_UPDATE_SOURCE_FAILED),\
@ -262,7 +264,7 @@ class UpdateManagerDbusController(dbus.service.Object):
return True
except Exception:
return False
#更新的dbus
@dbus.service.method(UPDATER_DBUS_INTERFACE,out_signature='bs',sender_keyword='sender')
def UpdateDetect(self,sender=None):
@ -356,10 +358,23 @@ class UpdateManagerDbusController(dbus.service.Object):
return (False, str(e))
#卸载包
@dbus.service.method(UPDATER_DBUS_INTERFACE,in_signature='ass',out_signature='bs',sender_keyword='sender')
def PurgePackages(self,_purge_list,cur_user,sender=None):
@dbus.service.method(UPDATER_DBUS_INTERFACE,in_signature='asss',out_signature='bs',sender_keyword='sender')
def PurgePackages(self,_purge_list,cur_user,user_lang = '', sender=None):
try:
#当传入为空时 直接返回
if str(user_lang) == '':
logging.info("The incoming language is null...")
else:
(lang, encoding) = locale._parse_localename(str(user_lang))
#合法性的校验
if lang == None or lang == '':
logging.info("The incoming language is Illegal...")
if lang != os.environ["LANGUAGE"]:
logging.warning("The system language is switched %s to %s",os.environ["LANGUAGE"],lang)
os.environ["LANGUAGE"] = lang
reload(enums)
sender_name = get_proc_from_dbus_name(sender)
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' DistPurgePackages Sender:%s and purge list is:%s...',sender_name,_purge_list)
(status, details) = PolicyKit_Authority(get_source_name_from_enum(sender_name)+_(" requires authentication to uninstall software packages."), sender)
if not status:
self.PurgePackagesFinished(False,details,'')
@ -379,8 +394,6 @@ class UpdateManagerDbusController(dbus.service.Object):
logging.warning('PurgePackages In the process of updating or Upgrading...')
return False,'PurgePackages In the process of updating or Upgrading...'
else:
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' DistPurgePackages Sender:%s and purge list is:%s...',sender_name,purge_list)
self._check_prohibit_user(sender_name)
self.parent.start_purge_pkgs(purge_list)
@ -416,24 +429,67 @@ class UpdateManagerDbusController(dbus.service.Object):
# 安装本地deb包
@dbus.service.method(UPDATER_DBUS_INTERFACE,in_signature='ssbb',out_signature='b',sender_keyword='sender')
def InstallDebFile(self,source = "unKnown", path = "", _check_local_dep = False, _auto_satisfy = False,sender=None):
@dbus.service.method(UPDATER_DBUS_INTERFACE,in_signature='ssbbs',out_signature='b',sender_keyword='sender')
def InstallDebFile(self,source = "unKnown", path = "", _check_local_dep = False, _auto_satisfy = False, user_lang = '', sender=None):
try:
#当传入为空时 直接返回
if str(user_lang) == '':
logging.info("The incoming language is null...")
else:
(lang, encoding) = locale._parse_localename(str(user_lang))
#合法性的校验
if lang == None or lang == '':
logging.info("The incoming language is Illegal...")
if lang != os.environ["LANGUAGE"]:
logging.warning("The system language is switched %s to %s",os.environ["LANGUAGE"],lang)
os.environ["LANGUAGE"] = lang
reload(enums)
sender_name = get_proc_from_dbus_name(sender)
self._check_prohibit_user(sender_name)
check_local_dep = bool(_check_local_dep)
auto_satisfy = bool(_auto_satisfy)
deb_path = str(path)
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' InstallDebFile and check_local_dep:%r, auto_satisfy:%r.',\
check_local_dep,auto_satisfy)
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' InstallDebFile and check_local_dep:%r, auto_satisfy:%r, current_lang:%s .',\
check_local_dep,auto_satisfy,user_lang)
logging.info("Will install: %s.",path)
self.parent.start_deb_install(deb_path, _check_local_dep, _auto_satisfy,sender)
self.parent.start_deb_install(deb_path, _check_local_dep, _auto_satisfy, source, sender)
return True
except Exception as e:
logging.error(str(e))
return (False)
# commitpackages
@dbus.service.method(UPDATER_DBUS_INTERFACE,in_signature='as',out_signature='b',sender_keyword='sender')
def InstallPackages(self, pkg_list = [], sender=None):
try:
sender_name = get_proc_from_dbus_name(sender)
self._check_prohibit_user(sender_name)
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' InstallPackages : [%s].', ", ".join(list(pkg_list)))
self.parent.start_back_upgrade(pkg_list)
except Exception as e:
logging.error(str(e))
return (False)
return True
#更新的dbus
@dbus.service.method(UPDATER_DBUS_INTERFACE,out_signature='bs',sender_keyword='sender')
def UpdateCache(self,sender=None):
try:
#处于更新和升级中的话 不进行更新
if self.parent.now_working != InstallBackend.ACTION_DEFUALT_STATUS:
logging.warning('UpdateDetect In the process of Updating or Upgrading...')
return False,'In the process of updating or Upgrading...'
else:
sender_name = get_proc_from_dbus_name(sender)
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' UpdateCache sender:%s...',sender_name)
self._check_prohibit_user(sender_name)
self.parent.start_update_backend()
return True,'success'
except Exception as e:
logging.error(str(e))
return False,str(e)
# dbus接口向数据库display表中插入数据
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='ss', out_signature='b', sender_keyword='sender')
def InsertInstallState(self, item, value, sender=None):
@ -524,14 +580,6 @@ class UpdateManagerDbusController(dbus.service.Object):
except:
return False, "0"
# # dbus接口: 后端大数据采集
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='ss', out_signature='b')
def DataBackendCollect(self, messageType, uploadMessage):
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' DataBackendCollect, messageType is %s ...',messageType)
try:
self.parent.collector.UpdateMsg(messageType, uploadMessage)
except Exception as e:
logging.error(str(e))
## dbus接口: 开启或关闭预下载功能
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='b', out_signature='b')
@ -706,45 +754,6 @@ class UpdateManagerDbusController(dbus.service.Object):
logging.info('Current os_version: %s, release_id: %s .', os_version, update_version)
return os_version,update_version
# commitpackages
@dbus.service.method(UPDATER_DBUS_INTERFACE,in_signature='sasb',out_signature='b',sender_keyword='sender')
def InstallPkgs(self,source = "unKnown", pkg_list = [], update_cache = False, sender=None):
try:
sender_name = get_proc_from_dbus_name(sender)
self._check_prohibit_user(sender_name)
if update_cache:
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' InstallPkgs (UPDATE_CACHE).')
else:
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' InstallPkgs : [%s].', pkg_list)
self.parent.start_back_upgrade(pkg_list, update_cache)
except Exception as e:
logging.error(str(e))
return (False)
return True
# 检查更新
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='as', out_signature='as', sender_keyword='sender')
def CheckInstalledOrUpgrade(self, pkgs, sender=None):
# logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' CheckInstalledOrUpgrade Parsed silent upgrade ...')
try:
pkglist = []
cache = MyCache(None)
self.parent.collector.cache = cache
for i in pkgs:
name = str(i).strip().replace("\n", "")
if name in cache:
pkg = cache[name]
if pkg.is_installed == False or pkg.is_upgradable == True:
pkglist.append(pkg.name)
pkglist.append(str(pkg.candidate.size))
self.parent.collector.make_background_version(pkg)
self.parent.collector.background_upgradable.append(pkg.name)
except:
logging.error("CheckInstalledOrUpgrade: Failed to obtain package information: %s" % str(i), exc_info=True)
# logging.info("All silent upgrade: %s.",pkglist)
return pkglist
#更新进度信息 0~100 进度信息 101为非预期的信号
@dbus.service.signal(UPDATER_DBUS_INTERFACE,signature='is')
def UpdateDetectStatusChanged(self,progress,status):
@ -985,8 +994,6 @@ class UpdateManagerDbusController(dbus.service.Object):
self.parent.configs_uncover.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_uncover.setValue("SystemStatus","upload_upgrade_log",str(bool(value)))
else:
raise dbus.exceptions.DBusException("Unknown or read only "
"property: %s" % name)
@ -1001,8 +1008,184 @@ class UpdateManagerDbusController(dbus.service.Object):
"ShutdownInstall": dbus.Boolean(
self.parent.configs_uncover.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())
}
else:
return {}
class UpdateManagerDbusControllerUtils(dbus.service.Object):
""" this is a helper to provide the UpdateManagerIFace """
def __init__(self, parent, bus_name,
object_path=UPDATER_DBUS_PATH_UTILS):
try:
dbus.service.Object.__init__(self, bus_name, object_path)
except Exception as e:
# pass
logging.warning(e)
self.parent = parent
self.bus = dbus.SystemBus()
self.transaction = None
def _check_prohibit_user(self, sender_name):
prohibit_list = ["dbus-send","gdbus"]
if sender_name in prohibit_list:
raise dbus.exceptions.DBusException("ERROR: You are not allowed to perform this action.")
# # dbus接口: 后端大数据采集
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='ss', out_signature='b')
def DataBackendCollect(self, messageType, uploadMessage):
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' DataBackendCollect, messageType is %s ...',messageType)
try:
self.parent.collector.UpdateMsg(messageType, uploadMessage)
except Exception as e:
logging.error(str(e))
# 检查更新
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='as', out_signature='as', sender_keyword='sender')
def CheckInstalledOrUpgrade(self, pkgs, sender=None):
# logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' CheckInstalledOrUpgrade Parsed silent upgrade ...')
try:
pkglist = []
cache = MyCache(None)
self.parent.collector.cache = cache
for i in pkgs:
name = str(i).strip().replace("\n", "")
if name in cache:
pkg = cache[name]
if pkg.is_installed == False or pkg.is_upgradable == True:
pkglist.append(pkg.name)
pkglist.append(str(pkg.candidate.size))
self.parent.collector.make_background_version(pkg)
self.parent.collector.background_upgradable.append(pkg.name)
except:
logging.error("CheckInstalledOrUpgrade: Failed to obtain package information: %s" % str(i), exc_info=True)
logging.info("All silent upgrade: %s.",pkglist)
return pkglist
WRITABLE_PROPERTIES = ()
# pylint: disable-msg=C0103,C0322
@dbus.service.signal(dbus_interface=dbus.PROPERTIES_IFACE,
signature="sa{sv}as")
def PropertiesChanged(self, interface, changed_properties,
invalidated_properties):
"""The signal gets emitted if a property of the object's
interfaces changed.
:param property: The name of the interface.
:param changed_properties: A dictrionary of changed
property/value pairs
:param invalidated_properties: An array of property names which
changed but the value isn't conveyed.
:type interface: s
:type changed_properties: a{sv}
:type invalidated_properties: as
"""
logging.info("Emitting PropertiesChanged: %s, %s, %s" %
(interface, changed_properties, invalidated_properties))
# pylint: disable-msg=C0103,C0322
@dbus.service.method(dbus.INTROSPECTABLE_IFACE,
in_signature='', out_signature='s',
path_keyword='object_path',
connection_keyword='connection')
def Introspect(self, object_path, connection):
# Inject the properties into the introspection xml data
data = dbus.service.Object.Introspect(self, object_path, connection)
xml = ElementTree.fromstring(data)
for iface in xml.findall("interface"):
props = self._get_properties(iface.attrib["name"])
for key, value in props.items():
attrib = {"name": key}
if key in self.WRITABLE_PROPERTIES:
attrib["access"] = "readwrite"
else:
attrib["access"] = "read"
if isinstance(value, dbus.String):
attrib["type"] = "s"
elif isinstance(value, dbus.UInt32):
attrib["type"] = "u"
elif isinstance(value, dbus.Int32):
attrib["type"] = "i"
elif isinstance(value, dbus.UInt64):
attrib["type"] = "t"
elif isinstance(value, dbus.Int64):
attrib["type"] = "x"
elif isinstance(value, dbus.Boolean):
attrib["type"] = "b"
elif isinstance(value, dbus.Struct):
attrib["type"] = "(%s)" % value.signature
elif isinstance(value, dbus.Dictionary):
attrib["type"] = "a{%s}" % value.signature
elif isinstance(value, dbus.Array):
attrib["type"] = "a%s" % value.signature
else:
raise Exception("Type %s of property %s isn't "
"convertable" % (type(value), key))
iface.append(ElementTree.Element("property", attrib))
new_data = ElementTree.tostring(xml, encoding="UTF-8")
return new_data
# pylint: disable-msg=C0103,C0322
@dbus.service.method(dbus.PROPERTIES_IFACE,
in_signature="ssv", out_signature="",
sender_keyword="sender")
def Set(self, iface, name, value, sender):
"""Set a property.
Only the user who intiaited the transaction is
allowed to modify it.
:param iface: The interface which provides the property.
:param name: The name of the property which should be modified.
:param value: The new value of the property.
:type iface: s
:type name: s
:type value: v
"""
logging.info("Set() was called: %s, %s" % (name, value))
return self._set_property(iface, name, value, sender)
# pylint: disable-msg=C0103,C0322
@dbus.service.method(dbus.PROPERTIES_IFACE,
in_signature="s", out_signature="a{sv}")
def GetAll(self, iface):
"""Get all available properties of the given interface."""
logging.info("GetAll() was called: %s" % iface)
return self._get_properties(iface)
# pylint: disable-msg=C0103,C0322
@dbus.service.method(dbus.PROPERTIES_IFACE,
in_signature="ss", out_signature="v")
def Get(self, iface, property):
"""Return the value of the given property provided by the given
interface.
"""
logging.info("Get() was called: %s, %s" % (iface, property))
return self._get_properties(iface)[property]
def _set_property(self, iface, name, value, sender):
"""Helper to set a property on the properties D-Bus interface."""
if iface == UPDATER_DBUS_INTERFACE:
if name == "UploadUpgradeLog":
self.parent.configs_uncover.setValue("SystemStatus","upload_upgrade_log",str(bool(value)))
else:
raise dbus.exceptions.DBusException("Unknown or read only "
"property: %s" % name)
else:
raise dbus.exceptions.DBusException("Unknown interface: %s" %
iface)
def _get_properties(self, iface):
"""Helper get the properties of a D-Bus interface."""
if iface == UPDATER_DBUS_INTERFACE:
return {
"UploadUpgradeLog": dbus.Boolean(
self.parent.configs_uncover.getWithDefault("SystemStatus", "upload_upgrade_log", False))
}

View File

@ -255,7 +255,7 @@ class InstallBackend():
self.fix_incomplete()
#卸载包
elif self.action == self.ACTION_REMOVE_PACKAGES:
self._start_install_lock()
# self._start_install_lock()
self.purge_packages(partial_upgrade_list)
elif self.action == self.ACTION_CLEAN:
self.clean()
@ -275,7 +275,7 @@ class InstallBackend():
# 安装本地deb包的接口
if self.action == self.ACTION_INSTALL_DEB:
try:
self._start_install_lock()
# self._start_install_lock()
self.install_deb(install_path = partial_upgrade_list, install_force = _is_install)
except Exception as e:
logging.error(str(e))
@ -544,6 +544,7 @@ class InstallBackend():
self.window_main.dbusController.UpdateDetectFinished(False,[self.window_main.BACKEND_PKG_NAME],error_string,'')
#升级本身完成后 退出 有systemd 来进行重启服务
self.window_main.dbusController.Quit(None)
return
#当单包升级的时候 升级本身时,让程序退出,再重新启动
if self.window_main.GROUPS_PKG_NAME in self.now_upgrade.upgrade_content:
@ -612,6 +613,7 @@ class InstallBackend():
elif action == self.ACTION_INSTALL_SHUTDOWN:
# self._release_install_lock()
self._send_error_code(error_code)
#插入数据库
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)
@ -695,7 +697,7 @@ class InstallBackend():
self.window_main.start_available()
else:
self.window_main.dbusController.UpdateDetectFinished(success,[''],\
get_error_string_from_enum(ERROR_UPDATE_DEFAULT_FAILED),error_string+' '+error_desc)
get_error_string_from_enum(ERROR_NOT_FIX_SYSTEM),error_string+' '+error_desc)
logging.error("fix broken packages is complete to failed...")
elif action == self.ACTION_FIX_INCOMPLETE:
@ -705,11 +707,11 @@ class InstallBackend():
logging.warning("fix incomplete install failed.")
elif action == self.ACTION_REMOVE_PACKAGES:
self._release_install_lock()
# self._release_install_lock()
self.window_main.dbusController.PurgePackagesFinished(success,error_string,error_desc)
elif action == self.ACTION_INSTALL_DEB:
self._release_install_lock()
# 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.")

View File

@ -1,6 +1,6 @@
[SystemStatus]
abnormal_reboot = False
upload_upgrade_log = False
upload_upgrade_log = True
[InstallMode]
shutdown_install = False

View File

@ -2632,6 +2632,12 @@ msgstr "磁盘空间不足,请清理磁盘后进行升级更新"
msgid "Check for update exceptions,please check your network connection."
msgstr "检查更新异常,请检查您的网络连接。"
msgid "Check for update exceptions,fix system APT environment error."
msgstr "检查更新异常修复系统APT环境出现错误。"
msgid "The system APT environment is abnormal, please check the system APT environment."
msgstr "系统APT环境异常请检查系统APT环境。"
msgid "Priority upgrade status exception."
msgstr "优先升级异常。"

View File

@ -14,6 +14,11 @@ echo $1 >> updaterlog/base-info
echo "记录BUG产生时间系统当前时间以及升级相关的版本信息"
cat updaterlog/base-info
cp /etc/apt/sources.list updaterlog || true
cp -r /etc/apt/sources.list.d/ updaterlog || true
cp -r /etc/apt/apt.conf.d / updaterlog || true
#复制后端的日志
cp -r /var/log/kylin-system-updater/ updaterlog || true

9
debian/changelog vendored
View File

@ -1,3 +1,12 @@
kylin-system-updater (2.0.5.2) v101; urgency=medium
* BUG: 124775 【应用商店】卸载应用的授权弹窗显示为英文(必现)
* 需求号: 无
* 其他改动说明: 无
* 其他改动影响域:系统更新
-- luoxueyi <luoxueyi@kylinos.cn> Tue, 28 Jun 2022 18:09:38 +0800
kylin-system-updater (2.0.5.1) v101; urgency=medium
* BUG: # 121890 【更新升级】部分应用更新完成后,在“查看历史更新”中查不到数据