Subject: [PATCH] Look for prebuilt ELF and PE (Windows) objects in the source tarball

From: Raphael Geissert <[email-masked]>
Date: Sat, 7 Feb 2009 14:25:47 -0600

---
 checks/cruft      |   11 +++++++++++
 checks/cruft.desc |   19 ++++++++++++++++++-
 2 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/checks/cruft b/checks/cruft
index adb82a6..1a92ed1 100644
--- a/checks/cruft
+++ b/checks/cruft
@@ -121,6 +121,17 @@ check_diffstat("diffstat", \%warned) unless $info->native;
 my $wanted = sub { find_cruft($pkg, $info, \%warned, $atdinbd) };
 find($wanted, 'unpacked');
 
+# Look for cruft based on file's results
+my $file_info = $info->file_info;
+
+for my $file (keys(%$file_info)) {
+    if ($file_info->{$file} =~ m/\bELF\b/) {
+	tag "source-contains-prebuilt-binary", $file;
+    } elsif ($file_info->{$file} =~ m/\bPE(32|64)\b/) {
+	tag "source-contains-prebuilt-windows-binary", $file;
+    }
+}
+
 } # </run>
 
 # -----------------------------------
diff --git a/checks/cruft.desc b/checks/cruft.desc
index d434148..64514c6 100644
--- a/checks/cruft.desc
+++ b/checks/cruft.desc
@@ -4,7 +4,7 @@ Abbrev: deb
 Type: source
 Unpack-Level: 2
 Info: This looks for cruft in Debian packaging or upstream source
-Needs-Info: debfiles, diffstat
+Needs-Info: debfiles, diffstat, file-info
 
 Tag: native-package-with-dash-version
 Severity: normal
@@ -356,3 +356,20 @@ Info: The referenced file seems to be from a libtool version
  If you have not updated the file but fixed architecture-specific
  issues with minimal patches and verified that it builds correctly
  please override this tag.  lintian will not be able to verify that.
+
+Tag: source-contains-prebuilt-binary
+Severity: pedantic
+Certainty: certain
+Info: The source tarball contains a prebuilt ELF object.  They are usually
+ left by mistake when generating the tarball by not cleaning the source
+ directory first.  You may want to report this as an upstream bug, in case
+ there is no sign that this was intended.
+
+Tag: source-contains-prebuilt-windows-binary
+Severity: pedantic
+Certainty: certain
+Info: The source tarball contains a prebuilt binary for Microsoft Windows.
+ They are usually left by convenience for end users, although it is possible
+ that upstream also provides tarballs source-only tarballs which you can use.
+ These files usually just take up space in the tarball and are of no use in
+ Debian.  You may want to ask upstream to provide source-only tarballs.