From ed5fc033051cf540e20442d3e149fc88bec3e88d Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Fri, 17 May 2019 14:29:29 +0200 Subject: [PATCH] apt: fix check_hel_packages script --- apt/files/check_held_packages.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apt/files/check_held_packages.sh b/apt/files/check_held_packages.sh index b0cd9c23..181b9679 100644 --- a/apt/files/check_held_packages.sh +++ b/apt/files/check_held_packages.sh @@ -2,10 +2,14 @@ is_held() { package=$1 - apt-mark showhold ${package} | grep --silent ${package} } +is_installed() { + package=$1 + dpkg -l "${package}" 2>/dev/null | grep -q -E '^(i|h)i' +} + config_file="/etc/evolinux/apt_hold_packages.cf" return_code=0 @@ -15,7 +19,7 @@ if [ -f ${config_file} ]; then if [ -n "${packages}" ]; then for package in ${packages}; do if [ -n "${package}" ]; then - if ! is_held ${package}; then + if is_installed ${package} && ! is_held ${package}; then apt-mark hold ${package} >&2 echo "Package \`${package}' has been marked \`hold'." return_code=1