This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=be3d4780796902b168aca9480fb02a097f148f58 commit be3d4780796902b168aca9480fb02a097f148f58 Author: Guillem Jover <[email protected]> AuthorDate: Mon Mar 20 23:33:37 2023 +0100 Dselect::Method::Ftp: Modify config and site subs towards method independence Pass the method as an argument and parametrize it inside the function, so that we can keep generalizing it towards a general purpose config and site handling set of functions. --- dselect/methods/Dselect/Method/Ftp.pm | 26 ++++++++++++++------------ dselect/methods/ftp/setup.pl | 4 ++-- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/dselect/methods/Dselect/Method/Ftp.pm b/dselect/methods/Dselect/Method/Ftp.pm index 4ed576932..7c080ee6f 100644 --- a/dselect/methods/Dselect/Method/Ftp.pm +++ b/dselect/methods/Dselect/Method/Ftp.pm @@ -115,29 +115,29 @@ MIRRORS } sub edit_config { - my $methdir = shift; + my ($method, $methdir) = @_; my $i; - #Get a config for ftp sites + # Get a config for the sites. while(1) { $i = 1; - print "\n\nList of selected ftp sites :\n"; + print "\n\nList of selected $method sites :\n"; foreach (@{$CONFIG{site}}) { - print "$i. ftp://$_->[0]$_->[1] @{$_->[2]}\n"; + print "$i. $method://$_->[0]$_->[1] @{$_->[2]}\n"; $i++; } print "\nEnter a command (a=add e=edit d=delete q=quit m=mirror list) \n"; print 'eventually followed by a site number : '; chomp($_ = <STDIN>); /q/i && last; - /a/i && add_site(); + /a/i && add_site($method); /d\s*(\d+)/i && do { splice(@{$CONFIG{site}}, $1 - 1, 1) if ($1 <= @{$CONFIG{site}}); next;}; /e\s*(\d+)/i && do { - edit_site($CONFIG{site}[$1 - 1]) if ($1 <= @{$CONFIG{site}}); + edit_site($method, $CONFIG{site}[$1 - 1]) if $1 <= @{$CONFIG{site}}; next; }; /m/i && view_mirrors(); } @@ -173,6 +173,8 @@ sub edit_config { } sub add_site { + my $method = shift; + my $pas = 1; my $user = 'anonymous'; my $email = qx(whoami); @@ -191,15 +193,15 @@ sub add_site { 'dists/stable/non-free', ], $pas, $user, $email ]); - edit_site($CONFIG{site}[@{$CONFIG{site}} - 1]); + edit_site($method, $CONFIG{site}[@{$CONFIG{site}} - 1]); } sub edit_site { - my $site = shift; + my ($method, $site) = @_; local($_); - print "\nEnter ftp site [$site->[0]] : "; + print "\nEnter $method site [$site->[0]] : "; chomp($_ = <STDIN>); $site->[0] = $_ || $site->[0]; @@ -211,11 +213,11 @@ sub edit_site { chomp($_ = <STDIN>); $site->[4] = $_ || $site->[4]; - print <<'EOF'; + print <<"EOF"; -If you're using anonymous ftp to retrieve files, enter your email +If you are using anonymous $method to retrieve files, enter your email address for use as a password. Otherwise enter your password, -or "?" if you want dselect-ftp to prompt you each time. +or "?" if you want the $method method to prompt you each time. EOF diff --git a/dselect/methods/ftp/setup.pl b/dselect/methods/ftp/setup.pl index 0c7b7da0c..de7648c43 100755 --- a/dselect/methods/ftp/setup.pl +++ b/dselect/methods/ftp/setup.pl @@ -102,9 +102,9 @@ EOM if (! $CONFIG{done}) { view_mirrors() if (yesno('y', 'Would you like to see a list of ftp mirrors')); - add_site(); + add_site('ftp'); } -edit_config($methdir); +edit_config('ftp', $methdir); my $ftp; sub download() { -- Dpkg.Org's dpkg

