Last active
May 13, 2016 20:55
-
-
Save eserte/1a8b031d7ba463dbf3d1 to your computer and use it in GitHub Desktop.
CPANDebianInstaller.pm - handle debian package dependencies of CPAN modules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package CPANDebianInstaller; | |
use strict; | |
use warnings; | |
sub new { bless {}, shift } | |
sub post_get { | |
my($self, $dist) = @_; | |
my %packages; | |
if (0) { | |
} elsif ($dist->base_id =~ m{^Cairo-\d}) { | |
$packages{$_} = 1 for qw(libcairo2-dev); | |
} elsif ($dist->base_id =~ m{^DBD-mysql-\d}) { | |
$packages{$_} = 1 for qw(libmysqlclient-dev); | |
} elsif ($dist->base_id =~ m{^DB_File-\d}) { | |
$packages{$_} = 1 for qw(libdb-dev); | |
} elsif ($dist->base_id =~ m{^GD-\d}) { | |
$packages{$_} = 1 for qw(libgd2-xpm-dev); | |
} elsif ($dist->base_id =~ m{^Geo-GDAL-\d}) { | |
$packages{$_} = 1 for qw(libgdal-dev); | |
} elsif ($dist->base_id =~ m{^Geo-Proj4-\d}) { | |
$packages{$_} = 1 for qw(libproj-dev proj-bin); | |
} elsif ($dist->base_id =~ m{^Geo-Shapelib\d}) { | |
$packages{$_} = 1 for qw(libshp-dev); | |
} elsif ($dist->base_id =~ m{^Glib-\d}) { | |
$packages{$_} = 1 for qw(libglib2.0-dev); | |
} elsif ($dist->base_id =~ m{^GraphViz-\d}) { | |
$packages{$_} = 1 for qw(graphviz); | |
} elsif ($dist->base_id =~ m{^Net-SSH2-\d}) { | |
$packages{$_} = 1 for qw(libssh2-1-dev); | |
} elsif ($dist->base_id =~ m{^Net-ZooKeeper-\d}) { | |
$packages{$_} = 1 for qw(libzookeeper-mt-dev zookeeperd); | |
} elsif ($dist->base_id =~ m{^Pango-\d}) { | |
$packages{$_} = 1 for qw(libpango1.0-dev); | |
} elsif ($dist->base_id =~ m{^Search-Xapian-\d}) { | |
$packages{$_} = 1 for qw(libxapian-dev); | |
} elsif ($dist->base_id =~ m{^Text-Hunspell-\d}) { | |
$packages{$_} = 1 for qw(libhunspell-dev); | |
} elsif ($dist->base_id =~ m{^Tk-\d}) { | |
$packages{$_} = 1 for qw(libx11-dev libfreetype6-dev libxft-dev libpng-dev libz-dev libjpeg-dev); | |
} elsif ($dist->base_id =~ m{^UUID-\d}) { | |
$packages{$_} = 1 for qw(uuid-dev); | |
} elsif ($dist->base_id =~ m{^XML-Parser-\d}) { | |
$packages{$_} = 1 for qw(libexpat1-dev); | |
} elsif ($dist->base_id =~ m{^XML-LibXML-\d}) { | |
$packages{$_} = 1 for qw(libxml2-dev); | |
} | |
if (%packages) { | |
my @cmd; | |
if ($< != 0) { | |
push @cmd, 'sudo'; | |
} | |
# XXX apt-get and/or aptitude? --yes? | |
push @cmd, ('aptitude', 'install', (sort keys %packages)); | |
system @cmd; | |
if ($? != 0) { | |
warn "Running '@cmd' failed...\n"; | |
} | |
} else { | |
warn "Nothing to do for " . $dist->pretty_id . "\n"; | |
} | |
} | |
1; | |
__END__ | |
=head1 EXAMPLES | |
=head2 WITH CPAN.pm | |
=over | |
=item * Copy this module a directory in perl's @INC as C<CPANDebianInstaller.pm> | |
=item * Install a recent CPAN.pm (2.11 or so) | |
=item * Configure CPAN.pm | |
perl -MCPAN -eshell | |
o conf plugin_list push CPANDebianInstaller | |
o conf commit | |
=item * Now install modules as usual | |
cpan GraphViz | |
or | |
perl -MCPAN -eshell | |
install GraphViz | |
quit | |
=back | |
=head2 WITH CPAN_SMOKER_MODULES | |
Example usage together with L<cpan_smoke_modules>: | |
env PERL5LIB=$HOME/work2/devel cpan_smoke_modules -pv 5.20.3-RC2 --cpanconf-unchecked plugin_list=CPANDebianInstaller GraphViz | |
C<--cpanconf-unchecked> is used because the new C<plugin_list> CPAN.pm | |
config is probably missing on my systems. | |
=cut |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
→ https://github.com/eserte/cpan-plugin-sysdeps