This is a script(linux only) which will let you install a directory full of module tarball source packages. Just run the script in the directory of sources. It uses Module::Depends to try to sort and install the non-dependent modules first. It is not 100% accurate, and will leave some for manual install, but it is a time saver when you need to install 100's of source packages, as when you are upgrading Perl versions. It work best when you have an existing set of packages, which have been installed without problem, and you want to install them onto a different perl version.

It can be tested by setting a $prefixdir as explained in the script. Requires some user monitoring for scripts which do prompting.

Yes,I know about CPAN, but I prefer to download source packages manually.

#!/usr/local/bin/perl use warnings; use strict; use Module::Depends::Intrusive; # linux only, # needs at least perl5.8.0 to use i/o to \$var, # attempts to automate module installation from # a directory full of module source tarballs. # Just put the script in a directory full of module # sources and run. You can set a non-standard install # dir by the $prefixdir variable immediately below. # requires Module::Depends->which needs File::chdir, # Class::Accessor, and Class::Accessor::Chained my $prefixflag = 0; # a dir to install to for testing or # a homedir install #my $prefixdir = ''; my $prefixdir = '/home/zentara/ztest'; if ( length $prefixdir > 0 ) { $prefixflag = 1 } open( LOG, "> $0.log" ) or die $!; my @tarballs = <*.tar.gz>; #extract all tarballs foreach my $tarball (@tarballs) { system( 'tar', '-zxvf', $tarball ); } #get a list of all newly created directories # which probably don't correspond with tarball names opendir my $dh, '.' or die "Error: $!"; my @sourcedirs = grep !/^\.\.?$/, readdir $dh; closedir $dh; @sourcedirs = grep { -d } @sourcedirs; #only directories my @bad; #module sources which need manual attention my @dependent; #modules which are dependent and need to be #done last #check dependencies and adjust build order foreach my $testdir (@sourcedirs) { my @needs = (); my $output = ''; my $error = ''; my $depends = undef; #capture output of module to test for failures { local *STDOUT; open STDOUT, '+>', \$output or die $!; $depends = Module::Depends::Intrusive->new->dist_dir($testdir)->find_mo +dules; } my $deps = $depends->requires; #check if error was generated $error = $depends->error; if ( length $error > 0 ) { @sourcedirs = grep { !/^\Q$testdir\E$/ } @sourcedirs; push @bad, $testdir; } next if length $error > 0; @needs = keys %{$deps}; if ( ( scalar @needs ) > 0 ) { #move to end of install list so that dependent #modules can install first...not efficient, but easy :-) @sourcedirs = grep { !/^\Q$testdir\E$/ } @sourcedirs; push @dependent, $testdir; } #check for "failed" messages in output from Module::Depends #and send those to dependent for later install if ( $output =~ /failed/i ) { @sourcedirs = grep { !/^\Q$testdir\E$/ } @sourcedirs; push @dependent, $testdir; } print LOG '#' x 25, "\n"; print LOG '#' x 25, "\n"; print LOG "DIR-> $testdir\n"; print LOG "OUTPUT $output\n"; print LOG "needs -> @needs\n"; print LOG "ERROR-> $error\n"; } print "\n\nSourcedirs-> @sourcedirs\n"; print "\n\nDependent-> @dependent\n"; print "\n\nBad-> @bad\n"; print LOG "\n\nSourcedirs-> @sourcedirs\n"; print LOG "\n\nDependent-> @dependent\n"; print LOG "\n\nBad-> @bad\n"; ################################################################### #start the install #do the first run on error free source dirs foreach my $installdir (@sourcedirs) { chdir $installdir; if ($prefixdir) { system( 'perl', 'Makefile.PL', "PREFIX=$prefixdir" ); } else { system( 'perl', 'Makefile.PL' ); } system( 'make', 'install' ); chdir '../'; } ##################################################################### #now process the @dependent sourcedirs. Hopefully, most #dependencies were installed above, if not, and some of the @dependent + #modules are dependent on each other, we will just install what we #can. foreach my $installdir (@dependent) { chdir $installdir; if ($prefixdir) { system( 'perl', 'Makefile.PL', "PREFIX=$prefixdir" ); } else { system( 'perl', 'Makefile.PL' ); } system( 'make', 'install' ); chdir '../'; } ##################################################################### print "\e[1;31mDone!...be sure to check list of \@bad modules at the e +nd of $0.log....which need manual installation.\e[0m\n"; print "Uninstallable modules are:\n"; print "\e[1;31m"; print join "\n", @bad; print "\e[0m\n";