update __package_pacman for absent/present
Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
This commit is contained in:
parent
52849b91c5
commit
3c19e7ab4c
2 changed files with 25 additions and 12 deletions
|
@ -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
|
||||
|
|
|
@ -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")"
|
||||
state_should="$(cat "$__object/parameter/state")"
|
||||
case "$state_should" in
|
||||
installed)
|
||||
echo "WARNING: $state_should is deprecated, please change to present/absent (will be removed in cdist 2.1)" >&2
|
||||
state_should="present"
|
||||
;;
|
||||
removed)
|
||||
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
|
||||
|
||||
case "$state" in
|
||||
installed)
|
||||
# Exit if nothing is needed to be done
|
||||
[ "$state_is" = "$state_should ] && exit 0
|
||||
|
||||
# Empty? Not installed.
|
||||
if [ -z "$pkg_version" ]; then
|
||||
case "$state_should" in
|
||||
present)
|
||||
echo pacman "$pacopts" -S \"$name\"
|
||||
fi
|
||||
;;
|
||||
removed)
|
||||
if [ "$pkg_version" ]; then
|
||||
absent)
|
||||
echo pacman "$pacopts" -R \"$name\"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Unknown state: $state" >&2
|
||||
|
|
Loading…
Reference in a new issue