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

This commit is contained in:
wangsong 2021-12-02 17:07:51 +08:00
commit 62012db6b3
1 changed files with 23 additions and 19 deletions

View File

@ -150,12 +150,12 @@ class UpdateManager():
return False,"<"+debname+"> Not a DEB package." return False,"<"+debname+"> Not a DEB package."
logging.info("About to Install Package: %s.",str(debname)) logging.info("About to Install Package: %s.",str(debname))
try: try:
dep_satisfy = self._attempt_depends(deb_path,_check_local_dep,_auto_satisfy) dep_satisfy, err_args = self._attempt_depends(deb_path,_check_local_dep,_auto_satisfy)
if dep_satisfy: if dep_satisfy:
install_backend = get_backend(self, InstallBackend.ACTION_INSTALL_DEB) install_backend = get_backend(self, InstallBackend.ACTION_INSTALL_DEB)
install_backend.start_alone(partial_upgrade_list = deb_path, _is_install = _auto_satisfy) install_backend.start_alone(partial_upgrade_list = deb_path, _is_install = _auto_satisfy)
# else: else:
# self.dbusController.InstalldebFinished() self.dbusController.InstalldebFinished(dep_satisfy, err_args['error_string'], err_args['error_desc'])
except Exception as e: except Exception as e:
logging.info(str(e)) logging.info(str(e))
@ -418,13 +418,12 @@ class UpdateManager():
depends_pkg = [] depends_pkg = []
satisfy_list = [] satisfy_list = []
depends_count = 0 depends_count = 0
_error_str = ""
_local_satisfy = False _local_satisfy = False
deb_cache = self.cache err_args = {'error_string':'','error_desc':''}
absolute_path, debname = os.path.split(deb_path) absolute_path, debname = os.path.split(deb_path)
if deb_cache == None:
deb_cache = Cache()
try: try:
deb_cache = Cache()
deb = DebPackage(deb_path, deb_cache) deb = DebPackage(deb_path, deb_cache)
deb.check() deb.check()
(install, remove, unauth) = deb.required_changes (install, remove, unauth) = deb.required_changes
@ -435,8 +434,8 @@ class UpdateManager():
if _check_local_dep: #查找本地 if _check_local_dep: #查找本地
if remove: if remove:
logging.error("Need uninstall: %s.",str(remove)) logging.error("Need uninstall: %s.",str(remove))
_error_str = "Installing "+str(debname.split("_")[0])+" requires uninstalling: "+str(remove) err_args['error_string'] = "Installing "+str(debname.split("_")[0])+" requires uninstalling: "+str(remove)
logging.error(_error_str) logging.error(err_args['error_string'])
# 需要查找本地依赖 # 需要查找本地依赖
elif len(install) > 0: elif len(install) > 0:
for pkg in deb_cache: for pkg in deb_cache:
@ -458,8 +457,9 @@ class UpdateManager():
_local_satisfy = True _local_satisfy = True
elif not _auto_satisfy: elif not _auto_satisfy:
_local_satisfy = False _local_satisfy = False
_error_str = str(debname.split("_")[0])+"dependency is not satisfied, will download: "+",".join(install) err_args['error_string'] = str(debname.split("_")[0])+" dependency is not satisfied. "
logging.error(_error_str) err_args['error_desc'] = ",".join(install)
logging.error(err_args['error_string']+ err_args['error_desc'])
else: else:
#将应用包与依赖包拷贝至archive目录安装 #将应用包与依赖包拷贝至archive目录安装
try: try:
@ -467,24 +467,28 @@ class UpdateManager():
satisfy_list.append(debname) satisfy_list.append(debname)
for satisfy in satisfy_list: for satisfy in satisfy_list:
shutil.copy(os.path.join(absolute_path,satisfy),"/var/cache/apt/archives/") shutil.copy(os.path.join(absolute_path,satisfy),"/var/cache/apt/archives/")
logging.info("move debpkg: %s",satisfy)
_local_satisfy = True _local_satisfy = True
except Exception as e: except Exception as e:
logging.info(str(e)) logging.info(str(e))
return _local_satisfy return _local_satisfy,err_args
elif not _check_local_dep and _auto_satisfy: elif not _check_local_dep and _auto_satisfy:
_local_satisfy = True _local_satisfy = True
if install: if install:
_error_str = str(debname.split("_")[0])+"dependency is not satisfied, will download: "+",".join(install) err_args['error_string'] = str(debname.split("_")[0])+" dependency is not satisfied, will download. "
logging.error(_error_str) err_args['error_desc'] = ",".join(install)
return _local_satisfy logging.error(err_args['error_string']+ err_args['error_desc'])
return _local_satisfy,err_args
elif not _check_local_dep and not _auto_satisfy: elif not _check_local_dep and not _auto_satisfy:
_local_satisfy = False _local_satisfy = False
if install: if install:
_error_str = str(debname.split("_")[0])+" dependency is not satisfied: "+",".join(install) err_args['error_string'] = str(debname.split("_")[0])+" dependency is not satisfied. "
logging.error(_error_str) err_args['error_desc'] = ",".join(install)
return _local_satisfy logging.error(err_args['error_string']+ err_args['error_desc'])
return _local_satisfy,err_args
# 依赖满足 # 依赖满足
else: else:
_local_satisfy = True _local_satisfy = True
return _local_satisfy err_args = {'error_string':'','error_desc':''}
return _local_satisfy,err_args