Package: binutils-multiarch
Version: 2.20.51.20100405-1
Severity: grave
Justification: renders package uninstallable
Tags: patch

I just found time to test the new binutils-multiarch with elfedit
diversion --- sorry for the delay.  Unfortunately, installation still
errors out:

dpkg: error processing 
/var/cache/apt/archives/binutils-multiarch_2.20.51.20100405-1_i386.deb 
(--unpack):
 trying to overwrite '/usr/bin/ld.bfd', which is also in package binutils 
2.20.51.20100405-1

I guess that’s what I get for not testing a patch before sending it.

Here’s a new series to go on top.  It can build a native kernel that
boots on i386 and works on mips objects well enought to produce
firmware for the Ben Nanonote (I haven’t tried booting with that
firmware yet, though).

Patch 1 makes diversion handling sane again (the packaging was
removing obsolete diversions in preinst, which is not late enough to
be safe) and gets rid of the unnecessary diversions for libbfd.a and
libopcode.a.  This was necessary to allow experimenting with other
things.

Unfortunately, patch 1 adds the current version number to some of the
maintainer scripts; keeping that up to date is a maintainance burden I
do not want to impose.  So patch 2 teaches debian/rules to take care
of that.

Patch 3 removes /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).  Except once the linker was renamed to ld.bfd,
the exclusion no longer applied, creating file conflicts --- oops.

Luckily, those 10-year-old regressions don’t seem to apply any more,
on x86 at least (as tested with the aforementioned kernel build).
So patch 4 adds a multi-target linker.  While at it, it adds
multi-target c++filt, too, since there is no reason to exclude it now
that the egcs saga is long over.

Patch 5 excludes elfedit from binutils-multiarch.  There is nothing
target-specific about it, so the copy in binutils-multiarch was just
a waste of space.

The patches are attached since the BTS seems to deal best with that.
I hope you enjoy them.  Sorry for the delay.  Please let me know if
you have any questions.

Thanks,
Jonathan Nieder (5):
  binutils-multiarch: clean up diversion handling
  binutils-multiarch: automatically update version in maintainer
    scripts
  Remove ld.bfd from binutils-multiarch
  Add ld.bfd and c++filt back to binutils-multiarch
  Remove elfedit from binutils-multiarch

 debian/binutils-multiarch.postinst    |    7 ---
 debian/binutils-multiarch.postinst.in |   50 ++++++++++++++++++++
 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                          |   54 ++++++++++++++++-----
 9 files changed, 258 insertions(+), 134 deletions(-)
 delete mode 100644 debian/binutils-multiarch.postinst
 create mode 100644 debian/binutils-multiarch.postinst.in
 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 091ae73e7a8d1366f89058836055be1caeedc048 Mon Sep 17 00:00:00 2001
From: Jonathan Nieder <jrnie...@gmail.com>
Date: Sun, 11 Apr 2010 02:56:53 -0500
Subject: [PATCH 1/5] binutils-multiarch: clean up diversion handling

Make diversion handling much 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 (the result would be that the diversion
stays around and no package provides the relevant file).

As an unfortunate side-effect, now
binutils-multiarch.{preinst,prerm,postrm} need to know the current
binutils-multiarch version.  Probably debian/rules should learn to
automatically adjust it.

Signed-off-by: Jonathan Nieder <jrnie...@gmail.com>
---
 debian/binutils-multiarch.postinst |   45 ++++++++++++++++-
 debian/binutils-multiarch.postrm   |   60 ++++++++++++++--------
 debian/binutils-multiarch.preinst  |   98 ++++++++----------------------------
 debian/binutils-multiarch.prerm    |   64 +++++++++++++++++++++++
 debian/changelog                   |   12 ++++
 debian/rules                       |    3 +-
 6 files changed, 183 insertions(+), 99 deletions(-)
 create mode 100644 debian/binutils-multiarch.prerm

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
index 73c239d..cb93e9a 100644
--- a/debian/binutils-multiarch.postrm
+++ b/debian/binutils-multiarch.postrm
@@ -1,31 +1,49 @@
 #! /bin/sh
-
 set -e
+this_ver=2.20.51.20100405-1.1; # 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
 
-if [ "$1" = "remove" -o "$1" = "abort-install" ]; then
+diversion() {
+       local added_ver divertto file
+       added_ver=$1
+       file=$2
+       divertto=${3-$file.single}
 
-       for f in size objdump ar strings ranlib objcopy addr2line \
-                 readelf elfedit nm strip gprof; do
+       if
+               test "$context" != purge &&
+               dpkg --compare-versions "$new_ver" lt "$added_ver"
+       then
                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
+                       --remove --rename --divert "$divertto" "$file"
+       fi
+}
 
