From 2b4e2bf960045e39c776aed179f41e51a5e17d2e Mon Sep 17 00:00:00 2001 From: Elijah Perrault Date: Thu, 10 Feb 2011 11:51:33 -0700 Subject: [PATCH] Cleaned up installation script. --- install | 57 ++++++++++++++++++++++++++++++---------------- lib/Lib/Install.pm | 19 +++++++++++++--- 2 files changed, 54 insertions(+), 22 deletions(-) diff --git a/install b/install index 396ffa7..66a3386 100755 --- a/install +++ b/install @@ -8,11 +8,12 @@ use warnings; use English qw(-no_match_vars); use FindBin qw($Bin); our $Bin = $Bin; -BEGIN { unshift(@INC, "$Bin/src"); } +BEGIN { unshift(@INC, "$Bin/lib"); } use Lib::Install; # Installation script. our $VERSION = 1.00; +our $ERROR = 0; # Iterate through the arguments passed to us. my $features = "base ssl"; @@ -41,6 +42,12 @@ if (defined $ARGV[0]) { } } +# Check Perl version. +println "Checking Perl version..... $^V"; +eval { + require 5.010_000; +} or println "This version of Perl is too old. Upgrade to Perl 5.10.0 or later and try again." and exit; + # Check operating system. print "Checking operating system..... $OSNAME - "; if ($OSNAME =~ /dos/i) { @@ -71,44 +78,56 @@ else { print "Unknown operating system. Contact support.\r\n"; } -# Check Perl version. -print "Checking Perl version..... $] - "; -if ($] >= 5.010000) { - println "OK"; +# Check for Perl core modules. +println "Checking for core Perl modules....."; +checkcore(); +println "\0"; +if ($ERROR) { + println "This Perl install is missing some core modules. Consider reinstalling Perl."; + exit; } else { - println "Incompatible"; - exit; + println "All good."; } # Check for required CPAN modules. println "\0"; -println "--- CPAN Modules ---"; +println '*** CPAN Modules ***'; +println "\0"; #modfind("Mouse"); -modfind("DBI"); -modfind("DBD::SQLite"); -modfind("Class::Unload"); -modfind("IO::Socket::INET6") if $features =~ /ipv6/; -modfind("IO::Socket::SSL") if $features =~ /ssl/; -modfind("MIME::Base64") if $features =~ /sasl/; +modfind('DBI'); +modfind('DBD::SQLite'); +modfind('Class::Unload'); +modfind('IO::Socket::INET6') if $features =~ /ipv6/; +modfind('IO::Socket::SSL') if $features =~ /ssl/; +modfind('MIME::Base64') if $features =~ /sasl/; +println "\0"; + +if ($ERROR) { + println "Failed to install. Please install the missing CPAN modules and try again."; + exit; +} +else { + println "All good."; +} # Create build. println "\0"; println "Building....."; if (!-d "$Bin/build") { - system("mkdir $Bin/build"); + system "mkdir $Bin/build"; } if (!-e "$Bin/build/time") { - system("touch $Bin/build/time"); + system "touch $Bin/build/time"; } if (!-e "$Bin/build/os") { - system("touch $Bin/build/os"); + system "touch $Bin/build/os"; } if (!-e "$Bin/build/perl") { - system("touch $Bin/build/perl"); + system "touch $Bin/build/perl"; } if (!-e "$Bin/build/ver") { - system("touch $Bin/build/ver"); + system "touch $Bin/build/ver"; } build($features); diff --git a/lib/Lib/Install.pm b/lib/Lib/Install.pm index 257c9f8..0ac98b9 100644 --- a/lib/Lib/Install.pm +++ b/lib/Lib/Install.pm @@ -11,7 +11,7 @@ our $Bin = $Bin; our $VERSION = 1.00; our @ISA = qw(Exporter); -our @EXPORT = qw(println modfind build checkver); +our @EXPORT = qw(println modfind build checkver checkcore); sub println { @@ -31,8 +31,8 @@ sub modfind { my ($mod) = @_; - print "Checking for $mod..... "; - eval('require '.$mod.'; 1;') and println "OK" or println "Not Found" and exit; + print " $mod: "; + eval('require '.$mod.'; 1;') and println "Found" or println "Not Found" and $Install::ERROR = 1; return 1; } @@ -99,3 +99,16 @@ sub checkver return 1; } + +sub checkcore +{ + println "Checking for Perl core modules....."; + println "\0"; + modfind('Carp'); + modfind('FindBin'); + modfind('feature'); + modfind('IO::Socket'); + modfind('Sys::Hostname'); + modfind('POSIX'); + modfind('Time::Local'); +}