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

Diff of /eclass/versionator.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.21 Revision 1.22
1# Copyright 1999-2008 Gentoo Foundation 1# Copyright 1999-2008 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.21 2011/12/10 08:36:31 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/versionator.eclass,v 1.22 2011/12/15 05:10:25 vapier Exp $
4 4
5# @ECLASS: versionator.eclass 5# @ECLASS: versionator.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Jonathan Callen <abcd@gentoo.org> 7# Jonathan Callen <abcd@gentoo.org>
8# base-system@gentoo.org 8# base-system@gentoo.org
505 shift 505 shift
506 set -- $(get_version_components "$@") 506 set -- $(get_version_components "$@")
507 eval echo "${fstr}" 507 eval echo "${fstr}"
508} 508}
509 509
510__versionator__test_version_compare() {
511 eshopts_push -s extglob
512 local lt=1 eq=2 gt=3 p q
513
514 __versionator__test_version_compare_t() {
515 version_compare "${1}" "${3}"
516 local r=$?
517 [[ ${r} -eq ${2} ]] || echo "FAIL: ${@} (got ${r} exp ${2})"
518 }
519
520 echo "
521 0 $lt 1
522 1 $lt 2
523 2 $gt 1
524 2 $eq 2
525 0 $eq 0
526 10 $lt 20
527 68 $eq 068
528 068 $gt 67
529 068 $lt 69
530
531 1.0 $lt 2.0
532 2.0 $eq 2.0
533 2.0 $gt 1.0
534
535 1.0 $gt 0.0
536 0.0 $eq 0.0
537 0.0 $lt 1.0
538
539 0.1 $lt 0.2
540 0.2 $eq 0.2
541 0.3 $gt 0.2
542
543 1.2 $lt 2.1
544 2.1 $gt 1.2
545
546 1.2.3 $lt 1.2.4
547 1.2.4 $gt 1.2.3
548
549 1.2.0 $gt 1.2
550 1.2.1 $gt 1.2
551 1.2 $lt 1.2.1
552
553 1.2b $eq 1.2b
554 1.2b $lt 1.2c
555 1.2b $gt 1.2a
556 1.2b $gt 1.2
557 1.2 $lt 1.2a
558
559 1.3 $gt 1.2a
560 1.3 $lt 1.3a
561
562 1.0_alpha7 $lt 1.0_beta7
563 1.0_beta $lt 1.0_pre
564 1.0_pre5 $lt 1.0_rc2
565 1.0_rc2 $lt 1.0
566
567 1.0_p1 $gt 1.0
568 1.0_p1-r1 $gt 1.0_p1
569
570 1.0_alpha6-r1 $gt 1.0_alpha6
571 1.0_beta6-r1 $gt 1.0_alpha6-r2
572
573 1.0_pre1 $lt 1.0_p1
574
575 1.0p $gt 1.0_p1
576 1.0r $gt 1.0-r1
577 1.6.15 $gt 1.6.10-r2
578 1.6.10-r2 $lt 1.6.15
579
580 " | while read a b c ; do
581 [[ -z "${a}${b}${c}" ]] && continue;
582 __versionator__test_version_compare_t "${a}" "${b}" "${c}"
583 done
584
585
586 for q in "alpha beta pre rc=${lt};${gt}" "p=${gt};${lt}" ; do
587 for p in ${q%%=*} ; do
588 local c=${q##*=}
589 local alt=${c%%;*} agt=${c##*;}
590 __versionator__test_version_compare_t "1.0" $agt "1.0_${p}"
591 __versionator__test_version_compare_t "1.0" $agt "1.0_${p}1"
592 __versionator__test_version_compare_t "1.0" $agt "1.0_${p}068"
593
594 __versionator__test_version_compare_t "2.0_${p}" $alt "2.0"
595 __versionator__test_version_compare_t "2.0_${p}1" $alt "2.0"
596 __versionator__test_version_compare_t "2.0_${p}068" $alt "2.0"
597
598 __versionator__test_version_compare_t "1.0_${p}" $eq "1.0_${p}"
599 __versionator__test_version_compare_t "0.0_${p}" $lt "0.0_${p}1"
600 __versionator__test_version_compare_t "666_${p}3" $gt "666_${p}"
601
602 __versionator__test_version_compare_t "1_${p}7" $lt "1_${p}8"
603 __versionator__test_version_compare_t "1_${p}7" $eq "1_${p}7"
604 __versionator__test_version_compare_t "1_${p}7" $gt "1_${p}6"
605 __versionator__test_version_compare_t "1_${p}09" $eq "1_${p}9"
606
607 __versionator__test_version_compare_t "1_${p}7-r0" $eq "1_${p}7"
608 __versionator__test_version_compare_t "1_${p}7-r0" $lt "1_${p}7-r1"
609 __versionator__test_version_compare_t "1_${p}7-r0" $lt "1_${p}7-r01"
610 __versionator__test_version_compare_t "1_${p}7-r01" $eq "1_${p}7-r1"
611 __versionator__test_version_compare_t "1_${p}8-r1" $gt "1_${p}7-r100"
612
613 __versionator__test_version_compare_t "1_${p}_alpha" $lt "1_${p}_beta"
614 done
615 done
616
617 for p in "-r" "_p" ; do
618 __versionator__test_version_compare_t "7.2${p}1" $lt "7.2${p}2"
619 __versionator__test_version_compare_t "7.2${p}2" $gt "7.2${p}1"
620 __versionator__test_version_compare_t "7.2${p}3" $gt "7.2${p}2"
621 __versionator__test_version_compare_t "7.2${p}2" $lt "7.2${p}3"
622 done
623
624 # The following tests all come from portage's test cases:
625 __versionator__test_version_compare_t "6.0" $gt "5.0"
626 __versionator__test_version_compare_t "5.0" $gt "5"
627 __versionator__test_version_compare_t "1.0-r1" $gt "1.0-r0"
628 __versionator__test_version_compare_t "1.0-r1" $gt "1.0"
629 __versionator__test_version_compare_t "999999999999999999999999999999" $gt "999999999999999999999999999998"
630 __versionator__test_version_compare_t "1.0.0" $gt "1.0"
631 __versionator__test_version_compare_t "1.0.0" $gt "1.0b"
632 __versionator__test_version_compare_t "1b" $gt "1"
633 __versionator__test_version_compare_t "1b_p1" $gt "1_p1"
634 __versionator__test_version_compare_t "1.1b" $gt "1.1"
635 __versionator__test_version_compare_t "12.2.5" $gt "12.2b"
636
637 __versionator__test_version_compare_t "4.0" $lt "5.0"
638 __versionator__test_version_compare_t "5" $lt "5.0"
639 __versionator__test_version_compare_t "1.0_pre2" $lt "1.0_p2"
640 __versionator__test_version_compare_t "1.0_alpha2" $lt "1.0_p2"
641 __versionator__test_version_compare_t "1.0_alpha1" $lt "1.0_beta1"
642 __versionator__test_version_compare_t "1.0_beta3" $lt "1.0_rc3"
643 __versionator__test_version_compare_t "1.001000000000000000001" $lt "1.001000000000000000002"
644 __versionator__test_version_compare_t "1.00100000000" $lt "1.0010000000000000001"
645 __versionator__test_version_compare_t "999999999999999999999999999998" $lt "999999999999999999999999999999"
646 __versionator__test_version_compare_t "1.01" $lt "1.1"
647 __versionator__test_version_compare_t "1.0-r0" $lt "1.0-r1"
648 __versionator__test_version_compare_t "1.0" $lt "1.0-r1"
649 __versionator__test_version_compare_t "1.0" $lt "1.0.0"
650 __versionator__test_version_compare_t "1.0b" $lt "1.0.0"
651 __versionator__test_version_compare_t "1_p1" $lt "1b_p1"
652 __versionator__test_version_compare_t "1" $lt "1b"
653 __versionator__test_version_compare_t "1.1" $lt "1.1b"
654 __versionator__test_version_compare_t "12.2b" $lt "12.2.5"
655
656 __versionator__test_version_compare_t "4.0" $eq "4.0"
657 __versionator__test_version_compare_t "1.0" $eq "1.0"
658 __versionator__test_version_compare_t "1.0-r0" $eq "1.0"
659 __versionator__test_version_compare_t "1.0" $eq "1.0-r0"
660 __versionator__test_version_compare_t "1.0-r0" $eq "1.0-r0"
661 __versionator__test_version_compare_t "1.0-r1" $eq "1.0-r1"
662
663 # The following were just tests for != in portage, we need something a bit
664 # more precise
665 __versionator__test_version_compare_t "1" $lt "2"
666 __versionator__test_version_compare_t "1.0_alpha" $lt "1.0_pre"
667 __versionator__test_version_compare_t "1.0_beta" $gt "1.0_alpha"
668 __versionator__test_version_compare_t "0" $lt "0.0"
669 __versionator__test_version_compare_t "1.0-r0" $lt "1.0-r1"
670 __versionator__test_version_compare_t "1.0-r1" $gt "1.0-r0"
671 __versionator__test_version_compare_t "1.0" $lt "1.0-r1"
672 __versionator__test_version_compare_t "1.0-r1" $gt "1.0"
673 __versionator__test_version_compare_t "1_p1" $lt "1b_p1"
674 __versionator__test_version_compare_t "1b" $gt "1"
675 __versionator__test_version_compare_t "1.1b" $gt "1.1"
676 __versionator__test_version_compare_t "12.2b" $gt "12.2"
677
678 # The following tests all come from paludis's test cases:
679 __versionator__test_version_compare_t "1.0" $gt "1"
680 __versionator__test_version_compare_t "1" $lt "1.0"
681 __versionator__test_version_compare_t "1.0_alpha" $gt "1_alpha"
682 __versionator__test_version_compare_t "1.0_alpha" $gt "1"
683 __versionator__test_version_compare_t "1.0_alpha" $lt "1.0"
684 __versionator__test_version_compare_t "1.2.0.0_alpha7-r4" $gt "1.2_alpha7-r4"
685
686 __versionator__test_version_compare_t "0001" $eq "1"
687 __versionator__test_version_compare_t "01" $eq "001"
688 __versionator__test_version_compare_t "0001.1" $eq "1.1"
689 __versionator__test_version_compare_t "01.01" $eq "1.01"
690 __versionator__test_version_compare_t "1.010" $eq "1.01"
691 __versionator__test_version_compare_t "1.00" $eq "1.0"
692 __versionator__test_version_compare_t "1.0100" $eq "1.010"
693 __versionator__test_version_compare_t "1" $eq "1-r0"
694 __versionator__test_version_compare_t "1-r00" $eq "1-r0"
695
696 eshopts_pop
697}
698
699fi 510fi

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22

  ViewVC Help
Powered by ViewVC 1.1.20