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

lintian: r1242 - in trunk: . checks data data/doc-base debian lib lib/Lintian testset testset/filenames/debian



Author: rra
Date: 2008-03-04 01:39:52 +0100 (Tue, 04 Mar 2008)
New Revision: 1242

Added:
   trunk/data/
   trunk/data/README
   trunk/data/doc-base/
   trunk/data/doc-base/sections
   trunk/lib/Lintian/
   trunk/lib/Lintian/Data.pm
   trunk/testset/filenames/debian/doc-base
Modified:
   trunk/checks/menus
   trunk/checks/menus.desc
   trunk/debian/changelog
   trunk/debian/dirs
   trunk/debian/rules
   trunk/testset/filenames/debian/rules
   trunk/testset/tags.binary
   trunk/testset/tags.filenames
Log:
  + [RA] Check doc-base sections against the new canonical list.
    Thanks, Robert Luberda.  (Closes: #463474)
* data/doc-base/sections:
  + [RA] New file listing known doc-base sections.
* debian/dirs:
  + [RA] Install the base directory for the Lintian root here.
* debian/rules:
  + [RA] Redo the installation rules to support arbitrary nesting under
    the copied directories.  As a side effect, install
    lib/Tags/ColonSeparated.pm, unbreaking the experimental
    colon-separated output format.
* lib/Lintian/Data.pm:
  + [RA] New module for loading and querying lists of keywords.

Modified: trunk/checks/menus
===================================================================
--- trunk/checks/menus	2008-03-03 22:53:46 UTC (rev 1241)
+++ trunk/checks/menus	2008-03-04 00:39:52 UTC (rev 1242)
@@ -24,6 +24,8 @@
 use strict;
 use lib "$ENV{'LINTIAN_ROOT'}/checks/";
 use common_data;
+
+use Lintian::Data;
 use Spelling;
 use Tags;
 use Util;
@@ -384,6 +386,13 @@
                                  join (' ', @$vals), "$dbfile:$line");
         }
 
