Quellcode durchsuchen

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.
Raphael Hertzog vor 18 Jahren
Ursprung
Commit
72524e4f01

+ 11 - 0
ChangeLog

@@ -39,6 +39,17 @@
 	the deprecated version of a symbol if it is already marked
 	deprecated.
 
+2007-12-09  Raphael Hertzog  <hertzog@debian.org>
+
+	* 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  <hertzog@debian.org>
 
 	* scripts/Dpkg/Shlibs/SymbolFile.pm (load): Pass the current

+ 5 - 0
man/ChangeLog

@@ -2,6 +2,11 @@
 
 	* po/de.po: Updated to 1335t0f48u.
 
+2007-12-09  Raphael Hertzog  <hertzog@debian.org>
+
+	* deb-symbols.5: Describe syntax of meta-information
+	fields and document the Build-Depends-Package field.
+
 2007-12-09  Raphael Hertzog  <hertzog@debian.org>
 
 	* dpkg-gensymbols.1: Remove the restriction that included files

+ 13 - 0
man/deb-symbols.5

@@ -14,6 +14,10 @@ in these files is:
 .br
 [ | <alternative dependency template> ]
 .br
+[ ... ]
+.br
+[ * <field-name>: <field value> ]
+.br
 [ ... ]
  <symbol> <mininal version>[ <id of dependency template> ]
 .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

+ 12 - 6
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 ]
     };
 }

+ 15 - 1
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;

+ 1 - 0
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