Przeglądaj źródła

dpkg-gensymbols: be more explicit in warning about new/lost libraries

* scripts/Dpkg/Shlibs/SymbolFile.pm: Replace has_new_libs(),
has_lost_libs(), has_new_symbols() and has_lost_symbols() by
corresponding get_* functions.
* scripts/dpkg-gensymbsols.pl: Display list of new/lost libs. Also
display list of lost symbols when wildcards symbols have been
used.
* scripts/t/200_Dpkg_Shlibs.t: Adjust test suite to API change.
Raphael Hertzog 18 lat temu
rodzic
commit
5f883bcea5

+ 10 - 0
ChangeLog

@@ -1,3 +1,13 @@
+2008-01-27  Raphael Hertzog  <hertzog@debian.org>
+
+	* scripts/Dpkg/Shlibs/SymbolFile.pm: Replace has_new_libs(),
+	has_lost_libs(), has_new_symbols() and has_lost_symbols() by
+	corresponding get_* functions.
+	* scripts/dpkg-gensymbsols.pl: Display list of new/lost libs. Also
+	display list of lost symbols when wildcards symbols have been
+	used.
+	* scripts/t/200_Dpkg_Shlibs.t: Adjust test suite to API change.
+
 2008-01-25  Andreas Påhlsson  <andreas.pahlsson@xcerion.com>
 
 	* utils/start-stop-daemon.c (tsub): Remove function.

+ 2 - 0
debian/changelog

@@ -14,6 +14,8 @@ dpkg (1.14.17) UNRELEASED; urgency=low
     smaller than the previous one. Closes: #4655
   * Add -d and -c options in dpkg-checkbuilddeps to override
     build-depends/conflicts. Closes: #114774
+  * Include list of libraries in dpkg-gensymbols' warning about new/lost
+    libraries.
 
   [ Updated manpages translations ]
   * German (Helge Kreutzmann).

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

@@ -353,8 +353,9 @@ sub lookup_symbol {
     return undef;
 }
 
-sub has_new_symbols {
+sub get_new_symbols {
     my ($self, $ref) = @_;
+    my @res;
     foreach my $soname (keys %{$self->{objects}}) {
 	my $mysyms = $self->{objects}{$soname}{syms};
 	next if not exists $ref->{objects}{$soname};
@@ -365,30 +366,35 @@ sub has_new_symbols {
 	    if ((not exists $refsyms->{$sym}) or
 		$refsyms->{$sym}{deprecated})
 	    {
-		return 1;
+		push @res, {
+		    'soname' => $soname,
+		    'name' => $sym,
+		    %{$mysyms->{$sym}}
+		};
 	    }
 	}
     }
-    return 0;
+    return @res;
 }
 
-sub has_lost_symbols {
+sub get_lost_symbols {
     my ($self, $ref) = @_;
-    return $ref->has_new_symbols($self);
+    return $ref->get_new_symbols($self);
 }
 
 
-sub has_new_libs {
+sub get_new_libs {
     my ($self, $ref) = @_;
+    my @res;
     foreach my $soname (keys %{$self->{objects}}) {
-	return 1 if not exists $ref->{objects}{$soname};
+	push @res, $soname if not exists $ref->{objects}{$soname};
     }
-    return 0;
+    return @res;
 }
 
-sub has_lost_libs {
+sub get_lost_libs {
     my ($self, $ref) = @_;
-    return $ref->has_new_libs($self);
+    return $ref->get_new_libs($self);
 }
 
 1;

+ 26 - 10
scripts/dpkg-gensymbols.pl

@@ -200,25 +200,41 @@ if ($compare) {
     use File::Temp;
     use Digest::MD5;
     # Compare
-    if ($symfile->has_new_libs($ref_symfile)) {
-	warning(_g("new libraries appeared in the symbols file."));
+    if (my @libs = $symfile->get_new_libs($ref_symfile)) {
+	warning(_g("new libraries appeared in the symbols file: %s"), "@libs");
 	$exitcode = 4 if ($compare >= 4);
     }
-    if ($symfile->has_lost_libs($ref_symfile)) {
-	warning(_g("some libraries disappeared in the symbols file."));
+    if (my @libs = $symfile->get_lost_libs($ref_symfile)) {
+	warning(_g("some libraries disappeared in the symbols file: %s"), "@libs");
 	$exitcode = 3 if ($compare >= 3);
     }
-    if ($symfile->has_new_symbols($ref_symfile)) {
+    if ($symfile->get_new_symbols($ref_symfile)) {
 	unless ($symfile->used_wildcards()) {
 	    # Wildcards are used to replace many additional symbols, so we
 	    # have no idea if this is really true, so don't say it and
 	    # don't check it
-	    warning(_g("some new symbols appeared in the symbols file."));
+	    warning(_g("some new symbols appeared in the symbols file: %s"),
+		    _g("see diff output below"));
 	    $exitcode = 2 if ($compare >= 2);
 	}
     }
-    if ($symfile->has_lost_symbols($ref_symfile)) {
-	warning(_g("some symbols disappeared in the symbols file."));
+    if (my @syms = $symfile->get_lost_symbols($ref_symfile)) {
+	my $list = _g("see diff output below");
+	if ($symfile->used_wildcards()) {
+	    # If wildcards are used, we don't get a diff, so list
+	    # explicitely symbols which are lost
+	    $list = "\n";
+	    my $cur_soname = "";
+	    foreach my $sym (sort { $a->{soname} cmp $b->{soname} or
+				    $a->{name} cmp $b->{name} } @syms) {
+		if ($cur_soname ne $sym->{soname}) {
+		    $list .= $sym->{soname} . "\n";
+		    $cur_soname = $sym->{soname};
+		}
+		$list .= " " . $sym->{name} . "\n";
+	    }
+	}
+	warning(_g("some symbols disappeared in the symbols file: %s"), $list);
 	$exitcode = 1 if ($compare >= 1);
     }
     unless ($symfile->used_wildcards()) {
@@ -234,10 +250,10 @@ if ($compare) {
 	# Output diffs between symbols files if any
 	if ($md5_before->hexdigest() ne $md5_after->hexdigest()) {
 	    if (defined($ref_symfile->{file})) {
-		warning(_g("%s doesn't match completely %s\n"),
+		warning(_g("%s doesn't match completely %s"),
 			$output, $ref_symfile->{file});
 	    } else {
-		warning(_g("no debian/symbols file used as basis for generating %s\n"),
+		warning(_g("no debian/symbols file used as basis for generating %s"),
 			$output);
 	    }
 	    my ($a, $b) = ($before->filename, $after->filename);

+ 2 - 2
scripts/t/200_Dpkg_Shlibs.t

@@ -102,8 +102,8 @@ ok( $sym_file->has_object('libc.so.6'), 'SONAME in sym file' );
 
 $sym_file->merge_symbols($obj, "2.6-1");
 
-ok( $sym_file->has_new_symbols($sym_file_old), 'has new symbols' );
-ok( $sym_file_old->has_lost_symbols($sym_file), 'has lost symbols' );
+ok( $sym_file->get_new_symbols($sym_file_old), 'has new symbols' );
+ok( $sym_file_old->get_lost_symbols($sym_file), 'has lost symbols' );
 
 is( $sym_file_old->lookup_symbol('__bss_start@Base', ['libc.so.6']),
     undef, 'internal symbols are blacklisted');