Created
September 8, 2010 19:24
-
-
Save mfontani/570665 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
# List of previously installed modules was created with: | |
# perldoc -o text perllocal | grep '"Module"' | cut -d'"' -f3 | cut -d' ' -f2 | |
my $installed = shift; | |
$installed = "$ENV{HOME}/perl-installed-20100908-1917.txt" unless defined $installed; | |
print "Using modules list from $installed\n"; | |
my @modules; | |
{ | |
open my $f, '<', $installed or die "Cannot open $installed: $!"; | |
@modules = <$f>; | |
close $f; | |
chomp @modules; | |
} | |
# preserving order | |
my @unique_modules; | |
{ | |
my %marker; | |
for my $module ( @modules ) { | |
push @unique_modules, $module if !defined $marker{$module}; | |
$marker{$module}++; | |
} | |
} | |
for my $modulename ( @unique_modules ) { | |
print "Installing $modulename...\n"; | |
my $rc = system("cpanm",$modulename); | |
if ( $rc ) { | |
print "Errors found while installing $modulename; aborting\n"; | |
exit $rc | |
} | |
print "Installed $modulename\n"; | |
system(qw/git add ./); | |
system(qw/git commit -am/, "Installed $modulename"); | |
print "Committed to Git repo\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment