From 76620a38559948a69f6d4d8c57a865ba60b9ee3c Mon Sep 17 00:00:00 2001 From: wangsong Date: Tue, 18 Jan 2022 09:36:13 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=8A=9E=E6=B3=95=EF=BC=8C=E5=BD=93=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E7=BC=BA=E5=B0=91=E4=BE=9D=E8=B5=96=E7=9A=84=E8=BD=AF?= =?UTF-8?q?=E4=BB=B6=E5=8C=85=E6=97=B6=E5=BC=B9=E5=87=BA=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/backend/__init__.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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: From 173fcaa2dfe67df9179a6f1ed3d3c9a23a377823 Mon Sep 17 00:00:00 2001 From: wangsong Date: Tue, 18 Jan 2022 09:58:55 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=87=8D=E5=90=AF?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/data/kylin-logout-required | 27 +++++++++++++++++++++++++++ backend/data/kylin-reboot-required | 27 +++++++++++++++++++++++++++ debian/kylin-system-updater.install | 2 ++ 3 files changed, 56 insertions(+) create mode 100755 backend/data/kylin-logout-required create mode 100755 backend/data/kylin-reboot-required diff --git a/backend/data/kylin-logout-required b/backend/data/kylin-logout-required new file mode 100755 index 0000000..10e8882 --- /dev/null +++ b/backend/data/kylin-logout-required @@ -0,0 +1,27 @@ +#!/bin/sh + +# we do not include ". gettext.sh" here because: +# 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..f2ecd7b --- /dev/null +++ b/backend/data/kylin-reboot-required @@ -0,0 +1,27 @@ +#!/bin/sh + +# we do not include ". gettext.sh" here because: +# 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/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/ From a816b5b9205da7593e6968aae4e31d324e9e145e Mon Sep 17 00:00:00 2001 From: wangsong Date: Tue, 18 Jan 2022 10:21:16 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=87=8D=E5=90=AF?= =?UTF-8?q?=E5=92=8C=E6=B3=A8=E9=94=80=E7=9A=84=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/data/kylin-logout-required | 1 - backend/data/kylin-reboot-required | 1 - 2 files changed, 2 deletions(-) diff --git a/backend/data/kylin-logout-required b/backend/data/kylin-logout-required index 10e8882..c066434 100755 --- a/backend/data/kylin-logout-required +++ b/backend/data/kylin-logout-required @@ -1,6 +1,5 @@ #!/bin/sh -# we do not include ". gettext.sh" here because: # a) it breaks if its not available # b) the string we have here does not need it (because it has no vars) eval_gettext() { diff --git a/backend/data/kylin-reboot-required b/backend/data/kylin-reboot-required index f2ecd7b..b88ab36 100755 --- a/backend/data/kylin-reboot-required +++ b/backend/data/kylin-reboot-required @@ -1,6 +1,5 @@ #!/bin/sh -# we do not include ". gettext.sh" here because: # a) it breaks if its not available # b) the string we have here does not need it (because it has no vars) eval_gettext() { From bebd7ce70d579c901b16282bccad0b0da73a85da Mon Sep 17 00:00:00 2001 From: wangsong Date: Tue, 18 Jan 2022 13:45:49 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E8=AF=BB=E5=8F=96=E6=B3=A8=E9=94=80?= =?UTF-8?q?=E7=9A=84=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/UpdateManager.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/SystemUpdater/UpdateManager.py b/backend/SystemUpdater/UpdateManager.py index 7152b45..5f40b1d 100644 --- a/backend/SystemUpdater/UpdateManager.py +++ b/backend/SystemUpdater/UpdateManager.py @@ -441,6 +441,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(): From 122b35dcb3337fe8b09633c29bf075b000a728a1 Mon Sep 17 00:00:00 2001 From: wangsong Date: Tue, 18 Jan 2022 13:51:19 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/UpdateManager.py | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/SystemUpdater/UpdateManager.py b/backend/SystemUpdater/UpdateManager.py index 5f40b1d..fb74d2b 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) From 6bb54af7654d7e76178782fbaf2207977665ab1c Mon Sep 17 00:00:00 2001 From: wangsong Date: Tue, 18 Jan 2022 17:27:15 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E4=B9=B1=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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