-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
+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
diff --git a/debian/binutils-multiarch.preinst 
b/debian/binutils-multiarch.preinst
index b9374f2..7fdf906 100644
--- a/debian/binutils-multiarch.preinst
+++ b/debian/binutils-multiarch.preinst
@@ -1,82 +1,28 @@
 #! /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
+new_ver=2.20.51.20100405-1.1; # 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 /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
+                       --add --rename --divert "$divertto" "$file"
        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
+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
-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.prerm b/debian/binutils-multiarch.prerm
new file mode 100644
index 0000000..d6003f9
--- /dev/null
+++ b/debian/binutils-multiarch.prerm
@@ -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_ver=2.20.51.20100405-1.1; # 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 f007309..df8c2b5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,15 @@
+binutils (2.20.51.20100405-1.1) experimental; urgency=low
+
+  * 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, 11 Apr 2010 02:13:35 -0500
+
 binutils (2.20.51.20100405-1) experimental; urgency=low
 
   * Snapshot, taken from the trunk 20100405.
diff --git a/debian/rules b/debian/rules
index c42770f..a55d787 100755
--- a/debian/rules
+++ b/debian/rules
@@ -796,9 +796,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.0.4

>From b93ac17cd6c12ee766396a3defc01e3c8620ba38 Mon Sep 17 00:00:00 2001
From: Jonathan Nieder <jrnie...@gmail.com>
Date: Sun, 11 Apr 2010 17:16:48 -0500
Subject: [PATCH 2/5] binutils-multiarch: automatically update version in 
maintainer scripts

Updating the version number in maintainer scripts by hand for
every release would be a big pain.  Add some commands to
debian/rules to take care of it for us.

Signed-off-by: Jonathan Nieder <jrnie...@gmail.com>
---
 debian/binutils-multiarch.postinst    |   50 -------------------------
 debian/binutils-multiarch.postinst.in |   50 +++++++++++++++++++++++++
 debian/binutils-multiarch.postrm      |   50 -------------------------
 debian/binutils-multiarch.postrm.in   |   50 +++++++++++++++++++++++++
 debian/binutils-multiarch.preinst     |   28 --------------
 debian/binutils-multiarch.preinst.in  |   28 ++++++++++++++
 debian/binutils-multiarch.prerm       |   64 ---------------------------------
 debian/binutils-multiarch.prerm.in    |   64 +++++++++++++++++++++++++++++++++
 debian/changelog                      |    3 +-
 debian/rules                          |   30 ++++++++++++----
 10 files changed, 217 insertions(+), 200 deletions(-)
 delete mode 100644 debian/binutils-multiarch.postinst
 create mode 100644 debian/binutils-multiarch.postinst.in
 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
 delete mode 100644 debian/binutils-multiarch.prerm
 create mode 100644 debian/binutils-multiarch.prerm.in

diff --git a/debian/binutils-multiarch.postinst 
b/debian/binutils-multiarch.postinst
deleted file mode 100644
index 37c42fd..0000000
--- a/debian/binutils-multiarch.postinst
+++ /dev/null
@@ -1,50 +0,0 @@
-#! /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
-fi
diff --git a/debian/binutils-multiarch.postinst.in 
b/debian/binutils-multiarch.postinst.in
new file mode 100644
index 0000000..37c42fd
--- /dev/null
+++ b/debian/binutils-multiarch.postinst.in
@@ -0,0 +1,50 @@
+#! /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
+fi
diff --git a/debian/binutils-multiarch.postrm b/debian/binutils-multiarch.postrm
deleted file mode 100644
index cb93e9a..0000000
--- a/debian/binutils-multiarch.postrm
+++ /dev/null
@@ -1,50 +0,0 @@
-#! /bin/sh
-set -e
-this_ver=2.20.51.20100405-1.1; # 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.postrm.in 
b/debian/binutils-multiarch.postrm.in
new file mode 100644
index 0000000..802d7b3
--- /dev/null
+++ b/debian/binutils-multiarch.postrm.in
@@ -0,0 +1,50 @@
+#! /bin/sh
+set -e
+this_ver=#THIS_VERSION#; # 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 7fdf906..0000000
--- a/debian/binutils-multiarch.preinst
+++ /dev/null
@@ -1,28 +0,0 @@
-#! /bin/sh
-set -e
-new_ver=2.20.51.20100405-1.1; # 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.preinst.in 
b/debian/binutils-multiarch.preinst.in
new file mode 100644
index 0000000..e0dee2c
--- /dev/null
+++ b/debian/binutils-multiarch.preinst.in
@@ -0,0 +1,28 @@
+#! /bin/sh
+set -e
+new_ver=#THIS_VERSION#; # 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 b/debian/binutils-multiarch.prerm
deleted file mode 100644
index d6003f9..0000000
--- a/debian/binutils-multiarch.prerm
+++ /dev/null
@@ -1,64 +0,0 @@
-#! /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_ver=2.20.51.20100405-1.1; # 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/binutils-multiarch.prerm.in 
b/debian/binutils-multiarch.prerm.in
new file mode 100644
index 0000000..28c0d47
--- /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_ver=#THIS_VERSION#; # 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 df8c2b5..240084f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,8 +7,9 @@ binutils (2.20.51.20100405-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)
+  * Do not ignore failures in clean target.
 
- -- Jonathan Nieder <jrnie...@gmail.com>  Sun, 11 Apr 2010 02:13:35 -0500
+ -- Jonathan Nieder <jrnie...@gmail.com>  Sun, 11 Apr 2010 02:59:32 -0500
 
 binutils (2.20.51.20100405-1) experimental; urgency=low
 
diff --git a/debian/rules b/debian/rules
index a55d787..b9db19b 100755
--- a/debian/rules
+++ b/debian/rules
@@ -176,13 +176,17 @@ unpatch:
 
 clean: unpatch
        $(checkdir)
-       -rm -fr builddir-multi builddir-single builddir-hppa64 builddir-spu 
builddir-gold
-       -find . -name \*.gmo -o -name \*~ -o -name \*.info ! -name sysroff.info 
| xargs rm -f
-       -rm -f $(pwd)/test-summary*
-       -rm -fr $(d_bin) $(d_dev) $(d_mul) $(d_doc) $(d_hppa64) $(d_src) 
$(d_spu) $(d_gold)
-       -rm -rf debian/patched debian/tmp debian/files* debian/substvars
-       -rm -f debian/*.orig debian/*.rej
-       -rm -f *-stamp
+       rm -fr builddir-multi builddir-single builddir-hppa64 builddir-spu 
builddir-gold
+       find . -name \*.gmo -o -name \*~ -o -name \*.info ! -name sysroff.info 
| xargs rm -f
+       rm -f $(pwd)/test-summary*
+       rm -fr $(d_bin) $(d_dev) $(d_mul) $(d_doc) $(d_hppa64) $(d_src) 
$(d_spu) $(d_gold)
+       rm -rf debian/patched debian/tmp debian/files* debian/substvars
+       set -e; for i in preinst postinst prerm postrm; \
+       do \
+               rm -f debian/binutils-multiarch.$$i; \
+       done
+       rm -f debian/*.orig debian/*.rej
+       rm -f *-stamp
 
 
################################################################################
 
@@ -786,6 +790,18 @@ ifneq (,$(filter $(DEB_HOST_ARCH),powerpc ppc64))
                $(d_spu)/usr/share/lintian/overrides/$(p_spu)
 endif
 
+ifeq ($(with_multiarch),yes)
+       : # add version numbers to maintainer scripts
+       set -e; \
+       ver=$$(dpkg-parsechangelog | awk '/^Version: / {print $$2; exit}'); \
+       for i in preinst postinst prerm postrm; \
+       do \
+               sed -e "s/#THIS_VERSION#/$$ver/" \
+                       <debian/binutils-multiarch.$$i.in \
+                       >debian/binutils-multiarch.$$i; \
+       done
+endif
+
        : # install maintainer scrtips
        $(install_dir) $(d_bin)/DEBIAN
        $(install_script) debian/binutils.postinst $(d_bin)/DEBIAN/postinst
-- 
1.7.0.4

>From 207af360f5c9f75a587d69d66f012f2ef50fb357 Mon Sep 17 00:00:00 2001
From: Jonathan Nieder <jrnie...@gmail.com>
Date: Tue, 6 Apr 2010 03:38:34 -0500
Subject: [PATCH 3/5] Remove ld.bfd from binutils-multiarch
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This is the only remaining file conflict with binutils.  I am
removing it from binutils-multiarch instead of diverting it from
binutils to respect the intent from the 10-year old release
2.9.5.0.31-2.

No doubt matters have changed since then, but to be safe, let’s
save re-adding the linker for a separate patch.

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

diff --git a/debian/changelog b/debian/changelog
index 240084f..5def17d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,8 +8,10 @@ binutils (2.20.51.20100405-1.1) experimental; urgency=low
     - remove diversions when downgrading to a version that does not have
       them (for example, when recovering from an upgrade failure)
   * Do not ignore failures in clean target.
+  * Remove ld.bfd from binutils-multiarch; it seems to have been added
+    back without notice since 2.9.5.0.31-2.
 
- -- Jonathan Nieder <jrnie...@gmail.com>  Sun, 11 Apr 2010 02:59:32 -0500
+ -- Jonathan Nieder <jrnie...@gmail.com>  Sun, 11 Apr 2010 03:03:28 -0500
 
 binutils (2.20.51.20100405-1) experimental; urgency=low
 
diff --git a/debian/rules b/debian/rules
index b9db19b..1e4aae2 100755
--- a/debian/rules
+++ b/debian/rules
@@ -513,7 +513,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.0.4

>From f2f1d1b5f1851061d7aae46f9f2d87c59b9648a7 Mon Sep 17 00:00:00 2001
From: Jonathan Nieder <jrnie...@gmail.com>
Date: Wed, 7 Apr 2010 00:33:14 -0500
Subject: [PATCH 4/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).

Now on i386 at least, it is working fine.  So add it back.

c++filt was removed from multiarch to avoid a conflict with egcs of
days gone by.

This requires some diversions to avoid file conflicts with the
versions in binutils.  If gold is not installed but binutils-multiarch
is, the /usr/bin/ld symlink in binutils will point to the multiarch
linker now.

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

diff --git a/debian/binutils-multiarch.postinst.in 
b/debian/binutils-multiarch.postinst.in
index 37c42fd..9e2a190 100644
--- a/debian/binutils-multiarch.postinst.in
+++ b/debian/binutils-multiarch.postinst.in
@@ -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 802d7b3..2728193 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.20100405-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 e0dee2c..83fea38 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.20100405-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 28c0d47..7c875b4 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 5def17d..88af07a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,10 +8,12 @@ binutils (2.20.51.20100405-1.1) experimental; urgency=low
     - remove diversions when downgrading to a version that does not have
       them (for example, when recovering from an upgrade failure)
   * Do not ignore failures in clean target.
-  * Remove ld.bfd from binutils-multiarch; it seems to have been added
-    back without notice since 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, 11 Apr 2010 03:03:28 -0500
+ -- Jonathan Nieder <jrnie...@gmail.com>  Sun, 11 Apr 2010 03:06:31 -0500
 
 binutils (2.20.51.20100405-1) experimental; urgency=low
 
diff --git a/debian/rules b/debian/rules
index 1e4aae2..c751cee 100755
--- a/debian/rules
+++ b/debian/rules
@@ -510,11 +510,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.0.4

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

elfedit does not include any target-specific functionality (the
list of machine types supported is the same for all targets), so
the extra copy in binutils-multiarch is a waste of space.

Even though the previous release did not successfully install,
the elfedit diversion needs to be removed in preinst.  Attempting
to upgrade from the previous release would fail, and then
downgrading would call postrm with abort-upgrade, which did not
remove the new diversion as it should have.

Signed-off-by: Jonathan Nieder <jrnie...@gmail.com>
---
 debian/binutils-multiarch.postinst.in |    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.in 
b/debian/binutils-multiarch.postinst.in
index 9e2a190..204ccd2 100644
--- a/debian/binutils-multiarch.postinst.in
+++ b/debian/binutils-multiarch.postinst.in
@@ -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 2728193..c0111fa 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.20100405-1.1 "/usr/bin/$prog"
diff --git a/debian/binutils-multiarch.preinst.in 
b/debian/binutils-multiarch.preinst.in
index 83fea38..54e0203 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.20100405-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 7c875b4..7bf6159 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 88af07a..775776c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,8 +12,10 @@ binutils (2.20.51.20100405-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, 11 Apr 2010 03:06:31 -0500
+ -- Jonathan Nieder <jrnie...@gmail.com>  Sun, 11 Apr 2010 03:07:04 -0500
 
 binutils (2.20.51.20100405-1) experimental; urgency=low
 
diff --git a/debian/rules b/debian/rules
index c751cee..5eda4e0 100755
--- a/debian/rules
+++ b/debian/rules
@@ -510,6 +510,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.0.4

Reply via email to