From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RaywV-00077f-4u for garchives@archives.gentoo.org; Thu, 15 Dec 2011 00:12:59 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 851A321C04F; Thu, 15 Dec 2011 00:12:48 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 5588121C04F for ; Thu, 15 Dec 2011 00:12:48 +0000 (UTC) Received: from flycatcher.gentoo.org (flycatcher.gentoo.org [81.93.255.6]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 6ACE01B4033 for ; Thu, 15 Dec 2011 00:12:47 +0000 (UTC) Received: by flycatcher.gentoo.org (Postfix, from userid 559) id 3CF2F2004B; Thu, 15 Dec 2011 00:12:46 +0000 (UTC) From: "Mike Frysinger (vapier)" To: gentoo-commits@lists.gentoo.org Reply-To: gentoo-dev@lists.gentoo.org, vapier@gentoo.org Subject: [gentoo-commits] gentoo-x86 commit in eclass/tests: tests-common.sh X-VCS-Repository: gentoo-x86 X-VCS-Files: tests-common.sh X-VCS-Directories: eclass/tests X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger Content-Type: text/plain; charset=utf8 Message-Id: <20111215001246.3CF2F2004B@flycatcher.gentoo.org> Date: Thu, 15 Dec 2011 00:12:46 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 417a9829-ae10-438b-ba0d-2a7c411e36b3 X-Archives-Hash: 07e6a2f3526d8ef495c987c444eb3c02 vapier 11/12/15 00:12:46 Modified: tests-common.sh Log: import KV_to_int and friends since a few eclasses still want it ... Revision Changes Path 1.6 eclass/tests/tests-common.sh file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/tests/tests= -common.sh?rev=3D1.6&view=3Dmarkup plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/tests/tests= -common.sh?rev=3D1.6&content-type=3Dtext/plain diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/tests/tests= -common.sh?r1=3D1.5&r2=3D1.6 Index: tests-common.sh =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /var/cvsroot/gentoo-x86/eclass/tests/tests-common.sh,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- tests-common.sh 23 Sep 2011 04:03:12 -0000 1.5 +++ tests-common.sh 15 Dec 2011 00:12:46 -0000 1.6 @@ -46,3 +46,44 @@ has_version() { portageq has_version / "$@" } + +KV_major() { + [[ -z $1 ]] && return 1 + + local KV=3D$@ + echo "${KV%%.*}" +} + +KV_minor() { + [[ -z $1 ]] && return 1 + + local KV=3D$@ + KV=3D${KV#*.} + echo "${KV%%.*}" +} + +KV_micro() { + [[ -z $1 ]] && return 1 + + local KV=3D$@ + KV=3D${KV#*.*.} + echo "${KV%%[^[:digit:]]*}" +} + +KV_to_int() { + [[ -z $1 ]] && return 1 + + local KV_MAJOR=3D$(KV_major "$1") + local KV_MINOR=3D$(KV_minor "$1") + local KV_MICRO=3D$(KV_micro "$1") + local KV_int=3D$(( KV_MAJOR * 65536 + KV_MINOR * 256 + KV_MICRO )) + + # We make version 2.2.0 the minimum version we will handle as + # a sanity check ... if its less, we fail ... + if [[ ${KV_int} -ge 131584 ]] ; then + echo "${KV_int}" + return 0 + fi + + return 1 +}