require
5.005;
my
@programs_to_install
=
qw(lwp-request lwp-mirror lwp-rget lwp-download)
;
my
@request_aliases
=
qw(GET HEAD POST)
;
unless
(getopts(
"n"
)) {
die
"Usage: $0 [-n]\n"
;
}
@programs_to_install
= ()
if
$opt_n
||
grep
/^LIB=/,
@ARGV
;
open
(CHANGES,
"Changes"
) ||
die
"Can't open Changes: $!"
;
my
$release_date
;
while
(<CHANGES>) {
if
(/^(\d{4}-\d{2}-\d{2})\D/) {
$release_date
= $1;
last
;
}
}
close
(CHANGES);
die
"Can't figure out release date"
unless
$release_date
;
my
$some_time_ago
=
sprintf
"%04d-%02d-%02d"
,
sub
{ (
$_
[5]+1900,
$_
[4]+1,
$_
[3])}->(
localtime
(
time
- 45 * 24*60*60));
if
(
$some_time_ago
lt
$release_date
) {
my
$s
= IO::Socket::INET->new(
PeerAddr
=>
"www.google.com:80"
,
Timeout
=> 10,
);
if
(
$s
) {
close
(
$s
);
print
<<EOT;
You appear to be directly connected to the Internet. I have some tests
that tries to access some sites on the net to verify that the new HTTP/1.1
support works as it should.
EOT
if
(prompt(
"Do you want to enable these tests?"
,
"y"
) =~ /^y/i) {
open
(ENABLED,
">t/live/ENABLED"
) ||
die
"Can't enable: $!"
;
close
(ENABLED);
eval
{
Compress::Zlib->VERSION(1.10);
open
(ZLIB_OK,
">t/live/ZLIB_OK"
) ||
die
"Can't create ZLIB_OK: $!"
;
print
ZLIB_OK
"$Compress::Zlib::VERSION\n"
;
close
(ZLIB_OK);
};
if
($@) {
unlink
(
"t/live/ZLIB_OK"
);
}
}
else
{
unlink
(
"t/live/ENABLED"
);
}
}
}
if
(
@programs_to_install
) {
print
<<EOT;
This package comes with some sample programs that I can try
to install in $Config{sitebin}.
Note that you can avoid these questions by passing
the '-n' option to 'Makefile.PL'.
EOT
my
@tmp
;
for
(
@programs_to_install
) {
if
(prompt(
"Do you want to install $_?"
,
"y"
) =~ /^y/) {
push
(
@tmp
,
$_
);
}
}
@programs_to_install
=
@tmp
;
if
(
grep
(
$_
eq
'lwp-request'
,
@programs_to_install
) &&
@request_aliases
) {
print
<<EOT;
The lwp-request program will use the name it is invoked with to
determine what HTTP method to use. I can set up alias for the most
common HTTP methods. These alias are also installed in
$Config{sitebin}.
EOT
@tmp
= ();
for
my
$alias
(
@request_aliases
) {
my
$default
=
"y"
;
if
(
open
(PROG,
"<$Config{sitebin}/$alias"
)) {
$default
=
"n"
;
while
(<PROG>) {
if
(/lwp-request/) {
$default
=
"y"
;
last
;
}
}
close
(PROG);
}
if
(prompt(
"Do you want to install the $alias alias?"
,
$default
) =~ /^y/) {
push
(
@tmp
,
$alias
);
}
}
@request_aliases
=
@tmp
;
}
}
$| = 1;
my
$missing_modules
= 0;
print
"\nChecking for URI..........."
;
eval
{
URI->VERSION(1.10);
};
if
($@) {
print
" failed\n"
;
$missing_modules
++;
print
<<EOT;
$@
The URI module must be installed. WWW without URIs would not
be that great :-)
EOT
sleep
(2);
}
else
{
print
" ok\n"
;
}
print
"Checking for HTML::Parser.."
;
eval
{
HTML::Parser->VERSION(2.20);
};
if
($@) {
print
" failed\n"
;
$missing_modules
++;
print
<<EOT;
$@
The HTML::Parser is needed to extract correct base URI information from
HTML so that we can resolve relative links correctly. The HTML::Form
module also need HTML::TokeParser to work.
EOT
sleep
(2);
}
else
{
print
" ok\n"
;
}
print
"Checking for MIME::Base64.."
;
eval
{
};
if
($@) {
print
" failed\n"
;
$missing_modules
++;
print
<<EOT;
$@
The Base64 encoding is used in authentication headers in HTTP.
EOT
sleep
(2);
}
else
{
print
" ok\n"
;
}
print
"Checking for Net::FTP......"
;
eval
{
Net::FTP->VERSION(
'2.58'
);
};
if
($@) {
print
" failed\n"
;
$missing_modules
++;
print
<<EOT;
$@
The libwww-perl library normally use the Net::FTP module when
accessing ftp servers. You would have to install this package or
configure your application to use a proxy server for making ftp
requests work. Net::FTP is part of the 'libnet' distribution.
EOT
sleep
(2);
}
else
{
print
" ok\n"
;
}
print
"Checking for Digest::MD5 .."
;
eval
{
};
if
($@) {
print
" failed\n"
;
$missing_modules
++;
print
<<EOT;
$@
The Digest::MD5 library is needed if you want to be able use the
experimental "Digest Access Authentication" scheme. Since very few
servers implement this authentication scheme, you should normally not
worry too much about this.
EOT
}
else
{
print
" ok\n"
;
}
print
<<EOT if $missing_modules;
The missing modules can be obtained from CPAN. Visit
EOT
print
"\n"
;
if
(
@request_aliases
) {
for
(
@request_aliases
) {
File::Copy::copy(
"bin/lwp-request"
,
"bin/$_"
) ||
die
"Can't copy bin/$_"
;
chmod
(0755,
"bin/$_"
);
push
(
@programs_to_install
,
$_
);
}
}
WriteMakefile(
NAME
=>
'libwww-perl'
,
VERSION_FROM
=>
'lib/LWP.pm'
,
EXE_FILES
=> [
map
"bin/$_"
,
@programs_to_install
],
PREREQ_PM
=> {
'URI'
=>
"1.10"
,
'MIME::Base64'
=>
"2.1"
,
'Net::FTP'
=>
"2.58"
,
'HTML::HeadParser'
=> 0,
'Digest::MD5'
=> 0,
},
'clean'
=> {
FILES
=>
join
(
" "
,
map
"bin/$_"
,
@request_aliases
) },
'dist'
=> {
COMPRESS
=>
'gzip -9f'
,
SUFFIX
=>
'gz'
, },
);
sub
test
{
q(
TEST_VERBOSE=0
test: all
$(FULLPERL)
t/TEST $(TEST_VERBOSE)
);
}
sub
libscan
{
my
(
$self
,
$path
) =
@_
;
return
''
if
$path
=~ m/.(pl|dtd|sgml)$/;
return
''
if
$path
=~ m:\bCVS/:;
return
''
if
$path
=~ m/~$/;
$path
;
}
sub
manifypods
{
my
$self
=
shift
;
my
$ver
=
$self
->{VERSION} ||
""
;
local
(
$_
) =
$self
->SUPER::manifypods(
@_
);
s/pod2man\s*$/pod2man --release libwww-perl-
$ver
/m;
$_
;
}