From 40652b700bf4d45f284c3a3b0fbcd8eca3f87780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sat, 3 Aug 2019 03:39:10 +0200 Subject: [PATCH 1/2] dnf: clear updates-available flag when dnf update yields no updates Fixes QubesOS/qubes-issues#2009 --- misc/dnf-qubes-hooks.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/misc/dnf-qubes-hooks.py b/misc/dnf-qubes-hooks.py index 1771851..608f6cc 100644 --- a/misc/dnf-qubes-hooks.py +++ b/misc/dnf-qubes-hooks.py @@ -36,6 +36,22 @@ class QubesHooks(dnf.Plugin): self.base = base self.log = logging.getLogger('dnf') + def resolved(self): + # in case of no action to do, transaction() hook won't be called; + # report updates availability here - especially when everything is up + # to date - to clear updates-available flag + if not self.base.transaction: + query = self.base.sack.query() + query = query.upgrades() + updates = set(query.run()) + subprocess.call([ + '/usr/lib/qubes/qrexec-client-vm', + 'dom0', + 'qubes.NotifyUpdates', + '/bin/echo', + str(len(updates)) + ]) + def transaction(self): if LooseVersion(dnf.const.VERSION) < '2.0.0': config = self.read_config(self.base.conf, PLUGIN_CONF) From ca659ef6dff6bce08ef71c0c620e22a2ec873c12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Wed, 7 Aug 2019 00:03:51 +0200 Subject: [PATCH 2/2] Fix downloading dom0 updates on Debian When yumdownloader is used, it needs yum.conf. In Qubes 4.1 it isn't there anymore, so symlink dnf.conf instead. In Debian case, packages are downloaded directly to packages directory, doesn't need to be extracted from cache. Redirect error message to /dev/null for that. --- misc/qubes-download-dom0-updates.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/misc/qubes-download-dom0-updates.sh b/misc/qubes-download-dom0-updates.sh index 9608494..e2f70ff 100755 --- a/misc/qubes-download-dom0-updates.sh +++ b/misc/qubes-download-dom0-updates.sh @@ -116,6 +116,10 @@ YUM_COMMAND="fakeroot $YUM $YUM_ACTION -y --downloadonly" # check for --downloadonly option - if not supported (Debian), fallback to # yumdownloader if ! $YUM --help | grep -q downloadonly; then + # setup environment for yumdownloader to be happy + if [ ! -e "$DOM0_UPDATES_DIR/etc/yum.conf" ]; then + ln -nsf dnf/dnf.conf "$DOM0_UPDATES_DIR/etc/yum.conf" + fi if [ "$YUM_ACTION" = "install" ]; then YUM_COMMAND="yumdownloader --destdir=$DOM0_UPDATES_DIR/packages --resolve" elif [ "$YUM_ACTION" = "upgrade" ]; then @@ -162,7 +166,7 @@ else $YUM_COMMAND $OPTS "${PKGLIST[@]}" fi -find "$DOM0_UPDATES_DIR/var/cache" -name '*.rpm' -print0 |\ +find "$DOM0_UPDATES_DIR/var/cache" -name '*.rpm' -print0 2>/dev/null |\ xargs -0 -r ln -f -t "$DOM0_UPDATES_DIR/packages/" if ls "$DOM0_UPDATES_DIR"/packages/*.rpm > /dev/null 2>&1; then