diff --git a/backend/SystemUpdater/UpdateManager.py b/backend/SystemUpdater/UpdateManager.py index d4dbd3a..ad55e0e 100644 --- a/backend/SystemUpdater/UpdateManager.py +++ b/backend/SystemUpdater/UpdateManager.py @@ -54,7 +54,6 @@ 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) @@ -441,6 +440,11 @@ class UpdateManager(): 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): with cache.actiongroup(): if cache.get_changes(): diff --git a/backend/SystemUpdater/backend/__init__.py b/backend/SystemUpdater/backend/__init__.py index 1ec1e08..e9b07b0 100644 --- a/backend/SystemUpdater/backend/__init__.py +++ b/backend/SystemUpdater/backend/__init__.py @@ -7,7 +7,7 @@ import logging import os from gettext import gettext as _ -import apt_pkg +import apt from SystemUpdater.Core.utils import ( unLockedEnableShutdown, check_free_space, @@ -330,14 +330,18 @@ class InstallBackend(): with cache.actiongroup(): if cache.get_changes(): cache.clear() - Fix = apt_pkg.ProblemResolver(cache._depcache) + resolver = apt.cache.ProblemResolver(cache) #计算出来的需要删除的包列表 all_delete_pkgs = [] all_delete_desc = [] #标记计算所有需要升级的包 for pkg in pkgs_upgrade: - cache[pkg].mark_upgrade() + cache[pkg].mark_install(False, False, True) + + resolver.clear(cache[pkg]) + resolver.protect(cache[pkg]) + deleted_pkgs = self._make_delete_pkgs(cache,all_delete_pkgs) for d_pkg in deleted_pkgs: delete_desc = str(d_pkg) + _(" Will be deleted Due to Upgrade ") + str(pkg) @@ -346,14 +350,17 @@ class InstallBackend(): #标记计算所有需要安装的 for pkg in pkgs_install: - cache[pkg].mark_install() + cache[pkg].mark_install(False, False,True) + + resolver.clear(cache[pkg]) + resolver.protect(cache[pkg]) deleted_pkgs = self._make_delete_pkgs(cache,all_delete_pkgs) for d_pkg in deleted_pkgs: delete_desc = str(d_pkg) + _(" Will be deleted Due to Install ") + str(pkg) all_delete_desc.append(delete_desc) logging.warning(delete_desc) #会安装新包和卸载包 - Fix.resolve() + resolver.resolve() #不会安装和卸载 只升级 return _success,all_delete_pkgs,all_delete_desc,header,desc except Exception as e: diff --git a/backend/data/kylin-logout-required b/backend/data/kylin-logout-required new file mode 100755 index 0000000..c066434 --- /dev/null +++ b/backend/data/kylin-logout-required @@ -0,0 +1,26 @@ +#!/bin/sh + +# a) it breaks if its not available +# b) the string we have here does not need it (because it has no vars) +eval_gettext() { + if [ -x /usr/bin/gettext ]; then + echo $(gettext "$1") + else + echo "$1" + fi +} +export TEXTDOMAIN=update-notifier +export TEXTDOMAINDIR=/usr/share/locale + +case "$DPKG_MAINTSCRIPT_PACKAGE::$DPKG_MAINTSCRIPT_NAME" in + linux-image-extra*::postrm) + exit 0;; +esac + +if [ "$0" = "/etc/kernel/postinst.d/update-notifier" ]; then + DPKG_MAINTSCRIPT_PACKAGE=linux-base +fi + +# Wake the applet up +echo "*** $(eval_gettext "System logout required") ***" > /var/run/logout-required +echo "$DPKG_MAINTSCRIPT_PACKAGE" >> /var/run/logout-required.pkgs diff --git a/backend/data/kylin-reboot-required b/backend/data/kylin-reboot-required new file mode 100755 index 0000000..b88ab36 --- /dev/null +++ b/backend/data/kylin-reboot-required @@ -0,0 +1,26 @@ +#!/bin/sh + +# a) it breaks if its not available +# b) the string we have here does not need it (because it has no vars) +eval_gettext() { + if [ -x /usr/bin/gettext ]; then + echo $(gettext "$1") + else + echo "$1" + fi +} +export TEXTDOMAIN=update-notifier +export TEXTDOMAINDIR=/usr/share/locale + +case "$DPKG_MAINTSCRIPT_PACKAGE::$DPKG_MAINTSCRIPT_NAME" in + linux-image-extra*::postrm) + exit 0;; +esac + +if [ "$0" = "/etc/kernel/postinst.d/update-notifier" ]; then + DPKG_MAINTSCRIPT_PACKAGE=linux-base +fi + +# Wake the applet up +echo "*** $(eval_gettext "System restart required") ***" > /var/run/reboot-required +echo "$DPKG_MAINTSCRIPT_PACKAGE" >> /var/run/reboot-required.pkgs diff --git a/backend/setup.cfg b/backend/setup.cfg index 40e8a37..312b9e8 100644 --- a/backend/setup.cfg +++ b/backend/setup.cfg @@ -5,7 +5,7 @@ domain=kylin-system-updater formats = bztar [nosetests] -match=^test +match=test [install] skip-build=0 diff --git a/debian/kylin-system-updater.install b/debian/kylin-system-updater.install index 3f1b6a1..70ea54e 100644 --- a/debian/kylin-system-updater.install +++ b/debian/kylin-system-updater.install @@ -3,6 +3,8 @@ backend/data/kylin-system-updater.db /usr/share/kylin-system-updater/ backend/data/30kylin-system-updater /etc/apt/apt.conf.d/ backend/data/com.kylin.systemupgrade.conf /etc/dbus-1/system.d/ backend/data/kylin-system-updater.service /usr/lib/systemd/system/ +backend/data/kylin-logout-required /usr/share/kylin-system-updater/ +backend/data/kylin-reboot-required /usr/share/kylin-system-updater/ backend/kylin-system-updater /usr/share/kylin-system-updater/ backend/SystemUpdater/*.py /usr/share/kylin-system-updater/SystemUpdater/ backend/SystemUpdater/backend/*.py /usr/share/kylin-system-updater/SystemUpdater/backend/