From 8d7313b9287bc7a9c83e8face74a7c09b08e5426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Wed, 5 Dec 2018 06:26:25 +0100 Subject: [PATCH] Fix updates notification on Fedora 29 Workaround for https://bugzilla.redhat.com/1650446 This caused not clearing updates-available flag after installing updates in the template. Fixes QubesOS/qubes-issues#2009 --- misc/dnf-qubes-hooks.py | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/misc/dnf-qubes-hooks.py b/misc/dnf-qubes-hooks.py index f9a8881..1771851 100644 --- a/misc/dnf-qubes-hooks.py +++ b/misc/dnf-qubes-hooks.py @@ -43,16 +43,28 @@ class QubesHooks(dnf.Plugin): config = self.read_config(self.base.conf) if config.getboolean('main', 'notify-updates'): - # Get all updates available _before_ this transaction - query = self.base.sack.query() - query = query.upgrades() - updates = set(query.run()) - # Get packages installed in this transaction... - just_installed = self.base.transaction - # ...and filter them out of available updates - for item in just_installed: - for pkg in item.installs(): - updates.discard(pkg) + if LooseVersion(dnf.const.VERSION) > '4.0.0': + # self.base.transaction empty at this point in dnf4 + # https://bugzilla.redhat.com/1650446 + # until fixed, load the repositories again and again check for + # updates + base = dnf.Base() + base.read_all_repos() + base.fill_sack() + query = base.sack.query() + query = query.upgrades() + updates = set(query.run()) + else: + # Get all updates available _before_ this transaction + query = self.base.sack.query() + query = query.upgrades() + updates = set(query.run()) + # Get packages installed in this transaction... + just_installed = self.base.transaction + # ...and filter them out of available updates + for item in just_installed: + for pkg in item.installs(): + updates.discard(pkg) subprocess.call([ '/usr/lib/qubes/qrexec-client-vm', 'dom0',