| 1 | # Copyright 1999-2004 Gentoo Foundation |
1 | # Copyright 1999-2004 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/versionator.eclass,v 1.5 2005/01/04 13:03:54 ciaranm Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/versionator.eclass,v 1.6 2005/03/25 00:51:48 ciaranm Exp $ |
| 4 | # |
4 | # |
| 5 | # Original Author: Ciaran McCreesh <ciaranm@gentoo.org> |
5 | # Original Author: Ciaran McCreesh <ciaranm@gentoo.org> |
| 6 | # |
6 | # |
| 7 | # This eclass provides functions which simplify manipulating $PV and similar |
7 | # This eclass provides functions which simplify manipulating $PV and similar |
| 8 | # variables. Most functions default to working with $PV, although other |
8 | # variables. Most functions default to working with $PV, although other |
| … | |
… | |
| 230 | |
230 | |
| 231 | # Stage 1: compare the version numbers part. |
231 | # Stage 1: compare the version numbers part. |
| 232 | local done_w="" done_h="" i=0 |
232 | local done_w="" done_h="" i=0 |
| 233 | while [[ -z "${done_w}" ]] || [[ -z "${done_h}" ]] ; do |
233 | while [[ -z "${done_w}" ]] || [[ -z "${done_h}" ]] ; do |
| 234 | local cur_w="${want_c[$i]}" cur_h="${have_c[$i]}" |
234 | local cur_w="${want_c[$i]}" cur_h="${have_c[$i]}" |
|
|
235 | local my_cur_w="${cur_w//#0}" my_cur_h="${cur_h//#0}" |
| 235 | [[ -z "${cur_w##[^[:digit:]]*}" ]] && done_w="yes" |
236 | [[ -z "${my_cur_w##[^[:digit:]]*}" ]] && done_w="yes" |
| 236 | [[ -z "${cur_h##[^[:digit:]]*}" ]] && done_h="yes" |
237 | [[ -z "${my_cur_h##[^[:digit:]]*}" ]] && done_h="yes" |
| 237 | [[ -z "${done_w}" ]] || cur_w=0 |
238 | [[ -z "${done_w}" ]] || my_cur_w=0 |
| 238 | [[ -z "${done_h}" ]] || cur_h=0 |
239 | [[ -z "${done_h}" ]] || my_cur_h=0 |
| 239 | if [[ ${cur_w} -lt ${cur_h} ]] ; then return 0 ; fi |
240 | if [[ ${my_cur_w} -lt ${my_cur_h} ]] ; then return 0 ; fi |
| 240 | if [[ ${cur_w} -gt ${cur_h} ]] ; then return 1 ; fi |
241 | if [[ ${my_cur_w} -gt ${my_cur_h} ]] ; then return 1 ; fi |
| 241 | i=$(($i + 1)) |
242 | i=$(($i + 1)) |
| 242 | done |
243 | done |
| 243 | |
244 | |
| 244 | local part |
245 | local part |
| 245 | for part in "_alpha" "_beta" "_pre" "_rc" "_p" "-r" ; do |
246 | for part in "_alpha" "_beta" "_pre" "_rc" "_p" "-r" ; do |
| … | |
… | |
| 307 | version_is_at_least "1.2-r1" "1.2-r2" || echo "test 16 failed" |
308 | version_is_at_least "1.2-r1" "1.2-r2" || echo "test 16 failed" |
| 308 | version_is_at_least "1.2-r3" "1.2-r2" && echo "test 17 failed" |
309 | version_is_at_least "1.2-r3" "1.2-r2" && echo "test 17 failed" |
| 309 | |
310 | |
| 310 | version_is_at_least "1.2-r1" "1.2_beta2-r3" && echo "test 18 failed" |
311 | version_is_at_least "1.2-r1" "1.2_beta2-r3" && echo "test 18 failed" |
| 311 | version_is_at_least "1.2-r1" "1.3_beta2-r3" || echo "test 19 failed" |
312 | version_is_at_least "1.2-r1" "1.3_beta2-r3" || echo "test 19 failed" |
|
|
313 | |
|
|
314 | version_is_at_least "1.002" "1.2" || echo "test 20 failed" |
|
|
315 | version_is_at_least "1.2" "1.002" || echo "test 21 failed" |
|
|
316 | version_is_at_least "1.003" "1.2" && echo "test 22 failed" |
|
|
317 | version_is_at_least "1.3" "1.002" && echo "test 23 failed" |
| 312 | return 0 |
318 | return 0 |
| 313 | } |
319 | } |
| 314 | |
320 | |