X-Git-Url: https://git.deb.at/?a=blobdiff_plain;f=lib%2FDeb%2FVersions.pm;h=35f0cb5d5665e2a20dbc7a5104654f2a10832686;hb=c185991379b2754822262d4fcc6559481cef430c;hp=ba9df21b193eeb2b7cb983e235828209db9bb026;hpb=af06e819e0543521b4220ef7ea0562f7b8427f79;p=deb%2Fpackages.git diff --git a/lib/Deb/Versions.pm b/lib/Deb/Versions.pm index ba9df21..35f0cb5 100644 --- a/lib/Deb/Versions.pm +++ b/lib/Deb/Versions.pm @@ -70,11 +70,28 @@ our @EXPORT = qw( version_cmp version_sort suites_cmp suites_sort ); our $VERSION = v1.0.0; -sub version_cmp { +BEGIN { + eval { + use AptPkg::Config '$_config'; + use AptPkg::System '$_system'; + use AptPkg::Version; + + $_config->init; + $_system = $_config->system; + my $apt_ver = $_system->versioning; + *version_cmp = sub { return $apt_ver->compare(@_) }; + }; + unless( *version_cmp ){ + *version_cmp = \&version_cmp_pp; + } +} + +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; @@ -152,10 +169,16 @@ 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 dapper edgy feisty gutsy hardy intrepid jaunty); +our @SUITES_SORT = qw( 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); our @ARCHIVE_SORT = qw( non-US security updates volatile backports ); our @PRIORITY_SORT = qw( required important standard optional extra ); my $i = 1000;