+    # Section field.
+    } elsif ($field eq 'section') {
+	my $sections = Lintian::Data->new('doc-base/sections');
+	$_ = join (' ', @$vals);
+	tag "doc-base-unknown-section", "$dbfile:$line", $_
+	    unless $sections->known($_);
+
     # Abstract field.
     } elsif ($field eq 'abstract') {
         # The three following variables are used for checking if the field is

Modified: trunk/checks/menus.desc
===================================================================
--- trunk/checks/menus.desc	2008-03-03 22:53:46 UTC (rev 1241)
+++ trunk/checks/menus.desc	2008-03-04 00:39:52 UTC (rev 1242)
@@ -299,3 +299,11 @@
  .
   $ iconv -f ISO-8859-1 -t UTF-8 doc-base > doc-base.new
   $ mv doc-base.new doc-base
+Ref: Debian doc-base Manual section 2.3.2
+
+Tag: doc-base-unknown-section
+Type: warning
+Info: The section indicated in this doc-base control file is not one of
+ the standard doc-base sections.  The doc-base sections are based on the
+ menu sections but are not exactly the same.
+Ref: Debian doc-base Manual section 2.3.3

Added: trunk/data/README
===================================================================
--- trunk/data/README	                        (rev 0)
+++ trunk/data/README	2008-03-04 00:39:52 UTC (rev 1242)
@@ -0,0 +1,12 @@
+This directory contains files loaded by the Lintian::Data module,
+specifically lists of keywords used in various Lintian checks.  For all
+files in this directory, blank lines are ignored, as are lines beginning
+with #.
+
+For each list of keywords, please include in a comment the origin of the
+list, any information about how to resynchronize the list with that
+origin, and any special exceptions or caveats.
+
+Files should generally be organized into subdirectory by check or by
+general class of lists (for example, all lists related to doc-base files
+should go into a doc-base subdirectory).

Added: trunk/data/doc-base/sections
===================================================================
--- trunk/data/doc-base/sections	                        (rev 0)
+++ trunk/data/doc-base/sections	2008-03-04 00:39:52 UTC (rev 1242)
@@ -0,0 +1,73 @@
+# Taken from /usr/share/doc-base/data/sections.list.
+#
+# Last synchronized with doc-base 0.8.10 (2008-02-22).
+
+Accessibility
+Amateur Radio
+Data Management
+Debian
+Editors
+Education
+Emulators
+File Management
+Games/Action
+Games/Adventure
+Games/Blocks
+Games/Board
+Games/Card
+Games/Puzzles
+Games/Simulation
+Games/Strategy
+Games/Tools
+Games/Toys
+Graphics
+Help
+Help/Books
+Help/FAQ
+Help/HOWTO
+Help/RFC
+Help/Standards
+Mobile Devices
+Network/Communication
+Network/File Transfer
+Network/Monitoring
+Network/Web Browsing
+Network/Web News
+Office
+Programming
+Programming/C
+Programming/C++
+Programming/Java
+Programming/Perl
+Programming/Python
+Programming/Ruby
+Project Management
+Science/Astronomy
+Science/Biology
+Science/Chemistry
+Science/Data Analysis
+Science/Electronics
+Science/Engineering
+Science/Geoscience
+Science/Mathematics
+Science/Medicine
+Science/Physics
+Science/Social
+Screen
+Screen/Saving
+Screen/Locking
+Shells
+Sound
+System/Administration
+System/Hardware
+System/Language Environment
+System/Monitoring
+System/Package Management
+System/Security
+Terminal Emulators
+Text
+TV and Radio
+Viewers
+Video
+Web Development
+Window Managers

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2008-03-03 22:53:46 UTC (rev 1241)
+++ trunk/debian/changelog	2008-03-04 00:39:52 UTC (rev 1242)
@@ -55,6 +55,8 @@
   * checks/menus{,desc}:
     + [RA] Check that doc-base files are encoded in UTF-8.  Thanks, Robert
       Luberda.  (Closes: #468759)
+    + [RA] Check doc-base sections against the new canonical list.
+      Thanks, Robert Luberda.  (Closes: #463474)
   * check/patch-systems:
     + [HE] Warn if the .diff.gz contains changes while the package uses
       a patch system. (Closes: #452215)
@@ -76,6 +78,17 @@
       to sharedobject-in-library-directory-missing-soname for clarity.
       Thanks, Peter Eisentraut.  (Closes: #467425)
 
+  * data/doc-base/sections:
+    + [RA] New file listing known doc-base sections.
+
+  * debian/dirs:
+    + [RA] Install the base directory for the Lintian root here.
+  * debian/rules:
+    + [RA] Redo the installation rules to support arbitrary nesting under
+      the copied directories.  As a side effect, install
+      lib/Tags/ColonSeparated.pm, unbreaking the experimental
+      colon-separated output format.
+
   * frontend/lintian:
     + [CW] Make the presence of an Ubuntu release name in the version number
       trigger the Ubuntu distribution field checks.
@@ -86,6 +99,8 @@
     + [RA] Skip empty dependencies, avoiding false positives for
       stronger-dependency-implies-weaker.  Patch from Adam D. Barratt.
       (Closes: #469222)
+  * lib/Lintian/Data.pm:
+    + [RA] New module for loading and querying lists of keywords.
   * lib/Spelling.pm:
     + [RA] Add another spelling correction.
     + [RA] Merriam-Webster and the OED have both given up on publically

Modified: trunk/debian/dirs
===================================================================
--- trunk/debian/dirs	2008-03-03 22:53:46 UTC (rev 1241)
+++ trunk/debian/dirs	2008-03-04 00:39:52 UTC (rev 1242)
@@ -1,3 +1,4 @@
+etc
 usr/bin
-etc
+usr/share/lintian
 var/spool/lintian

Modified: trunk/debian/rules
===================================================================
--- trunk/debian/rules	2008-03-03 22:53:46 UTC (rev 1241)
+++ trunk/debian/rules	2008-03-04 00:39:52 UTC (rev 1242)
@@ -45,11 +45,9 @@
 	install -m 755 frontend/lintian-info $(tmp)/usr/bin/
 # library files
 	@echo .... install library files ....
-	for d in checks collection lib unpack; do \
-	  install -d $(usl)/$$d; \
-	  find $$d -type f ! -path '*/CVS/*' ! -path '*/.svn/*' \
-	  	| xargs -iFILE cp -p FILE $(usl)/$$d/; \
-	done
+	find checks collection data lib unpack \
+	    \( -path '*/CVS' -o -path '*/.svn' \) -prune -o -print \
+		| cpio -admp $(usl)
 # documentation
 	@echo .... install documentation ....
 	dh_installdocs

Added: trunk/lib/Lintian/Data.pm
===================================================================
--- trunk/lib/Lintian/Data.pm	                        (rev 0)
+++ trunk/lib/Lintian/Data.pm	2008-03-04 00:39:52 UTC (rev 1242)
@@ -0,0 +1,169 @@
+# -*- perl -*-
+# Lintian::Data -- interface to query lists of keywords
+
+# Copyright (C) 2008 Russ Allbery
+#
+# 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, see <http://www.gnu.org/licenses/>.
+
+package Lintian::Data;
+use strict;
+
+use Carp qw(croak);
+
+# The constructor loads a list into a hash in %data, which is private to this
+# module.  Use %data as a cache to avoid loading the same list more than once
+# (which means lintian doesn't support having the list change over the life of
+# the proces.  The returned object knows what list, stored in %data, it is
+# supposed to act on.
+{
+    my %data;
+    sub new {
+        my ($class, $type) = @_;
+        croak('no data type specified') unless $type;
+        unless (exists $data{$type}) {
+            my $dir = $ENV{LINTIAN_ROOT} . '/data';
+            open(LIST, '<', "$dir/$type")
+                or croak("unknown data type $type");
+            local ($_, $.);
+            while (<LIST>) {
+                chomp;
+                s/^\s+//;
+                next if /^\#/;
+                next if /^$/;
+                $data{$type}{$_} = 1;
+            }
+        }
+        my $self = { data => $data{$type} };
+        bless($self, $class);
+        return $self;
+    }
+}
+
+# Query a data object for whether a particular keyword is valid.
+sub known {
+    my ($self, $keyword) = @_;
+    return (exists $self->{data}{$keyword}) ? 1 : undef;
+}
+
+=head1 NAME
+
+Lintian::Data - Lintian interface to query lists of keywords
+
+=head1 SYNOPSIS
+
+    my $list = Lintian::Data->new('type');
+    if ($list->known($keyword)) {
+        # do something ...
+    }
+
+=head1 DESCRIPTION
+
+Lintian::Data provides a way of loading a list of keywords from a file in
+the Lintian root and then querying that list.  The lists are stored in the
+F<data> directory of the Lintian root and consist of one keyword per line.
+Blank lines and lines beginning with C<#> are ignored.  Leading and
+trailing whitespace is stripped; other than that, keywords are taken
+verbatim as they are listed in the file and may include spaces.
+
+This module allows lists such as menu sections, doc-base sections,
+obsolete packages, package fields, and so forth to be stored in simple,
+easily editable files.
+
+=head1 CLASS METHODS
+
+=over 4
+
+=item new(TYPE)
+
+Creates a new Lintian::Data object for the given TYPE.  TYPE is a partial
+path relative to the F<data> directory and should correspond to a file in
+that directory.  The contents of that file will be loaded into memory and
+returned as part of the newly created object.  On error, new() throws an
+exception.
+
+A given file will only be loaded once.  If new() is called again with the
+same TYPE argument, the data previously loaded will be reused, avoiding
+multiple file reads.
+
+=back
+
+=head1 INSTANCE METHODS
+
+=over 4
+
+=item known(KEYWORD)
+
+Returns true if KEYWORD was listed in the data file represented by this
+Lintian::Data instance and false otherwise.
+
+=back
+
+=head1 DIAGNOSTICS
+
+=over 4
+
+=item no data type specified
+
+new() was called without a TYPE argument.
+
+=item unknown data type %s
+
+The TYPE argument to new() did not correspond to a file in the F<data>
+directory of the Lintian root.
+
+=back
+
+=head1 FILES
+
+=over 4
+
+=item LINTIAN_ROOT/data
+
+The files loaded by this module must be located in this directory.
+Relative paths containing a C</> are permitted, so files may be organized
+in subdirectories in this directory.
+
+=back
+
+=head1 ENVIRONMENT
+
+=over 4
+
+=item LINTIAN_ROOT
+
+This variable must be set to Lintian's root directory (normally
+F</usr/share/lintian> when Lintian is installed as a Debian package).  The
+B<lintian> program normally takes care of doing this.  This module doesn't
+care about the contents of this directory other than expecting the F<data>
+subdirectory of this directory to contain its files.
+
+=back
+
+=head1 AUTHOR
+
+Originally written by Russ Allbery <rra@debian.org> for Lintian.
+
+=head1 SEE ALSO
+
+lintian(1)
+
+=cut
+
+1;
+
+# Local Variables:
+# indent-tabs-mode: nil
+# cperl-indent-level: 4
+# End:
+# vim: syntax=perl sw=4 sts=4 ts=4 et shiftround

Added: trunk/testset/filenames/debian/doc-base
===================================================================
--- trunk/testset/filenames/debian/doc-base	                        (rev 0)
+++ trunk/testset/filenames/debian/doc-base	2008-03-04 00:39:52 UTC (rev 1242)
@@ -0,0 +1,11 @@
+Document: testing
+Title: Working doc-base control file
+Author: Russ Allbery
+Abstract: This control file ensures that we don't get false positives for
+ correct doc-base files.
+ .
+ There isn't anything wrong with this one.
+Section: Education
+
+Format: Text
+Files: /usr/share/doc/filenames/README.macosx

Modified: trunk/testset/filenames/debian/rules
===================================================================
--- trunk/testset/filenames/debian/rules	2008-03-03 22:53:46 UTC (rev 1241)
+++ trunk/testset/filenames/debian/rules	2008-03-04 00:39:52 UTC (rev 1242)
@@ -175,6 +175,9 @@
 	ln -s ../../doc/filenames/good-devhelp debian/tmp/usr/share/gtk-doc/html/good
 	ln -s ../doc/filenames/bad-devhelp debian/tmp/usr/share/gtk-doc/html/bad
 
+	install -d debian/tmp/usr/share/doc-base
+	install -m 644 debian/doc-base debian/tmp/usr/share/doc-base/filenames
+
 	dpkg-gencontrol -pfilenames -Pdebian/tmp
 	dpkg --build debian/tmp ..
 

Modified: trunk/testset/tags.binary
===================================================================
--- trunk/testset/tags.binary	2008-03-03 22:53:46 UTC (rev 1241)
+++ trunk/testset/tags.binary	2008-03-04 00:39:52 UTC (rev 1242)
@@ -79,6 +79,7 @@
 W: binary: desktop-entry-uses-reserved-category Screensaver /usr/share/applications/goodbye.desktop
 W: binary: doc-base-abstract-field-separator-extra-whitespaces binary:7
 W: binary: doc-base-file-unknown-format binary:20 esp
+W: binary: doc-base-unknown-section binary:11 Non/Existant
 W: binary: executable-not-elf-or-script ./usr/bin/iminusrbin
 W: binary: executable-not-elf-or-script ./usr/share/applications/goodbye.desktop
 W: binary: file-in-unusual-dir usr/bar

Modified: trunk/testset/tags.filenames
===================================================================
--- trunk/testset/tags.filenames	2008-03-03 22:53:46 UTC (rev 1241)
+++ trunk/testset/tags.filenames	2008-03-04 00:39:52 UTC (rev 1242)
@@ -14,8 +14,10 @@
 E: filenames: package-installs-file-to-usr-x11r6-bin usr/X11R6/bin/
 E: filenames: package-installs-file-to-usr-x11r6-bin usr/X11R6/bin/testxbin2
 E: filenames: package-installs-packlist usr/lib/perl5/foo/.packlist
+E: filenames: postinst-does-not-call-installdocs usr/share/doc-base/filenames
 E: filenames: postinst-does-not-call-updatemenus usr/share/menu/menu
 E: filenames: postrm-does-not-call-updatemenus usr/share/menu/menu
+E: filenames: prerm-does-not-call-installdocs usr/share/doc-base/filenames
 E: filenames: subdir-in-usr-bin usr/bin/bin/
 E: filenames: symlink-contains-spurious-segments usr/lib/filenames/symlink5wrong ../menu/../somethingelse
 E: filenames: symlink-contains-spurious-segments usr/lib/filenames/symlink6wrong ./file4


Reply to: