>From 2ed90c88dfac1abe7403acc9c0939cc882940bda Mon Sep 17 00:00:00 2001
From: Andy Beverley <a...@andybev.com>
Date: Sun, 28 Dec 2014 08:40:12 +0000
Subject: [PATCH 6/6] Allow built core modules to overwrite files from perl
 package

---
 lib/DhMakePerl/Command/make.pm |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/lib/DhMakePerl/Command/make.pm b/lib/DhMakePerl/Command/make.pm
index 64a067f..05f2a82 100644
--- a/lib/DhMakePerl/Command/make.pm
+++ b/lib/DhMakePerl/Command/make.pm
@@ -136,6 +136,23 @@ sub execute {
     $bin->Depends->add( $self->cfg->depends )
         if $self->cfg->depends;
 
+    # If it's a module that would otherwise be part of core, then
+    # tell dpkg that this is allowed to overwrite files from
+    # the core perl package. We'll have only got this far if
+    # --core-ok has been specified.
+    if (is_core_module $self->cfg->cpan)
+    {
+        # Look up installed Perl version in apt cache
+        if (my $apt_cache = apt_cache()) {
+            my $pkg = $apt_cache->{perl};
+            if ( my $available = $pkg->{VersionList} ) {
+                my $target_perl_version = pop @$available;
+                my $depends = Debian::Dependency->new("perl (<=$target_perl_version)");
+                $bin->Replaces->add( $depends );
+            }
+        }
+    }
+
     $src->Build_Depends->add( $self->cfg->bdepends )
         if $self->cfg->bdepends;
 
-- 
1.7.10.4

Reply via email to