Package: squidguard
Severity: normal

Hi Joachim,

please Cc: me or use <bugnumber>-submit...@bugs.debian.org, since I
didn't receive your email.

> > removal of libdb4.7-dev has been scheduled on 2011-06-14 (exactly
> > after month after perl transition).
> 
> > If you need help with transition or do you want me to take care of it,
> > please don't hesitate to contact me, I'll be happy to help.
> 
> I have a question about transition: The old databases used by squidguard
> must be migrated to the new libdb

> version 4.8

Don't use db4.8.  libdb4.8 is also obsolete.

> (I think that libdb 5.1 does not run with squidguard 1.4).

There really no reason why it shouldn't work, unless there are some
checks for DB_VERSION_MAJOR == 4 as I stated in the original report.
The db5.1 is really db4.11, but the upstream probably didn't wanted to
use two digits fro DB_VERSION_MINOR.

> How should I initiate this migration in the updated squidguard
> package?

Well, that depends whether the squidguard uses Berkeley DB environment:
http://download.oracle.com/docs/cd/E17076_02/html/upgrading/upgrade_process.html

And quickly scanning the source code it does.

You have two options:

1. if the databases contains only temporary data, you can just remove
them and let the squidguard create them from scratch

2. run the upgrade script in the postinst, it's not that hard.  You
can find the simple version of the upgrade procedure f.e. in the sks
where I wrote it.

You have to add these lines to debian/rules to note compiled-in version:

BDB_VERSION ?= $(shell LC_ALL=C dpkg-query -l 'libdb[45].[0-9]-dev' | grep ^ii 
| sed -e 's|.*\s\libdb\([45]\.[0-9]\)-dev\s.*|\1|')

<the_install_target>:
        echo $(BDB_VERSION) > debian/<package>/usr/lib/<package>/berkeley_db.txt

and then the postinst (you have to adjust paths and users, etc.):

        # Read the active Berkeley DB version, fall back to 4.7 if not found
        if [ -r /var/lib/<package>/berkeley_db.active ]; then
            OLD_BDB=$(cat /usr/lib/<package>/berkeley_db.active)
        else
            if dpkg --compare-versions "$2" lt "1.1.1+dpkgv3-1"; then
                OLD_BDB=4.6
            elif dpkg --compare-versions "$2" lt "1.1.1+dpkgv3-6.1"; then
                OLD_BDB=4.7
            else
                OLD_BDB=4.7
            fi
        fi

        # Read the compiled-in Berkeley DB version
        NEW_BDB=$(cat /usr/lib/<package>/berkeley_db.txt)

        if [ "$OLD_BDB" != "$NEW_BDB" ]; then

        # Upgrade Berkeley DB in place
        BACKUP_DIR=/var/backup/<package>/$(date +%Y%m%d-%H%M%S)
        mkdir -p $BACKUP_DIR
        chown <username>:<username> ${BACKUP_DIR}

        for DBHOME in <database directories>; do

            # Don't run if the database directory doesn't exist
            [ ! -d ${DBHOME} ] && continue

            # Create backup directory
            mkdir -p ${BACKUP_DIR}/${DBHOME}
            chown <username>:<username> ${BACKUP_DIR}/${DBHOME}

            # Make sure we own the files
            chown <username>:<username> -R ${DBHOME}

            if [ -x /usr/bin/db${OLD_BDB}_recover ]; then
                # Run recover with old tools
                su <username> -c "db${OLD_BDB}_recover -h ${DBHOME}"
                # Backup needed log files
                LOG_FILES=$(su <username> -c "db${OLD_BDB}_archive -h ${DBHOME} 
-l")
            else
                # If we don't have the Berkeley DB tools then backup all log 
files
                LOG_FILES=$(cd ${DBHOME}; ls -1 | grep -E "^log\.")
            fi

            # Backup log files
            for log_file in ${LOG_FILES}; do
                cp -a ${DBHOME}/$log_file ${BACKUP_DIR}/${DBHOME}/
            done

            # Backup & upgrade database files
            for db in $(cd ${DBHOME}; ls -1 | grep -Ev "^(__|log\.)"); do
                # Backup database file
                su <username> -c "cp ${DBHOME}/${db} ${BACKUP_DIR}/${DBHOME}/"
                # Upgrade database file
                su <username> -c "db${NEW_BDB}_upgrade -h ${DBHOME} 
${DBHOME}/$db";
            done
    
            # Set checkpoint and delete old logfiles
            su <username> -c "db${NEW_BDB}_checkpoint -h ${DBHOME} -1"
            su <username> -c "db${NEW_BDB}_archive -h ${DBHOME} -d"
        done

        # Note the active Berkeley DB version
        cp -f /usr/lib/<package>/berkeley_db.txt 
/usr/lib/<package>/berkeley_db.active

        fi

Also don't forget to remove the berkeley_db.active file in the postrm purge 
target:

Something like this:

<package>.postrm:
        if [ "$1" = "purge" ]; then
                rm -f /usr/lib/<package>/berkeley_db.active
                rmdir /usr/lib/<package> || true
        fi



-- System Information:
Debian Release: 6.0.1
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-5-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=cs_CZ.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to