ソースを参照

Dselect::Ftp: Uppercase public %config package variable

This module has a problematic license, so there's no point in doing
a more intrusive cleanup, just uppercase the variable and be done
with it.

Addresses Variables::ProhibitPackageVars.

Warned-by: perlcritic
Guillem Jover 12 年 前
コミット
16f9bd122b
共有4 個のファイルを変更した55 個の追加54 個の削除を含む
  1. 24 23
      dselect/methods/Dselect/Ftp.pm
  2. 9 9
      dselect/methods/ftp/install
  3. 13 13
      dselect/methods/ftp/setup
  4. 9 9
      dselect/methods/ftp/update

+ 24 - 23
dselect/methods/Dselect/Ftp.pm

@@ -15,16 +15,17 @@ package Dselect::Ftp;
 use strict;
 use warnings;
 
-our $VERSION = '0.01';
+our $VERSION = '0.02';
 
 use Exporter qw(import);
 
 use Net::FTP;
 use Data::Dumper;
 
-our @EXPORT = qw(%config yesno do_connect do_mdtm add_site edit_site
+our @EXPORT = qw(%CONFIG yesno do_connect do_mdtm add_site edit_site
                  edit_config read_config store_config view_mirrors nb);
-our %config;
+
+my %CONFIG;
 
 sub nb {
   my $nb = shift;
@@ -54,7 +55,7 @@ sub read_config {
   die "couldn't eval $vars content: $@\n" if ($@);
   if (ref($conf) =~ /HASH/) {
     foreach (keys %{$conf}) {
-      $config{$_} = $conf->{$_};
+      $CONFIG{$_} = $conf->{$_};
     }
   } else {
     print "Bad $vars file : removing it.\n";
@@ -68,11 +69,11 @@ sub store_config {
   my $vars = shift;
 
   # Check that config is completed
-  return if not $config{done};
+  return if not $CONFIG{done};
 
   open(my $vars_fh, '>', $vars) ||
     die "couldn't open $vars in write mode: $!\n";
-  print $vars_fh Dumper(\%config);
+  print $vars_fh Dumper(\%CONFIG);
   close $vars_fh;
 }
 
@@ -94,7 +95,7 @@ sub edit_config {
   while(1) {
     $i = 1;
     print "\n\nList of selected ftp sites :\n";
-    foreach (@{$config{site}}) {
+    foreach (@{$CONFIG{site}}) {
       print "$i. ftp://$_->[0]$_->[1] @{$_->[2]}\n";
       $i++;
     }
@@ -105,42 +106,42 @@ sub edit_config {
     /a/i && add_site();
     /d\s*(\d+)/i &&
     do {
-         splice(@{$config{site}}, $1 - 1, 1) if ($1 <= @{$config{site}});
+         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($CONFIG{site}[$1 - 1]) if ($1 <= @{$CONFIG{site}});
          next; };
     /m/i && view_mirrors();
   }
 
   print "\n";
-  $config{use_auth_proxy} = yesno($config{use_auth_proxy} ? 'y' : 'n',
+  $CONFIG{use_auth_proxy} = yesno($CONFIG{use_auth_proxy} ? 'y' : 'n',
                                   'Go through an authenticated proxy');
 
-  if ($config{use_auth_proxy}) {
-    print "\nEnter proxy hostname [$config{proxyhost}] : ";
+  if ($CONFIG{use_auth_proxy}) {
+    print "\nEnter proxy hostname [$CONFIG{proxyhost}] : ";
     chomp($_ = <STDIN>);
-    $config{proxyhost} = $_ || $config{proxyhost};
+    $CONFIG{proxyhost} = $_ || $CONFIG{proxyhost};
 
-    print "\nEnter proxy log name [$config{proxylogname}] : ";
+    print "\nEnter proxy log name [$CONFIG{proxylogname}] : ";
     chomp($_ = <STDIN>);
-    $config{proxylogname} = $_ || $config{proxylogname};
+    $CONFIG{proxylogname} = $_ || $CONFIG{proxylogname};
 
-    print "\nEnter proxy password [$config{proxypassword}] : ";
+    print "\nEnter proxy password [$CONFIG{proxypassword}] : ";
     chomp ($_ = <STDIN>);
-    $config{proxypassword} = $_ || $config{proxypassword};
+    $CONFIG{proxypassword} = $_ || $CONFIG{proxypassword};
   }
 
   print "\nEnter directory to download binary package files to\n";
   print "(relative to $methdir)\n";
   while(1) {
-    print "[$config{dldir}] : ";
+    print "[$CONFIG{dldir}] : ";
     chomp($_ = <STDIN>);
     s{/$}{};
-    $config{dldir} = $_ if ($_);
-    last if -d "$methdir/$config{dldir}";
-    print "$methdir/$config{dldir} is not a directory !\n";
+    $CONFIG{dldir} = $_ if ($_);
+    last if -d "$methdir/$CONFIG{dldir}";
+    print "$methdir/$CONFIG{dldir} is not a directory !\n";
   }
 }
 
@@ -153,11 +154,11 @@ sub add_site {
   chomp $email;
   my $dir = '/debian';
 
-  push (@{$config{site}}, [ '', $dir, [ 'dists/stable/main',
+  push (@{$CONFIG{site}}, [ '', $dir, [ 'dists/stable/main',
                                         'dists/stable/contrib',
                                         'dists/stable/non-free' ],
                                $pas, $user, $email ]);
-  edit_site($config{site}[@{$config{site}} - 1]);
+  edit_site($CONFIG{site}[@{$CONFIG{site}} - 1]);
 }
 
 sub edit_site {

+ 9 - 9
dselect/methods/ftp/install

@@ -56,7 +56,7 @@ my $methdir = "$vardir/methods/ftp";
 read_config("$methdir/vars");
 
 chdir "$methdir";
-mkpath(["$methdir/$config{dldir}"], 0, 0755);
+mkpath(["$methdir/$CONFIG{dldir}"], 0, 0755);
 
 
 #Read md5sums already calculated
@@ -187,7 +187,7 @@ sub procpkgfile {
 print "\nProcessing Package files...\n";
 my ($fn, $i, $j);
 $i = 0;
-foreach my $site (@{$config{site}}) {
+foreach my $site (@{$CONFIG{site}}) {
   $j = 0;
   foreach my $dist (@{$site->[2]}) {
     $fn = $dist;
@@ -204,7 +204,7 @@ foreach my $site (@{$config{site}}) {
   $i++;
 }
 
-my $dldir = $config{dldir};
+my $dldir = $CONFIG{dldir};
 # md5sum
 sub md5sum($) {
     my $fn = shift;
@@ -262,7 +262,7 @@ foreach my $pkg (keys(%pkgs)) {
 	    my $ffn = $fn;
 	    $ffn =~ s/binary-[^\/]+/.../;
 	    print 'want: ' .
-	          $config{site}[$pkgfiles{$fn}[2]][0] . " $ffn (${csize}k)\n";
+	          $CONFIG{site}[$pkgfiles{$fn}[2]][0] . " $ffn (${csize}k)\n";
 	    $downloads{$fn} = 0;
 	    $totsize += $csize;
 	}
@@ -317,7 +317,7 @@ sub download() {
 
  my $i = 0;
 
- foreach my $site (@{$config{site}}) {
+ foreach my $site (@{$CONFIG{site}}) {
 
     my @getfiles = grep { $pkgfiles{$_}[2] == $i } keys %downloads;
     my @pre_dist = (); # Directory to add before $fn
@@ -342,10 +342,10 @@ sub download() {
 		       $site->[5], #$::password,
 		       $site->[1], #$::ftpdir,
 		       $site->[3], #$::passive,
-		       $config{use_auth_proxy},
-		       $config{proxyhost},
-		       $config{proxylogname},
-		       $config{proxypassword});
+		       $CONFIG{use_auth_proxy},
+		       $CONFIG{proxyhost},
+		       $CONFIG{proxylogname},
+		       $CONFIG{proxypassword});
 
     local $SIG{INT} = sub { die "Interrupted !\n"; };
 

+ 13 - 13
dselect/methods/ftp/setup

@@ -48,11 +48,11 @@ chomp $logname;
 my $host = `cat /etc/mailname || dnsdomainname`;
 chomp $host;
 
-$config{dldir} = 'debian';
-$config{use_auth_proxy} = 0;
-$config{proxyhost} = '';
-$config{proxylogname} = $logname;
-$config{proxypassword} = '';
+$CONFIG{dldir} = 'debian';
+$CONFIG{use_auth_proxy} = 0;
+$CONFIG{proxyhost} = '';
+$CONFIG{proxylogname} = $logname;
+$CONFIG{proxypassword} = '';
 
 my $methdir = "$vardir/methods/ftp";
 my $exit = 0;
@@ -97,11 +97,11 @@ FTP site:
 
 Eg:  use auth proxy: y
               proxy: proxy.isp.com
-      proxy account: $config{proxylogname}
+      proxy account: $CONFIG{proxylogname}
      proxy password: ?
 EOM
 
-if (! $config{done}) {
+if (! $CONFIG{done}) {
   view_mirrors() if (yesno('y', 'Would you like to see a list of ftp mirrors'));
   add_site();
 }
@@ -109,17 +109,17 @@ edit_config($methdir);
 
 my $ftp;
 sub download() {
- foreach (@{$config{site}}) {
+ 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});
+		       $CONFIG{use_auth_proxy},
+		       $CONFIG{proxyhost},
+		       $CONFIG{proxylogname},
+		       $CONFIG{proxypassword});
 
     my @dists = @{$_->[2]};
 
@@ -166,7 +166,7 @@ if($@) {
 };
 
 # output new vars file
-$config{done} = 1;
+$CONFIG{done} = 1;
 store_config("$methdir/vars");
 chmod  0600, "$methdir/vars";
 

+ 9 - 9
dselect/methods/ftp/update

@@ -69,7 +69,7 @@ my $ftp;
 my $packages_modified = 0;
 
 sub download {
-foreach (@{$config{site}}) {
+foreach (@{$CONFIG{site}}) {
 
    my $site = $_;
 
@@ -78,10 +78,10 @@ foreach (@{$config{site}}) {
                            $_->[5], # password
                            $_->[1], # ftp dir
                            $_->[3], # passive
-                           $config{use_auth_proxy},
-                           $config{proxyhost},
-                           $config{proxylogname},
-                           $config{proxypassword});
+                           $CONFIG{use_auth_proxy},
+                           $CONFIG{proxyhost},
+                           $CONFIG{proxylogname},
+                           $CONFIG{proxypassword});
 
     my @dists = @{$_->[2]};
     PACKAGE:
@@ -168,10 +168,10 @@ foreach (@{$config{site}}) {
                            $site->[5], # password
                            $site->[1], # ftp dir
                            $site->[3], # passive
-                           $config{use_auth_proxy},
-                           $config{proxyhost},
-                           $config{proxylogname},
-                           $config{proxypassword});
+                           $CONFIG{use_auth_proxy},
+                           $CONFIG{proxyhost},
+                           $CONFIG{proxylogname},
+                           $CONFIG{proxypassword});
 
 			if ($newest_pack_date != do_mdtm ($ftp, "$dir/Packages.gz")) {
 			    print ("Packages file has changed !\n");