OpenPKG CVS Repository
http://cvs.openpkg.org/
____________________________________________________________________________
Server: cvs.openpkg.org Name: Ralf S. Engelschall
Root: /v/openpkg/cvs Email: [EMAIL PROTECTED]
Module: openpkg-src Date: 02-Apr-2008 10:32:57
Branch: HEAD Handle: 2008040209325500
Added files:
openpkg-src/postgresql82
pg_migrate pg_passwd postgresql82.patch
postgresql82.spec rc.postgresql
Log:
still provide PostgreSQL 8.2 for some more time
Summary:
Revision Changes Path
1.4 +215 -0 openpkg-src/postgresql82/pg_migrate
1.1 +174 -0 openpkg-src/postgresql82/pg_passwd
1.3 +19 -0 openpkg-src/postgresql82/postgresql82.patch
1.16 +771 -0 openpkg-src/postgresql82/postgresql82.spec
1.3 +108 -0 openpkg-src/postgresql82/rc.postgresql
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: openpkg-src/postgresql82/pg_migrate
============================================================================
$ cvs diff -u -r0 -r1.4 pg_migrate
--- /dev/null 2008-04-02 10:32:37 +0200
+++ pg_migrate 2008-04-02 10:32:56 +0200
@@ -0,0 +1,215 @@
+#!/bin/sh
+##
+## pg_migrate -- PostgreSQL Database Migration Utility
+## Copyright (c) 2000-2007 OpenPKG Foundation e.V. <http://openpkg.net/>
+## Copyright (c) 2000-2007 Ralf S. Engelschall <http://engelschall.com/>
+##
+## Permission to use, copy, modify, and distribute this software for
+## any purpose with or without fee is hereby granted, provided that
+## the above copyright notice and this permission notice appear in all
+## copies.
+##
+## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+## SUCH DAMAGE.
+##
+
+# configuration
+l_prefix="@l_prefix@"
+l_rusr="@l_rusr@"
+l_rgrp="@l_rgrp@"
+
+# load superuser information
+l_pgdata=""
+l_pguser=""
+l_pgpass=""
+if [ -r @l_prefix@/var/db/postgresql/pg_superuser.conf ]; then
+ eval `. @l_prefix@/var/db/postgresql/pg_superuser.conf; \
+ echo l_pgdata=\"$superuser_database\"; \
+ echo l_pguser=\"$superuser_username\"; \
+ echo l_pgpass=\"$superuser_password\"`
+fi
+
+# establish sane environment
+LC_CTYPE=C
+export LC_CTYPE
+umask 022
+
+# check command line
+if [ $# -ne 1 -a $# -ne 2 ]; then
+ echo "$0:ERROR: invalid command line" 1>&2
+ echo "$0:USAGE: $0 dump|restore [<password>]" 1>&2
+ exit 1
+fi
+cmd="$1"; shift
+if [ $# -eq 1 ]; then
+ l_pgpass="$1"; shift
+fi
+
+# dispatch into commands
+case $cmd in
+ dump )
+ echo "++ enforcing full-superuser access policy"
+ cp -p $l_prefix/var/postgresql/db/pg_hba.conf \
+ $l_prefix/var/postgresql/db/pg_hba.conf.orig
+ ( echo "local all trust"
+ echo "host all 127.0.0.1 255.255.255.255 trust"
+ ) >$l_prefix/var/postgresql/db/pg_hba.conf
+
+ if [ ".`$l_prefix/bin/openpkg rc postgresql status 2>&1 | grep 'is
running'`" != . ]; then
+ echo "++ reloading already running database engine"
+ $l_prefix/bin/openpkg rc postgresql reload
+ sleep 2
+ epilog=reload
+ else
+ echo "++ temporarily starting database engine"
+ $l_prefix/bin/openpkg rc postgresql start
+ sleep 4
+ epilog=stop
+ fi
+
+ echo "++ rotating dump files
$l_prefix/var/postgresql/db.dump*.sql.bz2"
+ i=9
+ rm -f $l_prefix/var/postgresql/db.dump.$i.sql.bz2 >/dev/null 2>&1 ||
true
+ while [ $i -gt 0 ]; do
+ j=$i
+ i=`expr $i - 1`
+ if [ $i -eq 0 ]; then
+ prev="$l_prefix/var/postgresql/db.dump.sql.bz2"
+ next="$l_prefix/var/postgresql/db.dump.$j.sql.bz2"
+ else
+ prev="$l_prefix/var/postgresql/db.dump.$i.sql.bz2"
+ next="$l_prefix/var/postgresql/db.dump.$j.sql.bz2"
+ fi
+ if [ -f $prev ]; then
+ mv $prev $next
+ fi
+ done
+
+ echo "++ dumping all databases into
$l_prefix/var/postgresql/db.dump.sql.bz2"
+ PGPASSWORD="$l_pgpass" \
+ $l_prefix/bin/pg_dumpall \
+ -U $l_pguser -o |\
+ $l_prefix/lib/openpkg/bzip2 -9 \
+ >$l_prefix/var/postgresql/db.dump.sql.bz2
+ chown ${l_rusr}:${l_rgrp} $l_prefix/var/postgresql/db.dump.sql.bz2
+ chmod 700 $l_prefix/var/postgresql/db.dump.sql.bz2
+
+ echo "++ restoring original access policy"
+ cp -p $l_prefix/var/postgresql/db/pg_hba.conf.orig \
+ $l_prefix/var/postgresql/db/pg_hba.conf
+ rm -f $l_prefix/var/postgresql/db/pg_hba.conf.orig
+
+ if [ ".$epilog" = .reload ]; then
+ echo "++ reloading already running database engine (again)"
+ $l_prefix/bin/openpkg rc postgresql reload
+ sleep 2
+ else
+ echo "++ stopping temporarily started database engine"
+ $l_prefix/bin/openpkg rc postgresql stop
+ sleep 4
+ fi
+ ;;
+
+ restore )
+ if [ ".`$l_prefix/bin/openpkg rc postgresql status 2>&1 | grep 'is
running'`" != . ]; then
+ echo "++ stopping already running database engine"
+ $l_prefix/bin/openpkg rc postgresql stop
+ sleep 2
+ epilog=start
+ else
+ epilog=none
+ fi
+
+ echo "++ rotating database directories
$l_prefix/var/postgresql/db.old*/"
+ i=9
+ rm -rf $l_prefix/var/postgresql/db.old.$i >/dev/null 2>&1 || true
+ while [ $i -gt 0 ]; do
+ j=$i
+ i=`expr $i - 1`
+ if [ $i -eq 0 ]; then
+ prev="$l_prefix/var/postgresql/db"
+ next="$l_prefix/var/postgresql/db.old.$j"
+ else
+ prev="$l_prefix/var/postgresql/db.old.$i"
+ next="$l_prefix/var/postgresql/db.old.$j"
+ fi
+ if [ -d $prev ]; then
+ mv $prev $next
+ fi
+ done
+
+ echo "++ creating new database directory
$l_prefix/var/postgresql/db/"
+ mkdir $l_prefix/var/postgresql/db
+ chown ${l_rusr}:${l_rgrp} $l_prefix/var/postgresql/db
+ chmod 700 $l_prefix/var/postgresql/db
+
+ su - ${l_rusr} -c \
+ "LC_CTYPE=C; export LC_CTYPE; umask 022; \
+ echo $l_pgpass >$l_prefix/var/postgresql/run/pw; \
+ $l_prefix/bin/pg_initdb \
+ -U $l_pguser --pwfile=$l_prefix/var/postgresql/run/pw \
+ -D $l_prefix/var/postgresql/db; \
+ rm -f $l_prefix/var/postgresql/run/pw" 2>&1 |\
+ $l_prefix/lib/openpkg/shtool prop \
+ -p "++ creating new database data"
+
+ echo "++ restoring database configurations"
+ for conf in pg_hba.conf pg_ident.conf postgresql.conf; do
+ cp -p $l_prefix/var/postgresql/db.old.1/$conf \
+ $l_prefix/var/postgresql/db/
+ done
+
+ echo "++ enforcing full-superuser access policy"
+ cp -p $l_prefix/var/postgresql/db/pg_hba.conf \
+ $l_prefix/var/postgresql/db/pg_hba.conf.orig
+ ( echo "local all trust"
+ echo "host all 127.0.0.1 255.255.255.255 trust"
+ ) >$l_prefix/var/postgresql/db/pg_hba.conf
+
+ if [ ".$epilog" = .start ]; then
+ echo "++ starting database engine"
+ else
+ echo "++ temporarily starting database engine"
+ fi
+ $l_prefix/bin/openpkg rc postgresql start
+ sleep 4
+
+ echo "++ restoring all databases from
$l_prefix/var/postgresql/db.dump.sql.bz2"
+ $l_prefix/lib/openpkg/bzip2 -c -d \
+ $l_prefix/var/postgresql/db.dump.sql.bz2 |\
+ $l_prefix/bin/psql -U $l_pguser -d $l_pgdata 2>&1 |\
+ tee $l_prefix/var/postgresql/db.log |\
+ $l_prefix/lib/openpkg/shtool prop \
+ -p "++ restoring data (see
$l_prefix/var/postgresql/db.log)"
+
+ echo "++ restoring original access policy"
+ cp -p $l_prefix/var/postgresql/db/pg_hba.conf.orig \
+ $l_prefix/var/postgresql/db/pg_hba.conf
+ rm -f $l_prefix/var/postgresql/db/pg_hba.conf.orig
+
+ if [ ".$epilog" = .start ]; then
+ echo "++ reloading already running database engine"
+ $l_prefix/bin/openpkg rc postgresql reload
+ sleep 2
+ else
+ echo "++ stopping temporarily started database engine"
+ $l_prefix/bin/openpkg rc postgresql stop
+ sleep 4
+ fi
+ ;;
+ * )
+ echo "$0:ERROR: unknown command \"$cmd\"" 1>&2
+ exit 1
+ ;;
+esac
+
@@ .
patch -p0 <<'@@ .'
Index: openpkg-src/postgresql82/pg_passwd
============================================================================
$ cvs diff -u -r0 -r1.1 pg_passwd
--- /dev/null 2008-04-02 10:32:37 +0200
+++ pg_passwd 2008-04-02 10:32:56 +0200
@@ -0,0 +1,174 @@
[EMAIL PROTECTED]@
+##
+## pg_passwd -- PostgreSQL Database Password Changing Utility
+## Copyright (c) 2007 OpenPKG Foundation e.V. <http://openpkg.net/>
+## Copyright (c) 2007 Ralf S. Engelschall <http://engelschall.com/>
+##
+## Permission to use, copy, modify, and distribute this software for
+## any purpose with or without fee is hereby granted, provided that
+## the above copyright notice and this permission notice appear in all
+## copies.
+##
+## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+## SUCH DAMAGE.
+##
+
+# determine system username
+system_username="`(id -un) 2>/dev/null`"
+if [ ".$system_username" = . ]; then
+ str="`(id) 2>/dev/null`"
+ if [ ".`echo $str | grep '^uid[ ]*=[ ]*[0-9]*('`" != . ]; then
+ system_username=`echo $str | sed -e 's/^uid[ ]*=[
]*[0-9]*(//' -e 's/).*$//'`
+ fi
+ if [ ".$system_username" = . ]; then
+ system_username="$LOGNAME"
+ if [ ".$system_username" = . ]; then
+ system_username="$USER"
+ if [ ".$system_username" = . ]; then
+ system_username="`(whoami) 2>/dev/null | awk '{ printf("%s",
$1); }'`"
+ if [ ".$system_username" = . ]; then
+ system_username="`(who am i) 2>/dev/null | awk '{
printf("%s", $1); }'`"
+ fi
+ fi
+ fi
+ fi
+fi
+
+# determine database superuser username, password and database
+superuser_username=""
+superuser_password=""
+superuser_database=""
+superuser_config_file="@l_prefix@/var/postgresql/db/pg_superuser.conf"
+if [ -r $superuser_config_file ]; then
+ # read information
+ eval `. $superuser_config_file; \
+ echo superuser_database=\"$superuser_database\"; \
+ echo superuser_username=\"$superuser_username\"; \
+ echo superuser_password=\"$superuser_password\"`
+else
+ # guess information
+ superuser_username="postgresql"
+ superuser_database="template1"
+fi
+
+# determine requested username, database and hostname
+username="$1"
+database="$2"
+hostname="$3"
+if [ ".$username" = . ]; then
+ if [ ".$system_username" = ".root" -o ".$system_username" = "[EMAIL
PROTECTED]@" ]; then
+ username="$superuser_username"
+ else
+ username="$system_username"
+ fi
+fi
+if [ ".$database" = . ]; then
+ if [ ".$username" = ".$superuser_username" ]; then
+ database="$superuser_database"
+ else
+ database="$username"
+ fi
+fi
+if [ ".$hostname" = . ]; then
+ hostname="localhost"
+fi
+
+# make sure that the PostgreSQL super-user password
+# can be kept in sync with the external storage
+if [ ".$username" = ".$superuser_username" -a \
+ ".$database" = ".$superuser_database" ]; then
+ if [ ".$system_username" != ".root" -a ".$system_username" != "[EMAIL
PROTECTED]@" ]; then
+ echo "$0:ERROR: super-user account password can be changed by
\"root\" and \"@[EMAIL PROTECTED]" only" 2>&1
+ exit 1
+ fi
+ if [ -h $superuser_config_file ]; then
+ echo "$0:ERROR: superuser config \"$superuser_config_file\": invalid
(symbolic link)" 2>&1
+ exit 1
+ fi
+ if [ ! -f $superuser_config_file ]; then
+ echo "$0:WARNING: superuser config \"$superuser_config_file\": not
existing" 2>&1
+ exit 1
+ elif [ ! -w $superuser_password_file ]; then
+ echo "$0:ERROR: superuser config \"$superuser_config_file\":
permission denied (not writeable)" 2>&1
+ exit 1
+ fi
+fi
+
+# request old and new password
+password_old=""
+password_new=""
+password_new_verify=""
+if [ ".$username" = ".$superuser_username" -a \
+ ".$database" = ".$superuser_database" ]; then
+ password_old="$superuser_password"
+fi
+while [ ".$password_old" = . ]; do
+ read -s -p "$username:$database:$hostname OLD password: " password_old
+ echo ""
+done
+while [ ".$password_new" = . ]; do
+ read -s -p "$username:$database:$hostname NEW password: " password_new
+ echo ""
+done
+while [ ".$password_new_verify" = . ]; do
+ read -s -p "$username:$database:$hostname NEW password (retype to
verify): " password_new_verify
+ echo ""
+done
+if [ ".$password_new" != ".$password_new_verify" ]; then
+ echo "$0:ERROR: mismatch on NEW password" 1>&2
+ exit 1
+fi
+
+# change the password
+echo "ALTER ROLE $username WITH PASSWORD '$password_new'" | \
+PGPASSWORD="$password_old" @l_prefix@/bin/psql \
+ -q -U $username -d $database -h $hostname -f- || exit $?
+
+# update superuser configuration
+if [ ".$username" = ".$superuser_username" -a \
+ ".$database" = ".$superuser_database" ]; then
+ ( umask 077
+ sed -e "s;.*\(superuser_password=\"\).*\(\"\).*;\1$password_new\2;" \
+ <$superuser_config_file >$superuser_config_file.new || exit $?
+ cp $superuser_config_file.new $superuser_config_file || exit $?
+ rm -f $superuser_config_file.new || exit $?
+ exit 0
+ ) || {
+ echo "$0:ERROR: \"$superuser_config_file\": failed to update
content" 1>&2
+ rm -f $superuser_config_file.new || true
+ exit $?
+ }
+ ( superuser_database_old="$superuser_database"
+ superuser_username_old="$superuser_username"
+ superuser_password_old="$superuser_password"
+ . $superuser_config_file
+ [ ".$superuser_database" != ".$superuser_database_old" ] && exit 1
+ [ ".$superuser_username" != ".$superuser_username_old" ] && exit 1
+ [ ".$superuser_password" = ".$superuser_password_old" ] && exit 1
+ [ ".$superuser_password" != ".$password_new" ] && exit 1
+ exit 0
+ ) || {
+ echo "$0:ERROR: \"$superuser_config_file\": unexpected updated
content" 1>&2
+ exit $?
+ }
+ ( if [ ".$system_username" = ".root" ]; then
+ chown @l_rusr@:@l_rgrp@ $superuser_config_file || exit $?
+ fi
+ chmod 600 $superuser_config_file || exit $?
+ exit 0
+ ) || {
+ echo "$0:ERROR: \"$superuser_config_file\": failed to fixate
attributes" 1>&2
+ exit $?
+ }
+fi
+
@@ .
patch -p0 <<'@@ .'
Index: openpkg-src/postgresql82/postgresql82.patch
============================================================================
$ cvs diff -u -r0 -r1.3 postgresql82.patch
--- /dev/null 2008-04-02 10:32:37 +0200
+++ postgresql82.patch 2008-04-02 10:32:56 +0200
@@ -0,0 +1,19 @@
+Index: src/template/freebsd
+--- src/template/freebsd.orig 2006-03-11 05:38:41 +0100
++++ src/template/freebsd 2006-11-20 20:54:27 +0100
+@@ -1,5 +1,5 @@
+ # $PostgreSQL: pgsql/src/template/freebsd,v 1.35 2006/03/11 04:38:41
momjian Exp $
+
+ case $host_cpu in
+- alpha*) CFLAGS="-O";; # alpha has problems with -O2
++ alpha*) CFLAGS=`echo "x$CFLAGS" | sed -e 's;^x;;' -e 's;-O2;-O;'`;; #
alpha has problems with -O2
+ esac
+Index: src/template/linux
+--- src/template/linux.orig 2006-03-11 05:38:41 +0100
++++ src/template/linux 2006-11-20 20:54:27 +0100
+@@ -1,4 +1,4 @@
+ # $PostgreSQL: pgsql/src/template/linux,v 1.28 2006/03/11 04:38:41 momjian
Exp $
+
+ # Force _GNU_SOURCE on; plperl is broken with Perl 5.8.0 otherwise
+-CPPFLAGS="-D_GNU_SOURCE"
++CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
@@ .
patch -p0 <<'@@ .'
Index: openpkg-src/postgresql82/postgresql82.spec
============================================================================
$ cvs diff -u -r0 -r1.16 postgresql82.spec
--- /dev/null 2008-04-02 10:32:37 +0200
+++ postgresql82.spec 2008-04-02 10:32:56 +0200
@@ -0,0 +1,771 @@
+##
+## postgresql82.spec -- OpenPKG RPM Package Specification
+## Copyright (c) 2000-2008 OpenPKG Foundation e.V. <http://openpkg.net/>
+##
+## Permission to use, copy, modify, and distribute this software for
+## any purpose with or without fee is hereby granted, provided that
+## the above copyright notice and this permission notice appear in all
+## copies.
+##
+## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+## SUCH DAMAGE.
+##
+
+# package versions
+%define V_postgresql 8.2.7
+%define V_libpqxx 2.6.9
+%define V_perl 5.8.8
+%define V_pgperl 2.0.2
+%define V_psqlodbc 08.02.0500
+%define V_pgjdbc 8.3-603
+%define V_slony1_major 1.2
+%define V_slony1_minor 13
+%define V_pgcluster 1.7.0rc12
+%define V_pgcluster_dir 1708
+%define V_mysqlcompat 1.0b3
+%define V_mysqlcompat_dir 548
+
+# package information
+Name: postgresql82
+Summary: PostgreSQL Database
+URL: http://www.postgresql.org/
+Vendor: PostgreSQL Group
+Packager: OpenPKG Foundation e.V.
+Distribution: OpenPKG Community
+Class: EVAL
+Group: Database
+License: GPL
+Version: %{V_postgresql}
+Release: 20080402
+
+# package options
+%option with_server yes
+%option with_cxx no
+%option with_perl no
+%option with_odbc no
+%option with_jdbc no
+%option with_compat no
+%option with_tcl no
+%option with_slony1 no
+%option with_pgcluster no
+%option with_kerberos no
+%option with_mysqlcompat no
+%option with_int_datetime no
+
+# list of sources
+Source0:
ftp://ftp.postgresql.org/pub/source/v%{V_postgresql}/postgresql-%{V_postgresql}.tar.bz2
+Source1:
http://pqxx.org/download/software/libpqxx/libpqxx-%{V_libpqxx}.tar.gz
+Source2:
ftp://gborg.postgresql.org/pub/pgperl/stable/pgperl-%{V_pgperl}.tar.gz
+Source3:
ftp://ftp.postgresql.org/pub/odbc/versions/src/psqlodbc-%{V_psqlodbc}.tar.gz
+Source4:
http://slony.info/downloads/%{V_slony1_major}/source/slony1-%{V_slony1_major}.%{V_slony1_minor}.tar.bz2
+Source5:
http://pgfoundry.org/frs/download.php/%{V_pgcluster_dir}/pgcluster-%{V_pgcluster}.patch.tar.gz
+Source6:
http://pgfoundry.org/frs/download.php/%{V_mysqlcompat_dir}/mysqlcompat-%{V_mysqlcompat}.tar.gz
+Source7:
http://jdbc.postgresql.org/download/postgresql-jdbc-%{V_pgjdbc}.src.tar.gz
+Source8: rc.postgresql
+Source9: pg_migrate
+Source10: pg_passwd
+Patch0: postgresql82.patch
+
+# build information
+Prefix: %{l_prefix}
+BuildRoot: %{l_buildroot}
+BuildPreReq: OpenPKG, openpkg >= 20060823, make, gcc, flex, bison, gzip
+PreReq: OpenPKG, openpkg >= 20060823
+BuildPreReq: readline, zlib, openssl, getopt
+PreReq: readline, zlib, openssl, getopt
+%if "%{with_perl}" == "yes"
+BuildPreReq: perl >= %{V_perl}, perl-openpkg >= %{V_perl}-20061013
+PreReq: perl >= %{V_perl}
+%endif
+%if "%{with_odbc}" == "yes"
+BuildPreReq: unixodbc
+PreReq: unixodbc
+%endif
+%if "%{with_jdbc}" == "yes"
+BuildPreReq: java, JAVA-JDK, ant
+PreReq: java, JAVA-JDK
+%endif
+%if "%{with_tcl}" == "yes"
+BuildPreReq: tcl, tcl::with_x11 = yes, X11
+PreReq: tcl, tcl::with_x11 = yes, X11
+%endif
+%if "%{with_kerberos}" == "yes"
+BuildPreReq: KERBEROS
+PreReq: KERBEROS
+%endif
+AutoReq: no
+AutoReqProv: no
+Provides: postgresql = %{version}-%{release}
+Conflicts: postgresql
+
+%description
+ PostgreSQL is a sophisticated Object-Relational Database Management
+ System (ORDBMS). It is fully ACID compliant and has full support
+ for foreign keys, joins, views, triggers, and stored procedures (in
+ multiple languages). It includes most SQL92 and SQL99 data types
+ and also supports storage of binary large objects. It is the most
+ advanced Open-Source RDBMS available anywhere.
+
+ As an enterprise class RDBMS, PostgreSQL boasts sophisticated
+ features such as Multi-Version Concurrency Control (MVCC), Point In
+ Time Recovery (PITR), tablespaces, asynchronous replication, nested
+ transactions (savepoints), online/hot backups, a sophisticated
+ query planner/optimizer, and Write Ahead Logging (WAL) for fault
+ tolerance. It supports international character sets, multibyte
+ character encodings, Unicode, and it is locale-aware for sorting,
+ case-sensitivity, and formatting. It is highly scalable both in the
+ sheer quantity of data it can manage and in the number of concurrent
+ users it can accommodate.
+
+%track
+ prog postgresql82 = {
+ version = %{V_postgresql}
+ url = ftp://ftp.postgresql.org/pub/source/
+ regex = v(8\.2(\.\d+)*)
+ url = ftp://ftp.postgresql.org/pub/source/v__NEWVER__/
+ regex = postgresql-(\d+(\.\d+)+)\.tar\.(bz2|gz)
+ }
+ prog postgresql82:libpqxx = {
+ version = %{V_libpqxx}
+ url = http://pqxx.org/development/libpqxx/wiki/DownloadPage
+ regex = libpqxx-(__VER__)\.tar\.gz
+ }
+ prog postgresql82:pgperl = {
+ version = %{V_pgperl}
+ url = ftp://gborg.postgresql.org/pub/pgperl/stable/
+ regex = pgperl-(__VER__)\.tar\.gz
+ }
+ prog postgresql82:psqlodbc = {
+ version = %{V_psqlodbc}
+ url = ftp://ftp.postgresql.org/pub/odbc/versions/src/
+ regex = psqlodbc-(\d{2}\.\d{2}\.\d{4})\.tar\.gz
+ }
+ prog postgresql82:jdbc = {
+ version = %{V_pgjdbc}
+ url = http://jdbc.postgresql.org/download.html
+ regex = postgresql-jdbc-(\d+\.\d+-\d+)\.src\.tar\.gz
+ }
+ prog postgresql82:slony1 = {
+ version = %{V_slony1_major}.%{V_slony1_minor}
+ url = http://slony.info/downloads/%{V_slony1_major}/source/
+ regex = slony1-(\d+\.\d+\.\d+)\.tar\.bz2
+ }
+ prog postgresql82:pgcluster = {
+ version = %{V_pgcluster}.%{V_pgcluster_dir}
+ url = http://pgfoundry.org/frs/?group_id=1000072
+ regex = /(\d+/pgcluster-__VER__)\.patch\.tar\.gz
+ transform = "s/^(\\d+)\/pgcluster-(.+)$/$2.$1/; $_"
+ }
+ prog postgresql82:mysqlcompat = {
+ version = %{V_mysqlcompat}.%{V_mysqlcompat_dir}
+ url = http://pgfoundry.org/frs/?group_id=1000154
+ regex = (\d+/mysqlcompat-__VER__)\.tar\.gz
+ transform = "s/^(\\d+)\/mysqlcompat-(.+)$/$2.$1/; $_"
+ }
+
+%prep
+ %setup -q -n postgresql-%{V_postgresql}
+ %patch -p0
+%if "%{with_cxx}" == "yes"
+ %setup -q -n postgresql-%{V_postgresql} -T -D -a 1
+ case "%{l_platform -t}" in
+ *-sunos* )
+ %{l_shtool} subst \
+ -e 's;strerror_r(0,0,0);strerror((int)0);g' \
+ -e 's;strerror_r((int)0, (char \*)0,
(size_t)0);strerror((int)0);g' \
+ libpqxx-%{V_libpqxx}/configure
+ %{l_shtool} subst \
+ -e 's;strerror_r(err, buf, sizeof(buf));strerror(err);g' \
+ libpqxx-%{V_libpqxx}/src/largeobject.cxx \
+ libpqxx-%{V_libpqxx}/configure
+ %{l_shtool} subst \
+ -e 's;\(strerror(err) ==\) -1;\1 (char *)-1;' \
+ libpqxx-%{V_libpqxx}/src/largeobject.cxx
+ ;;
+ esac
+ %{l_shtool} subst \
+ -e 's;^function \(add_compiler_opts() {\);\1;' \
+ libpqxx-%{V_libpqxx}/configure
+%endif
+%if "%{with_perl}" == "yes"
+ %setup -q -n postgresql-%{V_postgresql} -T -D -a 2
+%endif
+%if "%{with_odbc}" == "yes"
+ %setup -q -n postgresql-%{V_postgresql} -T -D -a 3
+%endif
+%if "%{with_slony1}" == "yes"
+ %setup -q -n postgresql-%{V_postgresql} -T -D -a 4
+%endif
+%if "%{with_pgcluster}" == "yes"
+ %setup -q -n postgresql-%{V_postgresql} -T -D -a 5
+ sed -e '/^diff.*libpq\.rc/,/^diff/d' pgcluster-*-patch |\
+ %{l_patch} -p1
+%endif
+%if "%{with_mysqlcompat}" == "yes"
+ %setup -q -n postgresql-%{V_postgresql} -T -D -a 6
+%endif
+%if "%{with_jdbc}" == "yes"
+ %setup -q -n postgresql-%{V_postgresql} -T -D -a 7
+%endif
+
+ # adjust source tree
+ %{l_shtool} subst \
+ -e
's;\(#define.*DEFAULT_PGSOCKET_DIR[^"]*"\)/tmp\("\);\1%{l_prefix}/var/postgresql/run\2;'
\
+ src/include/pg_config_manual.h
+ %{l_shtool} subst \
+ -e 's;^\(sqlmansect *=\).*$;\1 7;' \
+ src/makefiles/Makefile.solaris
+ %{l_shtool} subst \
+ -e 's;$(INSTALL_SHLIB);#$(INSTALL_SHLIB);g' \
+ src/backend/utils/mb/conversion_procs/proc.mk
+ %{l_shtool} subst \
+ -e 's;# Shared library stuff;enable_shared = yes;g' \
+ src/pl/plpgsql/src/Makefile
+
+%build
+ rm -rf $RPM_BUILD_ROOT
+
+ # configure package
+ echo "ac_cv_func_isinf=no" >config.cache
+ export CC="%{l_cc}"
+ export CFLAGS="%{l_cflags -O}"
+ export CPPFLAGS="%{l_cppflags readline}"
+ export LDFLAGS="%{l_ldflags}"
+ export LIBS=""
+%if "%{with_slony1}" == "yes"
+ CFLAGS="$CFLAGS -pthread"
+%endif
+%if "%{with_tcl}" == "yes"
+ CPPFLAGS="$CPPFLAGS %{l_cppflags tcl}"
+ LDFLAGS="$LDFLAGS -L`%{l_rc} --query x11_libdir`"
+%endif
+%if "%{with_kerberos}" == "yes"
+ CPPFLAGS="$CPPFLAGS `krb5-config --cflags`"
+ LIBS="$LIBS `krb5-config --libs`"
+%endif
+%if "%{with_pgcluster}" == "yes"
+ case "%{l_platform -t}" in
+ *-freebsd* ) LIBS="$LIBS -lcompat" ;;
+ esac
+%endif
+ export TAR="%{l_tar}"
+ export YACC="bison -y"
+ ./configure \
+ --cache-file=./config.cache \
+ --prefix=%{l_prefix} \
+ --sysconfdir=%{l_prefix}/etc/postgresql \
+ --includedir=%{l_prefix}/include/postgresql \
+ --with-openssl \
+ --with-readline \
+ --with-zlib \
+%if "%{with_tcl}" == "yes"
+ --with-tcl \
+ --with-tclconfig="%{l_prefix}/lib" \
+ --with-tkconfig="%{l_prefix}/lib" \
+%endif
+%if "%{with_slony1}" == "yes"
+ --enable-thread-safety \
+%endif
+%if "%{with_kerberos}" == "yes"
+ --with-krb5 \
+ --with-krb-srvnam=postgresql \
+%endif
+%if "%{with_int_datetime}" == "yes"
+ --enable-integer-datetimes \
+%endif
+ --disable-syslog \
+ --disable-shared
+
+ # build package
+ %{l_make} %{l_mflags}
+
+ # build C++ bindings (both old and new one)
+%if "%{with_cxx}" == "yes"
+ ln -s `pwd`/src/interfaces/libpq/*.h src/include/
+ ( cd libpqxx-%{V_libpqxx}
+ %{l_shtool} subst \
+ -e 's;\(cut\)\( .*/configitems\)\( -f [0-9]\);\1\3\2;g' \
+ configure
+ ( echo "#!/bin/sh"
+ echo "case \"\$1\" in"
+ echo " --includedir ) echo \"`pwd`/../src/include\" ;;"
+ echo " --libdir ) echo \"`pwd`/../src/interfaces/libpq\" ;;"
+ echo "esac"
+ ) >pg_config
+ chmod a+x pg_config
+ export PG_CONFIG=`pwd`/pg_config
+ export CC="%{l_cc}"
+ export CXX="%{l_cxx}"
+ export CFLAGS="%{l_cflags -O}"
+ export CXXFLAGS="%{l_cxxflags -O}"
+ export CPPFLAGS="-I`pwd`/../src/include %{l_cppflags}"
+ export LDFLAGS="%{l_ldflags}"
+ export LIBS="-lssl -lcrypto -lcrypt"
+ case "%{l_platform -t}" in
+ *-sunos* ) LIBS="$LIBS -lsocket -lnsl" ;;
+ esac
+ ./configure \
+ --disable-shared
+ %{l_make} %{l_mflags -O}
+ ) || exit $?
+%endif
+
+ # build Perl bindings
+%if "%{with_perl}" == "yes"
+ %{l_prefix}/bin/perl-openpkg prepare
+ ( cd Pg-%{V_pgperl}
+ export POSTGRES_INCLUDE=dummy
+ export POSTGRES_LIB=dummy
+ %{l_shtool} subst \
+ -e 's;-I$POSTGRES_INCLUDE;-I../src/interfaces/libpq
-I../src/include;' \
+ -e 's;-L$POSTGRES_LIB;-L../src/interfaces/libpq;' \
+ -e 's;-lpq;-lpq %{l_ldflags} -lssl -lcrypto -lcrypt;' \
+ Makefile.PL
+ ) || exit $?
+ ( export POSTGRES_INCLUDE=dummy
+ export POSTGRES_LIB=dummy
+ %{l_prefix}/bin/perl-openpkg -d Pg-%{V_pgperl} configure build
+ ) || exit $?
+%endif
+
+ # build ODBC driver
+%if "%{with_odbc}" == "yes"
+ ( cd psqlodbc-%{V_psqlodbc}
+ export CC="%{l_cc}"
+ export CXX="%{l_cxx}"
+ export CFLAGS="%{l_cflags -O}"
+ export CXXFLAGS="%{l_cxxflags -O}"
+ export CPPFLAGS="-I`pwd`/../src/include"
+ CPPFLAGS="$CPPFLAGS -I`pwd`/../src/interfaces
-I`pwd`/../src/interfaces/libpq"
+ CPPFLAGS="$CPPFLAGS %{l_cppflags}"
+ export LDFLAGS="-L`pwd`/../src/interfaces/libpq %{l_ldflags}"
+ ./configure \
+ --prefix=%{l_prefix} \
+ --with-unixodbc=%{l_prefix} \
+ --with-odbcinst=%{l_prefix}/etc/unixodbc
+ %{l_make} %{l_mflags -O}
+ ) || exit $?
+%endif
+
+ # build JDBC driver
+%if "%{with_jdbc}" == "yes"
+ ( cd postgresql-jdbc-%{V_pgjdbc}.src
+ export JAVA_PLATFORM="sun-jdk"
+ eval `%{l_prefix}/bin/java-toolkit -e`
+ %{l_prefix}/bin/ant
+ ) || exit $?
+%endif
+
+ # build Slony-1 replication engine
+%if "%{with_slony1}" == "yes"
+ ( cd slony1-%{V_slony1_major}.%{V_slony1_minor}
+ ln ../src/pl/plpgsql/src/libplpgsql.so \
+ ../src/pl/plpgsql/src/plpgsql.so
+ %{l_shtool} subst \
+ -e 's;-lpq;-lpq @LIBS@;' \
+ Makefile.global.in
+ export CC="%{l_cc}"
+ export CFLAGS="%{l_cflags -O}"
+ export CPPFLAGS="%{l_cppflags}"
+ export LDFLAGS="%{l_ldflags}"
+ export LIBS="-lssl -lcrypto -lcrypt"
+ ./configure \
+ --prefix=%{l_prefix} \
+ --sysconfdir=%{l_prefix}/etc/postgresql \
+ --with-pgconfigdir=../src/bin/pg_config \
+ --with-pgincludedir=../src/include \
+ --with-pgincludeserverdir=../src/interfaces/libpq \
+ --with-pglibdir=../src/interfaces/libpq \
+ --with-pgpkglibdir=../src/pl/plpgsql/src \
+ --with-pgsharedir=../src/backend/utils/misc
+ %{l_make} %{l_mflags -O}
+ ) || exit $?
+%endif
+
+ # rebuild pg_config with hard-coded path to avoid that it provides
+ # dynamically resolved paths which circumvent symlinks, etc.
+ ( cd src/bin/pg_config
+ %{l_shtool} subst \
+ -e 's:find_my_exec(argv.0., mypath):0; strcpy(mypath,
"%{l_prefix}/bin/pg_config"):' \
+ pg_config.c
+ %{l_make} %{l_mflags}
+ ) || exit $?
+
+%install
+ rm -rf $RPM_BUILD_ROOT
+
+ # perform standard installation procedure
+ cp /dev/null register.txt
+ %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
+
+ # strip down installation
+ rm -rf $RPM_BUILD_ROOT%{l_prefix}/doc
+ strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
+ rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgaccess.1
+ rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgtclsh.1
+ rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgtksh.1
+
+ # namespace adjustments to installation
+ for prog in \
+ createdb createlang createuser dropdb droplang clusterdb \
+ dropuser initdb ipcclean vacuumdb reindexdb; do
+%if "%{with_compat}" == "yes"
+ cmd="ln"
+%else
+ cmd="mv"
+%endif
+ $cmd $RPM_BUILD_ROOT%{l_prefix}/bin/$prog \
+ $RPM_BUILD_ROOT%{l_prefix}/bin/pg_$prog
+ $cmd $RPM_BUILD_ROOT%{l_prefix}/man/man1/$prog.1 \
+ $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_$prog.1
+ done
+ ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man7
+ for man in *.7; do
+ mv $man pg_$man
+ done
+ ) || exit $?
+
+ # create additional directories
+ %{l_shtool} mkdir -f -p -m 755 \
+%if "%{with_slony1}" == "yes" || "%{with_pgcluster}" == "yes"
+ $RPM_BUILD_ROOT%{l_prefix}/etc/postgresql \
+%endif
+ $RPM_BUILD_ROOT%{l_prefix}/var/postgresql/db \
+ $RPM_BUILD_ROOT%{l_prefix}/var/postgresql/run
+
+ # install addon utilities
+ %{l_shtool} install -c -m 755 %{l_value -s -a} \
+ %{SOURCE pg_migrate} $RPM_BUILD_ROOT%{l_prefix}/bin/
+ %{l_shtool} install -c -m 755 %{l_value -s -a} \
+ -e "s;@l_bash@;%{l_bash};g" \
+ %{SOURCE pg_passwd} $RPM_BUILD_ROOT%{l_prefix}/bin/
+
+ # install C++ bindings (both old and new one)
+%if "%{with_cxx}" == "yes"
+ ( cd libpqxx-%{V_libpqxx}
+ %{l_shtool} mkdir -f -p -m 755 \
+ $RPM_BUILD_ROOT%{l_prefix}/include/pqxx
+ %{l_shtool} install -c -m 644 \
+ include/pqxx/* \
+ $RPM_BUILD_ROOT%{l_prefix}/include/pqxx/
+ rm -f $RPM_BUILD_ROOT%{l_prefix}/include/pqxx/Makefile*
+ rm -f $RPM_BUILD_ROOT%{l_prefix}/include/pqxx/config.h*
+ %{l_shtool} install -c -m 644 \
+ src/.libs/libpqxx.a \
+ $RPM_BUILD_ROOT%{l_prefix}/lib/
+ ) || exit $?
+%endif
+
+ # install Perl binding
+%if "%{with_perl}" == "yes"
+ ( export POSTGRES_INCLUDE=dummy
+ export POSTGRES_LIB=dummy
+ %{l_prefix}/bin/perl-openpkg -d Pg-%{V_pgperl} install
+ ) || exit $?
+ %{l_prefix}/bin/perl-openpkg -F perl-openpkg-files fixate cleanup
+%else
+ >perl-openpkg-files
+%endif
+
+ # install ODBC driver
+%if "%{with_odbc}" == "yes"
+ ( cd psqlodbc-%{V_psqlodbc}
+ %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
+ ) || exit $?
+%endif
+
+ # install JDBC driver
+%if "%{with_jdbc}" == "yes"
+ ( cd postgresql-jdbc-%{V_pgjdbc}.src
+ %{l_shtool} install -c -m 644 \
+ jars/postgresql.jar $RPM_BUILD_ROOT%{l_prefix}/lib/
+ ) || exit $?
+%endif
+
+ # install Slony-1 replication engine
+%if "%{with_slony1}" == "yes"
+ ( cd slony1-%{V_slony1_major}.%{V_slony1_minor}
+ %{l_shtool} subst \
+ -e 's;$(SQL_NAME80);$(SQL_NAME74);g' \
+ src/xxid/Makefile
+ %{l_make} %{l_mflags} install \
+ DESTDIR=$RPM_BUILD_ROOT \
+ pgconfigdir=%{l_prefix}/bin \
+ pgincludedir=%{l_prefix}/include/postgresql \
+ pgincludeserverdir=%{l_prefix}/include/postgresql/libpq \
+ pglibdir=%{l_prefix}/lib/postgresql \
+ pgpkglibdir=%{l_prefix}/lib/postgresql \
+ pgsharedir=%{l_prefix}/share/postgresql
+ rm -f $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/slony1*v7[34].sql
+ rm -f $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/xxid.v73.sql
+ mv $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/xxid.v74.sql \
+ $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/xxid.sql
+ ( echo "# Slony-1 configuration for replication engine slon(1)"
+ echo "SLON_CLUSTER_NAME=\"example\""
+ echo "SLON_CONNECT_DBNAME=\"example\""
+ echo "SLON_CONNECT_USER=\"postgresql\""
+ echo "SLON_CONNECT_PASS=\"postgresql\""
+ echo "SLON_CONNECT_HOST=\"localhost\""
+ echo "SLON_SYNC_INTERVAL=\"10000\""
+ echo "SLON_SYNC_TIMEOUT=\"60000\""
+ echo "SLON_SYNC_GROUPSIZE=\"6\""
+ echo "SLON_SYNC_LOGLEVEL=\"1\""
+ ) >$RPM_BUILD_ROOT%{l_prefix}/etc/postgresql/slony1.conf
+ ) || exit $?
+%endif
+
+ # adjust default configuration for hourly auto-vacuum operation
+ %{l_shtool} subst \
+ -e 's;^# *\(stats_start_collector *=\) *[^#]*\(#.*\);\1 on \2;' \
+ -e 's;^# *\(stats_row_level *=\) *[^#]*\(#.*\);\1 on \2;' \
+ -e 's;^# *\(autovacuum *=\) *[^#]*\(#.*\);\1 on \2;' \
+ -e 's;^# *\(autovacuum_naptime *=\) *[^#]*\(#.*\);\1 1h \2;' \
+ $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/postgresql.conf.sample
+
+ # post-adjust pgcluster configuration filenames
+%if "%{with_pgcluster}" == "yes"
+ cp $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/pgreplicate.conf.sample \
+ $RPM_BUILD_ROOT%{l_prefix}/etc/postgresql/pgreplicate.conf
+%endif
+
+ # install MySQL compatibility layer
+%if "%{with_mysqlcompat}" == "yes"
+ %{l_shtool} mkdir -f -p -m 755 \
+ $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/mysqlcompat
+ %{l_shtool} install -c -m 644 \
+ mysqlcompat-%{V_mysqlcompat}/README \
+ mysqlcompat-%{V_mysqlcompat}/*.sql \
+ $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/mysqlcompat/
+%endif
+
+ # install run-command script
+ %{l_shtool} mkdir -f -p -m 755 \
+ $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
+ %{l_shtool} install -c -m 755 %{l_value -s -a} \
+ %{SOURCE rc.postgresql} \
+ $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
+
+ # optionally strip down to client-only installation
+%if "%{with_server}" != "yes"
+ rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/pg_[a-bd-z]*
+ rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/pg_c[a-np-z]*
+ rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/pg_controldata
+ rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/post*
+ rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_[a-bd-z]*
+ rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_c[a-np-z]*
+ rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_controldata.1
+ rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/post*
+ rm -rf $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
+ rm -rf $RPM_BUILD_ROOT%{l_prefix}/include/postgresql/server
+ rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/postgresql
+ rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/postgresql
+ rm -rf $RPM_BUILD_ROOT%{l_prefix}/var/postgresql
+%endif
+
+ # determine installation files
+ %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
+%if "%{with_server}" == "yes"
+ %{l_files_std} `cat perl-openpkg-files` \
+%if "%{with_slony1}" == "yes" || "%{with_pgcluster}" == "yes"
+ '%config %{l_prefix}/etc/postgresql/*' \
+%endif
+ '%attr(700,%{l_rusr},%{l_rgrp}) %dir %{l_prefix}/var/postgresql/db' \
+ '%attr(755,%{l_rusr},%{l_rgrp}) %dir %{l_prefix}/var/postgresql/run'
+%else
+ %{l_files_std} `cat perl-openpkg-files`
+%endif
+
+%files -f files
+
+%clean
+ rm -rf $RPM_BUILD_ROOT
+
+%pre
+%if "%{with_server}" == "yes"
+ # before upgrade, check migration dump, save status and stop service
+ [ $1 -eq 2 ] || exit 0
+ if [ -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION -a \
+ -f $RPM_INSTALL_PREFIX/bin/pg_migrate ]; then
+ # database migration dumping hint
+ v_old_all=`cat $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION`
+ v_old_maj=`echo "$v_old_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
+ v_new_all="%{V_postgresql}"
+ v_new_maj=`echo "$v_new_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
+ if [ ".$v_old_maj" != ".$v_new_maj" ]; then
+ if [ ! -f $RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2 -a
".$RPM_POSTGRESQL_MIGRATE" != .ignore ]; then
+ ( echo "You are upgrading from PostgreSQL $v_old_all to
PostgresSQL $v_new_all,"
+ echo "which is a major version change. We expect a
database incompatibility,"
+ echo "so we strongly recommend that you backup your
existing database"
+ echo "($RPM_INSTALL_PREFIX/var/postgresql/db/) first by
running:"
+ echo " \$ $RPM_INSTALL_PREFIX/bin/pg_migrate dump"
+ echo "If this fails for some reasons, try to dump your
data manually:"
+ echo " \$ $RPM_INSTALL_PREFIX/bin/pg_dumpall -U
postgresql -o | \\ "
+ echo " $RPM_INSTALL_PREFIX/lib/openpkg/bzip2 -9 \\ "
+ echo "
>$RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2"
+ echo "Alternatively, if you want to force this package to
be installed without"
+ echo "performing a database dump, run the following
command before upgrading:"
+ echo " \$ RPM_POSTGRESQL_MIGRATE=ignore; export
RPM_POSTGRESQL_MIGRATE"
+ ) | %{l_rpmtool} msg -b -t error
+ exit 1
+ fi
+ fi
+ fi
+ eval `%{l_rc} postgresql status 2>/dev/null | tee %{l_tmpfile}`
+ %{l_rc} postgresql stop 2>/dev/null
+ exit 0
+%endif
+
+%post
+%if "%{with_server}" == "yes"
+%if "%{with_compat}" == "yes"
+ l_pguser="postgres"
+ l_pgpass="postgres"
+%else
+ l_pguser="postgresql"
+ l_pgpass="postgresql"
+%endif
+ if [ $1 -eq 1 ]; then
+ # create initial database
+ su - %{l_rusr} -c \
+ "LC_CTYPE=C; export LC_CTYPE; umask 077; \
+ rm -rf $RPM_INSTALL_PREFIX/var/postgresql/db/*; \
+ echo $l_pgpass
>$RPM_INSTALL_PREFIX/var/postgresql/run/pg_initdb.pw; \
+ $RPM_INSTALL_PREFIX/bin/pg_initdb \
+ --encoding=SQL_ASCII --locale=C --auth=md5
--username=$l_pguser \
+ --pwfile=$RPM_INSTALL_PREFIX/var/postgresql/run/pg_initdb.pw
\
+ --pgdata=$RPM_INSTALL_PREFIX/var/postgresql/db; \
+ rm -f $RPM_INSTALL_PREFIX/var/postgresql/run/pg_initdb.pw" 2>&1
| \
+ $RPM_INSTALL_PREFIX/lib/openpkg/shtool prop \
+ -p "Creating initial PostgreSQL DB in
$RPM_INSTALL_PREFIX/var/postgresql/db"
+ if [ ! -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION ]; then
+ echo "ERROR: failed to create initial PostgreSQL database" 1>&2
+ exit 1
+ fi
+ ( umask 077
+ ( echo "##"
+ echo "## pg_superuser.conf -- PostgreSQL database superuser
configuration"
+ echo "##"
+ echo ""
+ echo "superuser_database=\"template1\""
+ echo "superuser_username=\"$l_pguser\""
+ echo "superuser_password=\"$l_pgpass\""
+ echo ""
+ ) >$RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf
+ chown %{l_rusr}:%{l_rgrp}
$RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf || exit $?
+ chmod 600 $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf
|| exit $?
+ ) || exit $?
+
+ # display information about next steps
+ ( echo "An initial PostgreSQL DB was created with the two standard"
+ echo "databases 'template0' and 'template1'. The owner of both"
+ echo "is the DB user '$l_pguser'. Its initial password is
'$l_pgpass'."
+ echo ""
+ echo "After starting PostgreSQL with"
+ echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc postgresql start"
+ echo "you should immediately change this with the following
command:"
+ echo " \$ $RPM_INSTALL_PREFIX/bin/pg_passwd postgresql
template1"
+ echo ""
+ echo "Then you usually create a database for a user <user>
(assuming that"
+ echo "his home directory is /u/<user>) with password <password>
under"
+ echo "path /u/<user>/rdbms with the commands:"
+ echo " \$ mkdir /u/<user>/rdbms"
+ echo " \$ chmod 700 /u/<user>/rdbms"
+ echo " \$ chown %{l_rusr}:%{l_rgrp} /u/<user>/rdbms"
+ echo " \$ $RPM_INSTALL_PREFIX/bin/psql -U $l_pguser -d
template1"
+ echo " template1=> CREATE ROLE <user>"
+ echo " LOGIN ENCRYPTED PASSWORD '<password>'"
+ echo " NOCREATEDB NOCREATEROLE;"
+ echo " template1=> CREATE TABLESPACE <user> OWNER <user>"
+ echo " LOCATION '/u/<user>/rdbms';"
+ echo " template1=> CREATE DATABASE <user> OWNER <user>"
+ echo " TABLESPACE <user>;"
+ echo " \$ echo 'localhost:*:<user>:<user>:<password>'
>>/u/<user>/.pgpass"
+ echo " \$ chmod 600 <user> /u/<user>/.pgpass"
+ echo " \$ chown <user> /u/<user>/.pgpass"
+ echo "After this the user <user> will be able to connect to his
RDBMS with:"
+ echo " \$ $RPM_INSTALL_PREFIX/bin/psql"
+ ) | %{l_rpmtool} msg -b -t notice
+ fi
+
+%if "%{with_odbc}" == "yes"
+ # optionally link into ODBC
+ if ! $RPM_INSTALL_PREFIX/bin/odbcinst -q -d -n "PostgreSQL" >/dev/null
2>&1; then
+ ( echo "[PostgreSQL]"
+ echo "Description = PostgreSQL ODBC driver"
+ echo "Driver = $RPM_INSTALL_PREFIX/lib/psqlodbc.so"
+ echo "Threading = 2"
+ ) | $RPM_INSTALL_PREFIX/bin/odbcinst -i -d -r -n "PostgreSQL"
+ fi
+%endif
+
+ if [ $1 -eq 2 ]; then
+ # after upgrade, restore status
+ { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null
2>&1
+ [ ".$postgresql_active" = .yes ] && %{l_rc} postgresql start
+ if [ -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION -a \
+ ! -f $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf ];
then
+ ( umask 077
+ ( echo "##"
+ echo "## pg_superuser.conf -- PostgreSQL database superuser
configuration"
+ echo "##"
+ echo ""
+ echo "superuser_database=\"template1\""
+ echo "superuser_username=\"$l_pguser\""
+ echo "superuser_password=\"\""
+ echo ""
+ ) >$RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf
+ chown %{l_rusr}:%{l_rgrp}
$RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf || exit $?
+ chmod 600
$RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf || exit $?
+ ) || exit $?
+ ( echo "Created still missing \"pg_superuser.conf\"
configuration file."
+ echo "You should update its content by resetting the
PostgreSQL"
+ echo "superuser account password with the following command:"
+ echo " \$ $RPM_INSTALL_PREFIX/bin/pg_passwd postgresql
template1"
+ ) | %{l_rpmtool} msg -b -t warn
+ fi
+ if [ -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION -a
".$PG_MIGRATE" != .ignore ]; then
+ # database migration restoring hint
+ v_old_all=`cat $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION`
+ v_old_maj=`echo "$v_old_all" | sed -e
's/^\([0-9]*\.[0-9]*\).*/\1/'`
+ v_new_all="%{V_postgresql}"
+ v_new_maj=`echo "$v_new_all" | sed -e
's/^\([0-9]*\.[0-9]*\).*/\1/'`
+ if [ ".$v_old_maj" != ".$v_new_maj" ]; then
+ ( echo "You upgraded from PostgreSQL $v_old_all to
PostgresSQL $v_new_all,"
+ echo "which is a major version upgrade. We expect a
database incompatibility,"
+ echo "so we strongly recommend you to recreate the
existing database under"
+ echo "$RPM_INSTALL_PREFIX/var/postgresql/db/ by running
the following command:"
+ echo " \$ $RPM_INSTALL_PREFIX/bin/pg_migrate restore"
+ echo "If this fails for some reasons, try to restore your
data manually:"
+ echo " \$ $RPM_INSTALL_PREFIX/lib/openpkg/bzip2 -d -c
\\ "
+ echo "
$RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2 | \\ "
+ echo " $RPM_INSTALL_PREFIX/bin/psql -U postgresql -d
template1"
+ ) | %{l_rpmtool} msg -b -t warn
+ fi
+ fi
+ fi
+ exit 0
+%endif
+
+%preun
+%if "%{with_server}" == "yes"
+ # before erase, stop service and remove log files
+ [ $1 -eq 0 ] || exit 0
+ %{l_rc} postgresql stop 2>/dev/null
+ rm -f $RPM_INSTALL_PREFIX/var/postgresql/run/* >/dev/null 2>&1 || true
+ # optionally unlink from ODBC
+%if "%{with_odbc}" == "yes"
+ $RPM_INSTALL_PREFIX/bin/odbcinst -u -d -n "PostgreSQL"
+%endif
+ exit 0
+%endif
+
@@ .
patch -p0 <<'@@ .'
Index: openpkg-src/postgresql82/rc.postgresql
============================================================================
$ cvs diff -u -r0 -r1.3 rc.postgresql
--- /dev/null 2008-04-02 10:32:37 +0200
+++ rc.postgresql 2008-04-02 10:32:57 +0200
@@ -0,0 +1,108 @@
[EMAIL PROTECTED]@/bin/openpkg rc
+##
+## rc.postgresql -- Run-Commands
+##
+
+%config
+ postgresql_enable="$openpkg_rc_def"
+ postgresql_flags=""
+ postgresql_datadir="@l_prefix@/var/postgresql/db"
+ postgresql_rundir="@l_prefix@/var/postgresql/run"
+ postgresql_shut_mode="fast"
+ postgresql_socket_inet="127.0.0.1"
+ postgresql_socket_unix="@l_prefix@/var/postgresql/run"
+ postgresql_log_prolog="true"
+ postgresql_log_epilog="true"
+ postgresql_log_numfiles="10"
+ postgresql_log_minsize="1M"
+ postgresql_log_complevel="9"
+ postgresql_slony1="no"
+
+%common
+ postgresql_opts="-h $postgresql_socket_inet -k $postgresql_socket_unix"
+ postgresql_opts="$postgresql_opts $postgresql_flags"
+ postgresql_logfile="$postgresql_rundir/postgresql.log"
+ postgresql_pidfile="$postgresql_datadir/postgresql.pid"
+ postgresql_slony1_pidfile="$postgresql_rundir/slon.pid"
+ postgresql_slony1_start () {
+ ( . @l_prefix@/etc/postgresql/slony1.conf
+ nohup @l_prefix@/bin/slon \
+ -d "$SLON_SYNC_LOGLEVEL" -g "$SLON_SYNC_GROUPSIZE" \
+ -s "$SLON_SYNC_INTERVAL" -t "$SLON_SYNC_TIMEOUT" \
+ "$SLON_CLUSTER_NAME" \
+ user="$SLON_CONNECT_USER" password="$SLON_CONNECT_PASS" \
+ dbname="$SLON_CONNECT_DBNAME" host="$SLON_CONNECT_HOST"
+ </dev/null >/dev/null 2>&1 &
+ echo $! >$postgresql_slony1_pidfile
+ ) >/dev/null 2>&1
+ }
+ postgresql_slony1_stop () {
+ if [ -f $postgresql_slony1_pidfile ]; then
+ kill -TERM `cat $postgresql_slony1_pidfile`
+ rm -f $postgresql_slony1_pidfile
+ fi
+ }
+ postgresql_ctl () {
+ if [ -s $postgresql_pidfile ]; then
+ kill -0 `head -1 $postgresql_pidfile` >/dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ rm -f $postgresql_pidfile >/dev/null 2>&1 || true
+ rm -f $postgresql_rundir/.s* >/dev/null 2>&1 || true
+ fi
+ fi
+ cmd="$1"; shift
+ @l_prefix@/bin/pg_ctl $cmd \
+ -l $postgresql_logfile \
+ -D $postgresql_datadir \
+ ${1+"$@"}
+ }
+
+%status -u @l_rusr@ -o
+ postgresql_usable="unknown"
+ postgresql_active="no"
+ rcService postgresql enable yes && \
+ postgresql_ctl status >/dev/null && \
+ postgresql_active="yes"
+ echo "postgresql_enable=\"$postgresql_enable\""
+ echo "postgresql_usable=\"$postgresql_usable\""
+ echo "postgresql_active=\"$postgresql_active\""
+
+%start -p 400 -u @l_rusr@
+ rcService postgresql enable yes || exit 0
+ rcService postgresql active yes && exit 0
+ postgresql_ctl start -o "$postgresql_opts"
+ if rcVarIsYes postgresql_slony1; then
+ postgresql_slony1_start
+ fi
+
+%stop -p 600 -u @l_rusr@
+ rcService postgresql enable yes || exit 0
+ rcService postgresql active no && exit 0
+ postgresql_ctl stop -m "$postgresql_shut_mode"
+ if rcVarIsYes postgresql_slony1; then
+ postgresql_slony1_stop
+ fi
+
+%restart -p 400 -u @l_rusr@
+ rcService postgresql enable yes || exit 0
+ rcService postgresql active no && exit 0
+ postgresql_ctl restart -o "$postgresql_opts" -m "$postgresql_shut_mode"
+ if rcVarIsYes postgresql_slony1; then
+ postgresql_slony1_stop
+ postgresql_slony1_start
+ fi
+
+%reload -p 400 -u @l_rusr@
+ rcService postgresql enable yes || exit 0
+ rcService postgresql active no && exit 0
+ postgresql_ctl reload
+
+%daily -u @l_rusr@
+ rcService postgresql enable yes || exit 0
+ shtool rotate -f \
+ -n ${postgresql_log_numfiles} -s ${postgresql_log_minsize} -d -c \
+ -z ${postgresql_log_complevel} -m 600 -o @l_rusr@ -g @l_rgrp@ \
+ -P "$postgresql_log_prolog" \
+ -E "$postgresql_log_epilog" \
+ $postgresql_logfile
+
@@ .
______________________________________________________________________
OpenPKG http://openpkg.org
CVS Repository Commit List [email protected]