r27247 - /trunk/dh-make-perl/dh-make-perl

dmn at users.alioth.debian.org dmn at users.alioth.debian.org
Tue Nov 25 08:38:02 UTC 2008


Author: dmn
Date: Tue Nov 25 08:37:58 2008
New Revision: 27247

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=27247
Log:
avoid duplicate entries in dependency lists

Use AptPkg's compare() to leave only the higher versions

Modified:
    trunk/dh-make-perl/dh-make-perl

Modified: trunk/dh-make-perl/dh-make-perl
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/dh-make-perl?rev=27247&op=diff
==============================================================================
--- trunk/dh-make-perl/dh-make-perl (original)
+++ trunk/dh-make-perl/dh-make-perl Tue Nov 25 08:37:58 2008
@@ -13,6 +13,7 @@
 use Module::Depends::Intrusive;
 use Email::Date::Format qw(email_date);
 use Text::Wrap;
+use AptPkg::Config;
 use strict;
 
 # TODO:
@@ -878,6 +879,38 @@
 
     Storable::store( $cache, "$homedir/Contents.cache.new" );
     rename( "$homedir/Contents.cache.new", "$homedir/Contents.cache" );
+}
+
+# filter @deps to contain only one instance of each package
+# say we have te following list of dependencies:
+#   libppi-perl, libppi-perl (>= 3.0), libarm-perl, libalpa-perl, libarm-perl (>= 2)
+# we want a clean list instead:
+#   libalpa-perl, libarm-perl (>= 2), libppi-perl (>= 3.0)
+sub prune_deps(@)
+{
+    my %deps;
+    for (@_)
+    {
+        my $p = $_->{name};
+        my $v = exists( $_->{version} ) ? $_->{version} : undef;
+        if( exists $deps{$p} )
+        {
+            my $cur_ver = $deps{$p};
+
+            $deps{$p} = $v
+                if    defined($v)
+                  and not defined($cur_ver)
+                   or $AptPkg::Config::_config->system->versioning
+                      ->compare( $cur_ver, $v ) < 0;
+        }
+        else
+        {
+            $deps{$p} = $v;
+        }
+
+    }
+
+    return map( { name=>$_, version=>$deps{$_} }, sort( keys(%deps) ) );
 }
 
 sub extract_depends {
@@ -1035,6 +1068,8 @@
     elsif ( $opts{requiredeps} ) {
         die "--requiredeps was specified, but apt-file was not found\n";
     }
+
+    @deps = prune_deps(@deps);
 
     print "\n";
     print "Needs the following debian packages: "




More information about the Pkg-perl-cvs-commits mailing list