forked from ungleich-public/cdist
[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:
parent
c492c53a98
commit
827081f8a2
1 changed files with 8 additions and 3 deletions
|
@ -19,7 +19,7 @@
|
||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
if [ -f "$__object/parameter/name" ]; then
|
||||||
|
@ -28,5 +28,10 @@ else
|
||||||
name="$__object_id"
|
name="$__object_id"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#TODO: Is there a better way?
|
# Extract version number from pkg_info.
|
||||||
pkg_info | grep "^$name-[0-9]" | sed 's|.*\(-[0-9][0-9.]*\).*|\1|' | sed 's/-//'
|
# 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/'
|
||||||
|
|
Loading…
Reference in a new issue