Hi Matthias,

Here are the updated binutils-multiarch patches.  The patches are
based on binutils 2.20.51.20100415-1.  I hope it is not too late for
them to be useful.

Matthias Klose wrote:

> I added this for shlibs file generation in the meantime. please use
> the DEB_VERSION var. Also the this_version stuff won't handle
> binNMUs, maybe it's enough to drop the +bN suffix from this_version.

Checking dpkg/scripts/Dpkg/Substvars.pm for the definition of
${source:Version}, yes, all it does is s/\+b[0-9]+//.  So I used
that to define a new DEB_SVERSION var.

For the maintainer scripts, it is not actually important whether
DEB_VERSION or DEB_SVERSION is used.  I couldn’t come up with a good
single place in the code to explain that, so I just put it in the
description for the patch.

Thanks again for your feedback so far.

Jonathan Nieder (5):
  binutils-multiarch: clean up diversion handling
  Remove ld.bfd from binutils-multiarch
  Add ld.bfd and c++filt back to binutils-multiarch
  Remove elfedit from binutils-multiarch
  Fix shlibs files to use correct SONAMES

 debian/binutils-multiarch.postinst   |   45 ++++++++++++++++++-
 debian/binutils-multiarch.postrm     |   32 -------------
 debian/binutils-multiarch.postrm.in  |   53 ++++++++++++++++++++++
 debian/binutils-multiarch.preinst    |   82 ----------------------------------
 debian/binutils-multiarch.preinst.in |   31 +++++++++++++
 debian/binutils-multiarch.prerm.in   |   64 ++++++++++++++++++++++++++
 debian/changelog                     |   19 ++++++++
 debian/rules                         |   30 +++++++++---
 8 files changed, 234 insertions(+), 122 deletions(-)
 delete mode 100644 debian/binutils-multiarch.postrm
 create mode 100644 debian/binutils-multiarch.postrm.in
 delete mode 100644 debian/binutils-multiarch.preinst
 create mode 100644 debian/binutils-multiarch.preinst.in
 create mode 100644 debian/binutils-multiarch.prerm.in

>From 607f8c4a9dccb524c65f69327f17f513fcc4a844 Mon Sep 17 00:00:00 2001
From: Jonathan Nieder <jrnie...@gmail.com>
Date: Sun, 18 Apr 2010 05:51:20 -0500
Subject: [PATCH 1/5] binutils-multiarch: clean up diversion handling

Make diversion handling more robust by taking more cases into account.

Previously, an upgrade removing a file that was previously diverted
could easily produce errors from attempting to remove the diversion
too early.  As a result, the diversion would stay around and no
package would provide the relevant file.

Signed-off-by: Jonathan Nieder <jrnie...@gmail.com>
---
 debian/binutils-multiarch.postinst   |   45 ++++++++++++++++++-
 debian/binutils-multiarch.postrm     |   32 -------------
 debian/binutils-multiarch.postrm.in  |   50 ++++++++++++++++++++
 debian/binutils-multiarch.preinst    |   82 ----------------------------------
 debian/binutils-multiarch.preinst.in |   28 ++++++++++++
 debian/binutils-multiarch.prerm.in   |   64 ++++++++++++++++++++++++++
 debian/changelog                     |   13 +++++
 debian/rules                         |    3 +-
 8 files changed, 201 insertions(+), 116 deletions(-)
 delete mode 100644 debian/binutils-multiarch.postrm
 create mode 100644 debian/binutils-multiarch.postrm.in
 delete mode 100644 debian/binutils-multiarch.preinst
 create mode 100644 debian/binutils-multiarch.preinst.in
 create mode 100644 debian/binutils-multiarch.prerm.in

diff --git a/debian/binutils-multiarch.postinst 
b/debian/binutils-multiarch.postinst
index 9977c68..37c42fd 100644
--- a/debian/binutils-multiarch.postinst
+++ b/debian/binutils-multiarch.postinst
@@ -1,6 +1,49 @@
 #! /bin/sh
-
+# Update .so symlinks and remove obsolete diversions.
+#
+# Removing a diversion requires a guarantee that the conflicting
+# file is not present any more, and we cannot guarantee that if
+# some other version of binutils-multiarch is installed.
+# So we remove the diversions in postinst, not preinst.
 set -e
+old_diversion() {
+       local divertto file
+       file=$1
+       divertto=${2-$file.single}
+       if
+               dpkg-divert --package binutils-multiarch --list |
+               grep -q -F "$divertto"
+       then
+               dpkg-divert --package binutils-multiarch \
+                               --remove --rename \
+                               --divert "$divertto" "$file"
+       fi
+}
+
+# remove obsolete diversions
+old_diversion /usr/lib/libbfd.a /usr/lib/libbfd-single.a
+old_diversion /usr/lib/libopcodes.a /usr/lib/libopcodes-single.a
+old_diversion /usr/bin/ld
+for f in elf32_sparc elf32ppc elf64alpha elf_i386 m68kelf \
+         alpha i386linux m68klinux sparclinux sun4
+do
+       for ext in x xbn xn xr xs xu
+       do
+               old_diversion /usr/lib/ldscripts/$f.$ext
+       done
+done
+old_diversion /usr/lib/libbfd-2.9.1.0.15.so.0.0.0 \
+              /usr/lib/libbfd-single-2.9.1.0.15.so.0.0.0
+old_diversion /usr/lib/libopcodes-2.9.1.0.15.so.0.0.0 \
+              /usr/lib/libopcodes-single-2.9.1.0.15.so.0.0.0
+old_diversion /usr/lib/libbfd.la /usr/lib/libbfd-single.la
+old_diversion /usr/lib/libopcodes.la /usr/lib/libopcodes-single.la
+old_diversion /usr/include/bfd.h /usr/include/bfd.single.h
+old_diversion /usr/lib/ldscripts
+old_diversion /usr/bin/c++filt
+
+rm -f /usr/lib/libbfd-*-multiarch.so.0
+rm -f /usr/lib/libopcodes-*-multiarch.so.0
 
 if [ "$1" = "configure" ]; then
        ldconfig
