Author: rra
Date: 2006-11-11 08:28:28 +0100 (Sat, 11 Nov 2006)
New Revision: 774

Modified:
   trunk/checks/control-files
   trunk/checks/debconf
   trunk/checks/debconf.desc
   trunk/checks/infofiles
   trunk/debian/changelog
   trunk/testset/tags.debconf
Log:
  + [RA] Close opened files.
  + [RA] Warn of debconf notes displayed with low or medium priority,
    with an exception for Policy-required device file warnings.  Based
    on a patch by Thomas Huriaux.  (Closes: #389070)
  + [RA] Close files after opening them, fixing incorrect line numbers
    when reporting problems with config scripts.
* checks/infofiles:
  + [RA] Close opened files.

Modified: trunk/checks/control-files
===================================================================
--- trunk/checks/control-files  2006-11-11 06:46:36 UTC (rev 773)
+++ trunk/checks/control-files  2006-11-11 07:28:28 UTC (rev 774)
@@ -102,6 +102,7 @@
 
 # for other maintainer scripts checks, see the scripts check
 }
+close IN;
 
 } # </run>
 

Modified: trunk/checks/debconf
===================================================================
--- trunk/checks/debconf        2006-11-11 06:46:36 UTC (rev 773)
+++ trunk/checks/debconf        2006-11-11 07:28:28 UTC (rev 774)
@@ -105,6 +105,7 @@
     if (-f "fields/$field") {
        open(IN, "fields/$field") or fail("Can't open fields/$field: $!");
        chomp($_ = <IN>);
+       close IN;
        $_ .= ", $version" if defined $version;
        $_ =~ s/debconf-2\.0/debconf (>= 1.2.30)/go;
        $_ =~ s/cdebconf(-\w+)?(-udeb)?\s*(\(.+?\))?/debconf (>= 1.2.30)/g;
@@ -170,6 +171,7 @@
 # Lots of template checks.
 
 my @templates = $seentemplates ? read_dpkg_control("control/templates", 
"templates file") : ();
+my %potential_db_abuse;
 
 foreach my $template (@templates) {
     my $isselect='';
@@ -253,6 +255,11 @@
        }
     }
 
+    if ($template->{template} && $template->{type}) {
+        $potential_db_abuse{$template->{template}} = 1
+            if (($template->{type} eq "note") or ($template->{type} eq 
"text"));
+    }
+
     # Check the description against the best practices in the Developer's
     # Reference, but skip all templates where the short description contains
     # the string "for internal use".
