Merge branch 'bugfix_type__package_emerge' of https://github.com/dheule/cdist

This commit is contained in:
Nico Schottelius 2014-10-02 15:20:08 +02:00
commit a6c37d688b
3 changed files with 18 additions and 14 deletions

View file

@ -27,37 +27,40 @@ else
name="$__object_id" name="$__object_id"
fi fi
if [ -f "$__object/parameter/state" ]; then
state_should="$(cat "$__object/parameter/state")" state_should="$(cat "$__object/parameter/state")"
else
state_should="present" version="$(cat "$__object/parameter/version")"
if [ -n "$version" ]; then
name="=$name-$version"
fi fi
pkg_version="$(cat "$__object/explorer/pkg_version")" pkg_version="$(cat "$__object/explorer/pkg_version")"
if [ -z "$pkg_version" ]; then if [ -z "$pkg_version" ]; then
state_is="absent" state_is="absent"
elif [ $(echo "$pkg_version" | wc -l) -gt 1 ]; then elif [ -z "$version" -a $(echo "$pkg_version" | wc -l) -gt 1 ]; then
echo "Package name is not unique! The following packages are installed:"
echo "$pkg_version"
exit 1
elif [ -n "$version" -a $(echo "$pkg_version" | cut -d " " -f 1 | sort | uniq | wc -l) -gt 1 ]; then
echo "Package name is not unique! The following packages are installed:" echo "Package name is not unique! The following packages are installed:"
echo "$pkg_version" echo "$pkg_version"
exit 1 exit 1
else else
state_is="present" state_is="present"
installed_version="$(echo "$pkg_version" | cut -d " " -f 2)" if [ -n "$version" ] && echo "$pkg_version" | cut -d " " -f 2 | grep -q -x "$version"; then
installed_version="$(echo "$pkg_version" | cut -d " " -f 2 | grep -x "$version")"
else
installed_version="$(echo "$pkg_version" | cut -d " " -f 2 | tail -n 1)"
fi
fi fi
if [ -f "$__object/parameter/version" ]; then
version="$(cat "$__object/parameter/version")"
if [ ! -z "$version" ]; then
name="=$name-$version"
fi
else
version=""
fi
# Exit if nothing is needed to be done # Exit if nothing is needed to be done
[ "$state_is" = "$state_should" ] && ( [ -z "$version" ] || [ "$installed_version" = "$version" ] ) && exit 0 [ "$state_is" = "$state_should" ] && ( [ -z "$version" ] || [ "$installed_version" = "$version" ] ) && exit 0
[ "$state_should" = "absent" ] && [ ! -z "$version" ] && [ "$installed_version" != "$version" ] && exit 0 [ "$state_should" = "absent" ] && [ ! -z "$version" ] && [ "$installed_version" != "$version" ] && exit 0
case "$state_should" in case "$state_should" in
present) present)
echo "emerge \"$name\" &>/dev/null || exit 1" echo "emerge \"$name\" &>/dev/null || exit 1"

View file

@ -0,0 +1 @@
present