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

[SCM] Debian package checker branch, master, updated. 2.2.14-44-gfee7702



The following commit has been merged in the master branch:
commit 04a77b09efc851c6f07e4e6aa0a93b32ca48b11f
Author: Russ Allbery <rra@debian.org>
Date:   Sun Sep 13 13:07:38 2009 -0700

    Reformatting and adjustment of new init.d checks
    
    Change some of the new tag names to be more idiomatic (and shorter)
    English and reword the long tag descriptions.  Reformat the code a
    bit and avoid some long variable names.

diff --git a/checks/init.d b/checks/init.d
index bcc4fe7..a6bb3ae 100644
--- a/checks/init.d
+++ b/checks/init.d
@@ -34,16 +34,21 @@ my %lsb_keywords = (provides		=> 1,
 		    'short-description' => 1,
 		    'description'	=> 0);
 
-my %common_implied_dependencies = ('mountall' => '$local_fs',
-				    'mountnfs' => '$remote_fs',
-				    'hwclock' => '$time',
-				    'portmap' => '$portmap',
-				    'named' => '$named',
-				    'bind9' => '$named',
-				    'networking' => '$network',
-				    'syslog' => '$syslog',
-				    'rsyslog' => '$syslog',
-				    'sysklogd' => '$syslog');
+# These init script names should probably not be used in dependencies.
+# Instead, the corresponding virtual facility should be used.
+my %implied_dependencies =
+    (
+     'mountall'   => '$local_fs',
+     'mountnfs'   => '$remote_fs',
+     'hwclock'    => '$time',
+     'portmap'    => '$portmap',
+     'named'      => '$named',
+     'bind9'      => '$named',
+     'networking' => '$network',
+     'syslog'     => '$syslog',
+     'rsyslog'    => '$syslog',
+     'sysklogd'   => '$syslog'
+    );
 
 sub run {
 
@@ -265,10 +270,13 @@ sub check_init {
 	for my $runlevel (split (/\s+/, $lsb{'default-start'})) {
 	    if ($runlevel =~ /^[sS0-6]$/) {
 		$start{lc $runlevel} = 1;
-		tag "init.d-script-starts-in-stop-runlevel", "/etc/init.d/$_ $runlevel"
-		    if ($runlevel =~ /^(?:0|6)$/);
+		if ($runlevel eq '0' or $runlevel eq '6') {
+		    tag 'init.d-script-starts-in-stop-runlevel',
+			"/etc/init.d/$_", $runlevel;
+		}
 	    } else {
-		tag "init.d-script-has-bad-start-runlevel", "/etc/init.d/$_ $runlevel";
+		tag 'init.d-script-has-bad-start-runlevel', "/etc/init.d/$_",
+		    $runlevel;
 	    }
 	}
     }
@@ -287,25 +295,27 @@ sub check_init {
 	}
     }
     if ($lsb{'provides'}) {
-	my $named_after_script = 0;
+	my $provides_self;
 	for my $facility (split(/\s+/, $lsb{'provides'})) {
 	    if ($facility =~ /^\$/) {
-		tag "init.d-script-provides-virtual-facility-in-header",
-		    "/etc/init.d/$_ $facility";
+		tag 'init.d-script-provides-virtual-facility',
+		    "/etc/init.d/$_", $facility;
+	    }
+	    if (/^\Q$facility\E(?:.sh)?$/) {
+		$provides_self = 1;
 	    }
-	    $named_after_script = 1
-		if ($_ =~ m/^\Q$facility\E(?:.sh)?$/);
 	}
-	tag "init.d-script-provides-not-after-its-name", "/etc/init.d/$_"
-	    unless ($named_after_script);
+	tag 'init.d-script-does-not-provide-itself', "/etc/init.d/$_"
+	    unless $provides_self;
     }
 
     for my $keyword qw(required-start should-start required-stop should-stop) {
-	next unless defined($lsb{$keyword});
+	next unless defined $lsb{$keyword};
 	for my $dependency (split(/\s+/, $lsb{$keyword})) {
-	    if (defined($common_implied_dependencies{$dependency})) {
-		tag "init.d-script-dependency-better-on-virtual-facility",
-			"/etc/init.d/$_ $dependency -> $common_implied_dependencies{$dependency}";
+	    if (defined $implied_dependencies{$dependency}) {
+		tag 'init.d-script-should-depend-on-virtual-facility',
+		    "/etc/init.d/$_",
+		    "$dependency -> $implied_dependencies{$dependency}";
 	    }
 	}
     }
diff --git a/checks/init.d.desc b/checks/init.d.desc
index d4eda6d..0ff2009 100644
--- a/checks/init.d.desc
+++ b/checks/init.d.desc
@@ -231,41 +231,50 @@ Ref: policy 9.3.2
 Tag: init.d-script-starts-in-stop-runlevel
 Severity: normal
 Certainty: certain
-Info: This <tt>/etc/init.d</tt> script specifies the 6 or 0 runlevel in
+Info: This <tt>/etc/init.d</tt> script specifies the 0 or 6 runlevels in
  Default-Start in its LSB keyword section.  The 0 and 6 runlevels are
- meant to only stop services, not to start them.  If the intention is
- to do something that might not exactly be stopping a service at one of
- those runlevels the script should anyway specify them in Default-Stop
- and perform the actions when passed the <tt>stop</tt> argument.
+ meant to only stop services, not to start them.  Even if the init script
+ is doing something that isn't exactly stopping a service, the run-level
+ should be listed in Default-Stop, not Default-Start, and the script
+ should perform those actions when passed the <tt>stop</tt> argument.
 
-Tag: init.d-script-provides-virtual-facility-in-header
+Tag: init.d-script-provides-virtual-facility
 Severity: normal
 Certainty: certain
-Info: This <tt>/etc/init.d</tt> script indicates it provides a virtual
- facility, denoted by the dollar sign in front of the name.
- Virtual facilities are declared as provided by shipping a file,
- usually named after the package to avoid file conflicts, that is
- installed in <tt>/etc/insserv.conf.d</tt> with its content on the
- following format: <tt>$virtual_facility_name +init-script-name</tt>.
+Info: This <tt>/etc/init.d</tt> script indicates in its LSB headers that
+ it provides a virtual facility, denoted by the dollar sign in front of
+ the name.
+ .
+ This is not the correct way to provide a virtual facility.  Instead, the
+ package should include a file in <tt>/etc/insserv.conf.d</tt>, usually
+ named after the package, containing:
+ .
+  $virtual_facility_name +init-script-name
+ .
+ to declare that the named init script provides the named virtual
+ facility.
 Ref: http://wiki.debian.org/LSBInitScripts/DebianVirtualFacilities
 
-Tag: init.d-script-provides-not-after-its-name
+Tag: init.d-script-does-not-provide-itself
 Severity: normal
 Certainty: possible
 Info: This <tt>/etc/init.d</tt> script indicates it provides one or
- more facilities but none is named after the name of the init script.
- Although in certain cases it might be necessary not to follow that
- naming convention, in most cases that's the right way to name the
- facility provided by the init script.
+ more facilities, but none of the provided facilities match the name of
+ the init script.  In certain cases, it may be necessary to not follow
+ that convention, but normally init scripts should always provide a
+ facility matching the name of the init script.
 Ref: http://wiki.debian.org/LSBInitScripts
 
-Tag: init.d-script-dependency-better-on-virtual-facility
+Tag: init.d-script-should-depend-on-virtual-facility
 Severity: important
 Certainty: possible
 Info: The given <tt>/etc/init.d</tt> script depends on a non-virtual
- facility although it should probably depend on the virtual facility
- that implies that facility. One such example is when a dependency on
- <tt>networking</tt> is declared, although the script should probably
- depend on <tt>$network</tt> instead, which will pull in whataver
- init script provides that virtual facility, therefore accomodating to
- other setups and requirements.
+ facility that should probably be replaced by a vitual facility.  For
+ example, init scripts should depend on the virtual facility
+ <tt>$network</tt> rather than the facility <tt>networking</tt>, and the
+ virtual facility <tt>$named</tt> rather than the specific facility
+ <tt>bind9</tt>.
+ .
+ Properly using virtual facilities allows multiple implementations of the
+ same facility and accomodates systems where that specific facility may
+ not be enough to provide everything the script expects.
diff --git a/t/tests/init.d-lsb-headers/desc b/t/tests/init.d-lsb-headers/desc
index 6466b13..76de822 100644
--- a/t/tests/init.d-lsb-headers/desc
+++ b/t/tests/init.d-lsb-headers/desc
@@ -1,12 +1,12 @@
 Testname: init.d-lsb-headers
 Sequence: 6000
 Version: 1.0
-Description: Test tags related to the init.d lsb header checks
+Description: Test tags related to init script LSB headers
 Test-For:
+ init-d-script-stops-in-s-runlevel
+ init.d-script-does-not-provide-itself
  init.d-script-has-bad-start-runlevel
  init.d-script-has-bad-stop-runlevel
- init-d-script-stops-in-s-runlevel
+ init.d-script-provides-virtual-facility
+ init.d-script-should-depend-on-virtual-facility
  init.d-script-starts-in-stop-runlevel
- init.d-script-provides-virtual-facility-in-header
- init.d-script-provides-not-after-its-name
- init.d-script-dependency-better-on-virtual-facility
diff --git a/t/tests/init.d-lsb-headers/tags b/t/tests/init.d-lsb-headers/tags
index 6801139..b60faf0 100644
--- a/t/tests/init.d-lsb-headers/tags
+++ b/t/tests/init.d-lsb-headers/tags
@@ -1,12 +1,12 @@
-E: init.d-lsb-headers: init.d-script-dependency-better-on-virtual-facility /etc/init.d/init.d-lsb-headers mountall -> $local_fs
-E: init.d-lsb-headers: init.d-script-dependency-better-on-virtual-facility /etc/init.d/init.d-lsb-headers mountnfs -> $remote_fs
-E: init.d-lsb-headers: init.d-script-dependency-better-on-virtual-facility /etc/init.d/init.d-lsb-headers networking -> $network
-E: init.d-lsb-headers: init.d-script-dependency-better-on-virtual-facility /etc/init.d/init.d-lsb-headers portmap -> $portmap
-E: init.d-lsb-headers: init.d-script-dependency-better-on-virtual-facility /etc/init.d/init.d-lsb-headers sysklogd -> $syslog
+E: init.d-lsb-headers: init.d-script-should-depend-on-virtual-facility /etc/init.d/init.d-lsb-headers mountall -> $local_fs
+E: init.d-lsb-headers: init.d-script-should-depend-on-virtual-facility /etc/init.d/init.d-lsb-headers mountnfs -> $remote_fs
+E: init.d-lsb-headers: init.d-script-should-depend-on-virtual-facility /etc/init.d/init.d-lsb-headers networking -> $network
+E: init.d-lsb-headers: init.d-script-should-depend-on-virtual-facility /etc/init.d/init.d-lsb-headers portmap -> $portmap
+E: init.d-lsb-headers: init.d-script-should-depend-on-virtual-facility /etc/init.d/init.d-lsb-headers sysklogd -> $syslog
 W: init.d-lsb-headers: init-d-script-stops-in-s-runlevel /etc/init.d/init.d-lsb-headers
+W: init.d-lsb-headers: init.d-script-does-not-provide-itself /etc/init.d/init.d-lsb-headers
 W: init.d-lsb-headers: init.d-script-has-bad-start-runlevel /etc/init.d/init.d-lsb-headers X
 W: init.d-lsb-headers: init.d-script-has-bad-stop-runlevel /etc/init.d/init.d-lsb-headers Y
-W: init.d-lsb-headers: init.d-script-provides-not-after-its-name /etc/init.d/init.d-lsb-headers
-W: init.d-lsb-headers: init.d-script-provides-virtual-facility-in-header /etc/init.d/init.d-lsb-headers $bad_facility
+W: init.d-lsb-headers: init.d-script-provides-virtual-facility /etc/init.d/init.d-lsb-headers $bad_facility
 W: init.d-lsb-headers: init.d-script-starts-in-stop-runlevel /etc/init.d/init.d-lsb-headers 0
 W: init.d-lsb-headers: init.d-script-starts-in-stop-runlevel /etc/init.d/init.d-lsb-headers 6

-- 
Debian package checker


Reply to: