Created
October 11, 2012 20:50
-
-
Save mshock/3875391 to your computer and use it in GitHub Desktop.
ppm install missing modules from exported csv
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
#! perl -w | |
# read exported ppm csv list and install all missing modules | |
use strict; | |
# first make sure everything is up to date | |
print "updating all installed modules...\n"; | |
print `ppm upgrade --install`; | |
print "\ndone\n\n"; | |
print "getting list of all installed modules...\n"; | |
# get csv of all currently installed modules | |
my %local_mods = csv2hash(split "\n", `ppm list --csv --no-header`); | |
print "\ndone\n\n"; | |
print "reading exported module csv...\n"; | |
# read list of modules desired | |
open(CSV,'<', $ARGV[0] || 'ppm_list.csv'); | |
my @remote_mods = <CSV>; | |
close CSV; | |
print "\ndone\n\n"; | |
print "installing all missing modules...\n"; | |
# check each module | |
for my $line (@remote_mods){ | |
chomp $line; | |
my ($name,$version,$files,$area) = split ',', $line; | |
# install if not found | |
unless ($local_mods{$name}) { | |
$name =~ s/-/::/g; | |
print "\tinstalling $name\n"; | |
print `ppm install $name`; | |
} | |
} | |
print "\ndone\n\n"; | |
# convert ppm csv to hash of package_name => version # | |
sub csv2hash { | |
my @csv = shift; | |
my %hash; | |
for my $line (@csv) { | |
chomp $line; | |
my ($name,$version,$files,$area) = split ',', $line; | |
# if not site specific, skip it | |
next if $area ne 'site'; | |
$hash{$name} = $version; | |
} | |
return %hash; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment