#!/usr/bin/perl -w use strict; use warnings; use File::Copy; my $perlv = $ARGV[0]; my $ver = $1 if $perlv =~ m!^(\d+\.\d+\.\d+)([mst])?!; die 'Usage: new_setup ', $/ unless $ver; my $HOME = $ENV{'HOME'} // '/home/stro'; # Copy Config.pm my $src_config = $HOME . '/cpan/Config.pm'; my $res_config = $HOME . '/perl/' . $perlv . '/lib/' . $ver . '/CPAN/Config.pm'; die 'No ' . $src_config unless -e $src_config; if (-e $res_config) { warn 'Existing config ' . $res_config; } else { File::Copy::copy($src_config => $res_config) or die $!, ': Cannot copy ', $src_config, ' to ', $res_config; } # Create new build directory to store initial Metabase file mkdir $HOME . '/cpan/build/' . $ver; # Install modules my @list = qw/CPAN::Reporter CPAN::SQLite CPAN::Reporter::Smoker YAML::Syck Log::Log4perl CPAN LWP::UserAgent YAML Test::Reporter::Transport::Metabase::Fallback /; foreach my $module (@list) { system('~/perl/' . $perlv . '/bin/cpan ' . $module); die 'CPAN::Reporter is not installed' unless -e $HOME . '/perl/' . $perlv . '/lib/site_perl/' . $ver . '/CPAN/Reporter.pm'; } print '-' x 64, $/; foreach my $module (@list) { my $call = '~/perl/' . $perlv . '/bin/perl -M' . $module . ' -e "print q{' . $module . ' v}, \\$' . $module . '::VERSION"'; system($call); print $/; } print (('=' x 64 . $/) x 3, 'DONE', $/);