-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Tags: patch
I have created a patch in order to support this request. I've introduced an option called fullsourcemangle (any recommendations for something more meaningful are more than welcome ) whose existence tells the program to search in the full source instead of just in the href="..." urls and the actual mangle is used to generate the href link from the text matched. For Axel's request, the watch file would be: - ---snip--- version=3 opts=fullsourcemangle=s/.*/wiki/ \ http://www.256bit.org/~chrisbra/wiki VERSION=([\d\.]+) debian uupdate - ---snap--- I checked and it works for two of the packages I maintain and they have no version information in the link (guifications and myspell-el-gr) and for wikipedia2text package. I am not a perl expert, so please let me know of any problems/suggestions for the code. Now the ideal would be to have a way to specify the upstream version in the second option of filenamemangle so that we save the downloaded file in a name containing the actual version, but this is another story :) - -- =Do- N.AND -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkxDKWAACgkQrdZ2oYS0I7J7GwCdHxvDKThIS5upppLjX4pJrwRs mCsAnjbAv1KSDtRGE+A/7p2fjAlThnPF =s5z/ -----END PGP SIGNATURE-----
--- usr/bin/uscan 2009-10-08 23:26:42.000000000 +0200 +++ home/andrikos/temp/uscan 2010-07-18 17:59:25.000000000 +0200 @@ -6,6 +6,7 @@ # Originally written by Christoph Lameter <clame...@debian.org> (I believe) # Modified by Julian Gilbey <j...@debian.org> # HTTP support added by Piotr Roszatycki <dex...@debian.org> +# Full source search support by Nick Andrik <nick.and...@gmail.com> # Rewritten in Perl, Copyright 2002-2006, Julian Gilbey # # This program is free software; you can redistribute it and/or modify @@ -675,6 +676,13 @@ # opts=downloadurlmangle=s/prdownload/download/ \ # http://developer.berlios.de/project/showfiles.php?group_id=2051 \ # http://prdownload.berlios.de/softdevice/vdr-softdevice-(.*).tgz +# +# The option fullsourcemangle can be used to search in the full text of the page +# (not just in the href="..." URLs). The substitution has to compute the URL of +# the file from the matching text. For example: +# opts=fullsourcemangle=s/.*"(.*)".*/$1/ \ +# http://foo.bar.org/trac/downloads \ +# <a\s+href="/trac/downloads/[\d]+">\s*foo-([\d\.]+)\.tar\.bz2\s*</a> sub process_watchline ($$$$$$) @@ -764,6 +772,9 @@ elsif ($opt =~ /^downloadurlmangle\s*=\s*(.+)/) { @{$options{'downloadurlmangle'}} = split /;/, $1; } + elsif ($opt =~ /^fullsourcemangle\s*=\s*(.+)/) { + @{$options{'fullsourcemangle'}} = split /;/, $1; + } else { warn "$progname warning: unrecognised option $opt\n"; } @@ -893,33 +904,63 @@ print STDERR "$progname debug: matching pattern(s) @patterns\n" if $debug; my @hrefs; - while ($content =~ m/<\s*a\s+[^>]*href\s*=\s*([\"\'])(.*?)\1/sgi) { - my $href = $2; - $href =~ s/\n//g; - foreach my $_pattern (@patterns) { - if ($href =~ m&^$_pattern$&) { - if ($watch_version == 2) { - # watch_version 2 only recognised one group; the code - # below will break version 2 watchfiles with a construction - # such as file-([\d\.]+(-\d+)?) (bug #327258) - push @hrefs, [$1, $href]; - } else { - # need the map { ... } here to handle cases of (...)? - # which may match but then return undef values - my $mangled_version = - join(".", map { $_ if defined($_) } - $href =~ 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; + if ( exists $options{'fullsourcemangle'} ) { + # We are searching in the whole text of the file, not just the links + while ($content =~ m/($filepattern)/sgi){ + my $href = $1; + my $mangled_version = $2; + $href =~ s/[\s\n]+/ /g; + foreach my $pat (@{$options{'fullsourcemangle'}}) { + if (! safe_replace(\$href, $pat)) { + warn "$progname: In $watchfile, potentially" + . " unsafe or malformed fullsourcemangle" + . " pattern:\n '$pat'" + . " found. Skipping watchline\n" + . " $line\n"; + return 1; + } + } + 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]; + } + } else { + while ($content =~ m/<\s*a\s+[^>]*href\s*=\s*([\"\'])(.*?)\1/sgi) { + my $href = $2; + $href =~ s/\n//g; + foreach my $_pattern (@patterns) { + if ($href =~ m&^$_pattern$&) { + if ($watch_version == 2) { + # watch_version 2 only recognised one group; the code + # below will break version 2 watchfiles with a construction + # such as file-([\d\.]+(-\d+)?) (bug #327258) + push @hrefs, [$1, $href]; + } else { + # need the map { ... } here to handle cases of (...)? + # which may match but then return undef values + my $mangled_version = + join(".", map { $_ if defined($_) } + $href =~ 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]; } - push @hrefs, [$mangled_version, $href]; } } }