Package: devscripts
Version: 2.13.0
Severity: wishlist
Tags: patch
Hi,
Following my previous patch, I also added a new uscan option, uselinktext,
that makes uscan to also search the version in the text contained in the
<a>...</a>, instead only checking the href value.
A bit of a complex example would be:
version=3
opts=uselinktext,filenamemangle=s!.*/([^/]*)$!xawtv-$1\.tar\.gz!,downloadurlmangle=s!commit/([^/]*)!snapshot/$1\.tar\.gz!
\
http://git.linuxtv.org/xawtv3.git/tags xawtv-([\d.]+)
Thanks and happy hacking,
commit 113554c68392dfd80351968c2088b3648ba46b7c
Author: Maximiliano Curia <[email protected]>
Date: Tue Apr 23 10:36:46 2013 +0200
Basic use link text support
diff --git a/scripts/uscan.pl b/scripts/uscan.pl
index 03f2ea4..c782db7 100755
--- a/scripts/uscan.pl
+++ b/scripts/uscan.pl
@@ -1,4 +1,5 @@
#! /usr/bin/perl -w
+# vi:sw=4 ts=8 noet
# uscan: This program looks for watchfiles and checks upstream ftp sites
# for later versions of the software.
@@ -749,6 +750,9 @@ sub process_watchline ($$$$$$)
or $opt eq 'nopassive') {
$options{'pasv'}=0;
}
+ elsif ($opt eq 'uselinktext') {
+ $options{'uselinktext'}=1;
+ }
elsif ($opt =~ /^uversionmangle\s*=\s*(.+)/) {
@{$options{'uversionmangle'}} = split /;/, $1;
}
@@ -944,11 +948,11 @@ sub process_watchline ($$$$$$)
# which may match but then return undef values
my $mangled_version =
join(".", map { $_ if defined($_) }
- $href =~ m&^$_pattern$&);
+ $href =~ m&^$_pattern$&);
foreach my $pat (@{$options{'uversionmangle'}}) {
if (! safe_replace(\$mangled_version, $pat)) {
warn "$progname: In $watchfile, potentially"
- . " unsafe or malformed uversionmangle"
+ . " unsafe or malformed uversionmangle"
. " pattern:\n '$pat'"
. " found. Skipping watchline\n"
. " $line\n";
@@ -960,6 +964,34 @@ sub process_watchline ($$$$$$)
}
}
}
+ if (exists $options{'uselinktext'}) {
+ while ($content =~
+ m/<\s*a\s+[^>]*href\s*=\s*([\"\'])(.*?)\1[^>]*>([^<]*)<\/a>/sgi) {
+ my $href = $2;
+ my $atext = $3;
+ $href =~ s/\n//g;
+ $atext =~ s/\n//g;
+ foreach my $_pattern (@patterns) {
+ if ($atext =~ m&^$_pattern$&) {
+ my $mangled_version =
+ join(".", map { $_ if defined($_) }
+ $atext =~ m&^$_pattern$&);
+ foreach my $pat (@{$options{'uversionmangle'}}) {
+ if (! safe_replace(\$mangled_version, $pat)) {
+ warn "$progname: In $watchfile, potentially"
+ . " unsafe or malformed uversionmangle"
+ . " pattern:\n '$pat'"
+ . " found. Skipping watchline\n"
+ . " $line\n";
+ return 1;
+ }
+ }
+ push @hrefs, [$mangled_version, $href];
+ }
+ }
+
+ }
+ }
if (@hrefs) {
if ($verbose) {
print "-- Found the following matching hrefs:\n";
_______________________________________________
devscripts-devel mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/devscripts-devel