3 # Copyright © 1996 Andy Guy <awpguy@acs.ucalgary.ca>
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; version 2 of the License.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <https://www.gnu.org/licenses/>.
23 pop @INC if $INC[-1] eq '.';
27 warn "Please install the 'perl' package if you want to use the\n" .
28 "FTP access method of dselect.\n\n";
34 my $vardir = $ARGV[0];
35 my $method = $ARGV[1];
36 my $option = $ARGV[2];
38 if ($option eq 'manual') {
39 print "Manual package installation.\n";
42 #print "vardir: $vardir, method: $method, option: $option\n";
45 my $arch = qx(dpkg --print-architecture);
49 my $logname = qx(whoami);
51 my $host = qx(cat /etc/mailname || dnsdomainname);
54 $CONFIG{dldir} = 'debian';
55 $CONFIG{use_auth_proxy} = 0;
56 $CONFIG{proxyhost} = '';
57 $CONFIG{proxylogname} = $logname;
58 $CONFIG{proxypassword} = '';
60 my $methdir = "$vardir/methods/ftp";
64 if (-f "$methdir/vars") {
65 read_config("$methdir/vars");
78 You must supply an ftp site, use of passive mode, username, password,
79 path to the debian directory,list of distributions you are interested
80 in and place to download the binary package files to (relative to
81 /var/lib/dpkg/methods/ftp). You can add as much sites as you like. Later
82 entries will always override older ones.
84 Supply "?" as a password to be asked each time you connect.
86 Eg: ftp site: ftp.debian.org
89 password: $logname\@$host
91 distributions: dists/stable/main dists/stable/contrib
94 If you want to install package from non-US consider adding a second ftp site
95 with "debian-non-US" as debian directory and "dists/stable/non-US" as
98 You may have to use an authenticated FTP proxy in order to reach the
101 Eg: use auth proxy: y
103 proxy account: $CONFIG{proxylogname}
107 if (! $CONFIG{done}) {
108 view_mirrors() if (yesno('y', 'Would you like to see a list of ftp mirrors'));
111 edit_config($methdir);
115 foreach (@{$CONFIG{site}}) {
117 $ftp = do_connect ($_->[0], # Ftp server
122 $CONFIG{use_auth_proxy},
124 $CONFIG{proxylogname},
125 $CONFIG{proxypassword});
127 my @dists = @{$_->[2]};
129 foreach my $dist (@dists) {
130 my $dir = "$dist/binary-$arch";
131 print "Checking $dir...\n";
132 # if (!$ftp->pasv()) { print $ftp->message . "\n"; die 'error'; }
133 my @dirlst = $ftp->ls("$dir/");
136 foreach my $line (@dirlst) {
137 if($line =~ /Packages/) {
142 print "Warning: Could not find a Packages file in $dir\n",
143 "This may not be a problem if the directory is a symbolic link\n";
147 print "Closing ftp connection...\n";
152 # download stuff (protect from ^C)
153 print "\nUsing FTP to check directories...(stop with ^C)\n\n";
155 local $SIG{INT} = sub {
156 die "interrupted!\n";
162 print 'FTP ERROR - ';
163 if ($@ eq 'connect') {
164 print "config was untested\n";
171 # output new vars file
173 store_config("$methdir/vars");
174 chmod 0600, "$methdir/vars";
176 if($exit || $problem) {
177 print "Press <enter> to continue\n";