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

[SCM] Debian package checker branch, master, updated. 2.1.2-12-g35e601e



The following commit has been merged in the master branch:
commit 35e601ecf8cd41bfff371539217ec19ca44ebf7a
Author: Russ Allbery <rra@debian.org>
Date:   Sat Dec 27 11:33:11 2008 -0800

    Improve handling of unversioned shared libraries
    
    * checks/shared-libs{,.desc}:
      + [RA] Use the same regexes as dpkg-shlibdeps when parsing version
        information from SONAMEs.
    
    Also re-add unversioned shared libraries for the symbols file checks, since
    they can be represented there, and update comments.  Add a new-style test
    suite for handling of unversioned shared libraries.

diff --git a/checks/shared-libs b/checks/shared-libs
index 2b3033d..4e2b3ae 100644
--- a/checks/shared-libs
+++ b/checks/shared-libs
@@ -244,14 +244,14 @@ $provides = Dep::parse($provides);
 my %shlibs_control;
 my %symbols_control;
 
-# Libraries with no version information can't be represented by the shlibs and
-# symbols format and are on their own, but we can warn about that if they
-# appear in public directories.  If they're in private directories, assume
-# they're plugins and ignore them.
+# Libraries with no version information can't be represented by the shlibs
+# format (but can be represented by symbols).  We want to warn about them if
+# they appear in public directories.  If they're in private directories,
+# assume they're plugins or private libraries and are safe.
 my %unversioned_shlibs;
 for (keys %SONAME) {
-    my $soname = $SONAME{$_};
-    if ($soname !~ /\.so\.[0-9]+/ and $soname !~ /.+-\w[\w\.]*\.so$/) {
+    my $soname = format_soname($SONAME{$_});
+    if ($soname !~ / /) {
 	$unversioned_shlibs{$_} = 1;
 	tag 'shlib-without-versioned-soname', $_, $soname
 	    if $ldconfig_dirs->known(dirname($_));
@@ -335,8 +335,9 @@ if ($#shlibs == -1) {
     }
 }
 
-# 5th step: check symbols control file
-if ($#shlibs == -1) {
+# 5th step: check symbols control file.  Add back in the unversioned shared
+# libraries, since they can still have symbols files.
+if ($#shlibs == -1 and not %unversioned_shlibs) {
     # no shared libraries included in package, thus symbols control file should
     # not be present
     if (-f $symbols_control_file) {
@@ -344,7 +345,7 @@ if ($#shlibs == -1) {
     }
 } elsif (not -f $symbols_control_file) {
     if ($type ne 'udeb') {
-	for my $shlib (@shlibs) {
+	for my $shlib (@shlibs, keys %unversioned_shlibs) {
 	    # skip it if it's not a public shared library
 	    next unless $ldconfig_dirs->known(dirname($shlib));
 	    tag "no-symbols-control-file", "$shlib";
@@ -450,7 +451,7 @@ if ($#shlibs == -1) {
 	    "on symbol $debian_revision_sym$others";
     }
     my $shlib_name;
-    for my $shlib (@shlibs) {
+    for my $shlib (@shlibs, keys %unversioned_shlibs) {
 	$shlib_name = $SONAME{$shlib};
 	$shlib_name = format_soname($shlib_name);
 	$symbols_control_used{$shlib_name} = 1;
@@ -482,10 +483,12 @@ if ($#shlibs == -1) {
     } 
 }
 
-# Compare the contents of the shlibs and symbols control files
+# Compare the contents of the shlibs and symbols control files, but exclude
+# from this check shared libraries whose SONAMEs has no version.  Those can
+# only be represented in symbols files and aren't expected in shlibs files.
 if (keys %shlibs_control and keys %symbols_control) {
     for my $key (keys %symbols_control) {
-	unless (exists $shlibs_control{$key}) {
+	unless (exists $shlibs_control{$key} or $key !~ / /) {
 	    tag "symbols-declared-but-not-shlib", $key;
 	}
     }
@@ -563,14 +566,17 @@ sub abs_path {
     return $path;
 }
 
+# Extract the library name and the version from an SONAME and return them
+# separated by a space.  This code should match the split_soname function in
+# dpkg-shlibdeps.
 sub format_soname {
     my $soname = shift;
 
     # libfoo.so.X.X
-    if ($soname =~ m/(.+)\.so\.(.*)$/) {
+    if ($soname =~ /^(.*)\.so\.(.*)$/) {
 	$soname = "$1 $2";
     # libfoo-X.X.so
-    } elsif ($soname =~ m/(.+)\-(\w[\w\.]*)\.so$/) {
+    } elsif ($soname =~ /^(.*)-(\d.*)\.so$/) {
 	$soname = "$1 $2";
     }
 
diff --git a/debian/changelog b/debian/changelog
index d70f1fc..1af715b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -33,9 +33,11 @@ lintian (2.1.3) UNRELEASED; urgency=low
     + [RA] Remove special shlibs exception for NSS modules.  libc6 now
       includes shlibs entries for them.
     + [RA] Report a more specialized tag for shared libraries with SONAMEs
-      that have no version and exclude them from the shlibs and symbols
-      file tests since they cannot be represented there.  Reported by
-      Raphael Hertzog.  (Closes: #506673)
+      that have no version and exclude them from the shlibs file tests
+      since they cannot be represented there.  Reported by Raphael
+      Hertzog.  (Closes: #506673)
+    + [RA] Use the same regexes as dpkg-shlibdeps when parsing version
+      information from SONAMEs.
   * checks/version-substvars:
     + [RA] Skip version substvar checks when the dependency is on a
       package whose name is formed by expanding substvars at build time.
diff --git a/t/tests/6000_shared-libs-unversioned.desc b/t/tests/6000_shared-libs-unversioned.desc
new file mode 100644
index 0000000..63edaf0
--- /dev/null
+++ b/t/tests/6000_shared-libs-unversioned.desc
@@ -0,0 +1,8 @@
+Testname: shared-libs-unversioned
+Type: non-native
+Version: 1.0
+Architecture: any
+Description: Test handling of shared libraries without versioned SONAMEs
+Test-For: shlib-without-versioned-soname
+Test-Against: shlib-missing-in-control-file
+References: Debian Bug#506673
diff --git a/t/templates/skel/debian/control.in b/t/tests/shared-libs-unversioned/debian/debian/control.in
similarity index 92%
copy from t/templates/skel/debian/control.in
copy to t/tests/shared-libs-unversioned/debian/debian/control.in
index 440343b..616d35a 100644
--- a/t/templates/skel/debian/control.in
+++ b/t/tests/shared-libs-unversioned/debian/debian/control.in
@@ -1,11 +1,11 @@
 Source: {$srcpkg}
 Priority: extra
-Section: devel
+Section: libs
 Maintainer: {$author}
 Standards-Version: 3.8.0
 Build-Depends: debhelper (>= 7)
 
-Package: {$srcpkg}
+Package: libfoo
 Architecture: {$architecture}
 Depends: $\{shlibs:Depends\}, $\{misc:Depends\}
 Description: {$description}
diff --git a/t/tests/shared-libs-unversioned/debian/debian/postinst b/t/tests/shared-libs-unversioned/debian/debian/postinst
new file mode 100644
index 0000000..0f437db
--- /dev/null
+++ b/t/tests/shared-libs-unversioned/debian/debian/postinst
@@ -0,0 +1,13 @@
+#!/bin/sh
+#
+# A single library without a versioned SONAME makes dh_makeshlibs think
+# there's nothing to do and hence it doesn't add the ldconfig invocation.
+# Since that's not what we're testing, do it ourselves.
+
+set -e
+
+if [ "$1" = "configure" ] ; then
+    ldconfig
+fi
+
+#DEBHELPER#
diff --git a/t/tests/shared-libs-unversioned/debian/debian/postrm b/t/tests/shared-libs-unversioned/debian/debian/postrm
new file mode 100644
index 0000000..5c269c3
--- /dev/null
+++ b/t/tests/shared-libs-unversioned/debian/debian/postrm
@@ -0,0 +1,13 @@
+#!/bin/sh
+#
+# A single library without a versioned SONAME makes dh_makeshlibs think
+# there's nothing to do and hence it doesn't add the ldconfig invocation.
+# Since that's not what we're testing, do it ourselves.
+
+set -e
+
+if [ "$1" = "remove" ] ; then
+    ldconfig
+fi
+
+#DEBHELPER#
diff --git a/t/tests/shared-libs-unversioned/debian/debian/symbols b/t/tests/shared-libs-unversioned/debian/debian/symbols
new file mode 100644
index 0000000..76a969f
--- /dev/null
+++ b/t/tests/shared-libs-unversioned/debian/debian/symbols
@@ -0,0 +1,2 @@
+libfoo.so libfoo #MINVER#
+ foo@Base 1.0
diff --git a/t/tests/shared-libs-unversioned/tags b/t/tests/shared-libs-unversioned/tags
new file mode 100644
index 0000000..39f7789
--- /dev/null
+++ b/t/tests/shared-libs-unversioned/tags
@@ -0,0 +1 @@
+W: libfoo: shlib-without-versioned-soname usr/lib/libfoo.so libfoo.so
diff --git a/t/tests/shared-libs-unversioned/upstream/Makefile b/t/tests/shared-libs-unversioned/upstream/Makefile
new file mode 100644
index 0000000..8b1da19
--- /dev/null
+++ b/t/tests/shared-libs-unversioned/upstream/Makefile
@@ -0,0 +1,16 @@
+CC = gcc
+CFLAGS = -Wall -O2
+
+all: libfoo.so
+
+libfoo.so: foo.o
+	$(CC) -o $@ -shared -Wl,-soname,libfoo.so $^ -lc
+
+%.o: %.c
+	$(CC) $(CFLAGS) -fPIC -o $@ -c $<
+
+install:
+	install -d $(DESTDIR)/usr/lib
+	install -m644 libfoo.so $(DESTDIR)/usr/lib/
+
+.PHONY: distclean realclean clean install test check
diff --git a/t/tests/shared-libs-unversioned/upstream/foo.c b/t/tests/shared-libs-unversioned/upstream/foo.c
new file mode 100644
index 0000000..d5dd1be
--- /dev/null
+++ b/t/tests/shared-libs-unversioned/upstream/foo.c
@@ -0,0 +1,14 @@
+/*
+ * Be sure that this library uses a function from libc.  Otherwise, gcc is
+ * smart enough not to link it with libc and we get more tags for missing
+ * dependency lines.
+ */
+
+#include <stdio.h>
+
+int
+foo(int num)
+{
+    printf("%d\n", num);
+    return num * 42;
+}
diff --git a/testset/tags.libbaz b/testset/tags.libbaz
index f9c3c39..067e7f6 100644
--- a/testset/tags.libbaz
+++ b/testset/tags.libbaz
@@ -47,6 +47,7 @@ W: libbaz1: missing-depends-line
 W: libbaz1: new-package-should-close-itp-bug
 W: libbaz1: package-name-doesnt-match-sonames libbaz libbaz2-1.0 libbaz3-1
 W: libbaz1: postinst-should-not-set-usr-doc-link
+W: libbaz1: shlib-missing-in-symbols-control-file libbaz.so for usr/lib/libbaz.so
 W: libbaz1: shlib-missing-in-symbols-control-file libbaz2 1.0 for usr/lib/libfoo2.so.1.0.3b
 W: libbaz1: shlib-missing-in-symbols-control-file libbaz3 1 for usr/lib/libbaz3.so.1.0.3b
 W: libbaz1: shlib-without-versioned-soname usr/lib/libbaz.so libbaz.so

-- 
Debian package checker


Reply to: