r874 - /branches/packages/vim/etch/debian/vim-variant.preinst

jamessan at users.alioth.debian.org jamessan at users.alioth.debian.org
Wed Jan 31 00:19:57 UTC 2007


Author: jamessan
Date: Wed Jan 31 01:19:56 2007
New Revision: 874

URL: http://svn.debian.org/wsvn/pkg-vim/?sc=1&rev=874
Log:
Remove any alternatives that refer to stale diversions so we don't make the alternatives become manual.
Make sure we still remove the diversion even if /usr/bin/vim.org doesn't exist (/usr/bin/vim should be a symlink).

Modified:
    branches/packages/vim/etch/debian/vim-variant.preinst

Modified: branches/packages/vim/etch/debian/vim-variant.preinst
URL: http://svn.debian.org/wsvn/pkg-vim/branches/packages/vim/etch/debian/vim-variant.preinst?rev=874&op=diff
==============================================================================
--- branches/packages/vim/etch/debian/vim-variant.preinst (original)
+++ branches/packages/vim/etch/debian/vim-variant.preinst Wed Jan 31 01:19:56 2007
@@ -16,7 +16,7 @@
 }
 
 remove_old_diversion () {
-  if [ -f /usr/bin/vim.org ]; then
+  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
@@ -27,11 +27,24 @@
   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)
-    remove_old_diversion
+    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
 




More information about the pkg-vim-maintainers mailing list