@@ -330,6 +337,7 @@
 # Check the maintainer scripts.
 
 for my $file (qw(config postinst)) {
+    my $potential_makedev = {};
     if (open(IN, "control/$file")) {
        my $usesconfmodule='';
        my $obsoleteconfmodule='';
@@ -338,12 +346,21 @@
        my $usesseen='';
        my $usessettitle='';
 
+       # Only check scripts.
        my $fl = <IN>;
-       next unless $fl && ( $fl =~ /^#!/ ); # skip, if not a script
+       unless ($fl && $fl =~ /^\#!/) {
+           close IN;
+           next;
+       }
 
        while (<IN>) {
            s/#.*//;    # Not perfect for Perl, but should be OK
            next unless m/\S/;
+           while (s%\\$%%) {
+               my $next = <IN>;
+               last unless $next;
+               $_ .= $next;
+           }
            if (m#(?:\.|source)\s+/usr/share/debconf/confmodule# ||
                    m/use\s+Debconf::Client::ConfModule/) {
                $usesconfmodule=1;
@@ -361,11 +378,20 @@
                    unless $type eq 'udeb';
                $db_input=1;
            }
-           if (m/^\s*(?:db_input|db_text)\s+[\"\']?(\S+?)[\"\']?\s+\S+\s/) {
-               my $priority = $1;
-               tag "unknown-debconf-priority", "$file:$. $1"
-                   unless ($priority =~ /^\$\S+$/ || 
$valid_priorities{$priority});
+           if (m%/dev/%) {
+               $potential_makedev->{$.} = 1;
            }
+           if (m/^\s*(?:db_input|db_text)\s+[\"\']?(\S+?)[\"\']?\s+(\S+)\s/) {
+               my ($priority, $template) = ($1, $2);
+               if ($priority !~ /^\$\S+$/) {
+                   tag "unknown-debconf-priority", "$file:$. $1"
+                       unless ($valid_priorities{$priority});
+                   tag "possible-debconf-note-abuse", "$file:$. $template"
+                       if ($potential_db_abuse{$template}
+                           and (not ($potential_makedev->{($. - 1)} and 
($priority eq "low")))
+                           and ($priority =~ /^(low|medium)$/));
+               }
+           }
            if (not $isdefault and m/db_fset.*isdefault/) {
                # TODO: Perl?
                tag "isdefault-flag-is-deprecated", "$file";

Modified: trunk/checks/debconf.desc
===================================================================
--- trunk/checks/debconf.desc   2006-11-11 06:46:36 UTC (rev 773)
+++ trunk/checks/debconf.desc   2006-11-11 07:28:28 UTC (rev 774)
@@ -268,3 +268,21 @@
  first argument that doesn't match one of the known priorities.  The
  supported priorities are low, medium, high, and critical.
 Ref: debconf-devel(7)
+
+Tag: possible-debconf-note-abuse
+Type: warning
+Info: Debconf notes should be used only for important notes that the
+ user really should see, since debconf will go to great pains to make
+ sure the user sees it.
+ .
+ Displaying a note with a low priority is conflicting with this statement,
+ since using a low or medium priority shows that the note is not
+ important.
+ .
+ The right fix is NOT to increase the priority of the note, but to move
+ it somewhere else in the inline documentation, for example in a
+ README.Debian file for notes about package usability or NEWS.Debian for
+ changes in the package behavior, or to simply drop it if it is not
+ needed (e.g. "welcome" notes). Changing the templates type to "error"
+ can also be appropriate, such as for input validation errors.
+Ref: policy 3.9.1

Modified: trunk/checks/infofiles
===================================================================
--- trunk/checks/infofiles      2006-11-11 06:46:36 UTC (rev 773)
+++ trunk/checks/infofiles      2006-11-11 07:28:28 UTC (rev 774)
@@ -182,6 +182,7 @@
            }
        }
     }
+    close IN;
 }
 
 1;

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog      2006-11-11 06:46:36 UTC (rev 773)
+++ trunk/debian/changelog      2006-11-11 07:28:28 UTC (rev 774)
@@ -15,6 +15,7 @@
     + [RA] Diagnose a control file that creates binary packages in a
       different archive category from the source package or the other
       binary packages.  Idea from Yann Dirson.  (Closes: #394720)
+    + [RA] Close opened files.
   * checks/debconf{.desc,}:
     + [RA] Take into account comma escaping when checking the number of
       translated choices.  Reported by Frans Pop.  (Closes: #395028)
@@ -24,6 +25,11 @@
       preinst script.  Update the long description to deprecate only
       depending on debconf and falling back on another configuration
       system.  Reported by Josselin Mouette.  (Closes: #395468)
+    + [RA] Warn of debconf notes displayed with low or medium priority,
+      with an exception for Policy-required device file warnings.  Based
+      on a patch by Thomas Huriaux.  (Closes: #389070)
+    + [RA] Close files after opening them, fixing incorrect line numbers
+      when reporting problems with config scripts.
   * checks/debdiff{.desc,}:
     + [RA] Check for creation of ~ backup files in the Debian diff, but
       only at the info level for now since they cause no harm.
@@ -32,6 +38,8 @@
       into account transitive build dependencies.  (Closes: #393975)
     + [RA] Avoid Perl warning when diagnosing a Python-Version of the form
       "all, >= 2.4".  Thanks, Thijs Kinkhorst.  (Closes: #394104)
+  * checks/infofiles:
+    + [RA] Close opened files.
   * checks/md5sums{.desc,}:
     + [RA] Add a tag for a missing md5sums control file, but only at info
       level, at least for now.  (Closes: #133027)

Modified: trunk/testset/tags.debconf
===================================================================
--- trunk/testset/tags.debconf  2006-11-11 06:46:36 UTC (rev 773)
+++ trunk/testset/tags.debconf  2006-11-11 07:28:28 UTC (rev 774)
@@ -6,8 +6,8 @@
 E: debconf-test: no-template-description debconf/no-description
 E: debconf-test: no-template-type debconf/language
 E: debconf-test: settitle-requires-versioned-depends config
-E: debconf-test: unknown-debconf-priority config:11 LOW
-E: debconf-test: unknown-debconf-priority config:12 normal
+E: debconf-test: unknown-debconf-priority config:10 LOW
+E: debconf-test: unknown-debconf-priority config:11 normal
 E: debconf-udeb udeb: udeb-postinst-must-not-call-ldconfig
 W: debconf source: invalid-po-file debian/po/fr.po
 W: debconf source: invalid-po-file debian/po/sample-file.po
@@ -32,6 +32,8 @@
 W: debconf-test: old-fsf-address-in-copyright-file
 W: debconf-test: partially-translated-question debconf/testmulti de.utf-8
 W: debconf-test: partially-translated-question debconf/testmulti-escape 
de.utf-8
+W: debconf-test: possible-debconf-note-abuse config:19 debconf/test
+W: debconf-test: possible-debconf-note-abuse postinst:8 debconf/test
 W: debconf-test: postinst-uses-db-input
 W: debconf-test: too-long-extended-description-in-templates debconf/teststring
 W: debconf-test: too-long-short-description-in-templates debconf/testnote


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to