Skip to content

Commit 4eba9be

Browse files
committed
pkg-auto: Add a missing function
1 parent ae67b87 commit 4eba9be

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

pkg_auto/impl/gentoo_ver.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,38 @@ _ver_compare() {
118118
return 2
119119
}
120120

121+
# @FUNCTION: ver_test
122+
# @USAGE: [<v1>] <op> <v2>
123+
# @DESCRIPTION:
124+
# Check if the relation <v1> <op> <v2> is true. If <v1> is not specified,
125+
# default to ${PVR}. <op> can be -gt, -ge, -eq, -ne, -le, -lt.
126+
# Both versions must conform to the PMS version syntax (with optional
127+
# revision parts), and the comparison is performed according to
128+
# the algorithm specified in the PMS.
129+
ver_test() {
130+
local va op vb
131+
132+
if [[ $# -eq 3 ]]; then
133+
va=${1}
134+
shift
135+
else
136+
va=${PVR}
137+
fi
138+
139+
[[ $# -eq 2 ]] || fail "${FUNCNAME}: bad number of arguments"
140+
141+
op=${1}
142+
vb=${2}
143+
144+
case ${op} in
145+
-eq|-ne|-lt|-le|-gt|-ge) ;;
146+
*) fail "${FUNCNAME}: invalid operator: ${op}" ;;
147+
esac
148+
149+
_ver_compare "${va}" "${vb}"
150+
test $? "${op}" 2
151+
}
152+
121153
# symbolic names for use with gentoo_ver_cmp_out
122154
GV_LT=1
123155
GV_EQ=2

0 commit comments

Comments
 (0)