The following commit has been merged in the master branch:
commit c51f40a85bda632c3d4c1b0d14d9c7e158c355b6
Author: Raphael Geissert <atom...@gmail.com>
Date:   Sat May 8 20:22:31 2010 -0500

    Check for init.d scripts depending on unknown virtual facilities
    
    * checks/init.d{,.desc}:
      + [RG] Check for init.d scripts depending on unknown virtual
        facilities.
    * data/init.d/data/init.d/virtual_facilities
      + [RG] New list of virtual facilities that exist in the archive.
    * private/refresh-insserv-data:
      + [RG] New script to collect insserv data from the archive.

diff --git a/checks/init.d b/checks/init.d
index a4ca6b0..d40f57d 100644
--- a/checks/init.d
+++ b/checks/init.d
@@ -51,6 +51,8 @@ my %implied_dependencies =
      'sysklogd'   => '$syslog'
     );
 
+our $VIRTUAL_FACILITIES = Lintian::Data->new('init.d/virtual_facilities');
+
 sub run {
 
 my $pkg = shift;
@@ -404,6 +406,10 @@ sub check_init {
                tag 'init.d-script-should-depend-on-virtual-facility',
                    "/etc/init.d/$_",
                    "$dependency -> $implied_dependencies{$dependency}";
+           } elsif ($keyword =~ m/^required-/ && $dependency =~ m/^\$/) {
+               tag "init.d-script-depends-on-unknown-virtual-facility",
+                   "/etc/init.d/$_", "$dependency"
+                   unless ($VIRTUAL_FACILITIES->known($dependency));
            }
        }
     }
diff --git a/checks/init.d.desc b/checks/init.d.desc
index df0e92f..1bca796 100644
--- a/checks/init.d.desc
+++ b/checks/init.d.desc
@@ -331,3 +331,12 @@ Info: The given init script seems to refer to 
<tt>/var</tt>, possibly
  conceptually incorrect since the $local_fs facility is always
  available.  Required-Start or Required-Stop should be used instead.
 Ref: http://wiki.debian.org/LSBInitScripts
+
+Tag: init.d-script-depends-on-unknown-virtual-facility
+Severity: serious
+Certainty: possible
+Info: The given init script declares a dependency on a virtual facility
+ that is not known to be provided by any init.d script in the archive.
+ 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
diff --git a/data/init.d/virtual_facilities b/data/init.d/virtual_facilities
new file mode 100644
index 0000000..043aec4
--- /dev/null
+++ b/data/init.d/virtual_facilities
@@ -0,0 +1,13 @@
+# The list of known virtual facilities that init scripts may depend on.
+#
+# Last updated: 2010-05-02
+
+$local_fs
+$named
+$network
+$portmap
+$remote_fs
+$syslog
+$time
+$x-display-manager
+$x-font-server
diff --git a/debian/changelog b/debian/changelog
index 93531f3..6a9df92 100755
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,9 @@
 lintian (2.4.2) UNRELEASED; urgency=low
 
+  * Summary of tag changes:
+    + Added:
+      - init.d-script-depends-on-unknown-virtual-facility
+
   * checks/fields:
     + [RA] Allow Breaks without a version if the broken package is a
       virtual package.
@@ -7,6 +11,9 @@ lintian (2.4.2) UNRELEASED; urgency=low
     + [RA] Count file size from the tar listing rather than using du.  The
       results of du vary based on file system and other factors and make
       the tag difficult to test.
