1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
#!/usr/bin/perl
#?
#? NAME
#? $0 - install perl moduls
#?
#? DESCRIPTION
#? Build and install Net::DNS, Net::SSLeay and IO::Socket::SSL in a
#? local private ./lib directory.
#? Using perl instead of sh in the hope that it will be mainly platform-
#? independent.
#?
#? In shell-speak it does:
#? tar xf Net-DNS-x.xx.tar.gz
#? (cd Net-DNS-x.xx && perl Makefile.PL && make && make install)
#? tar xf Net-SSLeay-x.xx.tar.gz
#? (cd Net-SSLeay-x.xx && perl Makefile.PL && make && make install)
#? tar xf IO-Socket-SSL-x.xx.tar.gz
#? (cd IO-Socket-SSL-x.xx && perl Makefile.PL && make && make install)
#?
#? OPTIONS
#? --n - do not execute, just show what would be done
#? --f - do not exit if specified installation directory exists
#? --l - list avaialble modules to be installed
#?
#? LIMITATIONS
#? Module tarballs must exist in local ./ directory.
#? Some perl modules may require make and/or cc to install properly.
#? Installation path is hardcoded to ./lib to change edit code below.
#? Unfortunatelly some installations require interactive input.
#?
#? AUTHOR
#? 17-feb-17 Achim Hoffmann
#?
# -----------------------------------------------------------------------------
use strict;
use warnings;
use Cwd;
my $VERSION = "@(#) install_perl_modules.pl 1.3 18/10/01 17:18:09";
my $pwd = cwd();
my $lib = "$pwd";
$lib = "$pwd/lib" if ($pwd !~ m#/lib/?#);
my $try = ""; # echo for --n
my $force = 0 ; # --f
local $\ = "\n";
my @modules = qw(Net-DNS*gz Net-SSLeay*gz IO-Socket-SSL*gz);
# http://search.cpan.org/~nlnetlabs/Net-DNS/
# http://search.cpan.org/CPAN/authors/id/N/NL/NLNETLABS/Net-DNS-1.08.tar.gz
# http://search.cpan.org/CPAN/authors/id/M/MI/MIKEM/Net-SSLeay-1.80.tar.gz
# http://search.cpan.org/CPAN/authors/id/S/SU/SULLR/IO-Socket-SSL-2.047.tar.gz
$try = "echo" if (grep {/^--?n$/} @ARGV);
$force = 1 if (grep {/^--?f$/} @ARGV);
if (grep {/^--?l$/} @ARGV) {
foreach my $module (@modules) {
my $targz = (sort glob($module))[-1];
if (defined $targz) {
print "# $try $targz -> $lib";
} else {
print "# $module\t: not found";
}
}
exit 0;
}
sub do_install {
my $try = shift;
my $tar = shift;
my $dst = shift;
my $targz = (sort glob($tar))[-1];
# ls Net-SSLeay*gz | sort | tail -1
chomp $targz;
my $dir = $targz;
$dir =~ s/\.tar.gz$//;
$dir =~ s/\.tgz$//; # in case it is .tgz instead of .tar.gz
my @args = (); push(@args, $try) if ($try ne "");
print "# build $targz ...";
do {
push(@args, "tar", "xf", $targz);
eval { system(@args) }; # TODO: error check
};
print "# cd $dir ...";
chdir($dir) or do {
warn "**WARNING: cannot cd to '$dir': $!";
$try = "echo"; # avoids errors in next do{}
};
@args = (); push(@args, $try) if ($try ne "");
do {
# env NO_NETWORK_TESTING=n perl Makefile.PL PREFIX=$lib
local $ENV{'NO_NETWORK_TESTING'} = "n";
# eval { require "Makefile.PL", "PREFIX=$lib"; }; # does not work
@args = ("perl", "Makefile.PL", "PREFIX=$lib");
eval { system(@args) };
@args = (); push(@args, $try) if ($try ne "");
push(@args, "make");
eval { system(@args) };
push(@args, "install");
eval { system(@args) };
};
print "# rm $dir ...";
@args = ("rm", "-rf", "$dir");
chdir("..") and eval { system(@args) };
return;
}; # do_install
if (-e $lib) {
if ($force < 1) {
die "**ERROR: '$lib' exists; please use --f to enforce using it; exit";
}
} else {
mkdir($lib);
}
foreach my $module (@modules) {
print "\n# $try $module -> $lib";
do_install($try, $module, $lib);
chdir($pwd); # not necessary
print <<'EoT';
# try testing with:
o-saft.pl +version
#
# if it complains that modules cannot be loaded i.e. IO/Socket/SSL.pm or
# Net/SSLeay.pm , then adding path to @INC in o-saft.pl may help, like:
unshift(@INC,
"./", "./lib",
"./lib/share/perl/5.20.2/",
"./lib/lib/x86_64-linux-gnu/perl/5.20.2/",
...
# done.
EoT
}
|