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
This commit is contained in:
Marek Marczykowski-Górecki 2018-12-05 06:26:25 +01:00
parent bb28efe628
commit 8d7313b928
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -43,16 +43,28 @@ class QubesHooks(dnf.Plugin):
config = self.read_config(self.base.conf) config = self.read_config(self.base.conf)
if config.getboolean('main', 'notify-updates'): if config.getboolean('main', 'notify-updates'):
# Get all updates available _before_ this transaction if LooseVersion(dnf.const.VERSION) > '4.0.0':
query = self.base.sack.query() # self.base.transaction empty at this point in dnf4
query = query.upgrades() # https://bugzilla.redhat.com/1650446
updates = set(query.run()) # until fixed, load the repositories again and again check for
# Get packages installed in this transaction... # updates
just_installed = self.base.transaction base = dnf.Base()
# ...and filter them out of available updates base.read_all_repos()
for item in just_installed: base.fill_sack()
for pkg in item.installs(): query = base.sack.query()
updates.discard(pkg) 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([ subprocess.call([
'/usr/lib/qubes/qrexec-client-vm', '/usr/lib/qubes/qrexec-client-vm',
'dom0', 'dom0',