[SCM] Vim packaging branch, debian, updated. upstream/7.1.285-143-gee70e0f

James Vega jamessan at debian.org
Fri Jun 13 19:08:39 UTC 2008


The following commit has been merged in the debian branch:
commit ee70e0f56924abb12aa1cefd10cec426ffa928ee
Author: James Vega <jamessan at debian.org>
Date:   Fri Jun 13 15:05:26 2008 -0400

    Jump through hoops to get diversions setup/removed.
    
    Because of #476973, dpkg-divert fails when the directory structure for the
    diversion doesn't exist.  Therefore, we have to manually determine whether the
    entire directory structure is present, create it if it isn't, add/remove the
    diversion, and then remove the part of the directory structure we created.
    
    Signed-off-by: James Vega <jamessan at debian.org>

diff --git a/debian/vim-runtime.postrm.in b/debian/vim-runtime.postrm.in
index c1dcea9..a1aaf2b 100644
--- a/debian/vim-runtime.postrm.in
+++ b/debian/vim-runtime.postrm.in
@@ -1,14 +1,35 @@
 #!/bin/sh
 
-case "$1" in
-  remove)
-    rm -f /usr/share/vim/addons/doc/tags
-    dpkg-divert --package vim-runtime --rename --remove \
-      /usr/share/vim/@VIMCUR@/doc/help.txt
-    dpkg-divert --package vim-runtime --rename --remove \
-      /usr/share/vim/@VIMCUR@/doc/tags
-    ;;
-esac
+basedir=/usr/share/vim/@VIMCUR@/doc
+
+rm_diversion() {
+  dpkg-divert --package vim-runtime --rename --remove "$basedir/$1"
+}
+
+handhold_diversion_removal() {
+  # dpkg-divert requires the parent directory of the file-to-be-diverted or
+  # the divert-to-file to exist (#476973), which is unlikely to be the case
+  # during postrm.  Because of this, we now have to find whether part of
+  # that directory structure is missing, create it if so, add the diversion,
+  # and then remove it again.
+  availdir=$basedir
+  deaddir=
+  while [ -n "$availdir" ] && [ ! -d "$availdir" ]; do
+    deaddir="${availdir##*/}/$deaddir"
+    availdir=${availdir%/*}
+  done
+  if [ -n "$deaddir" ]; then
+    mkdir -p "$availdir/$deaddir"
+  fi
+  rm_diversion $basedir/help.txt
+  rm_diversion $basedir/tags
+  if [ -n "$deaddir" ]; then
+    (cd ${availdir:-/} && rm -r ${deaddir%%/*})
+  fi
+}
+
+rm -f /usr/share/vim/addons/doc/tags
+handhold_diversion_removal
 
 #DEBHELPER#
 
diff --git a/debian/vim-runtime.preinst.in b/debian/vim-runtime.preinst.in
index 62df1d7..4a93e42 100644
--- a/debian/vim-runtime.preinst.in
+++ b/debian/vim-runtime.preinst.in
@@ -1,30 +1,36 @@
 #!/bin/sh
 set -e
 
-basedir=/usr/share/vim/@VIMCUR@
+basedir=/usr/share/vim/@VIMCUR@/doc
 
-# If a diversion isn't setup yet, remove the current file which will be
-# diverted to ensure that we don't divert the wrong file.
-check_diversion() {
-  if ! dpkg-divert --list | grep -q "$1" >/dev/null 2>&1; then
-    [ ! -f "$1" ] || rm -f "$1"
-    dpkg-divert --package vim-runtime --add --rename \
-      --divert "$1.tiny" "$1"
+add_diversion() {
+  dpkg-divert --package vim-runtime --add --rename \
+    --divert "$1.vim-tiny" "$1"
+}
+
+handhold_diversion_setup() {
+  # dpkg-divert requires the parent directory of the file-to-be-diverted or
+  # the divert-to-file to exist (#476973), which is unlikely to be the case
+  # during preinst.  Because of this, we now have to find whether part of
+  # that directory structure is missing, create it if so, add the diversion,
+  # and then remove it again.
+  availdir=$basedir
+  deaddir=
+  while [ -n "$availdir" ] && [ ! -d "$availdir" ]; do
+    deaddir="${availdir##*/}/$deaddir"
+    availdir=${availdir%/*}
+  done
+  if [ -n "$deaddir" ]; then
+    mkdir -p "$availdir/$deaddir"
+  fi
+  add_diversion $basedir/help.txt
+  add_diversion $basedir/tags
+  if [ -n "$deaddir" ]; then
+    (cd ${availdir:-/} && rm -r ${deaddir%%/*})
   fi
 }
 
-case "$1" in
-  install)
-    dpkg-divert --package vim-runtime --add --rename \
-      --divert $basedir/doc/help.txt.tiny $basedir/doc/help.txt
-    dpkg-divert --package vim-runtime --add --rename \
-      --divert $basedir/doc/tags.tiny $basedir/doc/tags
-    ;;
-  upgrade)
-    check_diversion $basedir/doc/help.txt
-    check_diversion $basedir/doc/tags
-    ;;
-esac
+handhold_diversion_setup
 
 #DEBHELPER#
 

-- 
Vim packaging



More information about the pkg-vim-maintainers mailing list