Upload Tizen:Base source
[external/binutils.git] / debian / binutils-multiarch.prerm.in
1 #! /bin/sh
2 # Remove obsolete diversions.
3 #
4 # They are already removed in postinst, but if configuration fails,
5 # they will still be around.  Removing the package without
6 # configuring would then allow the diversions to leak.
7 #
8 # So we catch them here.  This cannot wait for postrm because that
9 # would break error recovery during upgrades: after the old, working
10 # version re-adds the diversion in preinst, the diversion would be removed
11 # again in postrm.  More generally, removing a diversion requires
12 # a guarantee that the conflicting file is not present any more,
13 # and we cannot guarantee that if some other version of
14 # binutils-multiarch is installed.
15 set -e
16 this_ver=@DEB_VER@; # this version
17 context=$1; # action: upgrade, remove, deconfigure, or failed-upgrade.
18 if
19         test "$context" = failed-upgrade &&
20         dpkg --compare-versions "$this_ver" lt "$2"
21 then
22         # prerm of the future failed.
23         # Who knows what it was supposed to do?  Abort.
24         exit 1
25 fi
26
27 old_diversion() {
28         local divertto file
29         file=$1
30         divertto=${2-$file.single}
31         if
32                 dpkg-divert --package binutils-multiarch --list |
33                 grep -q -F "$divertto"
34         then
35                 dpkg-divert --package binutils-multiarch \
36                                 --remove --rename \
37                                 --divert "$divertto" "$file"
38         fi
39 }
40
41 # remove obsolete diversions
42 old_diversion /usr/bin/ld.bfd
43 old_diversion /usr/bin/c++filt
44 old_diversion /usr/lib/libbfd.a /usr/lib/libbfd-single.a
45 old_diversion /usr/lib/libopcodes.a /usr/lib/libopcodes-single.a
46 old_diversion /usr/bin/ld
47 old_diversion /usr/bin/elfedit
48 for f in elf32_sparc elf32ppc elf64alpha elf_i386 m68kelf \
49          alpha i386linux m68klinux sparclinux sun4
50 do
51         for ext in x xbn xn xr xs xu
52         do
53                 old_diversion /usr/lib/ldscripts/$f.$ext
54         done
55 done
56 old_diversion /usr/lib/libbfd-2.9.1.0.15.so.0.0.0 \
57               /usr/lib/libbfd-single-2.9.1.0.15.so.0.0.0
58 old_diversion /usr/lib/libopcodes-2.9.1.0.15.so.0.0.0 \
59               /usr/lib/libopcodes-single-2.9.1.0.15.so.0.0.0
60 old_diversion /usr/lib/libbfd.la /usr/lib/libbfd-single.la
61 old_diversion /usr/lib/libopcodes.la /usr/lib/libopcodes-single.la
62 old_diversion /usr/include/bfd.h /usr/include/bfd.single.h
63 old_diversion /usr/lib/ldscripts
64
65 rm -f /usr/lib/libbfd-*-multiarch.so.0
66 rm -f /usr/lib/libopcodes-*-multiarch.so.0