Description of problem: In many cases, we need compare distro or pkg version to judge -if run the test case in the platform. so want beakerlib, add an function or cmd to compare distro or pkg version Version-Release number of selected component (if applicable): all beakerlib version How reproducible: Steps to Reproduce: 1. 2. 3. Actual results: Expected results: here is an alternative complete I created: (based sort -V) # cat /usr/local/bin/vercmp # author jiyin usage() { echo "usage: $0 <ver1> < = | '>' | '<' | '>=' | '<=' > <ver2>" >&2 echo " $0 <ver1> < eq | gt | lt | ge | le > <ver2>" >&2 echo " $0 <ver1> < match > <'pattern'>" >&2 } vercmp() { [ $# != 3 ] && { usage return 1 } vl=$1 cmpType=$2 vr=$3 res=1 [ "$vl" = "$vr" ] && eq=1 vmax=$(echo -e "$vl\n$vr" | sort -V | tail -n 1) case "$cmpType" in =|eq) [ "$eq" = 1 ] && res=0;; \>|gt) [ "$eq" != 1 -a "$vl" = "$vmax" ] && res=0;; \<|lt) [ "$eq" != 1 -a "$vr" = "$vmax" ] && res=0;; \>=|lt) [ "$vl" = "$vmax" ] && res=0;; \<=|lt) [ "$vr" = "$vmax" ] && res=0;; *) echo "$vl" | egrep -q "$vr"; res=$?;; esac return $res } vercmp "$@" Additional info:
Seems useful
because in RHEL5 sort not support -V option; update the code: #!/bin/bash #author: jiyin usage() { echo "usage: $0 <ver1> < = | '>' | '<' | '>=' | '<=' > <ver2>" >&2 echo " $0 <ver1> < eq | gt | lt | ge | le > <ver2>" >&2 echo " $0 <ver1> < match > <'pattern'>" >&2 } sortV() { if echo | sort -V 2>/dev/null; then cat - | sort -V else cat - | sed -r -e "s/-([0-9]+\.)/.\1/" -e "s/-([0-9]+\.)/-.\1/" | sort -t . -k1,1 -k2,2n -k3,3n -k4,4n -k5,5n -k6,6n | sed -r -e "s/\./-/" -e "s/-\./-/" fi } vercmp() { [ $# != 3 ] && { usage return 1 } vl=$1 cmpType=$2 vr=$3 res=1 [ "$vl" = "$vr" ] && eq=1 vmax=$(echo -e "$vl\n$vr" | sortV | tail -n 1) case "$cmpType" in =|eq) [ "$eq" = 1 ] && res=0;; \>|gt) [ "$eq" != 1 -a "$vl" = "$vmax" ] && res=0;; \<|lt) [ "$eq" != 1 -a "$vr" = "$vmax" ] && res=0;; \>=|lt) [ "$vl" = "$vmax" ] && res=0;; \<=|lt) [ "$vr" = "$vmax" ] && res=0;; *) echo "$vl" | egrep -q "$vr"; res=$?;; esac return $res } vercmp "$@"
This package has changed ownership in the Fedora Package Database. Reassigning to the new owner of this component.
currently __INTERNAL_version_cmp and __INTERNAL_test_version aree present in beakerlib. I can make them publick in next release.
fixed by https://git.fedorahosted.org/cgit/beakerlib.git/commit/?id=3917ef895b8b7de5befe3a606bfed1d74df4c1d9