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

[lintian] 01/01: c/files: Check for wrong M-A: foreign usage



This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository lintian.

commit d011d5ce6718a9d1a5174c9bf2712fda58a52787
Author: Helmut Grohne <helmut@subdivi.de>
Date:   Wed Apr 19 12:45:20 2017 +0000

    c/files: Check for wrong M-A: foreign usage
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 checks/files.desc                                  | 12 ++++++++++++
 checks/files.pm                                    | 20 ++++++++++++++++----
 debian/changelog                                   |  2 ++
 t/tests/files-wrong-ma-foreign/debian/Makefile     | 22 ++++++++++++++++++++++
 t/tests/files-wrong-ma-foreign/debian/code.c       | 15 +++++++++++++++
 .../debian/debian/control.in                       | 17 +++++++++++++++++
 .../debian/debian/libpublic1.symbols               |  3 +++
 t/tests/files-wrong-ma-foreign/desc                |  4 ++++
 t/tests/files-wrong-ma-foreign/tags                |  1 +
 9 files changed, 92 insertions(+), 4 deletions(-)

diff --git a/checks/files.desc b/checks/files.desc
index 5a30763..7113ac3 100644
--- a/checks/files.desc
+++ b/checks/files.desc
@@ -1729,3 +1729,15 @@ Info: The package contains files in the listed directory, but does
  not contain the actual directory itself.  Some tools do not cope
  very well with this case. Notably Lintian prior to 2.5.32 would
  crash on such packages.
