Net-FullAuto
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
$amazon{instance_type}=$instance_type;
}
if ($amazon{instance_type}=~/nano/ &&
exists $ENV{PERL5_CPAN_IS_RUNNING_IN_RECURSION}) {
my $message=<<'END';
_ _ _
__ _ __ __ _ _ _ _ _ ___| |_ ____ _ _ __ _ __ ___ _ _| |_ ___ __| |
/ _| '_ \/ _` | ' \ | ' \/ _ \ _| (_-< || | '_ \ '_ \/ _ \ '_| _/ -_) _` |
\__| .__/\__,_|_||_| |_||_\___/\__| /__/\_,_| .__/ .__/\___/_| \__\___\__,_|
|_| |_| |_|
END
$message.=<<END;
You are attempting to install Net::FullAuto on an Amazon AWS EC2
$amazon{instance_type} instance. The cpan utility requires more
memory to function successfully than this instance provides. To
install Net::FullAuto, use the "Complete" installer that bundles
all dependencies. This installer has much lower resource demands
than the cpan commandline utility. Download the installer bundle
here:
https://sourceforge.net/projects/fullauto/files/Net-FullAuto-Complete-$VERSION.tar.gz
END
print $message;
exit 1;
} elsif ($amazon{instance_type}=~/nano|micro/ and
$ENV{USER} ne 'root') {
my $message=<<'END';
__ __ _ _ _
| \/ |_ _ __| |_ | |__ ___ _ _ ___ ___| |_
| |\/| | || (_-< _| | '_ \/ -_) | '_/ _ \/ _ \ _|
|_| |_|\_,_/__/\__| |_.__/\___| |_| \___/\___/\__|
END
$message.=<<END;
Because of the severe memory and resource limitations of an AWS
$amazon{instance_type} instance, the Net::FullAuto installer will
only work seamlessly when started with sudo or the root user.
(If you want to avoid using root, you need to use a small or
larger AWS EC2 instance.) Micro and Nano sized instances require
the root user or sudo. To use sudo restart this installer with
this command:
sudo perl Makefile.PL
END
print $message;
die "User $ENV{USER} is not supported, log in as root or use sudo";
}
sub check_for_cpan {
my $check=`perl -MCPAN -e 1 2>&1`;
if (-1<index $check,"Can't locate CPAN") {
if ($aws) {
system('sudo dnf -y install cpan perl-HTTP-Date.noarch');
my $cmd='mkdir -pv '.(getpwuid $>)[7].'/.cpan/build';
`$cmd` || die "Cannot $cmd $!";
$ENV{PERL_MM_USE_DEFAULT}=1;
} else {
my $die="Can't locate CPAN.pm in \@INC ".
"(you may need to install the CPAN module)\n$!";
die $die;
}
} elsif (-e 'MANIFEST.SKIP') {
eval {
local $SIG{__DIE__}; # No sigdie handler
require CPAN;
CPAN::Shell->reload('index');
};
} return 1;
}
};
unless (grep { /SKIP|CPAN|figlet/ } @ARGV) {
use if (check_for_cpan()),'CPAN';
eval {
local $SIG{__DIE__}; # No sigdie handler
require CPAN;
CPAN::HandleConfig->load;
};
my $d = $CPAN::Config->{build_dir};
if (!(defined $d) || !(-d $d)) {
$d=(getpwuid $>)[7].'/.cpan/build';
my $cmd='mkdir -pv '.(getpwuid $>)[7].'/.cpan/build';
`$cmd` || die "Cannot $cmd $!";
unless (-d $d) {
unless (-d "/root/.cpan/build") {
die("ERROR - Can't locate .cpan/build directory");
} else {
$d='/root/.cpan/build';
}
}
}
$ENV{CPAN_BUILD_DIR}=$d;
$ENV{CPAN_GZIP}=$CPAN::Config->{gzip} if defined $CPAN::Config->{gzip}
&& $CPAN::Config->{gzip};
$ENV{CPAN_TAR}=$CPAN::Config->{tar} if defined $CPAN::Config->{tar}
&& $CPAN::Config->{tar};
$ENV{CPAN_WGET}=$CPAN::Config->{wget} if defined $CPAN::Config->{wget}
&& $CPAN::Config->{tar};
if ($ENV{PERL_LOCAL_LIB_ROOT} || ($ENV{LOGNAME} ne 'root' &&
(-f "$ENV{HOME}/perl5"))) {
$ENV{CPAN_LOCAL_LIB}="$ENV{HOME}/perl5";
}
if ($instance_type=~/nano/) {
`sudo su -c 'echo 3 > /proc/sys/vm/drop_caches'`
}
}
};
use Config;
use if (check_for_cpan()),'CPAN';
unshift @ExtUtils::MakeMaker::Overridable, 'pm_to_blib'; # this enables
# pm_to_blib to be overwritten in Makefile rather than ignored
*{MyClass::_using_sudo} = sub { return 1 }; # Override default local::lib.
# Net::FullAuto does not currently
# NOTE: local::lib is now # default to local::lib when CPAN
# supported but the install # is discovered to be unconfigured.
# does not default to local::lib # "sudo" is auto-configured instead
# local::lib.
$ENV{'CYGWIN'}='nodosfilewarning' if $^O eq 'cygwin';
use lib '.';
use subs qw/version name sign author license perl_version/;
use inc::Module::Install;
use if (($^O eq 'cygwin' && eval {
local $SIG{__DIE__};require 'Win32::RunAsAdmin' })
|| $^O eq 'MSWin32' || $^O eq 'MSWin64'),
'Win32::RunAsAdmin'; # Used to check Admin Priviliges on MS Windows
if ((($^O eq 'cygwin' && eval {
local $SIG{__DIE__};require 'Win32::RunAsAdmin' })
|| $^O eq 'MSWin32' || $^O eq 'MSWin64') &&
not Win32::RunAsAdmin::check()) {
my $name=substr($0,(rindex $0,'\\')+1);
$name=$ENV{SESSIONNAME} unless exists $ENV{PAR_TEMP};
my $message=<<END;
FATAL ERROR! - Windows Administrator privileges are needed in
order to install FullAuto or OpenSSH.
If you have Administrator Rights, be sure to Right Click on the
Makefile.PL view on Meta::CPAN
eval {
local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required
alarm $timeout;
my $menu1 = [
$message,
[ "Yes", sub{ return 'Yes' } ],
[ $fae, sub{ return 'No' } ],
];
$selection=&menu($menu1);
exit 0 if $selection eq ']quit[';
alarm 0;
};
}
if ($selection eq 'Yes') {
my $cmd='curl "https://awscli.amazonaws.com/'.
'awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"';
fa_system($cmd);
fa_system('unzip awscliv2.zip;sudo ./aws/install');
} print "\n\n FullAuto install continues . . .\n\n";
}
if (grep { /-*(?:add|all)[-_]?dependencies/i } @ARGV) {
my $f=$fs;
$f=~s/^.*\/(.*)$/$1/;
unless (-e "dependencies/FIGlet_fonts/$f") {
fa_system("(mkdir -vp dependencies/FIGlet_fonts;cd dependencies/FIGlet_fonts;wget $fs)");
}
}
my $cpantest=0;
$cpantest=1 unless $mycpantest;
use if ($mycpantest), "CPAN::MyConfig";
use if ($cpantest), "CPAN::Config";
sub fa_err_exit {
fa_die("$_[0]\n\n*** Please manually install $_[1]".
" from cpan.org first...\n");
}
sub fa_find_latest {
my $temp=0;
my $look=$_[0]||'';
my $cpanfil=$_[1]||'';
my @caller=caller;
my $caller=join " ",@caller;
unless ($look) {
fa_die("ERROR - No argument provided to &fa_find_latest(). Caller: $caller<==\n");
}
$look=~s/::/-/g;
print "***** Looking for Most Recent \"$look Dir\" \n";
my $d=$ENV{CPAN_BUILD_DIR}||'';
unless ($d) {
eval {
local $SIG{__DIE__}; # No sigdie handler
require CPAN;
CPAN::HandleConfig->load;
};
$d = $CPAN::Config->{build_dir};
if (!(defined $d) || !(-d $d)) {
$d=(getpwuid $>)[7].'/.cpan/build';
unless (-d $d) {
unless (-d "/root/.cpan/build") {
fa_die("ERROR - Can't locate .cpan/build directory");
} else {
$d='/root/.cpan/build';
}
}
}
$ENV{CPAN_BUILD_DIR}=$d;
}
if ($cpanfil) {
my $cwd=&cwd;
fa_system("cd $ENV{CPAN_BUILD_DIR};tar xvf ".
"$cwd/dependencies/CPAN/authors/id/$cpanfil;cd $cwd");
$look=$cpanfil;
$look=~s/.tar.gz//;
$look=~s/^.*\/(.*)$/$1/;
}
my $new='';my $file='';
opendir(DH,$d) or
fa_die("ERROR - Can't read Directory $d: $!\n");
my %timestamps=();
while ($_ = readdir(DH)) {
next if ($_ eq ".") || ($_ eq "..") || (/\.yml$/);
if (-e "dependencies/CPAN/authors" && !(-e "MANIFEST.SKIP") &&
!(grep {
/(?:use[-_]?)?internet|online|connect_to_internet_ok/i
} @ARGV)) {
next if $_ ne $look;
} elsif ($_!~/^$look[-][vV]?\d/) {
if (-d $d.'/'.$_) {
my $dr=$d.'/'.$_;
$new=&look_inside_dir($dr,$look);
} next
}
$file=sprintf("%s/%s",$CPAN::Config->{build_dir},$_,'Makefile.PL');
$file=sprintf("%s/%s",$CPAN::Config->{build_dir},$_,'Build.PL')
unless (-e $file);
my $attrs = stat $file;
$timestamps{$attrs}=$_;
}
close(DH);
my $newest=(sort keys %timestamps)[0];
$new=$CPAN::Config->{build_dir}.'/'.$timestamps{$newest};
close(DH);
$new=$file if !$new && $file;
print "***** Module Directory ",$new,"\n";
return $new;
}
sub look_inside_dir {
my $d=$_[0];
my $look=$_[1];
my $found='';
opendir(LI,$d) or
fa_die("ERROR - Can't read Directory $d: $!\n");
my $tar='';
while ($_ = readdir(LI)) {
next if ($_ eq ".") || ($_ eq "..");
Makefile.PL view on Meta::CPAN
my $cpan_error='';
eval {
local $SIG{__DIE__}; # No sigdie handler
local $SIG{TERM};
require CPAN::Mini;
import CPAN::Mini;
};
if (!$@ && grep { /-*(?:add|all)[-_]?dependencies/i } @ARGV) {
my $distribution = CPAN::Shell->expand(
"Module",'BerkeleyDB'
)->distribution()->pretty_id();
my $let=unpack('a1',$distribution);
my $lett=unpack('a2',$distribution);
my $minicpan=CPAN::Mini->new(
remote => "http://www.cpan.org",
local => cwd()."/dependencies/CPAN",
log_level => 'debug',
exact_mirror => 1,
);
$minicpan->mirror_file(
"authors/id/$let/$lett/$distribution");
}
if ($get_BerkeleyDB && $^O ne 'cygwin') {
# Let's find if Berkeley DB is already on the system
my $findpath='';
if (-e "/bin/find") {
$findpath="/bin/";
} elsif (-e "/usr/bin/find") {
$findpath="/usr/bin/";
} elsif (-e "/usr/local/bin/find") {
$findpath="/usr/local/bin/";
}
my $xargspath='';
if (-e "/bin/xargs") {
$xargspath="/bin/";
} elsif (-e "/usr/bin/xargs") {
$xargspath="/usr/bin/";
} elsif (-e "/usr/local/bin/xargs") {
$xargspath="/usr/local/bin/";
}
if ($findpath && $xargspath && $greppath) {
my @output=();
my $testgrep =`${greppath}grep -H 2>&1`;
my $testgrep2=`${greppath}grep 2>&1`;
my $grepopt='';
if ((-1==index $testgrep,'illegal option')
&& (-1==index $testgrep2,'-insvxbhwyu')) {
$grepopt='-H ';
}
my $testfind =`find -help 2>&1`;
my $maxdepth=(-1<index $testfind,'[-P]')?
" -maxdepth 4":'';
my $find_cmd1="${findpath}find ";
my $find_cmd2="$maxdepth -name \'*.h\' ".
"| ${xargspath}xargs ${greppath}grep ".
"${grepopt}DB_VERSION_STRING";
print "\nSearching for latest verison of Berkeley DB.\n".
"This may take up to five minutes ...\n\n";
FE: foreach my $dir ('/usr/','/opt/',(getpwuid $>)[7].'/') {
next if unpack('a1',$dir) eq '.';
next unless -d $dir;
opendir(DIR, $dir) or fa_die($!);
while (my $file = readdir(DIR) ) {
next if ($file eq "." or $file eq ".." or $file eq "doc" or
$file eq "X11R6" or $file eq "docs" or
$file eq "man" or $file eq "ssl" or
$file eq "license" or $file eq "logfile" or
$file eq "bin" or ($^O eq 'cygwin' &&
($file eq "Application Data" or
$file eq "Favorites" or $file eq
"Local Settings" or $file eq "Recent" or
$file eq "Start Menu" or $file eq "SendTo" or
$file eq "NetHood" or $file eq "PrintHood")));
if (-d $dir.$file) {
print "Searching $dir$file ...\n";
my @subout=`$find_cmd1\"$dir$file\"$find_cmd2`;
push @output, @subout;
}
last FE if $dir.$file eq "/usr/local";
}
}
my @vers=();my %verhash=();
if (-1<$#output) {
foreach my $version (@output) {
next if (-1<index $version, $CPAN::Config->{cpan_home}) ||
(-1<index $version, 'Net-FullAuto-') ||
$version!~/db.h:.*DB_VERSION_STRING/;
my @fileparts=split 'db.h:', $version;
$fileparts[1]=~s/^.*DB (\d+[^:]+):.*\s*$/$1/s;
$verhash{$fileparts[1]}=$fileparts[0];
}
}
my $header_to_use='';my $ver='';
foreach my $vr (reverse sort keys %verhash) {
$header_to_use=$verhash{$vr};
$vr=~/^((^\d+[.]\d+)[.]?\d*).*$/;
$vr=$1;$ver=$2;
chomp($vr);chomp($ver);
my $find_cmd="${findpath}find /usr -name \"libdb-".$ver.".a\"";
my @lib=`$find_cmd`;
chomp($lib[0]);$berkeleydb=$lib[0];last;
}
my $major_minor_ver=substr($ver,0,(rindex $ver,'.'));
$major_minor_ver=$ver if -1==index $major_minor_ver,'.';
if ($^O eq 'cygwin' && !(grep { /build_berkeleydb/i } @ARGV)) {
if ($berkeleydb && $major_minor_ver>=4.5) {
$berkeleydb=~s/^(.*)\/.*$/$1/;
$ENV{'BERKELEYDB_INCLUDE'}=$header_to_use;
$ENV{'BERKELEYDB_LIB'}=$berkeleydb;
$ENV{'BERKELEYDB_NAME'}="-ldb-$ver";
$ENV{'DB_FILE_INCLUDE'}=$header_to_use;
$ENV{'DB_FILE_LIB'}=$berkeleydb;
$ENV{'DB_FILE_NAME'}="-ldb-$ver";
$ENV{'LD_LIBRARY_PATH'}=$berkeleydb;
$ENV{'LD_RUN_PATH'}=$ENV{'LD_LIBRARY_PATH'};
} else {
my $uname=`/bin/uname`;
my $uname_all=`/bin/uname -a`;
$uname_all.=$uname;
Makefile.PL view on Meta::CPAN
Name => 'license_agree',
Item_1 => {
Text => "I agree to the license provisions\n\n",
},
Item_2 => {
Text => "Review GNU Affero Public License WARRANTY DISCLAIMER\n",
Result => \%read_license,
},
Item_3 => {
Text => "*IMPORTANT* STRONG CRYPTOGRAPHY WARNING!",
Result => $cryptography,
},
Item_4 => {
Text => "I DO NOT AGREE to the license provisions\n".
" ( FullAuto Install will EXIT )",
},
Scroll => 1,
Banner => $license_banner,
);
my $lic_sel='';
if (!(exists $ENV{PERL5_CPAN_IS_RUNNING}
&& $ENV{PERL5_CPAN_IS_RUNNING}) ||
exists $ENV{PAR_TEMP}) {
$lic_sel=Menu(\%license_agree);
chomp($lic_sel);
exit if $lic_sel eq ']quit[';
if (-1<index $lic_sel, 'NOT') {
my $exitmsg=<<END;
You have elected *NOT* to install FullAuto.
Please report any bugs and send any
questions, thoughts or feedback to:
Brian.Kelly\@FullAuto.com.
END
print $exitmsg;
if (exists $ENV{PAR_TEMP}) {
print " Press ANY key to exit.\n\n";<STDIN>;
}
exit;
}
}
}
WriteAll();
if (keys %amazon) {
#fa_system('sudo make install');
fa_system('make install');
if (exists $amazon{argv}) {
my $p=$amazon{argv}->[0];
my $username=getlogin || getpwuid($<);
select STDOUT;
$log->close() if $log && -1<index $log,'*';
exec "/usr/local/bin/fa",'-i',$p,
'--iset-amazon','--login',
$username,'--log';
}
}
sub fa_find_editor {
my $editor=$_[0];
$editor=~s/^.*\///;
$editor=~s/[.]exe$//;
return 0 unless $editor;
foreach my $path (split ':', $ENV{PATH}) {
$path=~s/[\/]*$/\//;
if ($^O eq 'cygwin' && (-e $path.$editor.'.exe')) {
return $path.$editor.'.exe';
} elsif (-e $path.$editor) {
return $path.$editor;
}
} return 0;
}
sub cpan_modules {
my $p=$_[0];
my $mod_info='';
my $version='';
@CPAN::Defaultsites = map {
CPAN::URL->new(TEXT => $_, FROM => "DEF")
} "http://www.cpan.org/CPAN/", "ftp://ftp.cpan.org/pub/CPAN/";
eval {
local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required
alarm 10;
local $SIG{__DIE__}=sub{ print "GOD DAMN IT=$@" }; # No sigdie handler;
local *STDOUT;
open(STDOUT, ">", \$mod_info) || die "CANNOT OPEN STDOUT $!\n";
CPAN::Shell->m($p);
close(STDOUT);
alarm 0;
};
print "CPAN::Shell BLOCK ERROR=$@\n" if $@;
my $instfile='';
($instfile=$mod_info)=~s/^.*INST_FILE\s+[(]([^)]+).*$/$1/s;
my $instver='';
($instver=$mod_info)=~s/^.*INST_VERSION\s+([^\s]+).*$/$1/s;
$instver=0 unless (-1<index $mod_info,'INST_VERSION');
my $cpanfil='';
($cpanfil=$mod_info)=~s/^.*CPAN_FILE\s+([^\s]+).*$/$1/s;
my $cpanver='';
($cpanver=$mod_info)=~s/^.*CPAN_VERSION\s+([^\s]+).*$/$1/s;
chomp($mod_info);chomp($mod_info);
$mod_info=~s/^Reading.*?$//m;
$mod_info=~s/^\s+Database.*?$//m;
$mod_info=~s/^\s*//s;
if ($ENV{CPAN_OUTDATED_MODULES} eq 'update') {
print $mod_info;
unlink $instfile;
$version=$cpanver;
return $version,$cpanfil,$instfile,$mod_info;
( run in 0.924 second using v1.01-cache-2.11-cpan-39bf76dae61 )