[devscripts] 03/06: uscan: filepattern without (.*)
Osamu Aoki
osamu at moszumanska.debian.org
Sun Nov 8 14:49:49 UTC 2015
This is an automated email from the git hooks/post-receive script.
osamu pushed a commit to branch multitar
in repository devscripts.
commit 8a3c05fc57aeeba1a4dda0758807bef817c201f5
Author: Osamu Aoki <osamu at debian.org>
Date: Sun Nov 8 00:25:27 2015 +0900
uscan: filepattern without (.*)
Fix #526450 and #803948: Please support version pattern matching in any
position of the URL
If filepattern is without (.*) match excliding the non-capturing
(?:.*) match, we need to generate the downloaded filename with the
version from the full download URL. This introduces the state
variable $versionless.
Since the full download URL is needed, move the filenamemangle code
after the downloadurlmangle one to use $upstream_url if needed
instead of $newversion.
---
scripts/uscan.pl | 115 +++++++++++++++++++++++++++++++------------------------
1 file changed, 64 insertions(+), 51 deletions(-)
diff --git a/scripts/uscan.pl b/scripts/uscan.pl
index e40fcb0..6e0c2e8 100755
--- a/scripts/uscan.pl
+++ b/scripts/uscan.pl
@@ -2282,6 +2282,7 @@ sub process_watchline ($$$$$$)
my ($request, $response);
my ($newfile, $newversion);
my $style='new';
+ my $versionless = 0;
my $urlbase;
my $headers = HTTP::Headers->new;
@@ -2465,10 +2466,13 @@ sub process_watchline ($$$$$$)
}
# Check $filepattern is OK
- if ( $filepattern !~ /\(.*\)/ and
- not exists $options{'filenamemangle'}) {
- uscan_warn "Filename pattern missing version delimiters () without filenamemangle\n in $watchfile, skipping:\n $line\n";
- return 1;
+ if ( $filepattern !~ /\([^?].*\)/) {
+ if (exists $options{'filenamemangle'}) {
+ $versionless = 1;
+ } else {
+ uscan_warn "Filename pattern missing version delimiters () without filenamemangle\n in $watchfile, skipping:\n $line\n";
+ return 1;
+ }
}
# Check validity of options
@@ -2769,9 +2773,13 @@ sub process_watchline ($$$$$$)
} else {
# need the map { ... } here to handle cases of (...)?
# which may match but then return undef values
- $mangled_version =
- join(".", map { $_ if defined($_) }
- $href =~ m&^$_pattern$&);
+ if ($versionless) {
+ $mangled_version = '';
+ } else {
+ $mangled_version =
+ join(".", map { $_ if defined($_) }
+ $href =~ m&^$_pattern$&);
+ }
foreach my $pat (@{$options{'uversionmangle'}}) {
uscan_verbose "uversionmangle rule $pat\n";
if (! safe_replace(\$mangled_version, $pat)) {
@@ -2957,50 +2965,6 @@ EOF
return 1;
}
}
- # $newversion = version used for pkg-ver.tar.gz and version comparison
- uscan_verbose "Newest upstream tarball version selected for download (uversionmangled): $newversion\n" if defined $newversion;
- uscan_verbose "Download filename (fullpath, pre-filenamemangle): $newfile\n";
-
- my $newfile_base;
- if (exists $options{'filenamemangle'}) {
- $newfile_base = $newfile;
- foreach my $pat (@{$options{'filenamemangle'}}) {
- uscan_verbose "filenamemangle rule $pat\n";
- if (! safe_replace(\$newfile_base, $pat)) {
- uscan_warn "In $watchfile, potentially"
- . " unsafe or malformed filenamemangle"
- . " pattern:\n '$pat'"
- . " found. Skipping watchline\n"
- . " $line\n";
- return 1;
- }
- }
- unless ($newversion) {
- # uversionmangles version not exist
- $newfile_base =~ m/^.+[-_]([^-_]+)(?:\.tar\.(gz|bz2|xz)|\.zip)$/i;
- $newversion = $1;
- unless ($newversion) {
- uscan_warn "Fix filenamemangle to produce a filename with the correct version\n";
- return 1;
- }
- uscan_verbose "Newest upstream tarball version from the filenamemangled filename: $newversion\n";
- }
- } else {
- $newfile_base = basename($newfile);
- # Remove HTTP header trash
- if ($site =~ m%^https?://%) {
- $newfile_base =~ s/[\?#].*$//; # PiPy
- # just in case this leaves us with nothing
- if ($newfile_base eq '') {
- uscan_warn "No good upstream filename found after removing tailing ?... and #....\n Use filenamemangle to fix this.\n";
- return 1;
- }
- }
- }
- uscan_verbose "Download filename (filenamemangled): $newfile_base\n";
- unless (defined $common_newversion) {
- $common_newversion = $newversion;
- }
# Determin download URL for tarball or signature
my $upstream_url;
@@ -3081,6 +3045,55 @@ EOF
}
uscan_verbose "Upstream URL (downloadurlmangled):\n $upstream_url\n";
+ # $newversion = version used for pkg-ver.tar.gz and version comparison
+ uscan_verbose "Newest upstream tarball version selected for download (uversionmangled): $newversion\n" if defined $newversion;
+ uscan_verbose "Download filename (fullpath, pre-filenamemangle): $newfile\n";
+
+ my $newfile_base;
+ if (exists $options{'filenamemangle'}) {
+ if ($versionless) {
+ $newfile_base = $upstream_url;
+ } else {
+ $newfile_base = $newfile;
+ }
+ foreach my $pat (@{$options{'filenamemangle'}}) {
+ uscan_verbose "filenamemangle rule $pat\n";
+ if (! safe_replace(\$newfile_base, $pat)) {
+ uscan_warn "In $watchfile, potentially"
+ . " unsafe or malformed filenamemangle"
+ . " pattern:\n '$pat'"
+ . " found. Skipping watchline\n"
+ . " $line\n";
+ return 1;
+ }
+ }
+ unless ($newversion) {
+ # uversionmangles version not exist
+ $newfile_base =~ m/^.+[-_]([^-_]+)(?:\.tar\.(gz|bz2|xz)|\.zip)$/i;
+ $newversion = $1;
+ unless ($newversion) {
+ uscan_warn "Fix filenamemangle to produce a filename with the correct version\n";
+ return 1;
+ }
+ uscan_verbose "Newest upstream tarball version from the filenamemangled filename: $newversion\n";
+ }
+ } else {
+ $newfile_base = basename($newfile);
+ # Remove HTTP header trash
+ if ($site =~ m%^https?://%) {
+ $newfile_base =~ s/[\?#].*$//; # PiPy
+ # just in case this leaves us with nothing
+ if ($newfile_base eq '') {
+ uscan_warn "No good upstream filename found after removing tailing ?... and #....\n Use filenamemangle to fix this.\n";
+ return 1;
+ }
+ }
+ }
+ uscan_verbose "Download filename (filenamemangled): $newfile_base\n";
+ unless (defined $common_newversion) {
+ $common_newversion = $newversion;
+ }
+
$dehs_tags{'debian-uversion'} = $lastversion;
$dehs_tags{'debian-mangled-uversion'} = $mangled_lastversion;
$dehs_tags{'upstream-version'} = $newversion;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git
More information about the devscripts-devel
mailing list