Просмотр исходного кода

dpkg-shlibdeps: fix code to find out minimal version among all symbols

dpkg-shlibdeps did not always correctly initialize symbol-based
dependencies for libraries having symbols associated with a version "0".

“$minver ||= $sym->{minver};” changed $minver to the first non-null version
that followed a null version. Because the null version is evidently
selected as the minimal version but that code considers it unset and
replaces it with whatever it has.

Add a non-regression test for this part of the code.
Raphael Hertzog лет назад: 17
Родитель
Сommit
02e3de2f1d

+ 4 - 0
debian/changelog

@@ -34,6 +34,10 @@ dpkg (1.15.1) UNRELEASED; urgency=low
     - Add debian-maintainers to Suggests. Together with debian-keyring they
     contain all the GPG keys required to verify official Debian packages.
   * Drop /etc/dpkg/origins as it's taken over by base-files (see #487437).
+  * Fix dpkg-shlibdeps to properly initialize a symbol-based dependency
+    even when some symbols are associated with a (fake) version "0". Such a
+    version means that the symbol has always existed in all versions of the
+    package.
 
   [ Guillem Jover ]
   * Fix typo in dpkg output (‘unexecpted’ → ‘unexpected’). Closes: #519082

+ 1 - 1
scripts/Dpkg/Shlibs/SymbolFile.pm

@@ -335,7 +335,7 @@ sub get_smallest_version {
     my $minver;
     foreach my $sym (values %{$self->{objects}{$soname}{syms}}) {
         next if $dep_id != $sym->{dep_id};
-        $minver ||= $sym->{minver};
+        $minver = $sym->{minver} unless defined($minver);
         if (vercmp($minver, $sym->{minver}) > 0) {
             $minver = $sym->{minver};
         }

+ 9 - 3
scripts/t/200_Dpkg_Shlibs.t

@@ -1,6 +1,6 @@
 # -*- mode: cperl;-*-
 
-use Test::More tests => 37;
+use Test::More tests => 39;
 use IO::String;
 
 use strict;
@@ -148,10 +148,13 @@ is_deeply($sym, {'minver' => '1.0', 'dep_id' => 0, 'deprecated' => 0,
 	    'overrides order with #include');
 
 $sym = $sym_file->lookup_symbol('symbol3_fake1@Base', ['libfake.so.1']);
-is_deeply($sym, { 'minver' => '1.1', 'dep_id' => 0, 'deprecated' => 0,
+is_deeply($sym, { 'minver' => '0', 'dep_id' => 0, 'deprecated' => 0,
 		  'depends' => 'libfake1 #MINVER#', 'soname' => 'libfake.so.1' }, 
 	    'overrides order with #include');
 
+is($sym_file->get_smallest_version('libfake.so.1'), "0",
+   'get_smallest_version with null version');
+
 $sym_file = Dpkg::Shlibs::SymbolFile->new("$srcdir/symbols.include-2");
 
 $sym = $sym_file->lookup_symbol('symbol1_fake2@Base', ['libfake.so.1']);
@@ -159,6 +162,9 @@ is_deeply($sym, { 'minver' => '1.0', 'dep_id' => 1, 'deprecated' => 0,
 		  'depends' => 'libvirtualfake', 'soname' => 'libfake.so.1' }, 
 	    'overrides order with circular #include');
 
+is($sym_file->get_smallest_version('libfake.so.1'), "1.0",
+   'get_smallest_version');
+
 # Check dump output
 my $io = IO::String->new();
 $sym_file->dump($io, package => "libfake1");
@@ -168,7 +174,7 @@ is(${$io->string_ref()},
 * Build-Depends-Package: libfake-dev
  symbol1_fake2@Base 1.0 1
  symbol2_fake2@Base 1.0
- symbol3_fake2@Base 1.0
+ symbol3_fake2@Base 1.1
 ', "Dump of $srcdir/symbols.include-2");
 
 

+ 1 - 1
scripts/t/200_Dpkg_Shlibs/symbols.fake-2

@@ -6,4 +6,4 @@ libfake.so.1 #PACKAGE# #MINVER#
 | libvirtualfake
  symbol1_fake2@Base 1.0 1
  symbol2_fake2@Base 1.0
- symbol3_fake2@Base 1.0
+ symbol3_fake2@Base 1.1

+ 1 - 1
scripts/t/200_Dpkg_Shlibs/symbols.include-1

@@ -3,5 +3,5 @@ libfake.so.1 libfake1 #MINVER#
  symbol2_fake1@Base 0.9
  symbol_before@Base 0.9
 #include "symbols.fake-1"
- symbol3_fake1@Base 1.1
+ symbol3_fake1@Base 0
  symbol_after@Base 1.1