diff --git a/cdist/conf/type/__package_pkg_openbsd/explorer/pkg_version b/cdist/conf/type/__package_pkg_openbsd/explorer/pkg_version index 212f0d96..71fccb42 100755 --- a/cdist/conf/type/__package_pkg_openbsd/explorer/pkg_version +++ b/cdist/conf/type/__package_pkg_openbsd/explorer/pkg_version @@ -19,7 +19,7 @@ # along with cdist. If not, see . # # -# Retrieve the status of a package - parsed dpkg output +# Retrieve the status of a package - parsed pkg_info output # if [ -f "$__object/parameter/name" ]; then @@ -28,5 +28,10 @@ else name="$__object_id" fi -#TODO: Is there a better way? -pkg_info | grep "^$name-[0-9]" | sed 's|.*\(-[0-9][0-9.]*\).*|\1|' | sed 's/-//' +# Extract version number from pkg_info. +# Refer to packages-specs(7) for more information regarding the format. + +# ATTENTION: If $name is just a stem (e.g. "php" or "python"), there may be +# multiple results. pkg_info prints a line for each version. + +pkg_info -q -I "inst:$name" | sed -e 's/^\([^-]*-\)*\([0-9][^-]*\).*$/\2/'