Skip to content

Commit

Permalink
apt: skip 'apt-get update' when running from apt already
Browse files Browse the repository at this point in the history
Do not call 'apt-get update' in post-invoke hook, as APT database is
locked at this time. Since this happens after packages install/update,
it should be already up to date at that point.

Fixes QubesOS/qubes-issues#9673
  • Loading branch information
marmarek committed Jan 4, 2025
1 parent b8b485f commit e3202dc
Show file tree
Hide file tree
Showing 3 changed files with 19 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";};
14 changes: 12 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,8 +31,10 @@ 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 | tee /proc/self/fd/2)"
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
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 e3202dc

Please sign in to comment.