/[gentoo-x86]/eclass/versionator.eclass
Gentoo

Contents of /eclass/versionator.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.19 - (show annotations) (download)
Tue Nov 22 18:40:14 2011 UTC (2 years, 11 months ago) by vapier
Branch: MAIN
Changes since 1.18: +2 -2 lines
fix usage on get_version_component_range

1 # Copyright 1999-2008 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/versionator.eclass,v 1.18 2011/07/07 00:34:19 abcd Exp $
4
5 # @ECLASS: versionator.eclass
6 # @MAINTAINER:
7 # Jonathan Callen <abcd@gentoo.org>, base-system@gentoo.org
8 # @BLURB: functions which simplify manipulation of ${PV} and similar version strings
9 # @DESCRIPTION:
10 # This eclass provides functions which simplify manipulating $PV and similar
11 # variables. Most functions default to working with $PV, although other
12 # values can be used.
13 # @EXAMPLE:
14 # Simple Example 1: $PV is 1.2.3b, we want 1_2.3b:
15 # MY_PV=$(replace_version_separator 1 '_' )
16 #
17 # Simple Example 2: $PV is 1.4.5, we want 1:
18 # MY_MAJORV=$(get_major_version )
19 #
20 # Rather than being a number, the index parameter can be a separator character
21 # such as '-', '.' or '_'. In this case, the first separator of this kind is
22 # selected.
23 #
24 # There's also:
25 # version_is_at_least want have
26 # which may be buggy, so use with caution.
27
28 inherit eutils
29
30 # @FUNCTION: get_all_version_components
31 # @USAGE: [version]
32 # @DESCRIPTION:
33 # Split up a version string into its component parts. If no parameter is
34 # supplied, defaults to $PV.
35 # 0.8.3 -> 0 . 8 . 3
36 # 7c -> 7 c
37 # 3.0_p2 -> 3 . 0 _ p2
38 # 20040905 -> 20040905
39 # 3.0c-r1 -> 3 . 0 c - r1
40 get_all_version_components() {
41 eshopts_push -s extglob
42 local ver_str=${1:-${PV}} result
43 result=()
44
45 # sneaky cache trick cache to avoid having to parse the same thing several
46 # times.
47 if [[ ${VERSIONATOR_CACHE_VER_STR} == ${ver_str} ]] ; then
48 echo ${VERSIONATOR_CACHE_RESULT}
49 eshopts_pop
50 return
51 fi
52 export VERSIONATOR_CACHE_VER_STR=${ver_str}
53
54 while [[ -n $ver_str ]] ; do
55 case "${ver_str::1}" in
56 # number: parse whilst we have a number
57 [[:digit:]])
58 result+=("${ver_str%%[^[:digit:]]*}")
59 ver_str=${ver_str##+([[:digit:]])}
60 ;;
61
62 # separator: single character
63 [-_.])
64 result+=("${ver_str::1}")
65 ver_str=${ver_str:1}
66 ;;
67
68 # letter: grab the letters plus any following numbers
69 [[:alpha:]])
70 local not_match=${ver_str##+([[:alpha:]])*([[:digit:]])}
71 # Can't say "${ver_str::-${#not_match}}" in Bash 3.2
72 result+=("${ver_str::${#ver_str} - ${#not_match}}")
73 ver_str=${not_match}
74 ;;
75
76 # huh?
77 *)
78 result+=("${ver_str::1}")
79 ver_str=${ver_str:1}
80 ;;
81 esac
82 done
83
84 export VERSIONATOR_CACHE_RESULT=${result[*]}
85 echo ${result[@]}
86 eshopts_pop
87 }
88
89 # @FUNCTION: get_version_components
90 # @USAGE: [version]
91 # @DESCRIPTION:
92 # Get the important version components, excluding '.', '-' and '_'. Defaults to
93 # $PV if no parameter is supplied.
94 # 0.8.3 -> 0 8 3
95 # 7c -> 7 c
96 # 3.0_p2 -> 3 0 p2
97 # 20040905 -> 20040905
98 # 3.0c-r1 -> 3 0 c r1
99 get_version_components() {
100 local c=$(get_all_version_components "${1:-${PV}}")
101 echo ${c//[-._]/ }
102 }
103
104 # @FUNCTION: get_major_version
105 # @USAGE: [version]
106 # @DESCRIPTION:
107 # Get the major version of a value. Defaults to $PV if no parameter is supplied.
108 # 0.8.3 -> 0
109 # 7c -> 7
110 # 3.0_p2 -> 3
111 # 20040905 -> 20040905
112 # 3.0c-r1 -> 3
113 get_major_version() {
114 local c=($(get_all_version_components "${1:-${PV}}"))
115 echo ${c[0]}
116 }
117
118 # @FUNCTION: get_version_component_range
119 # @USAGE: <range> [version]
120 # @DESCRIPTION:
121 # Get a particular component or range of components from the version. If no
122 # version parameter is supplied, defaults to $PV.
123 # 1 1.2.3 -> 1
124 # 1-2 1.2.3 -> 1.2
125 # 2- 1.2.3 -> 2.3
126 get_version_component_range() {
127 eshopts_push -s extglob
128 local c v="${2:-${PV}}" range="${1}" range_start range_end
129 local -i i=-1 j=0
130 c=($(get_all_version_components "${v}"))
131 range_start=${range%-*}; range_start=${range_start:-1}
132 range_end=${range#*-} ; range_end=${range_end:-${#c[@]}}
133
134 while ((j < range_start)); do
135 i+=1
136 ((i > ${#c[@]})) && eshopts_pop && return
137 [[ -n "${c[i]//[-._]}" ]] && j+=1
138 done
139
140 while ((j <= range_end)); do
141 echo -n ${c[i]}
142 ((i > ${#c[@]})) && eshopts_pop && return
143 [[ -n "${c[i]//[-._]}" ]] && j+=1
144 i+=1
145 done
146 eshopts_pop
147 }
148
149 # @FUNCTION: get_after_major_version
150 # @USAGE: [version]
151 # @DESCRIPTION:
152 # Get everything after the major version and its separator (if present) of a
153 # value. Defaults to $PV if no parameter is supplied.
154 # 0.8.3 -> 8.3
155 # 7c -> c
156 # 3.0_p2 -> 0_p2
157 # 20040905 -> (empty string)
158 # 3.0c-r1 -> 0c-r1
159 get_after_major_version() {
160 echo $(get_version_component_range 2- "${1:-${PV}}")
161 }
162
163 # @FUNCTION: replace_version_separator
164 # @USAGE: <search> <replacement> [subject]
165 # @DESCRIPTION:
166 # Replace the $1th separator with $2 in $3 (defaults to $PV if $3 is not
167 # supplied). If there are fewer than $1 separators, don't change anything.
168 # 1 '_' 1.2.3 -> 1_2.3
169 # 2 '_' 1.2.3 -> 1.2_3
170 # 1 '_' 1b-2.3 -> 1b_2.3
171 # Rather than being a number, $1 can be a separator character such as '-', '.'
172 # or '_'. In this case, the first separator of this kind is selected.
173 replace_version_separator() {
174 eshopts_push -s extglob
175 local w c v="${3:-${PV}}"
176 declare -i i found=0
177 w=${1:-1}
178 c=($(get_all_version_components ${v}))
179 if [[ ${w} != *[[:digit:]]* ]] ; then
180 # it's a character, not an index
181 for ((i = 0; i < ${#c[@]}; i++)); do
182 if [[ ${c[i]} == ${w} ]]; then
183 c[i]=${2}
184 break
185 fi
186 done
187 else
188 for ((i = 0; i < ${#c[@]}; i++)); do
189 if [[ -n "${c[i]//[^-._]}" ]]; then
190 found+=1
191 if ((found == w)); then
192 c[i]=${2}
193 break
194 fi
195 fi
196 done
197 fi
198 c=${c[*]}
199 echo ${c// }
200 eshopts_pop
201 }
202
203 # @FUNCTION: replace_all_version_separators
204 # @USAGE: <replacement> [subject]
205 # @DESCRIPTION:
206 # Replace all version separators in $2 (defaults to $PV) with $1.
207 # '_' 1b.2.3 -> 1b_2_3
208 replace_all_version_separators() {
209 local c=($(get_all_version_components "${2:-${PV}}"))
210 c=${c[@]//[-._]/$1}
211 echo ${c// }
212 }
213
214 # @FUNCTION: delete_version_separator
215 # @USAGE: <search> [subject]
216 # @DESCRIPTION:
217 # Delete the $1th separator in $2 (defaults to $PV if $2 is not supplied). If
218 # there are fewer than $1 separators, don't change anything.
219 # 1 1.2.3 -> 12.3
220 # 2 1.2.3 -> 1.23
221 # 1 1b-2.3 -> 1b2.3
222 # Rather than being a number, $1 can be a separator character such as '-', '.'
223 # or '_'. In this case, the first separator of this kind is deleted.
224 delete_version_separator() {
225 replace_version_separator "${1}" "" "${2}"
226 }
227
228 # @FUNCTION: delete_all_version_separators
229 # @USAGE: [subject]
230 # @DESCRIPTION:
231 # Delete all version separators in $1 (defaults to $PV).
232 # 1b.2.3 -> 1b23
233 delete_all_version_separators() {
234 replace_all_version_separators "" "${1}"
235 }
236
237 # @FUNCTION: get_version_component_count
238 # @USAGE: [version]
239 # @DESCRIPTION:
240 # How many version components are there in $1 (defaults to $PV)?
241 # 1.0.1 -> 3
242 # 3.0c-r1 -> 4
243 get_version_component_count() {
244 local a=($(get_version_components "${1:-${PV}}"))
245 echo ${#a[@]}
246 }
247
248 # @FUNCTION: get_last_version_component_index
249 # @USAGE: [version]
250 # @DESCRIPTION:
251 # What is the index of the last version component in $1 (defaults to $PV)?
252 # Equivalent to get_version_component_count - 1.
253 # 1.0.1 -> 2
254 # 3.0c-r1 -> 3
255 get_last_version_component_index() {
256 echo $(($(get_version_component_count "${1:-${PV}}" ) - 1))
257 }
258
259 # @FUNCTION: version_is_at_least
260 # @USAGE: <want> [have]
261 # @DESCRIPTION:
262 # Is $2 (defaults to $PVR) at least version $1? Intended for use in eclasses
263 # only. May not be reliable, be sure to do very careful testing before actually
264 # using this.
265 version_is_at_least() {
266 local want_s="$1" have_s="${2:-${PVR}}" r
267 version_compare "${want_s}" "${have_s}"
268 r=$?
269 case $r in
270 1|2)
271 return 0
272 ;;
273 3)
274 return 1
275 ;;
276 *)
277 die "versionator compare bug [atleast, ${want_s}, ${have_s}, ${r}]"
278 ;;
279 esac
280 }
281
282 # @FUNCTION: version_compare
283 # @USAGE: <A> <B>
284 # @DESCRIPTION:
285 # Takes two parameters (A, B) which are versions. If A is an earlier version
286 # than B, returns 1. If A is identical to B, return 2. If A is later than B,
287 # return 3. You probably want version_is_at_least rather than this function.
288 # May not be very reliable. Test carefully before using this.
289 version_compare() {
290 eshopts_push -s extglob
291 local ver_a=${1} ver_b=${2} parts_a parts_b
292 local cur_tok_a cur_tok_b num_part_a num_part_b
293 local -i cur_idx_a=0 cur_idx_b=0 prev_idx_a prev_idx_b
294 parts_a=( $(get_all_version_components "${ver_a}" ) )
295 parts_b=( $(get_all_version_components "${ver_b}" ) )
296
297 ### compare number parts.
298 local -i inf_loop=0
299 while true; do
300 inf_loop+=1
301 ((inf_loop > 20)) && \
302 die "versionator compare bug [numbers, ${ver_a}, ${ver_b}]"
303
304 # Store the current index to test later
305 prev_idx_a=cur_idx_a
306 prev_idx_b=cur_idx_b
307
308 # grab the current number components
309 cur_tok_a=${parts_a[cur_idx_a]}
310 cur_tok_b=${parts_b[cur_idx_b]}
311
312 # number?
313 if [[ -n ${cur_tok_a} ]] && [[ -z ${cur_tok_a//[[:digit:]]} ]] ; then
314 cur_idx_a+=1
315 [[ ${parts_a[cur_idx_a]} == . ]] \
316 && cur_idx_a+=1
317 else
318 cur_tok_a=
319 fi
320
321 if [[ -n ${cur_tok_b} ]] && [[ -z ${cur_tok_b//[[:digit:]]} ]] ; then
322 cur_idx_b+=1
323 [[ ${parts_b[cur_idx_b]} == . ]] \
324 && cur_idx_b+=1
325 else
326 cur_tok_b=
327 fi
328
329 # done with number components?
330 [[ -z ${cur_tok_a} && -z ${cur_tok_b} ]] && break
331
332 # if a component is blank, then it is the lesser value
333 [[ -z ${cur_tok_a} ]] && eshopts_pop && return 1
334 [[ -z ${cur_tok_b} ]] && eshopts_pop && return 3
335
336 # According to PMS, if we are *not* in the first number part, and either
337 # token begins with "0", then we use a different algorithm (that
338 # effectively does floating point comparison)
339 if (( prev_idx_a != 0 && prev_idx_b != 0 )) \
340 && [[ ${cur_tok_a} == 0* || ${cur_tok_b} == 0* ]] ; then
341
342 # strip trailing zeros
343 cur_tok_a=${cur_tok_a%%+(0)}
344 cur_tok_b=${cur_tok_b%%+(0)}
345
346 # do a *string* comparison of the resulting values: 2 > 11
347 [[ ${cur_tok_a} < ${cur_tok_b} ]] && eshopts_pop && return 1
348 [[ ${cur_tok_a} > ${cur_tok_b} ]] && eshopts_pop && return 3
349 else
350 # to avoid going into octal mode, strip any leading zeros. otherwise
351 # bash will throw a hissy fit on versions like 6.3.068.
352 cur_tok_a=${cur_tok_a##+(0)}
353 cur_tok_b=${cur_tok_b##+(0)}
354
355 # now if a component is blank, it was originally 0 -- make it so
356 : ${cur_tok_a:=0}
357 : ${cur_tok_b:=0}
358
359 # compare
360 ((cur_tok_a < cur_tok_b)) && eshopts_pop && return 1
361 ((cur_tok_a > cur_tok_b)) && eshopts_pop && return 3
362 fi
363 done
364
365 ### number parts equal. compare letter parts.
366 local letter_a=
367 letter_a=${parts_a[cur_idx_a]}
368 if [[ ${#letter_a} -eq 1 && -z ${letter_a/[a-z]} ]] ; then
369 cur_idx_a+=1
370 else
371 letter_a=@
372 fi
373
374 local letter_b=
375 letter_b=${parts_b[cur_idx_b]}
376 if [[ ${#letter_b} -eq 1 && -z ${letter_b/[a-z]} ]] ; then
377 cur_idx_b+=1
378 else
379 letter_b=@
380 fi
381
382 # compare
383 [[ ${letter_a} < ${letter_b} ]] && eshopts_pop && return 1
384 [[ ${letter_a} > ${letter_b} ]] && eshopts_pop && return 3
385
386 ### letter parts equal. compare suffixes in order.
387 inf_loop=0
388 while true ; do
389 inf_loop+=1
390 ((inf_loop > 20)) && \
391 die "versionator compare bug [numbers, ${ver_a}, ${ver_b}]"
392 [[ ${parts_a[cur_idx_a]} == _ ]] && ((cur_idx_a++))
393 [[ ${parts_b[cur_idx_b]} == _ ]] && ((cur_idx_b++))
394
395 cur_tok_a=${parts_a[cur_idx_a]}
396 cur_tok_b=${parts_b[cur_idx_b]}
397 num_part_a=0
398 num_part_b=0
399
400 if has ${cur_tok_a%%+([0-9])} "alpha" "beta" "pre" "rc" "p"; then
401 cur_idx_a+=1
402 num_part_a=${cur_tok_a##+([a-z])}
403 # I don't like octal
404 num_part_a=${num_part_a##+(0)}
405 : ${num_part_a:=0}
406 cur_tok_a=${cur_tok_a%%+([0-9])}
407 else
408 cur_tok_a=
409 fi
410
411 if has ${cur_tok_b%%+([0-9])} alpha beta pre rc p; then
412 cur_idx_b+=1
413 num_part_b=${cur_tok_b##+([a-z])}
414 # I still don't like octal
415 num_part_b=${num_part_b##+(0)}
416 : ${num_part_b:=0}
417 cur_tok_b=${cur_tok_b%%+([0-9])}
418 else
419 cur_tok_b=
420 fi
421
422 if [[ ${cur_tok_a} != ${cur_tok_b} ]]; then
423 local suffix
424 for suffix in alpha beta pre rc "" p; do
425 [[ ${cur_tok_a} == ${suffix} ]] && eshopts_pop && return 1
426 [[ ${cur_tok_b} == ${suffix} ]] && eshopts_pop && return 3
427 done
428 elif [[ -z ${cur_tok_a} && -z ${cur_tok_b} ]]; then
429 break
430 else
431 ((num_part_a < num_part_b)) && eshopts_pop && return 1
432 ((num_part_a > num_part_b)) && eshopts_pop && return 3
433 fi
434 done
435
436 # At this point, the only thing that should be left is the -r# part
437 [[ ${parts_a[cur_idx_a]} == - ]] && ((cur_idx_a++))
438 [[ ${parts_b[cur_idx_b]} == - ]] && ((cur_idx_b++))
439
440 # Sanity check
441 if [[ ${parts_a[cur_idx_a]/r+([0-9])} || ${parts_b[cur_idx_b]/r+([0-9])} ]]; then
442 die "versionator compare bug [revisions, ${ver_a}, ${ver_b}]"
443 fi
444
445 num_part_a=${parts_a[cur_idx_a]#r}
446 num_part_a=${num_part_a##+(0)}
447 : ${num_part_a:=0}
448 num_part_b=${parts_b[cur_idx_b]#r}
449 num_part_b=${num_part_b##+(0)}
450 : ${num_part_b:=0}
451
452 ((num_part_a < num_part_b)) && eshopts_pop && return 1
453 ((num_part_a > num_part_b)) && eshopts_pop && return 3
454
455 ### no differences.
456 eshopts_pop
457 return 2
458 }
459
460 # @FUNCTION: version_sort
461 # @USAGE: <version> [more versions...]
462 # @DESCRIPTION:
463 # Returns its parameters sorted, highest version last. We're using a quadratic
464 # algorithm for simplicity, so don't call it with more than a few dozen items.
465 # Uses version_compare, so be careful.
466 version_sort() {
467 eshopts_push -s extglob
468 local items=
469 local -i left=0
470 items=("$@")
471 while ((left < ${#items[@]})); do
472 local -i lowest_idx=left
473 local -i idx=lowest_idx+1
474 while ((idx < ${#items[@]})); do
475 version_compare "${items[lowest_idx]}" "${items[idx]}"
476 [[ $? -eq 3 ]] && lowest_idx=idx
477 idx+=1
478 done
479 local tmp=${items[lowest_idx]}
480 items[lowest_idx]=${items[left]}
481 items[left]=${tmp}
482 left+=1
483 done
484 echo ${items[@]}
485 eshopts_pop
486 }
487
488 # @FUNCTION: version_format_string
489 # @USAGE: <format> [version]
490 # @DESCRIPTION:
491 # Reformat complicated version strings. The first argument is the string
492 # to reformat with while the rest of the args are passed on to the
493 # get_version_components function. You should make sure to single quote
494 # the first argument since it'll have variables that get delayed expansions.
495 # @EXAMPLE:
496 # P="cow-hat-1.2.3_p4"
497 # MY_P=$(version_format_string '${PN}_source_$1_$2-$3_$4')
498 # Now MY_P will be: cow-hat_source_1_2-3_p4
499 version_format_string() {
500 local fstr=$1
501 shift
502 set -- $(get_version_components "$@")
503 eval echo "${fstr}"
504 }
505
506 __versionator__test_version_compare() {
507 eshopts_push -s extglob
508 local lt=1 eq=2 gt=3 p q
509
510 __versionator__test_version_compare_t() {
511 version_compare "${1}" "${3}"
512 local r=$?
513 [[ ${r} -eq ${2} ]] || echo "FAIL: ${@} (got ${r} exp ${2})"
514 }
515
516 echo "
517 0 $lt 1
518 1 $lt 2
519 2 $gt 1
520 2 $eq 2
521 0 $eq 0
522 10 $lt 20
523 68 $eq 068
524 068 $gt 67
525 068 $lt 69
526
527 1.0 $lt 2.0
528 2.0 $eq 2.0
529 2.0 $gt 1.0
530
531 1.0 $gt 0.0
532 0.0 $eq 0.0
533 0.0 $lt 1.0
534
535 0.1 $lt 0.2
536 0.2 $eq 0.2
537 0.3 $gt 0.2
538
539 1.2 $lt 2.1
540 2.1 $gt 1.2
541
542 1.2.3 $lt 1.2.4
543 1.2.4 $gt 1.2.3
544
545 1.2.0 $gt 1.2
546 1.2.1 $gt 1.2
547 1.2 $lt 1.2.1
548
549 1.2b $eq 1.2b
550 1.2b $lt 1.2c
551 1.2b $gt 1.2a
552 1.2b $gt 1.2
553 1.2 $lt 1.2a
554
555 1.3 $gt 1.2a
556 1.3 $lt 1.3a
557
558 1.0_alpha7 $lt 1.0_beta7
559 1.0_beta $lt 1.0_pre
560 1.0_pre5 $lt 1.0_rc2
561 1.0_rc2 $lt 1.0
562
563 1.0_p1 $gt 1.0
564 1.0_p1-r1 $gt 1.0_p1
565
566 1.0_alpha6-r1 $gt 1.0_alpha6
567 1.0_beta6-r1 $gt 1.0_alpha6-r2
568
569 1.0_pre1 $lt 1.0_p1
570
571 1.0p $gt 1.0_p1
572 1.0r $gt 1.0-r1
573 1.6.15 $gt 1.6.10-r2
574 1.6.10-r2 $lt 1.6.15
575
576 " | while read a b c ; do
577 [[ -z "${a}${b}${c}" ]] && continue;
578 __versionator__test_version_compare_t "${a}" "${b}" "${c}"
579 done
580
581
582 for q in "alpha beta pre rc=${lt};${gt}" "p=${gt};${lt}" ; do
583 for p in ${q%%=*} ; do
584 local c=${q##*=}
585 local alt=${c%%;*} agt=${c##*;}
586 __versionator__test_version_compare_t "1.0" $agt "1.0_${p}"
587 __versionator__test_version_compare_t "1.0" $agt "1.0_${p}1"
588 __versionator__test_version_compare_t "1.0" $agt "1.0_${p}068"
589
590 __versionator__test_version_compare_t "2.0_${p}" $alt "2.0"
591 __versionator__test_version_compare_t "2.0_${p}1" $alt "2.0"
592 __versionator__test_version_compare_t "2.0_${p}068" $alt "2.0"
593
594 __versionator__test_version_compare_t "1.0_${p}" $eq "1.0_${p}"
595 __versionator__test_version_compare_t "0.0_${p}" $lt "0.0_${p}1"
596 __versionator__test_version_compare_t "666_${p}3" $gt "666_${p}"
597
598 __versionator__test_version_compare_t "1_${p}7" $lt "1_${p}8"
599 __versionator__test_version_compare_t "1_${p}7" $eq "1_${p}7"
600 __versionator__test_version_compare_t "1_${p}7" $gt "1_${p}6"
601 __versionator__test_version_compare_t "1_${p}09" $eq "1_${p}9"
602
603 __versionator__test_version_compare_t "1_${p}7-r0" $eq "1_${p}7"
604 __versionator__test_version_compare_t "1_${p}7-r0" $lt "1_${p}7-r1"
605 __versionator__test_version_compare_t "1_${p}7-r0" $lt "1_${p}7-r01"
606 __versionator__test_version_compare_t "1_${p}7-r01" $eq "1_${p}7-r1"
607 __versionator__test_version_compare_t "1_${p}8-r1" $gt "1_${p}7-r100"
608
609 __versionator__test_version_compare_t "1_${p}_alpha" $lt "1_${p}_beta"
610 done
611 done
612
613 for p in "-r" "_p" ; do
614 __versionator__test_version_compare_t "7.2${p}1" $lt "7.2${p}2"
615 __versionator__test_version_compare_t "7.2${p}2" $gt "7.2${p}1"
616 __versionator__test_version_compare_t "7.2${p}3" $gt "7.2${p}2"
617 __versionator__test_version_compare_t "7.2${p}2" $lt "7.2${p}3"
618 done
619
620 # The following tests all come from portage's test cases:
621 __versionator__test_version_compare_t "6.0" $gt "5.0"
622 __versionator__test_version_compare_t "5.0" $gt "5"
623 __versionator__test_version_compare_t "1.0-r1" $gt "1.0-r0"
624 __versionator__test_version_compare_t "1.0-r1" $gt "1.0"
625 __versionator__test_version_compare_t "999999999999999999999999999999" $gt "999999999999999999999999999998"
626 __versionator__test_version_compare_t "1.0.0" $gt "1.0"
627 __versionator__test_version_compare_t "1.0.0" $gt "1.0b"
628 __versionator__test_version_compare_t "1b" $gt "1"
629 __versionator__test_version_compare_t "1b_p1" $gt "1_p1"
630 __versionator__test_version_compare_t "1.1b" $gt "1.1"
631 __versionator__test_version_compare_t "12.2.5" $gt "12.2b"
632
633 __versionator__test_version_compare_t "4.0" $lt "5.0"
634 __versionator__test_version_compare_t "5" $lt "5.0"
635 __versionator__test_version_compare_t "1.0_pre2" $lt "1.0_p2"
636 __versionator__test_version_compare_t "1.0_alpha2" $lt "1.0_p2"
637 __versionator__test_version_compare_t "1.0_alpha1" $lt "1.0_beta1"
638 __versionator__test_version_compare_t "1.0_beta3" $lt "1.0_rc3"
639 __versionator__test_version_compare_t "1.001000000000000000001" $lt "1.001000000000000000002"
640 __versionator__test_version_compare_t "1.00100000000" $lt "1.0010000000000000001"
641 __versionator__test_version_compare_t "999999999999999999999999999998" $lt "999999999999999999999999999999"
642 __versionator__test_version_compare_t "1.01" $lt "1.1"
643 __versionator__test_version_compare_t "1.0-r0" $lt "1.0-r1"
644 __versionator__test_version_compare_t "1.0" $lt "1.0-r1"
645 __versionator__test_version_compare_t "1.0" $lt "1.0.0"
646 __versionator__test_version_compare_t "1.0b" $lt "1.0.0"
647 __versionator__test_version_compare_t "1_p1" $lt "1b_p1"
648 __versionator__test_version_compare_t "1" $lt "1b"
649 __versionator__test_version_compare_t "1.1" $lt "1.1b"
650 __versionator__test_version_compare_t "12.2b" $lt "12.2.5"
651
652 __versionator__test_version_compare_t "4.0" $eq "4.0"
653 __versionator__test_version_compare_t "1.0" $eq "1.0"
654 __versionator__test_version_compare_t "1.0-r0" $eq "1.0"
655 __versionator__test_version_compare_t "1.0" $eq "1.0-r0"
656 __versionator__test_version_compare_t "1.0-r0" $eq "1.0-r0"
657 __versionator__test_version_compare_t "1.0-r1" $eq "1.0-r1"
658
659 # The following were just tests for != in portage, we need something a bit
660 # more precise
661 __versionator__test_version_compare_t "1" $lt "2"
662 __versionator__test_version_compare_t "1.0_alpha" $lt "1.0_pre"
663 __versionator__test_version_compare_t "1.0_beta" $gt "1.0_alpha"
664 __versionator__test_version_compare_t "0" $lt "0.0"
665 __versionator__test_version_compare_t "1.0-r0" $lt "1.0-r1"
666 __versionator__test_version_compare_t "1.0-r1" $gt "1.0-r0"
667 __versionator__test_version_compare_t "1.0" $lt "1.0-r1"
668 __versionator__test_version_compare_t "1.0-r1" $gt "1.0"
669 __versionator__test_version_compare_t "1_p1" $lt "1b_p1"
670 __versionator__test_version_compare_t "1b" $gt "1"
671 __versionator__test_version_compare_t "1.1b" $gt "1.1"
672 __versionator__test_version_compare_t "12.2b" $gt "12.2"
673
674 # The following tests all come from paludis's test cases:
675 __versionator__test_version_compare_t "1.0" $gt "1"
676 __versionator__test_version_compare_t "1" $lt "1.0"
677 __versionator__test_version_compare_t "1.0_alpha" $gt "1_alpha"
678 __versionator__test_version_compare_t "1.0_alpha" $gt "1"
679 __versionator__test_version_compare_t "1.0_alpha" $lt "1.0"
680 __versionator__test_version_compare_t "1.2.0.0_alpha7-r4" $gt "1.2_alpha7-r4"
681
682 __versionator__test_version_compare_t "0001" $eq "1"
683 __versionator__test_version_compare_t "01" $eq "001"
684 __versionator__test_version_compare_t "0001.1" $eq "1.1"
685 __versionator__test_version_compare_t "01.01" $eq "1.01"
686 __versionator__test_version_compare_t "1.010" $eq "1.01"
687 __versionator__test_version_compare_t "1.00" $eq "1.0"
688 __versionator__test_version_compare_t "1.0100" $eq "1.010"
689 __versionator__test_version_compare_t "1" $eq "1-r0"
690 __versionator__test_version_compare_t "1-r00" $eq "1-r0"
691
692 eshopts_pop
693 }

  ViewVC Help
Powered by ViewVC 1.1.20