Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 705240

Summary: [TRACKER] Lexicographical version comparison mistakes: use of [[ ${foo} < 1.2.3 ]] instead of ver_test ${foo} -lt 1.2.3
Product: Gentoo Linux Reporter: Sergei Trofimovich <slyfox>
Component: Current packagesAssignee: Sergei Trofimovich <slyfox>
Status: RESOLVED FIXED    
Severity: normal CC: bertrand, jstein, pacho
Priority: Normal Keywords: Tracker
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on: 705242, 705244, 705246, 705248, 705250, 705254, 705258, 705260, 705264, 705266, 705270, 705272, 705274, 705276, 705278, 705282    
Bug Blocks:    

Description Sergei Trofimovich gentoo-dev 2020-01-12 10:56:27 UTC
Ebuilds that use lexicographical version comparison like
    [[ ${foo} < 1.2.3 ]] && do_something
are sometimes broken for foo=1.2.10:
    $ [[ 1.2.3 < 1.2.3 ]] && echo yes || echo no
    no # ok
    $ [[ 1.2.9 < 1.2.3 ]] && echo yes || echo no
    no # ok
    $ [[ 1.2.9 < 1.2.10 ]] && echo yes || echo no
    no # whoops

The fix is usually to use
    ver_test ${foo} -lt 1.2.3
from eapi7-ver.eclass.
Comment 1 Sergei Trofimovich gentoo-dev 2020-01-12 10:58:28 UTC
Simplistic way to find such cases:

$ git grep -E '\[\[.*[<>]\s*[0-9]+.*\]\]' | cat
app-misc/unfoo/unfoo-1.0.8.ebuild:	elif [[ ${REPLACING_VERSIONS} < 1.0.7 ]]; then
dev-db/libzdb/libzdb-3.1-r1.ebuild:	if  [[ $(gcc-version) < 4.1 ]];then
dev-db/libzdb/libzdb-3.1.ebuild:	if  [[ $(gcc-version) < 4.1 ]];then
eclass/kernel-2.eclass:	if [[ ${K_SYMLINK} > 0 ]]; then
eclass/kernel-2.eclass:			if [[ ${KV_MAJOR} -ge 3 || ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} > 2.6.24 ]] ; then
eclass/kernel-2.eclass:		if [[ ${KV_MAJOR} -ge 3 || ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} > 2.6.28 ]]; then
eclass/kernel-2.eclass:	if [[ -n ${KV_MINOR} &&  ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} < 2.6.27 ]] ; then
eclass/linux-info.eclass:		if [[ ${error} > 0 ]]; then
eclass/linux-info.eclass:	if [[ ${hard_errors_count} > 0 ]]; then
eclass/linux-info.eclass:	elif [[ ${soft_errors_count} > 0 ]]; then
eclass/portability.eclass:		[[ $max < $min && $step > 0 ]] && break
eclass/portability.eclass:		[[ $min < $max && $step < 0 ]] && break
games-action/openclonk/openclonk-7.0.ebuild:	if [[ $(tc-getCXX) == *g++* && $(gcc-version) < 4.9 ]] ; then
media-gfx/nvidia-cg-toolkit/nvidia-cg-toolkit-3.1.0013-r5.ebuild:	if [[ ${REPLACING_VERSIONS} < 2.1.0016 ]]; then
media-tv/gentoo-vdr-scripts/gentoo-vdr-scripts-2.7.3.ebuild:	if [[ ${PLUGINS_NEW} > 0 ]]; then
media-tv/gentoo-vdr-scripts/gentoo-vdr-scripts-2.7.5.1.ebuild:	if [[ ${PLUGINS_NEW} > 0 ]]; then
net-libs/webkit-gtk/webkit-gtk-2.24.4.ebuild:		if tc-is-gcc && [[ $(gcc-version) < 4.9 ]] ; then
net-mail/mailgraph/mailgraph-1.14-r2.ebuild:	if [[ ${REPLACING_VERSIONS} < 1.13 ]] ; then
net-wireless/cpyrit-cuda/cpyrit-cuda-0.5.0.ebuild:	if tc-is-gcc && [[ $(gcc-version) > 4.8 ]]; then
profiles/prefix/windows/winnt/profile.bashrc:while [[ $# > 0 ]]
profiles/prefix/windows/winnt/profile.bashrc:	[[ ${#mysrcs[@]} < 2 ]] && exit 0
sys-apps/pciutils/pciutils-3.5.6-r1.ebuild:	if [[ ${REPLACING_VERSIONS} ]] && [[ ${REPLACING_VERSIONS} < 3.2.0 ]]; then
sys-apps/pciutils/pciutils-3.6.1.ebuild:	if [[ ${REPLACING_VERSIONS} ]] && [[ ${REPLACING_VERSIONS} < 3.2.0 ]]; then
sys-apps/pciutils/pciutils-3.6.2-r1.ebuild:	if [[ ${REPLACING_VERSIONS} ]] && [[ ${REPLACING_VERSIONS} < 3.2.0 ]]; then
sys-cluster/corosync/corosync-2.3.5.ebuild:	if [[ ${REPLACING_VERSIONS} < 2.0 ]]; then
sys-cluster/corosync/corosync-2.4.2.ebuild:	if [[ ${REPLACING_VERSIONS} < 2.0 ]]; then
sys-cluster/torque/torque-4.1.7-r1.ebuild:	if [[ -z "${REPLACING_VERSIONS}" ]] || [[ ${REPLACING_VERSIONS} < 4 ]]; then
sys-cluster/torque/torque-4.2.10-r1.ebuild:	if [[ ${showmessage} > 0 ]]; then
sys-libs/libcxx/libcxx-10.0.0.9999.ebuild:	if tc-is-gcc && [[ $(gcc-version) < 4.7 ]] ; then
sys-libs/libcxx/libcxx-7.1.0.ebuild:	if tc-is-gcc && [[ $(gcc-version) < 4.7 ]] ; then
sys-libs/libcxx/libcxx-8.0.1.ebuild:	if tc-is-gcc && [[ $(gcc-version) < 4.7 ]] ; then
sys-libs/libcxx/libcxx-9.0.1.ebuild:	if tc-is-gcc && [[ $(gcc-version) < 4.7 ]] ; then