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

[SCM] Debian package checker branch, master, updated. 2.5.4-103-gb291a84



The following commit has been merged in the master branch:
commit b291a847baf856ebfdc51197a675c000fee22466
Author: Niels Thykier <niels@thykier.net>
Date:   Sat Jan 21 19:46:56 2012 +0100

    Gracefully handle syntax errors in d/control
    
    Lintian::Collect::Source will now ignore syntax errors in d/control
    (but not other errors).  Instead it will "assume" the file to be
    "empty" (for the purpose of determining binaries/binary fields).
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/checks/control-file b/checks/control-file
index 81c1525..1a6475b 100644
--- a/checks/control-file
+++ b/checks/control-file
@@ -84,7 +84,18 @@ while (<CONTROL>) {
 }
 close CONTROL;
 
-my ($header, @binary_controls) = read_dpkg_control($dcontrol);
+my ($header, @binary_controls);
+
+eval {
+    ($header, @binary_controls) = read_dpkg_control($dcontrol);
+};
+if ($@) {
+    chomp $@;
+    $@ =~ s/^internal error: //;
+    $@ =~ s/^syntax error in //;
+    tag 'syntax-error-in-control-file', "debian/control: $@";
+    return;
+}
 
 for my $binary_control (@binary_controls) {
     tag 'build-info-in-binary-control-file-section', 'Package '.$binary_control->{'package'}
diff --git a/checks/control-file.desc b/checks/control-file.desc
index 853bf78..189a4be 100644
--- a/checks/control-file.desc
+++ b/checks/control-file.desc
@@ -193,3 +193,11 @@ Info: The given package appears to be a shared library -dev package, but
  ensure that a new upstream version of the library package doesn't satisfy
  the -dev package dependency, since the minor version of the shared
  library may have changed, breaking the <tt>*.so</tt> links.
+
+Tag: syntax-error-in-control-file
+Severity: important
+Certainty: possible
+Info: The control 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 fa2ecf9..af308c6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,6 +12,7 @@ lintian (2.5.5) UNRELEASED; urgency=low
       - package-uses-dh-exec-but-lacks-build-depends
       - preinst-uses-dpkg-maintscript-helper-without-predepends
       - shlib-in-multi-arch-foreign-package
+      - syntax-error-in-control-file
     + Removed:
       - dh_dhelp-is-deprecated
       - maintainer-script-calls-deprecated-wm-menu-config
@@ -22,11 +23,13 @@ lintian (2.5.5) UNRELEASED; urgency=low
     + [NT] Fixed assumptions about certain fields being present.
       Where needed, Lintian will make guesses to the most likely
       value (or the least "broken" value).
-  * checks/control-file:
+  * checks/control-file{,.desc}:
     + [NT] Allow "pkg (= ${source:Version})" versioned dependency if
       pkg is architecture all.  This fixes a false-positive
       "weak-library-dev-dependency" for some mono packages.  Thanks
       to David Bremner for the report.  (Closes: #652602)
+    + [NT] Emit a tag if there is a syntax error in d/control rather
+      than just aborting the rest of the check.
   * checks/cruft:
     + [NT] Added dh-autoreconf as a build-depends alternative to
       libtool for suppressing ancient-libtool warning.  Thanks to
diff --git a/lib/Lintian/Collect/Source.pm b/lib/Lintian/Collect/Source.pm
index 7b27c2e..1f20644 100644
--- a/lib/Lintian/Collect/Source.pm
+++ b/lib/Lintian/Collect/Source.pm
@@ -161,10 +161,21 @@ sub _load_binary_fields {
         $self->{binary_field} = {};
         return;
     }
-    my @control_data = read_dpkg_control($dctrl);
+    my @control_data;
     my %packages;
 
-    shift @control_data; # throw away the source part
+    eval {
+        @control_data = read_dpkg_control($dctrl);
+        shift @control_data; # throw away the source part
+    };
+    if ($@) {
+        # If it is a syntax error, ignore it (we emit
+        # syntax-error-in-control-file in this case via
+        # control-file).
+        die $@ unless $@ =~ /syntax error/;
+        $self->{binary_field} = {};
+        return 0;
+    }
 
     foreach my $binary (@control_data) {
         my $pkg = $binary->{'package'};
diff --git a/t/source/control-field-traversal-1/Makefile b/t/source/control-file-syntax-error/Makefile
similarity index 96%
copy from t/source/control-field-traversal-1/Makefile
copy to t/source/control-file-syntax-error/Makefile
index 03de3c4..b5bb5aa 100644
--- a/t/source/control-field-traversal-1/Makefile
+++ b/t/source/control-file-syntax-error/Makefile
@@ -1,4 +1,4 @@
-name = control-field-traversal-1
+name = control-file-syntax-error
 dir  = $(name)-1
 
 all:
diff --git a/t/tests/shared-libs-unversioned/debian/debian/control.in b/t/source/control-file-syntax-error/control.in
similarity index 77%
copy from t/tests/shared-libs-unversioned/debian/debian/control.in
copy to t/source/control-file-syntax-error/control.in
index b59e74b..94601a0 100644
--- a/t/tests/shared-libs-unversioned/debian/debian/control.in
+++ b/t/source/control-file-syntax-error/control.in
@@ -1,13 +1,14 @@
 Source: {$srcpkg}
-Priority: extra
-Section: libs
+Section: devel
+Priority: optional
 Maintainer: {$author}
-Standards-Version: {$standards_version}
 Build-Depends: debhelper (>= 7)
+Standards-Version: {$standards_version}
 
-Package: libfoo
-Architecture: {$architecture}
+Package: {$srcpkg}
+Architecture: all
 Depends: $\{shlibs:Depends\}, $\{misc:Depends\}
+Recommends a-colon, after-the-field, name
 Description: {$description}
  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
diff --git a/t/source/control-file-syntax-error/desc b/t/source/control-file-syntax-error/desc
new file mode 100644
index 0000000..0218cd5
--- /dev/null
+++ b/t/source/control-file-syntax-error/desc
@@ -0,0 +1,6 @@
+Testname: control-file-syntax-error
+Sequence: 6000
+Version: 1.0
+Description: Test for d/control with syntax errors
+Test-For: syntax-error-in-control-file
+
diff --git a/t/source/control-file-syntax-error/dsc.in b/t/source/control-file-syntax-error/dsc.in
new file mode 100644
index 0000000..f9c602b
--- /dev/null
+++ b/t/source/control-file-syntax-error/dsc.in
@@ -0,0 +1,14 @@
+Format: 1.0
+Source: control-file-syntax-error
+Binary: control-file-syntax-error
+Architecture: all
+Version: 1
+Maintainer: Debian Lintian Maintainers <lintian-maint@debian.org>
+Standards-Version: 3.9.2
+Build-Depends: debhelper (>= 7)
+Checksums-Sha1:
+ @SHA1@ @SIZE@ control-file-syntax-error_1.tar.gz
+Checksums-Sha256:
+ @SHA256@ @SIZE@ control-file-syntax-error_1.tar.gz
+Files:
+ @MD5@ @SIZE@ control-file-syntax-error_1.tar.gz
diff --git a/t/source/control-file-syntax-error/tags b/t/source/control-file-syntax-error/tags
new file mode 100644
index 0000000..8445525
--- /dev/null
+++ b/t/source/control-file-syntax-error/tags
@@ -0,0 +1 @@
+E: control-file-syntax-error source: syntax-error-in-control-file debian/control: paragraph 1 after the field depends: Recommends a-colon, after-the-field, name

-- 
Debian package checker


Reply to: