Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Module::Install and Debian packages

by dpavlin (Friar)
on Mar 12, 2008 at 21:00 UTC ( #673826=snippet: print w/ replies, xml ) Need Help??

Description: How many times did you wanted for Module::Install to just install available Debian packages and THEN use CPAN? I did several times. Here is quick diff to Module::Install::AutoInstall which does just that...
--- /home/dpavlin/.cpan/build/Module-Install-0.68/lib/Module/Install/A     2007-10-31 11:34:27.000000000 +0000
+++ /usr/local/share/perl/5.8.8/Module/Install/   2008-0
+3-12 20:58:01.000000000 +0000
@@ -30,6 +30,15 @@
     my @core = map @$_, map @$_, grep ref,
                $self->build_requires, $self->requires;
+       my @debs;
+       while ( my $module = shift @core ) {
+               my $ver = shift @core;
+               my $deb = 'lib' . lc($module) . '-perl';
+               $deb =~ s/::/-/g;
+               push @debs, $deb;
+       }
+       system "sudo apt-get install @debs";
     my @config = @_;
     # We'll need Module::AutoInstall
Comment on Module::Install and Debian packages
Download Code
Re: Module::Install and Debian packages
by Anonymous Monk on Mar 13, 2008 at 09:54 UTC
    What if the system call fails? Shouldn't you check its return value?
      To make this diff really small, I don't care. If system fails, Module::AutoInstall will install module from CPAN (because it's not installed by system).

      However, this approach has few problems: you might need to remove inc/ directory so that M::I will re-create it with this changes, and it will download only Debian packages which are required by current module (one which you did perl Makefile.PL for) and not for dependencies. So, let's move this idea at better place -- into Module::AutoInstall:

      --- /usr/share/perl5/Module/ 2007-10-31 11:34:27.0000 +00000 +0000 +++ 2008-03-13 14:48:31.000000000 +0000 @@ -6,7 +6,7 @@ use vars qw{$VERSION}; BEGIN { - $VERSION = '1.03'; + $VERSION = '1.04'; } # special map on pre-defined feature sets @@ -287,7 +288,10 @@ push @installed, $pkg; } else { - push @modules, $pkg, $ver; + my $deb = 'lib' . lc($pkg) . '-perl'; + $deb =~ s/::/-/g; + eval { system "sudo apt-get install $deb" }; + push @modules, $pkg, $ver if $@; } }
      I bumped $VERSION in hope that system-wide version will be picked before local version in inc/ directory.

      I would love to make this proper M::I module, but I'm afraid I don't have a clue where to start.


Back to Snippets Section

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://673826]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2015-03-03 17:15 GMT
Find Nodes?
    Voting Booth?

    When putting a smiley right before a closing parenthesis, do you:

    Results (77 votes), past polls