I do something similar to this on AIX, Sun, HP, Linux ... I can't exactly cut&paste the code, but I can give you an idea. So treat this not as untested code, but as pseudocode.
# get rid of env that you don't need, in case you're in another build +environment # (say it isn't using the same CC or make that perl used/uses) cleanup_environment(); # set up environment - bypass as many make-maker prompst as possible, $ENV{PERL_MM_USE_DEFAULT} = 1; # add the directory we're installing to to the PERL5LIB so we can find + them # after we install 'em. $ENV{PERL5LIB} = File::Spec->catdir($install_base, 'lib'); # I'm assuming the CPAN modules are somewhere local and already downlo +aded. chdir($modules_are) or die "Can't find CPAN modules"; my %tarballs = map { guess_package($_) => { tar => $_, # keep the original tarball name # extract the tarball to find out where the tarball is. dir => File::Spec->catdir($modules_are, extract_tarball($_)), } } grep { # remove your RCS directories/files... not /CVS/ and not /~$/ and # ... not is_module_installed($_) # maybe it's part of the core on this pl +atform already. } glob '*.tar*'; # loop through them, attempting to install each one. while (keys %tarballs) { my $count = scalar keys %tarballs; try_install($_) foreach keys %tarballs; # did we make progress? die "Can't meet any more pre-reqs" if $count == scalar keys %tarbal +ls; } exit 0; ### functions (not all are here - left as excersise for the reader) sub extract_tarball { my $tarball = shift; # figure out command based on extention... # e.g., /tar\.gz$/ => "gunzip -c $tarball | " # /tar\.Z$/ => "zcat $tarball | " # /tar$/ => "cat $tarball | " $cmd .= 'tar xf -'; open my $tar, "$cmd |" or die ...; while (<$tar>) { print; next if $subdir; $subdir = $1 if m{...}; # pull out the directory name being extrac +ted. } $subdir } sub try_install { my $module = shift; my $data = $tarballs{$module}; chdir $data->{dir}; if (-e 'Build.PL') { try_install_Build($data); } elsif (-e 'Makefile.PL') { try_install_Makefile($data); } else { die ... } delete $tarballs{$module} if $data->{installed}; }
In reply to Re: Module management and multiple architectures
by Tanktalus
in thread Module management and multiple architectures
by suaveant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |