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

[SCM] Debian package checker branch, master, updated. 2.2.14-30-g19af980



The following commit has been merged in the master branch:
commit 77c3031fa3e2cecefd338b480ae89b17077e03bb
Author: Damyan Ivanov <dmn@debian.org>
Date:   Sun Sep 13 11:32:55 2009 -0700

    Check example scripts with a distinct set of tags
    
    * checks/scripts:
      + [RA] Check example scripts for most of the same issues as scripts
        elsewhere in the package, but report problems with a different set
        of tags with pedantic severity.  Patch from Damyan Ivanov.
        (Closes: #543873)

diff --git a/checks/scripts b/checks/scripts
index 2ce8d8c..a653965 100644
--- a/checks/scripts
+++ b/checks/scripts
@@ -276,6 +276,15 @@ our @bashism_regexs = (
     $LEADIN . qr'(sh|\$\{?SHELL\}?) [-+]O', # sh [-+]O
 );
 
+# a local function to help use separate tags for example scripts
+sub script_tag {
+    my( $tag, $filename, @rest ) = @_;
+
+    $tag = "example-$tag"
+        if $filename and $filename =~ m,usr/share/doc/[^/]+/examples/,;
+
+    tag( $tag, $filename, @rest );
+}
 
 sub run {
 
@@ -323,8 +332,12 @@ for my $filename (sort keys %{$info->scripts}) {
     $filename = './' . $filename;
     $scripts{$filename} = 1;
 
+    my $in_docs = $filename =~ m,usr/share/doc/,;
+    my $in_examples = $filename =~ m,usr/share/doc/[^/]+/examples/,;
+
     # no checks necessary at all for scripts in /usr/share/doc/
-    next if $filename =~ m,usr/share/doc/,;
+    # unless they are examples
+    next if $in_docs and !$in_examples;
 
     my ($base) = $interpreter =~ m,([^/]*)$,;
 
@@ -337,15 +350,15 @@ for my $filename (sort keys %{$info->scripts}) {
     # an absolute path and are not in a bin/ directory (/usr/bin, /bin etc)
     # They are probably not scripts after all.
     next if ($filename !~ m,(bin/|etc/init\.d/), and !$executable{$filename}
-             and !$is_absolute);
+             and !$is_absolute and !$in_examples);
 
     if ($interpreter eq "") {
-	tag("script-without-interpreter", $filename);
+	script_tag("script-without-interpreter", $filename);
 	next;
     }
 
     # Either they use an absolute path or they use '/usr/bin/env interp'.
-    tag("interpreter-not-absolute", $filename, "#!$interpreter")
+    script_tag("interpreter-not-absolute", $filename, "#!$interpreter")
 	unless $is_absolute;
     tag("script-not-executable", $filename)
 	unless ($executable{$filename}
@@ -356,13 +369,15 @@ for my $filename (sort keys %{$info->scripts}) {
 		or $filename =~ m,\.ex$,
 		or $filename eq './etc/init.d/skeleton'
 		or $filename =~ m,^\./etc/menu-methods,
-		or $filename =~ m,^\./etc/X11/Xsession\.d,);
+		or $filename =~ m,^\./etc/X11/Xsession\.d,)
+		or $in_docs;
 
     # Warn about csh scripts.
     tag("csh-considered-harmful", $filename)
         if (($base eq 'csh' or $base eq 'tcsh')
 	    and $executable{$filename}
-	    and $filename !~ m,^\./etc/csh/login\.d/,);
+	    and $filename !~ m,^\./etc/csh/login\.d/,)
+	    and !$in_docs;
 
     # Syntax-check most shell scripts, but don't syntax-check scripts that end
     # in .dpatch.  bash -n doesn't stop checking at exit 0 and goes on to blow
@@ -375,7 +390,7 @@ for my $filename (sort keys %{$info->scripts}) {
 	    and $base !~ m/^(z|t?c)sh$/) {
 
 	    if (check_script_syntax($interpreter, "unpacked/$filename")) {
-		tag("shell-script-fails-syntax-check", $filename);
+		script_tag("shell-script-fails-syntax-check", $filename);
 	    }
 	}
     }
@@ -398,20 +413,20 @@ for my $filename (sort keys %{$info->scripts}) {
     if ($data) {
 	my $expected = $data->[0] . '/' . $base;
 	unless ($interpreter eq $expected or defined $calls_env) {
-	    tag("wrong-path-for-interpreter",
-		"#!$interpreter != $expected", "($filename)");
+	    script_tag("wrong-path-for-interpreter", $filename,
+		"(#!$interpreter != $expected)");
 	}
     } elsif ($interpreter =~ m,/usr/local/,) {
-	tag("interpreter-in-usr-local", $filename, "#!$interpreter");
+	script_tag("interpreter-in-usr-local", $filename, "#!$interpreter");
     } elsif ($executable{'.' . $interpreter}) {
 	# Package installs the interpreter itself, so it's probably ok.  Don't
 	# emit any tag for this.
     } elsif ($base eq 'suidperl') {
 	tag("calls-suidperl-directly", $filename);
     } elsif ($interpreter eq '/bin/env') {
-	tag("script-uses-bin-env", $filename);
+	script_tag("script-uses-bin-env", $filename);
     } else {
-	tag("unusual-interpreter", $filename, "#!$interpreter");
+	script_tag("unusual-interpreter", $filename, "#!$interpreter");
     }
 
     # Do some additional checks on shell scripts in /etc.  This should
@@ -452,7 +467,7 @@ for my $filename (sort keys %{$info->scripts}) {
     # If we found the interpreter and the script is executable, check
     # dependencies.  This should be the last thing we do in the loop so that
     # we can use next for an early exit and reduce the nesting.
-    next unless ($data && $executable{$filename});
+    next unless ($data && $executable{$filename} and !$in_docs);
     if (!$versioned) {
 	my $depends = $data->[1];
 	if (not defined $depends) {
diff --git a/checks/scripts.desc b/checks/scripts.desc
index 21a4e5c..27932c4 100644
--- a/checks/scripts.desc
+++ b/checks/scripts.desc
@@ -12,6 +12,12 @@ Certainty: certain
 Info: This file starts with the #! sequence that identifies scripts, but
  it does not name an interpreter.
 
+Tag: example-script-without-interpreter
+Severity: pedantic
+Certainty: certain
+Info: This file starts with the #! sequence that identifies scripts, but
+ it does not name an interpreter.
+
 Tag: executable-not-elf-or-script
 Severity: normal
 Certainty: certain
@@ -33,6 +39,13 @@ Info: This script uses a relative path to locate its interpreter.
  This path will be taken relative to the caller's current directory, not
  the script's, so it is not likely to be what was intended.
 
+Tag: example-interpreter-not-absolute
+Severity: pedantic
+Certainty: certain
+Info: This script uses a relative path to locate its interpreter.
+ This path will be taken relative to the caller's current directory, not
+ the script's, so it is not likely to be what was intended.
+
 Tag: unusual-interpreter
 Severity: normal
 Certainty: possible
@@ -41,6 +54,14 @@ Info: This package contains a script for an interpreter that the Lintian
  interpreter.  If not, please file a wishlist bug on lintian so that the
  Lintian maintainers can add this interpreter to their list.
 
+Tag: example-unusual-interpreter
+Severity: pedantic
+Certainty: possible
+Info: This package contains an example script for an interpreter that the
+ Lintian maintainers have not heard of.  It could be a typo for a common
+ interpreter.  If not, please file a wishlist bug on lintian so that the
+ Lintian maintainers can add this interpreter to their list.
+
 Tag: script-uses-bin-env
 Severity: normal
 Certainty: certain
@@ -49,6 +70,13 @@ Info: This script uses /bin/env as its interpreter (used to find the
  systems; env is instead installed as /usr/bin/env.  Usually, the path to
  env in the script should be changed.
 
+Tag: example-script-uses-bin-env
+Severity: pedantic
+Certainty: certain
+Info: This example script uses /bin/env as its interpreter (used to find
+ the actual interpreter on the user's path).  There is no /bin/env on
+ Debian systems; env is instead installed as /usr/bin/env.
+
 Tag: forbidden-config-interpreter
 Severity: important
 Certainty: certain
@@ -90,6 +118,13 @@ Info: This package contains a script that looks for an interpreter in a
  directory in /usr/local.  Since Debian does not install anything in
  /usr/local, this is the wrong place to look.
 
+Tag: example-interpreter-in-usr-local
+Severity: pedantic
+Certainty: certain
+Info: This package contains an example script that looks for an
+ interpreter in a directory in /usr/local.  Since Debian does not install
+ anything in /usr/local, this is the wrong place to look.
+
 Tag: control-interpreter-in-usr-local
 Severity: serious
 Certainty: certain
@@ -153,6 +188,12 @@ Certainty: certain
 Info: The interpreter you used is installed at another location on Debian
  systems.
 
+Tag: example-wrong-path-for-interpreter
+Severity: pedantic
+Certainty: certain
+Info: The interpreter used is installed at another location on Debian
+ systems.
+
 Tag: gawk-script-but-no-gawk-dep
 Severity: important
 Certainty: certain
@@ -258,6 +299,14 @@ Info: Running this shell script with the shell's -n option set fails,
  .
  Run e.g. <tt>sh -n yourscript</tt> to see the errors yourself.
 
+Tag: example-shell-script-fails-syntax-check
+Severity: pedantic
+Certainty: certain
+Info: Running this shell script with the shell's -n option set fails,
+ which means that the script has syntax errors.
+ .
+ Run e.g. <tt>sh -n yourscript</tt> to see the errors yourself.
+
 Tag: maintainer-shell-script-fails-syntax-check
 Severity: serious
 Certainty: certain
diff --git a/debian/changelog b/debian/changelog
index b95d2cf..d7cc228 100755
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,13 @@ lintian (2.2.15) UNRELEASED; urgency=low
   * Summary of tag changes:
     + Added:
       - build-depends-on-non-build-package
+      - example-interpreter-in-usr-local (pedantic)
+      - example-interpreter-not-absolute (pedantic)
+      - example-script-without-interpreter (pedantic)
+      - example-script-uses-bin-env (pedantic)
+      - example-shell-script-fails-syntax-check (pedantic)
+      - example-wrong-path-for-interpreter (pedantic)
+      - example-unusual-interpreter (pedantic)
       - global-data-in-games-directory
   
   * checks/changelog-file:
@@ -64,6 +71,10 @@ lintian (2.2.15) UNRELEASED; urgency=low
       installing a man page by the same name in the same numeric section,
       even if the specific section is different.  Thanks, Niko Tyni.
       (Closes: #543781)
+    + [RA] Check example scripts for most of the same issues as scripts
+      elsewhere in the package, but report problems with a different set
+      of tags with pedantic severity.  Patch from Damyan Ivanov.
+      (Closes: #543873)
 
   * data/fields/essential:
     + [RA] New list of essential packages.

-- 
Debian package checker


Reply to: