new set of changes
Hi all,
Attached is a patch making the following changes:
* correctly parse line continuations
* avoid trying to perform any extra check on version 1 watch files
* know about versionmangle when checking if there is any mangling because of
$repack
* add line information to some of the tags
* attempt to detect when watch file tries to access a sf.net mirror directly
(projectfoo.sf.net/some_file-(.+) and similar of course don't cause false
positives)
* debian-watch-file-specifies-wrong-upstream-version
* debian-watch-file-specifies-old-upstream-version
The changes to testset/scripts/debian/changelog were made to make it easier
to notice that it *is* a !native package.
Cheers,
--
Atomo64 - Raphael
Please avoid sending me Word, PowerPoint or Excel attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
diff --git a/checks/watch-file b/checks/watch-file
index 0177bd9..7b01a90 100644
--- a/checks/watch-file
+++ b/checks/watch-file
@@ -51,15 +51,19 @@ if ($version =~ /(dfsg|debian|ds)/) {
# diagnose on the first time through.
open(WATCH, '<', 'debfiles/watch') or fail("cannot open watch file: $!");
local $_;
-my ($watchver, $mangle, $dmangle, $nonempty);
+my ($watchver, $mangle, $dmangle, $nonempty, %dversions);
while (<WATCH>) {
next if /^\s*\#/;
next if /^\s*$/;
s/^\s*//;
+
+ CHOMP:
+ chomp;
if (s/(?<!\\)\\$//) {
# This is caught by uscan.
last if eof(WATCH);
$_ .= <WATCH>;
+ goto CHOMP;
}
if (/^version\s*=\s*(\d+)(\s|\Z)/) {
@@ -77,24 +81,38 @@ while (<WATCH>) {
tag 'debian-watch-file-missing-version';
$watchver = 1;
}
- while (s/\\\s*$//) {
- $_ .= <WATCH>;
- }
- chomp;
+ # version 1 watch files are broken enough to even try to check them
+ next if ($watchver == 1);
+
my ($opts, @opts);
- if (s/^opt(ion)?s=\"([^\"]+)\"\s+// || s/^opt(ion)?s=(\S+)\s+//) {
- $opts = $2;
+ if (s/^opt(?:ion)?s=\"([^\"]+)\"\s+// || s/^opt(?:ion)?s=(\S+)\s+//) {
+ $opts = $1;
@opts = split(',', $opts);
if (defined $repack) {
for (@opts) {
- $mangle = 1 if /^[ud]versionmangle.*=.*($repack)/;
- $dmangle = 1 if /^dversionmangle.*=.*($repack)/;
+ $mangle = 1 if /^[ud]?versionmangle\s*=.*($repack)/;
+ $dmangle = 1 if /^dversionmangle\s*=.*($repack)/;
}
}
}
if (m%qa\.debian\.org/watch/sf\.php\?%) {
- tag 'debian-watch-file-uses-deprecated-sf-redirector-method';
+ tag 'debian-watch-file-uses-deprecated-sf-redirector-method', "line $.";
}
+
+ if (m%(https?|ftp)://((.+\.)?dl|prdownloads|ftp\d?|downloads?)\.(sourceforge|sf)\.net%) {
+ tag 'debian-watch-file-should-use-sf-redirector', "line $.";
+ }
+
+ # this bit is as-is from uscan.pl:
+ my ($base, $filepattern, $lastversion, $action) = split ' ', $_, 4;
+ if ($base =~ s%/([^/]*\([^/]*\)[^/]*)$%/%) {
+ # Last component of $base has a pair of parentheses, so no
+ # separate filepattern field; we remove the filepattern from the
+ # end of $base and rescan the rest of the line
+ $filepattern = $1;
+ (undef, $lastversion, $action) = split ' ', $_, 3;
+ }
+ push @{$dversions{$lastversion}}, $. if (defined($lastversion));
}
}
close WATCH;
@@ -104,10 +122,42 @@ close WATCH;
if ($nonempty and $repack and not $mangle) {
tag 'debian-watch-file-should-mangle-version';
}
+
if ($repack and $mangle and not $dmangle) {
tag 'debian-watch-file-should-dversionmangle-not-uversionmangle';
}
+my $changes = $info->changelog;
+if (defined $changes && %dversions) {
+ my $data = $changes->data;
+ my %changelog_versions;
+ my $count = 1;
+ for my $entry (@{$data}) {
+ my $uversion = $entry->Version;
+ $uversion =~ s/-[^-]+$//; # revision
+ $uversion =~ s/^\d+://; # epoch
+ $changelog_versions{'orig'}{$entry->Version} = $count;
+ # preserve the first value here, as to correctly detect old versions
+ $changelog_versions{'mangled'}{$uversion} = $count
+ unless (exists($changelog_versions{'mangled'}{$uversion}));
+ $count++;
+ }
+
+ while (my ($dversion, $lines) = each %dversions) {
+ next if (!defined($dversion) || $dversion eq 'debian');
+ local $" = ', ';
+ if (!$info->native && exists($changelog_versions{'orig'}{$dversion})) {
+ tag 'debian-watch-file-specifies-wrong-upstream-version', "$dversion: @{$lines}";
+ next;
+ }
+ if (exists($changelog_versions{'mangled'}{$dversion})
+ && $changelog_versions{'mangled'}{$dversion} != 1) {
+ tag 'debian-watch-file-specifies-old-upstream-version', "$dversion: @{$lines}";
+ next;
+ }
+ }
+}
+
}
1;
diff --git a/checks/watch-file.desc b/checks/watch-file.desc
index 83e7874..1bb4863 100644
--- a/checks/watch-file.desc
+++ b/checks/watch-file.desc
@@ -82,3 +82,26 @@ Info: The watch file seems to be passing arguments to the redirector
other than a path. Calling the SourceForge redirector with parameters like
<tt>project</tt> prevents uscan from generating working uri's to the files
and thus has been deprecated and is no longer supported by the redirector.
+
+Tag: debian-watch-file-should-use-sf-redirector
+Type: warning
+Ref: uscan(1)
+Info: The watch file seems to be using a sourceforge download server directly.
+ It is discouraged to use them directly as they are known to change time by time
+ requiring the watch files to be modified everytime they change. It is
+ recommended to use the sourceforge redirector instead.
+
+Tag: debian-watch-file-specifies-wrong-upstream-version
+Type: warning
+Ref: uscan(1)
+Info: The watch file specifies a upstream version which matches a
+ <tt>debian/changelog</tt> entry and is very likely to be incorrect as no
+ version mangling (unless specified via d/versionmangle) is done.
+
+Tag: debian-watch-file-specifies-old-upstream-version
+Type: warning
+Ref: uscan(1)
+Info: The watch file specifies a upstream version which matches an old
+ <tt>debian/changelog</tt> entry thus being very likely to be incorrect and
+ undesired. Leaving an old version will cause DEHS and similar projects
+ to state that the package is out of date even when it might not be.
diff --git a/testset/dh7-test/debian/watch b/testset/dh7-test/debian/watch
index 0915699..d7fea6a 100644
--- a/testset/dh7-test/debian/watch
+++ b/testset/dh7-test/debian/watch
@@ -2,4 +2,4 @@
# package version number.
version=2
-http://www.example.com/dist/ dh7-test\.([\d.]+)\.tar\.gz
+http://www.example.com/dist/ dh7-test\.([\d.]+)\.tar\.gz 1.dfsg-1 uupdate
diff --git a/testset/scripts/debian/changelog b/testset/scripts/debian/changelog
index cbdb6d1..9c6bc54 100644
--- a/testset/scripts/debian/changelog
+++ b/testset/scripts/debian/changelog
@@ -7,34 +7,34 @@ scripts (6ds-1ubuntu0.5.10.1) unstable; urgency=low
-- Mark 'HE' Brokschmitt <he@debian.org> Thu, 23 Jun 2005 14:32:39 +0200
-scripts (5) unstable; urgency=low
+scripts (5-1) unstable; urgency=low
* I'm making a typo in my own name... And I want lintian to warn me about
it.
-- Jeroen van Wolffelaar <jeroen@wolffelaar.nl> Sun, 18 Apr 2004 02:26:34 +0200
-scripts (4) unstable; urgency=low
+scripts (4-1) unstable; urgency=low
* Add new example to check that not executable files with a shebang line
called *in don't trigger the script-not-executable warning.
-- Marc 'HE' Brockschmidt <he@debian.org> Wed, 14 Apr 2004 19:44:04 +0200
-scripts (3) unstable; urgency=low
+scripts (3-3) unstable; urgency=low
* Add suidperlfoo and some code in debian/rules to
check the new suidperl checks
-- Frank Lichtenheld <djpig@debian.org> Wed, 31 Mar 2004 21:06:20 +0000
-scripts (2) unstable; urgency=low
+scripts (2-1) unstable; urgency=low
* Add tkfoo script for tk checkings
-- Lintian Maintainers <lintian-maint@debian.org> Sat, 21 Feb 2004 17:13:36 +0100
-scripts (1) unstable; urgency=low
+scripts (1-0) unstable; urgency=low
* Initial version
diff --git a/testset/scripts/debian/watch b/testset/scripts/debian/watch
index 5a587ad..dba5815 100644
--- a/testset/scripts/debian/watch
+++ b/testset/scripts/debian/watch
@@ -2,5 +2,7 @@
version=2
opts="uversionmangle=s/$/ds/" \
-http://qa.debian.org/watch/sf.php?project=foo scripts\.([\d.]+)\.tar\.gz
+http://qa.debian.org/watch/sf.php?project=foo scripts\.([\d.]+)\.tar\.gz debian uupdate
+version=3
+http://ftp.sf.net/foo/foo_bar(.+)\.Z 5 uupdate
\ No newline at end of file
diff --git a/testset/tags.dh7-test b/testset/tags.dh7-test
index 15cf288..3f7ddad 100644
--- a/testset/tags.dh7-test
+++ b/testset/tags.dh7-test
@@ -1,6 +1,7 @@
W: dh7-test source: changelog-should-mention-nmu
W: dh7-test source: debhelper-script-needs-versioned-build-depends dh (>= 7)
W: dh7-test source: debian-watch-file-should-mangle-version
+W: dh7-test source: debian-watch-file-specifies-wrong-upstream-version 1.dfsg-1: 5
W: dh7-test source: no-human-maintainers
W: dh7-test source: source-nmu-has-incorrect-version-number 1.dfsg-1
W: dh7-test: new-package-should-close-itp-bug
diff --git a/testset/tags.scripts b/testset/tags.scripts
index bfb4eca..74ba588 100644
--- a/testset/tags.scripts
+++ b/testset/tags.scripts
@@ -25,7 +25,10 @@ I: scripts: script-in-usr-share-doc usr/share/doc/scripts/py2foo
I: scripts: script-in-usr-share-doc usr/share/doc/scripts/rubyfoo
W: scripts source: ancient-standards-version 3.2.1 (current is 3.8.0)
W: scripts source: binary-arch-rules-but-pkg-is-arch-indep
-W: scripts source: debian-watch-file-uses-deprecated-sf-redirector-method
+W: scripts source: debian-watch-file-declares-multiple-versions line 7
+W: scripts source: debian-watch-file-should-use-sf-redirector line 8
+W: scripts source: debian-watch-file-specifies-old-upstream-version 5: 8
+W: scripts source: debian-watch-file-uses-deprecated-sf-redirector-method line 5
W: scripts source: dpatch-missing-description 02_i_dont_have_a_description.patch
W: scripts source: maintainer-script-lacks-debhelper-token debian/postinst
W: scripts source: maintainer-script-lacks-debhelper-token debian/postrm
Reply to: