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 48 49 50 51 52 53
|
#!/bin/bash -e
pkg=@PKG@
variant=@VARIANT@
remove_directory () {
if [ -d $1 ]; then
rm -rf $1
fi
}
remove_variant_alternative () {
for i in vi view ex editor; do
update-alternatives --remove $i /usr/bin/vim.$variant
done
}
remove_old_diversion () {
if [ -f /usr/bin/vim.org -o \( -e /usr/bin/vim -a \! -L /usr/bin/vim \) ]; then
# We need to remove the actual vim binary in order to remove the diversion.
# This is normally done during postrm when removing the package, but since
# we're upgrading to a package with alternatives we have to manually
# perform the removal.
rm -f /usr/bin/vim
dpkg-divert --package $pkg --remove --rename \
--divert /usr/bin/vim.org /usr/bin/vim
fi
}
# check_and_remove_alternative cleans up stale alternatives that were left
# behind from previous mishandling of alternatives.
check_and_remove_alternative () {
if update-alternatives --list $1 | grep -q bin/vim; then
for f in `update-alternatives --list $1 | grep 'bin/vim$'`; do
update-alternatives --remove $1 $f
done
fi
}
case "$1" in
upgrade)
for i in vi view ex editor; do
check_and_remove_alternative $i
done
remove_directory /usr/share/doc/$pkg
[ -e /usr/share/man/ru.UTF-8/man1/vim.1.gz ] && remove_variant_alternative
remove_old_diversion
;;
esac
#DEBHELPER#
exit 0
|