support absent/present in __package_rubygem
Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
This commit is contained in:
parent
9fab782a0c
commit
e4aafe0af9
2 changed files with 34 additions and 24 deletions
|
@ -29,7 +29,6 @@
|
||||||
os_version="$(cat "$__global/explorer/os_version")"
|
os_version="$(cat "$__global/explorer/os_version")"
|
||||||
machine="$(cat "$__global/explorer/machine")"
|
machine="$(cat "$__global/explorer/machine")"
|
||||||
|
|
||||||
|
|
||||||
if [ -f "$__object/parameter/flavor" ]; then
|
if [ -f "$__object/parameter/flavor" ]; then
|
||||||
flavor="$(cat "$__object/parameter/flavor")"
|
flavor="$(cat "$__object/parameter/flavor")"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -21,28 +21,39 @@
|
||||||
# Manage Rubygem packages
|
# Manage Rubygem packages
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
if [ -f "$__object/parameter/name" ]; then
|
if [ -f "$__object/parameter/name" ]; then
|
||||||
name="$(cat "$__object/parameter/name")"
|
name="$(cat "$__object/parameter/name")"
|
||||||
else
|
else
|
||||||
name="$__object_id"
|
name="$__object_id"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
state="$(cat "$__object/parameter/state")"
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
is_installed="$(grep "true" "$__object/explorer/pkg_status" || true)"
|
# Correct pre 2.1 naming - FIXME in 2.1
|
||||||
|
case "$state_should" in
|
||||||
case "$state" in
|
|
||||||
installed)
|
installed)
|
||||||
# Install only if non-existent
|
echo "WARNING: $state_should is deprecated and will be removed in cdist 2.1. Please change to present/absent." >&2
|
||||||
if [ -z "$is_installed" ]; then
|
state_should="present"
|
||||||
echo gem install \"$name\" --no-ri --no-rdoc
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
removed)
|
removed)
|
||||||
# Remove only if existent
|
echo "WARNING: $state_should is deprecated and will be removed in cdist 2.1. Please change to present/absent." >&2
|
||||||
if [ -n "$is_installed" ]; then
|
state_should="absent"
|
||||||
echo gem uninstall \"$name\"
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if grep -q true "$__object/explorer/pkg_status"; then
|
||||||
|
state_is="present"
|
||||||
|
else
|
||||||
|
state_is="absent"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
[ "$state_is" = "$state_should ] && exit 0
|
||||||
|
|
||||||
|
case "$state_should" in
|
||||||
|
present)
|
||||||
|
echo gem install \"$name\" --no-ri --no-rdoc
|
||||||
|
;;
|
||||||
|
absent)
|
||||||
|
echo gem uninstall \"$name\"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown state: $state" >&2
|
echo "Unknown state: $state" >&2
|
||||||
|
|
Loading…
Reference in a new issue