+
+Tag: multiarch-foreign-shared-library
+Severity: important
+Certainty: wild-guess
+Info: The package is architecture-dependent, ships a shared library in
+ a public library search path and is marked <tt>Multi-Arch:
+ foreign</tt>. Typically, shared libraries are marked <tt>Multi-Arch:
+ same</tt> when possible. Sometimes, private shared libraries are put
+ into the public library search path to accomodate programs in the
+ same package, but this package does not contain any programs.
+ .
+ Please remove the <tt>Multi-Arch: foreign</tt> stanza.
diff --git a/checks/files.pm b/checks/files.pm
index 7f9e912..85ab480 100644
--- a/checks/files.pm
+++ b/checks/files.pm
@@ -259,7 +259,8 @@ my $OBSOLETE_PATHS = Lintian::Data->new(
 
 sub run {
     my ($pkg, $type, $info, $proc) = @_;
-    my ($is_python, $is_perl, $has_binary_perl_file);
+    my ($is_python, $is_perl, $has_binary_perl_file, $has_public_executable,
+        $has_public_shared_library);
     my @nonbinary_perl_files_in_lib;
     my %linked_against_libvga;
     my @devhelp;
@@ -274,7 +275,7 @@ sub run {
     my $source_pkg = $proc->pkg_src;
     my $pkg_section = $info->field('section', '');
     my $arch = $info->field('architecture', '');
-    my $isma_same = $info->field('multi-arch', '') eq 'same';
+    my $multiarch = $info->field('multi-arch', 'no');
     my $ppkg = quotemeta($pkg);
 
     # get the last changelog timestamp
@@ -358,6 +359,7 @@ sub run {
         $arch_dep_files = 1 if $fname !~ m,^usr/share/,o && $fname ne 'usr/';
 
         if (exists($PATH_DIRECTORIES{$file->dirname})) {
+            $has_public_executable = 1;
             tag 'file-name-in-PATH-is-not-ASCII', $file
               if $file->basename !~ m{\A [[:ascii:]]++ \Z}xsm;
         } elsif (!is_string_utf8_encoded($fname)) {
@@ -847,7 +849,6 @@ sub run {
                             or index($block,'pkg-config')  > -1)
                       ) {
                         tag 'old-style-config-script',$file;
-                        my $multiarch = $info->field('multi-arch', 'no');
                         # could be ok but only if multi-arch: no
                         if($multiarch ne 'no' or $arch eq 'all') {
                             # check multi-arch path
@@ -1084,6 +1085,11 @@ sub run {
             }
         }
 
+        if ($fname =~ m,(?:usr/)?lib/(?:([^/]+)/)?lib[^/]*\.so$,) {
+            $has_public_shared_library = 1
+              if (!defined($1) || $TRIPLETS->known($1));
+        }
+
         # ---------------- .pyc/.pyo (compiled Python files)
         #  skip any file installed inside a __pycache__ directory
         #  - we have a separate check for that directory.
@@ -1549,7 +1555,7 @@ sub run {
                     }
                     close($fd);
                     if ($mtime != 0) {
-                        if ($isma_same && $file !~ m/\Q$arch\E/) {
+                        if ($multiarch eq 'same' && $file !~ m/\Q$arch\E/) {
                             tag 'gzip-file-is-not-multi-arch-same-safe',$file;
                         } else {
                             # see https://bugs.debian.org/762105
@@ -1932,6 +1938,12 @@ sub run {
         tag 'package-mixes-misc-and-dpi-fonts';
     }
 
+    tag 'multiarch-foreign-shared-library'
+      if $arch ne 'all'
+      and $multiarch eq 'foreign'
+      and $has_public_shared_library
+      and not $has_public_executable;
+
     return;
 }
 
diff --git a/debian/changelog b/debian/changelog
index 675459c..41416ff 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -26,6 +26,8 @@ lintian (2.5.51) UNRELEASED; urgency=medium
   * checks/files.pm:
     + [BR] Do not report duplicates for package-installs-apt-preferences
       and package-installs-apt-sources.  (Closes: #814521).
+    + [NT] Apply patch from Helmut Grohne to detect some possible invalid
+      uses of "Multi-Arch: foreign".  (Closes: #856975)
   * checks/menu-format.{desc,pm}:
     + [NT] Update the reference to Desktop Entry Specification to point
       to version 1.1.
diff --git a/t/tests/files-wrong-ma-foreign/debian/Makefile b/t/tests/files-wrong-ma-foreign/debian/Makefile
new file mode 100644
index 0000000..64f6bba
--- /dev/null
+++ b/t/tests/files-wrong-ma-foreign/debian/Makefile
@@ -0,0 +1,22 @@
+CC=gcc
+CFLAGS+= -fPIC
+
+SONAMES:= libpublic.so.1
+LIBFILES:= $(patsubst %,%.0.1, $(SONAMES))
+
+all: $(LIBFILES)
+
+$(LIBFILES): code.o
+	$(CC) $(LDFLAGS) -o $@ -shared -Wl,-soname,$(patsubst %.0.1,%,$@) $^ -lc
+
+clean:
+	rm -f *.a *.o *.so*
+
+install: all
+	install -m 0755 -d $(DESTDIR)/usr/lib
+	install -m 0644 *.so* $(DESTDIR)/usr/lib
+	for FILE in $(SONAMES) ; do \
+	    ln -s $${FILE}.0.1 $(DESTDIR)/usr/lib/$$FILE ; \
+	done
+
+.PHONY: install clean
diff --git a/t/tests/files-wrong-ma-foreign/debian/code.c b/t/tests/files-wrong-ma-foreign/debian/code.c
new file mode 100644
index 0000000..0ed08e0
--- /dev/null
+++ b/t/tests/files-wrong-ma-foreign/debian/code.c
@@ -0,0 +1,15 @@
+#include <stdlib.h>
+#include <math.h>
+
+double e(void (*f)(char *)){
+  char tmp[10];
+  double x;
+  f(tmp);
+  x = atof(tmp);
+  return exp(x);
+}
+
+double energy(double mass){
+  return pow(10.0, 8.0) * pow(3.0, 2.0) * mass;
+}
+
diff --git a/t/tests/files-wrong-ma-foreign/debian/debian/control.in b/t/tests/files-wrong-ma-foreign/debian/debian/control.in
new file mode 100644
index 0000000..8ef50d3
--- /dev/null
+++ b/t/tests/files-wrong-ma-foreign/debian/debian/control.in
@@ -0,0 +1,17 @@
+Source: {$source}
+Priority: extra
+Section: {$section}
+Maintainer: {$author}
+Standards-Version: {$standards_version}
+Build-Depends: {$build_depends}
+
+Package: libpublic1
+Architecture: any
+Depends: $\{misc:Depends\}, $\{shlibs:Depends\},
+Multi-Arch: foreign
+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
+ things.  It should not be installed like a regular package.  It may
+ be an empty package.
+
diff --git a/t/tests/files-wrong-ma-foreign/debian/debian/libpublic1.symbols b/t/tests/files-wrong-ma-foreign/debian/debian/libpublic1.symbols
new file mode 100644
index 0000000..d8226ca
--- /dev/null
+++ b/t/tests/files-wrong-ma-foreign/debian/debian/libpublic1.symbols
@@ -0,0 +1,3 @@
+libexecbit.so.1 libexecbit1 #MINVER#
+ e@Base 1.0
+ energy@Base 0.9
diff --git a/t/tests/files-wrong-ma-foreign/desc b/t/tests/files-wrong-ma-foreign/desc
new file mode 100644
index 0000000..15157b9
--- /dev/null
+++ b/t/tests/files-wrong-ma-foreign/desc
@@ -0,0 +1,4 @@
+Testname: files-wrong-ma-foreign
+Version: 1.0
+Description: Test for wrong usage of Multi-Arch foreign
+Test-for: shlib-in-multi-arch-foreign-package
diff --git a/t/tests/files-wrong-ma-foreign/tags b/t/tests/files-wrong-ma-foreign/tags
new file mode 100644
index 0000000..f67dd7f
--- /dev/null
+++ b/t/tests/files-wrong-ma-foreign/tags
@@ -0,0 +1 @@
+E: libpublic1: shlib-in-multi-arch-foreign-package usr/lib/libpublic.so.1.0.1

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git


Reply to: