[type/__package_pkg_openbsd/explorer/pkg_version] Fix version extraction

The earlier code stripped away all non-numeric parts of the version number.

E.g. "5.6.38p0" would be trimmed to "5.6.38"
This commit is contained in:
Takashi Yoshi 2018-12-07 17:32:43 +01:00
parent c492c53a98
commit 827081f8a2

View file

@ -19,7 +19,7 @@
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
#
# 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/'