3 # Copyright © 1996 Andy Guy <andy@cyteen.org>
4 # Copyright © 1998 Martin Schulze <joey@infodrom.north.de>
5 # Copyright © 1999, 2009 Raphaël Hertzog <hertzog@debian.org>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <https://www.gnu.org/licenses/>.
24 use Dpkg; # Dummy import to require the presence of Dpkg::*.
27 warn "Missing Dpkg modules required by the FTP access method.\n\n";
32 use Dselect
::Method
::Ftp
;
35 my $vardir = $ARGV[0];
36 my $method = $ARGV[1];
37 my $option = $ARGV[2];
39 if ($option eq 'manual') {
40 print "Manual package installation.\n";
43 #print "vardir: $vardir, method: $method, option: $option\n";
46 my $arch = qx(dpkg
--print-architecture
);
50 my $logname = qx(whoami
);
52 my $host = qx(cat
/etc/mailname
|| dnsdomainname
);
55 $CONFIG{dldir
} = 'debian';
56 $CONFIG{use_auth_proxy
} = 0;
57 $CONFIG{proxyhost
} = '';
58 $CONFIG{proxylogname
} = $logname;
59 $CONFIG{proxypassword
} = '';
61 my $methdir = "$vardir/methods/ftp";
65 if (-f
"$methdir/vars") {
66 read_config
("$methdir/vars");
79 You must supply an ftp site, use of passive mode, username, password,
80 path to the debian directory,list of distributions you are interested
81 in and place to download the binary package files to (relative to
82 /var/lib/dpkg/methods/ftp). You can add as much sites as you like. Later
83 entries will always override older ones.
85 Supply "?" as a password to be asked each time you connect.
87 Eg: ftp site: ftp.debian.org
90 password: $logname\@$host
92 distributions: dists/stable/main dists/stable/contrib
95 You may have to use an authenticated FTP proxy in order to reach the
100 proxy account: $CONFIG{proxylogname}
104 if (! $CONFIG{done
}) {
105 view_mirrors
() if (yesno
('y', 'Would you like to see a list of ftp mirrors'));
108 edit_config
('ftp', $methdir);
112 foreach (@
{$CONFIG{site
}}) {
113 $ftp = do_connect
(ftpsite
=> $_->[0],
118 useproxy
=> $CONFIG{use_auth_proxy
},
119 proxyhost
=> $CONFIG{proxyhost
},
120 proxylogname
=> $CONFIG{proxylogname
},
121 proxypassword
=> $CONFIG{proxypassword
});
123 my @dists = @
{$_->[2]};
125 foreach my $dist (@dists) {
126 my $dir = "$dist/binary-$arch";
127 print "Checking $dir...\n";
128 # if (!$ftp->pasv()) { print $ftp->message . "\n"; die 'error'; }
129 my @dirlst = $ftp->ls("$dir/");
132 foreach my $line (@dirlst) {
133 if($line =~ /Packages/) {
138 print "Warning: Could not find a Packages file in $dir\n",
139 "This may not be a problem if the directory is a symbolic link\n";
143 print "Closing ftp connection...\n";
148 # download stuff (protect from ^C)
149 print "\nUsing FTP to check directories...(stop with ^C)\n\n";
151 local $SIG{INT
} = sub {
152 die "interrupted!\n";
158 print 'FTP ERROR - ';
159 if ($@
eq 'connect') {
160 print "config was untested\n";
167 # output new vars file
169 store_config
("$methdir/vars");
170 chmod 0600, "$methdir/vars";
172 if($exit || $problem) {
173 print "Press <enter> to continue\n";