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

lintian: r1198 - in trunk: checks debian testset testset/scripts/debian



Author: djpig
Date: 2008-02-09 16:58:00 +0100 (Sat, 09 Feb 2008)
New Revision: 1198

Added:
   trunk/testset/scripts/debian/preinst
Modified:
   trunk/checks/scripts
   trunk/checks/scripts.desc
   trunk/debian/changelog
   trunk/testset/scripts/debian/rules
   trunk/testset/tags.maintainer-scripts
   trunk/testset/tags.scripts
Log:
Warn if a maintainer script is a valid shell script but
doesn't seem to have any actual code.  Based on an idea
by Justin Pryzby.  (Closes: #410042)


Modified: trunk/checks/scripts
===================================================================
--- trunk/checks/scripts	2008-02-09 07:05:00 UTC (rev 1197)
+++ trunk/checks/scripts	2008-02-09 15:58:00 UTC (rev 1198)
@@ -478,13 +478,22 @@
 	or fail("cannot open maintainer script $filename for reading: $!");
 
     my %warned;
-    my ($saw_init, $saw_invoke, $saw_debconf);
+    my ($saw_init, $saw_invoke, $saw_debconf, $has_code);
     my $cat_string = "";
 
     while (<C>) {
+	next if m,^\s*$,;  # skip empty lines
 	next if m,^\s*\#,; # skip comment lines
 	s/\#.*$//;         # eat comments
 	chomp();
+
+	unless ($has_code
+		|| m/^\s*[:;]+\s*$/
+		|| m/^\s*set\s+-\w+\s*$/
+		|| m/^\s*exit\s+\d+\s*$/) {
+	    $has_code = 1;
+	}
+
 	if (m,[^\w=](/var)?/tmp\b, and not m/\bmktemp\b/ and not m/\btempfile\b/ and not m/\bmkdir\b/ and not m/\bmkstemp\b/) {
 	    tag "possibly-insecure-handling-of-tmp-files-in-maintainer-script", "$file:$."
 		unless $warned{tmp};
@@ -675,6 +684,9 @@
     if ($saw_init && ! $saw_invoke) {
 	tag "maintainer-script-calls-init-script-directly", "$file:$saw_init";
     }
+    unless ($has_code) {
+	tag "maintainer-script-empty", $file;
+    }
 
     close C;
 

Modified: trunk/checks/scripts.desc
===================================================================
--- trunk/checks/scripts.desc	2008-02-09 07:05:00 UTC (rev 1197)
+++ trunk/checks/scripts.desc	2008-02-09 15:58:00 UTC (rev 1198)
@@ -388,3 +388,10 @@
  and should only be used in postinst or prerm to remove the entries from
  earlier packages.  Given how long ago this transition was, consider
  removing it entirely.
+
+Tag: maintainer-script-empty
+Type: warning
+Info: The maintainer script doesn't seem to contain any code. While this
+ is harmless in most cases it is probably not what you wanted and may even
+ lead to problems in rare situations where dpkg would fail if no maintainer
+ script was present.

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2008-02-09 07:05:00 UTC (rev 1197)
+++ trunk/debian/changelog	2008-02-09 15:58:00 UTC (rev 1198)
@@ -1,3 +1,12 @@
+lintian (1.23.46) unstable; urgency=low
+
+  * checks/scripts{.desc,}:
+    + [FL] Warn if a maintainer script is a valid shell script but
+      doesn't seem to have any actual code.  Based on an idea
+      by Justin Pryzby.  (Closes: #410042)
+
+ -- Frank Lichtenheld <djpig@debian.org>  Sat, 09 Feb 2008 16:24:49 +0100
+
 lintian (1.23.45) unstable; urgency=low
 
   The "100 open bugs is magical" release.

Added: trunk/testset/scripts/debian/preinst
===================================================================
--- trunk/testset/scripts/debian/preinst	                        (rev 0)
+++ trunk/testset/scripts/debian/preinst	2008-02-09 15:58:00 UTC (rev 1198)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+set -e
+set -x
+
+#
+# Some comments here
+#
+
+# This serves as an example of an "empty" script, so
+# please do not add any real code here, thank you :)
+
+#DEBHELPER#
+
+exit 0

Modified: trunk/testset/scripts/debian/rules
===================================================================
--- trunk/testset/scripts/debian/rules	2008-02-09 07:05:00 UTC (rev 1197)
+++ trunk/testset/scripts/debian/rules	2008-02-09 15:58:00 UTC (rev 1198)
@@ -82,6 +82,7 @@
 	cp debian/copyright $(tmp)/usr/share/doc/scripts/copyright
 
 	cp debian/scripts.conffiles $(tmp)/DEBIAN/conffiles
+	install -m 755 debian/preinst $(tmp)/DEBIAN/preinst
 	install -m 755 debian/postinst $(tmp)/DEBIAN/postinst
 	install -m 755 debian/postrm $(tmp)/DEBIAN/postrm
 	touch $(tmp)/DEBIAN/prerm

Modified: trunk/testset/tags.maintainer-scripts
===================================================================
--- trunk/testset/tags.maintainer-scripts	2008-02-09 07:05:00 UTC (rev 1197)
+++ trunk/testset/tags.maintainer-scripts	2008-02-09 15:58:00 UTC (rev 1198)
@@ -37,6 +37,7 @@
 W: maintainer-scripts: gconftool-used-in-maintainer-script postinst:68
 W: maintainer-scripts: init.d-script-not-marked-as-conffile /etc/init.d/foo
 W: maintainer-scripts: maintainer-script-calls-deprecated-wm-menu-config postinst:31
+W: maintainer-scripts: maintainer-script-empty config
 W: maintainer-scripts: maintainer-script-hides-init-failure postinst:55
 W: maintainer-scripts: maintainer-script-needs-depends-on-gconf2 postinst
 W: maintainer-scripts: maintainer-script-needs-depends-on-ucf postinst

Modified: trunk/testset/tags.scripts
===================================================================
--- trunk/testset/tags.scripts	2008-02-09 07:05:00 UTC (rev 1197)
+++ trunk/testset/tags.scripts	2008-02-09 15:58:00 UTC (rev 1198)
@@ -60,6 +60,7 @@
 W: scripts: init.d-script-missing-lsb-keyword /etc/init.d/lsb-broken required-start
 W: scripts: init.d-script-missing-lsb-section /etc/init.d/no-lsb
 W: scripts: init.d-script-not-marked-as-conffile /etc/init.d/skeleton
+W: scripts: maintainer-script-empty preinst
 W: scripts: non-standard-executable-perm usr/bin/perl-bizarre-3 0754 != 0755
 W: scripts: non-standard-setuid-executable-perm usr/bin/suidperlfoo 4555
 W: scripts: package-installs-python-pyc usr/lib/python2.3/site-packages/test.pyc


Reply to: