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
This commit is contained in:
Patrick Schleizer 2015-10-22 15:26:24 +00:00
parent 06828a9374
commit aeb6d188cc
No known key found for this signature in database
GPG Key ID: CB8D50BB77BB3C48
4 changed files with 37 additions and 1 deletions

View File

@ -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
misc/upgrades-installed-check Executable file
View File

@ -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
misc/upgrades-status-notify Executable file
View File

@ -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

View File

@ -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";};