This repository has been archived by the owner on Aug 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure
executable file
·225 lines (184 loc) · 5.54 KB
/
configure
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
225
#!/usr/bin/perl
##
## (c) 2012 travis kuhl (kuhl.co)
##
## This is free software. You may redistribute copies of it under the terms of
## the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
## There is NO WARRANTY, to the extent permitted by law.
# depend
my $depend = {
"LWP" => 0,
"Digest::SHA" => 0,
"Digest::MD5" => 0,
"ExtUtils::MakeMaker" => 0,
"JSON" => 0,
"HTTP::Request" => 0,
"Module::Pluggable" => 0,
"Net::OpenSSH" => 0,
"Term::ReadKey" => 0,
"Text::Wrap" => 0,
"Data::Dumper" => 0,
"Archive::Tar" => 0
};
# start
print "Starting...\n";
# get opts
use Getopt::Long;
# test the cpan mods
print "Testing for CPAN module…\n";
# test
eval("use CPAN");
# if no try to install
if ( $@ ) {
print "No CPAN module found. Try: perl -MCPAN -e 'install Bundle::CPAN'\n"; exit;
}
# cwd
my $pwd = `pwd`;
# cpan
_setup_cpan();
# we need them to be using the correct
# cpan version
if ( $CPAN::VERSION < 1.9402 ) {
print ('-'x50)."\n";
print "Your version of CPAN (".$CPAN::VERSION.") is out-of-date.\n";
print "In order to continue, we're going to try updating it for you.\n";
print "A bunch of shit is going to scroll across the screen. Don't\n";
print "be alarmed. It's very normal. Don't take it personally. Should there\n";
print "be any problems, try installing manually using this commands:\n\n";
print " perl -MCPAN -e 'install Bundle::CPAN'\n\n";
print "This process may take a few minutes.\n";
print ('-'x50)."\n\n";
# install cpan
CPAN::Shell->install("CPAN");
print "\n".('-'x50)."\n";
print "CPAN upgrade complete.\nPlease run ./configure again!\n\n\n";
exit();
}
# checking
print ('-'x50)."\n";
print "\nChecking for required CPAN Modules...\n";
# depend str
my @_depend = ();
# test the deps
foreach my $mod ( keys %{$depend} ) {
# test
eval("use $mod");
# if no try to install
if ( $@ ) {
CPAN::Shell->notest('install', $mod);
}
# add it
push(@_depend, "'$mod' => 0");
}
# done
print "CPAN check complete\n" . ('-'x50)."\n";
# move back
chdir($pwd);
# make file
print "Setting up make file...\n";
# string
my $dependstr = join(",", @_depend);
# create our makefile.PL
my $makefilepl = qq~
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => "by",
VERSION_FROM => "lib/drib.pm",
PREREQ_PM => {$dependstr},
PREREQ_FATAL => 1,
INSTALLDIRS => 'vendor',
PMLIBDIRS => [qw(lib)],
EXE_FILES => [qw(bin/drib)],
AUTHOR => 'Travis Kuhl <travis@kuhl.co>',
);
~;
# write the file
open(MF,">Makefile.PL") || die "Could not write makefile\n";
print MF $makefilepl;
close(MF);
# run it
print `perl Makefile.PL`;
# remove the file
`rm Makefile.PL`;
# and done
print "Configuration complete! Time to run `make`\n";
# The Initial Developer of the Original Code is Everything Solved.
# Portions created by Everything Solved are Copyright (C) 2006
# Everything Solved. All Rights Reserved.
sub _setup_cpan {
# cpan home
my $dir = $CPAN::Config->{cpan_home};
# need dir
if (!defined $dir || !-w $dir) {
$dir = "$ENV{HOME}/.cpan";
mkdir $dir;
}
# set
$CPAN::Config->{cpan_home} = $dir;
$CPAN::Config->{build_dir} = "$dir/build";
$CPAN::Config->{keep_source_where} = "$dir/source";
$CPAN::Config->{inhibit_startup_message} = 1;
$CPAN::Config->{prerequisites_policy} = 'follow';
$CPAN::Config->{histfile} = "$dir/histfile";
$CPAN::Config->{use_sqlite} = 0;
$CPAN::Config->{prefs_dir} = "$dir/prefs";
$CPAN::Config->{make_test} = "NO";
# default
my $default = {
auto_commit => 0,
build_cache => 0,
build_requires_install_policy => 'yes',
cache_metadata => 1,
colorize_output => 1,
colorize_print => 'bold',
index_expire => 1,
scan_cache => 'atstart',
inhibit_startup_message => 1,
bzip2 => bin_loc('bzip2'),
curl => bin_loc('curl'),
gzip => bin_loc('gzip'),
links => bin_loc('links'),
lynx => bin_loc('lynx'),
make => bin_loc('make'),
pager => bin_loc('less'),
tar => bin_loc('tar'),
unzip => bin_loc('unzip'),
wget => bin_loc('wget'),
urllist => [qw(
http://www.cpan.org/
http://cpan.pair.com/
http://mirror.hiwaay.net/CPAN/
ftp://ftp.dc.aleron.net/pub/CPAN/
http://mirrors.kernel.org/cpan/
http://mirrors2.kernel.org/cpan/)]
};
# loop
foreach my $key ( keys %{$default} ) {
$CPAN::Config->{$key} = $default->{$key};
}
my @missing;
# In newer CPANs, this is in HandleConfig. In older CPANs, it's in
# Config.
if (eval { require CPAN::HandleConfig }) {
@missing = CPAN::HandleConfig->missing_config_data;
}
else {
@missing = CPAN::Config->missing_config_data;
}
foreach my $key (@missing) {
$CPAN::Config->{$key} = '';
}
}
# locate bin files
sub bin_loc {
my ($bin) = @_;
open(my $saveerr, ">&STDERR");
open(STDERR, '>/dev/null');
my $loc = `which $bin`;
close(STDERR);
open(STDERR, ">&", $saveerr);
my $exit_code = $? >> 8; # See the perlvar manpage.
return '' if $exit_code > 0;
chomp($loc);
return $loc;
}