-
Notifications
You must be signed in to change notification settings - Fork 5
/
install
executable file
·224 lines (200 loc) · 5.94 KB
/
install
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#!/usr/bin/env perl
# install - Installation wizard.
# Copyright (C) 2010-2011 Xelhua Development Group, et al.
# This program is free software; rights to this code are stated in doc/LICENSE.
package Install;
use strict;
use warnings;
use Getopt::Long;
use English qw(-no_match_vars);
use FindBin qw($Bin);
use File::Copy;
use File::Path qw(make_path remove_tree);
our $Bin = $Bin;
BEGIN { unshift(@INC, "$Bin/lib") }
use Lib::Install;
# Installation script.
our $VERSION = 1.00;
our $ERROR = 0;
# Store the arguments passed to us.
my ($opt_help, $opt_syswide, $PREFIX, $feature_nossl, $feature_sasl, $feature_ipv6, $feature_mysql, $feature_pgsql);
GetOptions(
'--disable-ssl' => \$feature_nossl,
'--enable-sasl' => \$feature_sasl,
'--enable-ipv6' => \$feature_ipv6,
'--with-mysql' => \$feature_mysql,
'--with-pgsql' => \$feature_pgsql,
'--prefix=s' => \$PREFIX,
'--syswide' => \$opt_syswide,
'--help' => \$opt_help,
);
# If --help was passed.
if ($opt_help) {
print <<"HELP";
Auto IRC Bot Installation Wizard (v1.00).
Usage: perl install [options]
Options:
--disable-ssl Disables SSL support.
--enable-sasl Enables SASL support.
--enable-ipv6 Enables IPv6 support.
--with-mysql Uses MySQL instead of SQLite.
--with-pgsql Uses PostgreSQL instead of SQLite.
--syswide Prefixes bin/ files with auto- (excluding `auto` itself), as
well as installs build/ to lib/ instead. Always use this
when installing to /usr.
--prefix=PREFIX Installs files to PREFIX
[$Bin]
HELP
exit 1;
}
# Set features.
my $features = 'base';
$features .= ' ssl' unless $feature_nossl;
$features .= ' sasl' if $feature_sasl;
$features .= ' ipv6' if $feature_ipv6;
if ($feature_mysql) { $features .= ' mysql' }
elsif ($feature_pgsql) { $features .= ' pgsql' }
else { $features .= ' sqlite' }
# Where to install.
my $upref;
if (!$PREFIX) {
$PREFIX = $Bin;
$upref = 0;
}
else { $upref = 1 }
# Adjust installation to be more appropriate for system-wide installs.
my $libbuild = 0;
if ($opt_syswide) { $libbuild = 1 }
# 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";
exit;
}
elsif ($OSNAME eq "MSWin32") {
print "OK\r\n";
}
elsif ($OSNAME eq "NetWare") {
print "NetWare is not supported.\r\n";
exit;
}
elsif ($OSNAME eq "linux") {
print "OK\n";
}
elsif ($OSNAME eq "os2") {
print "IBM OS/2 is not supported.\r\n";
exit;
}
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";
}
elsif ($OSNAME eq "solaris") {
print "OK\n";
}
else {
print "Unknown operating system. Contact support.\r\n";
exit;
}
# 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 'Checking for required CPAN modules......';
println "\0";
#modfind("Mouse");
modfind('DBI');
modfind('DBD::SQLite') if $features =~ /sqlite/;
modfind('DBD::mysql') if $features =~ /mysql/;
modfind('DBD::Pg') if $features =~ /pgsql/;
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 $PREFIX) { make_path($PREFIX) }
my $libdir;
if ($libbuild) { $libdir = "$PREFIX/lib/autobot/3.0.0" }
else { $libdir = "$PREFIX/lib" }
my $builddir;
if ($libbuild) { $builddir = "$libdir/build" }
else { $builddir = "$PREFIX/build" }
if (!-d $builddir) { make_path($builddir) }
build($features, $builddir, $opt_syswide);
# Install.
if ($upref) {
require File::Copy::Recursive;
File::Copy::Recursive->import('rcopy');
my $langdir;
if ($libbuild) { $langdir = "$libdir/lang" }
else { $langdir = "$PREFIX/lang" }
my $moddir;
if ($libbuild) { $moddir = "$libdir/modules" }
else { $moddir = "$PREFIX/modules" }
my $distdir;
if ($libbuild) { $distdir = "$libdir/dist" }
else { $distdir = "$PREFIX/dist" }
println "Installing.....";
if (!-d "$PREFIX/bin") { make_path("$PREFIX/bin") }
if (!-d $libdir) { make_path($libdir) }
if (!-d $langdir) { make_path($langdir) }
if (!-d $moddir) { make_path($moddir) }
if (!-d $distdir) { make_path($distdir) }
my $bgenssl = 'genssl';
my $bbuildmod = 'buildmod';
my $bwizard = 'wizard';
if ($libbuild) {
$bgenssl = "auto-$bgenssl";
$bbuildmod = "auto-$bbuildmod";
$bwizard = "auto-$bwizard";
}
copy("$Bin/bin/auto", "$PREFIX/bin/auto");
copy("$Bin/bin/buildmod", "$PREFIX/bin/$bbuildmod");
copy("$Bin/bin/genssl", "$PREFIX/bin/$bgenssl");
copy("$Bin/bin/wizard", "$PREFIX/bin/$bwizard");
chmod 0755, "$PREFIX/bin/auto", "$PREFIX/bin/$bgenssl", "$PREFIX/bin/$bbuildmod", "$PREFIX/bin/$bwizard";
rcopy("$Bin/lib/*", "$libdir/");
rcopy("$Bin/lang/*", "$langdir/");
rcopy("$Bin/modules/*", "$moddir/");
copy("$Bin/etc/example.conf", "$distdir/");
remove_tree("$libdir/File");
}
println 'Done.';
println q{};
if ($libbuild) {
println 'To install modules, run the auto-buildmod utility on a module.';
}
else { installmods($PREFIX) }
println q{};
# Success!
println "Done. Auto successfully installed.";
# vim: set ai et sw=4 ts=4: