Hi Charlie,

In the preinst I think you need to save both /etc/gallery2 and 
/usr/share/gallery2 because they are deleted by the old-postrm after the unpack 
phase. I would also check the version. It's useless to manipulate this files if 
the versions are not affected. 
So the preinst would be something like:
---- gallery2.preinst ----
#! /bin/sh

set -e

BACKUPDIR=/tmp/gallery2
ETCDIR=/etc/gallery2
SHAREDIR=/usr/share/gallery2

if [ "$1" = upgrade ]; then
        if dpkg --compare-versions "$2" ge-nl 2.3-1ubuntu2 &&
            dpkg --compare-versions "$2" lt "2.3-1ubuntu3.2"; then 
                mkdir -p ${BACKUPDIR}${ETCDIR}
                mkdir -p ${BACKUPDIR}${SHAREDIR}

                cp -a $ETCDIR/* ${BACKUPDIR}${ETCDIR}
                cp -a $SHAREDIR/* ${BACKUPDIR}${SHAREDIR}
        fi
fi

#DEBHELPER#

exit 0


Regarding the postinst, correct me if I'm wrong, but there is no 'upgrade' 
action for postinst scripts and everything needs to be done in the 'configure'. 
So the restore phase would look like
$ diff -u gallery2-2.3/debian/gallery2.postinst ./gallery2.postinst 
--- gallery2-2.3/debian/gallery2.postinst       2010-08-02 11:03:42.000000000 
+0200
+++ ./gallery2.postinst 2010-08-02 12:39:53.433622450 +0200
@@ -5,8 +5,22 @@
 . /usr/share/debconf/confmodule
 db_version 2.0 || [ $? -lt 30 ]
 
-
 if [ "$1" = "configure" ]; then
+    if dpkg --compare-versions "$2" lt "2.3-1ubuntu3.2" \
+       && dpkg --compare-versions "$2" ge-nl "2.3-1ubuntu2" ; then
+       # Restore directory deleted by old postrm
+       BACKUPDIR=/tmp/gallery2
+       ETCDIR=/etc/gallery2
+       SHAREDIR=/usr/share/gallery2
+
+       if [ -d "${BACKUPDIR}${ETCDIR}" -a ! -d "$ETCDIR" ]; then
+               cp -a ${BACKUPDIR}${ETCDIR}  $ETCDIR
+       fi
+
+       if [ -d "${BACKUPDIR}${SHAREDIR}" -a ! -d "$SHAREDIR" ]; then
+               cp -a ${BACKUPDIR}${SHAREDIR}  $SHAREDIR
+       fi
+    fi
 
     if [ ! -L /usr/share/gallery2/lib/smarty ]; then
         if [ -d /usr/share/gallery2/lib/smarty ]; then

The issue is that we restore files from a previous version of the package to a 
newer one. But that should not hurt because there was no change to theses files 
between the versions 2.3-1ubuntu3.2 and 2.3-1ubuntu2 of gallery2.
This is not heavily tested but preliminary tests shows that the upgrade is not 
failing anymore and that the deleted directories are there after the upgrade. 

What do you think ?

-- 
gallery2 2.3 php 5.3 incompatibility
https://bugs.launchpad.net/bugs/578137
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to