Browse Source

Improved upgrade notifications sent to QVMM.

Each time some arbitrary package was installed using dpkg or apt-get, the update notification in Qubes VM Manager was cleared.
No matter if there were still updates pending. (Could happen even after the user running `apt-get dist-upgrade` in case of package manager issues.)
No longer clear upgrade notification in QVMM on arbitrary package installation.
Check if upgrades have been actually installed before clearing the notifications.

https://github.com/QubesOS/qubes-issues/issues/1066#issuecomment-150044906
Patrick Schleizer 8 năm trước cách đây
mục cha
commit
aeb6d188cc
4 tập tin đã thay đổi với 37 bổ sung1 xóa
  1. 3 0
      Makefile
  2. 22 0
      misc/upgrades-installed-check
  3. 11 0
      misc/upgrades-status-notify
  4. 1 1
      network/00notify-hook

+ 3 - 0
Makefile

@@ -171,6 +171,9 @@ install-common:
 	install misc/dispvm-prerun.sh $(DESTDIR)$(LIBDIR)/qubes/dispvm-prerun.sh
 	install misc/close-window $(DESTDIR)$(LIBDIR)/qubes/close-window
 
+	install misc/upgrades-installed-check $(DESTDIR)$(LIBDIR)/qubes/upgrades-installed-check
+	install misc/upgrades-status-notify $(DESTDIR)$(LIBDIR)/qubes/upgrades-status-notify
+
 	install -m 0644 network/udev-qubes-network.rules $(DESTDIR)/etc/udev/rules.d/99-qubes-network.rules
 	install network/qubes-setup-dnat-to-ns $(DESTDIR)$(LIBDIR)/qubes
 	install network/setup-ip $(DESTDIR)$(LIBDIR)/qubes/

+ 22 - 0
misc/upgrades-installed-check

@@ -0,0 +1,22 @@
+#!/bin/bash
+
+## `echo`s:
+## * 'true' - if all upgrades have been installed
+## * 'false' - if there are pending upgrades
+## * nothing - if apt-get is currently locked
+##
+## Forwards the exit code of the package manager.
+
+if [ -e /etc/system-release ]; then
+   ## Fedora
+   yum_output="$(yum -q check-update 2>&1)"
+   exit_code="$?"
+   [ "$exit_code" -eq 100 ] && echo "true" || echo "false"
+else
+   ## Debian
+   apt_get_output="$(LANG="C" apt-get -s upgrade 2>&1)"
+   exit_code="$?"
+   echo "$apt_get_output" | awk "/^Inst/{ print $2 }" | [ "$(wc -L)" -eq 0 ] && echo "true" || echo "false"
+fi
+
+exit "$exit_code"

+ 11 - 0
misc/upgrades-status-notify

@@ -0,0 +1,11 @@
+#!/bin/bash
+
+set -e
+
+upgrades_installed="$(/usr/lib/qubes/upgrades-installed-check 2>&1)"
+
+if [ "$upgrades_installed" = "true" ]; then
+   /usr/lib/qubes/qrexec-client-vm dom0 qubes.NotifyUpdates /bin/sh -c 'echo 0'
+elif [ "$upgrades_installed" = "false" ]; then
+   /usr/lib/qubes/qrexec-client-vm dom0 qubes.NotifyUpdates /bin/sh -c 'echo 1'
+fi

+ 1 - 1
network/00notify-hook

@@ -1 +1 @@
-DPkg::Post-Invoke {"/usr/lib/qubes/qrexec-client-vm dom0 qubes.NotifyUpdates /bin/sh -c 'echo 0' || true";};
+DPkg::Post-Invoke {"/usr/lib/qubes/upgrades-status-notify || true";};