The following commit has been merged in the master branch:
commit 52e96c75e248d1e85c367dd99c965f3642a45171
Author: Raphael Hertzog <[email protected]>
Date:   Fri Feb 27 13:59:52 2009 +0100

    dpkg-gensymbols: replace #PACKAGE# in dependency templates
    
    To better support packages of libraries that have different names
    between architectures, offer the possibility to not hardcode the package
    name in the symbols file by using #PACKAGE#. This marker is then
    substituted by dpkg-gensymbols when the symbols files are installed inside
    the binary package.

diff --git a/ChangeLog b/ChangeLog
index dfa9472..e0686e2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2009-02-27  Raphael Hertzog  <[email protected]>
 
+       * scripts/Dpkg/Shlibs/SymbolFile.pm (save, dump): Add new
+       parameter asking that #PACKAGE# be replaced on the fly.
+       * scripts/dpkg-gensymbols.pl: Replace #PACKAGE# while outputting
+       symbols files.
+       * man/dpkg-gensymbols.1: Document the new feature.
+       * scripts/t/200_Dpkg_Shlibs.t,
+       scripts/t/200_Dpkg_Shlibs/symbols.fake-2: Add test-case for
+       replacement of #PACKAGE# on the fly (together with test of dump).
+
+2009-02-27  Raphael Hertzog  <[email protected]>
+
        * scripts/update-alternatives.pl: Add one more sanity check
        verifying that <link> and <path> are different (cf #509667 for a
        sample).
diff --git a/debian/changelog b/debian/changelog
index 7c34446..e81e0df 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -170,6 +170,9 @@ dpkg (1.15.0) UNRELEASED; urgency=low
       a single command.
   * Document in update-alternatives(8) how one can repair all broken
     alternatives with a single command. Closes: #250258, #395556
+  * Modify dpkg-gensymbols to replace #PACKAGE# on the fly while installing
+    symbols files so that package having libraries whose name varies between
+    architectures do not need to hardcode the package name. Closes: #517264
 
   [ Pierre Habouzit ]
   * Add a --query option to update-alternatives. Closes: #336091, #441904
diff --git a/man/dpkg-gensymbols.1 b/man/dpkg-gensymbols.1
index c3070f6..435614f 100644
--- a/man/dpkg-gensymbols.1
+++ b/man/dpkg-gensymbols.1
@@ -56,6 +56,14 @@ with "~".
 Before applying any patch to the symbols file, the maintainer should
 double-check that it's sane. Public symbols are not supposed to disappear,
 so the patch should ideally only add new lines.
+.SS Using #PACKAGE# substitution
+.P
+In some rare cases, the name of the library varies between architectures.
+To avoid hardcoding the name of the package in the symbols file, you can
+use the marker \fI#PACKAGE#\fR. It will be replaced by the real package
+name during installation of the symbols files. Contrary to the
+\fI#MINVER#\fR marker, \fI#PACKAGE#\fR will never appear in a symbols file
+inside a binary package.
 .SS Using includes
 .P 
 When the set of exported symbols differ between architectures, it's no
@@ -190,7 +198,7 @@ Show the version and exit.
 .BR dpkg\-shlibdeps (1).
 .
 .SH AUTHORS
