Debian Codegraph @

inc/Module/Install/Fetch.pm

raw symbols SCIP
1 #line 1
2 package Module::Install::Fetchscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/;
3
4 use strictscip-perl cpan Icon-FamFamFam-Silk 0.002001003 strict/;
5 use Module::Install::Basescip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Base/ ();
6
7 use varsscip-perl cpan Icon-FamFamFam-Silk 0.002001003 vars/ qw{$VERSION @ISA $ISCORE};
8 BEGIN {
9 $VERSIONscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/$VERSION. = '1.02';
10 @ISAscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/`@ISA`. = 'Module::Install::Base';
11 $ISCOREscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/$ISCORE. = 1;
12 }
13
14 sub get_filescip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/get_file(). {
15 my ($self, %args) = @_scip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/`@_`.;
16 my ($scheme, $host, $path, $file) =
17 $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return;
18
19 if ( $scheme eq 'http' and ! eval { requirescip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/require(). LWP::Simple; 1 } ) {
20 $args{url} = $args{ftp_url}
21 or (warnscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/warn().("LWP support unavailable!\n"), return);
22 ($scheme, $host, $path, $file) =
23 $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return;
24 }
25
26 $|scip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/`$|`.++;
27 printscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/print(). "Fetching '$file' from $host... ";
28
29 unless (eval { requirescip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/require(). Socket; Socket::inet_atonscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Socket/inet_aton().($host) }) {
30 warnscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/warn(). "'$host' resolve failed!\n";
31 return;
32 }
33
34 return unless $scheme eq 'ftp' or $scheme eq 'http';
35
36 requirescip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/require(). Cwd;
37 my $dir = Cwd::getcwdscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Cwd/getcwd().();
38 chdirscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/chdir(). $args{local_dir} or return if existsscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/exists(). $args{local_dir};
39
40 if (eval { requirescip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/require(). LWP::Simple; 1 }) {
41 LWP::Simple::mirrorscip-perl cpan Icon-FamFamFam-Silk 0.002001003 LWP/Simple/mirror().($args{url}, $file);
42 }
43 elsif (eval { requirescip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/require(). Net::FTP; 1 }) { eval {
44 # use Net::FTP to get past firewall
45 my $ftp = Net::FTP->newscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Net/FTP/new().($host, Passive => 1, Timeout => 600);
46 $ftp->loginscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Net/FTP/login().("anonymous", '[email protected]');
47 $ftp->cwdscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Net/FTP/cwd().($path);
48 $ftp->binaryscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Net/FTP/binary().;
49 $ftp->getscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Net/FTP/get().($file) or (warnscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/warn().("$!\n"), return);
50 $ftp->quitscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Net/FTP/quit().;
51 } }
52 elsif (my $ftp = $self->can_runscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/can_run().('ftp')) { eval {
53 # no Net::FTP, fallback to ftp.exe
54 requirescip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/require(). FileHandle;
55 my $fh = FileHandle->newscip-perl cpan Icon-FamFamFam-Silk 0.002001003 FileHandle/new().;
56
57 local $SIGscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/`%SIG`.{CHLD} = 'IGNORE';
58 unless ($fh->openscip-perl cpan Icon-FamFamFam-Silk 0.002001003 FileHandle/open().("|$ftp -n")) {
59 warnscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/warn(). "Couldn't open ftp: $!\n";
60 chdirscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/chdir(). $dir; return;
61 }
62
63 my @dialog = splitscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/split().(/\n/, <<"END_FTP");
64 open $host
65 user anonymous anonymous\@example.com
66 cd $path
67 binary
68 get $file $file
69 quit
70 END_FTP
71 foreach (@dialog) { $fh->printscip-perl cpan Icon-FamFamFam-Silk 0.002001003 FileHandle/print().("$_\n") }
72 $fh->closescip-perl cpan Icon-FamFamFam-Silk 0.002001003 FileHandle/close().;
73 } }
74 else {
75 warnscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/warn(). "No working 'ftp' program available!\n";
76 chdirscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/chdir(). $dir; return;
77 }
78
79 unless (-f $file) {
80 warnscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/warn(). "Fetching failed: $@\n";
81 chdirscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/chdir(). $dir; return;
82 }
83
84 return if existsscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/exists(). $args{size} and -s $file != $args{size};
85 systemscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/system().($args{run}) if existsscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/exists(). $args{run};
86 unlinkscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/unlink().($file) if $args{remove};
87
88 printscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/print().(((!existsscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/exists(). $args{check_for} or -e $args{check_for})
89 ? "done!" : "failed! ($!)"), "\n");
90 chdirscip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/chdir(). $dir; return !$?scip-perl cpan Icon-FamFamFam-Silk 0.002001003 Module/Install/Fetch/`$?`.;
91 }
92
93 1;