[med-svn] r8375 - trunk/packages/gmod/chado/trunk/debian
olivier sallou
osallou-guest at alioth.debian.org
Wed Nov 2 08:50:10 UTC 2011
Author: osallou-guest
Date: 2011-11-02 08:50:09 +0000 (Wed, 02 Nov 2011)
New Revision: 8375
Modified:
trunk/packages/gmod/chado/trunk/debian/postinst
trunk/packages/gmod/chado/trunk/debian/rules
trunk/packages/gmod/chado/trunk/debian/testdb.pl
Log:
set db test script to check if new install or update to launch correct target
Modified: trunk/packages/gmod/chado/trunk/debian/postinst
===================================================================
--- trunk/packages/gmod/chado/trunk/debian/postinst 2011-11-01 19:06:35 UTC (rev 8374)
+++ trunk/packages/gmod/chado/trunk/debian/postinst 2011-11-02 08:50:09 UTC (rev 8375)
@@ -5,10 +5,35 @@
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
else
echo "Application is not yet configured."
Modified: trunk/packages/gmod/chado/trunk/debian/rules
===================================================================
--- trunk/packages/gmod/chado/trunk/debian/rules 2011-11-01 19:06:35 UTC (rev 8374)
+++ trunk/packages/gmod/chado/trunk/debian/rules 2011-11-02 08:50:09 UTC (rev 8375)
@@ -35,6 +35,7 @@
mv debian/libchado-perl/usr/lib/perl5/* debian/libchado-perl/usr/share/perl5/
rm -rf debian/libchado-perl/usr/lib/perl5
mv debian/libchado-perl/usr/man debian/libchado-perl/usr/share/
+ cp debian/testdb.pl debian/libchado-perl/usr/share/gmod/chado/bin/
override_dh_auto_test:
echo "Not testing."
Modified: trunk/packages/gmod/chado/trunk/debian/testdb.pl
===================================================================
--- trunk/packages/gmod/chado/trunk/debian/testdb.pl 2011-11-01 19:06:35 UTC (rev 8374)
+++ trunk/packages/gmod/chado/trunk/debian/testdb.pl 2011-11-02 08:50:09 UTC (rev 8375)
@@ -1,16 +1,36 @@
-#!/usr/bin/perl
+#!/usr/bin/perl -w
+use strict;
+use DBI;
+use Bio::GMOD::Config;
use Bio::GMOD::DB::Config;
-use DBI;
+use Getopt::Long;
+use URI::Escape;
-my $conf = Bio::GMOD::Config->new();
-#my $tmpdir = $conf->tmp();
-#my $confdir = $conf->conf();
+my $gmod_conf = $ENV{'GMOD_ROOT'} ?
+ Bio::GMOD::Config->new($ENV{'GMOD_ROOT'}) :
+ Bio::GMOD::Config->new();
-my $dbconf = Bio::GMOD::DB::Config->new($conf, 'gmod-chado');
+my $db_conf = Bio::GMOD::DB::Config->new($gmod_conf,'gmod-chado');
+my $dbh = $db_conf->dbh or exit 2;
-my $dbh = DBI->connect( $dbconf->dsn(), $dbconf->user(), $dbconf->password() )
- or die "couldn't create db connection:$!";
+my $nbtables = $dbh->prepare("select count(*) as nbtables from pg_tables");
+$nbtables->execute() or exit 2;
+my $arrayref = $nbtables->fetchrow_arrayref();
+$nbtables = $$arrayref[0];
+
+if($nbtables>0) {
+ print "Database already exists, update it\n";
+ exit 0;
+}
+else {
+ print "Empty database\n";
+ exit 1;
+}
+
+$dbh->disconnect;
+
+print STDOUT "nb: ".$nbtables;
More information about the debian-med-commit
mailing list