better handling of virtual packages in __package_apt
This commit is contained in:
parent
202e5b69d8
commit
e4100e324a
2 changed files with 29 additions and 19 deletions
|
@ -28,4 +28,11 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Except dpkg failing, if package is not known / installed
|
# Except dpkg failing, if package is not known / installed
|
||||||
dpkg -s "$name" 2>/dev/null || exit 0
|
packages="$(apt-cache showpkg "$name" | grep -A 20 "Reverse Provides:" | sed 1d | cut -d ' ' -f 1) $name"
|
||||||
|
for p in $packages; do
|
||||||
|
if [ -n "$(dpkg -s "$p" 2>/dev/null | grep "^Status: install ok installed$")" ]; then
|
||||||
|
echo "installed $p"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "removed"
|
||||||
|
|
|
@ -27,26 +27,29 @@ else
|
||||||
name="$__object_id"
|
name="$__object_id"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
state="$(cat "$__object/parameter/state")"
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
is_installed="$(grep "^Status: install ok installed" "$__object/explorer/pkg_status" || true)"
|
state_is="$(cat "$__object/explorer/pkg_status")"
|
||||||
|
case "$state_is" in
|
||||||
|
installed*)
|
||||||
|
name="$(echo "$state_is" | cut -d ' ' -f 2)"
|
||||||
|
state_is="installed"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
aptget="DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes"
|
aptget="DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes"
|
||||||
|
|
||||||
case "$state" in
|
if [ "$state_is" != "$state_should" ]; then
|
||||||
|
case "$state_should" in
|
||||||
installed)
|
installed)
|
||||||
# Install only if non-existent
|
|
||||||
if [ -z "$is_installed" ]; then
|
|
||||||
echo $aptget install \"$name\"
|
echo $aptget install \"$name\"
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
removed)
|
removed)
|
||||||
# Remove only if existent
|
|
||||||
if [ -n "$is_installed" ]; then
|
|
||||||
echo $aptget remove \"$name\"
|
echo $aptget remove \"$name\"
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown state: $state" >&2
|
echo "Unknown state: $state" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue