Merge branch 'backend_manual' of gitlab2.kylin.com:kylin-desktop/update-manager-group/kylin-system-updater into backend_manual
This commit is contained in:
commit
6ca697bd1d
|
@ -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文件
|
||||
|
@ -107,12 +106,10 @@ class UpdateList():
|
|||
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 = []
|
||||
|
||||
#是否进行源过滤的选项
|
||||
if self.fu != None:
|
||||
try:
|
||||
after_pkgs_list,adjust_pkgs = self.fu.check_in_allowed_origin(pkgs_list,adjust_versions)
|
||||
except Exception as e:
|
||||
logging.error(str(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
|
||||
|
||||
#从本地中获取本次升级需要升级的包 部分升级和全部升级使用 全盘升级不适用
|
||||
|
@ -276,7 +279,7 @@ class UpdateList():
|
|||
except Exception as e:
|
||||
logging.error(e)
|
||||
|
||||
def _split_package_id(package):
|
||||
def _split_package_id(self,package):
|
||||
"""Return the name, the version number and the release of the
|
||||
specified package."""
|
||||
if "=" in package:
|
||||
|
@ -290,68 +293,56 @@ class UpdateList():
|
|||
version = release = None
|
||||
return name, version, release
|
||||
|
||||
def _mark_packages_for_downgrade(self, packages, resolver):
|
||||
"""Mark packages for downgrade."""
|
||||
for pkg_name, pkg_ver, pkg_rel in [self._split_package_id(pkg)
|
||||
for pkg in packages]:
|
||||
try:
|
||||
pkg = self.cache[pkg_name]
|
||||
except KeyError:
|
||||
pass
|
||||
# raise TransactionFailed(ERROR_NO_PACKAGE,
|
||||
# _("Package %s isn't available"),
|
||||
# pkg_name)
|
||||
if not pkg.is_installed:
|
||||
pass
|
||||
# raise TransactionFailed(ERROR_PACKAGE_NOT_INSTALLED,
|
||||
# _("Package %s isn't installed"),
|
||||
# pkg_name)
|
||||
auto = pkg.is_auto_installed
|
||||
|
||||
if pkg_ver:
|
||||
if pkg.installed and pkg.installed.version < pkg_ver:
|
||||
pass
|
||||
# FIXME: We need a new error enum
|
||||
# raise TransactionFailed(ERROR_NO_PACKAGE,
|
||||
# _("The former version %s of %s "
|
||||
# "is already installed"),
|
||||
# pkg.installed.version, pkg.name)
|
||||
elif pkg.installed and pkg.installed.version == pkg_ver:
|
||||
pass
|
||||
# raise TransactionFailed(ERROR_PACKAGE_ALREADY_INSTALLED,
|
||||
# _("The version %s of %s "
|
||||
# "is already installed"),
|
||||
# pkg.installed.version, pkg.name)
|
||||
try:
|
||||
pkg.candidate = pkg.versions[pkg_ver]
|
||||
except KeyError:
|
||||
pass
|
||||
# raise TransactionFailed(ERROR_NO_PACKAGE,
|
||||
# _("The version %s of %s isn't "
|
||||
# "available"), pkg_ver, pkg_name)
|
||||
else:
|
||||
pass
|
||||
# raise TransactionFailed(ERROR_NO_PACKAGE,
|
||||
# _("You need to specify a version to "
|
||||
# "downgrade %s to"),
|
||||
# pkg_name)
|
||||
|
||||
# pkg.mark_install(False, False, True)
|
||||
# pkg.mark_auto(auto)
|
||||
# resolver.clear(pkg)
|
||||
# resolver.protect(pkg)
|
||||
|
||||
def _make_downgrade(self,cache,data):
|
||||
downgrade_pkgs = data["force_downgrade"]
|
||||
def _make_downgrade(self,cache,downgrade_pkgs):
|
||||
output_downgrade = []
|
||||
adjust_pkgs = []
|
||||
for pkg_name, pkg_ver, pkg_rel in [self._split_package_id(pkg)
|
||||
for pkg in downgrade_pkgs]:
|
||||
try:
|
||||
pkg = cache[pkg_name]
|
||||
except KeyError:
|
||||
logging.warning("Package %s isn't available",pkg_name)
|
||||
continue
|
||||
if not pkg.is_installed:
|
||||
logging.warning("Package %s isn't installed",pkg_name)
|
||||
pass
|
||||
|
||||
if pkg_ver:
|
||||
if pkg.installed and pkg.installed.version < pkg_ver:
|
||||
logging.warning("The former version %s of %s is already installed",pkg.installed.version, pkg.name)
|
||||
continue
|
||||
elif pkg.installed and pkg.installed.version == pkg_ver:
|
||||
logging.warning("The version %s of %s is already installed",pkg.installed.version, pkg.name)
|
||||
continue
|
||||
|
||||
try:
|
||||
pkg.candidate = pkg.versions[pkg_ver]
|
||||
except KeyError:
|
||||
logging.warning("The version %s of %s isn't available",pkg_ver, pkg_name)
|
||||
continue
|
||||
|
||||
output_downgrade.append(pkg_name)
|
||||
adjust_pkgs.append(pkg_name+'='+pkg_ver)
|
||||
|
||||
return output_downgrade,adjust_pkgs
|
||||
|
||||
def _get_downgrade_list(self,cache,data):
|
||||
downgrade_pkgs = []
|
||||
|
||||
try:
|
||||
downgrade_raw = data['force_install_list']
|
||||
except Exception as e:
|
||||
downgrade_raw = []
|
||||
|
||||
for pkg_name, pkg_ver, pkg_rel in [self._split_package_id(pkg)
|
||||
for pkg in downgrade_raw]:
|
||||
|
||||
if pkg_name in cache:
|
||||
downgrade_pkgs.append(pkg_name)
|
||||
else:
|
||||
logging.warning("Package %s isn't available",pkg_name)
|
||||
continue
|
||||
|
||||
return downgrade_raw,downgrade_pkgs
|
||||
|
||||
def _make_groups_upgrade(self,cache,group_list, pkgs_upgrade = []):
|
||||
try:
|
||||
|
@ -385,17 +376,34 @@ class UpdateList():
|
|||
if not group_name in group_list:
|
||||
continue
|
||||
upgrade_pkgs_list = data['upgrade_list']
|
||||
|
||||
#检查包是否在cache中 以及是否已经安装 没有安装的话才添加到列表
|
||||
new_install_list = self._check_pkg_in_cache(cache,data['install_list'])
|
||||
|
||||
downgrade_raw,downgrade_pkgs = self._get_downgrade_list(cache,data)
|
||||
#被降级的软件包优先级最高
|
||||
for pkg in downgrade_pkgs:
|
||||
if pkg in upgrade_pkgs_list:
|
||||
upgrade_pkgs_list.remove(pkg)
|
||||
if pkg in new_install_list:
|
||||
new_install_list.remove(pkg)
|
||||
if pkg in self.upgrade_meta.single_pkgs:
|
||||
self.upgrade_meta.single_pkgs.remove(pkg)
|
||||
|
||||
#进行交集 升级列表
|
||||
new_upgrade_list = list(set(pkgs_upgrade) & set(upgrade_pkgs_list))
|
||||
|
||||
#进行源过滤
|
||||
new_install_list,new_upgrade_list,adjust_pkgs = self._make_fiter_origin([cache[pkg] for pkg in new_install_list + new_upgrade_list],False)
|
||||
|
||||
self.upgrade_meta.adjust_pkgs.extend(adjust_pkgs)
|
||||
|
||||
#在总升级列表中移除这些包
|
||||
for pkg in new_upgrade_list:
|
||||
pkgs_upgrade.remove(pkg)
|
||||
|
||||
downgrade_pkg,adjust_pkgs = self._make_downgrade(cache,downgrade_raw)
|
||||
self.upgrade_meta.adjust_pkgs.extend(adjust_pkgs)
|
||||
new_upgrade_list.extend(downgrade_pkg)
|
||||
|
||||
#单包的优先级最高 从组中剔除此包
|
||||
for pkg in self.upgrade_meta.single_pkgs:
|
||||
if pkg in new_install_list:
|
||||
|
@ -404,9 +412,7 @@ class UpdateList():
|
|||
#判断当前是否可升级或者新装的包
|
||||
if len(new_install_list) == 0 and len(new_upgrade_list) == 0:
|
||||
continue
|
||||
#在总升级列表中移除这些包
|
||||
for pkg in new_upgrade_list:
|
||||
pkgs_upgrade.remove(pkg)
|
||||
|
||||
#3、生成升级的包列表JSON
|
||||
upgrade_pkgs_json = self._make_pkg_info_json(cache,new_upgrade_list)
|
||||
#2、生成安装的软件列表
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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"
|
||||
|
@ -57,6 +59,7 @@ _STRINGS_ERROR = {
|
|||
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."),
|
||||
|
|
|
@ -36,6 +36,7 @@ class UpdateManager():
|
|||
BACKEND_PKG_NAME = 'kylin-system-updater'
|
||||
FRONTEND_PKG_NAME = "kylin-update-frontend"
|
||||
GROUPS_PKG_NAME = 'kylin-update-desktop-config'
|
||||
SOURCES_UPDATE_NAME = "kylin-software-properties"
|
||||
APTD_PKG_NAME = "aptdaemon"
|
||||
RUN_UNATTENDED_UPGRADE = '/var/run/unattended-upgrades.pid'
|
||||
RETRY_LIMIT_NUM = 2
|
||||
|
@ -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:
|
||||
|
|
|
@ -158,13 +158,13 @@ class InstallBackendAptdaemon(InstallBackend):
|
|||
raise
|
||||
|
||||
@inline_callbacks
|
||||
def commit(self,model,pkgs_install, pkgs_upgrade, pkgs_remove,pkgs_purge = []):
|
||||
def commit(self,model,pkgs_install, pkgs_upgrade, pkgs_remove,pkgs_downgrade = []):
|
||||
"""Commit a list of package adds and removes"""
|
||||
try:
|
||||
reinstall = downgrade = []
|
||||
reinstall = purge = []
|
||||
trans = yield self.client.commit_packages(
|
||||
pkgs_install, reinstall, pkgs_remove, purge = pkgs_purge, upgrade = pkgs_upgrade,
|
||||
downgrade = downgrade,download = model, defer=True)
|
||||
pkgs_install, reinstall, pkgs_remove, purge = purge, upgrade = pkgs_upgrade,
|
||||
downgrade = pkgs_downgrade,download = model, defer=True)
|
||||
self.window_main.dbusController.transaction = trans
|
||||
|
||||
yield self._show_transaction(trans, self.action,
|
||||
|
|
|
@ -148,8 +148,9 @@ class InstallBackend():
|
|||
#拿到升级列表
|
||||
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))
|
||||
pkgs_install,pkgs_upgrade,pkgs_remove,pkgs_downgrade = self._get_mark_from_cache(self.cache,self.upgrade_data.adjust_pkgs,self.action_mode)
|
||||
logging.info("INSTALL install:%d , upgrade:%d remove:%d pkgs_downgrade:%d",len(pkgs_install),\
|
||||
len(pkgs_upgrade),len(pkgs_remove),len(pkgs_downgrade))
|
||||
|
||||
#当下载数量大于200个包时 就认为属于大版本升级 开启重试机制
|
||||
if len(pkgs_install) + len(pkgs_upgrade) > 100:
|
||||
|
@ -157,7 +158,7 @@ class InstallBackend():
|
|||
self.now_upgrade.version_upgrade = True
|
||||
|
||||
#检查是否存在可升级的包
|
||||
if len(pkgs_install) == 0 and len(pkgs_upgrade) == 0 and len(pkgs_remove) == 0:
|
||||
if len(pkgs_install) == 0 and len(pkgs_upgrade) == 0 and len(pkgs_remove) == 0 and len(pkgs_downgrade) == 0:
|
||||
raise UpdateBaseError(ERROR_NOT_UPGRADE_PACKAGES)
|
||||
|
||||
# if self.action_mode == self.MODE_INSTALL_SINGLE:
|
||||
|
@ -172,10 +173,10 @@ class InstallBackend():
|
|||
self.window_main.collector.Upgrade_Process_Msg(self.action, {"appname":ul})
|
||||
|
||||
if self.action == self.ACTION_INSTALL:
|
||||
self.commit(self.action,pkgs_install, pkgs_upgrade, pkgs_remove)
|
||||
self.commit(self.action,pkgs_install, pkgs_upgrade, pkgs_remove,pkgs_downgrade)
|
||||
elif self.action == self.ACTION_DOWNLOADONLY:
|
||||
self._update_to_config(self.now_upgrade,pkgs_install,pkgs_upgrade,pkgs_remove)
|
||||
self.commit(self.action,pkgs_install, pkgs_upgrade, pkgs_remove)
|
||||
self.commit(self.action,pkgs_install, pkgs_upgrade, pkgs_remove,pkgs_downgrade)
|
||||
|
||||
elif self.action == self.ACTION_INSTALL_SHUTDOWN:
|
||||
self.now_upgrade,pkgs_install,pkgs_upgrade,pkgs_remove = self._config_to_upgrade()
|
||||
|
@ -202,8 +203,8 @@ class InstallBackend():
|
|||
#获取要升级和安装的包列表
|
||||
pkgs_install,pkgs_upgrade = self._make_pkgs_list(self.cache,self.upgrade_data.groups_pkgs,self.now_upgrade.upgrade_groups,self.now_upgrade.single_pkgs)
|
||||
#计算解决依赖关系
|
||||
delete_pkgs,delete_desc = self._make_problem_resolver(self.cache,pkgs_install,pkgs_upgrade)
|
||||
pkgs_install,pkgs_upgrade,pkgs_remove = self._get_mark_from_cache(self.cache,self.upgrade_data.adjust_pkgs,self.action_mode)
|
||||
delete_pkgs,delete_desc = self._make_problem_resolver(self.cache,pkgs_install,pkgs_upgrade,self.upgrade_data.adjust_pkgs)
|
||||
pkgs_install,pkgs_upgrade,pkgs_remove,pkgs_downgrade = self._get_mark_from_cache(self.cache,self.upgrade_data.adjust_pkgs,self.action_mode)
|
||||
|
||||
if len(pkgs_remove) != len(delete_pkgs):
|
||||
logging.warning("Simulation of the deletion package list:%s",str(delete_pkgs))
|
||||
|
@ -220,13 +221,14 @@ class InstallBackend():
|
|||
except Exception as e:
|
||||
logging.error(str(e))
|
||||
raise UpdateBaseError(ERROR_RESOLVER_FAILED,desc= str(e))
|
||||
pkgs_install,pkgs_upgrade,pkgs_remove = self._get_mark_from_cache(self.cache,self.upgrade_data.adjust_pkgs,self.action_mode)
|
||||
pkgs_install,pkgs_upgrade,pkgs_remove,pkgs_downgrade = self._get_mark_from_cache(self.cache,self.upgrade_data.adjust_pkgs,self.action_mode)
|
||||
|
||||
self.window_main.collector.Generate_Msg(self.now_upgrade.upgrade_groups+self.now_upgrade.single_pkgs, self.action_mode)
|
||||
for ul in self.window_main.collector.upgrade_list:
|
||||
self.window_main.collector.Upgrade_Process_Msg(self.action, {"appname":ul})
|
||||
|
||||
logging.info("RESOLVER install:%d , upgrade:%d remove:%d",len(pkgs_install),len(pkgs_upgrade),len(pkgs_remove))
|
||||
logging.info("RESOLVER install:%d , upgrade:%d remove:%d pkgs_downgrade:%d",len(pkgs_install),len(pkgs_upgrade),\
|
||||
len(pkgs_remove),len(pkgs_downgrade))
|
||||
is_remove_pkgs = len(pkgs_remove) != 0
|
||||
|
||||
#添加关于删除包的描述信息
|
||||
|
@ -253,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()
|
||||
|
@ -273,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))
|
||||
|
@ -292,7 +294,7 @@ class InstallBackend():
|
|||
"""Remove all downloaded files.t"""
|
||||
raise NotImplementedError
|
||||
|
||||
def commit(self,model,pkgs_install, pkgs_upgrade, pkgs_remove,pkgs_purge = []):
|
||||
def commit(self,model,pkgs_install, pkgs_upgrade, pkgs_remove,pkgs_downgrade = []):
|
||||
"""Commit the cache changes """
|
||||
raise NotImplementedError
|
||||
|
||||
|
@ -317,6 +319,7 @@ class InstallBackend():
|
|||
pkgs_install = []
|
||||
pkgs_upgrade = []
|
||||
pkgs_remove = []
|
||||
pkgs_downgrade = []
|
||||
|
||||
#全盘升级不做任何的调整
|
||||
if upgrade_mode == self.MODE_INSTALL_SYSTEM or upgrade_mode == self.MODE_INSTALL_SINGLE:
|
||||
|
@ -342,9 +345,11 @@ class InstallBackend():
|
|||
pkgs_upgrade.append(pkg.name)
|
||||
elif pkg.marked_delete:
|
||||
pkgs_remove.append(pkg.name)
|
||||
elif pkg.marked_downgrade:
|
||||
pkgs_downgrade.append(pkg.name+'='+pkg.candidate.source_version)
|
||||
except KeyError:
|
||||
pass
|
||||
return pkgs_install,pkgs_upgrade,pkgs_remove
|
||||
return pkgs_install,pkgs_upgrade,pkgs_remove,pkgs_downgrade
|
||||
|
||||
#获取当前升级的升级列表
|
||||
def _make_groups_list(self,upgrade_data,_upgrade_mode,partial_upgrade_list):
|
||||
|
@ -417,13 +422,26 @@ class InstallBackend():
|
|||
pass
|
||||
return all_deps
|
||||
|
||||
def _split_package_id(self,package):
|
||||
"""Return the name, the version number and the release of the
|
||||
specified package."""
|
||||
if "=" in package:
|
||||
name, version = package.split("=", 1)
|
||||
release = None
|
||||
elif "/" in package:
|
||||
name, release = package.split("/", 1)
|
||||
version = None
|
||||
else:
|
||||
name = package
|
||||
version = release = None
|
||||
return name, version, release
|
||||
|
||||
#将获取本次升级的包 进行计算依赖关系 解决依赖问题
|
||||
def _make_problem_resolver(self,cache,pkgs_install = [],pkgs_upgrade = []):
|
||||
def _make_problem_resolver(self,cache,pkgs_install = [],pkgs_upgrade = [],adjust_pkgs = []):
|
||||
last_broken_count = 0
|
||||
#计算出来的需要删除的包列表
|
||||
delete_pkgs = []
|
||||
delete_desc = []
|
||||
fresh_cache = Cache()
|
||||
try:
|
||||
logging.info("ProblemResolver install:%d , upgrade:%d",len(pkgs_install),len(pkgs_upgrade))
|
||||
logging.info("Start calculating dependencies...")
|
||||
|
@ -433,6 +451,15 @@ class InstallBackend():
|
|||
if cache.get_changes():
|
||||
cache.clear()
|
||||
resolver = apt.cache.ProblemResolver(cache)
|
||||
#调整候选版本强制更改版本
|
||||
for pkg_name, pkg_ver, pkg_rel in [self._split_package_id(pkg)
|
||||
for pkg in adjust_pkgs]:
|
||||
try:
|
||||
pkg = cache[pkg_name]
|
||||
pkg.candidate = pkg.versions[pkg_ver]
|
||||
except KeyError:
|
||||
logging.warning("The version %s of %s isn't available",pkg_ver, pkg_name)
|
||||
continue
|
||||
|
||||
#标记计算所有需要安装的
|
||||
for pkg in pkgs_upgrade + pkgs_install:
|
||||
|
@ -452,6 +479,7 @@ class InstallBackend():
|
|||
if cache._depcache.broken_count != last_broken_count and \
|
||||
self.window_main.configs_cover.getWithDefault("ConfigPkgStatus", "check_resover_remove", False) == True:
|
||||
last_broken_count = cache._depcache.broken_count
|
||||
fresh_cache = Cache()
|
||||
tmp_pkgs,tmp_desc = self._emulate_calcul_delete(pkg,fresh_cache)
|
||||
delete_pkgs.extend(tmp_pkgs)
|
||||
delete_desc.extend(tmp_desc)
|
||||
|
@ -516,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:
|
||||
|
@ -584,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)
|
||||
|
@ -667,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:
|
||||
|
@ -677,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.")
|
||||
|
|
|
@ -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 "优先升级异常。"
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue