[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

lintian: r954 - in trunk: checks collection debian testset testset/binary/debian testset/filenames/debian



Author: rra
Date: 2007-10-15 02:32:39 +0200 (Mon, 15 Oct 2007)
New Revision: 954

Added:
   trunk/testset/binary/debian/NEWS.Debian
Modified:
   trunk/checks/changelog-file
   trunk/checks/changelog-file.desc
   trunk/collection/changelog-file
   trunk/collection/changelog-file.desc
   trunk/debian/changelog
   trunk/testset/binary/debian/rules
   trunk/testset/filenames/debian/rules
   trunk/testset/tags.binary
   trunk/testset/tags.filenames
Log:
* checks/changelog-file{.desc,}:
  + [RA] Add some basic checks for NEWS.Debian files: naming,
    compression, encoding, a syntax check with Parse::DebianChangelog,
    and unreleased for the distribution.  (Closes: #437707)
* collection/changelog-file{.desc,}:
  + [RA] Collect NEWS.Debian as well as changelog.

Modified: trunk/checks/changelog-file
===================================================================
--- trunk/checks/changelog-file	2007-10-14 23:36:13 UTC (rev 953)
+++ trunk/checks/changelog-file	2007-10-15 00:32:39 UTC (rev 954)
@@ -97,18 +97,25 @@
 	return 0;
     }
 
-
     # we are only interested in files or symlinks in /usr/(share/)?doc/$pkg
     if (m,usr/(share/)?doc/$ppkg/([^/\s]+), ) {
 	my $file = $2;
+	my $file1 = "usr/share/doc/$pkg/$file";
 
 	push(@doc_files, $file);
 
+	# Check a few things about the NEWS.Debian file.
+	if ($file =~ /^NEWS.Debian(\.gz)?$/i) {
+	    if (not $file =~ /\.gz$/) {
+		tag "debian-news-file-not-compressed", "$file1";
+	    } elsif ($file ne 'NEWS.Debian.gz') {
+		tag "wrong-name-for-debian-news-file", "$file1";
+	    }
+	}
+
 	# check if changelog files are compressed with gzip -9
 	next unless $file =~ m/^changelog(\.html)?(\.gz)?$|changelog.debian(\.gz)?$/i;
 
-	my $file1 = "usr/share/doc/$pkg/$file";
-
 	if (not $file =~ m/\.gz$/) {
 	    tag "changelog-file-not-compressed", "$file";
 	} else {
@@ -143,6 +150,30 @@
     return 0;
 }
 
+# Check a NEWS.Debian file if we have one.  We should additionally check here
+# that the entries don't begin with an asterisk, but that hasn't been done
+# yet.
+if (-f 'NEWS.Debian') {
+    my $line = file_is_encoded_in_non_utf8('NEWS.Debian', $type, $pkg);
+    if ($line) {
+	tag "debian-news-file-uses-obsolete-national-encoding", "at line $line"
+    }
+    my $changes = Parse::DebianChangelog->init( { infile => 'NEWS.Debian', quiet => 1 } );
+    if (my @errors = $changes->get_parse_errors) {
+	for (@errors) {
+	    tag "syntax-error-in-debian-news-file", "line $_->[1]", "\"$_->[2]\"";
+	}
+    }
+
+    # Some checks on the most recent entry.
+    if ($changes->data) {
+        my ($entry) = $changes->data;
+        if ($entry->Distribution =~ /unreleased/i) {
+            tag "debian-news-entry-has-strange-distribution", $entry->Distribution;
+        }
+    }
+}
+
 if ( $found_html && !$found_text ) {
     tag "html-changelog-without-text-version", "";
 }

Modified: trunk/checks/changelog-file.desc
===================================================================
--- trunk/checks/changelog-file.desc	2007-10-14 23:36:13 UTC (rev 953)
+++ trunk/checks/changelog-file.desc	2007-10-15 00:32:39 UTC (rev 954)
@@ -32,6 +32,12 @@
  start out small, they will become large with time.
 Ref: policy 12.7
 
+Tag: debian-news-file-not-compressed
+Type: warning
+Info: NEWS.Debian files should be compressed using "gzip -9".  The file
+ must always have the same name.
+Ref: devref 6.3.4
+
 Tag: changelog-not-compressed-with-max-compression
 Type: warning
 Info: Changelog files should be compressed using "gzip -9"; i.e., using
@@ -71,6 +77,13 @@
  /usr/share/doc/<i>pkg</i>/changelog.Debian.gz
 Ref: policy 12.7
 
+Tag: wrong-name-for-debian-news-file
+Type: warning
+Info: The Debian news file must be installed as
+ /usr/share/doc/<i>pkg</i>/NEWS.Debian.gz with exactly that capitalization
+ or automated tools may not find it correctly.
+Ref: devref 6.3.4
+
 Tag: debian-changelog-file-missing
 Type: error
 Info: Each Debian package (which provides a /usr/share/doc/<i>pkg</i>
@@ -131,6 +144,17 @@
   $ iconv -f ISO-8859-1 -t UTF-8 changelog > changelog.new
   $ mv changelog.new changelog
 
+Tag: debian-news-file-uses-obsolete-national-encoding
+Type: error
+Info: The NEWS.Debian file must be valid UTF-8, an encoding of the Unicode
+ character set.
+ .
+ There are many ways to convert a changelog from an obsoleted encoding
+ like ISO-8859-1; you may for example use "iconv" like:
+ .
+  $ iconv -f ISO-8859-1 -t UTF-8 NEWS.Debian > NEWS.Debian.new
+  $ mv NEWS.Debian.new NEWS.Debian
+
 Tag: latest-debian-changelog-entry-without-new-date
 Type: warning
 Info: The latest Debian changelog has either the same or even an older
@@ -141,6 +165,11 @@
 Info: While parsing the Debian changelog, an syntax error was found.
 Ref: policy 4.4
 
+Tag: syntax-error-in-debian-news-file
+Type: warning
+Info: While parsing the NEWS.Debian file, a syntax error was found.
+Ref: devref 6.3.4
+
 Tag: wrong-bug-number-in-closes
 Type: warning
 Info: Bug numbers can only contain digits.
@@ -152,3 +181,11 @@
  followed by a colon.  This entry looked like it was intended to close a
  bug, but there's no colon after "closes".
 Ref: policy 4.4
+
+Tag: debian-news-entry-has-strange-distribution
+Type: warning
+Info: The latest entry in NEWS.Debian has an unusual distribution name.
+ This field is ignored by the archive software, so its value doesn't truly
+ matter, but it may be confusing to users reading the entry if the
+ distribution doesn't match the distribution for the same entry in the
+ Debian changelog file.

Modified: trunk/collection/changelog-file
===================================================================
--- trunk/collection/changelog-file	2007-10-14 23:36:13 UTC (rev 953)
+++ trunk/collection/changelog-file	2007-10-15 00:32:39 UTC (rev 954)
@@ -2,17 +2,17 @@
 # changelog-file -- lintian collector script
 
 # Copyright (C) 1998 Richard Braakman
-# 
+#
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 2 of the License, or
 # (at your option) any later version.
-# 
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, you can find it on the World Wide
 # Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
@@ -92,6 +92,27 @@
 	or fail("cannot link $chl to changelog: $!");
 }
 
+# Extract NEWS.Debian files as well, with similar precautious.  Ignore any
+# symlinks to other packages here; in that case, we just won't check the file.
+my $news = "unpacked/usr/share/doc/$pkg/NEWS.Debian.gz";
+if (-f $news) {
+    if (-l $news) {
+        my $link = readlink $news or fail("cannot readlink $chl: $!");
+        if ($link =~ /\.\./ || ($link =~ m%/% && $link !~ m%^[^/]+(/+[^/]+)*\z%)) {
+            undef $news;
+        } elsif (! -f $news) {
+            undef $news;
+        }
+    }
+    if ($news) {
+        use lib "$ENV{'LINTIAN_ROOT'}/lib";
+        use Pipeline;
+
+        pipeline((sub { exec 'gzip', '-dc', $news }), "NEWS.Debian") == 0
+            or fail("error in gzip");
+    }
+}
+
 exit 0;
 
 # -----------------------------------

Modified: trunk/collection/changelog-file.desc
===================================================================
--- trunk/collection/changelog-file.desc	2007-10-14 23:36:13 UTC (rev 953)
+++ trunk/collection/changelog-file.desc	2007-10-15 00:32:39 UTC (rev 954)
@@ -1,6 +1,8 @@
 Collector-Script: changelog-file
 Author: Richard Braakman <dark@xs4all.nl>
-Info: This script copies the `changelog' file of a package into the lintian directory.
+Info: This script copies the <tt>changelog</tt> file and
+ <tt>NEWS.Debian</tt> file (if any) of a package into the lintian
+ directory.
 Type: binary
 Unpack-Level: 2
 Output: changelog

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2007-10-14 23:36:13 UTC (rev 953)
+++ trunk/debian/changelog	2007-10-15 00:32:39 UTC (rev 954)
@@ -1,5 +1,9 @@
 lintian (1.23.35) UNRELEASED; urgency=low
 
+  * checks/changelog-file{.desc,}:
+    + [RA] Add some basic checks for NEWS.Debian files: naming,
+      compression, encoding, a syntax check with Parse::DebianChangelog,
+      and unreleased for the distribution.  (Closes: #437707)
   * checks/common_data.pm:
     + [RA] Allow Homepage in source and binary packages.
   * checks/cruft.desc:
@@ -9,8 +13,11 @@
     + [RA] Warn (at info level for now) about Homepage pseudo-fields in
       the extended description.  (Closes: #444336)
 
- -- Russ Allbery <rra@debian.org>  Sun, 14 Oct 2007 16:35:45 -0700
+  * collection/changelog-file{.desc,}:
+    + [RA] Collect NEWS.Debian as well as changelog.
 
+ -- Russ Allbery <rra@debian.org>  Sun, 14 Oct 2007 17:32:29 -0700
+
 lintian (1.23.34) unstable; urgency=low
 
   The "brown paper operator" release.

Added: trunk/testset/binary/debian/NEWS.Debian
===================================================================
--- trunk/testset/binary/debian/NEWS.Debian	2007-10-14 23:36:13 UTC (rev 953)
+++ trunk/testset/binary/debian/NEWS.Debian	2007-10-15 00:32:39 UTC (rev 954)
@@ -0,0 +1,11 @@
+binary (4-1.1) UNRELEASED; urgency=low
+
+  This is a Debian NEWS entry that isn't encoded properly in UTF-8: � -- Russ Allbery <rra@debian.org>  Sun, 14 Oct 2007 17:11:36 -0700
+
+binary (1) unstable; urgency=low
+
+  This is another entry but this one isn't syntactically valid.
+
+ -- Russ Allbery  2007-10-14

Modified: trunk/testset/binary/debian/rules
===================================================================
--- trunk/testset/binary/debian/rules	2007-10-14 23:36:13 UTC (rev 953)
+++ trunk/testset/binary/debian/rules	2007-10-15 00:32:39 UTC (rev 954)
@@ -41,6 +41,8 @@
 	install -d $(tmp)/usr/share/doc-base
 	install -m 644 debian/doc-base $(tmp)/usr/share/doc-base/binary
 	install -m 644 debian/README.Debian $(tmp)/usr/share/doc/binary
+	install -m 644 debian/NEWS.Debian $(tmp)/usr/share/doc/binary
+	gzip -9 $(tmp)/usr/share/doc/binary/NEWS.Debian
 	install -m 644 debian/copyright $(tmp)/usr/share/doc/binary
 	install -m 644 debian/changelog $(tmp)/usr/share/doc/binary
 	#gzip -9 $(tmp)/usr/share/doc/binary/changelog

Modified: trunk/testset/filenames/debian/rules
===================================================================
--- trunk/testset/filenames/debian/rules	2007-10-14 23:36:13 UTC (rev 953)
+++ trunk/testset/filenames/debian/rules	2007-10-15 00:32:39 UTC (rev 954)
@@ -80,6 +80,10 @@
 	echo foo > debian/tmp/usr/share/doc/filenames/bokm\\� 	echo foo > debian/tmp/usr/share/doc/filenames/bokm\\\\� 
+	touch debian/tmp/usr/share/doc/filenames/news.debian
+	gzip debian/tmp/usr/share/doc/filenames/news.debian
+	touch debian/tmp/usr/share/doc/filenames/NEWS.Debian
+
 	install -d debian/tmp/usr/share/doc/filenames/examples
 	touch debian/tmp/usr/share/doc/filenames/examples/__init__.py
 	touch debian/tmp/usr/share/doc/filenames/examples/very_interesting_example

Modified: trunk/testset/tags.binary
===================================================================
--- trunk/testset/tags.binary	2007-10-14 23:36:13 UTC (rev 953)
+++ trunk/testset/tags.binary	2007-10-15 00:32:39 UTC (rev 954)
@@ -1,6 +1,7 @@
 E: binary source: debian-rules-missing-required-target binary-indep
 E: binary-data: md5sums-control-file-is-empty
 E: binary: debian-changelog-file-missing-or-wrong-name
+E: binary: debian-news-file-uses-obsolete-national-encoding at line 3
 E: binary: depends-on-x-metapackage depends: xorg
 E: binary: desktop-entry-missing-required-key ./usr/share/applications/goodbye.desktop Name
 E: binary: doc-base-file-no-format binary:22
@@ -53,6 +54,7 @@
 W: binary: binary-without-manpage usr/bin/iminusrbin
 W: binary: binary-without-manpage usr/bin/static-hello
 W: binary: changelog-file-not-compressed changelog
+W: binary: debian-news-entry-has-strange-distribution UNRELEASED
 W: binary: desktop-command-not-in-package ./usr/share/applications/goodbye.desktop goodbye
 W: binary: desktop-entry-contains-unknown-key ./usr/share/applications/goodbye.desktop:5 SpecialTag
 W: binary: desktop-entry-contains-unknown-key ./usr/share/applications/goodbye.desktop:7 icon
@@ -91,6 +93,8 @@
 W: binary: su-to-root-with-usr-sbin /usr/lib/menu/binary:4
 W: binary: su-to-root-with-usr-sbin /usr/share/menu/binary:4
 W: binary: syntax-error-in-debian-changelog line 16 "couldn't parse date The, 15 Apr 2004 23:33:51 +0200"
+W: binary: syntax-error-in-debian-news-file line 11 "badly formatted trailer line"
+W: binary: syntax-error-in-debian-news-file line 11 "found eof where expected more change data or trailer"
 W: binary: unquoted-string-in-menu-item /usr/lib/menu/binary needs:1
 W: binary: unquoted-string-in-menu-item /usr/lib/menu/binary needs:2
 W: binary: unquoted-string-in-menu-item /usr/share/menu/binary needs:1

Modified: trunk/testset/tags.filenames
===================================================================
--- trunk/testset/tags.filenames	2007-10-14 23:36:13 UTC (rev 953)
+++ trunk/testset/tags.filenames	2007-10-15 00:32:39 UTC (rev 954)
@@ -46,6 +46,7 @@
 W: filenames: binary-without-manpage usr/bin/X11/testxbin
 W: filenames: binary-without-manpage usr/bin/mh/read
 W: filenames: cvsignore-file-in-package files/.cvsignore
+W: filenames: debian-news-file-not-compressed usr/share/doc/filenames/NEWS.Debian
 W: filenames: executable-not-elf-or-script ./usr/bin/bin/bad
 W: filenames: executable-not-elf-or-script ./usr/bin/mh/read
 W: filenames: extra-license-file usr/share/pixmaps/COPYING
@@ -83,6 +84,9 @@
 W: filenames: symlink-is-self-recursive usr/lib/filenames/symlink5ok+warn ..
 W: filenames: symlink-is-self-recursive usr/lib/filenames/symlink6ok+warn .
 W: filenames: symlink-is-self-recursive usr/lib/filenames/symlink7ok+warn /
+W: filenames: wrong-name-for-debian-news-file usr/share/doc/filenames/news.debian.gz
+W: filenames: zero-byte-file-in-doc-directory usr/share/doc/filenames/NEWS.Debian
 W: filenames: zero-byte-file-in-doc-directory usr/share/doc/filenames/README.macosx
 W: filenames: zero-byte-file-in-doc-directory usr/share/doc/filenames/examples/very_interesting_example
 W: filenames: zero-byte-file-in-doc-directory usr/share/doc/filenames/examples/very_interesting_example2.gz
+W: filenames: zero-byte-file-in-doc-directory usr/share/doc/filenames/news.debian.gz



Reply to: