From ea5e3009079fb532a72fade3f2369f05a9d840ba Mon Sep 17 00:00:00 2001 From: Adrian Perez Date: Fri, 20 Jul 2012 03:13:56 +0300 Subject: [PATCH] Debian: Enable plpgsql when using PostgreSQL 8.x In case PostgreSQL 8.x is being used, make sure that support for plpgsql is enabled. This is needed starting with version 1.3 of Libreplan. Note that the major version number number is taken from the output of "createlang --version", so this assumes that the version for which the tool is available is actually the one being run. This assumption should be safe in the vast majority of cases. --- debian/libreplan.postinst | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/debian/libreplan.postinst b/debian/libreplan.postinst index 45af8e1d3..518f98556 100644 --- a/debian/libreplan.postinst +++ b/debian/libreplan.postinst @@ -1,6 +1,32 @@ #! /bin/bash set -e +# If the database exists already *before* running dbconfig, it means that +# an upgrade is being done. In case PostgreSQL 8.x is being used, make +# sure that support for plpgsql is enabled. This is needed starting with +# Libreplan 1.3 +# +if [[ $1 = configure && -r /etc/dbconfig-common/libreplan.conf ]] +then + PGSQL_MAJOR=$(createlang --version | + sed -e '1s/^[^0-9]*\([0-9]\+\)\..*$/\1/p' -e d) + if [[ ${PGSQL_MAJOR} -eq 8 ]] + then + . /etc/dbconfig-common/libreplan.conf + + conn_args="" + if [[ ${dbc_dbserver} != localhost ]] ; then + conn_args="${conn_args} --host='${dbc_dbserver}'" + fi + if [[ -n ${dbc_dbport} ]] ; then + conn_args="${conn_args} --port=${dbc_dbport}" + fi + + su postgres -c "createlang -d ${dbc_dbname} ${conn_args} plpgsql" || true + fi +fi + + . /usr/share/debconf/confmodule . /usr/share/dbconfig-common/dpkg/postinst.pgsql