修复添加proposed源后打开更新界面,显示优先升级状态异常,等待一段时间后弹出授权框,授权后可以检测到更新,点击更新后提示更新失败
This commit is contained in:
parent
3bbf177c17
commit
53d5c8d75a
|
@ -33,6 +33,9 @@ from urllib.request import urlopen
|
|||
from urllib.parse import urlsplit
|
||||
from http.client import BadStatusLine
|
||||
import socket
|
||||
from SystemUpdater.Core.errors import *
|
||||
from SystemUpdater.Core.enums import *
|
||||
import subprocess,threading
|
||||
import re
|
||||
import SystemUpdater.Core.DistUpgradeCache
|
||||
from gettext import gettext as _
|
||||
|
@ -79,6 +82,7 @@ class MyCache(SystemUpdater.Core.DistUpgradeCache.MyCache):
|
|||
# assert (self._depcache.broken_count == 0
|
||||
# and self._depcache.del_count == 0)
|
||||
self.launchpad = None
|
||||
self.simulate_mode = SimulateTerminal()
|
||||
|
||||
def _dpkgJournalDirty(self):
|
||||
"""
|
||||
|
@ -151,6 +155,52 @@ class MyCache(SystemUpdater.Core.DistUpgradeCache.MyCache):
|
|||
return True
|
||||
return False
|
||||
|
||||
#此处代码不能随意改动 影响自我升级功能
|
||||
# 标记安装 升级 降级 存在异常时 提出
|
||||
def make_resolver_self_upgrade(self,packages_list):
|
||||
try:
|
||||
#FIXME: 提供计算的包列表 提供出去
|
||||
cache = self
|
||||
with cache.actiongroup():
|
||||
if cache.get_changes():
|
||||
cache.clear()
|
||||
resolver = apt.cache.ProblemResolver(cache)
|
||||
|
||||
for pkg in packages_list:
|
||||
if "=" in pkg:
|
||||
name, version = pkg.split("=", 1)
|
||||
pkg_cache = cache[name]
|
||||
pkg_cache.candidate = pkg_cache.versions[version]
|
||||
else:
|
||||
pkg_cache = cache[pkg]
|
||||
if not pkg_cache.is_upgradable and pkg_cache.is_installed:
|
||||
continue
|
||||
|
||||
pkg_cache.mark_install(False, True, True)
|
||||
|
||||
if pkg_cache.is_upgradable == True:
|
||||
auto = pkg_cache.is_auto_installed
|
||||
pkg_cache.mark_auto(auto)
|
||||
|
||||
if pkg_cache.marked_keep == True:
|
||||
pkg_cache.mark_install(False, False, True)
|
||||
if pkg_cache.marked_keep == True or pkg_cache.is_inst_broken:
|
||||
logging.error("Have broken pkgs(%s)",pkg)
|
||||
raise
|
||||
|
||||
resolver.clear(pkg_cache)
|
||||
resolver.protect(pkg_cache)
|
||||
|
||||
resolver.resolve()
|
||||
except Exception as e:
|
||||
logging.error(str(e))
|
||||
pkg_string = ''
|
||||
for pkg in packages_list:
|
||||
pkg_string = pkg_string + ' ' + str(pkg)
|
||||
logging.error('Resolver calculation Packages List: '+pkg_string+'\n')
|
||||
terminal_msg = self.simulate_mode.thread_install(packages_list)
|
||||
raise UpdateBaseError(ERROR_RESOLVER_FAILED)
|
||||
|
||||
def saveDistUpgrade(self):
|
||||
""" this functions mimics a upgrade but will never remove anything """
|
||||
#upgrade(True) 为True时使用dist-upgrade进行升级
|
||||
|
@ -432,3 +482,50 @@ class MyCache(SystemUpdater.Core.DistUpgradeCache.MyCache):
|
|||
"check your Internet "
|
||||
"connection.")
|
||||
self.all_changes[name] += changelog
|
||||
|
||||
|
||||
class SimulateTerminal():
|
||||
SOURCES_LIST_FLAG = "sources.list"
|
||||
def __init__(self):
|
||||
self.update_args = ["apt-get", "update"]
|
||||
self.install_args = ["apt-get","-c","/etc/kylin-system-updater/apt_private.conf","install","--simulate"]
|
||||
|
||||
def _sub_emulate(self,args):
|
||||
p = subprocess.run(args, stdout=subprocess.PIPE,stderr=subprocess.STDOUT,text=True)
|
||||
logging.info(str(p.stdout))
|
||||
return p.stdout
|
||||
|
||||
def _emulate_install(self,pkgs):
|
||||
sources_path = apt_pkg.config["Dir::Etc::SourceList"]
|
||||
args = ["apt-get","install","--simulate"]
|
||||
|
||||
args = args + pkgs
|
||||
|
||||
p = subprocess.run(args, stdout=subprocess.PIPE,stderr=subprocess.STDOUT,text=True)
|
||||
logging.error(str(p.stdout))
|
||||
return p.stdout
|
||||
|
||||
def emulate_update(self):
|
||||
args = ["apt-get", "update"]
|
||||
|
||||
p = subprocess.run(args, stdout=subprocess.PIPE,stderr=subprocess.STDOUT,text=True)
|
||||
logging.error(str(p.stdout))
|
||||
return p.stdout
|
||||
|
||||
def start_caculate(self,args = [],thread = False):
|
||||
tmp_str = ''
|
||||
if thread is True:
|
||||
threading_emulate = threading.Thread(target=self._sub_emulate,args=(args,))
|
||||
threading_emulate.start()
|
||||
else:
|
||||
p = subprocess.run(args, stdout=subprocess.PIPE,stderr=subprocess.STDOUT,text=True)
|
||||
tmp_str = p.stdout
|
||||
return tmp_str
|
||||
|
||||
def thread_install(self,pkgs):
|
||||
threading_emulate = threading.Thread(target=self._emulate_install,args=(pkgs,))
|
||||
threading_emulate.start()
|
||||
|
||||
def thread_update(self):
|
||||
threading_emulate = threading.Thread(target=self.emulate_update)
|
||||
threading_emulate.start()
|
|
@ -281,12 +281,11 @@ class UpdateManager():
|
|||
raise UpdateProgressExit()
|
||||
|
||||
def _check_self_upgrade(self,cache):
|
||||
need_upgrade = False
|
||||
self_upgrade = []
|
||||
|
||||
channel_config = json_config().getWithDefault("update_channel_upgrade",default = None)
|
||||
channel_config = json_config().getWithDefault("update_self_upgrade",default = None)
|
||||
if channel_config == None:
|
||||
logging.warning("Json: update_channel_upgrade item is None...")
|
||||
logging.warning("Json: update_self_upgrade item is None...")
|
||||
upgrade_list = [self.BACKEND_PKG_NAME,self.APTD_PKG_NAME,self.FRONTEND_PKG_NAME]
|
||||
else:
|
||||
upgrade_list = channel_config.get("upgrade_list",[self.BACKEND_PKG_NAME,self.APTD_PKG_NAME,self.FRONTEND_PKG_NAME])
|
||||
|
@ -298,24 +297,20 @@ class UpdateManager():
|
|||
if self_pkg.is_upgradable:
|
||||
logging.info("Check: (%s) will upgrading From %s to %s...",pkg_name,\
|
||||
self_pkg.installed.source_version,self_pkg.candidate.source_version)
|
||||
try:
|
||||
logging.info("Check: (%s) start upgrading From %s to %s...",pkg_name,\
|
||||
self_pkg.installed.source_version,self_pkg.candidate.source_version)
|
||||
self_pkg.mark_install(True,False,True)
|
||||
self_upgrade.append(pkg_name)
|
||||
need_upgrade = True
|
||||
except SystemError:
|
||||
self.simulate_mode.thread_install([pkg_name])
|
||||
logging.error("Check: mark %s to upgrade Failed...",pkg_name)
|
||||
raise UpdateBaseError(ERROR_NOT_SELFPKG_DEPENDENCIES)
|
||||
self_upgrade.append(pkg_name)
|
||||
else:
|
||||
logging.info("Check: (%s:%s) No need to upgrade...",pkg_name,self_pkg.installed.source_version)
|
||||
else:
|
||||
logging.info("Check: (%s) Not to be installed...",pkg_name)
|
||||
logging.info("Check: (%s:%s) start new installing...",pkg_name,self_pkg.candidate.version)
|
||||
self_upgrade.append(pkg_name)
|
||||
else:
|
||||
logging.error("Check: (%s) The upgrade package is not in Cache...",pkg_name)
|
||||
|
||||
if need_upgrade == True:
|
||||
logging.info("Check: (%s) The upgrade package is not in Cache...",pkg_name)
|
||||
|
||||
if self_upgrade:
|
||||
try:
|
||||
cache.make_resolver_self_upgrade(self_upgrade)
|
||||
except Exception:
|
||||
raise UpdateBaseError(ERROR_NOT_SELFPKG_DEPENDENCIES)
|
||||
self.dbusController.UpdateDetectStatusChanged(95,_("Priority Upgrade Package being updated"))
|
||||
self.start_install(InstallBackend.MODE_INSTALL_SINGLE,True,push_content=self_upgrade)
|
||||
raise UpdateProgressExit()
|
||||
|
|
|
@ -617,7 +617,7 @@ class InstallBackend():
|
|||
if success:
|
||||
restart_ui = False
|
||||
|
||||
channel_config = json_config().getWithDefault("update_channel_upgrade",default = {})
|
||||
channel_config = json_config().getWithDefault("update_self_upgrade",default = {})
|
||||
|
||||
restart_list = channel_config.get("restart_service_list",[self.window_main.APTD_PKG_NAME,self.window_main.BACKEND_PKG_NAME])
|
||||
notify_list = channel_config.get("restart_panel_list",[self.window_main.FRONTEND_PKG_NAME])
|
||||
|
|
Loading…
Reference in New Issue