core-agent-linux/misc/upgrades-installed-check
Patrick Schleizer aeb6d188cc
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
2015-11-11 15:45:00 +00:00

23 lines
612 B
Bash
Executable File

#!/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"