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

[SCM] Debian package checker branch, master, updated. 2.2.5-61-g98be8ca



The following commit has been merged in the master branch:
commit 6b67d8f0fe17de021c58c47ae53a65f877150277
Author: Raphael Geissert <atomo64@gmail.com>
Date:   Wed Feb 18 18:52:56 2009 -0600

    Check for binaries from other architectures

diff --git a/checks/binaries b/checks/binaries
index 5b0c5a7..1aaaa35 100644
--- a/checks/binaries
+++ b/checks/binaries
@@ -25,6 +25,33 @@ use Util;
 
 use File::Spec;
 
+# Table based on checks/emdebian' %archdetecttable, as found in
+# emdebian-tools
+our %archselftable = (
+	'alpha' => qr'ELF 64-bit LSB .* Alpha',
+	'amd64' => qr'ELF 64-bit LSB .* x86-64, .* (?:GNU/Linux|(?!GNU))',
+	'arm' => qr'ELF 32-bit LSB .* ARM, version \d,',
+	'armeb' => qr'ELF 32-bit MSB .* ARM',
+	'armel' => qr'ELF 32-bit LSB .* \(SYSV\)',
+	'hppa' => qr'ELF 32-bit MSB .* PA-RISC',
+	'hurd-i386' => qr'ELF 32-bit LSB .* Intel 80386, .* (?:GNU/Hurd|(?!GNU))',
+	'i386' => qr'ELF 32-bit LSB .* 80386, .* (?:GNU/Linux|(?!GNU))',
+	'ia64' => qr'ELF 64-bit LSB .* IA-64',
+	'kfreebsd-amd64' => qr'ELF 64-bit LSB .* x86-64, .* (?:GNU/kFreeBSD|(?!GNU))',
+	'kfreebsd-i386' => qr'ELF 32-bit LSB .* 80386, .* (?:GNU/kFreeBSD|(?!GNU))',
+	'm32r' => qr'ELF 32-bit MSB .* M32R',
+	'm68k' => qr'ELF 32-bit MSB .* 680[02]0',
+	'mips' => qr'ELF 32-bit MSB .* MIPS',
+	'mipsel' => qr'ELF 32-bit LSB .* MIPS',
+	'powerpc' => qr'ELF 32-bit MSB .* PowerPC',
+	'powerpc64' => qr'ELF 64-bit MSB .* PowerPC',
+	's390' => qr'ELF 32-bit MSB .* S.390',
+	's390x' => qr'ELF 64-bit MSB .* S.390',
+	'sparc' => qr'ELF 32-bit MSB .* SPARC',
+	'sparc64' => qr'ELF 64-bit MSB .* SPARC');
+
+our $multiarch;
+
 sub run {
 
 my $pkg = shift;
@@ -142,7 +169,8 @@ foreach my $file (sort keys %{$info->file_info}) {
     # package may be a support package for cross-compiles.
     if ($arch eq 'all') {
 	my ($arch) = ($file =~ m,^\./(?:usr/)?lib/([^/]+)/,);
-	my $multiarch = Lintian::Data->new('binaries/multiarch');
+	$multiarch = Lintian::Data->new('binaries/multiarch')
+	    unless defined($multiarch);
 	unless ($arch and $multiarch->known($arch)) {
 	    tag "arch-independent-package-contains-binary-or-object", "$file";
 	}
@@ -159,6 +187,13 @@ foreach my $file (sort keys %{$info->file_info}) {
 	tag "arch-dependent-file-in-usr-share", "$file";
     }
 
+    if ($arch ne 'all' and $fileinfo !~ m/$archselftable{$arch}/) {
+	$multiarch = Lintian::Data->new('binaries/multiarch')
+	    unless defined($multiarch);
+	tag "binary-from-other-architecture", $file
+	    unless (grep { $file =~ m,/\Q$_\E/, } $multiarch->all);
+    }
+
     # stripped?
     if ($fileinfo =~ m,not stripped\s*$,o) {
 	# Is it an object file (which generally can not be stripped),
diff --git a/checks/binaries.desc b/checks/binaries.desc
index dfc0c25..3017276 100644
--- a/checks/binaries.desc
+++ b/checks/binaries.desc
@@ -201,3 +201,11 @@ Info: This file is in a location generally used for detached debugging
  If you are using dh_strip with the --dbg-package flag, don't also install
  the library in <tt>/usr/lib/debug</tt>.  dh_strip does all the work for
  you.
+
+Tag: binary-from-other-architecture
+Severity: serious
+Certainty: possible
+Info: This ELF binary appears to have been built for an architecture other than
+ the one of the binary package being tested.  This may occur when a pre-built
+ binary is shipped in the package or when an atempt to cross-compile didn't
+ work.
diff --git a/t/tests/binary-from-other-arch/debian/debian/dumpobj b/t/tests/binary-from-other-arch/debian/debian/dumpobj
new file mode 100644
index 0000000..ba529d5
--- /dev/null
+++ b/t/tests/binary-from-other-arch/debian/debian/dumpobj
@@ -0,0 +1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AAA
+AAMAAAACcAAAANAAAAOQAAADIAAAAsAAAALwAAAAIAAAAuAAAACg==
+DATA
+else
+    base64 -d <<DATA
+f0VMRgEBAQAAAAAAAAAAAAIAAwABAAAAIKwECDQAAAAsjgUAAAAAADQAIAAIACgAHAAbAA
+YAAAA0AAAANIAECDSABAgAAQAAAAEAAAUAAAAEAAAAAwAAADQBAAA0gQQINIEECBMAAAAT
+AAAABAAAAAEAAAABAAAAAAAAAACABAgAgAQI8IYFAPCGBQAFAAAAABAAAAEAAADwhgUA8B
+YK
+DATA
+fi
diff --git a/t/tests/binary-from-other-arch/debian/debian/install b/t/tests/binary-from-other-arch/debian/debian/install
new file mode 100644
index 0000000..fdaf3a4
--- /dev/null
+++ b/t/tests/binary-from-other-arch/debian/debian/install
@@ -0,0 +1 @@
+debian/elfobject  usr/bin/
diff --git a/t/tests/binary-from-other-arch/debian/debian/rules b/t/tests/binary-from-other-arch/debian/debian/rules
new file mode 100755
index 0000000..40c65ef
--- /dev/null
+++ b/t/tests/binary-from-other-arch/debian/debian/rules
@@ -0,0 +1,11 @@
+#!/usr/bin/make -f
+
+DEB_BUILD_OPTIONS := nostrip
+export DEB_BUILD_OPTIONS
+
+%:
+	dh $@
+
+binary:
+	sh debian/dumpobj > debian/elfobject
+	dh binary
diff --git a/t/tests/binary-from-other-arch/desc b/t/tests/binary-from-other-arch/desc
new file mode 100644
index 0000000..e3690c8
--- /dev/null
+++ b/t/tests/binary-from-other-arch/desc
@@ -0,0 +1,9 @@
+Testname: binary-from-other-arch
+Sequence: 6000
+Architecture: any
+Version: 1.0
+Description: Test package with a pseudo binary from a different architecture
+Test-For:
+    binary-from-other-architecture
+    statically-linked-binary
+    apparently-corrupted-elf-binary
diff --git a/t/tests/binary-from-other-arch/tags b/t/tests/binary-from-other-arch/tags
new file mode 100644
index 0000000..8995b1f
--- /dev/null
+++ b/t/tests/binary-from-other-arch/tags
@@ -0,0 +1,4 @@
+E: binary-from-other-arch: binary-from-other-architecture ./usr/bin/elfobject
+E: binary-from-other-arch: statically-linked-binary ./usr/bin/elfobject
+W: binary-from-other-arch: apparently-corrupted-elf-binary ./usr/bin/elfobject
+W: binary-from-other-arch: binary-without-manpage usr/bin/elfobject

-- 
Debian package checker


Reply to: