update __package_pacman for absent/present

Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
This commit is contained in:
Nico Schottelius 2012-02-09 11:54:13 +01:00
parent 52849b91c5
commit 3c19e7ab4c
2 changed files with 25 additions and 12 deletions

View file

@ -1,6 +1,6 @@
#!/bin/sh
#
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@ -18,7 +18,7 @@
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
#
# Retrieve the status of a package - parsed dpkg output
# Retrieve the status of a package - parsed pacman output
#
if [ -f "$__object/parameter/name" ]; then

View file

@ -1,6 +1,6 @@
#!/bin/sh
#
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@ -33,21 +33,34 @@ else
name="$__object_id"
fi
state="$(cat "$__object/parameter/state")"
pkg_version="$(cat "$__object/explorer/pkg_version")"
case "$state" in
state_should="$(cat "$__object/parameter/state")"
case "$state_should" in
installed)
# Empty? Not installed.
if [ -z "$pkg_version" ]; then
echo pacman "$pacopts" -S \"$name\"
fi
echo "WARNING: $state_should is deprecated, please change to present/absent (will be removed in cdist 2.1)" >&2
state_should="present"
;;
removed)
if [ "$pkg_version" ]; then
echo pacman "$pacopts" -R \"$name\"
echo "WARNING: $state_should is deprecated, please change to present/absent (will be removed in cdist 2.1)" >&2
state_should="absent"
;;
esac
pkg_version="$(cat "$__object/explorer/pkg_version")"
if [ -z "$pkg_version" ]; then
state_is="absent"
else
state_is="present"
fi
# Exit if nothing is needed to be done
[ "$state_is" = "$state_should ] && exit 0
case "$state_should" in
present)
echo pacman "$pacopts" -S \"$name\"
;;
absent)
echo pacman "$pacopts" -R \"$name\"
;;
*)
echo "Unknown state: $state" >&2