Merge branch 'backend_manual' into 'backend_uu'
Backend manual See merge request kylin-desktop/update-manager-group/kylin-system-updater!436
This commit is contained in:
commit
7d3eb3d5c7
|
@ -104,7 +104,7 @@ class UpdateMsgCollector():
|
|||
self.upgrade_list = []
|
||||
self.waitSendList = []
|
||||
self.cache = None
|
||||
|
||||
self.Send_log = False
|
||||
self.updateManager = manager
|
||||
# 转换 & 加密
|
||||
self.convertor = FormatConvert(self)
|
||||
|
@ -189,22 +189,23 @@ class UpdateMsgCollector():
|
|||
logging.error(e)
|
||||
|
||||
def Upgrade_Process_Msg(self, action, dict_msg = {}):
|
||||
tmp_dict = {}
|
||||
tmp_dict.update(dict_msg)
|
||||
try:
|
||||
self.UpdateInfos.update({"step":self.action_map.get(action, "")})
|
||||
if self.upgrade_mode == self.MODE_INSTALL_SYSTEM:
|
||||
self.UpdateInfos.update({"appname":"Upgrade System"})
|
||||
tmp_dict.update(self.UpdateInfos)
|
||||
json_file = json.dumps(tmp_dict.copy())
|
||||
self.UpdateMsg(self.messageType_map.get(action, ""), json_file, self.uuid)
|
||||
else:
|
||||
tmp_dict.update(self.UpdateInfos)
|
||||
json_file = json.dumps(tmp_dict.copy())
|
||||
self.UpdateMsg(self.messageType_map.get(action, ""), json_file, self.uuid)
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
tmp_dict.clear()
|
||||
if self.Send_log == True:
|
||||
tmp_dict = {}
|
||||
tmp_dict.update(dict_msg)
|
||||
try:
|
||||
self.UpdateInfos.update({"step":self.action_map.get(action, "")})
|
||||
if self.upgrade_mode == self.MODE_INSTALL_SYSTEM:
|
||||
self.UpdateInfos.update({"appname":"Upgrade System"})
|
||||
tmp_dict.update(self.UpdateInfos)
|
||||
json_file = json.dumps(tmp_dict.copy())
|
||||
self.UpdateMsg(self.messageType_map.get(action, ""), json_file, self.uuid)
|
||||
else:
|
||||
tmp_dict.update(self.UpdateInfos)
|
||||
json_file = json.dumps(tmp_dict.copy())
|
||||
self.UpdateMsg(self.messageType_map.get(action, ""), json_file, self.uuid)
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
tmp_dict.clear()
|
||||
|
||||
def make_background_version(self,pkg):
|
||||
if pkg.is_installed == True:
|
||||
|
@ -217,6 +218,9 @@ class UpdateMsgCollector():
|
|||
self.UploadMessage = {}
|
||||
self.PackageInfo = {}
|
||||
self.UpdateInfos = {}
|
||||
|
||||
def _set_Send_log(self, flag):
|
||||
self.Send_log = flag
|
||||
|
||||
class FormatConvert():
|
||||
def __init__(self, DataCollector):
|
||||
|
@ -549,7 +553,8 @@ class PHPServer(threading.Thread):
|
|||
if os.path.isfile(log_file_gzip):
|
||||
os.remove(log_file_gzip)
|
||||
|
||||
def PHPSeverSend(_appname="", _appversion="", _statue="", _errorcode=""):
|
||||
def PHPSeverSend(_send_log = False, _appname="", _appversion="", _statue="", _errorcode=""):
|
||||
if _send_log == True:
|
||||
send_thread = PHPServer()
|
||||
send_thread.get_values(_appname=_appname, _appversion=_appversion, _state=_statue, _errorcode=_errorcode)
|
||||
send_thread.start()
|
||||
|
|
|
@ -29,7 +29,14 @@ class Sqlite3Server(object):
|
|||
# uncoverable配置文件
|
||||
self.ucconfigs = UpgradeConfig(datadir = "/etc/kylin-version", name = "kylin-system-version.conf")
|
||||
self._system_version_config()
|
||||
|
||||
|
||||
#发送日志
|
||||
self.upload_upgrade_log = self.window_main.configs.getWithDefault("SystemStatus", "upload_upgrade_log", False)
|
||||
if self.upload_upgrade_log == False:
|
||||
logging.warning("Log sending is not enabled, and the server will not receive your update records .")
|
||||
else:
|
||||
self.window_main.collector._set_Send_log(self.upload_upgrade_log)
|
||||
|
||||
# 初始化连接数据库
|
||||
def init_sqlit(self):
|
||||
logging.info(_("Initialize the connection to the database ..."))
|
||||
|
@ -211,7 +218,7 @@ class Sqlite3Server(object):
|
|||
self._refresh_system_version(version)
|
||||
|
||||
#FIXME: 临时方案 PHP
|
||||
PHPSeverSend(_appname=pkgname, _appversion=pkgversion, _statue=status, _errorcode="10000100")
|
||||
PHPSeverSend(_send_log = self.upload_upgrade_log, _appname=pkgname, _appversion=pkgversion, _statue=status, _errorcode="10000100")
|
||||
elif pkg_list:
|
||||
# 单包更新 # 获取单包数据插入数据库
|
||||
pkgname = pkg_list.pop(0)
|
||||
|
@ -261,7 +268,7 @@ class Sqlite3Server(object):
|
|||
# 软件商店获取中文名
|
||||
appname_cn = self.get_cn_appname(str(pkgname))
|
||||
#FIXME: 临时方案 PHP
|
||||
PHPSeverSend(_appname=pkgname, _appversion=pkgversion, _statue=status, _errorcode="10000100")
|
||||
PHPSeverSend(_send_log = self.upload_upgrade_log, _appname=pkgname, _appversion=pkgversion, _statue=status, _errorcode="10000100")
|
||||
try:
|
||||
self.insert_into_updateinfo(pkgname, pkgversion, pkgdescription, timestr, status, "1", errstr, appname_cn)
|
||||
# FIXME: 发送插入数据库成功的信号local_upgrade_list
|
||||
|
@ -314,7 +321,7 @@ class Sqlite3Server(object):
|
|||
self.insert_into_updateinfo(str(i), pkgversion, pkgdescription, timestr, status, "1", errstr, appname_cn)
|
||||
self.window_main.dbusController.UpdateSqlitSingle(str(i), timestr)
|
||||
#FIXME: 临时方案 PHP
|
||||
PHPSeverSend(_appname=pkg.name, _appversion=pkgversion, _statue=status, _errorcode="10000100")
|
||||
PHPSeverSend(_send_log = self.upload_upgrade_log, _appname=pkg.name, _appversion=pkgversion, _statue=status, _errorcode="10000100")
|
||||
# insert group deb next
|
||||
for i in pkg_group:
|
||||
# FIXME: 获取组信息
|
||||
|
@ -336,7 +343,7 @@ class Sqlite3Server(object):
|
|||
InstallInfos.update({"errorCode":str(error_string+" "+error_desc)})
|
||||
self.window_main.collector.Upgrade_Process_Msg("finish-install", InstallInfos.copy())
|
||||
#FIXME: 临时方案 PHP
|
||||
PHPSeverSend(_appname=i, _appversion=pkgversion, _statue=status, _errorcode="10000100")
|
||||
PHPSeverSend(_send_log = self.upload_upgrade_log, _appname=i, _appversion=pkgversion, _statue=status, _errorcode="10000100")
|
||||
try:
|
||||
self.insert_into_updateinfo(str(i), pkgversion, pkgdescription, timestr, status, "1", errstr, appname_cn)
|
||||
self.window_main.dbusController.UpdateSqlitSingle(str(i), timestr)
|
||||
|
|
|
@ -7,7 +7,7 @@ __all__ = (
|
|||
"ERROR_NOT_INIT_PACKAGESINFIO","ERROR_READ_IMPORTANTLIST_FAILED","ERROR_RESOLVER_FAILED","ERROR_NOT_UPGRADE_PACKAGES",
|
||||
"ERROR_REMOVE_ESSENTIAL_PACKAGES","ERROR_NOT_DISK_SPACE",
|
||||
|
||||
"ERROR_UPDATE_KEY_SIGNATURES",
|
||||
"ERROR_UPDATE_KEY_SIGNATURES","ERROR_UPDATE_NET_AUTHENTICATION","ERROR_UPDATE_NOTREAD_SOURCES",
|
||||
|
||||
"get_error_description_from_enum", "get_error_string_from_enum", "get_source_name_from_enum")
|
||||
|
||||
|
@ -18,14 +18,8 @@ _ = gettext.gettext
|
|||
|
||||
#更新阶段
|
||||
ERROR_UPDATE_KEY_SIGNATURES = "The following signatures"
|
||||
|
||||
|
||||
#UPGRADE MONITOR STATUS
|
||||
MONIT_DETECT = "step-updatedetect"
|
||||
MONIT_DEPRESOLUT = "step-depresolution"
|
||||
MONIT_DOWNLOAD = "step-downloading"
|
||||
MONIT_INSTALL = "step-installing"
|
||||
MONIT_FINISH = "step-finish"
|
||||
ERROR_UPDATE_NET_AUTHENTICATION ="does the network require authentication?"
|
||||
ERROR_UPDATE_NOTREAD_SOURCES = "The list of sources could not be read"
|
||||
|
||||
#自己的
|
||||
ERROR_UPDATE_SOURCE_FAILED = "error-update-source-failed"
|
||||
|
@ -39,6 +33,17 @@ ERROR_NOT_UPGRADE_PACKAGES = "error-not-upgrade-packages"
|
|||
ERROR_REMOVE_ESSENTIAL_PACKAGES = "error-remove-essential-packages"
|
||||
ERROR_NOT_DISK_SPACE = "error-not-disk-space"
|
||||
|
||||
_STRINGS_ERROR = {
|
||||
ERROR_UPDATE_SOURCE_FAILED: _("Unable to access the source management server"),
|
||||
ERROR_NETWORK_FAILED: _("Please check your network connection and retry."),
|
||||
ERROR_NOT_GROUPS_CONFIG: _("Unable to get group configuration package, please contact administrator to solve"),
|
||||
ERROR_SOFTWARE_INDEX_RROKEN: _("Software index is broken"),
|
||||
ERROR_NOT_INIT_PACKAGESINFIO: _("Could not initialize the package information"),
|
||||
ERROR_READ_IMPORTANTLIST_FAILED: _("read important list failed"),
|
||||
ERROR_RESOLVER_FAILED: _("Could not calculate the upgrade"),
|
||||
ERROR_NOT_UPGRADE_PACKAGES: _("There is an exception in the update package."),
|
||||
ERROR_REMOVE_ESSENTIAL_PACKAGES: _("There is an exception in the update package."),
|
||||
ERROR_NOT_DISK_SPACE: _("Disk space is insufficient, please clean the disk and then upgrade")}
|
||||
|
||||
_DESCS_ERROR = {
|
||||
ERROR_UPDATE_SOURCE_FAILED: _("Check your source management server config"),
|
||||
|
@ -57,20 +62,20 @@ _DESCS_ERROR = {
|
|||
ERROR_RESOLVER_FAILED: _("nothing"),
|
||||
ERROR_NOT_UPGRADE_PACKAGES: _("This update cannot detect the upgradeable package."),
|
||||
ERROR_REMOVE_ESSENTIAL_PACKAGES: _("You request the removal of a system-essential package."),
|
||||
ERROR_NOT_DISK_SPACE: _("test")}
|
||||
ERROR_NOT_DISK_SPACE: _("test"),
|
||||
ERROR_UPDATE_KEY_SIGNATURES: _("Check your source public key signature"),
|
||||
ERROR_UPDATE_NET_AUTHENTICATION: _("Check if your network requires authentication?"),
|
||||
|
||||
_STRINGS_ERROR = {
|
||||
ERROR_UPDATE_SOURCE_FAILED: _("Unable to access the source management server"),
|
||||
ERROR_NETWORK_FAILED: _("Please check your network connection and retry."),
|
||||
ERROR_NOT_GROUPS_CONFIG: _("Unable to get group configuration package, please contact administrator to solve"),
|
||||
ERROR_SOFTWARE_INDEX_RROKEN: _("Software index is broken"),
|
||||
ERROR_NOT_INIT_PACKAGESINFIO: _("Could not initialize the package information"),
|
||||
ERROR_READ_IMPORTANTLIST_FAILED: _("read important list failed"),
|
||||
ERROR_RESOLVER_FAILED: _("Could not calculate the upgrade"),
|
||||
ERROR_NOT_UPGRADE_PACKAGES: _("There is an exception in the update package."),
|
||||
ERROR_REMOVE_ESSENTIAL_PACKAGES: _("There is an exception in the update package."),
|
||||
ERROR_NOT_DISK_SPACE: _("Disk space is insufficient, please clean the disk and then upgrade")}
|
||||
ERROR_UPDATE_NOTREAD_SOURCES: _("Please check your source list and retry.")
|
||||
|
||||
}
|
||||
|
||||
#UPGRADE MONITOR STATUS
|
||||
MONIT_DETECT = "step-updatedetect"
|
||||
MONIT_DEPRESOLUT = "step-depresolution"
|
||||
MONIT_DOWNLOAD = "step-downloading"
|
||||
MONIT_INSTALL = "step-installing"
|
||||
MONIT_FINISH = "step-finish"
|
||||
|
||||
SOURCE_NAME = {
|
||||
'kylin-installer':_("Kylin Installer"),
|
||||
|
|
|
@ -660,43 +660,6 @@ def get_package_label(pkg):
|
|||
name = getattr(pkg.candidate, "summary", "")
|
||||
return capitalize_first_word(name)
|
||||
|
||||
#安装时禁止关机 进行加锁
|
||||
def LockedPreventShutdown():
|
||||
global inhibit_lock
|
||||
"""
|
||||
Send a dbus signal to logind to not suspend the system, it will be
|
||||
released when the return value drops out of scope
|
||||
"""
|
||||
try:
|
||||
from gi.repository import Gio, GLib
|
||||
connection = Gio.bus_get_sync(Gio.BusType.SYSTEM)
|
||||
|
||||
var, fdlist = connection.call_with_unix_fd_list_sync(
|
||||
'org.freedesktop.login1', '/org/freedesktop/login1',
|
||||
'org.freedesktop.login1.Manager', 'Inhibit',
|
||||
GLib.Variant('(ssss)',
|
||||
('shutdown',
|
||||
'Kylin System Updater', 'Installing Packages',
|
||||
'block')),
|
||||
None, 0, -1, None, None)
|
||||
inhibit_lock = Gio.UnixInputStream(fd=fdlist.steal_fds()[var[0]])
|
||||
logging.info("Shutdown Has been locked...")
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
|
||||
#解锁禁止关机
|
||||
def unLockedEnableShutdown():
|
||||
global inhibit_lock
|
||||
try:
|
||||
if inhibit_lock != None:
|
||||
inhibit_lock.close()
|
||||
logging.info("Shutdown Has been unlocked...")
|
||||
inhibit_lock == None
|
||||
else:
|
||||
logging.info("Not locked and Quitting ...")
|
||||
except Exception as e:
|
||||
logging.error("unlock failed." + str(e))
|
||||
|
||||
# 查看uu进程是否需要kill
|
||||
def kill_process(path):
|
||||
try:
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
# UpdateManager.py
|
||||
# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*-
|
||||
import os
|
||||
import subprocess
|
||||
from apt import Cache
|
||||
import apt_pkg
|
||||
import sys
|
||||
import time
|
||||
|
@ -11,10 +9,16 @@ import dbus
|
|||
import logging
|
||||
import dbus.service
|
||||
import json
|
||||
import threading
|
||||
import subprocess
|
||||
from apt import Cache
|
||||
from gettext import gettext as _
|
||||
from apt.debfile import DebPackage
|
||||
from dbus.mainloop.glib import DBusGMainLoop
|
||||
DBusGMainLoop(set_as_default=True)
|
||||
|
||||
from .Core.errors import *
|
||||
from .Core.enums import *
|
||||
from .Core.MyCache import MyCache
|
||||
from .UpdateManagerDbus import UpdateManagerDbusController,UPDATER_DBUS_INTERFACE,UPDATER_DBUS_PATH,UPDATER_DBUS_SERVICE
|
||||
from .Core.UpdateList import UpdateList
|
||||
|
@ -23,14 +27,12 @@ from .Core.Database import Sqlite3Server
|
|||
from .Core.loop import mainloop
|
||||
from .Core.DataAcquisition import UpdateMsgCollector
|
||||
|
||||
from gettext import gettext as _
|
||||
from SystemUpdater.Core.UpdaterConfigParser import UpgradeConfig
|
||||
from SystemUpdater.Core.utils import get_broken_details,kill_process
|
||||
from SystemUpdater.Core.DpkgInstallProgress import LogInstallProgress
|
||||
from SystemUpdater.Core.utils import deb_verify,PolicyKit_Authority,get_proc_from_dbus_name
|
||||
|
||||
from .Core.errors import *
|
||||
from .Core.enums import *
|
||||
|
||||
|
||||
class UpdateManager():
|
||||
BACKEND_PKG_NAME = 'kylin-system-updater'
|
||||
|
@ -54,21 +56,22 @@ class UpdateManager():
|
|||
self.configs = UpgradeConfig("/var/lib/kylin-system-updater/")
|
||||
self.uuconfigs = UpgradeConfig(datadir = "/var/lib/unattended-upgrades/", name = "unattended-upgrades-policy.conf")
|
||||
|
||||
#数据采集器
|
||||
self.collector = UpdateMsgCollector(self)
|
||||
|
||||
#连接数据库
|
||||
self.sqlite3_server = Sqlite3Server(self)
|
||||
|
||||
#是否重启apt
|
||||
self.init_config_aptdeamon = False
|
||||
|
||||
#数据采集器
|
||||
self.collector = UpdateMsgCollector(self)
|
||||
|
||||
#后台aptdaemon的语言环境
|
||||
self.aptdaemonLang = os.environ["LANGUAGE"]
|
||||
|
||||
#失败后重启进行安装的限制次数 目前在自适应升级上面使用
|
||||
self.retry_limit = self.RETRY_LIMIT_NUM
|
||||
|
||||
self.simulate_mode = SimulateTerminal()
|
||||
#光盘源
|
||||
self.source_info = UpdateSourceInfo()
|
||||
|
||||
|
@ -77,9 +80,13 @@ class UpdateManager():
|
|||
self.install_mode = UpdateInstallMode(self)
|
||||
|
||||
self.apt_p2p_config = AptP2pConfigManager()
|
||||
#加载Cache
|
||||
self.refresh_cache()
|
||||
|
||||
self.inhibit_shutdown = InhibitShutdownLock()
|
||||
|
||||
self._reload_options_config()
|
||||
#加载Cache
|
||||
self._refresh_cache_only()
|
||||
|
||||
|
||||
def _reload_options_config(self):
|
||||
#添加默认保留旧配置
|
||||
|
@ -213,15 +220,14 @@ class UpdateManager():
|
|||
|
||||
if self.options.no_update_source is False:
|
||||
self.dbusController.on_update_important_list()
|
||||
return
|
||||
|
||||
#不进行update
|
||||
if self.options.no_update:
|
||||
self.start_available()
|
||||
return
|
||||
|
||||
#调用aptdeamon进行update
|
||||
update_backend = get_backend(self, InstallBackend.ACTION_UPDATE,update_mode)
|
||||
update_backend.start()
|
||||
self.start_update_backend()
|
||||
|
||||
except UpdateBaseError as excep:
|
||||
self.dbusController.DistUpdateDetectFinished(False,[],excep.header,excep.desc)
|
||||
|
@ -230,6 +236,14 @@ class UpdateManager():
|
|||
except Exception as e:
|
||||
logging.error(e)
|
||||
|
||||
def start_update_backend(self,update_mode = InstallBackend.MODE_UPDATE_ALL):
|
||||
try:
|
||||
#调用aptdeamon进行update
|
||||
update_backend = get_backend(self, InstallBackend.ACTION_UPDATE,update_mode)
|
||||
update_backend.start()
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
|
||||
def start_available(self):
|
||||
try:
|
||||
self.refresh_cache()
|
||||
|
@ -277,6 +291,17 @@ class UpdateManager():
|
|||
logging.error(str(e))
|
||||
raise UpdateBaseError(ERROR_NOT_INIT_PACKAGESINFIO)
|
||||
|
||||
def _refresh_cache_only(self):
|
||||
try:
|
||||
#第一次进入 之后update不进入
|
||||
if self.cache is None:
|
||||
self.cache = MyCache(None)
|
||||
else:
|
||||
self.cache.open(None)
|
||||
self.cache._initDepCache()
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
|
||||
def _check_self_upgrade(self,cache):
|
||||
need_upgrade = False
|
||||
|
||||
|
@ -284,72 +309,29 @@ class UpdateManager():
|
|||
data = f.read()
|
||||
important_list = data.split()
|
||||
|
||||
#self
|
||||
if self.BACKEND_PKG_NAME in cache:
|
||||
self_pkg = cache[self.BACKEND_PKG_NAME]
|
||||
#是否安装
|
||||
if self_pkg.is_installed and self_pkg.is_upgradable:
|
||||
logging.info("Check: Updater(%s) start upgrading From %s to %s...",self.BACKEND_PKG_NAME,\
|
||||
self_pkg.installed.source_version,self_pkg.candidate.source_version)
|
||||
if self.BACKEND_PKG_NAME in important_list:
|
||||
self_pkg.mark_install()
|
||||
need_upgrade = True
|
||||
else:
|
||||
logging.info("Check: Updater(%s:%s) No need to upgrade...",self.BACKEND_PKG_NAME,self_pkg.installed.source_version)
|
||||
else:
|
||||
logging.info("Check: Updater(%s:%s) No need to upgrade...",self.BACKEND_PKG_NAME,self_pkg.installed.source_version)
|
||||
else:
|
||||
#没有在cache中就认为不需要升级
|
||||
logging.error("Check: Updater(%s) The upgrade package is not in Cache...",self.BACKEND_PKG_NAME)
|
||||
|
||||
#Aptdaemon
|
||||
if self.APTD_PKG_NAME in cache:
|
||||
self_pkg = cache[self.APTD_PKG_NAME]
|
||||
#是否安装
|
||||
if self_pkg.is_installed and self_pkg.is_upgradable:
|
||||
logging.info("Check: Aptdaemon(%s) start upgrading From %s to %s...",self.APTD_PKG_NAME,\
|
||||
self_pkg.installed.source_version,self_pkg.candidate.source_version)
|
||||
if self.BACKEND_PKG_NAME in important_list:
|
||||
self_pkg.mark_install()
|
||||
need_upgrade = True
|
||||
else:
|
||||
logging.info("Check: Aptdaemon(%s:%s) No need to upgrade...",self.APTD_PKG_NAME,self_pkg.installed.source_version)
|
||||
else:
|
||||
logging.info("Check: Aptdaemon(%s:%s) No need to upgrade...",self.APTD_PKG_NAME,self_pkg.installed.source_version)
|
||||
else:
|
||||
#没有在cache中就认为不需要升级
|
||||
logging.error("Check: Aptdaemon(%s) The upgrade package is not in Cache...",self.APTD_PKG_NAME)
|
||||
|
||||
#控制面板前端包的检查升级
|
||||
if self.FRONTEND_PKG_NAME in cache:
|
||||
self_pkg = cache[self.FRONTEND_PKG_NAME]
|
||||
|
||||
if self_pkg.is_installed:
|
||||
#是否可升级
|
||||
if self_pkg.is_upgradable:
|
||||
logging.info("Check: Frontend(%s) start upgrading From %s to %s...",self.FRONTEND_PKG_NAME,\
|
||||
for pkg_name in (self.BACKEND_PKG_NAME,self.APTD_PKG_NAME,self.FRONTEND_PKG_NAME):
|
||||
if pkg_name in cache:
|
||||
self_pkg = cache[pkg_name]
|
||||
if self_pkg.is_installed and self_pkg.is_upgradable:
|
||||
logging.info("Check: Updater(%s) start upgrading From %s to %s...",pkg_name,\
|
||||
self_pkg.installed.source_version,self_pkg.candidate.source_version)
|
||||
if self.FRONTEND_PKG_NAME in important_list:
|
||||
self_pkg.mark_install()
|
||||
need_upgrade = True
|
||||
if pkg_name in important_list:
|
||||
try:
|
||||
self_pkg.mark_install()
|
||||
need_upgrade = True
|
||||
except SystemError:
|
||||
logging.error("Check: mark %s to upgrade Failed...",pkg_name)
|
||||
else:
|
||||
logging.info("Check: Frontend(%s:%s) No need to upgrade...",self.FRONTEND_PKG_NAME,self_pkg.installed.source_version)
|
||||
logging.info("Check: (%s:%s) No need to upgrade...",pkg_name,self_pkg.installed.source_version)
|
||||
else:
|
||||
logging.info("Check: Frontend(%s:%s) No need to upgrade...",self.FRONTEND_PKG_NAME,self_pkg.installed.source_version)
|
||||
logging.info("Check: (%s:%s) No need to upgrade...",pkg_name,self_pkg.installed.source_version)
|
||||
else:
|
||||
self.dbusController.UpdateDetectStatusChanged(95,_("Group configuration being updated"))
|
||||
logging.info("Check: Frontend(%s) start new installing...",self.FRONTEND_PKG_NAME)
|
||||
self_pkg.mark_install()
|
||||
need_upgrade = True
|
||||
else:
|
||||
#没有在cache中就认为不需要升级
|
||||
logging.error("Check: Frontend(%s) The upgrade package is not in Cache...",self.FRONTEND_PKG_NAME)
|
||||
|
||||
logging.error("Check: (%s) The upgrade package is not in Cache...",pkg_name)
|
||||
|
||||
#config包
|
||||
if self.GROUPS_PKG_NAME in cache:
|
||||
pkg_json = cache[self.GROUPS_PKG_NAME]
|
||||
#是否安装
|
||||
if pkg_json.is_installed:
|
||||
#是否可升级
|
||||
if pkg_json.is_upgradable:
|
||||
self.dbusController.UpdateDetectStatusChanged(95,_("Group configuration being updated"))
|
||||
logging.info("Check: groups JSON ConfigPkgs(%s) start upgrading From %s to %s...",self.GROUPS_PKG_NAME,\
|
||||
|
@ -875,6 +857,89 @@ class AptP2pConfigManager():
|
|||
self.p2pConfigs.setValue("apt_p2p_Khashmir","BOOTSTRAP",str(value))
|
||||
|
||||
|
||||
class InhibitShutdownLock():
|
||||
|
||||
def __init__(self):
|
||||
self.inhibit_lock = None
|
||||
|
||||
#安装时禁止关机 进行加锁
|
||||
def lock(self):
|
||||
"""
|
||||
Send a dbus signal to logind to not suspend the system, it will be
|
||||
released when the return value drops out of scope
|
||||
"""
|
||||
try:
|
||||
from gi.repository import Gio, GLib
|
||||
connection = Gio.bus_get_sync(Gio.BusType.SYSTEM)
|
||||
|
||||
var, fdlist = connection.call_with_unix_fd_list_sync(
|
||||
'org.freedesktop.login1', '/org/freedesktop/login1',
|
||||
'org.freedesktop.login1.Manager', 'Inhibit',
|
||||
GLib.Variant('(ssss)',
|
||||
('shutdown',
|
||||
'Kylin System Updater', 'Installing Packages',
|
||||
'block')),
|
||||
None, 0, -1, None, None)
|
||||
self.inhibit_lock = Gio.UnixInputStream(fd=fdlist.steal_fds()[var[0]])
|
||||
logging.info("Shutdown Has been locked...")
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
|
||||
#解锁禁止关机
|
||||
def unlock(self):
|
||||
try:
|
||||
if self.inhibit_lock != None:
|
||||
self.inhibit_lock.close()
|
||||
self.inhibit_lock == None
|
||||
logging.info("Shutdown Has been unlocked...")
|
||||
else:
|
||||
logging.info("Not locked and Quitting ...")
|
||||
except Exception as e:
|
||||
logging.error("unlock failed." + str(e))
|
||||
|
||||
class SimulateTerminal():
|
||||
ZH_UNMET_DEPENDENCIES = '下列软件包有未满足的依赖关系:'
|
||||
EN_UNMET_DEPENDENCIES = 'The following packages have unmet dependencies:'
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def _emulate_install(self,pkgs):
|
||||
args = ["apt-get", "install","--simulate"]
|
||||
args = args + pkgs
|
||||
|
||||
p = subprocess.run(args, stdout=subprocess.PIPE,stderr=subprocess.STDOUT,text=True)
|
||||
logging.info(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.info(str(p.stdout))
|
||||
return p.stdout
|
||||
|
||||
def thread_install(self):
|
||||
threading_emulate = threading.Thread(target=self._emulate_install)
|
||||
threading_emulate.start()
|
||||
|
||||
def thread_update(self):
|
||||
threading_emulate = threading.Thread(target=self.emulate_update)
|
||||
threading_emulate.start()
|
||||
|
||||
def dependencies_broken(self,pkgs):
|
||||
terminal_msg = self._emulate_install(pkgs)
|
||||
|
||||
if len(terminal_msg) > 500:
|
||||
terminal_msg = ''
|
||||
if self.ZH_UNMET_DEPENDENCIES in terminal_msg:
|
||||
terminal_msg = '\n' + self.ZH_UNMET_DEPENDENCIES + terminal_msg.split(self.ZH_UNMET_DEPENDENCIES)[1]
|
||||
elif self.EN_UNMET_DEPENDENCIES in terminal_msg:
|
||||
terminal_msg = '\n' + self.EN_UNMET_DEPENDENCIES + terminal_msg.split(self.EN_UNMET_DEPENDENCIES)[1]
|
||||
else:
|
||||
terminal_msg = ''
|
||||
|
||||
return terminal_msg
|
||||
|
||||
class UpdateInstallMode():
|
||||
def __init__(self,parent):
|
||||
self.parent = parent
|
||||
|
|
|
@ -11,7 +11,7 @@ from .Core.loop import mainloop
|
|||
from .Core.errors import *
|
||||
from .Core.enums import *
|
||||
from .Core.utils import humanize_size
|
||||
from SystemUpdater.Core.utils import unLockedEnableShutdown,get_proc_from_dbus_name,PolicyKit_Authority
|
||||
from SystemUpdater.Core.utils import get_proc_from_dbus_name,PolicyKit_Authority
|
||||
import locale
|
||||
from xml.etree import ElementTree
|
||||
from .Core.MyCache import MyCache
|
||||
|
@ -58,19 +58,22 @@ class UpdateManagerDbusController(dbus.service.Object):
|
|||
|
||||
self.transaction = None
|
||||
|
||||
def _update_important_reply(self,retval):
|
||||
if bool(retval) == False:
|
||||
self.DistUpdateDetectFinished(False,[''],get_error_string_from_enum(ERROR_UPDATE_SOURCE_FAILED),\
|
||||
get_error_description_from_enum(ERROR_UPDATE_SOURCE_FAILED))
|
||||
else:
|
||||
self.parent.start_update_backend()
|
||||
|
||||
def _update_important_error(self,retval):
|
||||
self.DistUpdateDetectFinished(False,[''],get_error_string_from_enum(ERROR_UPDATE_SOURCE_FAILED),str(retval))
|
||||
|
||||
#更新important.list的本次升级的列表
|
||||
def on_update_important_list(self):
|
||||
try:
|
||||
self.UpdateDetectStatusChanged(10,_("Updating Source Template"))
|
||||
obj = self.bus.get_object('com.kylin.software.properties', '/com/kylin/software/properties')
|
||||
interface = dbus.Interface(obj, dbus_interface='com.kylin.software.properties.interface')
|
||||
retval = interface.updateSourceTemplate(timeout=20)
|
||||
except Exception as excep:
|
||||
raise UpdateBaseError(ERROR_UPDATE_SOURCE_FAILED,
|
||||
details= str(excep))
|
||||
if retval == False:
|
||||
raise UpdateBaseError(ERROR_UPDATE_SOURCE_FAILED)
|
||||
return
|
||||
self.UpdateDetectStatusChanged(10,_("Updating Source Template"))
|
||||
obj = self.bus.get_object('com.kylin.software.properties', '/com/kylin/software/properties')
|
||||
interface = dbus.Interface(obj, dbus_interface='com.kylin.software.properties.interface')
|
||||
interface.updateSourceTemplate(timeout=1,reply_handler=self._update_important_reply,error_handler=self._update_important_error)
|
||||
|
||||
def is_reboot_required(self):
|
||||
"""If a reboot is required to get all changes into effect."""
|
||||
|
@ -127,11 +130,7 @@ class UpdateManagerDbusController(dbus.service.Object):
|
|||
"""Request a shutdown of the daemon."""
|
||||
#如果在下载就请求 取消
|
||||
self.CancelDownload()
|
||||
try:
|
||||
#尝试接触 关闭枷锁
|
||||
unLockedEnableShutdown()
|
||||
except:
|
||||
logging.error("File lock release failure")
|
||||
self.parent.inhibit_shutdown.unlock()
|
||||
logging.info("Quitting was requested")
|
||||
logging.debug("Quitting main loop...")
|
||||
mainloop.quit()
|
||||
|
@ -894,7 +893,13 @@ class UpdateManagerDbusController(dbus.service.Object):
|
|||
@dbus.service.signal(UPDATER_DBUS_INTERFACE)
|
||||
def ChangeUpgradePolicy(self):
|
||||
logging.info(COLORLOG_PREFIX + "Emitting" + COLORLOG_SUFFIX +" ChangeUpgradePolicy")
|
||||
|
||||
|
||||
#下载安装前的状态检查信号
|
||||
@dbus.service.signal(UPDATER_DBUS_INTERFACE,signature='bs')
|
||||
def InstallDetectStatus(self, success,error_code=''):
|
||||
logging.info(COLORLOG_PREFIX + "Emitting"+ COLORLOG_SUFFIX + " InstallDetectStatus success = %r , error_code = %s",\
|
||||
success,error_code)
|
||||
|
||||
WRITABLE_PROPERTIES = ()
|
||||
|
||||
# pylint: disable-msg=C0103,C0322
|
||||
|
@ -1006,6 +1011,8 @@ class UpdateManagerDbusController(dbus.service.Object):
|
|||
self.parent.configs.setValue("InstallMode","shutdown_install",str(bool(value)))
|
||||
elif name == "P2pBootstrap":
|
||||
self.parent.apt_p2p_config.set_bootstrap(str(value))
|
||||
elif name == "UploadUpgradeLog":
|
||||
self.parent.configs.setValue("SystemStatus","upload_upgrade_log",str(bool(value)))
|
||||
else:
|
||||
raise dbus.exceptions.DBusException("Unknown or read only "
|
||||
"property: %s" % name)
|
||||
|
@ -1020,7 +1027,10 @@ class UpdateManagerDbusController(dbus.service.Object):
|
|||
"ShutdownInstall": dbus.Boolean(
|
||||
self.parent.configs.getWithDefault("InstallMode", "shutdown_install", False)),
|
||||
|
||||
"P2pBootstrap": dbus.String(self.parent.apt_p2p_config.get_bootstrap())
|
||||
"P2pBootstrap": dbus.String(self.parent.apt_p2p_config.get_bootstrap()),
|
||||
|
||||
"UploadUpgradeLog": dbus.Boolean(
|
||||
self.parent.configs.getWithDefault("SystemStatus", "upload_upgrade_log", False))
|
||||
}
|
||||
else:
|
||||
return {}
|
|
@ -21,7 +21,6 @@ import dbus,time
|
|||
from gi.repository import GLib
|
||||
import os
|
||||
from importlib import reload
|
||||
from SystemUpdater.Core.utils import unLockedEnableShutdown,LockedPreventShutdown
|
||||
|
||||
# 超时检测 秒单位
|
||||
UPDATER_IDLE_CHECK_INTERVAL = 5
|
||||
|
@ -30,7 +29,6 @@ INSTALL_IDLE_TIMEOUT = 20 * 60
|
|||
#更新超时检查 5分钟
|
||||
UPDATE_IDLE_TIMEOUT = 5 * 60
|
||||
|
||||
|
||||
class InstallBackendAptdaemon(InstallBackend):
|
||||
"""Makes use of aptdaemon to refresh the cache and to install updates."""
|
||||
|
||||
|
@ -99,14 +97,13 @@ class InstallBackendAptdaemon(InstallBackend):
|
|||
if (time.time() - timestamp > INSTALL_IDLE_TIMEOUT
|
||||
and self.on_install_stage == True):
|
||||
logging.error("Quitting due to inactivity(%s)",self.aptd_base.details)
|
||||
|
||||
if self.action == self.ACTION_INSTALL_SHUTDOWN:
|
||||
#关机安装模式 解除禁止关机锁
|
||||
self.window_maininhibit_lock.close()
|
||||
self.window_main.inhibit_lock.close()
|
||||
logging.info("Installtion timeout to exit Due to inactivity and Releasing the shutdown lock...")
|
||||
else:
|
||||
#超时只单独进行解锁关机
|
||||
unLockedEnableShutdown()
|
||||
self.window_main.inhibit_shutdown.unlock()
|
||||
# self._action_done(self.ACTION_INSTALL,
|
||||
# is_cancelled=False, success=False,
|
||||
# #FIXME: 安装超时退出
|
||||
|
@ -329,10 +326,7 @@ class InstallBackendAptdaemon(InstallBackend):
|
|||
if progress > 51 and progress < 90 and self.on_install_stage == False:
|
||||
logging.info("The process is now in the installtion phase")
|
||||
self.on_install_stage = True
|
||||
LockedPreventShutdown()
|
||||
|
||||
#进度安装阶段标志位,使用鉴别是否出现安装过程中强制关闭 之后进行修复使用得
|
||||
self.window_main.configs.setValue("SystemStatus","abnormal_reboot",str(True),True)
|
||||
self._start_install_lock()
|
||||
|
||||
#只处理从下载切换到安装时出现的网络问题
|
||||
#当网络波动时下载某些软件包失败时属于异常状态进行重试时 不发送后续进度 等待重试正常是 进行下载安装
|
||||
|
|
|
@ -3,25 +3,19 @@
|
|||
|
||||
"""Integration of package managers into SystemUpdater"""
|
||||
|
||||
import logging
|
||||
import os
|
||||
from gettext import gettext as _
|
||||
|
||||
import apt
|
||||
import apt_pkg
|
||||
import json
|
||||
from SystemUpdater.Core.utils import (
|
||||
unLockedEnableShutdown,
|
||||
get_broken_details
|
||||
)
|
||||
from SystemUpdater.Core.DataAcquisition import get_east_8_time
|
||||
from apt import Cache
|
||||
import logging
|
||||
import subprocess
|
||||
from SystemUpdater.Core.UpdateList import LocalUpgradeDataList
|
||||
from SystemUpdater.Core.errors import *
|
||||
import threading
|
||||
from apt import Cache
|
||||
from gettext import gettext as _
|
||||
from SystemUpdater.Core.errors import *
|
||||
from SystemUpdater.Core.enums import *
|
||||
from SystemUpdater.Core.DataAcquisition import get_east_8_time
|
||||
from SystemUpdater.Core.UpdateList import LocalUpgradeDataList
|
||||
from SystemUpdater.Core.DistUpgradeCache import NotEnoughFreeSpaceError
|
||||
|
||||
class NowUpgradeMeta:
|
||||
|
@ -43,7 +37,7 @@ class NowUpgradeMeta:
|
|||
self.single_pkgs = single_pkgs
|
||||
self.version_upgrade = version_upgrade
|
||||
self.need_retry = need_retry
|
||||
self.upgrade_content = upgrade_groups + single_pkgs
|
||||
self.upgrade_content = self.upgrade_groups + self.single_pkgs
|
||||
|
||||
#获取当前升级的升级列表
|
||||
def _make_groups_list(self,upgrade_data,_upgrade_mode,partial_upgrade_list):
|
||||
|
@ -184,8 +178,7 @@ class InstallBackend():
|
|||
self.now_upgrade,pkgs_install,pkgs_upgrade,pkgs_remove = self._config_to_upgrade()
|
||||
logging.info("ACTION_INSTALL_SHUTDOWN install:%d , upgrade:%d remove:%d",len(pkgs_install),len(pkgs_upgrade),len(pkgs_remove))
|
||||
|
||||
#进度安装阶段标志位,使用鉴别是否出现安装过程中强制关闭 之后进行修复使用得
|
||||
self.window_main.configs.setValue("SystemStatus","abnormal_reboot",str(True),True)
|
||||
# self._start_install_lock()
|
||||
self.commit(self.action,pkgs_install, pkgs_upgrade, pkgs_remove)
|
||||
|
||||
#计算依赖解决方案
|
||||
|
@ -257,27 +250,8 @@ class InstallBackend():
|
|||
self.fix_incomplete()
|
||||
#卸载包
|
||||
elif self.action == self.ACTION_REMOVE_PACKAGES:
|
||||
# remove_pkgs = []
|
||||
# for pkg in partial_upgrade_list:
|
||||
# if pkg in self.cache:
|
||||
# pkg_cache = self.cache[pkg]
|
||||
# pkg_cache.mark_delete(True, True)
|
||||
# else:
|
||||
# #没有在cache中就认为不需要升级
|
||||
# logging.error("Check: (%s) The reomve package is not in Cache...",pkg)
|
||||
|
||||
# for pkg_obj in self.cache.get_changes():
|
||||
# if pkg_obj.marked_delete:
|
||||
# remove_pkgs.append(pkg_obj.name)
|
||||
|
||||
# success,header,desc = self.check_essential_pkgs(remove_pkgs)
|
||||
# if success == False:
|
||||
# self._action_done(self.action,False,False,header,desc)
|
||||
# return
|
||||
# else:
|
||||
self._start_install_lock()
|
||||
self.purge_packages(partial_upgrade_list)
|
||||
|
||||
#清空所有下载的文件
|
||||
elif self.action == self.ACTION_CLEAN:
|
||||
self.clean()
|
||||
#更新cache
|
||||
|
@ -286,17 +260,17 @@ class InstallBackend():
|
|||
self.window_main.check_conifg_aptdeamon()
|
||||
self.update()
|
||||
except UpdateBaseError as excep:
|
||||
self._action_done(self.action,True,False,excep.header,excep.desc)
|
||||
self._action_done(self.action,True,False,excep.header,excep.desc,excep.code)
|
||||
except UpdateProgressExit as excep:
|
||||
pass
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
|
||||
logging.error(e)
|
||||
|
||||
def start_alone(self,partial_upgrade_list = [],_is_install = False):
|
||||
# 安装本地deb包的接口
|
||||
if self.action == self.ACTION_INSTALL_DEB:
|
||||
try:
|
||||
self._start_install_lock()
|
||||
self.install_deb(install_path = partial_upgrade_list, install_force = _is_install)
|
||||
except Exception as e:
|
||||
logging.error(str(e))
|
||||
|
@ -482,18 +456,14 @@ class InstallBackend():
|
|||
return delete_pkgs,delete_desc
|
||||
except Exception as e:
|
||||
logging.info(str(e))
|
||||
# msg = get_broken_details(cache,False)
|
||||
pkg_string = ''
|
||||
for pkg in pkgs_install + pkgs_upgrade:
|
||||
pkg_string = pkg_string + ' ' + str(pkg)
|
||||
logging.info('Resolver calculation Packages List: '+pkg_string+'\n')
|
||||
# logging.error('\n' + msg)
|
||||
terminal_msg = self.emulate_calcul_broken(pkgs_install + pkgs_upgrade)
|
||||
terminal_msg = self.window_main.simulate_mode.dependencies_broken(pkgs_install + pkgs_upgrade)
|
||||
logging.error(terminal_msg)
|
||||
raise UpdateBaseError(ERROR_RESOLVER_FAILED,
|
||||
desc= terminal_msg)
|
||||
# threading_emulate = threading.Thread(target=emulate_calcul_broken,args=(pkgs_install + pkgs_upgrade,))
|
||||
# threading_emulate.start()
|
||||
|
||||
def _emulate_calcul_delete(self,pkg,cache):
|
||||
try:
|
||||
|
@ -521,18 +491,20 @@ class InstallBackend():
|
|||
logging.error("Package("+pkg+") "+ str(e))
|
||||
return [],[]
|
||||
|
||||
#调用aptdeamon结束之后处理的地方 不管是出错还是正常都在此处理
|
||||
def _action_done(self, action, is_cancelled,success, error_string,error_desc):
|
||||
#后端的状态 到空闲状态
|
||||
self.window_main.now_working = self.ACTION_DEFUALT_STATUS
|
||||
def _send_error_code(self,error_code):
|
||||
if error_code == ERROR_NOT_DISK_SPACE:
|
||||
self.window_main.dbusController.InstallDetectStatus(False,error_code)
|
||||
|
||||
#调用aptdeamon结束之后处理的地方 不管是出错还是正常都在此处理
|
||||
def _action_done(self, action, is_cancelled,success, error_string,error_desc,error_code=''):
|
||||
#后端的状态 到空闲状态
|
||||
self.window_main.now_working = self.ACTION_DEFUALT_STATUS
|
||||
|
||||
#升级完成后走的分支
|
||||
if action == self.ACTION_INSTALL:
|
||||
#记录这个过程中是否关机
|
||||
self.window_main.configs.setValue("SystemStatus","abnormal_reboot",str(False),True)
|
||||
#解锁 禁止关机
|
||||
unLockedEnableShutdown()
|
||||
|
||||
self._release_install_lock()
|
||||
self._send_error_code(error_code)
|
||||
|
||||
#单包安装模式 单独处理 目前 更新配置包和升级本身使用
|
||||
if self.action_mode == self.MODE_INSTALL_SINGLE:
|
||||
if success:
|
||||
|
@ -566,7 +538,7 @@ class InstallBackend():
|
|||
if len(error_string + error_desc) > 20:
|
||||
self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string,error_desc)
|
||||
else:
|
||||
self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string+','+error_desc,error_desc)
|
||||
self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string,error_desc)
|
||||
return
|
||||
else:
|
||||
if self.now_upgrade.version_upgrade == True and self.now_upgrade.need_retry == True and success == False:
|
||||
|
@ -609,7 +581,7 @@ class InstallBackend():
|
|||
self.window_main.refresh_cache()
|
||||
|
||||
elif action == self.ACTION_INSTALL_SHUTDOWN:
|
||||
self.window_main.configs.setValue("SystemStatus","abnormal_reboot",str(False))
|
||||
# self._release_install_lock()
|
||||
#插入数据库
|
||||
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)
|
||||
|
@ -629,17 +601,7 @@ class InstallBackend():
|
|||
self.window_main.dbusController.Quit(None)
|
||||
|
||||
elif action == self.ACTION_CHECK_RESOLVER:
|
||||
zh_desc = '下列软件包有未满足的依赖关系:'
|
||||
en_desc = 'The following packages have unmet dependencies:'
|
||||
|
||||
if success == False:
|
||||
if len(error_desc) > 500:
|
||||
error_desc = ''
|
||||
if zh_desc in error_desc:
|
||||
error_desc = '\n' + zh_desc + error_desc.split(zh_desc)[1]
|
||||
elif en_desc in error_desc:
|
||||
error_desc = '\n' + en_desc + error_desc.split(en_desc)[1]
|
||||
|
||||
self.window_main.sqlite3_server.insert_info(self.action_mode,self.now_upgrade.single_pkgs,\
|
||||
self.now_upgrade.upgrade_groups,[],success,error_string,error_desc)
|
||||
|
||||
|
@ -673,27 +635,28 @@ class InstallBackend():
|
|||
|
||||
self.window_main.dbusController.UpdateDownloadFinished(success,self.now_upgrade.upgrade_content,error_string,error_desc)
|
||||
|
||||
elif action == self.ACTION_UPDATE:
|
||||
if success == False and ERROR_UPDATE_KEY_SIGNATURES in self.aptd_base.error_details:
|
||||
error_desc = _("Check your source public key signature")
|
||||
#网络认证错误
|
||||
elif success == False and 'does the network require authentication?' in self.aptd_base.error_details:
|
||||
error_desc = _("Check if your network requires authentication?")
|
||||
|
||||
if success and self.action_mode == self.MODE_UPDATE_ALL:
|
||||
#开始生成列表
|
||||
self.window_main.start_available()
|
||||
else:
|
||||
self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string+','+error_desc,error_desc)
|
||||
|
||||
if self.action_mode == self.MODE_UPDATE_ALL:
|
||||
#记录本次更新时间插入数据库
|
||||
self.window_main.sqlite3_server.insert_into_display("check_time",get_east_8_time())
|
||||
|
||||
if success == False and self.action_mode == self.MODE_UPDATE_ALL:
|
||||
elif action == self.ACTION_UPDATE and self.action_mode == self.MODE_UPDATE_ALL:
|
||||
if success == False:
|
||||
threading_emulate = threading.Thread(target=self.emulate_update)
|
||||
threading_emulate.start()
|
||||
|
||||
if ERROR_UPDATE_KEY_SIGNATURES in self.aptd_base.error_details:
|
||||
error_desc = get_error_description_from_enum(ERROR_UPDATE_KEY_SIGNATURES)
|
||||
elif ERROR_UPDATE_NET_AUTHENTICATION in self.aptd_base.error_details:
|
||||
error_desc = get_error_description_from_enum(ERROR_UPDATE_NET_AUTHENTICATION)
|
||||
elif ERROR_UPDATE_NOTREAD_SOURCES in self.aptd_base.error_details:
|
||||
error_desc = get_error_description_from_enum(ERROR_UPDATE_NOTREAD_SOURCES)
|
||||
|
||||
if success:
|
||||
#开始生成列表
|
||||
self.window_main.start_available()
|
||||
else:
|
||||
self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string,error_desc)
|
||||
|
||||
self.window_main.sqlite3_server.insert_into_display("check_time",get_east_8_time())
|
||||
|
||||
elif action == self.ACTION_UPDATE and self.action_mode == self.MODE_UPDATE_CACHE:
|
||||
self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string,error_desc)
|
||||
elif action == self.ACTION_FIX_BROKEN:
|
||||
self.window_main.dbusController.FixBrokenStatusChanged(True,success,100,'',error_string,error_desc)
|
||||
logging.warning("fix broken packages is complete...")
|
||||
|
@ -712,15 +675,18 @@ class InstallBackend():
|
|||
logging.warning("fix incomplete install failed.")
|
||||
|
||||
elif action == self.ACTION_REMOVE_PACKAGES:
|
||||
self._release_install_lock()
|
||||
self.window_main.dbusController.PurgePackagesFinished(success,error_string,error_desc)
|
||||
|
||||
elif action == self.ACTION_INSTALL_DEB:
|
||||
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.")
|
||||
error_desc = ''
|
||||
self.window_main.dbusController.InstalldebFinished(success,error_string,error_desc)
|
||||
elif action == self.ACTION_BACKGROUND_UPGRADE:
|
||||
self._release_install_lock()
|
||||
UpdateMsg = {}
|
||||
if success:
|
||||
status = 'Success'
|
||||
|
@ -740,6 +706,14 @@ class InstallBackend():
|
|||
|
||||
self.window_main.dbusController.UpdateInstallFinished(success,self.now_upgrade.upgrade_content,error_string,error_desc)
|
||||
|
||||
def _start_install_lock(self):
|
||||
self.window_main.configs.setValue("SystemStatus","abnormal_reboot",str(True))
|
||||
self.window_main.inhibit_shutdown.lock()
|
||||
|
||||
def _release_install_lock(self):
|
||||
self.window_main.configs.setValue("SystemStatus","abnormal_reboot",str(False))
|
||||
self.window_main.inhibit_shutdown.unlock()
|
||||
|
||||
def _message_to_plymouth(self,message):
|
||||
subprocess.call(["/bin/plymouth", "message", "--text", message])
|
||||
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
[UpdaterStatus]
|
||||
first_run = yes
|
||||
|
||||
[SYSTEM]
|
||||
version =
|
||||
kylin_release_id =
|
|
@ -1,6 +1,7 @@
|
|||
[SystemStatus]
|
||||
abnormal_reboot = False
|
||||
close_source_filter = False
|
||||
upload_upgrade_log = False
|
||||
|
||||
[ConfigPkgStatus]
|
||||
check_resover_remove = False
|
||||
|
|
|
@ -520,6 +520,27 @@
|
|||
|
||||
|
||||
|
||||
#### InstallDetectStatus
|
||||
|
||||
- `介绍:`下载安装前的状态检查
|
||||
|
||||
- `出参`: `b:`检查出错时为`False`,没有错误`success`,`s:`产生错误的码
|
||||
|
||||
- 错误码示例:
|
||||
|
||||
```python
|
||||
ERROR_NOT_DISK_SPACE = "error-not-disk-space"
|
||||
```
|
||||
|
||||
- `示例:`
|
||||
|
||||
```sh
|
||||
#表示出现磁盘已满的错误z
|
||||
InstallDetectStatus success = False , error_code = "error-not-disk-space"
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -85,18 +85,15 @@ if __name__ == "__main__":
|
|||
|
||||
logging.info('kylin-system-updater(lang:%s) starting ...',os.environ["LANGUAGE"])
|
||||
|
||||
try:
|
||||
app = UpdateManager(options)
|
||||
app = UpdateManager(options)
|
||||
|
||||
#当出现安装过程中异常的重启时 开机直接进行修复操作
|
||||
if app.configs.getWithDefault("ConfigPkgStatus", "check_frontend_pkg", False) == True:
|
||||
app.configs.setValue("ConfigPkgStatus","check_frontend_pkg",str(False),True)
|
||||
app.check_frontend_pkg()
|
||||
#当出现安装过程中异常的重启时 开机直接进行修复操作
|
||||
# if app.configs.getWithDefault("ConfigPkgStatus", "check_frontend_pkg", False) == True:
|
||||
# app.configs.setValue("ConfigPkgStatus","check_frontend_pkg",str(False),True)
|
||||
# app.check_frontend_pkg()
|
||||
|
||||
#当出现安装过程中异常的重启时 开机直接进行修复操作
|
||||
if app.configs.getWithDefault("SystemStatus", "abnormal_reboot", False) == True:
|
||||
app.start_update()
|
||||
#当出现安装过程中异常的重启时 开机直接进行修复操作
|
||||
if app.configs.getWithDefault("SystemStatus", "abnormal_reboot", False) == True:
|
||||
app.start_update()
|
||||
|
||||
app.run()
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
app.run()
|
|
@ -2625,6 +2625,9 @@ msgstr "磁盘空间不足,请清理磁盘后进行升级更新"
|
|||
msgid "Please check your network connection and retry."
|
||||
msgstr "请检查您的网络连接后再试。"
|
||||
|
||||
msgid "Please check your source list and retry."
|
||||
msgstr "请检查您的源列表后再试。"
|
||||
|
||||
msgid "Checking network connection"
|
||||
msgstr "检查网络连接中"
|
||||
|
||||
|
|
|
@ -1,3 +1,16 @@
|
|||
kylin-system-updater (2.0.5.1) v101; urgency=medium
|
||||
|
||||
* BUG: # 121890 【更新升级】部分应用更新完成后,在“查看历史更新”中查不到数据
|
||||
# 123985 【在线更新】系统存在可选更新且在设置中开启了自动下载和安装更新,系统到达定时下载的时间未进行自动下载
|
||||
# 110370 【更新升级】 【自动更新】出现一次,自动更新安装服务,将本地安装包地址检测成源地址导致安装报错
|
||||
* 需求号: # 12722 【更新升级】系统更新全流程监控
|
||||
# 12720 【更新升级】升级环境检测
|
||||
# 12721 【更新升级】系统版本号体系
|
||||
* 其他改动说明: 无
|
||||
* 其他改动影响域:系统更新
|
||||
|
||||
-- luoxueyi <luoxueyi@kylinos.cn> Mon, 13 Jun 2022 16:25:38 +0800
|
||||
|
||||
kylin-system-updater (2.0.4.3) v101; urgency=medium
|
||||
|
||||
* BUG: # 118021 【在线更新】中文环境下,安装和卸载应用时弹出授权界面,提示内容未汉化
|
||||
|
|
|
@ -16,7 +16,6 @@ backend/data/system-updater.conf /var/lib/kylin-system-updater/
|
|||
backend/data/unattended-upgrades-policy.conf /var/lib/unattended-upgrades/
|
||||
backend/data/unattended-upgrades-timestamp /var/lib/unattended-upgrades/
|
||||
backend/data/cn.kylinos.KylinSystemUpdater.policy /usr/share/polkit-1/actions/
|
||||
backend/data/system-updater-uncoverable.conf /usr/share/kylin-system-updater/
|
||||
|
||||
#uu
|
||||
unattended-upgrades/*.service /lib/systemd/system/
|
||||
|
|
|
@ -19,7 +19,3 @@ if [ -f /usr/share/kylin-system-updater/SystemUpdater/Core/DataMigration.py ];th
|
|||
/usr/share/kylin-system-updater/SystemUpdater/Core/DataMigration.py -u appname_cn=
|
||||
/usr/share/kylin-system-updater/SystemUpdater/Core/DataMigration.py -t=tid_search
|
||||
fi
|
||||
|
||||
if [ ! -f /var/lib/kylin-system-updater/system-updater-uncoverable.conf ];then
|
||||
cp /usr/share/kylin-system-updater/system-updater-uncoverable.conf /var/lib/kylin-system-updater/
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue