http://www.perlmonks.org?node_id=910155


in reply to Re: How to clean-up an autobundle so it's really "auto-installable"
in thread How to clean-up an autobundle so it's really "auto-installable"

Here is my version, takes bundle (or as cpanp names it, snapshot) file as argument
#!/usr/bin/perl -- use strict; use warnings; use CPANPLUS::Internals::Utils ; use DBI; Main( @ARGV ); exit( 0 ); sub Main { my @snaps = @_; my %U; my $db = CPANPLUS::Internals::Utils->_home_dir . '\.cpanplus\db.sq +l'; warn "db is $db snaps is @snaps "; my $dbh = DBI->connect( qq!dbi:SQLite:dbname=$db!, undef, undef, { RaiseError => 1, PrintError => 1, }, ); my $sth = $dbh->prepare( q! select path, package from module where + module = ? ! ); for my $file ( @snaps ){ open my($fh), '<', $file or die; while(<$fh>){ if(/=head1 CONTENTS/.. /=head1 CONFIGURATION/){ if( /^(\w\S+)\s/ ){ my $module = $1; $sth->execute($module ); my($a,$p) = $sth->fetchrow_array; next unless $p and $a; $a =~ s!^authors/id/!!; next if $p =~ /^perl-5\./; next if $p =~ /^perl-5\./; my $pp = $p; $pp =~ s/-\d.\d.+$//; ## libwwwperl $U{$pp}="$a/$p"; #~ perl-5.10.1.tar.gz #~ perl-5.11.1.tar.bz2 #~ perl-5.12.3.tar.bz2 #~ perl-5.13.9.tar.gz } } } close $fh; } undef $sth; undef $dbh; print "\n\nsystem qw[ cpanp -d \n"; print " $U{$_}\n" for sort keys %U; print "\n\n];\n"; } __END__ system qw[ cpanp -d ... G/GB/GBARR/libnet-1.22.tar.gz G/GA/GAAS/libwww-perl-6.02.tar.gz ];
I use cpanp -d to first download all the tarballs then later, offline, change -d to -i to install all the tarballs

  • Comment on Re^2: How to clean-up an autobundle so it's really "auto-installable"
  • Download Code

Replies are listed 'Best First'.
Re^3: How to clean-up an autobundle so it's really "auto-installable"
by Anonymous Monk on Dec 31, 2014 at 01:31 UTC

    Sometimes the simple solution isn't pure Perl.

    cpanm `cat Snapshot_2014_12_29_00.pm|awk '/\:\:/{print $1}'`

    I suppose I could find a way to do that in Perl but awk is simple and fast. This certainly puts lots of extra modules on cpanm's list, but it knows how to figure this stuff out.

      Sometimes the simple solution isn't pure Perl.

      cpanp already knows how to install snapshots, there is no need for cpanm or awk here

Re^3: How to clean-up an autobundle so it's really "auto-installable"
by Anonymous Monk on Dec 31, 2014 at 01:31 UTC

    Sometimes the simple solution isn't pure Perl.

    cpanm `cat Snapshot_2014_12_29_00.pm|awk '/\:\:/{print $1}'`

    I suppose I could find a way to do that in Perl but awk is simple and fast. This certainly puts lots of extra modules on cpanm's list, but it knows how to figure this stuff out.