From 5f883bcea5b09cc70a60c7262fb394a49d2bd628 Mon Sep 17 00:00:00 2001 From: Raphael Hertzog Date: Sun, 27 Jan 2008 17:53:05 +0100 Subject: [PATCH] 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. --- ChangeLog | 10 +++++++++ debian/changelog | 2 ++ scripts/Dpkg/Shlibs/SymbolFile.pm | 26 +++++++++++++--------- scripts/dpkg-gensymbols.pl | 36 ++++++++++++++++++++++--------- scripts/t/200_Dpkg_Shlibs.t | 4 ++-- 5 files changed, 56 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 96516d22..6d26526f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-01-27 Raphael Hertzog + + * 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 * utils/start-stop-daemon.c (tsub): Remove function. diff --git a/debian/changelog b/debian/changelog index 66ce59c3..08528d2a 100644 --- a/debian/changelog +++ b/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). diff --git a/scripts/Dpkg/Shlibs/SymbolFile.pm b/scripts/Dpkg/Shlibs/SymbolFile.pm index 7e076b81..5aac6810 100644 --- a/scripts/Dpkg/Shlibs/SymbolFile.pm +++ b/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; diff --git a/scripts/dpkg-gensymbols.pl b/scripts/dpkg-gensymbols.pl index 58aaa091..df50dad7 100755 --- a/scripts/dpkg-gensymbols.pl +++ b/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); diff --git a/scripts/t/200_Dpkg_Shlibs.t b/scripts/t/200_Dpkg_Shlibs.t index 8b28ec46..529bf511 100644 --- a/scripts/t/200_Dpkg_Shlibs.t +++ b/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'); -- 2.39.5