From: Raphael Hertzog Date: Sun, 9 Dec 2007 10:14:47 +0000 (+0100) Subject: Dpkg::Shlibs::SymbolFile supports meta-information fields X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=72524e4f013dd006cefd4b9d9daa766d228788ee;p=dpkg Dpkg::Shlibs::SymbolFile supports meta-information fields Meta-information fields are stored in symbols files on lines starting with an asterisk. Added a corresponding non-regression test. Updated deb-symbols(5) accordingly. --- diff --git a/ChangeLog b/ChangeLog index e37452a8..1dc85f13 100644 --- a/ChangeLog +++ b/ChangeLog @@ -39,6 +39,17 @@ the deprecated version of a symbol if it is already marked deprecated. +2007-12-09 Raphael Hertzog + + * scripts/Dpkg/Shlibs/SymbolFile.pm: Parse and dump properly + new meta-information fields (on lines starting with an asterisk). + Bugfix with alternate dependency handling that were not properly + dumped. + * scripts/t/200_Dpkg_Shlibs.t, + scripts/t/200_Dpkg_Shlibs/symbols.fake-2: Add a test case to + verify that meta-information fields and alternate dependencies are + properly parsed and dumped. + 2007-12-09 Raphael Hertzog * scripts/Dpkg/Shlibs/SymbolFile.pm (load): Pass the current diff --git a/man/ChangeLog b/man/ChangeLog index 608d7712..177d0272 100644 --- a/man/ChangeLog +++ b/man/ChangeLog @@ -2,6 +2,11 @@ * po/de.po: Updated to 1335t0f48u. +2007-12-09 Raphael Hertzog + + * deb-symbols.5: Describe syntax of meta-information + fields and document the Build-Depends-Package field. + 2007-12-09 Raphael Hertzog * dpkg-gensymbols.1: Remove the restriction that included files diff --git a/man/deb-symbols.5 b/man/deb-symbols.5 index 94c1bd51..98a3c554 100644 --- a/man/deb-symbols.5 +++ b/man/deb-symbols.5 @@ -14,6 +14,10 @@ in these files is: .br [ | ] .br +[ ... ] +.br +[ * : ] +.br [ ... ] [ ] .P @@ -29,6 +33,13 @@ to a \fIminimal version\fR of its dependency template (the main dependency template is used if \fIid of dependency template\fR is not present). The first alternative dependency template is numbered 1, the second one 2, etc. +.P +Each entry for a library can also have some fields of meta-information. +Those fields are stored on lines starting with an asterisk. Currently, +the only valid field is \fIBuild-Depends-Package\fR, it indicates the name +of the "-dev" package associated to the library and is used by +dpkg-shlibdeps to make sure that the dependency generated is at least as +strict as the corresponding build dependency. .SH EXAMPLES .SS Simple symbols file .PP @@ -41,6 +52,8 @@ libftp.so.3 libftp3 #MINVER# libGL.so.1 libgl1 .br | libgl1-mesa-glx #MINVER# +.br +* Build-Depends-Package: libgl1-mesa-dev publicGlSymbol@Base 6.3-1 [...] implementationSpecificSymbol@Base 6.5.2-7 1 diff --git a/scripts/Dpkg/Shlibs/SymbolFile.pm b/scripts/Dpkg/Shlibs/SymbolFile.pm index a2cf9f2e..8f3dfe58 100644 --- a/scripts/Dpkg/Shlibs/SymbolFile.pm +++ b/scripts/Dpkg/Shlibs/SymbolFile.pm @@ -19,6 +19,7 @@ package Dpkg::Shlibs::SymbolFile; use Dpkg::Gettext; use Dpkg::ErrorHandling qw(syserr warning error); use Dpkg::Version qw(vercmp); +use Dpkg::Fields qw(capit); my %blacklist = ( '__bss_end__' => 1, # arm @@ -129,6 +130,9 @@ sub load { } elsif (/^\|\s*(.*)$/) { # Alternative dependency template push @{$self->{objects}{$object}{deps}}, "$1"; + } elsif (/^\*\s*([^:]+):\s*(.*\S)\s*$/) { + # Add meta-fields + $self->{objects}{$object}{fields}{capit($1)} = $2; } elsif (/^(\S+)\s+(.*)$/) { # New object and dependency template $object = $1; @@ -137,10 +141,7 @@ sub load { $self->{objects}{$object}{deps} = [ "$2" ]; } else { # Create a new object - $self->{objects}{$object} = { - syms => {}, - deps => [ "$2" ] - }; + $self->create_object($object, "$2"); } } else { warning(sprintf(_g("Failed to parse a line in %s: %s"), $file, $_)); @@ -167,8 +168,12 @@ sub dump { my ($self, $fh, $with_deprecated) = @_; $with_deprecated = 1 unless defined($with_deprecated); foreach my $soname (sort keys %{$self->{objects}}) { - print $fh "$soname $self->{objects}{$soname}{deps}[0]\n"; - print $fh "| $_" foreach (@{$self->{objects}{$soname}{deps}}[ 1 .. -1 ]); + my @deps = @{$self->{objects}{$soname}{deps}}; + print $fh "$soname $deps[0]\n"; + shift @deps; + print $fh "| $_\n" foreach (@deps); + my $f = $self->{objects}{$soname}{fields}; + print $fh "* $_: $f->{$_}\n" foreach (sort keys %{$f}); foreach my $sym (sort keys %{$self->{objects}{$soname}{syms}}) { my $info = $self->{objects}{$soname}{syms}{$sym}; next if $info->{deprecated} and not $with_deprecated; @@ -257,6 +262,7 @@ sub create_object { my ($self, $soname, @deps) = @_; $self->{objects}{$soname} = { syms => {}, + fields => {}, deps => [ @deps ] }; } diff --git a/scripts/t/200_Dpkg_Shlibs.t b/scripts/t/200_Dpkg_Shlibs.t index bfc5da27..86bdeab2 100644 --- a/scripts/t/200_Dpkg_Shlibs.t +++ b/scripts/t/200_Dpkg_Shlibs.t @@ -1,6 +1,7 @@ # -*- mode: cperl;-*- -use Test::More tests => 33; +use Test::More tests => 34; +use IO::String; use strict; use warnings; @@ -148,6 +149,19 @@ is_deeply($sym, { 'minver' => '1.0', 'dep_id' => 1, 'deprecated' => 0, 'depends' => 'libvirtualfake', 'soname' => 'libfake.so.1' }, 'overrides order with circular #include'); +# Check dump output +my $io = IO::String->new(); +$sym_file->dump($io); +is(${$io->string_ref()}, +'libfake.so.1 libfake1 #MINVER# +| libvirtualfake +* Build-Depends-Package: libfake-dev + symbol1_fake2@Base 1.0 1 + symbol2_fake2@Base 1.0 + symbol3_fake2@Base 1.0 +', "Dump of $srcdir/symbols.include-2"); + + # Check parsing of objdump output on ia64 (local symbols # without versions and with visibility attribute) $obj = Dpkg::Shlibs::Objdump::Object->new; diff --git a/scripts/t/200_Dpkg_Shlibs/symbols.fake-2 b/scripts/t/200_Dpkg_Shlibs/symbols.fake-2 index 89586d1e..e8593b4e 100644 --- a/scripts/t/200_Dpkg_Shlibs/symbols.fake-2 +++ b/scripts/t/200_Dpkg_Shlibs/symbols.fake-2 @@ -1,6 +1,7 @@ #include "symbols.include-2" # This is just a comment libfake.so.1 libfake1 #MINVER# +* Build-Depends-Package: libfake-dev # The alternate dependency is below | libvirtualfake symbol1_fake2@Base 1.0 1