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

lintian: r604 - in trunk: checks debian testset testset/maintainer-scripts/debian



Author: rra
Date: 2006-04-03 06:34:23 +0200 (Mon, 03 Apr 2006)
New Revision: 604

Modified:
   trunk/checks/scripts
   trunk/checks/scripts.desc
   trunk/debian/changelog
   trunk/testset/maintainer-scripts/debian/postinst
   trunk/testset/maintainer-scripts/debian/postrm
   trunk/testset/maintainer-scripts/debian/prerm
   trunk/testset/tags.maintainer-scripts
Log:
* checks/scripts{.desc,}:
  + [RA] Warn when maintainer scripts run init scripts directly and
    don't use invoke-rc.d.  Thanks, Lars Wirzenius.  (Closes: #353659)

Modified: trunk/checks/scripts
===================================================================
--- trunk/checks/scripts	2006-04-03 03:14:06 UTC (rev 603)
+++ trunk/checks/scripts	2006-04-03 04:34:23 UTC (rev 604)
@@ -416,6 +416,7 @@
 	or fail("cannot open maintainer script $filename for reading: $!");
 
     my ($warned_tmp, $warned_killall, $warned_netbase, $warned_adduser);
+    my ($saw_init, $saw_invoke);
     my $cat_string = "";
 
     while (<C>) {
@@ -436,6 +437,19 @@
 	    tag "mknod-in-maintainer-script", "$file:$.";
 	}
 
+	# Collect information about init script invocations to catch running
+	# init scripts directory rather than through invoke-rc.d.  Since the
+	# script is allowed to run the init script directly if invoke-rc.d
+	# doesn't exist, only tag direct invocations where invoke-rc.d is
+	# never used in the same script.  Lots of false negatives, but
+	# hopefully not many false positives.
+	if (m%^\s*/etc/init.d/(\S+)\s+[\"\']?(\S+)[\"\']?%) {
+	    $saw_init = $.;
+	}
+	if (m%^\s*invoke-rc.d\s+%) {
+	    $saw_invoke = $.;
+	}
+
 	if ($shellscript) {
 	    if (m/^\s*cat\s*\<\<\s*(\w+)/) {
 		$cat_string = $1;
@@ -564,6 +578,10 @@
 	}
     }
 
+    if ($saw_init && ! $saw_invoke) {
+	tag "maintainer-script-calls-init-script-directly", "$file:$saw_init";
+    }
+
     close C;
 
 }

Modified: trunk/checks/scripts.desc
===================================================================
--- trunk/checks/scripts.desc	2006-04-03 03:14:06 UTC (rev 603)
+++ trunk/checks/scripts.desc	2006-04-03 04:34:23 UTC (rev 604)
@@ -297,3 +297,12 @@
  a debhelper version suffering from Bug#337664 that inserted incorrect
  invoke-rc.d code in the generated maintainer script. The package needs to
  be reuploaded (could be bin-NMUd, no source changes needed).
+
+Tag: maintainer-script-calls-init-script-directly
+Type: warning
+Info: This script apparently runs an init script directly rather than
+ using invoke-rc.d.  The use of invoke-rc.d to invoke the /etc/init.d/*
+ initscripts instead of calling them directly is strongly recommended.
+ Maintainer scripts may call the init script directly if invoke-rc.d is
+ not available.
+Ref: policy 9.3.3.2

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2006-04-03 03:14:06 UTC (rev 603)
+++ trunk/debian/changelog	2006-04-03 04:34:23 UTC (rev 604)
@@ -29,17 +29,18 @@
   * checks/po-debconf:
     + [RA] Use system_env instead of system out of caution and to avoid
       extraneous output when CDPATH is set.
-  * checks/scripts:
+  * checks/scripts{.desc,}:
     + [RA] Ignore text inside single quotes and, for most checks, text
       inside double quotes when checking for bashisms.  Reported by Frank
       Küster.  (Closes: #344266)
     + [RA] Change canonical zsh path to /bin/zsh at the request of the zsh
       maintainer.  (Closes: #360534)
-  * checks/scripts.desc:
     + [RA] Change the check for broken error handling with invoke-rc.d to
       maintainer-script-hides-init-failure to be more generic and explain
       what the test looks at.  Add the script name and line number and fix
       a typo.  Thanks, Marc Haber.  (Closes: #360214, #360216)
+    + [RA] Warn when maintainer scripts run init scripts directly and
+      don't use invoke-rc.d.  Thanks, Lars Wirzenius.  (Closes: #353659)
 
   * collection/objdump-info:
     + [RA] Unset CDPATH before running cd to avoid strange effects from

Modified: trunk/testset/maintainer-scripts/debian/postinst
===================================================================
--- trunk/testset/maintainer-scripts/debian/postinst	2006-04-03 03:14:06 UTC (rev 603)
+++ trunk/testset/maintainer-scripts/debian/postinst	2006-04-03 04:34:23 UTC (rev 604)
@@ -53,3 +53,10 @@
 
 # invalid, maintainer-script-hides-init-failure
 invoke-rc.d foo start || exit 0
+
+# The right way to invoke an rc script
+if which invoke-rc.d >/dev/null 2>&1; then
+    invoke-rc.d package start
+else
+    /etc/init.d/package start
+fi

Modified: trunk/testset/maintainer-scripts/debian/postrm
===================================================================
--- trunk/testset/maintainer-scripts/debian/postrm	2006-04-03 03:14:06 UTC (rev 603)
+++ trunk/testset/maintainer-scripts/debian/postrm	2006-04-03 04:34:23 UTC (rev 604)
@@ -20,3 +20,6 @@
 [ "remove" ="$1" ] && ldconfig
 
 update-rc.d bar remove
+
+# Shouldn't provoke an error despite no invoke-rc.d.
+echo "/etc/init.d/package stop to stop something"

Modified: trunk/testset/maintainer-scripts/debian/prerm
===================================================================
--- trunk/testset/maintainer-scripts/debian/prerm	2006-04-03 03:14:06 UTC (rev 603)
+++ trunk/testset/maintainer-scripts/debian/prerm	2006-04-03 04:34:23 UTC (rev 604)
@@ -49,3 +49,6 @@
 
 # Still catch disallowed expansions in double-quotes, though.
 echo "${line:3:1}"
+
+# The wrong way to run an init script (no invoke-rc.d).
+/etc/init.d/package stop

Modified: trunk/testset/tags.maintainer-scripts
===================================================================
--- trunk/testset/tags.maintainer-scripts	2006-04-03 03:14:06 UTC (rev 603)
+++ trunk/testset/tags.maintainer-scripts	2006-04-03 04:34:23 UTC (rev 604)
@@ -25,6 +25,7 @@
 W: maintainer-scripts: deprecated-chown-usage postinst:33 'chown root.root'
 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-calls-init-script-directly prerm:54
 W: maintainer-scripts: maintainer-script-hides-init-failure postinst:55
 W: maintainer-scripts: missing-debconf-dependency
 W: maintainer-scripts: no-debconf-templates



Reply to: