Package: debmirror
Version: 20060907.1
Severity: normal

I added wget-transport in debmirror. This allows you to use debmirror
networks with unstable connect.

=begin diff

--- debmirror   2006-09-08 17:00:27.000000000 +0400
+++ debmirror.wget      2007-01-06 15:15:08.000000000 +0300
@@ -67,6 +67,7 @@
           [--proxy=http://user:[EMAIL PROTECTED]:port/] [--help]
           [--rsync-options=options] [--ignore-small-errors]
           [--pdiff=mirror|use|none]
+          [--use-wget] [--wget-options=options]
           mirrordir
 
 For details, see man page.
@@ -137,6 +138,15 @@
 server, you need to put ':' prefix in the root directory
 (i.e. ":debian", which means host::debian).
 
+=item --use-wget
+
+Use wget for http and ftp methods.
+
+=item --wget-options=options
+
+Specify alternative wget options to be used. Default options are
+"-c". See 'man wget' for more information.
+
 =item --proxy=http://user:[EMAIL PROTECTED]:port/
 
 Specifies the http proxy (like Squid) to use for http and hftp method.
@@ -403,6 +413,8 @@
 our $rsync_options="-aIL --partial";
 our $ignore_small_errors=0;
 our $pdiff_mode="use";
+our $use_wget=0;
+our $wget_options="-c";
 my @errlog;
 my $HOME;
 ($HOME = $ENV{'HOME'}) or die "HOME not defined in environment!\n";
@@ -419,6 +431,8 @@
 
 my $help;
 GetOptions('debug'        => \$debug,
+     'use-wget'     => \$use_wget,
+     'wget-options=s'   => \$wget_options,
           'progress|p'   => \$progress,
           'verbose|v'    => \$verbose,
           'source!'      => \$do_source,
@@ -911,7 +925,7 @@
        if (($dirname) = $file =~ m:(.*)/:) {
          make_dir($dirname);
        }
-       http_get($file);
+       if ($use_wget) { wget_get($file); } else { http_get($file); }
        if ($max_batch > 0 && ++$i >= $max_batch) {
          push (@errlog,"Batch limit exceeded, mirror run was partial\n");
          $num_errors++;
@@ -931,7 +945,7 @@
        if (($dirname) = $file =~ m:(.*)/:) {
          make_dir($dirname);
        }
-       ftp_get($file);
+       if ($use_wget) { wget_get($file); } else { ftp_get($file); }
        if ($max_batch > 0 && ++$i >= $max_batch) {
          push (@errlog,"Batch limit exceeded, mirror run was partial\n");
          $num_errors++;
@@ -1160,7 +1174,15 @@
     };
 
     /^http$/ && do {
-      $res=http_get($file);
+      if ($use_wget) 
+      {
+        $res=wget_get($file); 
+      }
+      else
+      {
+        $res=http_get($file);
+      }
+
       $res=$res && check_lists($file);
       if (!$res) {
        say("$file failed md5sum check, removing");
@@ -1169,7 +1191,15 @@
     };
 
     /^ftp$/ && do {
-      $res=ftp_get($file);
+      if ($use_wget) 
+      {
+        $res=wget_get($file); 
+      }
+      else
+      {
+        $res=ftp_get($file);
+      }
+
       $res=$res && check_lists($file);
       if (!$res) {
        say("$file failed md5sum check, removing");
@@ -1259,6 +1289,70 @@
   return $ret;
 }
 
+# WGGET a file via http or ftp
+sub wget_get 
+{
+  local $_;
+  my $file=shift;
+
+  my $proto=$download_method;
+  $proto=~/^hftp$/ and $proto='ftp';
+
+  my $url="$proto://${host}/${remoteroot}/${file}";
+
+  my $wget_cmd="wget $wget_options -O $file $url 2>&1";
+
+  my $percent=0;
+  $percent = sprintf("%3.0f",(($bytes_gotten/$bytes_to_get)*100))
+  unless($bytes_to_get == 0);
+
+  print "$url => " if $debug;
+  print "[$percent%] Getting: $file... " 
+    if ($progress || $verbose);
+
+  print "'$wget_cmd'... " if $verbose;
+
+  
+  if ($dry_run)
+  {
+    print "ok\n" if $progress || $verbose;
+    return 1;
+  }
+
+  -f $file and unlink $file;
+
+  my $hwget;
+  unless (open $hwget, "-|", $wget_cmd) 
+  {
+    warn "failed: $!\n" if $progress || $verbose;
+    push @errlog, "Download of $file failed: $!";
+    $num_errors++;
+    return 0;
+  }
+ 
+  print "\n" if $debug;
+  while (<$hwget>)
+  {
+    s/\s+$//g;
+    print "$_\n" if $debug;
+  }
+  close $hwget;
+  if ($?)
+  {
+    my $emsg="'$wget_cmd' return code: $?";
+    push @errlog, $emsg;
+    $num_errors++;
+    warn "failed: $emsg\n";
+    return 0;
+  }
+  else
+  {
+    print "ok\n" if $progress || $verbose;
+    return 1;
+  }
+}
+
+
 # Get a file via ftp, first displaying its filename if progress is on.
 # I should just be able to subclass Net::Ftp and override the get method,
 # but it's late.

=end diff 


-- System Information:
Debian Release: 4.0
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.8-2-686
Locale: LANG=ru_RU.UTF-8, LC_CTYPE=ru_RU.UTF-8 (charmap=UTF-8)

Versions of packages debmirror depends on:
ii  bzip2                         1.0.3-6    high-quality block-sorting file co
ii  libcompress-zlib-perl         1.42-1     Perl module for creation and manip
ii  libdigest-sha1-perl           2.11-1     NIST SHA-1 message digest algorith
ii  liblockfile-simple-perl       0.2.5-7    Simple advisory file locking
ii  libnet-perl                   1:1.19-3   Implementation of Internet protoco
ii  libwww-perl                   5.805-1    WWW client/server library for Perl
ii  perl [libdigest-md5-perl]     5.8.8-6.1  Larry Wall's Practical Extraction 
ii  perl-modules [libnet-perl]    5.8.8-6.1  Core Perl modules
ii  rsync                         2.6.9-2    fast remote file copy program (lik

Versions of packages debmirror recommends:
ii  gnupg                         1.4.5-3    GNU privacy guard - a free PGP rep
ii  patch                         2.5.9-4    Apply a diff file to an original

-- no debconf information


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to