diff --git a/debian/binutils-multiarch.postrm b/debian/binutils-multiarch.postrm
deleted file mode 100644
index 73c239d..0000000
--- a/debian/binutils-multiarch.postrm
+++ /dev/null
@@ -1,32 +0,0 @@
-#! /bin/sh
-
-set -e
-
-if [ "$1" = "remove" -o "$1" = "abort-install" ]; then
-
-       for f in size objdump ar strings ranlib objcopy addr2line \
-                 readelf elfedit nm strip gprof; do
-               dpkg-divert --package binutils-multiarch \
-                       --remove --rename \
-                       --divert /usr/bin/$f.single /usr/bin/$f
-       done
-
-       dpkg-divert --package binutils-multiarch \
-               --remove --rename \
-               --divert /usr/lib/libbfd-single.a /usr/lib/libbfd.a
-       dpkg-divert --package binutils-multiarch \
-               --remove --rename \
-               --divert /usr/lib/libopcodes-single.a /usr/lib/libopcodes.a
-
-fi
-
-if [ -e /usr/lib/libbfd-*-multiarch.so.0 ]; then
-       rm -f /usr/lib/libbfd-*-multiarch.so.0;
-fi
-if [ -e /usr/lib/libopcodes-*-multiarch.so.0 ]; then
-       rm -f /usr/lib/libopcodes-*-multiarch.so.0;
-fi
-
-if [ "$1" = "remove" ]; then
-       ldconfig
-fi
diff --git a/debian/binutils-multiarch.postrm.in 
b/debian/binutils-multiarch.postrm.in
new file mode 100644
index 0000000..5f22b97
--- /dev/null
+++ b/debian/binutils-multiarch.postrm.in
@@ -0,0 +1,50 @@
+#! /bin/sh
+set -e
+this_v...@ver@; # this version
+# action: upgrade, abort-upgrade, remove, abort-install, disappear,
+# purge, or failed-upgrade.
+context=$1
+if
+       test "$context" = failed-upgrade &&
+       dpkg --compare-versions "$this_ver" lt "$2"
+then
+       # postrm of the future failed.
+       # Who knows what it was supposed to do?  Abort.
+       exit 1
+fi
+new_ver=; # version replacing this one, if any.
+case "$context" in
+failed-upgrade)
+       new_ver=$this_ver ;;
+abort-install|disappear)
+       new_ver= ;;
+*)
+       new_ver=$2 ;;
+esac
+
+diversion() {
+       local added_ver divertto file
+       added_ver=$1
+       file=$2
+       divertto=${3-$file.single}
+
+       if
+               test "$context" != purge &&
+               dpkg --compare-versions "$new_ver" lt "$added_ver"
+       then
+               dpkg-divert --package binutils-multiarch \
+                       --remove --rename --divert "$divertto" "$file"
+       fi
+}
+
+
+for prog in nm objdump objcopy strings strip size \
+            ar ranlib addr2line gprof readelf
+do
+       diversion 2.9.5.0.16-1 "/usr/bin/$prog"
+done
+diversion 2.20.51.20100405-1 /usr/bin/elfedit
+
+if [ "$1" = "remove" ]; then
+       ldconfig
+fi
diff --git a/debian/binutils-multiarch.preinst 
b/debian/binutils-multiarch.preinst
deleted file mode 100644
index b9374f2..0000000
--- a/debian/binutils-multiarch.preinst
+++ /dev/null
@@ -1,82 +0,0 @@
-#! /bin/sh
-
-set -e
-
-if [ install = "$1" -o upgrade = "$1" ]; then
-
-       for f in size objdump ar strings ranlib objcopy addr2line \
-                 readelf elfedit nm strip gprof; do
-               dpkg-divert --package binutils-multiarch \
-                       --add --rename \
-                       --divert /usr/bin/$f.single /usr/bin/$f
-       done
-
-       dpkg-divert --package binutils-multiarch \
-               --add --rename \
-               --divert /usr/lib/libbfd-single.a /usr/lib/libbfd.a
-       dpkg-divert --package binutils-multiarch \
-               --add --rename \
-               --divert /usr/lib/libopcodes-single.a /usr/lib/libopcodes.a
-
-       if [ -x /usr/bin/ld.single ]; then
-               rm -f /usr/bin/ld
-               dpkg-divert --package binutils-multiarch \
-                       --remove --rename \
-                       --divert /usr/bin/ld.single /usr/bin/ld \
-                       | grep -v '^No diversion' || true
-       fi
-
-fi
-
-# remove obsolete diversions
-for f in elf32_sparc elf32ppc elf64alpha elf_i386 m68kelf \
-         alpha i386linux m68klinux sparclinux sun4; do
-       for ext in x xbn xn xr xs xu; do
-               dpkg-divert --package binutils-multiarch \
-                       --remove --rename \
-                       --divert /usr/lib/ldscripts/$f.$ext.single \
-                     /usr/lib/ldscripts/$f.$ext \
-               | grep -v '^No diversion' || true
-       done
-done
-dpkg-divert --package binutils-multiarch \
-       --remove --rename \
-       --divert /usr/lib/libbfd-single-2.9.1.0.15.so.0.0.0 \
-                /usr/lib/libbfd-2.9.1.0.15.so.0.0.0 \
-       | grep -v '^No diversion' || true
-dpkg-divert --package binutils-multiarch \
-       --remove --rename \
-       --divert /usr/lib/libopcodes-single-2.9.1.0.15.so.0.0.0 \
-                /usr/lib/libopcodes-2.9.1.0.15.so.0.0.0 \
-       | grep -v '^No diversion' || true
-dpkg-divert --package binutils-multiarch \
-       --remove --rename \
-       --divert /usr/lib/libbfd-single.la \
-                /usr/lib/libbfd.la \
-       | grep -v '^No diversion' || true
-dpkg-divert --package binutils-multiarch \
-       --remove --rename \
-       --divert /usr/lib/libopcodes-single.la \
-                /usr/lib/libopcodes.la \
-       | grep -v '^No diversion' || true
-dpkg-divert --package binutils-multiarch \
-       --remove --rename \
-       --divert /usr/include/bfd.single.h /usr/include/bfd.h \
-       | grep -v '^No diversion' || true
-dpkg-divert --package binutils-multiarch \
-       --remove --rename \
-       --divert /usr/lib/ldscripts.single /usr/lib/ldscripts \
-       | grep -v '^No diversion' || true
-if [ -e /usr/bin/c++filt.single ]; then
-dpkg-divert --package binutils-multiarch \
-       --remove --rename \
-       --divert /usr/bin/c++filt.single /usr/bin/c++filt \
-       | grep -v '^No diversion' || true
-fi
-
-if [ -e /usr/lib/libbfd-*-multiarch.so.0 ]; then
-       rm -f libbfd-*-multiarch.so.0;
-fi
-if [ -e /usr/lib/libopcodes-*-multiarch.so.0 ]; then
-       rm -f libopcodes-*-multiarch.so.0;
-fi
diff --git a/debian/binutils-multiarch.preinst.in 
b/debian/binutils-multiarch.preinst.in
new file mode 100644
index 0000000..c8096ab
--- /dev/null
+++ b/debian/binutils-multiarch.preinst.in
@@ -0,0 +1,28 @@
+#! /bin/sh
+set -e
+new_v...@ver@; # this version
+context=$1; # why to install (install, upgrade, or abort-upgrade)
+old_ver=$2; # version being replaced, if any
+
+diversion() {
+       local added_ver divertto file
+       added_ver=$1
+       file=$2
+       divertto=${3-$file.single}
+
+       if
+               test "$context" = install ||
+               dpkg --compare-versions "$old_ver" lt "$added_ver" ||
+               dpkg --compare-versions "$new_ver" lt "$old_ver"
+       then
+               dpkg-divert --package binutils-multiarch \
+                       --add --rename --divert "$divertto" "$file"
+       fi
+}
+
+diversion 2.20.51.20100405-1 /usr/bin/elfedit
+for prog in nm objdump objcopy strings strip size \
+            ar ranlib addr2line gprof readelf
+do
+       diversion 2.9.5.0.16-1 "/usr/bin/$prog"
+done
diff --git a/debian/binutils-multiarch.prerm.in 
b/debian/binutils-multiarch.prerm.in
new file mode 100644
index 0000000..f627d44
--- /dev/null
+++ b/debian/binutils-multiarch.prerm.in
@@ -0,0 +1,64 @@
+#! /bin/sh
+# Remove obsolete diversions.
+#
+# They are already removed in postinst, but if configuration fails,
+# they will still be around.  Removing the package without
+# configuring would then allow the diversions to leak.
+#
+# So we catch them here.  This cannot wait for postrm because that
+# would break error recovery during upgrades: after the old, working
+# version re-adds the diversion in preinst, the diversion would be removed
+# again in postrm.  More generally, removing a diversion requires
+# a guarantee that the conflicting file is not present any more,
+# and we cannot guarantee that if some other version of
+# binutils-multiarch is installed.
+set -e
+this_v...@ver@; # this version
+context=$1; # action: upgrade, remove, deconfigure, or failed-upgrade.
+if
+       test "$context" = failed-upgrade &&
+       dpkg --compare-versions "$this_ver" lt "$2"
+then
+       # prerm of the future failed.
+       # Who knows what it was supposed to do?  Abort.
+       exit 1
+fi
+
+old_diversion() {
+       local divertto file
+       file=$1
+       divertto=${2-$file.single}
+       if
+               dpkg-divert --package binutils-multiarch --list |
+               grep -q -F "$divertto"
+       then
+               dpkg-divert --package binutils-multiarch \
+                               --remove --rename \
+                               --divert "$divertto" "$file"
+       fi
+}
+
+# remove obsolete diversions
+old_diversion /usr/lib/libbfd.a /usr/lib/libbfd-single.a
+old_diversion /usr/lib/libopcodes.a /usr/lib/libopcodes-single.a
+old_diversion /usr/bin/ld
+for f in elf32_sparc elf32ppc elf64alpha elf_i386 m68kelf \
+         alpha i386linux m68klinux sparclinux sun4
+do
+       for ext in x xbn xn xr xs xu
+       do
+               old_diversion /usr/lib/ldscripts/$f.$ext
+       done
+done
+old_diversion /usr/lib/libbfd-2.9.1.0.15.so.0.0.0 \
+              /usr/lib/libbfd-single-2.9.1.0.15.so.0.0.0
+old_diversion /usr/lib/libopcodes-2.9.1.0.15.so.0.0.0 \
+              /usr/lib/libopcodes-single-2.9.1.0.15.so.0.0.0
+old_diversion /usr/lib/libbfd.la /usr/lib/libbfd-single.la
+old_diversion /usr/lib/libopcodes.la /usr/lib/libopcodes-single.la
+old_diversion /usr/include/bfd.h /usr/include/bfd.single.h
+old_diversion /usr/lib/ldscripts
+old_diversion /usr/bin/c++filt
+
+rm -f /usr/lib/libbfd-*-multiarch.so.0
+rm -f /usr/lib/libopcodes-*-multiarch.so.0
diff --git a/debian/changelog b/debian/changelog
index af44d86..2d72fc7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,16 @@
+binutils (2.20.51.20100415-1.1) experimental; urgency=low
+
+  * fixup to version changes handling.
+  * Clean up diversion handling in binutils-multiarch:
+    - remove diversion of libbfd.a and libopcodes.a.  Closes: #545067.
+    - wait for the new version to be unpacked before removing old diversions
+    - avoid messages from re-adding diversions when upgrading from a version
+      that already has them
+    - remove diversions when downgrading to a version that does not have
+      them (for example, when recovering from an upgrade failure)
+
+ -- Jonathan Nieder <jrnie...@gmail.com>  Sun, 18 Apr 2010 05:50:17 -0500
+
 binutils (2.20.51.20100415-1) experimental; urgency=low
 
   * Snapshot, taken from the trunk 20100415.
