]> git.deb.at Git - deb/packages.git/blobdiff - lib/Deb/Versions.pm
Reflect lucid release, add maverick.
[deb/packages.git] / lib / Deb / Versions.pm
index ec127ce8923eb380a76c2670d3dd0e76c833f7e0..706f017f20c185f25beab1cb6cae6b1d7864622f 100644 (file)
@@ -1,6 +1,5 @@
 #
 # Deb::Versions
-# $Id$
 #
 # Copyright 2003, 2004 Frank Lichtenheld <frank@lichtenheld.de>
 #
@@ -16,7 +15,7 @@
 #
 #    You should have received a copy of the GNU General Public License
 #    along with this program; if not, write to the Free Software
-#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
 
 =head1 NAME
@@ -71,11 +70,12 @@ our @EXPORT = qw( version_cmp version_sort suites_cmp suites_sort );
 
 our $VERSION = v1.0.0;
 
-sub version_cmp {
+my $re = qr/^(?:(\d+):)?([\w.+:~-]+?)(?:-([\w+.~]+))?$/;
+sub version_cmp_pp {
+    return 0 if $_[0] eq $_[1];
     my ( $ver1, $ver2 ) = @_;
 
     my ( $e1, $e2, $u1, $u2, $d1, $d2 );
-    my $re = qr/^(?:(\d+):)?([\w.+:~-]+?)(?:-([\w+.~]+))?$/;
     if ( $ver1 =~ $re ) {
        ( $e1, $u1, $d1 ) = ( $1, $2, $3 );
        $e1 ||= 0;
@@ -103,6 +103,18 @@ sub version_cmp {
     return $res;
 }
 
+*version_cmp = \&version_cmp_pp;
+eval {
+    require AptPkg::Config;
+    require AptPkg::System;
+    require AptPkg::Version;
+    
+    $AptPkg::Config::_config->init;
+    $AptPkg::System::_system = $AptPkg::Config::_config->system;
+    my $apt_ver = $AptPkg::System::_system->versioning;
+    *version_cmp = sub { return $apt_ver->compare(@_) };
+};
+
 sub version_sort {
     return sort { version_cmp( $b, $a ) } @_;
 }
@@ -142,9 +154,9 @@ sub _lcmp {
     for ( my $i = 0; $i <= length( $v1 ); $i++ ) {
        my ( $n1, $n2 ) = ( ord( substr( $v1, $i, 1 ) ), 
                            ord( substr( $v2, $i, 1 ) ) );
-       $n1 += 256 if $n1 < 65; # letters sort earlier than non-letters
+       $n1 += 256 if $n1 && $n1 < 65; # letters sort earlier than non-letters
        $n1 = -1 if $n1 == 126; # '~' sorts earlier than everything else
-       $n2 += 256 if $n2 < 65;
+       $n2 += 256 if $n2 && $n2 < 65;
        $n2 = -1 if $n2 == 126;
        if ( my $r = ($n1 <=> $n2) ) {
            return $r;
@@ -153,10 +165,22 @@ sub _lcmp {
     return length( $v1 ) <=> length( $v2 );
 }
 
-our @SUITES_SORT = qw( woody oldstable sarge stable stable-proposed-updates
-                      etch etch-m68k testing testing-proposed-updates lenny
-                      sid unstable experimental
-                      warty hoary breezy breezy dapper edgy feisty gutsy );
+our @SUITES_SORT = qw(  
+                       bo
+                       hamm
+                       slink
+                       potato
+                       woody
+                       sarge
+                       oldstable
+                       etch etch-m68k
+                       stable stable-proposed-updates
+                       lenny
+                       testing testing-proposed-updates
+                       squeeze
+                       sid unstable experimental
+                       warty hoary breezy dapper edgy feisty gutsy hardy
+                       intrepid jaunty karmic lucid maverick);
 our @ARCHIVE_SORT = qw( non-US security updates volatile backports );
 our @PRIORITY_SORT = qw( required important standard optional extra );
 my $i = 1000;
@@ -177,11 +201,11 @@ sub suites_cmp {
        $cmp_b = $suites_sort{$1} - $archive_sort{$2}
        if $s_b =~ m;^(.+?)[/-](.*)$;o;
     }
-    return ($cmp_a <=> $cmp_b);
+    return ($cmp_b <=> $cmp_a);
 }
 
 sub suites_sort {
-    return sort { suites_cmp( $b, $a ) } @_;
+    return sort { suites_cmp( $a, $b ) } @_;
 }
 
 sub priority_cmp {