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
|
#!/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.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
if [ -f "$__object/parameter/name" ]; then
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/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.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -33,21 +33,34 @@ else
|
||||||
name="$__object_id"
|
name="$__object_id"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
state="$(cat "$__object/parameter/state")"
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
pkg_version="$(cat "$__object/explorer/pkg_version")"
|
case "$state_should" in
|
||||||
|
|
||||||
case "$state" in
|
|
||||||
installed)
|
installed)
|
||||||
|
echo "WARNING: $state_should is deprecated, please change to present/absent (will be removed in cdist 2.1)" >&2
|
||||||
# Empty? Not installed.
|
state_should="present"
|
||||||
if [ -z "$pkg_version" ]; then
|
|
||||||
echo pacman "$pacopts" -S \"$name\"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
removed)
|
removed)
|
||||||
if [ "$pkg_version" ]; then
|
echo "WARNING: $state_should is deprecated, please change to present/absent (will be removed in cdist 2.1)" >&2
|
||||||
echo pacman "$pacopts" -R \"$name\"
|
state_should="absent"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
pkg_version="$(cat "$__object/explorer/pkg_version")"
|
||||||
|
if [ -z "$pkg_version" ]; then
|
||||||
|
state_is="absent"
|
||||||
|
else
|
||||||
|
state_is="present"
|
||||||
fi
|
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
|
echo "Unknown state: $state" >&2
|
||||||
|
|
Loading…
Reference in a new issue