[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Using dbconfig-common to upgrade an old database



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Everyone,

I'm packaging my own software OPUS (ITP bug 415241) and I'd made some
successful packages with my old "upstream" version 3.3, which are in use
by one or two universities.

I'm now packaging my new 4.0 for official submission, and I decided to
use dbconfig-common to handle the database. So far that has been a
qualified success. My new package installs find on a new system, and on
an upgrade it does upgrade the database.

However, I can't seem to get it to honour the old configuration in the
upgrade, and I wondered if anyone here could help me.

- -=-

Here is my file /etc/debconf_config.php which is generated in the manual
database handling of version 3.3

<?php
// DO NOT EDIT THIS FILE, it is automatically generated from debconf
// Use dpkg-reconfigure -p low opus to regenerate this file
$conf['webhost'] = 'localhost';
$conf['institution'] = 'University of Somewhere';
$conf['database'] = array();
$conf['database']['hostname'] = 'localhost';
$conf['database']['database'] = 'opus';
$conf['database']['username'] = 'opus';
$conf['database']['password'] = 'abc';
?>

- -=-

Unfortunately, this is a bit far away from the format dbconfig expects,
so I created this file in version 4.0

/usr/share/opus/include/load_old_database.php

<?php

/**
* Read Old OPUS 3.x configuration
*
* This script only loads old OPUS 3.x style configuration files to map the
* database details into what is expected by dbconfig-common. It is only
* used for automated conversion from old databases using Debian GNU/Linux.
*
* @package OPUS
* @author Colin Turner <c.turner@ulster.ac.uk>
* @license http://opensource.org/licenses/gpl-license.php GNU Public
License v2
*/

require_once("/etc/opus/debconf_config.php");

$dbuser   = $conf['database']['username'];
$dbpass   = $conf['database']['password'];
$dbname   = $conf['database']['database'];
$dbserver = $conf['database']['hostname'];
$dbtype   = 'mysql';

?>

- -=-

If I run

dbconfig-load-include -f php /usr/share/opus/include/load_old_database.php

I get this output, which looks perfect...

dbc_dbuser='opus';
dbc_dbpass='abc';
dbc_dbname='opus';
dbc_dbserver='localhost';
dbc_dbtype='mysql';

- -=-

As I understand it, the last piece of the jigsaw is the config file,
which starts like this:

#!/bin/sh -e
# Attempt at debconf for OPUS

# Source debconf library.
. /usr/share/debconf/confmodule

# Deep magic for dbconfig-common
if [ -f /usr/share/dbconfig-common/dpkg/config.mysql ]; then
        . /usr/share/dbconfig-common/dpkg/config.mysql
        dbc_first_version="4.0.0"
        # This PHP script just reads the old config file and maps it to
dbconfig-common
        dbc_load_include="php:/usr/share/opus/include/load-old-database.php"
        dbc_go opus $@
fi

# Now much less to ask about... (the rest deleted)

- -=-

When I run an upgrade, it prompts me to use dbconfig-common, and then
asks for the opus password. There is no evidence one way or the other (I
have exported dbc_debug=1 and checked the log file) whether the include
file is being read. It *does* say

detected upgrade from previous non-dbconfig version.

long after it dumps out its setup variables with the hostname empty.

- -=-

Really oddly, I noticed in my previous attempt to write this email that
I'd messed up the dbc_dbserver by reading the wrong variable, fixed it,
and all seemed to work, but it hasn't worked again since in all my trials.

Any ideas what dumb thing I'm doing?

CT.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFH4kZG0SwfPjLnaZYRAo4UAJ93jBHI/eS8uDW0nbIIejuQk5RyjwCg369g
BJjVuXaIY4R+whB2t3kuyps=
=C7Td
-----END PGP SIGNATURE-----


Reply to: