Sfoglia il codice sorgente

Deperecate a symbol only when the history of version matches.

When merging symbols in a SymbolFile, a symbol is deprecated when it has
disappeared from the new set of symbols. However when the new set of
symbols dates back to before the current one, deprecating doesn't make
sense. This patch corrects this behaviour. Also add a test to verify that
symbols got correctly marked as deprecated.
Raphael Hertzog 19 anni fa
parent
commit
fddb619b2d
2 ha cambiato i file con 15 aggiunte e 5 eliminazioni
  1. 10 4
      scripts/Dpkg/Shlibs/SymbolFile.pm
  2. 5 1
      scripts/t/200_Dpkg_Shlibs.t

+ 10 - 4
scripts/Dpkg/Shlibs/SymbolFile.pm

@@ -223,10 +223,14 @@ sub merge_symbols {
     }
     }
 
 
     # Scan all symbols in the file and mark as deprecated those that are
     # Scan all symbols in the file and mark as deprecated those that are
-    # no more provided
+    # no more provided (only if the minver is bigger than the version where
+    # the symbol was introduced)
     foreach my $sym (keys %{$self->{objects}{$soname}{syms}}) {
     foreach my $sym (keys %{$self->{objects}{$soname}{syms}}) {
 	if (! exists $dynsyms{$sym}) {
 	if (! exists $dynsyms{$sym}) {
-	    $self->{objects}{$soname}{syms}{$sym}{deprecated} = $minver;
+	    my $info = $self->{objects}{$soname}{syms}{$sym};
+	    if (vercmp($minver, $info->{minver}) > 0) {
+		$self->{objects}{$soname}{syms}{$sym}{deprecated} = $minver;
+	    }
 	}
 	}
     }
     }
 }
 }
@@ -256,11 +260,13 @@ sub get_dependency {
 }
 }
 
 
 sub lookup_symbol {
 sub lookup_symbol {
-    my ($self, $name, $sonames) = @_;
+    my ($self, $name, $sonames, $inc_deprecated) = @_;
+    $inc_deprecated = 0 unless defined($inc_deprecated);
     foreach my $so (@{$sonames}) {
     foreach my $so (@{$sonames}) {
 	next if (! exists $self->{objects}{$so});
 	next if (! exists $self->{objects}{$so});
 	if (exists $self->{objects}{$so}{syms}{$name} and
 	if (exists $self->{objects}{$so}{syms}{$name} and
-	    not $self->{objects}{$so}{syms}{$name}{deprecated})
+	    ($inc_deprecated or not
+	    $self->{objects}{$so}{syms}{$name}{deprecated}))
 	{
 	{
 	    my $dep_id = $self->{objects}{$so}{syms}{$name}{dep_id};
 	    my $dep_id = $self->{objects}{$so}{syms}{$name}{dep_id};
 	    return {
 	    return {

+ 5 - 1
scripts/t/200_Dpkg_Shlibs.t

@@ -1,6 +1,6 @@
 # -*- mode: cperl;-*-
 # -*- mode: cperl;-*-
 
 
-use Test::More tests => 25;
+use Test::More tests => 26;
 
 
 use strict;
 use strict;
 use warnings;
 use warnings;
@@ -79,6 +79,10 @@ ok( $sym_file_old->has_lost_symbols($sym_file), 'has lost symbols' );
 is( $sym_file_old->lookup_symbol('__bss_start@Base', ['libc.so.6']),
 is( $sym_file_old->lookup_symbol('__bss_start@Base', ['libc.so.6']),
     undef, 'internal symbols are blacklisted');
     undef, 'internal symbols are blacklisted');
 
 
+$sym = $sym_file->lookup_symbol('_errno@GLIBC_2.0', ['libc.so.6'], 1);
+is_deeply($sym, { 'minver' => '2.3.6.ds1-13', 'dep_id' => 0, 
+		  'deprecated' => '2.6-1', 'depends' => '', 
+		  'soname' => 'libc.so.6' }, 'deprecated symbol');
 
 
 use File::Temp;
 use File::Temp;