[med-svn] r8380 - trunk/packages/gmod/chado/trunk/debian
olivier sallou
osallou-guest at alioth.debian.org
Wed Nov 2 11:18:02 UTC 2011
Author: osallou-guest
Date: 2011-11-02 11:18:02 +0000 (Wed, 02 Nov 2011)
New Revision: 8380
Modified:
trunk/packages/gmod/chado/trunk/debian/postinst
trunk/packages/gmod/chado/trunk/debian/testdb.pl
Log:
trap specific codes to manage db actions
Modified: trunk/packages/gmod/chado/trunk/debian/postinst
===================================================================
--- trunk/packages/gmod/chado/trunk/debian/postinst 2011-11-02 10:02:09 UTC (rev 8379)
+++ trunk/packages/gmod/chado/trunk/debian/postinst 2011-11-02 11:18:02 UTC (rev 8380)
@@ -1,40 +1,50 @@
#!/bin/bash
-set -e
+set -E
+trap onexit ERR
+function onexit() {
+ EXITCODE=$?
+ if [ $EXITCODE -eq 102 ]; then
+ echo "Database access not correctly configured"
+ echo "Check your configuration and run manually the database update:"
+ echo "cd /usr/share/gmod/chado/"
+ echo "make load_schema for a new install"
+ echo "OR"
+ echo "make update to upgrade the schema from a previous install"
+ exit 0
+ fi
+ if [ $EXITCODE -eq 100 ]; then
+ make load_schema
+ make prepdb
+ make clean &> /dev/null
+ rm -f /usr/share/gmod/chado/pgpass
+ exit 0
+ fi
+ if [ $EXITCODE -eq 101 ]; then
+ make update
+ make clean &> /dev/null
+ rm -f /usr/share/gmod/chado/pgpass
+ exit 0
+ fi
+ exit $EXITCODE
+}
+
+
case "$1" in
configure)
if [ -e /etc/gmod/gmod-chado.conf ]; then
- export GMOD_ROOT=/usr/share/gmod/chado
- . /etc/gmod/gmod-chado.conf
- cd /usr/share/gmod/chado
- export CHADO_DB_NAME=gmod-chado
- perl Makefile.PL update GMOD_ROOT=/usr/share/gmod/chado DBNAME=$CHADO_DB_NAME DBUSER=$DBUSER DBPASS=$DBPASS DBHOST=$DBHOST DBPORT=$DBPORT DBDRIVER=PostgreSQL SIMPLE=Y RECONFIGURE=1 LOCAL_TMP=/tmp/chado
- export PATH=$PATH:/usr/share/gmod/chado/bin
- #echo "*:*:*:$DBUSER:$DBPASS" > /usr/share/gmod/chado/pgpass
- #chmod 0600 /usr/share/gmod/chado/pgpass
- #export PGPASSFILE=/usr/share/gmod/chado/pgpass
- # Need to detect with testdb if access to db is ok or need to be configured
- perl /usr/share/gmod/chado/bin/testdb.pl
- EXITCODE=$?
- if [ $EXITCODE -eq 2 ]; then
- echo "Database access not correctly configured"
- echo "Check your configuration and run manually the database update:"
- echo "cd /usr/share/gmod/chado/"
- echo "make load_schema for a new install"
- echo "OR"
- echo "make update to upgrade the schema from a previous install"
- exit 0
- fi
- if [ $EXITCODE -eq 0 ]; then
- make load_schema
- make prepdb
- fi
- if [ $EXITCODE -eq 1 ]; then
- make update
- fi
- make clean
-
+ export GMOD_ROOT=/usr/share/gmod/chado
+ . /etc/gmod/gmod-chado.conf
+ cd /usr/share/gmod/chado
+ export CHADO_DB_NAME=gmod-chado
+ perl Makefile.PL update GMOD_ROOT=/usr/share/gmod/chado DBNAME=$CHADO_DB_NAME DBUSER=$DBUSER DBPASS=$DBPASS DBHOST=$DBHOST DBPORT=$DBPORT DBDRIVER=PostgreSQL SIMPLE=Y RECONFIGURE=1 LOCAL_TMP=/tmp/chado &> /dev/null
+ export PATH=$PATH:/usr/share/gmod/chado/bin
+ echo "*:*:*:$DBUSER:$DBPASS" > /usr/share/gmod/chado/pgpass
+ chmod 0600 /usr/share/gmod/chado/pgpass
+ export PGPASSFILE=/usr/share/gmod/chado/pgpass
+ # Need to detect with testdb if access to db is ok or need to be configured
+ perl /usr/share/gmod/chado/bin/testdb.pl
else
echo "Application is not yet configured."
echo "To install or upgrade the database:"
Modified: trunk/packages/gmod/chado/trunk/debian/testdb.pl
===================================================================
--- trunk/packages/gmod/chado/trunk/debian/testdb.pl 2011-11-02 10:02:09 UTC (rev 8379)
+++ trunk/packages/gmod/chado/trunk/debian/testdb.pl 2011-11-02 11:18:02 UTC (rev 8380)
@@ -15,22 +15,20 @@
my $db_conf = Bio::GMOD::DB::Config->new($gmod_conf,'gmod-chado');
-my $dbh = $db_conf->dbh or exit 2;
+my $dbh = $db_conf->dbh or exit 102;
my $nbtables = $dbh->prepare("select count(*) as nbtables from pg_tables");
-$nbtables->execute() or exit 2;
+$nbtables->execute() or exit 102;
my $arrayref = $nbtables->fetchrow_arrayref();
$nbtables = $$arrayref[0];
+$dbh->disconnect;
if($nbtables>0) {
print "Database already exists, update it\n";
- exit 0;
+ exit 101;
}
else {
- print "Empty database\n";
- exit 1;
+ print "Empty database, create it\n";
+ exit 100;
}
-$dbh->disconnect;
-
-print STDOUT "nb: ".$nbtables;
More information about the debian-med-commit
mailing list