[Dehs-devel] SVN devscripts commit: r370 - in trunk: . debian

Julian Gilbey jdg at costa.debian.org
Fri Mar 31 12:53:09 UTC 2006


Author: jdg
Date: 2006-03-31 12:53:07 +0000 (Fri, 31 Mar 2006)
New Revision: 370

Modified:
   trunk/debian/changelog
   trunk/uscan.1
   trunk/uscan.pl
Log:
* uscan: provide filenamemangle option to mangle the filename before
  attempting to save the download (Closes: #327404)

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2006-03-31 09:20:06 UTC (rev 369)
+++ trunk/debian/changelog	2006-03-31 12:53:07 UTC (rev 370)
@@ -9,8 +9,10 @@
   * mass-bug: new script (Closes: #355505)
   * pts-subscribe.1: improve the wording of the manpage (Closes: #360027)
   * uscan: *really* fix the uninitialized value bug (Closes: #356959)
+  * uscan: provide filenamemangle option to mangle the filename before
+    attempting to save the download (Closes: #327404)
 
- -- Julian Gilbey <jdg at debian.org>  Fri, 31 Mar 2006 10:19:43 +0100
+ -- Julian Gilbey <jdg at debian.org>  Fri, 31 Mar 2006 13:52:41 +0100
 
 devscripts (2.9.16) unstable; urgency=low
 

Modified: trunk/uscan.1
===================================================================
--- trunk/uscan.1	2006-03-31 09:20:06 UTC (rev 369)
+++ trunk/uscan.1	2006-03-31 12:53:07 UTC (rev 370)
@@ -78,7 +78,7 @@
 # concatenated before mangling is performed, and that mangling will
 # only be performed on the basename version number, not any path
 # version numbers.)
-opts="uversionmangle=s/^/0.0/" \\
+opts="uversionmangle=s/^/0.0./" \\
   ftp://ftp.ibiblio.org/pub/Linux/ALPHA/wine/development/Wine-(.*)\\.tar\\.gz
 
 # Similarly, the upstream part of the Debian version number can be
@@ -86,6 +86,17 @@
 opts=dversionmangle=s/\\.dfsg\\.\\d+$// \\
   http://some.site.org/some/path/foobar-(.*)\\.tar\\.gz
 
+# Handling cases where the URL would not make a usable filename
+# <A href="http://foo.bar.org/download/?path=&amp;download=foo-0.1.1.tar.gz">
+# could be handled as:
+# opts=filenamemangle=s/.*=(.*)/$1/ \
+#     http://foo.bar.org/download/\?path=&amp;download=foo-(.*)\.tar\.gz
+# 
+# <A href="http://foo.bar.org/download/?path=&amp;download_version=0.1.1">
+# could be handled as:
+# opts=filenamemangle=s/.*=(.*)/foo-$1\.tar\.gz/ \
+#    http://foo.bar.org/download/\?path=&amp;download_version=(.*)
+
 .fi
 .PP
 Comment lines may be introduced with a `#' character.  Continuation
@@ -218,6 +229,12 @@
 `.dfsg.1' suffix from the Debian version number, or to handle `.pre6'
 type version numbers.  Again, the \fIrules\fR string may not contain
 commas; this should not be a problem.
+.TP
+\fBfilenamemangle=\fIrules\fR
+This is used to mangle the filename with which the downloaded file
+will be saved, and is parsed in the same way as the
+\fBuversionmangle\fR option.  Examples of its use are given in the
+examples above.
 .SH "Directory name checking"
 Similarly to several other scripts in the \fBdevscripts\fR package,
 \fBuscan\fR explores the requested directory trees looking for

Modified: trunk/uscan.pl
===================================================================
--- trunk/uscan.pl	2006-03-31 09:20:06 UTC (rev 369)
+++ trunk/uscan.pl	2006-03-31 12:53:07 UTC (rev 370)
@@ -571,15 +571,26 @@
 # concatenated before mangling is performed, and that mangling will
 # only be performed on the basename version number, not any path version
 # numbers.)
-# opts=uversionmangle=s/^/0.0/ \
+# opts=uversionmangle=s/^/0.0./ \
 #   ftp://ftp.ibiblio.org/pub/Linux/ALPHA/wine/development/Wine-(.*)\.tar\.gz
 # 
 # Similarly, the upstream part of the Debian version number can be
 # mangled:
 # opts=dversionmangle=s/\.dfsg\.\d+$// \
 #   http://some.site.org/some/path/foobar-(.*)\.tar\.gz
+# 
+# The option filenamemangle can be used to mangle the name under which
+# the downloaded file will be saved:
+#   href="http://foo.bar.org/download/?path=&amp;download=foo-0.1.1.tar.gz"
+# could be handled as:
+# opts=filenamemangle=s/.*=(.*)/$1/ \
+#     http://foo.bar.org/download/\?path=&amp;download=foo-(.*)\.tar\.gz
+# and
+#   href="http://foo.bar.org/download/?path=&amp;download_version=0.1.1"
+# as:
+# opts=filenamemangle=s/.*=(.*)/foo-$1\.tar\.gz/ \
+#    http://foo.bar.org/download/\?path=&amp;download_version=(.*)
 
-
 sub process_watchline ($$$$$$)
 {
     my ($line, $watch_version, $pkg_dir, $pkg, $pkg_version, $watchfile) = @_;
@@ -651,6 +662,9 @@
 		elsif ($opt =~ /^dversionmangle\s*=\s*(.+)/) {
 		    @{$options{'dversionmangle'}} = split /;/, $1;
 		}
+		elsif ($opt =~ /^filenamemangle\s*=\s*(.+)/) {
+		    @{$options{'filenamemangle'}} = split /;/, $1;
+		}
 		else {
 		    warn "$progname warning: unrecognised option $opt\n";
 		}
@@ -842,6 +856,13 @@
     }
 
     my $newfile_base=basename($newfile);
+    if (exists $options{'filenamemangle'})
+    {
+        $newfile_base=$newfile;
+    }
+    foreach my $pat (@{$options{'filenamemangle'}}) {
+	eval "\$newfile_base =~ $pat;";
+    }
     # Remove HTTP header trash
     if ($site =~ m%^http://%)
     {
@@ -965,6 +986,9 @@
     print "-- Downloading updated package $newfile_base\n" if $verbose;
     # Download newer package
     if ($upstream_url =~ m%^http://%) {
+	# substitute HTML entities
+	# Is anything else than "&amp;" required?  I doubt it.
+	$upstream_url =~ s/&amp;/&/g;
 	print STDERR "$progname debug: requesting URL $upstream_url\n" if $debug;
 	$request = HTTP::Request->new('GET', $upstream_url);
 	$response = $user_agent->request($request, "../$newfile_base");




More information about the Dehs-devel mailing list