Author: adam-guest
Date: 2008-06-28 09:29:55 +0000 (Sat, 28 Jun 2008)
New Revision: 1535

Modified:
   trunk/debian/changelog
   trunk/scripts/uscan.1
   trunk/scripts/uscan.pl
Log:
Update enhanced-matching patch again

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog      2008-06-27 19:52:03 UTC (rev 1534)
+++ trunk/debian/changelog      2008-06-28 09:29:55 UTC (rev 1535)
@@ -37,8 +37,8 @@
       based projects to the manpage
     + If the site being checked redirects to another with a directory
       structure that does not match the original site, check for download URLs
-      that refer to the redirected site rather than the original. Based on a
-      patch by Raphael Geissert (Closes: #487436)
+      that refer to any of the redirected sites, in addition to the original
+      site. Based on a patch by Raphael Geissert (Closes: #487436)
   * debian/control
     + Suggest libnet-smtp-ssl-perl (>= 1.01-2) in order to allow bts to
       suport SMTPS. The versioned dependency is required in order to ensure

Modified: trunk/scripts/uscan.1
===================================================================
--- trunk/scripts/uscan.1       2008-06-27 19:52:03 UTC (rev 1534)
+++ trunk/scripts/uscan.1       2008-06-28 09:29:55 UTC (rev 1535)
@@ -68,18 +68,16 @@
   Twisted-([\\d\\.]*)\\.tar\\.bz2
 
http://tmrc.mit.edu/mirror/twisted/Twisted/(\\d\.\\d)/Twisted-([\\d\\.]*)\\.tar\\.bz2
 
-# If your package is located on SourceForge, you can use the following
-# format. Note that the trailing .* is required.
-http://downloads.sourceforge.net/audacity/audacity-src-(.+)\\.tar\\.gz\\.*
-
 # qa.debian.org runs a redirector which allows a simpler form of URL
 # for SourceForge based projects. The format below will automatically
-# be rewritten to use the redirector. Note that the format in the
-# previous example, whilst slightly more complicated, is recommended
-# instead of this one as it does not rely on a particular SourceForge
-# mirror being available
+# be rewritten to use the redirector.
 http://sf.net/audacity/ audacity-src-(.+)\\.tar\\.gz
 
+# If your package is located on SourceForge and the redirector
+# isn't working for you, you can use the following format. Note
+# that the trailing .* is required.
+http://downloads.sourceforge.net/audacity/audacity-src-(.+)\\.tar\\.gz\\.*
+
 # This is the format for a site which has funny version numbers;
 # the parenthesised groups will be joined with dots to make a
 # sanitised version number

Modified: trunk/scripts/uscan.pl
===================================================================
--- trunk/scripts/uscan.pl      2008-06-27 19:52:03 UTC (rev 1534)
+++ trunk/scripts/uscan.pl      2008-06-28 09:29:55 UTC (rev 1535)
@@ -359,7 +359,30 @@
 #   else { delete $ENV{'FTP_PASSIVE'}; }
 # to restore $ENV{'FTP_PASSIVE'} to what it was at this point
 
-my $user_agent = LWP::UserAgent->new(env_proxy => 1);
+# dummy subclass used to store all the redirections for later use
+package LWP::UserAgent::UscanCatchRedirections;
+
+use base 'LWP::UserAgent';
+
+my @uscan_redirections;
+
+sub redirect_ok {
+    my $self = shift;
+    my ($request) = @_;
+    if ($self->SUPER::redirect_ok(@_)) {
+       push @uscan_redirections, $request->uri;
+       return 1;
+    }
+    return 0;
+}
+
+sub get_redirections {
+    return [EMAIL PROTECTED];
+}
+
+package main;
+
+my $user_agent = LWP::UserAgent::UscanCatchRedirections->new(env_proxy => 1);
 $user_agent->timeout($timeout);
 $user_agent->agent($user_agent_string);
 
@@ -653,7 +676,7 @@
 
     my $origline = $line;
     my ($base, $site, $dir, $filepattern, $pattern, $lastversion, $action);
-    my (@patterns, @sites, $response_uri);
+    my (@patterns, @sites, @redirections);
     my %options = ();
 
     my ($request, $response);
@@ -766,7 +789,7 @@
        }
 
        # Handle sf.net addresses specially
-       $base =~ s%^http://sf\.net/%http://qa.debian.org/watch/sf.php/%;
+       $base =~ 
s%^http://sf\.net/([^/]+)/(.*)%http://qa.debian.org/watch/sf.php/$1/$2\?.*%;
        if ($base =~ m%^(\w+://[^/]+)%) {
            $site = $1;
        } else {
@@ -810,19 +833,16 @@
            return 1;
        }
 
-       $response_uri = $response->base;
-       if (! defined($response_uri)) {
-           warn "$progname warning: In watchfile $watchfile, failed to get 
base URI: \n";
-       }
+       @redirections = @{$user_agent->get_redirections};
        
-       print STDERR "$progname debug: base URI: $response_uri\n"
+       print STDERR "$progname debug: redirections: @redirections\n"
            if $debug;
 
-       if (defined($response_uri)) {
-           my $base_dir = $response_uri;
+       foreach my $_redir (@redirections) {
+           my $base_dir = $_redir;
            
            $base_dir =~ s%^\w+://[^/]+/%/%;
-           if ($response_uri =~ m%^(\w+://[^/]+)%) {
+           if ($_redir =~ m%^(\w+://[^/]+)%) {
                my $base_site = $1;
 
                push @patterns, "(?:(?:$base_site)?" . quotemeta($base_dir) . 
")?$filepattern";
@@ -1043,7 +1063,7 @@
            $upstream_url = $newfile;
        }
        # absolute filename?
-       elsif ($newfile =~ m%^/%) {
+       elsif ($newfile =~ m%^/% and $#patterns > 1) {
            # replace $site here with the one we were redirected to
            foreach my $index (0 .. $#patterns) {
                if ("$sites[$index]$newfile" =~ m&^$patterns[$index]$&) {
@@ -1052,7 +1072,10 @@
                }
            }
            if (!defined($upstream_url)) {
-               warn "$progname warning: Unable to determine upstream url\n" if 
$debug;
+               if ($debug) {
+                   warn "$progname warning: Unable to determine upstream url 
from redirections,\n" .
+                       "defaulting to using site specified in watchfile\n";
+               }
                $upstream_url = "$sites[0]$newfile";
            }
        }



-- 
To unsubscribe, send mail to [EMAIL PROTECTED]

Reply via email to