+  * checks/init.d{,.desc}:
+    + [RG] Check for init.d scripts depending on unknown virtual
+      facilities.
   * checks/menu-format.desc:
     + [RA] Fix typo in long description of duplicated-key-in-desktop-entry.
       Thanks, Niels Thykier.  (Closes: #580700)
@@ -14,6 +21,8 @@ lintian (2.4.2) UNRELEASED; urgency=low
   * data/fields/virtual-packages:
     + [RA] Update to current unstable and add the old xserver-xorg video
       and input virtual packages.
+  * data/init.d/data/init.d/virtual_facilities
+    + [RG] New list of virtual facilities that exist in the archive.
 
   * frontend/lintian:
     + [RA] Set a PATH of /bin:/usr/bin if PATH is completely unset.
@@ -23,6 +32,8 @@ lintian (2.4.2) UNRELEASED; urgency=low
     + [RA] Rather than allowing only a package name or a substvar, allow
       substvars mixed into the package name.  (Closes: #580494)
 
+  * private/refresh-insserv-data:
+    + [RG] New script to collect insserv data from the archive.
   * private/refresh-virtual-packages-data:
     + [RA] Fix handling of # Keep: lines to work correctly now that
       virtual packages mentioned only once are excluded.
diff --git a/private/refresh-insserv-data b/private/refresh-insserv-data
new file mode 100755
index 0000000..c681b11
--- /dev/null
+++ b/private/refresh-insserv-data
@@ -0,0 +1,94 @@
+#!/bin/sh
+
+####################
+#    Copyright (C) 2008, 2010 by Raphael Geissert <atom...@gmail.com>
+#
+#
+#    This file is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This file is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this file.  If not, see <http://www.gnu.org/licenses/>.
+####################
+
+set -eu
+
+if [ -z "${1:-}" ]; then
+    printf "Usage: %s path/to/lintian/data\n" \
+       "$(basename "$0")"
+    cat <<INFO
+
+The script downloads the following files from a mirror (which should be
+specified via the DEB_MIRROR env var, which defaults to 
+http://i386-geomirror.debian.net/debian and is used directly without any
+kind of parsing so one can play with it):
+* Contents-i386.gz, main/binary-i386/Packages.gz
+* Binary packages found at Contents shipping insser.conf.d files
+Any special parameter can be passed to wget via WGET_ARGS, if needed.
+
+Other options:
+Other variables such as GREP_OPTIONS can be used to enable things like --mmap.
+INFO
+    exit
+fi
+
+readonly lintian_data="$(readlink -f "$1")"
+readonly regex='^etc/insserv.conf.'
+readonly perl_regex='^etc/insserv\.conf.*?\s+[\w-]+/([^,]+).*'
+
+[ -d "$lintian_data" ] || {
+    printf "%s is not a directory, aborting" "$lintian_data" >&2
+    exit 1
+}
+
+readonly workdir="$(mktemp -d)"
+
+cleanup () {
+        [ ! -d "$workdir" ] || rm -rf "$workdir"
+}; trap cleanup EXIT
+
+cat > "$workdir/virtual_facilities" <<EOF
+# The list of known virtual facilities that init scripts may depend on.
+#
+# Last updated: $(date -u +'%Y-%m-%d')
+
+EOF
+
+mirror="${DEB_MIRROR:=http://i386-geomirror.debian.net/debian}";
+WGET_ARGS="${WGET_ARGS:=-nv}"
+wget() {
+    echo wget "$mirror"/"$1"
+    /usr/bin/wget $WGET_ARGS "$mirror"/"$1"
+}
+mkdir -p "$lintian_data/init.d"
+
+cd "$workdir"
+wget dists/sid/Contents-i386.gz
+zgrep -E "$regex" Contents-i386.gz > entries
+cat entries \
+    | perl -p -w -E 's#'"$perl_regex"'#$1#g;' \
+    | LC_ALL=C sort -u > packages
+
+wget dists/sid/main/binary-i386/Packages.gz
+gunzip Packages.gz
+for package in $(cat packages); do
+    fn="$(grep-dctrl -n -P -X "$package" -sFilename Packages)"
+    wget "$fn"
+    file="$(basename "$fn")"
+    dpkg-deb -x "$file" "$(mktemp -d -p .)"
+    rm -rf "$file"
+    find */ | grep -Ev '^[^/]+/etc/insserv.+$' \
+       | xargs rm >/dev/null 2>&1 || true
+    find */ -type l -print | xargs rm >/dev/null 2>&1 || true
+done
+
+sed -nr '/^\$/{s/\s.*$//;p}' */etc/insserv.conf */etc/insserv.conf.d/* |
+    sort -u >> virtual_facilities
+mv virtual_facilities "$lintian_data/init.d/"
diff --git a/t/tests/init.d-lsb-headers/debian/debian/control.in 
b/t/tests/init.d-lsb-headers/debian/debian/control.in
index a339b2a..d70d06d 100644
--- a/t/tests/init.d-lsb-headers/debian/debian/control.in
+++ b/t/tests/init.d-lsb-headers/debian/debian/control.in
@@ -52,3 +52,11 @@ Description: {$description} -- missing runlevels
  This is yet another test package designed to exercise the checking of
  init scripts by 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}-virtual
+Architecture: {$architecture}
+Depends: $\{shlibs:Depends\}, $\{misc:Depends\}
+Description: {$description} -- virtual facilities
+ Test package to exercise the virtual facilities in init.d scripts
+ checks by 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-lsb-headers/desc b/t/tests/init.d-lsb-headers/desc
index 058e3a9..8bb44c4 100644
--- a/t/tests/init.d-lsb-headers/desc
+++ b/t/tests/init.d-lsb-headers/desc
@@ -4,6 +4,7 @@ Version: 1.0
 Description: Test tags related to init script LSB headers
 Test-For:
  init-d-script-stops-in-s-runlevel
+ init.d-script-depends-on-unknown-virtual-facility
  init.d-script-does-not-provide-itself
  init.d-script-has-bad-start-runlevel
  init.d-script-has-bad-stop-runlevel
diff --git a/t/tests/init.d-lsb-headers/tags b/t/tests/init.d-lsb-headers/tags
index da23fe4..9b1b266 100644
--- a/t/tests/init.d-lsb-headers/tags
+++ b/t/tests/init.d-lsb-headers/tags
@@ -1,5 +1,6 @@
 E: init.d-lsb-headers-local: init.d-script-missing-dependency-on-local_fs 
/etc/init.d/init.d-lsb-headers-local: required-start
 E: init.d-lsb-headers-remote: init.d-script-missing-dependency-on-remote_fs 
/etc/init.d/init.d-lsb-headers-remote: required-start
+E: init.d-lsb-headers-virtual: 
init.d-script-depends-on-unknown-virtual-facility 
/etc/init.d/init.d-lsb-headers-virtual $something_that_doesnt_exist
 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

-- 
Debian package checker


-- 
To UNSUBSCRIBE, email to debian-lint-maint-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/e1oaxjf-0000zu...@alioth.debian.org

Reply via email to