[dh-make-perl] 01/01: Add deb install options for dependencies

Damyan Ivanov dmn at moszumanska.debian.org
Fri Mar 11 17:09:29 UTC 2016


This is an automated email from the git hooks/post-receive script.

dmn pushed a commit to branch master
in repository dh-make-perl.

commit dd2326335bf676627c23001b955d7a1dc02d105a
Author: Andy Beverley <andy at andybev.com>
Date:   Thu Mar 10 19:07:26 2016 +0000

    Add deb install options for dependencies
    
    When building recursively, it would be useful if package dependencies
    could be installed as the building progresses, otherwise it takes
    several attempts to build the module.
    
    This patch provides 2 new options: --install-build-deps and
    --install-deps, which install just those packages required for building,
    and install all related packages, respectively.
---
 dh-make-perl                        | 10 ++++++++++
 lib/Debian/Control/FromCPAN.pm      | 21 +++++++++++++++++++++
 lib/DhMakePerl/Command/Packaging.pm | 16 +++++++++-------
 lib/DhMakePerl/Config.pm            |  1 +
 4 files changed, 41 insertions(+), 7 deletions(-)

diff --git a/dh-make-perl b/dh-make-perl
index 256eafd..8da532c 100755
--- a/dh-make-perl
+++ b/dh-make-perl
@@ -306,6 +306,16 @@ dpkg-source's default values.
 Installs the freshly built package. Specifying --install implies --build - The
 package will not be installed unless it was built (obviously ;-) )
 
+=item B<--install-deps>
+
+Install all dependencies for the module, as long as those dependencies are
+available as Debian packages.
+
+=item B<--install-build-deps>
+
+Install dependencies required for building the module, as long as those dependencies
+are available as Debian packages.
+
 =item B<--intrusive>
 
 When determining module dependencies, if L<Module::Depends> fails, tries again
diff --git a/lib/Debian/Control/FromCPAN.pm b/lib/Debian/Control/FromCPAN.pm
index b0895e1..7ce3a46 100644
--- a/lib/Debian/Control/FromCPAN.pm
+++ b/lib/Debian/Control/FromCPAN.pm
@@ -85,6 +85,16 @@ found.
 
 =cut
 
+sub _install_deb {
+    my ($deb, $verbose) = @_;
+    return if $deb eq 'libdbd-sqlite3-perl' || $deb eq 'libdbd-sqlite-perl';
+    my $inst_cmd = "apt-get -y install $deb";
+    $inst_cmd = "sudo $inst_cmd" if $>;
+    print "Running '$inst_cmd'..." if $verbose;
+    system($inst_cmd) == 0
+        || die "Cannot install package $deb\n";
+}
+
 sub discover_dependencies {
     my ( $self, $opts ) = @_;
 
@@ -97,6 +107,8 @@ sub discover_dependencies {
     my $intrusive = delete $opts->{intrusive};
     my $require_deps = delete $opts->{require_deps};
     my $verbose = delete $opts->{verbose};
+    my $install_deps = delete $opts->{install_deps};
+    my $install_build_deps = delete $opts->{install_build_deps};
     my $wnpp_query = delete $opts->{wnpp_query};
 
     die "Unsupported option(s) given: " . join( ', ', sort( keys(%$opts) ) )
@@ -187,6 +199,11 @@ sub discover_dependencies {
         else {
             $src->Build_Depends->add(@$debs);
         }
+        if ($install_deps) {
+            foreach my $deb (@$debs) {
+                _install_deb($deb->pkg) unless grep {$deb} @$missing;
+            }
+        }
     }
 
     # build-time
@@ -212,6 +229,10 @@ sub discover_dependencies {
         else {
             $src->Build_Depends_Indep->add(@$b_debs);
         }
+        if ($install_build_deps || $install_deps) {
+            _install_deb($_->pkg)
+                foreach @$b_debs;
+        }
     }
 
     push @$missing, @$b_missing;
diff --git a/lib/DhMakePerl/Command/Packaging.pm b/lib/DhMakePerl/Command/Packaging.pm
index 2407b9e..f45ec0f 100644
--- a/lib/DhMakePerl/Command/Packaging.pm
+++ b/lib/DhMakePerl/Command/Packaging.pm
@@ -1405,13 +1405,15 @@ sub discover_dependencies {
         }
 
         return $self->control->discover_dependencies(
-            {   dir            => $self->main_dir,
-                verbose        => $self->cfg->verbose,
-                apt_contents   => $self->apt_contents,
-                dpkg_available => $dpkg_available,
-                require_deps   => $self->cfg->requiredeps,
-                wnpp_query     => $wnpp_query,
-                intrusive      => $self->cfg->intrusive,
+            {   dir                => $self->main_dir,
+                verbose            => $self->cfg->verbose,
+                apt_contents       => $self->apt_contents,
+                dpkg_available     => $dpkg_available,
+                require_deps       => $self->cfg->requiredeps,
+                install_deps       => $self->cfg->install_deps,
+                install_build_deps => $self->cfg->install_build_deps,
+                wnpp_query         => $wnpp_query,
+                intrusive          => $self->cfg->intrusive,
             }
         );
     }
diff --git a/lib/DhMakePerl/Config.pm b/lib/DhMakePerl/Config.pm
index 01c4ab1..9f3752a 100644
--- a/lib/DhMakePerl/Config.pm
+++ b/lib/DhMakePerl/Config.pm
@@ -29,6 +29,7 @@ my @OPTIONS = (
     'dist=s',          'email|e=s',
     'exclude|i:s{,}',
     'home-dir=s',      'install!',
+    'install-deps',     'install-build-deps',
     'intrusive!',
     'network!',
     'nometa',          'notest',

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/dh-make-perl.git



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