forked from ungleich-public/cdist
Merge branch 'bugfix_type__package_emerge' of https://github.com/dheule/cdist
This commit is contained in:
commit
a6c37d688b
3 changed files with 18 additions and 14 deletions
|
@ -27,37 +27,40 @@ else
|
|||
name="$__object_id"
|
||||
fi
|
||||
|
||||
if [ -f "$__object/parameter/state" ]; then
|
||||
state_should="$(cat "$__object/parameter/state")"
|
||||
else
|
||||
state_should="present"
|
||||
state_should="$(cat "$__object/parameter/state")"
|
||||
|
||||
version="$(cat "$__object/parameter/version")"
|
||||
|
||||
if [ -n "$version" ]; then
|
||||
name="=$name-$version"
|
||||
fi
|
||||
|
||||
pkg_version="$(cat "$__object/explorer/pkg_version")"
|
||||
if [ -z "$pkg_version" ]; then
|
||||
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 "$pkg_version"
|
||||
exit 1
|
||||
else
|
||||
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
|
||||
|
||||
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
|
||||
[ "$state_is" = "$state_should" ] && ( [ -z "$version" ] || [ "$installed_version" = "$version" ] ) && exit 0
|
||||
[ "$state_should" = "absent" ] && [ ! -z "$version" ] && [ "$installed_version" != "$version" ] && exit 0
|
||||
|
||||
|
||||
case "$state_should" in
|
||||
present)
|
||||
echo "emerge \"$name\" &>/dev/null || exit 1"
|
||||
|
|
1
cdist/conf/type/__package_emerge/parameter/default/state
Normal file
1
cdist/conf/type/__package_emerge/parameter/default/state
Normal file
|
@ -0,0 +1 @@
|
|||
present
|
Loading…
Reference in a new issue