summaryrefslogtreecommitdiff
path: root/dselect/methods
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2017-08-31 03:29:53 +0200
committerGuillem Jover <guillem@debian.org>2017-09-24 21:03:09 +0200
commit417c80f6fbc6673aac6c42bb1fdc3e0280b01cd1 (patch)
tree7b5c84ffdba5c2df585a1ae485ab4e2d9415d967 /dselect/methods
parent0d2b3cee25b74dd3fd9ddc3a469b8b144368c963 (diff)
downloaddpkg-417c80f6fbc6673aac6c42bb1fdc3e0280b01cd1.tar.gz
Dselect::Ftp: Avoid many function arguments in do_connect()
Addresses: Subroutines::ProhibitManyArgs Warned-by: perlcritic
Diffstat (limited to 'dselect/methods')
-rw-r--r--dselect/methods/Dselect/Ftp.pm38
-rwxr-xr-xdselect/methods/ftp/install.pl18
-rwxr-xr-xdselect/methods/ftp/setup.pl18
-rwxr-xr-xdselect/methods/ftp/update.pl36
4 files changed, 56 insertions, 54 deletions
diff --git a/dselect/methods/Dselect/Ftp.pm b/dselect/methods/Dselect/Ftp.pm
index 1c326c4bf..acd32d15f 100644
--- a/dselect/methods/Dselect/Ftp.pm
+++ b/dselect/methods/Dselect/Ftp.pm
@@ -228,8 +228,7 @@ sub yesno($$) {
##############################
sub do_connect {
- my($ftpsite,$username,$pass,$ftpdir,$passive,
- $useproxy,$proxyhost,$proxylogname,$proxypassword) = @_;
+ my (%opts) = @_;
my($rpass,$remotehost,$remoteuser,$ftp);
@@ -237,28 +236,28 @@ sub do_connect {
while(1) {
my $exit = 0;
- if ($useproxy) {
- $remotehost = $proxyhost;
- $remoteuser = $username . '@' . $ftpsite;
+ if ($opts{useproxy}) {
+ $remotehost = $opts{proxyhost};
+ $remoteuser = $opts{username} . '@' . $opts{ftpsite};
} else {
- $remotehost = $ftpsite;
- $remoteuser = $username;
+ $remotehost = $opts{ftpsite};
+ $remoteuser = $opts{username};
}
- print "Connecting to $ftpsite...\n";
- $ftp = Net::FTP->new($remotehost, Passive => $passive);
+ print "Connecting to $opts{ftpsite}...\n";
+ $ftp = Net::FTP->new($remotehost, Passive => $opts{passive});
if(!$ftp || !$ftp->ok) {
print "Failed to connect\n";
$exit=1;
}
if (!$exit) {
# $ftp->debug(1);
- if ($useproxy) {
- print "Login on $proxyhost...\n";
- $ftp->_USER($proxylogname);
- $ftp->_PASS($proxypassword);
+ if ($opts{useproxy}) {
+ print "Login on $opts{proxyhost}...\n";
+ $ftp->_USER($opts{proxylogname});
+ $ftp->_PASS($opts{proxypassword});
}
- print "Login as $username...\n";
- if ($pass eq '?') {
+ print "Login as $opts{username}...\n";
+ if ($opts{password} eq '?') {
print 'Enter password for ftp: ';
system('stty', '-echo');
$rpass = <STDIN>;
@@ -266,7 +265,7 @@ sub do_connect {
print "\n";
system('stty', 'echo');
} else {
- $rpass = $pass;
+ $rpass = $opts{password};
}
if(!$ftp->login($remoteuser, $rpass))
{ print $ftp->message() . "\n"; $exit=1; }
@@ -276,8 +275,11 @@ sub do_connect {
if(!$ftp->binary()) { print $ftp->message . "\n"; $exit=1; }
}
if (!$exit) {
- print "Cd to '$ftpdir'...\n";
- if(!$ftp->cwd($ftpdir)) { print $ftp->message . "\n"; $exit=1; }
+ print "Cd to '$opts{ftpdir}'...\n";
+ if (!$ftp->cwd($opts{ftpdir})) {
+ print $ftp->message . "\n";
+ $exit = 1;
+ }
}
if ($exit) {
diff --git a/dselect/methods/ftp/install.pl b/dselect/methods/ftp/install.pl
index 2eb9f16a8..9966e7a5d 100755
--- a/dselect/methods/ftp/install.pl
+++ b/dselect/methods/ftp/install.pl
@@ -338,15 +338,15 @@ sub download() {
if (! @getfiles) { $i++; next; }
- $ftp = do_connect ($site->[0], #$::ftpsite,
- $site->[4], #$::username,
- $site->[5], #$::password,
- $site->[1], #$::ftpdir,
- $site->[3], #$::passive,
- $CONFIG{use_auth_proxy},
- $CONFIG{proxyhost},
- $CONFIG{proxylogname},
- $CONFIG{proxypassword});
+ $ftp = do_connect(ftpsite => $site->[0],
+ ftpdir => $site->[1],
+ passive => $site->[3],
+ username => $site->[4],
+ password => $site->[5],
+ useproxy => $CONFIG{use_auth_proxy},
+ proxyhost => $CONFIG{proxyhost},
+ proxylogname => $CONFIG{proxylogname},
+ proxypassword => $CONFIG{proxypassword});
local $SIG{INT} = sub { die "Interrupted !\n"; };
diff --git a/dselect/methods/ftp/setup.pl b/dselect/methods/ftp/setup.pl
index 18a5832f9..67a86fef6 100755
--- a/dselect/methods/ftp/setup.pl
+++ b/dselect/methods/ftp/setup.pl
@@ -114,15 +114,15 @@ my $ftp;
sub download() {
foreach (@{$CONFIG{site}}) {
- $ftp = do_connect ($_->[0], # Ftp server
- $_->[4], # username
- $_->[5], # password
- $_->[1], # ftp dir
- $_->[3], # passive
- $CONFIG{use_auth_proxy},
- $CONFIG{proxyhost},
- $CONFIG{proxylogname},
- $CONFIG{proxypassword});
+ $ftp = do_connect(ftpsite => $_->[0],
+ ftpdir => $_->[1],
+ passive => $_->[3],
+ username => $_->[4],
+ password => $_->[5],
+ useproxy => $CONFIG{use_auth_proxy},
+ proxyhost => $CONFIG{proxyhost},
+ proxylogname => $CONFIG{proxylogname},
+ proxypassword => $CONFIG{proxypassword});
my @dists = @{$_->[2]};
diff --git a/dselect/methods/ftp/update.pl b/dselect/methods/ftp/update.pl
index 68f7a67f5..a40f6f01a 100755
--- a/dselect/methods/ftp/update.pl
+++ b/dselect/methods/ftp/update.pl
@@ -76,15 +76,15 @@ foreach (@{$CONFIG{site}}) {
my $site = $_;
- $ftp = do_connect ($_->[0], # Ftp server
- $_->[4], # username
- $_->[5], # password
- $_->[1], # ftp dir
- $_->[3], # passive
- $CONFIG{use_auth_proxy},
- $CONFIG{proxyhost},
- $CONFIG{proxylogname},
- $CONFIG{proxypassword});
+ $ftp = do_connect(ftpsite => $_->[0],
+ ftpdir => $_->[1],
+ passive => $_->[3],
+ username => $_->[4],
+ password => $_->[5],
+ useproxy => $CONFIG{use_auth_proxy},
+ proxyhost => $CONFIG{proxyhost},
+ proxylogname => $CONFIG{proxylogname},
+ proxypassword => $CONFIG{proxypassword});
my @dists = @{$_->[2]};
PACKAGE:
@@ -166,15 +166,15 @@ foreach (@{$CONFIG{site}}) {
$ftp->quit();
};
if (yesno ('y', "Transfer failed at $size: retry at once")) {
- $ftp = do_connect ($site->[0], # Ftp server
- $site->[4], # username
- $site->[5], # password
- $site->[1], # ftp dir
- $site->[3], # passive
- $CONFIG{use_auth_proxy},
- $CONFIG{proxyhost},
- $CONFIG{proxylogname},
- $CONFIG{proxypassword});
+ $ftp = do_connect(ftpsite => $site->[0],
+ ftpdir => $site->[1],
+ passive => $site->[3],
+ username => $site->[4],
+ password => $site->[5],
+ useproxy => $CONFIG{use_auth_proxy},
+ proxyhost => $CONFIG{proxyhost},
+ proxylogname => $CONFIG{proxylogname},
+ proxypassword => $CONFIG{proxypassword});
if ($newest_pack_date != do_mdtm ($ftp, "$dir/Packages.gz")) {
print ("Packages file has changed !\n");