Skip to content

Commit

Permalink
Merge branch 'updates-notify-debug'
Browse files Browse the repository at this point in the history
* updates-notify-debug:
  apt: skip 'apt-get update' when running from apt already
  log stdout/err from updates check on Debian
  • Loading branch information
marmarek committed Jan 7, 2025
2 parents 1783677 + e3202dc commit 0d32aa0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package-managers/apt-conf-00notify-hook
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DPkg::Post-Invoke {"/usr/lib/qubes/upgrades-status-notify || true";};
DPkg::Post-Invoke {"/usr/lib/qubes/upgrades-status-notify skip-refresh || true";};
15 changes: 13 additions & 2 deletions package-managers/upgrades-installed-check
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@
## * 'false' - if there are pending upgrades
## * nothing - if apt-get is currently locked
##
## optional argument "skip-refresh" can be used to not refresh metadata (useful
## when it's already up to date, like after installing updates)
##
## Forwards the exit code of the package manager.

skip_refresh=false
if [ "$1" = "skip-refresh" ]; then
skip_refresh=true
fi

if [ -e /etc/system-release ]; then
## Fedora
if command -v dnf >/dev/null; then
Expand All @@ -23,12 +31,15 @@ elif [ -e /etc/debian_version ]; then
## Debian
set -e
set -o pipefail
# shellcheck disable=SC2034
apt_get_update_output="$(apt-get -q update 2>&1)"
if ! $skip_refresh; then
# shellcheck disable=SC2034
apt_get_update_output="$(apt-get -q update 2>&1 | tee /proc/self/fd/2)"
fi
apt_get_upgrade_output="$(LANG="C" apt-get -s upgrade 2>&1)"
exit_code="$?"
# shellcheck disable=SC2266
echo "$apt_get_upgrade_output" | awk "/^Inst/{ print $2 }" | [ "$(wc -L)" -eq 0 ] && echo "true" || echo "false"
echo "$apt_get_upgrade_output" >&2
elif [ -e /etc/arch-release ]; then
## Archlinux
checkupdates >/dev/null 2>&1
Expand Down
7 changes: 6 additions & 1 deletion package-managers/upgrades-status-notify
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ else
fi
fi

upgrades_installed="$(/usr/lib/qubes/upgrades-installed-check)"
script_arg=
if [ "$1" = "skip-refresh" ]; then
script_arg=skip-refresh
fi

upgrades_installed="$(/usr/lib/qubes/upgrades-installed-check $script_arg)"

if [ "$upgrades_installed" = "true" ]; then
/usr/lib/qubes/qrexec-client-vm dom0 qubes.NotifyUpdates /bin/sh -c 'echo 0'
Expand Down

0 comments on commit 0d32aa0

Please sign in to comment.