use strict; use ExtUtils::MakeMaker; use LWP::Simple qw(getstore $ua is_success); if ($ENV{HTTP_proxy_user} and $ENV{HTTP_proxy_pass} and $ENV{HTTP_proxy} =~ /^http:\/\/([^@]+)$/) { my $proxy ="http://$ENV{HTTP_proxy_user}:$ENV{HTTP_proxy_pass}\@" . $1; print "setting user/pass into proxy_env...\n"; $ua->proxy(['http'], $proxy); } my $lib1 = 'ssleay32.dll'; my $lib2 = 'libeay32.dll'; my $version = '0.9.7'; my $default = '/Perl/bin'; my $guess = 'openssl/bin'; my $recommended = 'yes'; my $lib; foreach ($lib1, $lib2) { $lib = $_; if (my $hit = is_in_path($lib)) { print <<"END"; A copy of the needed library $lib was found in your PATH environment variable, under $hit. If this is compatible with the version ($version) used to compile the Perl module, no further action is needed to complete the installation. END $recommended = 'no'; } if ($recommended eq 'yes' and my $hit = guess($lib, $guess)) { print <<"END"; A copy of the needed library $lib was found in $hit. If this is compatible with the version ($version) used to compile the Perl module, all that is needed to complete the installation is to add $hit to your PATH environment variable. END $recommended = 'no'; } if ($recommended eq 'yes') { print <<"END"; The library $lib is needed to complete the installation, and should be placed in a directory somewhere in your PATH environment variable. I can fetch and install this for you, if you don\'t already have it. END } my $proceed = prompt("Fetch $lib?", $recommended); suggest_manual("Aborting download of $lib.", 'warn') unless ($proceed =~ /^y/i); my $remote = 'http://theoryx5.uwinnipeg.ca/ppms/scripts/' . $lib; print "Fetching $remote ... "; getstore($remote, $lib); print " done!\n"; suggest_manual("Cannot find $lib", 'fatal') unless -f $lib; my $base = prompt("Where should $lib be placed?", $default); $base =~ s/$lib$//i; $base =~ s!\\!/!g; $base =~ s!/$!!; unless (-d $base) { my $ans = prompt("$base does not exist. Create it?", 'no'); if ($ans =~ /^y/i) { mkdir $base; suggest_manual("Could not create $base: $!", 'fatal') unless (-d $base); } else { suggest_manual("Will not create $base.", 'fatal'); } } if (-f "$base/$lib") { my $ans = prompt("$base/$lib exists. Overwrite?", 'no'); if ($ans =~ /^n/i) { suggest_manual("Will not overwrite $base/$lib.", 'fatal'); } } use File::Copy; move($lib, "$base/$lib"); suggest_manual("Moving $lib to $base failed: $!", 'fatal') unless (-f "$base/$lib"); print "$lib has been successfully installed to $base\n"; } sleep(5); sub suggest_manual { my ($msg, $type) = @_; print $msg, "\n"; print "Installation of $lib not completed.\n" if ($type eq 'fatal'); sleep (5); exit(0); } sub is_in_path { my $lib = shift; my $hit; foreach (split ';', $ENV{PATH}) { if (-f "$_/$lib") { $hit = $_; last; } } return $hit; } sub guess { my ($lib, $guess) = @_; my $hit; foreach my $drive('C' .. 'Z') { if (-f "$drive:/$guess/$lib") { $hit = "$drive:/$guess/"; last; } } return $hit; }