Merge branch 'backend_manual' of gitlab2.kylin.com:kylin-desktop/update-manager-group/kylin-system-updater into backend_manual
This commit is contained in:
commit
7b2a3ddf6f
|
@ -70,8 +70,6 @@ class UpdateList():
|
||||||
def _empty_output_dir(self):
|
def _empty_output_dir(self):
|
||||||
try:
|
try:
|
||||||
#清空 升级列表
|
#清空 升级列表
|
||||||
self.parent.configs.setValue("AutoUpgrade","upgradelist",'',True)
|
|
||||||
|
|
||||||
if not os.path.exists(self.OUTPUT_CONFIG_PATH):
|
if not os.path.exists(self.OUTPUT_CONFIG_PATH):
|
||||||
os.makedirs(self.OUTPUT_CONFIG_PATH)
|
os.makedirs(self.OUTPUT_CONFIG_PATH)
|
||||||
logging.info('making the ConfigPath(%s) is complete...',self.OUTPUT_CONFIG_PATH)
|
logging.info('making the ConfigPath(%s) is complete...',self.OUTPUT_CONFIG_PATH)
|
||||||
|
@ -237,26 +235,44 @@ class UpdateList():
|
||||||
def _make_autoupgrade_config(self,cache,upgrade_data,_adjust_pkgs):
|
def _make_autoupgrade_config(self,cache,upgrade_data,_adjust_pkgs):
|
||||||
try:
|
try:
|
||||||
pkgs_install,pkgs_upgrade = self._make_pkgs_list(cache,upgrade_data.groups_pkgs,upgrade_data.upgrade_groups,upgrade_data.single_pkgs)
|
pkgs_install,pkgs_upgrade = self._make_pkgs_list(cache,upgrade_data.groups_pkgs,upgrade_data.upgrade_groups,upgrade_data.single_pkgs)
|
||||||
|
|
||||||
split_adjust_pkgs = [i.split("=")[0] for i in _adjust_pkgs]
|
split_adjust_pkgs = [i.split("=")[0] for i in _adjust_pkgs]
|
||||||
|
|
||||||
pkgs_upgrade_str = ''
|
output_config_name = self.OUTPUT_CONFIG_PATH + 'auto-upgrade-list.json'
|
||||||
pkgs_list = pkgs_upgrade + pkgs_install
|
output_json = {}
|
||||||
if pkgs_list:
|
install_info = {}
|
||||||
for pkg_str in pkgs_list:
|
for pkg in pkgs_install:
|
||||||
|
pkg_cache = cache[pkg]
|
||||||
#记录源过滤后调整的版本
|
pkgs_json = {}
|
||||||
if pkg_str in split_adjust_pkgs:
|
pkgs_json.update({"cur_version":getattr(pkg_cache.installed, "version", '')})
|
||||||
pkg_str = _adjust_pkgs[split_adjust_pkgs.index(pkg_str)]
|
|
||||||
else:
|
|
||||||
ver = getattr(cache[pkg_str].candidate, "version", '')
|
|
||||||
pkg_str = pkg_str + "=" + ver
|
|
||||||
pkgs_upgrade_str += (pkg_str + ',')
|
|
||||||
|
|
||||||
pkgs_upgrade_str=pkgs_upgrade_str[:-1]
|
if pkg in split_adjust_pkgs:
|
||||||
|
version_adjust = _adjust_pkgs[split_adjust_pkgs.index(pkg)].split("=")[1]
|
||||||
|
pkgs_json.update({"new_version":version_adjust})
|
||||||
|
else:
|
||||||
|
pkgs_json.update({"new_version":getattr(pkg_cache.candidate, "version", '')})
|
||||||
|
install_info.update({pkg:pkgs_json})
|
||||||
|
|
||||||
self.parent.configs.setValue("AutoUpgrade","upgradelist",pkgs_upgrade_str,True)
|
upgrade_json = {}
|
||||||
logging.info("Generate AutoUpgrade Configfile to Complete and Upgradable Number:%d...",len(pkgs_list))
|
for pkg in pkgs_upgrade:
|
||||||
|
pkg_cache = cache[pkg]
|
||||||
|
pkgs_json = {}
|
||||||
|
pkgs_json.update({"cur_version":getattr(pkg_cache.installed, "version", '')})
|
||||||
|
|
||||||
|
if pkg in split_adjust_pkgs:
|
||||||
|
version_adjust = _adjust_pkgs[split_adjust_pkgs.index(pkg)].split("=")[1]
|
||||||
|
pkgs_json.update({"new_version":version_adjust})
|
||||||
|
else:
|
||||||
|
pkgs_json.update({"new_version":getattr(pkg_cache.candidate, "version", '')})
|
||||||
|
|
||||||
|
upgrade_json.update({pkg:pkgs_json})
|
||||||
|
|
||||||
|
output_json.update({"upgrade_list":upgrade_json})
|
||||||
|
output_json.update({"install_list":install_info})
|
||||||
|
|
||||||
|
#产生JSON文件
|
||||||
|
with open(output_config_name, 'w', encoding='utf-8') as f:
|
||||||
|
json.dump(output_json, f, ensure_ascii=False, indent=4)
|
||||||
|
logging.info("Generate AutoUpgrade Configfile to Complete and Jsonfile(%s) to complete... ",output_config_name)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(e)
|
logging.error(e)
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ __all__ = (
|
||||||
"ERROR_NOT_INIT_PACKAGESINFIO","ERROR_READ_IMPORTANTLIST_FAILED","ERROR_RESOLVER_FAILED","ERROR_NOT_UPGRADE_PACKAGES",
|
"ERROR_NOT_INIT_PACKAGESINFIO","ERROR_READ_IMPORTANTLIST_FAILED","ERROR_RESOLVER_FAILED","ERROR_NOT_UPGRADE_PACKAGES",
|
||||||
"ERROR_REMOVE_ESSENTIAL_PACKAGES","ERROR_NOT_DISK_SPACE",
|
"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")
|
"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"
|
ERROR_UPDATE_KEY_SIGNATURES = "The following signatures"
|
||||||
|
ERROR_UPDATE_NET_AUTHENTICATION ="does the network require authentication?"
|
||||||
|
ERROR_UPDATE_NOTREAD_SOURCES = "The list of sources could not be read"
|
||||||
#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_SOURCE_FAILED = "error-update-source-failed"
|
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_REMOVE_ESSENTIAL_PACKAGES = "error-remove-essential-packages"
|
||||||
ERROR_NOT_DISK_SPACE = "error-not-disk-space"
|
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 = {
|
_DESCS_ERROR = {
|
||||||
ERROR_UPDATE_SOURCE_FAILED: _("Check your source management server config"),
|
ERROR_UPDATE_SOURCE_FAILED: _("Check your source management server config"),
|
||||||
|
@ -57,20 +62,20 @@ _DESCS_ERROR = {
|
||||||
ERROR_RESOLVER_FAILED: _("nothing"),
|
ERROR_RESOLVER_FAILED: _("nothing"),
|
||||||
ERROR_NOT_UPGRADE_PACKAGES: _("This update cannot detect the upgradeable package."),
|
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_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_NOTREAD_SOURCES: _("Please check your source list and retry.")
|
||||||
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")}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#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 = {
|
SOURCE_NAME = {
|
||||||
'kylin-installer':_("Kylin Installer"),
|
'kylin-installer':_("Kylin Installer"),
|
||||||
|
|
|
@ -61,7 +61,7 @@ import struct
|
||||||
# 禁止关机锁文件路径
|
# 禁止关机锁文件路径
|
||||||
FILELOCK_PATH = "/tmp/lock/"
|
FILELOCK_PATH = "/tmp/lock/"
|
||||||
SHUTDOWN_BLOCK_FILELOCK = "kylin-update.lock"
|
SHUTDOWN_BLOCK_FILELOCK = "kylin-update.lock"
|
||||||
pidfile = None
|
inhibit_lock = None
|
||||||
VERIFY_SO = "libkylin_signtool.so"
|
VERIFY_SO = "libkylin_signtool.so"
|
||||||
|
|
||||||
class ExecutionTime(object):
|
class ExecutionTime(object):
|
||||||
|
@ -662,62 +662,40 @@ def get_package_label(pkg):
|
||||||
|
|
||||||
#安装时禁止关机 进行加锁
|
#安装时禁止关机 进行加锁
|
||||||
def LockedPreventShutdown():
|
def LockedPreventShutdown():
|
||||||
global pidfile
|
global inhibit_lock
|
||||||
|
"""
|
||||||
#不为空是表示以及被锁
|
Send a dbus signal to logind to not suspend the system, it will be
|
||||||
if pidfile != None:
|
released when the return value drops out of scope
|
||||||
logging.error("pidfile file disc not is None,Has been locked...")
|
"""
|
||||||
return False
|
|
||||||
|
|
||||||
if not os.path.exists(FILELOCK_PATH):
|
|
||||||
#不存在创建
|
|
||||||
logging.info("File(%s) is not exists and will be create",FILELOCK_PATH)
|
|
||||||
os.makedirs(FILELOCK_PATH)
|
|
||||||
else:
|
|
||||||
#当目录存在时进行删除 不删除进行创建文件的话会报错
|
|
||||||
# file cannot be locked.[Errno 11] Resource temporarily unavailable
|
|
||||||
# 资源被占用报错
|
|
||||||
shutil.rmtree(FILELOCK_PATH)
|
|
||||||
logging.info("File(%s) is exists and will be delete and create",FILELOCK_PATH)
|
|
||||||
os.makedirs(FILELOCK_PATH)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pidfile = open(os.path.join(FILELOCK_PATH, SHUTDOWN_BLOCK_FILELOCK), "w+")
|
from gi.repository import Gio, GLib
|
||||||
fcntl.flock(pidfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
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...")
|
logging.info("Shutdown Has been locked...")
|
||||||
return True
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error("file cannot be locked." + str(e))
|
logging.error(e)
|
||||||
pidfile.close()
|
|
||||||
pidfile = None
|
|
||||||
return False
|
|
||||||
|
|
||||||
#解锁禁止关机
|
#解锁禁止关机
|
||||||
def unLockedEnableShutdown():
|
def unLockedEnableShutdown():
|
||||||
global pidfile
|
global inhibit_lock
|
||||||
#未加锁退出
|
|
||||||
if not pidfile:
|
|
||||||
logging.info("Not locked and Quitting ...")
|
|
||||||
return False
|
|
||||||
try:
|
try:
|
||||||
fcntl.flock(pidfile, fcntl.LOCK_UN)
|
if inhibit_lock != None:
|
||||||
logging.info("Shutdown Has been unlocked...")
|
inhibit_lock.close()
|
||||||
pidfile.close()
|
logging.info("Shutdown Has been unlocked...")
|
||||||
pidfile = None
|
inhibit_lock == None
|
||||||
|
|
||||||
# Fix 修复权限问题 当普通用户无法使用 所以直接删除目录
|
|
||||||
if os.path.exists(FILELOCK_PATH):
|
|
||||||
shutil.rmtree(FILELOCK_PATH)
|
|
||||||
logging.info('Emptying the lockPath(%s) is complete...',FILELOCK_PATH)
|
|
||||||
else:
|
else:
|
||||||
logging.info("Emptying the lockPath(%s) is Failed...",FILELOCK_PATH)
|
logging.info("Not locked and Quitting ...")
|
||||||
|
|
||||||
return True
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error("unlock failed." + str(e))
|
logging.error("unlock failed." + str(e))
|
||||||
pidfile.close()
|
|
||||||
pidfile = None
|
|
||||||
return False
|
|
||||||
|
|
||||||
# 查看uu进程是否需要kill
|
# 查看uu进程是否需要kill
|
||||||
def kill_process(path):
|
def kill_process(path):
|
||||||
|
|
|
@ -77,8 +77,30 @@ class UpdateManager():
|
||||||
self.install_mode = UpdateInstallMode(self)
|
self.install_mode = UpdateInstallMode(self)
|
||||||
|
|
||||||
self.apt_p2p_config = AptP2pConfigManager()
|
self.apt_p2p_config = AptP2pConfigManager()
|
||||||
|
|
||||||
|
self._reload_options_config()
|
||||||
|
#加载Cache
|
||||||
|
self._refresh_cache_only()
|
||||||
|
|
||||||
self.refresh_cache()
|
|
||||||
|
def _reload_options_config(self):
|
||||||
|
#添加默认保留旧配置
|
||||||
|
apt_pkg.config["DPkg::Options::"] = "--force-confold"
|
||||||
|
options_new = list(set(apt_pkg.config.value_list("DPkg::Options")))
|
||||||
|
for option in ("--force-confnew","--force-confdef"):
|
||||||
|
if option in options_new:
|
||||||
|
options_new.remove(option)
|
||||||
|
#清除所有配置重新加载
|
||||||
|
apt_pkg.config.clear("DPkg::Options")
|
||||||
|
for option in options_new:
|
||||||
|
apt_pkg.config["DPkg::Options::"] = option
|
||||||
|
#去除安装推荐和建议的软件包
|
||||||
|
if apt_pkg.config.find_b("APT::Install-Recommends",False) == True:
|
||||||
|
apt_pkg.config.clear("APT::Install-Recommends")
|
||||||
|
if apt_pkg.config.find_b("APT::Install-Suggests",False) == True:
|
||||||
|
apt_pkg.config.clear("APT::Install-Suggests")
|
||||||
|
|
||||||
|
apt_pkg.init_system()
|
||||||
|
|
||||||
def check_config_patch(self):
|
def check_config_patch(self):
|
||||||
NOW_UPDATE_CONFIG = '/usr/share/kylin-update-desktop-config/config/'
|
NOW_UPDATE_CONFIG = '/usr/share/kylin-update-desktop-config/config/'
|
||||||
|
@ -257,6 +279,17 @@ class UpdateManager():
|
||||||
logging.error(str(e))
|
logging.error(str(e))
|
||||||
raise UpdateBaseError(ERROR_NOT_INIT_PACKAGESINFIO)
|
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):
|
def _check_self_upgrade(self,cache):
|
||||||
need_upgrade = False
|
need_upgrade = False
|
||||||
|
|
||||||
|
@ -835,13 +868,23 @@ class UpdateSourceInfo():
|
||||||
return
|
return
|
||||||
|
|
||||||
class AptP2pConfigManager():
|
class AptP2pConfigManager():
|
||||||
|
APT_P2P_FILE = "/etc/apt-p2p/apt-p2p.conf"
|
||||||
|
HEADER_DSC = "apt-p2p config(/etc/apt-p2p/apt-p2p.conf) is not exists..."
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.p2pConfigs = UpgradeConfig(datadir = "/etc/apt-p2p/", name = "apt-p2p.cof")
|
if os.path.exists(self.APT_P2P_FILE):
|
||||||
|
self.p2pConfigs = UpgradeConfig(datadir = "/etc/apt-p2p/", name = "apt-p2p.conf")
|
||||||
|
else:
|
||||||
|
self.p2pConfigs = None
|
||||||
|
|
||||||
def get_bootstrap(self):
|
def get_bootstrap(self):
|
||||||
|
if self.p2pConfigs == None:
|
||||||
|
return self.HEADER_DSC
|
||||||
|
|
||||||
return self.p2pConfigs.getWithDefault("apt_p2p_Khashmir", "BOOTSTRAP", "Failed")
|
return self.p2pConfigs.getWithDefault("apt_p2p_Khashmir", "BOOTSTRAP", "Failed")
|
||||||
|
|
||||||
def set_bootstrap(self,value):
|
def set_bootstrap(self,value):
|
||||||
|
if self.p2pConfigs == None:
|
||||||
|
return self.HEADER_DSC
|
||||||
self.p2pConfigs.setValue("apt_p2p_Khashmir","BOOTSTRAP",str(value))
|
self.p2pConfigs.setValue("apt_p2p_Khashmir","BOOTSTRAP",str(value))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -894,7 +894,13 @@ class UpdateManagerDbusController(dbus.service.Object):
|
||||||
@dbus.service.signal(UPDATER_DBUS_INTERFACE)
|
@dbus.service.signal(UPDATER_DBUS_INTERFACE)
|
||||||
def ChangeUpgradePolicy(self):
|
def ChangeUpgradePolicy(self):
|
||||||
logging.info(COLORLOG_PREFIX + "Emitting" + COLORLOG_SUFFIX +" ChangeUpgradePolicy")
|
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 = ()
|
WRITABLE_PROPERTIES = ()
|
||||||
|
|
||||||
# pylint: disable-msg=C0103,C0322
|
# pylint: disable-msg=C0103,C0322
|
||||||
|
|
|
@ -410,7 +410,7 @@ class InstallBackendAptdaemon(InstallBackend):
|
||||||
logging.info("Config file conflict oldconf = %s , newconf = %s...",str(old),str(new))
|
logging.info("Config file conflict oldconf = %s , newconf = %s...",str(old),str(new))
|
||||||
logging.info("Default To Replace Old Configfile...")
|
logging.info("Default To Replace Old Configfile...")
|
||||||
#默认替换旧的配置文件
|
#默认替换旧的配置文件
|
||||||
transaction.resolve_config_file_conflict(old, "replace")
|
transaction.resolve_config_file_conflict(old, "keep")
|
||||||
# transaction.resolve_config_file_conflict(old, "keep")
|
# transaction.resolve_config_file_conflict(old, "keep")
|
||||||
|
|
||||||
#增加记录当产生错误的时候 详细信息
|
#增加记录当产生错误的时候 详细信息
|
||||||
|
|
|
@ -286,7 +286,7 @@ class InstallBackend():
|
||||||
self.window_main.check_conifg_aptdeamon()
|
self.window_main.check_conifg_aptdeamon()
|
||||||
self.update()
|
self.update()
|
||||||
except UpdateBaseError as excep:
|
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:
|
except UpdateProgressExit as excep:
|
||||||
pass
|
pass
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -521,18 +521,23 @@ class InstallBackend():
|
||||||
logging.error("Package("+pkg+") "+ str(e))
|
logging.error("Package("+pkg+") "+ str(e))
|
||||||
return [],[]
|
return [],[]
|
||||||
|
|
||||||
#调用aptdeamon结束之后处理的地方 不管是出错还是正常都在此处理
|
def _send_error_code(self,error_code):
|
||||||
def _action_done(self, action, is_cancelled,success, error_string,error_desc):
|
if error_code == ERROR_NOT_DISK_SPACE:
|
||||||
#后端的状态 到空闲状态
|
self.window_main.dbusController.InstallDetectStatus(False,error_code)
|
||||||
self.window_main.now_working = self.ACTION_DEFUALT_STATUS
|
|
||||||
|
|
||||||
|
#调用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:
|
if action == self.ACTION_INSTALL:
|
||||||
#记录这个过程中是否关机
|
#记录这个过程中是否关机
|
||||||
self.window_main.configs.setValue("SystemStatus","abnormal_reboot",str(False),True)
|
self.window_main.configs.setValue("SystemStatus","abnormal_reboot",str(False),True)
|
||||||
#解锁 禁止关机
|
#解锁 禁止关机
|
||||||
unLockedEnableShutdown()
|
unLockedEnableShutdown()
|
||||||
|
self._send_error_code(error_code)
|
||||||
|
|
||||||
#单包安装模式 单独处理 目前 更新配置包和升级本身使用
|
#单包安装模式 单独处理 目前 更新配置包和升级本身使用
|
||||||
if self.action_mode == self.MODE_INSTALL_SINGLE:
|
if self.action_mode == self.MODE_INSTALL_SINGLE:
|
||||||
if success:
|
if success:
|
||||||
|
@ -673,27 +678,28 @@ class InstallBackend():
|
||||||
|
|
||||||
self.window_main.dbusController.UpdateDownloadFinished(success,self.now_upgrade.upgrade_content,error_string,error_desc)
|
self.window_main.dbusController.UpdateDownloadFinished(success,self.now_upgrade.upgrade_content,error_string,error_desc)
|
||||||
|
|
||||||
elif action == self.ACTION_UPDATE:
|
elif action == self.ACTION_UPDATE and self.action_mode == self.MODE_UPDATE_ALL:
|
||||||
if success == False and ERROR_UPDATE_KEY_SIGNATURES in self.aptd_base.error_details:
|
if success == False:
|
||||||
error_desc = _("Check your source public key signature")
|
threading_emulate = threading.Thread(target=self.emulate_update)
|
||||||
#网络认证错误
|
threading_emulate.start()
|
||||||
elif success == False and 'does the network require authentication?' in self.aptd_base.error_details:
|
|
||||||
error_desc = _("Check if your network requires authentication?")
|
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 and self.action_mode == self.MODE_UPDATE_ALL:
|
if success:
|
||||||
#开始生成列表
|
#开始生成列表
|
||||||
self.window_main.start_available()
|
self.window_main.start_available()
|
||||||
else:
|
else:
|
||||||
self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string+','+error_desc,error_desc)
|
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())
|
||||||
#记录本次更新时间插入数据库
|
|
||||||
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:
|
|
||||||
threading_emulate = threading.Thread(target=self.emulate_update)
|
|
||||||
threading_emulate.start()
|
|
||||||
|
|
||||||
|
elif action == self.ACTION_UPDATE and self.action_mode == self.MODE_UPDATE_CACHE:
|
||||||
|
self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string+','+error_desc,error_desc)
|
||||||
elif action == self.ACTION_FIX_BROKEN:
|
elif action == self.ACTION_FIX_BROKEN:
|
||||||
self.window_main.dbusController.FixBrokenStatusChanged(True,success,100,'',error_string,error_desc)
|
self.window_main.dbusController.FixBrokenStatusChanged(True,success,100,'',error_string,error_desc)
|
||||||
logging.warning("fix broken packages is complete...")
|
logging.warning("fix broken packages is complete...")
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
[AutoUpgrade]
|
|
||||||
upgradelist =
|
|
||||||
|
|
||||||
[SystemStatus]
|
[SystemStatus]
|
||||||
abnormal_reboot = False
|
abnormal_reboot = False
|
||||||
close_source_filter = False
|
close_source_filter = 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"])
|
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:
|
if app.configs.getWithDefault("ConfigPkgStatus", "check_frontend_pkg", False) == True:
|
||||||
app.configs.setValue("ConfigPkgStatus","check_frontend_pkg",str(False),True)
|
app.configs.setValue("ConfigPkgStatus","check_frontend_pkg",str(False),True)
|
||||||
app.check_frontend_pkg()
|
app.check_frontend_pkg()
|
||||||
|
|
||||||
#当出现安装过程中异常的重启时 开机直接进行修复操作
|
#当出现安装过程中异常的重启时 开机直接进行修复操作
|
||||||
if app.configs.getWithDefault("SystemStatus", "abnormal_reboot", False) == True:
|
if app.configs.getWithDefault("SystemStatus", "abnormal_reboot", False) == True:
|
||||||
app.start_update()
|
app.start_update()
|
||||||
|
|
||||||
app.run()
|
app.run()
|
||||||
except Exception as e:
|
|
||||||
logging.error(e)
|
|
|
@ -2625,6 +2625,9 @@ msgstr "磁盘空间不足,请清理磁盘后进行升级更新"
|
||||||
msgid "Please check your network connection and retry."
|
msgid "Please check your network connection and retry."
|
||||||
msgstr "请检查您的网络连接后再试。"
|
msgstr "请检查您的网络连接后再试。"
|
||||||
|
|
||||||
|
msgid "Please check your source list and retry."
|
||||||
|
msgstr "请检查您的源列表后再试。"
|
||||||
|
|
||||||
msgid "Checking network connection"
|
msgid "Checking network connection"
|
||||||
msgstr "检查网络连接中"
|
msgstr "检查网络连接中"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue