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

[SCM] Debian package checker branch, master, updated. 2.5.4-104-gabf44d7



The following commit has been merged in the master branch:
commit abf44d7b25f9c18cba06c31f3c1eedc931e23bec
Author: Niels Thykier <niels@thykier.net>
Date:   Fri Jan 20 16:43:43 2012 +0100

    Gracefully handle syntax errors in debconf templates
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/checks/debconf b/checks/debconf
index b02bf7c..2ba3072 100644
--- a/checks/debconf
+++ b/checks/debconf
@@ -87,7 +87,17 @@ if ($type eq 'source') {
         }
 
         if (-f $templates_file) {
-            my @templates = read_dpkg_control($templates_file, 'templates file');
+            my @templates;
+            eval {
+                @templates = read_dpkg_control ($templates_file, 'templates file');
+            };
+            if ($@) {
+                chomp $@;
+                $@ =~ s/^internal error: //;
+                $@ =~ s/^syntax error in //;
+                tag 'syntax-error-in-debconf-template', "$file: $@";
+                next;
+            }
 
             foreach my $template (@templates) {
                 if (exists $template->{template} and exists $template->{_choices}) {
@@ -199,10 +209,23 @@ if ($seentemplates) {
 
 # Lots of template checks.
 
-my @templates = $seentemplates ? read_dpkg_control("$cdir/templates", 'templates file') : ();
+my @templates = ();
 my %potential_db_abuse;
 my @templates_seen;
 
+if ($seentemplates) {
+    eval {
+        @templates = read_dpkg_control("$cdir/templates", 'templates file');
+    };
+    if ($@) {
+        chomp $@;
+        $@ =~ s/^internal error: //;
+        $@ =~ s/^syntax error in //;
+        tag 'syntax-error-in-debconf-template', "templates: $@";
+        @templates = ();
+    }
+}
+
 foreach my $template (@templates) {
     my $isselect='';
 
diff --git a/checks/debconf.desc b/checks/debconf.desc
index 684fd35..b6f4edf 100644
--- a/checks/debconf.desc
+++ b/checks/debconf.desc
@@ -351,3 +351,11 @@ Info: Templates which are not used by the package should be removed from
  understands the shell script debconf functions.
  .
  If any of the above apply, please install an override.
+
+Tag: syntax-error-in-debconf-template
+Severity: important
+Certainty: possible
+Info: The template file contains a syntax error.
+ .
+ This issue may hide other issues as Lintian skips some checks on the
+ file in this case.
diff --git a/debian/changelog b/debian/changelog
index af308c6..010bf5a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -13,6 +13,7 @@ lintian (2.5.5) UNRELEASED; urgency=low
       - preinst-uses-dpkg-maintscript-helper-without-predepends
       - shlib-in-multi-arch-foreign-package
       - syntax-error-in-control-file
+      - syntax-error-in-debconf-template
     + Removed:
       - dh_dhelp-is-deprecated
       - maintainer-script-calls-deprecated-wm-menu-config
diff --git a/testset/debconf/debian/debconf-udeb.postinst b/t/tests/debconf-syntax-error/debian/debian/config
similarity index 77%
copy from testset/debconf/debian/debconf-udeb.postinst
copy to t/tests/debconf-syntax-error/debian/debian/config
index 4ce41f0..6f264ea 100644
--- a/testset/debconf/debian/debconf-udeb.postinst
+++ b/t/tests/debconf-syntax-error/debian/debian/config
@@ -4,6 +4,3 @@ set -e
 
 . /usr/share/debconf/confmodule
 
-ldconfig
-
-true
diff --git a/testset/debconf/debian/debconf-udeb.postinst b/t/tests/debconf-syntax-error/debian/debian/postinst
similarity index 79%
copy from testset/debconf/debian/debconf-udeb.postinst
copy to t/tests/debconf-syntax-error/debian/debian/postinst
index 4ce41f0..4d6cb4d 100644
--- a/testset/debconf/debian/debconf-udeb.postinst
+++ b/t/tests/debconf-syntax-error/debian/debian/postinst
@@ -2,8 +2,7 @@
 
 set -e
 
-. /usr/share/debconf/confmodule
+#DEBHELPER#
 
-ldconfig
+. /usr/share/debconf/confmodule
 
-true
diff --git a/t/tests/debconf-syntax-error/debian/debian/templates b/t/tests/debconf-syntax-error/debian/debian/templates
new file mode 100644
index 0000000..adf2ece
--- /dev/null
+++ b/t/tests/debconf-syntax-error/debian/debian/templates
@@ -0,0 +1,3 @@
+Template: debconf/syntax-error
+Type: note
+Description whoops, I forgot a colon
diff --git a/t/tests/debconf-syntax-error/desc b/t/tests/debconf-syntax-error/desc
new file mode 100644
index 0000000..dd793ee
--- /dev/null
+++ b/t/tests/debconf-syntax-error/desc
@@ -0,0 +1,5 @@
+Testname: debconf-syntax-error
+Sequence: 6000
+Version: 1.0
+Description: Test for syntax error in debconf files
+Test-For: syntax-error-in-debconf-template
diff --git a/t/tests/debconf-syntax-error/tags b/t/tests/debconf-syntax-error/tags
new file mode 100644
index 0000000..630e7a1
--- /dev/null
+++ b/t/tests/debconf-syntax-error/tags
@@ -0,0 +1,2 @@
+E: debconf-syntax-error source: syntax-error-in-debconf-template templates: paragraph 0 after the field type: Description whoops, I forgot a colon
+E: debconf-syntax-error: syntax-error-in-debconf-template templates: paragraph 0 after the field type: Description whoops, I forgot a colon

-- 
Debian package checker


Reply to: