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

Bug#389070: [checks/debconf] abuse of debconf notes



Package: lintian
Version: 1.23.24
Severity: wishlist
Tags: patch

Hi,

Following the discussion on debian-devel (see
http://lists.debian.org/debian-devel/2006/09/msg00438.html), here is a
patch for lintian to warn for notes displayed with a low or medium
priority. To avoid false-positives as mentioned on
http://lists.debian.org/debian-devel/2006/09/msg00456.html
I do not take in account db_input calls if the string "/dev/" is on the
previous line and the priority is medium.
Christian already did the MBF, but a lintian warning could be good to
avoid new abuses.

Cheers,

-- 
Thomas Huriaux
--- /usr/share/lintian/checks/debconf	2006-09-04 21:03:38.000000000 +0200
+++ debconf	2006-09-23 19:34:44.000000000 +0200
@@ -155,6 +155,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='';
@@ -234,6 +235,9 @@
 	}
     }
 
+    push (@potential_db_abuse, $template->{template})
+      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".
@@ -322,6 +326,7 @@
 }
 
 for my $file (qw(config postinst)) {
+    my $potential_makedev = {};
     if (open(IN, "control/$file")) {
 	my $usesconfmodule='';
 	my $obsoleteconfmodule='';
@@ -353,10 +358,19 @@
 		    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 "debconf-abuse", "$file:$. $template"
+		        if ((grep ( /^$template$/, @potential_db_abuse )) and
+			     (not ($potential_makedev->{($. - 1)} and ($priority eq "low"))) and
+			     ($priority =~ /^(low|medium)$/));
+		}
 	    }
 	    if (not $isdefault and m/db_fset.*isdefault/) {
 	        # TODO: Perl?
--- /usr/share/lintian/checks/debconf.desc	2006-09-04 21:03:38.000000000 +0200
+++ debconf.desc	2006-09-23 18:48:00.000000000 +0200
@@ -272,3 +272,20 @@
  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: debconf-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,
+ as 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, 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, e.g. for input validation errors.
+Ref: policy 3.9.1

Attachment: signature.asc
Description: Digital signature


Reply to: