diff options
Diffstat (limited to 'dselect/methods')
-rw-r--r-- | dselect/methods/Dselect/Ftp.pm | 52 | ||||
-rwxr-xr-x | dselect/methods/ftp/install | 68 | ||||
-rwxr-xr-x | dselect/methods/ftp/setup | 22 | ||||
-rwxr-xr-x | dselect/methods/ftp/update | 44 |
4 files changed, 94 insertions, 92 deletions
diff --git a/dselect/methods/Dselect/Ftp.pm b/dselect/methods/Dselect/Ftp.pm index 5c995d512..dc0cc3a53 100644 --- a/dselect/methods/Dselect/Ftp.pm +++ b/dselect/methods/Dselect/Ftp.pm @@ -27,11 +27,11 @@ our %config; sub nb { my $nb = shift; if ($nb > 1024**2) { - return sprintf("%.2fM", $nb / 1024**2); + return sprintf('%.2fM', $nb / 1024**2); } elsif ($nb > 1024) { - return sprintf("%.2fk", $nb / 1024); + return sprintf('%.2fk', $nb / 1024); } else { - return sprintf("%.2fb", $nb); + return sprintf('%.2fb', $nb); } } @@ -97,7 +97,7 @@ sub edit_config { $i++; } print "\nEnter a command (a=add e=edit d=delete q=quit m=mirror list) \n"; - print "eventually followed by a site number : "; + print 'eventually followed by a site number : '; chomp($_ = <STDIN>); /q/i && last; /a/i && add_site(); @@ -113,8 +113,8 @@ sub edit_config { } print "\n"; - $config{use_auth_proxy} = yesno($config{use_auth_proxy} ? "y" : "n", - "Go through an authenticated proxy"); + $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}] : "; @@ -144,16 +144,16 @@ sub edit_config { sub add_site { my $pas = 1; - my $user = "anonymous"; + my $user = 'anonymous'; my $email = `whoami`; chomp $email; $email .= '@' . `cat /etc/mailname || dnsdomainname`; chomp $email; - my $dir = "/debian"; + my $dir = '/debian'; - push (@{$config{site}}, [ "", $dir, [ "dists/stable/main", - "dists/stable/contrib", - "dists/stable/non-free" ], + push (@{$config{site}}, [ '', $dir, [ 'dists/stable/main', + 'dists/stable/contrib', + 'dists/stable/non-free' ], $pas, $user, $email ]); edit_site($config{site}[@{$config{site}} - 1]); } @@ -167,7 +167,7 @@ sub edit_site { chomp($_ = <STDIN>); $site->[0] = $_ || $site->[0]; - print "\nUse passive mode [" . ($site->[3] ? "y" : "n") ."] : "; + print "\nUse passive mode [" . ($site->[3] ? 'y' : 'n') . '] : '; chomp($_ = <STDIN>); $site->[3] = (/y/i ? 1 : 0) if ($_); @@ -202,9 +202,9 @@ sub yesno($$) { my ($res, $r); $r = -1; - $r = 0 if $d eq "n"; - $r = 1 if $d eq "y"; - die "Incorrect usage of yesno, stopped" if $r == -1; + $r = 0 if $d eq 'n'; + $r = 1 if $d eq 'y'; + die 'Incorrect usage of yesno, stopped' if $r == -1; while (1) { print $msg, " [$d]: "; $res = <STDIN>; @@ -229,7 +229,7 @@ sub do_connect { if ($useproxy) { $remotehost = $proxyhost; - $remoteuser = $username . "@" . $ftpsite; + $remoteuser = $username . '@' . $ftpsite; } else { $remotehost = $ftpsite; $remoteuser = $username; @@ -248,13 +248,13 @@ sub do_connect { $ftp->_PASS($proxypassword); } print "Login as $username...\n"; - if ($pass eq "?") { - print "Enter password for ftp: "; - system("stty", "-echo"); + if ($pass eq '?') { + print 'Enter password for ftp: '; + system('stty', '-echo'); $rpass = <STDIN>; chomp $rpass; print "\n"; - system("stty", "echo"); + system('stty', 'echo'); } else { $rpass = $pass; } @@ -271,17 +271,17 @@ sub do_connect { } if ($exit) { - if (yesno ("y", "Retry connection at once")) { + if (yesno ('y', 'Retry connection at once')) { next TRY_CONNECT; } else { - die "error"; + die 'error'; } } last TRY_CONNECT; } -# if(!$ftp->pasv()) { print $ftp->message . "\n"; die "error"; } +# if(!$ftp->pasv()) { print $ftp->message . "\n"; die 'error'; } return $ftp; } @@ -334,7 +334,7 @@ sub do_mdtm { # print "[$#files]"; - # get the date components from the output of "ls -l" + # get the date components from the output of 'ls -l' if ($files[0] =~ /([^ ]+ *){5}[^ ]+ ([A-Z][a-z]{2}) ([ 0-9][0-9]) ([0-9 ][0-9][:0-9][0-9]{2})/) { @@ -364,13 +364,13 @@ sub do_mdtm { $hours = 0; $minutes = 0; $year = $yearOrTime - 1900; } else { - die "Cannot parse year-or-time"; + die 'Cannot parse year-or-time'; } # build a system time $time = timegm (0, $minutes, $hours, $day, $month, $year); } else { - die "Regexp match failed on LIST output"; + die 'Regexp match failed on LIST output'; } } diff --git a/dselect/methods/ftp/install b/dselect/methods/ftp/install index 615fa8f75..de365e334 100755 --- a/dselect/methods/ftp/install +++ b/dselect/methods/ftp/install @@ -42,7 +42,7 @@ my $vardir = $ARGV[0]; my $method = $ARGV[1]; my $option = $ARGV[2]; -if ($option eq "manual" ) { +if ($option eq 'manual') { print "manual mode not supported yet\n"; exit 1; } @@ -115,14 +115,14 @@ my %curpkgs; sub procstatus { my (%flds, $fld); open(my $status_fh, '<', "$vardir/status") or - die "Could not open status file"; + die 'Could not open status file'; while (%flds = getblk($status_fh), %flds) { if($flds{'status'} =~ /^install ok/) { my $cs = (split(/ /, $flds{'status'}))[2]; - if(($cs eq "not-installed") || - ($cs eq "half-installed") || - ($cs eq "config-files")) { - $curpkgs{$flds{'package'}} = ""; + if (($cs eq 'not-installed') || + ($cs eq 'half-installed') || + ($cs eq 'config-files')) { + $curpkgs{$flds{'package'}} = ''; } else { $curpkgs{$flds{'package'}} = $flds{'version'}; } @@ -135,7 +135,7 @@ procstatus(); sub dcmpvers { my($a, $p, $b) = @_; my ($r); - $r = system("dpkg", "--compare-versions", "$a", "$p", "$b"); + $r = system('dpkg', '--compare-versions', "$a", "$p", "$b"); $r = $r/256; if ($r == 0) { return 1; @@ -164,7 +164,7 @@ sub procpkgfile { @files = split(/[\s\n]+/, $flds{'filename'}); @sizes = split(/[\s\n]+/, $flds{'size'}); @md5sums = split(/[\s\n]+/, $flds{'md5sum'}); - if ( defined($ver) && ( ($ver eq "") || dcmpvers( $ver, "lt", $flds{'version'} ) )) { + if (defined($ver) && (($ver eq '') || dcmpvers($ver, 'lt', $flds{'version'}))) { $pkgs{$pkg} = [ $flds{'version'}, [ @files ], $site ]; $curpkgs{$pkg} = $flds{'version'}; } @@ -207,7 +207,7 @@ my $dldir = $config{dldir}; sub md5sum($) { my $fn = shift; my $m = `md5sum $fn`; - $m = (split(" ", $m))[0]; + $m = (split(' ', $m))[0]; $md5sums{"$dldir/$fn"} = $m; return $m; } @@ -236,8 +236,8 @@ foreach $pkg (keys(%pkgs)) { $size = -s "$dldir/$fn"; if($info[1] > $size) { # partial download - if(yesno("y", "continue file: $fn (" . nb($size) ."/" . - nb($info[1]). ")")) { + if (yesno('y', "continue file: $fn (" . nb($size) . '/' . + nb($info[1]) . ')')) { $downloads{$fn} = $size; $totsize += $csize - int($size/1024); } else { @@ -259,7 +259,7 @@ foreach $pkg (keys(%pkgs)) { } else { my $ffn = $fn; $ffn =~ s/binary-[^\/]+/.../; - print "want: " . + print 'want: ' . $config{site}[$pkgfiles{$fn}[2]][0] . " $ffn (${csize}k)\n"; $downloads{$fn} = 0; $totsize += $csize; @@ -277,18 +277,19 @@ print "Available space in $dldir: ${avsp}k\n"; #chomp $avsp; if($totsize == 0) { - print "Nothing to get."; + print 'Nothing to get.'; } else { if($totsize > $avsp) { print "Space required is greater than available space,\n"; print "you will need to select which items to get.\n"; } # ask user which files to get - if(($totsize > $avsp) || yesno("n", "Do you want to select the files to get")) { + if (($totsize > $avsp) || + yesno('n', 'Do you want to select the files to get')) { $totsize = 0; my @files = sort(keys(%downloads)); my $fn; - my $def = "y"; + my $def = 'y'; foreach $fn (@files) { my @info = @{$pkgfiles{$fn}}; my $csize = int($info[1] / 1024) + 1; @@ -300,10 +301,10 @@ if($totsize == 0) { if(yesno($def, $downloads{$fn} ? "download: $fn ${rsize}k/${csize}k (total = ${totsize}k)" : "download: $fn ${rsize}k (total = ${totsize}k)")) { - $def = "y"; + $def = 'y'; $totsize += $rsize; } else { - $def = "n"; + $def = 'n'; delete $downloads{$fn}; } } @@ -326,7 +327,7 @@ sub download() { $cp = -1; foreach (@{$site->[2]}) { $cp++; - $pre_dist[$cp] = ""; + $pre_dist[$cp] = ''; $n = (s#\.\./#../#g); next if (! $n); if (m#^((?:\.\./){$n}(?:[^/]+/){$n})#) { @@ -351,10 +352,10 @@ sub download() { my ($fn,$rsize,$res,$pre); foreach $fn (@getfiles) { - $pre = $pre_dist[$pkgfiles{$fn}[3]] || ""; + $pre = $pre_dist[$pkgfiles{$fn}[3]] || ''; if ($downloads{$fn}) { $rsize = ${pkgfiles{$fn}}[1] - $downloads{$fn}; - print "getting: $pre$fn (". nb($rsize) . "/" . + print "getting: $pre$fn (" . nb($rsize) . '/' . nb($pkgfiles{$fn}[1]) . ")\n"; } else { print "getting: $pre$fn (". nb($pkgfiles{$fn}[1]) . ")\n"; @@ -399,11 +400,12 @@ sub download() { # download stuff (protect from ^C) if($totsize != 0) { - if(yesno("y", "\nDo you want to download the required files")) { + if (yesno('y', "\nDo you want to download the required files")) { DOWNLOAD_TRY: while (1) { print "Downloading files... use ^C to stop\n"; eval { - if ((download() == 1) && yesno("y", "\nDo you want to retry downloading at once")) { + if ((download() == 1) && + yesno('y', "\nDo you want to retry downloading at once")) { next DOWNLOAD_TRY; } }; @@ -415,7 +417,7 @@ if($totsize != 0) { undef $::ftp; } print "FTP ERROR\n"; - if (yesno("y", "\nDo you want to retry downloading at once")) { + if (yesno('y', "\nDo you want to retry downloading at once")) { # get the first $fn that foreach would give: # this is the one that got interrupted. my $ffn; @@ -425,7 +427,7 @@ if($totsize != 0) { } my $size = -s "$dldir/$fn"; # partial download - if(yesno("y", "continue file: $fn (at $size)")) { + if (yesno('y', "continue file: $fn (at $size)")) { $downloads{$fn} = $size; } else { $downloads{$fn} = 0; @@ -497,9 +499,9 @@ sub prcdeb($$) { return 0; } if($vers{$pkg}) { - if(dcmpvers($vers{$pkg}, "eq", $ver)) { + if (dcmpvers($vers{$pkg}, 'eq', $ver)) { $files{$pkg . $ver} = [ $files{$pkg . $ver }, "$dir/$fn" ]; - } elsif (dcmpvers($vers{$pkg}, "gt", $ver)) { + } elsif (dcmpvers($vers{$pkg}, 'gt', $ver)) { print "old version\n"; unlink $fn; } else { # else $ver is gt current version @@ -520,7 +522,7 @@ sub prcdeb($$) { sub prcfile() { my ($fn) = $_; if (-f $fn and $fn ne '.') { - my $dir = "."; + my $dir = '.'; if (length($File::Find::dir) > length($dldir)) { $dir = substr($File::Find::dir, length($dldir)+1); } @@ -558,7 +560,7 @@ sub prcfile() { find(\&prcfile, "$dldir/"); # install .debs -if(yesno("y", "\nDo you want to install the files fetched")) { +if (yesno('y', "\nDo you want to install the files fetched")) { print "Installing files...\n"; #Installing pre-dependent package before ! my (@flds, $package, @filename, $r); @@ -574,7 +576,7 @@ if(yesno("y", "\nDo you want to install the files fetched")) { if ($r) { print "DPKG ERROR\n"; $exit = 1; } } #Installing other packages after - $r = system("dpkg", "-iGREOB", $dldir); + $r = system('dpkg', '-iGREOB', $dldir); if($r) { print "DPKG ERROR\n"; $exit = 1; @@ -584,7 +586,7 @@ if(yesno("y", "\nDo you want to install the files fetched")) { sub removeinstalled { my $fn = $_; if (-f $fn and $fn ne '.') { - my $dir = "."; + my $dir = '.'; if (length($File::Find::dir) > length($dldir)) { $dir = substr($File::Find::dir, length($dldir)+1); } @@ -593,7 +595,7 @@ sub removeinstalled { if(!defined($pkg) || !defined($ver)) { print "Could not get info for: $dir/$fn\n"; } else { - if($curpkgs{$pkg} and dcmpvers($ver, "le", $curpkgs{$pkg})) { + if ($curpkgs{$pkg} and dcmpvers($ver, 'le', $curpkgs{$pkg})) { print "deleting: $dir/$fn\n"; unlink $fn; } else { @@ -608,7 +610,7 @@ sub removeinstalled { # remove .debs that have been installed (query user) # first need to reprocess status file -if(yesno("y", "\nDo you wish to delete the installed package (.deb) files?")) { +if (yesno('y', "\nDo you wish to delete the installed package (.deb) files?")) { print "Removing installed files...\n"; %curpkgs = (); procstatus(); @@ -616,7 +618,7 @@ if(yesno("y", "\nDo you wish to delete the installed package (.deb) files?")) { } # remove whole ./debian directory if user wants to -if(yesno("n", "\nDo you want to remove $dldir directory?")) { +if (yesno('n', "\nDo you want to remove $dldir directory?")) { rmtree("$dldir"); } diff --git a/dselect/methods/ftp/setup b/dselect/methods/ftp/setup index a5cc9af62..26da50d36 100755 --- a/dselect/methods/ftp/setup +++ b/dselect/methods/ftp/setup @@ -32,7 +32,7 @@ my $vardir = $ARGV[0]; my $method = $ARGV[1]; my $option = $ARGV[2]; -if ($option eq "manual") { +if ($option eq 'manual') { print "Manual package installation.\n"; exit 0; } @@ -48,11 +48,11 @@ chomp $logname; my $host = `cat /etc/mailname || dnsdomainname`; chomp $host; -$config{dldir} = "debian"; +$config{dldir} = 'debian'; $config{use_auth_proxy} = 0; -$config{proxyhost} = ""; +$config{proxyhost} = ''; $config{proxylogname} = $logname; -$config{proxypassword} = ""; +$config{proxypassword} = ''; my $methdir = "$vardir/methods/ftp"; my $exit = 0; @@ -63,8 +63,8 @@ if (-f "$methdir/vars") { } chdir "$methdir"; -if (! -d "debian") { - mkdir "debian", 0755; +if (! -d 'debian') { + mkdir 'debian', 0755; } # get info from user @@ -102,7 +102,7 @@ Eg: use auth proxy: y EOM if (! $config{done}) { - view_mirrors() if (yesno("y", "Would you like to see a list of ftp mirrors")); + view_mirrors() if (yesno('y', 'Would you like to see a list of ftp mirrors')); add_site(); } edit_config($methdir); @@ -127,10 +127,10 @@ sub download() { foreach $dist (@dists) { my $dir = "$dist/binary-$arch"; print "Checking $dir...\n"; -# if(!$ftp->pasv()) { print $ftp->message . "\n"; die "error"; } +# if (!$ftp->pasv()) { print $ftp->message . "\n"; die 'error'; } my @dirlst = $ftp->ls("$dir/"); my $got_pkgfile = 0; - my $line = ""; + my $line = ''; foreach $line (@dirlst) { if($line =~ /Packages/) { $got_pkgfile=1; @@ -157,8 +157,8 @@ eval { }; if($@) { $ftp->quit(); - print "FTP ERROR - "; - if ($@ eq "connect") { + print 'FTP ERROR - '; + if ($@ eq 'connect') { print "config was untested\n"; } else { print "$@\n"; diff --git a/dselect/methods/ftp/update b/dselect/methods/ftp/update index 92b82782c..bb3050c0b 100755 --- a/dselect/methods/ftp/update +++ b/dselect/methods/ftp/update @@ -33,17 +33,17 @@ my $vardir = $ARGV[0]; my $method = $ARGV[1]; my $option = $ARGV[2]; -if ($option eq "manual") { +if ($option eq 'manual') { print "Enter package file names or a blank line to finish\n"; while(1) { - print "Enter package file name:"; + print 'Enter package file name:'; my $fn = <STDIN>; chomp $fn; - if ( $fn == "") { + if ($fn == '') { exit 0; } if ( -f $fn ) { - system ("dpkg", "--merge-avail", $fn); + system('dpkg', '--merge-avail', $fn); } else { print "Could not find $fn, try again\n"; } @@ -134,36 +134,36 @@ foreach (@{$config{site}}) { } if ($must_get) { - -f "Packages.gz" and unlink "Packages.gz"; - -f "Packages" and unlink "Packages"; + -f 'Packages.gz' and unlink 'Packages.gz'; + -f 'Packages' and unlink 'Packages'; my $size = 0; TRY_GET_PACKAGES: while (1) { if ($size) { - print " Continuing "; + print ' Continuing '; } else { - print " Getting "; + print ' Getting '; } print "Packages file from $dir...\n"; eval { - if ($ftp->get("$dir/Packages.gz", "Packages.gz", $size)) { - if (system("gunzip", "Packages.gz")) { + if ($ftp->get("$dir/Packages.gz", 'Packages.gz', $size)) { + if (system('gunzip', 'Packages.gz')) { print " Couldn't gunzip Packages.gz, stopped"; - die "error"; + die 'error'; } } else { print " Couldn't get Packages.gz from $dir !!! Stopped."; - die "error"; + die 'error'; } }; if ($@) { - $size = -s "Packages.gz"; + $size = -s 'Packages.gz'; if (ref($ftp)) { $ftp->abort(); $ftp->quit(); }; - if (yesno ("y", "Transfer failed at $size: retry at once")) { + if (yesno ('y', "Transfer failed at $size: retry at once")) { $ftp = do_connect ($site->[0], # Ftp server $site->[4], # username $site->[5], # password @@ -180,15 +180,15 @@ foreach (@{$config{site}}) { } next TRY_GET_PACKAGES; } else { - die "error"; + die 'error'; } } last TRY_GET_PACKAGES; } - if(!rename "Packages", "Packages.$site->[0].$dist") { + if (!rename 'Packages', "Packages.$site->[0].$dist") { print " Couldn't rename Packages to Packages.$site->[0].$dist"; - die "error"; + die 'error'; } else { # set local Packages file to same date as the one it mirrors # to allow comparison to work. @@ -228,11 +228,11 @@ However if you have only downloaded a Package files from non-main distributions you might not want to do this. EOM - if (yesno ("y", "Do you want to clear available list")) { + if (yesno ('y', 'Do you want to clear available list')) { print "Clearing...\n"; - if(system("dpkg", "--clear-avail")) { - print "dpkg --clear-avail failed."; - die "error"; + if (system('dpkg', '--clear-avail')) { + print 'dpkg --clear-avail failed.'; + die 'error'; } } } @@ -243,7 +243,7 @@ if (!$packages_modified) { my $file; foreach $file (@pkgfiles) { - if(system ("dpkg", "--merge-avail", $file)) { + if (system('dpkg', '--merge-avail', $file)) { print "Dpkg merge available failed on $file"; $exit = 1; } |