Преглед на файлове

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 преди 18 години
родител
ревизия
72524e4f01
променени са 6 файла, в които са добавени 57 реда и са изтрити 7 реда
  1. 11 0
      ChangeLog
  2. 5 0
      man/ChangeLog
  3. 13 0
      man/deb-symbols.5
  4. 12 6
      scripts/Dpkg/Shlibs/SymbolFile.pm
  5. 15 1
      scripts/t/200_Dpkg_Shlibs.t
  6. 1 0
      scripts/t/200_Dpkg_Shlibs/symbols.fake-2

+ 11 - 0
ChangeLog

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

+ 5 - 0
man/ChangeLog

@@ -2,6 +2,11 @@
 
 
 	* po/de.po: Updated to 1335t0f48u.
 	* 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>
 2007-12-09  Raphael Hertzog  <hertzog@debian.org>
 
 
 	* dpkg-gensymbols.1: Remove the restriction that included files
 	* dpkg-gensymbols.1: Remove the restriction that included files

+ 13 - 0
man/deb-symbols.5

@@ -14,6 +14,10 @@ in these files is:
 .br
 .br
 [ | <alternative dependency template> ]
 [ | <alternative dependency template> ]
 .br
 .br
+[ ... ]
+.br
+[ * <field-name>: <field value> ]
+.br
 [ ... ]
 [ ... ]
  <symbol> <mininal version>[ <id of dependency template> ]
  <symbol> <mininal version>[ <id of dependency template> ]
 .P
 .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
 template is used if \fIid of dependency template\fR is not present). The
 first alternative dependency template is numbered 1, the second one 2,
 first alternative dependency template is numbered 1, the second one 2,
 etc.
 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
 .SH EXAMPLES
 .SS Simple symbols file
 .SS Simple symbols file
 .PP 
 .PP 
@@ -41,6 +52,8 @@ libftp.so.3 libftp3 #MINVER#
 libGL.so.1 libgl1
 libGL.so.1 libgl1
 .br
 .br
 | libgl1-mesa-glx #MINVER#
 | libgl1-mesa-glx #MINVER#
+.br
+* Build-Depends-Package: libgl1-mesa-dev
  publicGlSymbol@Base 6.3-1
  publicGlSymbol@Base 6.3-1
  [...]
  [...]
  implementationSpecificSymbol@Base 6.5.2-7 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::Gettext;
 use Dpkg::ErrorHandling qw(syserr warning error);
 use Dpkg::ErrorHandling qw(syserr warning error);
 use Dpkg::Version qw(vercmp);
 use Dpkg::Version qw(vercmp);
+use Dpkg::Fields qw(capit);
 
 
 my %blacklist = (
 my %blacklist = (
     '__bss_end__' => 1,		# arm
     '__bss_end__' => 1,		# arm
@@ -129,6 +130,9 @@ sub load {
 	} elsif (/^\|\s*(.*)$/) {
 	} elsif (/^\|\s*(.*)$/) {
 	    # Alternative dependency template
 	    # Alternative dependency template
 	    push @{$self->{objects}{$object}{deps}}, "$1";
 	    push @{$self->{objects}{$object}{deps}}, "$1";
+	} elsif (/^\*\s*([^:]+):\s*(.*\S)\s*$/) {
+	    # Add meta-fields
+	    $self->{objects}{$object}{fields}{capit($1)} = $2;
 	} elsif (/^(\S+)\s+(.*)$/) {
 	} elsif (/^(\S+)\s+(.*)$/) {
 	    # New object and dependency template
 	    # New object and dependency template
 	    $object = $1;
 	    $object = $1;
@@ -137,10 +141,7 @@ sub load {
 		$self->{objects}{$object}{deps} = [ "$2" ];
 		$self->{objects}{$object}{deps} = [ "$2" ];
 	    } else {
 	    } else {
 		# Create a new object
 		# Create a new object
-		$self->{objects}{$object} = {
-		    syms => {},
-		    deps => [ "$2" ]
-		};
+		$self->create_object($object, "$2");
 	    }
 	    }
 	} else {
 	} else {
 	    warning(sprintf(_g("Failed to parse a line in %s: %s"), $file, $_));
 	    warning(sprintf(_g("Failed to parse a line in %s: %s"), $file, $_));
@@ -167,8 +168,12 @@ sub dump {
     my ($self, $fh, $with_deprecated) = @_;
     my ($self, $fh, $with_deprecated) = @_;
     $with_deprecated = 1 unless defined($with_deprecated);
     $with_deprecated = 1 unless defined($with_deprecated);
     foreach my $soname (sort keys %{$self->{objects}}) {
     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}}) {
 	foreach my $sym (sort keys %{$self->{objects}{$soname}{syms}}) {
 	    my $info = $self->{objects}{$soname}{syms}{$sym};
 	    my $info = $self->{objects}{$soname}{syms}{$sym};
 	    next if $info->{deprecated} and not $with_deprecated;
 	    next if $info->{deprecated} and not $with_deprecated;
@@ -257,6 +262,7 @@ sub create_object {
     my ($self, $soname, @deps) = @_;
     my ($self, $soname, @deps) = @_;
     $self->{objects}{$soname} = {
     $self->{objects}{$soname} = {
 	syms => {},
 	syms => {},
+	fields => {},
 	deps => [ @deps ]
 	deps => [ @deps ]
     };
     };
 }
 }

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

@@ -1,6 +1,7 @@
 # -*- mode: cperl;-*-
 # -*- mode: cperl;-*-
 
 
-use Test::More tests => 33;
+use Test::More tests => 34;
+use IO::String;
 
 
 use strict;
 use strict;
 use warnings;
 use warnings;
@@ -148,6 +149,19 @@ is_deeply($sym, { 'minver' => '1.0', 'dep_id' => 1, 'deprecated' => 0,
 		  'depends' => 'libvirtualfake', 'soname' => 'libfake.so.1' }, 
 		  'depends' => 'libvirtualfake', 'soname' => 'libfake.so.1' }, 
 	    'overrides order with circular #include');
 	    '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
 # Check parsing of objdump output on ia64 (local symbols
 # without versions and with visibility attribute)
 # without versions and with visibility attribute)
 $obj = Dpkg::Shlibs::Objdump::Object->new;
 $obj = Dpkg::Shlibs::Objdump::Object->new;

+ 1 - 0
scripts/t/200_Dpkg_Shlibs/symbols.fake-2

@@ -1,6 +1,7 @@
 #include "symbols.include-2"
 #include "symbols.include-2"
 # This is just a comment
 # This is just a comment
 libfake.so.1 libfake1 #MINVER#
 libfake.so.1 libfake1 #MINVER#
+* Build-Depends-Package: libfake-dev
 # The alternate dependency is below
 # The alternate dependency is below
 | libvirtualfake
 | libvirtualfake
  symbol1_fake2@Base 1.0 1
  symbol1_fake2@Base 1.0 1