implemented some sugestions from nico

This commit is contained in:
Daniel Heule 2014-09-29 17:28:45 +02:00
parent 9bac6da6c9
commit c70834eaff
3 changed files with 12 additions and 14 deletions

View file

@ -27,36 +27,32 @@ else
name="$__object_id"
fi
if [ -f "$__object/parameter/state" ]; then
state_should="$(cat "$__object/parameter/state")"
else
state_should="present"
fi
state_should="$(cat "$__object/parameter/state")"
if [ -f "$__object/parameter/version" ]; then
version="$(cat "$__object/parameter/version")"
else
version=""
fi
version="$(cat "$__object/parameter/version")"
if [ ! -z "$version" ]; then
if [ -n "$version" ]; then
name="=$name-$version"
fi
pkg_version="$(cat "$__object/explorer/pkg_version")"
if [ -z "$pkg_version" ]; then
state_is="absent"
elif [ ! -z "$version" -a $(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 [ -z "$version" -a $(echo "$pkg_version" | cut -d " " -f 1 | sort | uniq | wc -l) -gt 1 ]; then
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 | tail -n 1)"
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
@ -64,6 +60,7 @@ fi
[ "$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"

View file

@ -0,0 +1 @@
present