-Copyright \(co 2007 Rapha\[:e]l Hertzog
+Copyright \(co 2007-2009 Rapha\[:e]l Hertzog
 .sp
 This is free software; see the GNU General Public Licence version 2 or later
 for copying conditions. There is NO WARRANTY.
diff --git a/scripts/Dpkg/Shlibs/SymbolFile.pm 
b/scripts/Dpkg/Shlibs/SymbolFile.pm
index b871154..42c2ad6 100644
--- a/scripts/Dpkg/Shlibs/SymbolFile.pm
+++ b/scripts/Dpkg/Shlibs/SymbolFile.pm
@@ -188,7 +188,7 @@ sub merge_object_from_symfile {
 }
 
 sub save {
-    my ($self, $file, $with_deprecated) = @_;
+    my ($self, $file, %opts) = @_;
     $file = $self->{file} unless defined($file);
     my $fh;
     if ($file eq "-") {
@@ -197,23 +197,31 @@ sub save {
        open($fh, ">", $file)
            || syserr(_g("cannot write %s"), $file);
     }
-    $self->dump($fh, $with_deprecated);
+    $self->dump($fh, %opts);
     close($fh) if ($file ne "-");
 }
 
 sub dump {
-    my ($self, $fh, $with_deprecated) = @_;
-    $with_deprecated = 1 unless defined($with_deprecated);
+    my ($self, $fh, %opts) = @_;
+    $opts{with_deprecated} = 1 unless exists $opts{with_deprecated};
     foreach my $soname (sort keys %{$self->{objects}}) {
        my @deps = @{$self->{objects}{$soname}{deps}};
-       print $fh "$soname $deps[0]\n";
-       shift @deps;
-       print $fh "| $_\n" foreach (@deps);
+        my $dep = shift @deps;
+        $dep =~ s/#PACKAGE#/$opts{package}/g if exists $opts{package};
+       print $fh "$soname $dep\n";
+        foreach $dep (@deps) {
+            $dep =~ s/#PACKAGE#/$opts{package}/g if exists $opts{package};
+           print $fh "| $dep\n";
+        }
        my $f = $self->{objects}{$soname}{fields};
-       print $fh "* $_: $f->{$_}\n" foreach (sort keys %{$f});
+        foreach my $field (sort keys %{$f}) {
+            my $value = $f->{$field};
+            $value =~ s/#PACKAGE#/$opts{package}/g if exists $opts{package};
+           print $fh "* $field: $value\n";
+        }
        foreach my $sym (sort keys %{$self->{objects}{$soname}{syms}}) {
            my $info = $self->{objects}{$soname}{syms}{$sym};
-           next if $info->{deprecated} and not $with_deprecated;
+           next if $info->{deprecated} and not $opts{with_deprecated};
            print $fh "#MISSING: $info->{deprecated}#" if $info->{deprecated};
            print $fh " $sym $info->{minver}";
            print $fh " $info->{dep_id}" if $info->{dep_id};
diff --git a/scripts/dpkg-gensymbols.pl b/scripts/dpkg-gensymbols.pl
index d4bb229..bebe0f7 100755
--- a/scripts/dpkg-gensymbols.pl
+++ b/scripts/dpkg-gensymbols.pl
@@ -189,7 +189,7 @@ $symfile->clear_except(keys %{$od->{objects}});
 # Write out symbols files
 if ($stdout) {
     $output = "standard output";
-    $symfile->save("-");
+    $symfile->save("-", package => $oppackage);
 } else {
     unless (defined($output)) {
        unless($symfile->is_empty()) {
@@ -199,7 +199,7 @@ if ($stdout) {
     }
     if (defined($output)) {
        print "Storing symbols in $output.\n" if $debug;
-       $symfile->save($output);
+       $symfile->save($output, package => $oppackage);
     } else {
        print "No symbol information to store.\n" if $debug;
     }
@@ -253,7 +253,8 @@ if ($compare) {
        # and after
        my $before = File::Temp->new(TEMPLATE=>'dpkg-gensymbolsXXXXXX');
        my $after = File::Temp->new(TEMPLATE=>'dpkg-gensymbolsXXXXXX');
-       $ref_symfile->dump($before); $symfile->dump($after);
+       $ref_symfile->dump($before, package => $oppackage);
+        $symfile->dump($after, package => $oppackage);
        seek($before, 0, 0); seek($after, 0, 0);
        my ($md5_before, $md5_after) = (Digest::MD5->new(), Digest::MD5->new());
        $md5_before->addfile($before);
diff --git a/scripts/t/200_Dpkg_Shlibs.t b/scripts/t/200_Dpkg_Shlibs.t
index c6713d6..95b862a 100644
--- a/scripts/t/200_Dpkg_Shlibs.t
+++ b/scripts/t/200_Dpkg_Shlibs.t
@@ -161,7 +161,7 @@ is_deeply($sym, { 'minver' => '1.0', 'dep_id' => 1, 
'deprecated' => 0,
 
 # Check dump output
 my $io = IO::String->new();
-$sym_file->dump($io);
+$sym_file->dump($io, package => "libfake1");
 is(${$io->string_ref()},
 'libfake.so.1 libfake1 #MINVER#
 | libvirtualfake
diff --git a/scripts/t/200_Dpkg_Shlibs/symbols.fake-2 
b/scripts/t/200_Dpkg_Shlibs/symbols.fake-2
index e8593b4..8cc3412 100644
--- a/scripts/t/200_Dpkg_Shlibs/symbols.fake-2
+++ b/scripts/t/200_Dpkg_Shlibs/symbols.fake-2
@@ -1,6 +1,6 @@
 #include "symbols.include-2"
 # This is just a comment
-libfake.so.1 libfake1 #MINVER#
+libfake.so.1 #PACKAGE# #MINVER#
 * Build-Depends-Package: libfake-dev
 # The alternate dependency is below
 | libvirtualfake

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to