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

[SCM] Debian package checker branch, master, updated. 2.5.12-131-gdd0a448



The following commit has been merged in the master branch:
commit dd0a448c2793a151c0bca09009b33a043aebd67c
Author: Bastien ROUCARIÈS <roucaries.bastien@gmail.com>
Date:   Mon May 20 20:26:22 2013 +0200

    Warn about any reference to /lib/init in init.d scripts
    
    /lib/init/rw has gone away, and the scripts in /lib/init/*.sh represent
    internal implementation details of initscripts, *not* public API for
    other packages to use.  Nonetheless, some packages incorrectly reference
    those scripts, notably /lib/init/vars.sh.
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/checks/init.d b/checks/init.d
index b081b2a..eb4dc7b 100644
--- a/checks/init.d
+++ b/checks/init.d
@@ -73,7 +73,7 @@ our $INITD_NAME_REGEX = qr/[\w\.\+][\w\-\.\+]*/;
 
 sub run {
 
-my (undef, undef, $info) = @_;
+my ($pkg, undef, $info) = @_;
 
 my $initd_dir = $info->lab_data_path ('init.d');
 
@@ -181,7 +181,7 @@ foreach my $initd_file (keys %initd_postinst) {
     # Check if file exists in package and check the script for other issues if
     # it was included in the package.
     if (-f $initd_path) {
-        check_init ($initd_file, $initd_path);
+        check_init($initd_file, $initd_path, $pkg);
     } elsif (not -l $initd_path) {
         tag 'init.d-script-not-included-in-package', "etc/init.d/$initd_file";
     }
@@ -210,7 +210,7 @@ for my $script (readdir($dirfd)) {
     # that we get more complete Lintian coverage in the first pass.
     unless ($initd_postinst{$script}) {
         tag $tagname, "etc/init.d/$script";
-        check_init ($script, $script_path) if -f $script_path;
+        check_init($script, $script_path, $pkg) if -f $script_path;
     }
 }
 closedir($dirfd);
@@ -218,7 +218,7 @@ closedir($dirfd);
 }
 
 sub check_init {
-    my ($initd_file, $initd_path) = @_;
+    my ($initd_file, $initd_path, $pkg) = @_;
 
     # In an upstart system, such as Ubuntu, init scripts are symlinks to
     # upstart-job.  It doesn't make sense to check the syntax of upstart-job,
@@ -291,6 +291,13 @@ sub check_init {
         $needs_fs{'remote'} = 1 if ($l =~ m,^[^\#]*/usr/,);
         $needs_fs{'local'}  = 1 if ($l =~ m,^[^\#]*/var/,);
 
+        # /lib/init/* scripts are only for use by init
+        if ($pkg ne 'initscripts') {
+            if ($l =~ m,^[^\#]*/lib/init/,) {
+                tag 'init.d-script-call-internal-API', "etc/init.d/${initd_file}";
+            }
+        }
+
         while ($l =~ s/^[^\#]*?(start|stop|restart|force-reload|status)//o) {
             $tag{$1} = 1;
         }
diff --git a/checks/init.d.desc b/checks/init.d.desc
index 84a8c7a..526dfe9 100644
--- a/checks/init.d.desc
+++ b/checks/init.d.desc
@@ -366,3 +366,13 @@ Info: The given init script declares a dependency on a virtual facility
  If the dependency can not be satisfied upon the package's
  installation, insserv will refuse the activation of the init.d script.
 Ref: http://wiki.debian.org/LSBInitScripts
+
+Tag: init.d-script-call-internal-API
+Severity: normal
+Certainty: possible
+Info: The given init script call an internal API under
+ <tt>/lib/init</tt>.  <tt>/lib/init/rw</tt> has gone away, and the
+ scripts in <tt>/lib/init/*.sh</tt> represent internal implementation
+ details of initscripts.  They are not public API for other packages
+ to use.  Nonetheless, some packages incorrectly reference those
+ scripts, notably /lib/init/vars.sh.
diff --git a/debian/changelog b/debian/changelog
index dd5eb17..4f3d0ec 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -70,9 +70,12 @@ lintian (2.5.13) UNRELEASED; urgency=low
   * checks/group-checks.desc:
     + [NT] Add missing semi-colon in tag description.  Thanks to
       Andrey Rahmatullin for the report.  (Closes: #706827)
-  * checks/init.d:
+  * checks/init.d{,.desc}:
     + [NT] Add missing import of utility function that could cause
       Lintian to crash in some cases.
+    + [NT] Add check for uses of /lib/init in maintainer scripts.
+      Thanks to Josh Triplett for the report and to Bastien
+      Roucariès for the patch.  (Closes: #670092)
   * checks/menu-format:
     + [NT] Fix use of uninitialized variable when menu file uses a
       section of "/".  (Closes: #708755)
diff --git a/t/tests/files-bad-perm-owner/debian/debian/binary.init b/t/tests/files-bad-perm-owner/debian/debian/binary.init
index e51bb78..32f2618 100644
--- a/t/tests/files-bad-perm-owner/debian/debian/binary.init
+++ b/t/tests/files-bad-perm-owner/debian/debian/binary.init
@@ -12,8 +12,6 @@ set -e
 # Description: Does nothing
 ### END INIT INFO
 
-. /lib/init/vars.sh
-
 case "$1" in
     start|stop|force-reload|restart|status|*)
 	echo hello world
diff --git a/t/tests/init.d-general/debian/debian/control.in b/t/tests/init.d-general/debian/debian/control.in
index 7b01af0..c831e9e 100644
--- a/t/tests/init.d-general/debian/debian/control.in
+++ b/t/tests/init.d-general/debian/debian/control.in
@@ -43,3 +43,13 @@ Description: {$description} -- sourcing without test
  This is a test package designed to exercise some feature or tag of
  Lintian.  It is part of the Lintian test suite and may do very odd
  things.  It should not be installed like a regular package.
+
+Package: {$srcpkg}-script-call-internal-api
+Architecture: {$architecture}
+Depends: $\{shlibs:Depends\}, $\{misc:Depends\}
+Description: {$description} -- sourcing internal API
+ Test a check for . /lib/init sourcing that is use of internal API
+ .
+ This is a test package designed to exercise some feature or tag of
+ Lintian.  It is part of the Lintian test suite and may do very odd
+ things.  It should not be installed like a regular package.
diff --git a/t/tests/init.d-general/debian/debian/init.d-general-script-call-internal-api.init b/t/tests/init.d-general/debian/debian/init.d-general-script-call-internal-api.init
new file mode 100644
index 0000000..5d36ab0
--- /dev/null
+++ b/t/tests/init.d-general/debian/debian/init.d-general-script-call-internal-api.init
@@ -0,0 +1,23 @@
+#! /bin/bash
+
+### BEGIN INIT INFO
+# Provides:          init.d-general-script-call-internal-api
+# Required-Start:    $local_fs $remote_fs $network $named $time
+# Required-Stop:     $local_fs $remote_fs $network $named $time
+# Should-Start:      $syslog
+# Should-Stop:       $syslog
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Starts The Onion Router daemon processes
+# Description:       Start The Onion Router, a TCP overlay
+#                    network client that provides anonymous
+#                    transport.
+### END INIT INFO
+
+# Load the VERBOSE setting and other rcS variables (internal API)
+. /lib/init/vars.sh
+
+# Define LSB log_* functions.
+. /lib/lsb/init-functions
+
+printf "start status stop reload restart force-reload\n";
diff --git a/t/tests/init.d-general/desc b/t/tests/init.d-general/desc
index 6f4711f..87f66b5 100644
--- a/t/tests/init.d-general/desc
+++ b/t/tests/init.d-general/desc
@@ -8,3 +8,4 @@ Test-For:
  init.d-script-does-not-implement-required-option
  init.d-script-sourcing-without-test
  init.d-script-uses-usr-interpreter
+ init.d-script-call-internal-API
diff --git a/t/tests/init.d-general/tags b/t/tests/init.d-general/tags
index 818f511..5665d79 100644
--- a/t/tests/init.d-general/tags
+++ b/t/tests/init.d-general/tags
@@ -6,3 +6,4 @@ E: init.d-general-bugs: init.d-script-does-not-implement-required-option etc/ini
 E: init.d-general-sourcing-without-test: init.d-script-sourcing-without-test etc/init.d/init.d-general-sourcing-without-test:15 /etc/default/rcS
 I: init.d-general-bugs: init.d-script-does-not-implement-optional-option etc/init.d/init.d-general-bugs status
 W: init.d-general-interpreter-in-usr-dir: init.d-script-uses-usr-interpreter etc/init.d/init.d-general-interpreter-in-usr-dir /usr/bin/perl
+W: init.d-general-script-call-internal-api: init.d-script-call-internal-API etc/init.d/init.d-general-script-call-internal-api
diff --git a/t/tests/init.d-lsb-headers/debian/debian/init.d-lsb-headers-missing.init b/t/tests/init.d-lsb-headers/debian/debian/init.d-lsb-headers-missing.init
index c315953..88b55a2 100644
--- a/t/tests/init.d-lsb-headers/debian/debian/init.d-lsb-headers-missing.init
+++ b/t/tests/init.d-lsb-headers/debian/debian/init.d-lsb-headers-missing.init
@@ -10,8 +10,6 @@ set -e
 # Default-Stop: 0 6
 ### END INIT INFO
 
-. /lib/init/vars.sh
-
 case "$1" in
     start|stop|force-reload|restart|status|*)
 	echo hello world
diff --git a/t/tests/init.d-lsb-headers/debian/debian/init.d-lsb-headers-virtual.init b/t/tests/init.d-lsb-headers/debian/debian/init.d-lsb-headers-virtual.init
index 032163c..6c55c20 100644
--- a/t/tests/init.d-lsb-headers/debian/debian/init.d-lsb-headers-virtual.init
+++ b/t/tests/init.d-lsb-headers/debian/debian/init.d-lsb-headers-virtual.init
@@ -13,8 +13,6 @@ set -e
 # Description: The short description pretty much covers it.
 ### END INIT INFO
 
-. /lib/init/vars.sh
-
 case "$1" in
     start|stop|force-reload|restart|status|*)
 	echo hello world

-- 
Debian package checker


Reply to: