对优先升级做出改动 加入控制面板插件包的自我升级
This commit is contained in:
parent
0438fe76d8
commit
5b2f2a2e1a
|
@ -29,7 +29,8 @@ from SystemUpdater.Core.DpkgInstallProgress import LogInstallProgress
|
|||
from SystemUpdater.Core.utils import inhibit_sleep,plymouth_splash
|
||||
|
||||
class UpdateManager():
|
||||
SELF_PKG_NAME = 'kylin-system-updater'
|
||||
BACKEND_PKG_NAME = 'kylin-system-updater'
|
||||
FRONTEND_PKG_NAME = "kylin-update-frontend"
|
||||
GROUPS_PKG_NAME = 'kylin-update-desktop-config'
|
||||
APTD_PKG_NAME = "aptdaemon"
|
||||
INSTALL_ALONE_PROGRESS = "alone"
|
||||
|
@ -408,16 +409,10 @@ class UpdateManager():
|
|||
if _success == False:
|
||||
return _success,header,desc
|
||||
|
||||
#检查自己是否需要升级更新
|
||||
if self.options.no_check_selfupgrade is False:
|
||||
_success,header,desc = self._check_aptd_upgrade(self.cache)
|
||||
if _success == False:
|
||||
return _success,header,desc
|
||||
|
||||
#检查更新分组配置表
|
||||
_success,header,desc = self._check_group_config(self.cache)
|
||||
if _success == False and self.configs.getWithDefault("ConfigPkgStatus", "mustexistconfigpkg", True) == True:
|
||||
return _success,header,desc
|
||||
# #检查更新分组配置表
|
||||
# _success,header,desc = self._check_group_config(self.cache)
|
||||
# if _success == False and self.configs.getWithDefault("ConfigPkgStatus", "mustexistconfigpkg", True) == True:
|
||||
# return _success,header,desc
|
||||
|
||||
try:
|
||||
_success,header,desc = self.update_list.update(self.cache)
|
||||
|
@ -429,32 +424,92 @@ class UpdateManager():
|
|||
_success = True
|
||||
header = ''
|
||||
desc = ''
|
||||
need_upgrade = False
|
||||
configpkg_error = False
|
||||
#2、 安装JSON分组配置文件包 安装完毕会重新调start_available --> here 安装失败就直接退出不会进行下面的操作
|
||||
try:
|
||||
if self.SELF_PKG_NAME in cache:
|
||||
self_pkg = cache[self.SELF_PKG_NAME]
|
||||
#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: Self-Updater(%s) start upgrading From %s to %s...",self.SELF_PKG_NAME,\
|
||||
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)
|
||||
self_pkg.mark_upgrade()
|
||||
|
||||
self.start_install(InstallBackend.MODE_INSTALL_SINGLE,True)
|
||||
#直接退出 进行安装程序
|
||||
_success = False
|
||||
header = self.INSTALL_ALONE_PROGRESS
|
||||
return _success,header,desc
|
||||
self_pkg.mark_install()
|
||||
need_upgrade = True
|
||||
else:
|
||||
logging.info("Check: Self-Updater(%s:%s) No need to upgrade...",self.SELF_PKG_NAME,self_pkg.installed.source_version)
|
||||
#直接退出 进行之后的动作
|
||||
_success = True
|
||||
return _success,header,desc
|
||||
logging.info("Check: Updater(%s:%s) No need to upgrade...",self.BACKEND_PKG_NAME,self_pkg.installed.source_version)
|
||||
else:
|
||||
#没有在cache中就认为不需要升级
|
||||
logging.error("Check: Self-Updater(%s) The upgrade package is not in Cache...",self.SELF_PKG_NAME)
|
||||
#直接退出 进行之后的动作
|
||||
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)
|
||||
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:
|
||||
#没有在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 and self_pkg.is_upgradable:
|
||||
logging.info("Check: Frontend(%s) start upgrading From %s to %s...",self.FRONTEND_PKG_NAME,\
|
||||
self_pkg.installed.source_version,self_pkg.candidate.source_version)
|
||||
self_pkg.mark_install()
|
||||
need_upgrade = True
|
||||
else:
|
||||
logging.info("Check: Frontend(%s:%s) No need to upgrade...",self.FRONTEND_PKG_NAME,self_pkg.installed.source_version)
|
||||
else:
|
||||
#没有在cache中就认为不需要升级
|
||||
logging.error("Check: Frontend(%s) The upgrade package is not in Cache...",self.FRONTEND_PKG_NAME)
|
||||
|
||||
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.BACKEND_PKG_NAME,\
|
||||
pkg_json.installed.source_version,pkg_json.candidate.source_version)
|
||||
pkg_json.mark_install()
|
||||
need_upgrade = True
|
||||
else:
|
||||
logging.info("Check: ConfigPkgs(%s:%s) No need to upgrade...",self.GROUPS_PKG_NAME,pkg_json.installed.source_version)
|
||||
else:
|
||||
self.dbusController.UpdateDetectStatusChanged(95,_("Group configuration being updated"))
|
||||
logging.info("Check: groups JSON ConfigPkgs(%s) start new installing...",self.GROUPS_PKG_NAME)
|
||||
pkg_json.mark_install()
|
||||
need_upgrade = True
|
||||
else:
|
||||
header = _("Unable to get group configuration package, please contact administrator to solve")
|
||||
desc = _("groups JSON ConfigPkgs install failed")
|
||||
logging.error("Check: groups JSON ConfigPkgs(%s) install failed...",self.GROUPS_PKG_NAME)
|
||||
configpkg_error = True
|
||||
_success = False
|
||||
|
||||
if need_upgrade == True:
|
||||
self.start_install(InstallBackend.MODE_INSTALL_SINGLE,True)
|
||||
#直接退出 进行安装程序
|
||||
_success = False
|
||||
header = self.INSTALL_ALONE_PROGRESS
|
||||
return _success,header,desc
|
||||
elif need_upgrade == False and configpkg_error == True:
|
||||
_success = False
|
||||
return _success,header,desc
|
||||
else:
|
||||
_success = True
|
||||
return _success,header,desc
|
||||
return _success,header,desc
|
||||
|
||||
#FIXME: 错误处理未做 报告到控制面板
|
||||
except Exception as e:
|
||||
|
@ -475,7 +530,7 @@ class UpdateManager():
|
|||
#是否可升级
|
||||
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.SELF_PKG_NAME,\
|
||||
logging.info("Check: groups JSON ConfigPkgs(%s) start upgrading From %s to %s...",self.BACKEND_PKG_NAME,\
|
||||
pkg_json.installed.source_version,pkg_json.candidate.source_version)
|
||||
pkg_json.mark_upgrade()
|
||||
|
||||
|
@ -510,43 +565,6 @@ class UpdateManager():
|
|||
|
||||
return _success,header,desc
|
||||
|
||||
def _check_aptd_upgrade(self,cache):
|
||||
_success = True
|
||||
header = ''
|
||||
desc = ''
|
||||
#2、 安装JSON分组配置文件包 安装完毕会重新调start_available --> here 安装失败就直接退出不会进行下面的操作
|
||||
try:
|
||||
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)
|
||||
self_pkg.mark_upgrade()
|
||||
|
||||
self.start_install(InstallBackend.MODE_INSTALL_SINGLE,True)
|
||||
#直接退出 进行安装程序
|
||||
_success = False
|
||||
header = self.INSTALL_ALONE_PROGRESS
|
||||
return _success,header,desc
|
||||
else:
|
||||
logging.info("Check: Aptdaemon(%s:%s) No need to upgrade...",self.APTD_PKG_NAME,self_pkg.installed.source_version)
|
||||
#直接退出 进行之后的动作
|
||||
_success = True
|
||||
return _success,header,desc
|
||||
else:
|
||||
#没有在cache中就认为不需要升级
|
||||
logging.error("Check: Aptdaemon(%s) The upgrade package is not in Cache...",self.APTD_PKG_NAME)
|
||||
#直接退出 进行之后的动作
|
||||
_success = True
|
||||
return _success,header,desc
|
||||
|
||||
#FIXME: 错误处理未做 报告到控制面板
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
_success = True
|
||||
return _success,header,desc
|
||||
|
||||
def _check_system_broken(self,cache):
|
||||
_success = True
|
||||
header = ''
|
||||
|
|
|
@ -453,20 +453,29 @@ class InstallBackend():
|
|||
#单包安装模式 单独处理 目前 更新配置包和升级本身使用
|
||||
if self.action_mode == self.MODE_INSTALL_SINGLE:
|
||||
if success:
|
||||
#当单包升级的时候 升级本身时,让程序退出,再重新启动
|
||||
if self.window_main.SELF_PKG_NAME in self.cache and self.cache[self.window_main.SELF_PKG_NAME] in self.cache.get_changes():
|
||||
error_string = _("Update Manager upgrade is complete, please restart the control panel before performing the system update")
|
||||
self.window_main.dbusController.DistUpdateDetectFinished(False,[self.window_main.SELF_PKG_NAME],error_string,error_desc)
|
||||
#升级本身完成后 退出 有systemd 来进行重启服务
|
||||
self.window_main.dbusController.Quit(None)
|
||||
elif self.window_main.APTD_PKG_NAME in self.cache and self.cache[self.window_main.APTD_PKG_NAME] in self.cache.get_changes():
|
||||
#升级本身完成后 直接重启aptd
|
||||
if self.window_main.APTD_PKG_NAME in self.cache and self.cache[self.window_main.APTD_PKG_NAME] in self.cache.get_changes():
|
||||
error_string = _("Update Manager upgrade is complete, please restart the control panel before performing the system update")
|
||||
self.window_main.dbusController.DistUpdateDetectFinished(False,[self.window_main.APTD_PKG_NAME],error_string,error_desc)
|
||||
self.window_main.dbusController.make_aptdeamon_restart()
|
||||
else:
|
||||
|
||||
#当单包升级的时候 升级本身时,让程序退出,再重新启动
|
||||
if self.window_main.FRONTEND_PKG_NAME in self.cache and self.cache[self.window_main.FRONTEND_PKG_NAME] in self.cache.get_changes():
|
||||
error_string = _("Update Manager upgrade is complete, please restart the control panel before performing the system update")
|
||||
self.window_main.dbusController.DistUpdateDetectFinished(False,[self.window_main.FRONTEND_PKG_NAME],error_string,error_desc)
|
||||
|
||||
#当单包升级的时候 升级本身时,让程序退出,再重新启动
|
||||
if self.window_main.BACKEND_PKG_NAME in self.cache and self.cache[self.window_main.BACKEND_PKG_NAME] in self.cache.get_changes():
|
||||
error_string = _("Update Manager upgrade is complete, please restart the control panel before performing the system update")
|
||||
self.window_main.dbusController.DistUpdateDetectFinished(False,[self.window_main.BACKEND_PKG_NAME],error_string,error_desc)
|
||||
#升级本身完成后 退出 有systemd 来进行重启服务
|
||||
self.window_main.dbusController.Quit(None)
|
||||
return
|
||||
|
||||
#当单包升级的时候 升级本身时,让程序退出,再重新启动
|
||||
if self.window_main.GROUPS_PKG_NAME in self.cache and self.cache[self.window_main.GROUPS_PKG_NAME] in self.cache.get_changes():
|
||||
#只有安装配置文件包 才会走到此处
|
||||
self.window_main.start_available()
|
||||
|
||||
return
|
||||
else:
|
||||
#当更新过程中安装配置包时 失败时发送错误信号
|
||||
|
|
Loading…
Reference in New Issue