Package: vim-runtime
Version: 1:7.2.049-2
Followup-For: Bug #503757

Hi,

I'm still seeing this problem when upgrading to 7.2.049-2, from
1:7.1.314-3 (I'll call these new and old respectively further on).

I'm not so sure how these diversions really work, though I'll try to
provide some more info.

The exact error I'm seeing is:

        Preparing to replace vim-runtime 1:7.1.314-3 (using 
.../vim-runtime_2%3a7.2.049-2_all.deb) ...
        Leaving `diversion of /usr/share/vim/vim72/doc/help.txt to 
/usr/share/vim/vim72/doc/help.txt.vim-tiny by vim-runtime'
        Leaving `diversion of /usr/share/vim/vim72/doc/tags to 
/usr/share/vim/vim72/doc/tags.vim-tiny by vim-runtime'
        Removing `diversion of /usr/share/vim/vim71/doc/help.txt to 
/usr/share/vim/vim71/doc/help.txt.vim-tiny by vim-runtime'
        dpkg-divert: rename involves overwriting 
`/usr/share/vim/vim71/doc/help.txt' with
          different file `/usr/share/vim/vim71/doc/help.txt.vim-tiny', not 
allowed

It's interesting to note that (probably due to the conflicts: vim-tiny
that was added) vim-tiny was already (and succesfully) upgraded, but
vim-runtime fails after that.

It seems that diversions are in place for both vim71 and vim72:

        matth...@xanthe:~$ sudo dpkg-divert --list *vim*
        diversion of /usr/share/vim/vim71/doc/help.txt to 
/usr/share/vim/vim71/doc/help.txt.vim-tiny by vim-runtime
        diversion of /usr/share/vim/vim71/doc/tags to 
/usr/share/vim/vim71/doc/tags.vim-tiny by vim-runtime
        diversion of /usr/share/vim/vim72/doc/help.txt to 
/usr/share/vim/vim72/doc/help.txt.vim-tiny by vim-runtime
        diversion of /usr/share/vim/vim72/doc/tags to 
/usr/share/vim/vim72/doc/tags.vim-tiny by vim-runtime

I suspect that the vim72 diversions are added by the previous failed
upgrade attempt, from looking at the new preinst script. I also suspect
that the two "Leaving diversion..." messages in the output above are the
attempts to add those diversions again, so it seems these don't pose any
problem.

The new preinst script also tries to remove any old diversions that are
still in place, and this is where things are failing.

Manually executing the remove command confirms that this is indeed the
problem:

        matth...@xanthe:~$ sudo dpkg-divert --package vim-runtime --rename 
--remove "/usr/share/vim/vim71/doc/help.txt"
        Removing `diversion of /usr/share/vim/vim71/doc/help.txt to 
/usr/share/vim/vim71/doc/help.txt.vim-tiny by vim-runtime'
        dpkg-divert: rename involves overwriting 
`/usr/share/vim/vim71/doc/help.txt' with
          different file `/usr/share/vim/vim71/doc/help.txt.vim-tiny', not 
allowed

This does make sense, since the old vim-runtime is still installed (so
/usr/share/vim/vim71/doc/help.txt is present), while there is also still
a /usr/share/vim/vim71/doc/help.txt.vim-tiny.

AFAICS, the latter should have been removed when vim-tiny was upgraded
(I assume that diversions work for removal of files as well as for
installs?). I'm not so sure why that didn't happen, though I'm not so
sure if removing that file is the proper way to handle this.

AFAICU, the diversion should not be removed until after the file is
removed by vim-runtime (ie, in the postinst upgrade and postrm scripts,
I think?). This would also allow vim-runtime to be upgraded when
vim-tiny is still installed, and properly restore
/usr/share/vim/vim71/doc/help.txt to the vim-tiny version.

I did a quick implementation of this scheme (removing the old diversions
in postinst configure, see attachment), which solved my upgrading
problems. This still leaves the vim-tiny versions of help.txt and tags
littering /usr/share/vim/vim71/, but that makes sense, since the cause
of the problem seems to be that the vim-tiny files didn't get removed
properly.

In other words, removing the diversions later makes the vim-runtime
package a lot more robust. Removing any .vim-tiny versions that make
dpkg-divert --remove fail doesn't seem to be the right approach here.

Note that I don't remove the check_diversion function from preinst in
my patch (I don't fully know what it does or why it exists either), but
following the above reasoning I think it might be a bad approach as
well.

I haven't tried reproducing this on a clean environment yet (due to lack
of time), but I'm happy to provide more information if needed.

Gr.

Matthijs

-- System Information:
Debian Release: 5.0
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.27-rc2-wl-35635-gf8895ad (PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

vim-runtime depends on no packages.

Versions of packages vim-runtime recommends:
ii  vim-tiny                     2:7.2.049-2 Vi IMproved - enhanced vi editor -

vim-runtime suggests no packages.

-- no debconf information
diff -ur DEBIAN.orig/postinst DEBIAN/postinst
--- DEBIAN.orig/postinst	2008-11-30 19:28:30.000000000 +0100
+++ DEBIAN/postinst	2008-12-23 14:13:47.000000000 +0100
@@ -1,12 +1,33 @@
 #!/bin/sh
 set -e
 
+basedir=/usr/share/vim/vim72/doc
+
 # Need to run helpztags since we're overwriting /u/s/v/a/d/tags whenever
 # vim-runtime is install/upgraded which breaks the help for other vim addons
 if which helpztags >/dev/null 2>&1; then
   helpztags /usr/share/vim/addons/doc
 fi
 
+rm_diversion() {
+  dpkg-divert --package vim-runtime --rename --remove "$1"
+}
+
 
+# Used to remove the previous diversion when upgrading from one major release
+# to the next
+remove_previous_diversions() {
+  for v in vim71 vim72a vim72b vim72c; do
+    oldpath="$(echo $1 | sed s/vim72/$v/)"
+    if dpkg-divert --list 2>/dev/null | grep -q "$oldpath"; then
+      rm_diversion $oldpath
+    fi
+  done
+}
+
+if [ "$1" = "configure" ]; then
+  remove_previous_diversions $basedir/help.txt
+  remove_previous_diversions $basedir/tags
+fi
 
 exit 0
diff -ur DEBIAN.orig/preinst DEBIAN/preinst
--- DEBIAN.orig/preinst	2008-11-30 19:28:30.000000000 +0100
+++ DEBIAN/preinst	2008-12-23 14:13:50.000000000 +0100
@@ -31,26 +31,11 @@
   fi
 }
 
-rm_diversion() {
-  dpkg-divert --package vim-runtime --rename --remove "$1"
-}
-
 add_diversion() {
   dpkg-divert --package vim-runtime --add --rename \
     --divert "$1.vim-tiny" "$1"
 }
 
-# Used to remove the previous diversion when upgrading from one major release
-# to the next
-remove_previous_diversions() {
-  for v in vim71 vim72a vim72b vim72c; do
-    oldpath="$(echo $1 | sed s/vim72/$v/)"
-    if dpkg-divert --list 2>/dev/null | grep -q "$oldpath"; then
-      rm_diversion $oldpath
-    fi
-  done
-}
-
 # Also run during upgrade to fix the botched handling of diversions in postrm
 # in the 1:71.314-{1,2} uploads.  This would need to be run during an upgrade
 # to a new major upstream version as well to handle removing the diversions in
@@ -61,8 +46,6 @@
   fi
   add_diversion $basedir/help.txt
   add_diversion $basedir/tags
-  remove_previous_diversions $basedir/help.txt
-  remove_previous_diversions $basedir/tags
 fi
 
 

Reply via email to