diff --git a/debian/rules b/debian/rules
index 93fa8a6..ba914cd 100755
--- a/debian/rules
+++ b/debian/rules
@@ -775,9 +775,10 @@ endif
 
 ifeq ($(with_multiarch),yes)
        $(install_dir) $(d_mul)/DEBIAN
+       $(install_script) debian/binutils-multiarch.preinst 
$(d_mul)/DEBIAN/preinst
        $(install_script) debian/binutils-multiarch.postinst 
$(d_mul)/DEBIAN/postinst
+       $(install_script) debian/binutils-multiarch.prerm $(d_mul)/DEBIAN/prerm
        $(install_script) debian/binutils-multiarch.postrm 
$(d_mul)/DEBIAN/postrm
-       $(install_script) debian/binutils-multiarch.preinst 
$(d_mul)/DEBIAN/preinst
        $(install_file) debian/binutils-multiarch.shlibs $(d_mul)/DEBIAN/shlibs
 endif
 
-- 
1.7.1.rc1

>From dbd5a4926c566a779294c000040d2b5a10e2c5d4 Mon Sep 17 00:00:00 2001
From: Jonathan Nieder <jrnie...@gmail.com>
Date: Tue, 6 Apr 2010 03:38:34 -0500
Subject: [PATCH 2/5] Remove ld.bfd from binutils-multiarch

