summaryrefslogtreecommitdiff
path: root/debian/binutils-multiarch.postrm.in
blob: 7b9438597086f972fb0da8d2042347e4c79c8fe0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#! /bin/sh
set -e
this_ver=@DEB_VER@; # this version
ma=@DEB_MULTIARCH@
triplet=@DEB_TRIPLET@
# 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.27-8 "/usr/bin/$triplet-$prog"
done