增加判断是否需要注销以及重启

This commit is contained in:
wangsong 2022-01-19 09:37:46 +08:00
parent ba170cd6ff
commit fed594d378
4 changed files with 42 additions and 14 deletions

View File

@ -275,8 +275,6 @@ class UpdateManager():
upgrade_list = self.update_list.local_upgrade_data.upgrade_groups + self.update_list.local_upgrade_data.single_pkgs upgrade_list = self.update_list.local_upgrade_data.upgrade_groups + self.update_list.local_upgrade_data.single_pkgs
#发送更新升级列表完成的标志 #发送更新升级列表完成的标志
self.dbusController.DistUpdateDetectFinished(_success,upgrade_list,header,desc) self.dbusController.DistUpdateDetectFinished(_success,upgrade_list,header,desc)
#检查安装完成之后需要重启吗
self.is_reboot_required()
#清空cache #清空cache
if self.cache != None and self.cache.get_changes(): if self.cache != None and self.cache.get_changes():
self.cache.clear() self.cache.clear()
@ -435,16 +433,6 @@ class UpdateManager():
return _success,header,desc return _success,header,desc
def is_reboot_required(self):
"""If a reboot is required to get all changes into effect."""
return os.path.exists(os.path.join(apt_pkg.config.find_dir("Dir"),
"var/run/reboot-required"))
def is_logout_required(self):
"""If a reboot is required to get all changes into effect."""
return os.path.exists(os.path.join(apt_pkg.config.find_dir("Dir"),
"var/run/logout-required"))
def _check_cache_broken(self,cache): def _check_cache_broken(self,cache):
with cache.actiongroup(): with cache.actiongroup():
if cache.get_changes(): if cache.get_changes():

View File

@ -558,3 +558,8 @@ class UpdateManagerDbusController(dbus.service.Object):
@dbus.service.signal(UPDATER_DBUS_INTERFACE, signature='sa{sv}') @dbus.service.signal(UPDATER_DBUS_INTERFACE, signature='sa{sv}')
def KumSnapSignal(self, type_msg, msg): def KumSnapSignal(self, type_msg, msg):
logging.info(COLORLOG_PREFIX + "Emitting" + COLORLOG_SUFFIX +" KumSnapSignal type_msg = %s,msg = %s",type_msg,str(msg)) logging.info(COLORLOG_PREFIX + "Emitting" + COLORLOG_SUFFIX +" KumSnapSignal type_msg = %s,msg = %s",type_msg,str(msg))
#重启和注销请求信号
@dbus.service.signal(UPDATER_DBUS_INTERFACE,signature='s')
def RebootLogoutRequired(self,required_status=''):
logging.info(COLORLOG_PREFIX + "Emitting"+ COLORLOG_SUFFIX + " RebootLogoutRequired required_status = %s",required_status)

View File

@ -8,6 +8,7 @@ import os
from gettext import gettext as _ from gettext import gettext as _
import apt import apt
import apt_pkg
from SystemUpdater.Core.utils import ( from SystemUpdater.Core.utils import (
unLockedEnableShutdown, unLockedEnableShutdown,
check_free_space, check_free_space,
@ -438,6 +439,12 @@ class InstallBackend():
self.window_main.dbusController.UpdateInstallFinished(success,upgrade_content,error_string,error_desc) self.window_main.dbusController.UpdateInstallFinished(success,upgrade_content,error_string,error_desc)
#更新完成之后检查是否需要重启
if self.is_reboot_required() == True:
self.window_main.dbusController.RebootLogoutRequired("reboot")
elif self.is_logout_required() == True:
self.window_main.dbusController.RebootLogoutRequired("logout")
elif action == self.ACTION_UPDATE: elif action == self.ACTION_UPDATE:
if success == False and 'The following signatures' in self.trans_error_details: if success == False and 'The following signatures' in self.trans_error_details:
error_desc = _("Check your source public key signature") error_desc = _("Check your source public key signature")
@ -541,6 +548,17 @@ class InstallBackend():
except Exception as e: except Exception as e:
logging.error(str(e)) logging.error(str(e))
def is_reboot_required(self):
"""If a reboot is required to get all changes into effect."""
return os.path.exists(os.path.join(apt_pkg.config.find_dir("Dir"),
"var/run/reboot-required"))
def is_logout_required(self):
"""If a logout is required to get all changes into effect."""
return os.path.exists(os.path.join(apt_pkg.config.find_dir("Dir"),
"var/run/logout-required"))
# try aptdaemon # try aptdaemon
if os.path.exists("/usr/sbin/aptd") \ if os.path.exists("/usr/sbin/aptd") \
and "UPDATE_MANAGER_FORCE_BACKEND_SYNAPTIC" not in os.environ: and "UPDATE_MANAGER_FORCE_BACKEND_SYNAPTIC" not in os.environ:

View File

@ -200,7 +200,7 @@
| FixBrokenStatusChanged | iiisss | 修复依赖的状态信号 | | FixBrokenStatusChanged | iiisss | 修复依赖的状态信号 |
| PurgePackagesFinished | iss | 卸载完成信号 | | PurgePackagesFinished | iss | 卸载完成信号 |
| PurgePkgStatusChanged | bss | 卸载进度信息以及状态信息 | | PurgePkgStatusChanged | bss | 卸载进度信息以及状态信息 |
| | | | | RebootLogoutRequired | s | 请求重启或者注销的信号 |
| | | | | | | |
@ -376,6 +376,23 @@
#### RebootLogoutRequired
- `介绍:`请求重启和注销的信号
- `出参`: `s:` "reboot" 表示重启 "logout"表示注销
- `示例:`
```sh
Emitting RebootLogoutRequired required_status = reboot
```
后端日志:`/var/log/kylin-system-updater/kylin-system-updater.log.1` 后端日志:`/var/log/kylin-system-updater/kylin-system-updater.log.1`