Merge branch 'backend_dev' of gitlab2.kylin.com:kylin-desktop/update-manager-group/kylin-system-updater into backend_dev

This commit is contained in:
Xueyi Luo 2022-03-17 14:41:00 +08:00
commit 3d6b8bf029
1 changed files with 27 additions and 13 deletions

View File

@ -327,24 +327,30 @@ class InstallBackend():
#计算升级或者安装这个包 是否存在需要卸载某个包
def _make_delete_pkgs(self,cache,all_delete_pkgs):
wouldDelete = cache._depcache.del_count
deleted_pkgs = []
if wouldDelete > len(all_delete_pkgs):
try:
for pkg_obj in cache:
if pkg_obj.marked_delete:
if pkg_obj.name in all_delete_pkgs:
continue
else:
deleted_pkgs.append(pkg_obj.name)
if deleted_pkgs:
all_delete_pkgs += deleted_pkgs
return deleted_pkgs
all_delete_pkgs.append(pkg_obj.name)
return deleted_pkgs
except Exception as e:
logging.error(str(e))
return []
#将获取本次升级的包 进行计算依赖关系 解决依赖问题
def _make_problem_resolver(self,cache,pkgs_install,pkgs_upgrade):
_success = True
header = ''
desc = ''
del_exception = False
#记录出现异常的包
exception_pkg = ''
try:
logging.info("ProblemResolver install:%d , upgrade:%d",len(pkgs_install),len(pkgs_upgrade))
logging.info("Start calculating dependencies...")
@ -361,6 +367,8 @@ class InstallBackend():
#标记计算所有需要安装的
for pkg in pkgs_upgrade + pkgs_install:
exception_pkg = pkg
pkg_cache = cache[pkg]
pkg_cache.mark_install()
@ -380,19 +388,25 @@ class InstallBackend():
if pkg_cache.marked_upgrade == False and pkg_cache.marked_install == False:
logging.error("Error: Problems calculating %s package dependencies...",pkg)
deleted_pkgs = self._make_delete_pkgs(cache,all_delete_pkgs)
for d_pkg in deleted_pkgs:
delete_desc = str(d_pkg) + _(" Will be deleted Due to Install or Upgrade ") + str(pkg)
all_delete_desc.append(delete_desc)
logging.warning(delete_desc)
#会安装新包和卸载包
#计算删除包的描述
wouldDelete = cache._depcache.del_count
if del_exception == False and wouldDelete > len(all_delete_pkgs):
deleted_pkgs = self._make_delete_pkgs(cache,all_delete_pkgs)
if deleted_pkgs == []:
del_exception == True
else:
for d_pkg in deleted_pkgs:
delete_desc = str(d_pkg) + _(" Will be deleted Due to Install or Upgrade ") + str(pkg)
all_delete_desc.append(delete_desc)
logging.warning(delete_desc)
resolver.resolve()
#不会安装和卸载 只升级
return _success,all_delete_pkgs,all_delete_desc,header,desc
except Exception as e:
_success = False
header = _("Could not calculate the upgrade")
logging.error(header+str(e))
logging.error(header + "(" + exception_pkg + ")" +str(e))
msg = get_broken_details(cache,False)
pkg_string = ''
for pkg in pkgs_install + pkgs_upgrade: