Files
Autobot/install
T

137 lines
3.2 KiB
Perl
Executable File

#!/usr/bin/env perl
# Auto IRC Bot. An advanced, lightweight and powerful IRC bot.
# Copyright (C) 2010-2011 Xelhua Development Team (doc/CREDITS)
# This program is free software; rights to this code are stated in doc/LICENSE.
package Install;
use strict;
use warnings;
use English qw(-no_match_vars);
use FindBin qw($Bin);
our $Bin = $Bin;
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";
if (defined $ARGV[0]) {
foreach (@ARGV) {
if ($_ eq "-h" or $_ eq "--help") {
println "*** ./install help ***";
println " --enable-sasl - Enable support for SASL.";
println " --enable-ipv6 - Enable support for IPv6.";
println " --disable-ssl - Disable support for SSL.";
println "*** End of Help ***";
exit;
}
elsif ($_ eq "--enable-sasl") {
$features .= " sasl";
}
elsif ($_ eq "--disable-ssl") {
$features =~ s/ ssl//g;
}
elsif ($_ eq "--enable-ipv6") {
$features .= " ipv6";
}
else {
println "Warning: Unknown option '".$_."'";
}
}
}
# 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) {
print "DOS is not supported.\r\n";
}
elsif ($OSNAME eq "MSWin32") {
print "Microsoft Windows is not supported. Support is planned for the future.\r\n";
}
elsif ($OSNAME eq "NetWare") {
print "NetWare is not supported.\r\n";
}
elsif ($OSNAME eq "linux") {
print "OK\n";
}
elsif ($OSNAME eq "os2") {
print "IBM OS/2 is not supported.\r\n";
}
elsif ($OSNAME =~ /mac/i or $OSNAME =~ /darwin/i) {
print "OK\r";
}
elsif ($OSNAME eq "freebsd") {
print "OK\n";
}
elsif ($OSNAME eq "openbsd") {
print "OK\n";
}
else {
print "Unknown operating system. Contact support.\r\n";
}
# 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 "All good.";
}
# Check for required CPAN modules.
println "\0";
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/;
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";
}
if (!-e "$Bin/build/time") {
system "touch $Bin/build/time";
}
if (!-e "$Bin/build/os") {
system "touch $Bin/build/os";
}
if (!-e "$Bin/build/perl") {
system "touch $Bin/build/perl";
}
if (!-e "$Bin/build/ver") {
system "touch $Bin/build/ver";
}
build($features);
# Success!
println "Done. Auto successfully installed.";