Remove /usr/bin/ld.bfd from the binutils-multiarch package.
As far as I can tell, the linker was excluded from binutils-multiarch
because it had regressions relative to the single-target linker
(Bug#61719, #51625).  ld.bfd was introduced to differentiate between
the gnu linker and the new gold linker, which requires that we
exclude the new name, too.

After this change, binutils-multiarch is installable again.

An alternative solution would be to divert the ld.bfd binary and
install a new one.  That is even probably the right solution.  For
now, remove the binary in case the bug of 10 years ago that prompted
its removal in release 2.9.5.0.31-2 is still around.  Adding a
multi-target linker can wait wait until another patch.

Signed-off-by: Jonathan Nieder <jrnie...@gmail.com>
---
 debian/changelog |    6 +++++-
 debian/rules     |    2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 2d72fc7..f669fe5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,8 +8,12 @@ binutils (2.20.51.20100415-1.1) experimental; urgency=low
       that already has them
     - remove diversions when downgrading to a version that does not have
       them (for example, when recovering from an upgrade failure)
+  * Remove linker (ld.bfd) from binutils-multiarch to avoid file
+    conflict with binutils.
+    binutils-multiarch has not included a linker since it was removed
+    under the name ld in version 2.9.5.0.31-2.
 
- -- Jonathan Nieder <jrnie...@gmail.com>  Sun, 18 Apr 2010 05:50:17 -0500
+ -- Jonathan Nieder <jrnie...@gmail.com>  Sun, 18 Apr 2010 05:51:40 -0500
 
 binutils (2.20.51.20100415-1) experimental; urgency=low
 
diff --git a/debian/rules b/debian/rules
index ba914cd..ed3bf36 100755
--- a/debian/rules
+++ b/debian/rules
@@ -499,7 +499,7 @@ ifeq ($(with_multiarch),yes)
        : # Get rid of ld for the time being since it's suddenly unhappy when
        : # linking kernels.  Also get rid of the ldscripts for good measure.
        rm -f $(d_mul)/usr/bin/as $(d_mul)/usr/bin/gasp 
$(d_mul)/usr/bin/c++filt \
-              $(d_mul)/usr/bin/ld
+              $(d_mul)/usr/bin/ld.bfd $(d_mul)/usr/bin/ld
        rm -rf $(d_mul)/usr/lib/ldscripts
   ifneq (,$(filter $(DEB_HOST_ARCH),powerpc ppc64))
        rm -f $(d_mul)/usr/bin/embedspu
-- 
1.7.1.rc1

>From 6f568f93025343cd375731a1bf6edc08da9c7b2d Mon Sep 17 00:00:00 2001
From: Jonathan Nieder <jrnie...@gmail.com>
Date: Sun, 18 Apr 2010 05:59:01 -0500
Subject: [PATCH 3/5] Add ld.bfd and c++filt back to binutils-multiarch

About 10 years ago, the linker was removed from binutils-multiarch
because it was preventing compiling kernels correctly on i386 and ppc
(Bug#61719, Bug#51625).

On i386 at least, it works fine now.  If gold is not installed but
binutils-multiarch is, arrange for the /usr/bin/ld symlink in binutils
to point to a multi-target linker by diverting ld.bfd to
ld.bfd.single.

c++filt was removed from multiarch to avoid a conflict with egcs of
days gone by.  Add it back, too.

Signed-off-by: Jonathan Nieder <jrnie...@gmail.com>
---
 debian/binutils-multiarch.postinst   |    1 -
 debian/binutils-multiarch.postrm.in  |    4 ++++
 debian/binutils-multiarch.preinst.in |    4 ++++
 debian/binutils-multiarch.prerm.in   |    1 -
 debian/changelog                     |   10 +++++-----
 debian/rules                         |   17 ++++++++++++-----
 6 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/debian/binutils-multiarch.postinst 
b/debian/binutils-multiarch.postinst
index 37c42fd..9e2a190 100644
--- a/debian/binutils-multiarch.postinst
+++ b/debian/binutils-multiarch.postinst
@@ -40,7 +40,6 @@ old_diversion /usr/lib/libbfd.la /usr/lib/libbfd-single.la
 old_diversion /usr/lib/libopcodes.la /usr/lib/libopcodes-single.la
 old_diversion /usr/include/bfd.h /usr/include/bfd.single.h
 old_diversion /usr/lib/ldscripts
-old_diversion /usr/bin/c++filt
 
 rm -f /usr/lib/libbfd-*-multiarch.so.0
 rm -f /usr/lib/libopcodes-*-multiarch.so.0
diff --git a/debian/binutils-multiarch.postrm.in 
b/debian/binutils-multiarch.postrm.in
index 5f22b97..750e4f7 100644
--- a/debian/binutils-multiarch.postrm.in
+++ b/debian/binutils-multiarch.postrm.in
@@ -44,6 +44,10 @@ do
        diversion 2.9.5.0.16-1 "/usr/bin/$prog"
 done
 diversion 2.20.51.20100405-1 /usr/bin/elfedit
+for prog in ld.bfd c++filt
+do
+       diversion 2.20.51.20100415-1.1 "/usr/bin/$prog"
+done
 
 if [ "$1" = "remove" ]; then
        ldconfig
diff --git a/debian/binutils-multiarch.preinst.in 
b/debian/binutils-multiarch.preinst.in
index c8096ab..df54332 100644
--- a/debian/binutils-multiarch.preinst.in
+++ b/debian/binutils-multiarch.preinst.in
@@ -20,6 +20,10 @@ diversion() {
        fi
 }
 
+for prog in ld.bfd c++filt
+do
+       diversion 2.20.51.20100415-1.1 "/usr/bin/$prog"
+done
 diversion 2.20.51.20100405-1 /usr/bin/elfedit
 for prog in nm objdump objcopy strings strip size \
             ar ranlib addr2line gprof readelf
diff --git a/debian/binutils-multiarch.prerm.in 
b/debian/binutils-multiarch.prerm.in
index f627d44..539dcbc 100644
--- a/debian/binutils-multiarch.prerm.in
+++ b/debian/binutils-multiarch.prerm.in
@@ -58,7 +58,6 @@ old_diversion /usr/lib/libbfd.la /usr/lib/libbfd-single.la
 old_diversion /usr/lib/libopcodes.la /usr/lib/libopcodes-single.la
 old_diversion /usr/include/bfd.h /usr/include/bfd.single.h
 old_diversion /usr/lib/ldscripts
-old_diversion /usr/bin/c++filt
 
 rm -f /usr/lib/libbfd-*-multiarch.so.0
 rm -f /usr/lib/libopcodes-*-multiarch.so.0
diff --git a/debian/changelog b/debian/changelog
index f669fe5..0465b23 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,12 +8,12 @@ binutils (2.20.51.20100415-1.1) experimental; urgency=low
       that already has them
     - remove diversions when downgrading to a version that does not have
       them (for example, when recovering from an upgrade failure)
-  * Remove linker (ld.bfd) from binutils-multiarch to avoid file
-    conflict with binutils.
-    binutils-multiarch has not included a linker since it was removed
-    under the name ld in version 2.9.5.0.31-2.
+  * Add diversion for ld.bfd in binutils-multiarch.
+  * Update comment in debian/rules to acknowledge that binutils-multiarch
+    includes a linker now.
+  * Add c++filt to binutils-multiarch.
 
- -- Jonathan Nieder <jrnie...@gmail.com>  Sun, 18 Apr 2010 05:51:40 -0500
+ -- Jonathan Nieder <jrnie...@gmail.com>  Sun, 18 Apr 2010 05:54:37 -0500
 
 binutils (2.20.51.20100415-1) experimental; urgency=low
 
diff --git a/debian/rules b/debian/rules
index ed3bf36..3ae9daf 100755
--- a/debian/rules
+++ b/debian/rules
@@ -496,11 +496,18 @@ ifeq ($(with_multiarch),yes)
        rm -rf $(d_mul)/usr/man $(d_mul)/usr/info $(d_mul)/usr/include
        rm -rf $(d_mul)/usr/share/man $(d_mul)/usr/share/info 
$(d_mul)/usr/share/locale
 
-       : # Get rid of ld for the time being since it's suddenly unhappy when
-       : # linking kernels.  Also get rid of the ldscripts for good measure.
-       rm -f $(d_mul)/usr/bin/as $(d_mul)/usr/bin/gasp 
$(d_mul)/usr/bin/c++filt \
-              $(d_mul)/usr/bin/ld.bfd $(d_mul)/usr/bin/ld
-       rm -rf $(d_mul)/usr/lib/ldscripts
+       : # As gas/README points out (search for --enable-targets),
+       : # multi-arch gas is not ready yet.
+       rm -f $(d_mul)/usr/bin/as
+
+       : # binutils will provide ldscripts for the native architecture.
+       set -e; for i in $(d_bin)/usr/lib/ldscripts/*; do \
+               rm -f $(d_mul)/usr/lib/ldscripts/`basename $$i`; \
+       done
+
+       : # binutils provides the ld symlink.
+       rm -f $(d_mul)/usr/bin/ld
+
   ifneq (,$(filter $(DEB_HOST_ARCH),powerpc ppc64))
        rm -f $(d_mul)/usr/bin/embedspu
   endif
-- 
1.7.1.rc1

>From 1cce04372020038a29cffcf8257f785f248a5803 Mon Sep 17 00:00:00 2001
From: Jonathan Nieder <jrnie...@gmail.com>
Date: Sun, 11 Apr 2010 17:18:42 -0500
Subject: [PATCH 4/5] Remove elfedit from binutils-multiarch

elfedit does not include any target-specific functionality.  In
particular, the list of machine types supported is the same for all
targets.

Signed-off-by: Jonathan Nieder <jrnie...@gmail.com>
---
 debian/binutils-multiarch.postinst   |    1 +
 debian/binutils-multiarch.postrm.in  |    1 -
 debian/binutils-multiarch.preinst.in |    1 -
 debian/binutils-multiarch.prerm.in   |    1 +
 debian/changelog                     |    4 +++-
 debian/rules                         |    4 ++++
 6 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/debian/binutils-multiarch.postinst 
b/debian/binutils-multiarch.postinst
index 9e2a190..204ccd2 100644
--- a/debian/binutils-multiarch.postinst
+++ b/debian/binutils-multiarch.postinst
@@ -24,6 +24,7 @@ old_diversion() {
 old_diversion /usr/lib/libbfd.a /usr/lib/libbfd-single.a
 old_diversion /usr/lib/libopcodes.a /usr/lib/libopcodes-single.a
 old_diversion /usr/bin/ld
+old_diversion /usr/bin/elfedit
 for f in elf32_sparc elf32ppc elf64alpha elf_i386 m68kelf \
          alpha i386linux m68klinux sparclinux sun4
 do
diff --git a/debian/binutils-multiarch.postrm.in 
b/debian/binutils-multiarch.postrm.in
index 750e4f7..a8b95cd 100644
--- a/debian/binutils-multiarch.postrm.in
+++ b/debian/binutils-multiarch.postrm.in
@@ -43,7 +43,6 @@ for prog in nm objdump objcopy strings strip size \
 do
        diversion 2.9.5.0.16-1 "/usr/bin/$prog"
 done
-diversion 2.20.51.20100405-1 /usr/bin/elfedit
 for prog in ld.bfd c++filt
 do
        diversion 2.20.51.20100415-1.1 "/usr/bin/$prog"
diff --git a/debian/binutils-multiarch.preinst.in 
b/debian/binutils-multiarch.preinst.in
index df54332..578f8f2 100644
--- a/debian/binutils-multiarch.preinst.in
+++ b/debian/binutils-multiarch.preinst.in
@@ -24,7 +24,6 @@ for prog in ld.bfd c++filt
 do
        diversion 2.20.51.20100415-1.1 "/usr/bin/$prog"
 done
-diversion 2.20.51.20100405-1 /usr/bin/elfedit
 for prog in nm objdump objcopy strings strip size \
             ar ranlib addr2line gprof readelf
 do
diff --git a/debian/binutils-multiarch.prerm.in 
b/debian/binutils-multiarch.prerm.in
index 539dcbc..2623219 100644
--- a/debian/binutils-multiarch.prerm.in
+++ b/debian/binutils-multiarch.prerm.in
@@ -42,6 +42,7 @@ old_diversion() {
 old_diversion /usr/lib/libbfd.a /usr/lib/libbfd-single.a
 old_diversion /usr/lib/libopcodes.a /usr/lib/libopcodes-single.a
 old_diversion /usr/bin/ld
+old_diversion /usr/bin/elfedit
 for f in elf32_sparc elf32ppc elf64alpha elf_i386 m68kelf \
          alpha i386linux m68klinux sparclinux sun4
 do
diff --git a/debian/changelog b/debian/changelog
index 0465b23..db1cd3e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,8 +12,10 @@ binutils (2.20.51.20100415-1.1) experimental; urgency=low
   * Update comment in debian/rules to acknowledge that binutils-multiarch
     includes a linker now.
   * Add c++filt to binutils-multiarch.
+  * Remove elfedit from binutils-multiarch.
+    Its functionality does not depend on the list of supported targets.
 
- -- Jonathan Nieder <jrnie...@gmail.com>  Sun, 18 Apr 2010 05:54:37 -0500
+ -- Jonathan Nieder <jrnie...@gmail.com>  Sun, 18 Apr 2010 05:57:09 -0500
 
 binutils (2.20.51.20100415-1) experimental; urgency=low
 
diff --git a/debian/rules b/debian/rules
index 3ae9daf..45e2998 100755
--- a/debian/rules
+++ b/debian/rules
@@ -496,6 +496,10 @@ ifeq ($(with_multiarch),yes)
        rm -rf $(d_mul)/usr/man $(d_mul)/usr/info $(d_mul)/usr/include
        rm -rf $(d_mul)/usr/share/man $(d_mul)/usr/share/info 
$(d_mul)/usr/share/locale
 
+       : # elfedit (even with its --input-mach option)
+       : # is the same for all targets.
+       rm -f $(d_mul)/usr/bin/elfedit
+
        : # As gas/README points out (search for --enable-targets),
        : # multi-arch gas is not ready yet.
        rm -f $(d_mul)/usr/bin/as
-- 
1.7.1.rc1

>From 0a5ee0e552c7b208d76fda8b52cd97484cef1055 Mon Sep 17 00:00:00 2001
From: Jonathan Nieder <jrnie...@gmail.com>
Date: Sun, 18 Apr 2010 06:27:19 -0500
Subject: [PATCH 5/5] Fix shlibs files to use correct SONAMES

The automatically generated shlibs files should use the upstream
version number where they currently put the Debian version
number.

To fix this, change the list of possible substitutions:

 - @VER@ represents the upstream version
 - @DEB_VER@ represents the Debian binary package version
 - @DEB_SVER@ represents the Debian source package version,
   which should correspond to the ${source:Version} substvar
 - @DATE_EXT@ represents the snapshot date, if any

The maintainer scripts use @DEB_VER@ now instead of @v...@.  What
is most important is that the current version

 1. increases each time a new diversion is added
 2. decreases for downgrades in which maintainer scripts
    might have changed

Both the source package version and binary package version satisfy
these requirements.  Use the binary package version for simplicity.

Signed-off-by: Jonathan Nieder <jrnie...@gmail.com>
---
 debian/binutils-multiarch.postrm.in  |    2 +-
 debian/binutils-multiarch.preinst.in |    2 +-
 debian/binutils-multiarch.prerm.in   |    2 +-
 debian/changelog                     |    2 +-
 debian/rules                         |    6 +++++-
 5 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/debian/binutils-multiarch.postrm.in 
b/debian/binutils-multiarch.postrm.in
index a8b95cd..291dc83 100644
--- a/debian/binutils-multiarch.postrm.in
+++ b/debian/binutils-multiarch.postrm.in
@@ -1,6 +1,6 @@
 #! /bin/sh
 set -e
-this_v...@ver@; # this version
+this_v...@deb_ver@; # this version
 # action: upgrade, abort-upgrade, remove, abort-install, disappear,
 # purge, or failed-upgrade.
 context=$1
diff --git a/debian/binutils-multiarch.preinst.in 
b/debian/binutils-multiarch.preinst.in
index 578f8f2..e350583 100644
--- a/debian/binutils-multiarch.preinst.in
+++ b/debian/binutils-multiarch.preinst.in
@@ -1,6 +1,6 @@
 #! /bin/sh
 set -e
-new_v...@ver@; # this version
+new_v...@deb_ver@; # this version
 context=$1; # why to install (install, upgrade, or abort-upgrade)
 old_ver=$2; # version being replaced, if any
 
diff --git a/debian/binutils-multiarch.prerm.in 
b/debian/binutils-multiarch.prerm.in
index 2623219..903c226 100644
--- a/debian/binutils-multiarch.prerm.in
+++ b/debian/binutils-multiarch.prerm.in
@@ -13,7 +13,7 @@
 # and we cannot guarantee that if some other version of
 # binutils-multiarch is installed.
 set -e
-this_v...@ver@; # this version
+this_v...@deb_ver@; # this version
 context=$1; # action: upgrade, remove, deconfigure, or failed-upgrade.
 if
        test "$context" = failed-upgrade &&
diff --git a/debian/changelog b/debian/changelog
index db1cd3e..f148b53 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -15,7 +15,7 @@ binutils (2.20.51.20100415-1.1) experimental; urgency=low
   * Remove elfedit from binutils-multiarch.
     Its functionality does not depend on the list of supported targets.
 
- -- Jonathan Nieder <jrnie...@gmail.com>  Sun, 18 Apr 2010 05:57:09 -0500
+ -- Jonathan Nieder <jrnie...@gmail.com>  Sun, 18 Apr 2010 06:27:12 -0500
 
 binutils (2.20.51.20100415-1) experimental; urgency=low
 
diff --git a/debian/rules b/debian/rules
index 45e2998..e770a02 100755
--- a/debian/rules
+++ b/debian/rules
@@ -80,6 +80,7 @@ CHANGELOG_VARS := $(shell dpkg-parsechangelog | \
         sed -n 's/ /_/g;/^[^_]/s/^\([^:]*\):_\(.*\)/\1=\2/p')
 
 DEB_VERSION    := $(call vafilt,$(CHANGELOG_VARS),Version)
+DEB_SVERSION   := $(shell echo $(DEB_VERSION) | sed 's/+b[0-9][0-9]*$$//')
 DEB_UPSTREAM   := $(firstword $(subst -,$(SPACE),$(DEB_VERSION)))
 
 VERSION                := $(shell sed -n 's/^ *VERSION=\(.*\)/\1/p' 
bfd/configure | head -1)
@@ -752,7 +753,10 @@ binary-arch: checkroot build install
        : # generate some control & helper files
        for i in debian/*.in; do \
            case "$$i" in debian/control.cross.in) continue; esac; \
-           sed 's/@VER@/$(DEB_VERSION)/g;s/@DATE_EXT@/$(DATE_EXT)/g' \
+           sed -e 's/@VER@/$(VERSION)/g' \
+               -e 's/@DEB_VER@/$(DEB_VERSION)/g' \
+               -e 's/@DEB_SVER@/$(DEB_SVERSION)/g' \
+               -e 's/@DATE_EXT@/$(DATE_EXT)/g' \
                $$i > $${i%*.in}; \
        done
 
-- 
1.7.1.rc1

Reply via email to