apt: fix check_hel_packages script

This commit is contained in:
Jérémy Lecour 2019-05-17 14:29:29 +02:00 committed by Jérémy Lecour
parent 66ab052ac7
commit ed5fc03305

View file

@ -2,10 +2,14 @@
is_held() { is_held() {
package=$1 package=$1
apt-mark showhold ${package} | grep --silent ${package} 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" config_file="/etc/evolinux/apt_hold_packages.cf"
return_code=0 return_code=0
@ -15,7 +19,7 @@ if [ -f ${config_file} ]; then
if [ -n "${packages}" ]; then if [ -n "${packages}" ]; then
for package in ${packages}; do for package in ${packages}; do
if [ -n "${package}" ]; then if [ -n "${package}" ]; then
if ! is_held ${package}; then if is_installed ${package} && ! is_held ${package}; then
apt-mark hold ${package} apt-mark hold ${package}
>&2 echo "Package \`${package}' has been marked \`hold'." >&2 echo "Package \`${package}' has been marked \`hold'."
return_code=1 return_code=1