优化计算删除软件包
This commit is contained in:
parent
ff8c711952
commit
675e5ab451
|
@ -10,6 +10,7 @@ import json
|
||||||
import logging
|
import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
import traceback
|
import traceback
|
||||||
|
import threading
|
||||||
from apt import Cache
|
from apt import Cache
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
from SystemUpdater.Core.errors import *
|
from SystemUpdater.Core.errors import *
|
||||||
|
@ -288,6 +289,10 @@ class InstallBackend():
|
||||||
self.window_main.dbusController.DistupgradeDependResloveStatus(True,is_remove_pkgs,pkgs_remove,raw_description,delete_desc,'','')
|
self.window_main.dbusController.DistupgradeDependResloveStatus(True,is_remove_pkgs,pkgs_remove,raw_description,delete_desc,'','')
|
||||||
|
|
||||||
self._action_done(self.action,False,True,'','')
|
self._action_done(self.action,False,True,'','')
|
||||||
|
|
||||||
|
if is_remove_pkgs:
|
||||||
|
threading_emulate = threading.Thread(target=self._emulate_calcul_delete,args=((pkgs_upgrade + pkgs_install),))
|
||||||
|
threading_emulate.start()
|
||||||
|
|
||||||
#修复未满足的依赖关系 与apt-get -f install匹配
|
#修复未满足的依赖关系 与apt-get -f install匹配
|
||||||
elif self.action == self.ACTION_CHECK_BROKEN:
|
elif self.action == self.ACTION_CHECK_BROKEN:
|
||||||
|
@ -547,9 +552,6 @@ class InstallBackend():
|
||||||
logging.info("ProblemResolver install:%d , upgrade:%d",len(pkgs_install),len(pkgs_upgrade))
|
logging.info("ProblemResolver install:%d , upgrade:%d",len(pkgs_install),len(pkgs_upgrade))
|
||||||
logging.info("Start calculating dependencies...")
|
logging.info("Start calculating dependencies...")
|
||||||
|
|
||||||
if self.window_main.configs_cover.getWithDefault("ConfigPkgStatus", "check_resover_remove", False) == True:
|
|
||||||
self._emulate_calcul_delete(cache,pkgs_upgrade + pkgs_install)
|
|
||||||
|
|
||||||
#actiongroup 可以加速计算依赖关系 计算花费的时间将大幅度缩减
|
#actiongroup 可以加速计算依赖关系 计算花费的时间将大幅度缩减
|
||||||
with cache.actiongroup():
|
with cache.actiongroup():
|
||||||
if cache.get_changes():
|
if cache.get_changes():
|
||||||
|
@ -596,13 +598,22 @@ class InstallBackend():
|
||||||
raise UpdateBaseError(ERROR_RESOLVER_FAILED,
|
raise UpdateBaseError(ERROR_RESOLVER_FAILED,
|
||||||
desc= terminal_msg)
|
desc= terminal_msg)
|
||||||
|
|
||||||
def _emulate_calcul_delete(self,cache,total_pkg,):
|
def _emulate_calcul_delete(self,total_pkg):
|
||||||
logging.info("Start calculating delete dependencies...")
|
# 多线程的方式来计算删除的软件包
|
||||||
|
logging.info("[DELETE_DETAILS] Start calculating delete dependencies...")
|
||||||
delete_pkgs = []
|
delete_pkgs = []
|
||||||
last_delete_count = 0
|
last_delete_count = 0
|
||||||
|
cache = Cache()
|
||||||
|
|
||||||
with cache.actiongroup():
|
with cache.actiongroup():
|
||||||
|
if cache.get_changes():
|
||||||
|
cache.clear()
|
||||||
for pkg in total_pkg:
|
for pkg in total_pkg:
|
||||||
|
if '#' in pkg:
|
||||||
|
pkg = pkg.split("#")[0]
|
||||||
|
elif '=' in pkg:
|
||||||
|
pkg = pkg.split("=")[0]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cache[pkg].mark_install()
|
cache[pkg].mark_install()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -615,7 +626,10 @@ class InstallBackend():
|
||||||
if pkg_obj.marked_delete and pkg_obj.name not in delete_pkgs:
|
if pkg_obj.marked_delete and pkg_obj.name not in delete_pkgs:
|
||||||
delete_pkgs.append(pkg_obj.name)
|
delete_pkgs.append(pkg_obj.name)
|
||||||
delete_pkgs.append(pkg)
|
delete_pkgs.append(pkg)
|
||||||
logging.warning("%s Will be deleted Due to Install or Upgrade %s",pkg_obj.name,pkg)
|
logging.info("[DELETE_DETAILS] %s Will be deleted Due to Install or Upgrade %s",pkg_obj.name,pkg)
|
||||||
|
|
||||||
|
logging.info("[DELETE_DETAILS] End calculating delete dependencies...")
|
||||||
|
cache.close()
|
||||||
|
|
||||||
def _send_error_code(self,error_code):
|
def _send_error_code(self,error_code):
|
||||||
if error_code == ERROR_NOT_DISK_SPACE:
|
if error_code == ERROR_NOT_DISK_SPACE:
|
||||||
|
|
|
@ -10,4 +10,5 @@ key8 = /usr/bin/kylin-unattended-upgrade
|
||||||
key9 = /usr/bin/kylin-software-center
|
key9 = /usr/bin/kylin-software-center
|
||||||
key10 = /usr/bin/kylin-printer
|
key10 = /usr/bin/kylin-printer
|
||||||
key11 = /usr/bin/kylin-printer-applet
|
key11 = /usr/bin/kylin-printer-applet
|
||||||
key12 = /usr/bin/hedron-client
|
key12 = /usr/bin/hedron-client
|
||||||
|
key13 = /usr/bin/kylin-software-center-plugin-synchrodata
|
Loading…
Reference in New Issue