[DRE-commits] [SCM] ruby-dataobjects-postgres.git branch, master, updated. upstream/0.10.7-12-gac315fd

Cédric Boutillier cedric.boutillier at gmail.com
Wed Dec 21 00:14:58 UTC 2011


The following commit has been merged in the master branch:
commit 48cd2b93b4adc975cffe69a6271b1da8bef00a20
Author: Cédric Boutillier <cedric.boutillier at gmail.com>
Date:   Wed Dec 21 00:37:07 2011 +0100

    add nonworking script to start postgres server for test purposes

diff --git a/debian/TODO b/debian/TODO
new file mode 100644
index 0000000..325a2a8
--- /dev/null
+++ b/debian/TODO
@@ -0,0 +1,4 @@
+make start_postgres_and_auto_building work, and uncomment
+override_dh_auto_build: target in debian/rules.
+The main problem is to be able to run the postgres server with postgres user
+using su while the package is being built with fakeroot. Is it even possible?
diff --git a/debian/rules b/debian/rules
index 236eebf..1eead02 100755
--- a/debian/rules
+++ b/debian/rules
@@ -7,6 +7,7 @@
 # Uncomment to ignore some test failures (but the tests will run anyway).
 # Valid values:
 #export DH_RUBY_IGNORE_TESTS=ruby1.8 ruby1.9.1 require-rubygems
+export DH_RUBY_IGNORE_TESTS=ruby1.8 ruby1.9.1 
 #
 # If you need to specify the .gemspec (eg there is more than one)
 #export DH_RUBY_GEMSPEC=gem.gemspec
@@ -17,3 +18,9 @@
 #install upstream changelog
 override_dh_installchangelog:
 	dh_installchangelog ChangeLog.markdown
+
+## start postgres server before auto_building
+## not working yet
+#override_dh_auto_build:
+#	chmod +x debian/start_postgres_and_auto_build.sh
+#	debian/start_postgres_and_auto_build.sh
diff --git a/debian/start_postgres_and_auto_install.sh b/debian/start_postgres_and_auto_install.sh
new file mode 100755
index 0000000..d933f76
--- /dev/null
+++ b/debian/start_postgres_and_auto_install.sh
@@ -0,0 +1,91 @@
+#!/bin/sh
+#
+# start_postgres.sh - starts an instance of postgres before
+# auto_installing and running do_mysql's test suite. It is inspired by
+# debian/test_mysql.sh from libdbi-drivers source package and 
+# t/dbdpg_test_setup.pl from libdbd-pg-perl.
+
+
+
+set -evx
+
+MYTEMP_DIR=`mktemp -d`
+
+SCRIPT_USER=`stat -c %U $0`
+ME=`whoami`
+
+BINDIR=`pg_config --bindir`
+
+
+INFO=`${BINDIR}/initdb -D --locale=C -E UTF-8 ${MYTEMP_DIR} 2>&1 || true`
+#if we are root, we need to find another user to run the server
+if echo $INFO | grep "root"; then
+	FOUNDUSER=0
+
+	USER_LIST="$ME $SCRIPT_USER postgres"
+
+	for x in $USER_LIST; do
+		if [ "$x" = "root" ] ; then
+			continue
+		fi
+		TEST_USER=$x
+		chown -vR $TEST_USER $MYTEMP_DIR || break
+		SU_USER=$x
+		FOUNDUSER=$((FOUNDUSER + 1))
+                ( cd $MYTEMP_DIR ; INFO=`su -m $SU_USER -c "${BINDIR}/initdb --locale=C -E UTF-8 -D ${MYTEMP_DIR} 2>&1"` ) || continue
+                [ $? -eq 0 ] && break
+	done
+	if [ "$SU_USER" = "" ]; then
+		TEST_USER=`echo $INFO | sed -e "s/owned by user (\.+)/$1/"`
+	fi
+fi
+
+# environment variables for ruby-dataobjects-postgres test suite
+export DO_POSTGRES_USER=${SU_USER}
+#export DO_POSTGRES_PASS=
+export DO_POSTGRES_DBNAME=do_test
+export DO_POSTGRES_DATABASE=/do_test
+
+
+# start postgres server
+if [ ! "$SU_USER" = "" ]; then
+	su -m $SU_USER -c "${BINDIR}/pg_ctl -D ${MYTEMP_DIR} -o\"-h '' -k ${MYTEMP_DIR}\" -l /tmp/pgres.log start"
+else
+	${BINDIR}/postgres -D ${MYTEMP_DIR} -k ${MYTEMP_DIR} &
+fi
+attempts=0
+while ! [ -e ${MYTEMP_DIR}/postmaster.pid ] ; do
+	attempts=$((attempts+1))
+	if [ "${attempts}" -gt 10 ] ; then
+		echo "skipping test, postgres pid file was not created after 30 seconds"
+		exit 0
+	fi
+	sleep 3
+	echo `date`: retrying...
+done
+:
+# Set the env. var so that pgsql client doesn't use networking
+
+export PGHOST=${MYTEMP_DIR}
+
+
+#create test database
+if [ "$SU_USER" = "" ]; then
+	createdb -e ${DO_POSTGRES_DBNAME}
+else
+	su -m $SU_USER -c "createdb -e ${DO_POSTGRES_DBNAME}"
+fi
+
+dh_auto_install
+ecode=$?
+#
+## Kill the postgress process and wait of it to shutdown
+if [ "$SU_USER" = "" ]; then
+	dropdb -e ${DO_POSTGRES_DBNAME}$END_SU
+	$BINDIR/pg_ctl stop -D ${MYTEMP_DIR}$END_SU
+else
+	su -m $SU_USER -c "dropdb -e ${DO_POSTGRES_DBNAME}"
+	su -m $SU_USER -c "$BINDIR/pg_ctl stop -D ${MYTEMP_DIR}"
+fi
+rm -rf $MYTEMP_DIR
+exit $ecode

-- 
ruby-dataobjects-postgres.git



More information about the Pkg-ruby-extras-commits mailing list