head	1.13;
access;
symbols;
locks; strict;
comment	@-- @;


1.13
date	2007.09.06.09.52.04;	author rse;	state dead;
branches;
next	1.12;
commitid	g5QVXf52i4DPUEws;

1.12
date	2007.04.27.21.02.18;	author rse;	state Exp;
branches;
next	1.11;
commitid	47FYtJChyBwORKfs;

1.11
date	2007.04.21.07.42.56;	author rse;	state Exp;
branches;
next	1.10;
commitid	nnrRJBS3qKVxDUes;

1.10
date	2007.04.20.15.36.47;	author cs;	state Exp;
branches;
next	1.9;
commitid	iKgfo3WfkQR5iPes;

1.9
date	2007.04.18.21.46.20;	author thl;	state Exp;
branches;
next	1.8;
commitid	WyQKNMwmoITBoBes;

1.8
date	2007.03.02.05.42.17;	author cs;	state Exp;
branches;
next	1.7;
commitid	kWNs0qRm4IwNzt8s;

1.7
date	2007.02.19.07.26.55;	author rse;	state Exp;
branches;
next	1.6;
commitid	r2cyAkztdUfCv47s;

1.6
date	2007.02.07.16.54.58;	author rse;	state Exp;
branches;
next	1.5;
commitid	VHwBvRHCQCup2A5s;

1.5
date	2007.02.02.16.37.29;	author rse;	state Exp;
branches;
next	1.4;
commitid	QWQWonCwhbAn6W4s;

1.4
date	2007.01.10.22.24.16;	author rse;	state Exp;
branches;
next	1.3;
commitid	ei9VBbNSmjsbL02s;

1.3
date	2007.01.10.18.45.58;	author rse;	state Exp;
branches;
next	1.2;
commitid	PeZPXmqheHShyZ1s;

1.2
date	2007.01.09.07.16.45;	author rse;	state Exp;
branches;
next	1.1;
commitid	5I14LmlAE3MPLN1s;

1.1
date	2007.01.06.20.45.51;	author rse;	state Exp;
branches;
next	;
commitid	FY7GrCI53l4jlu1s;


desc
@@


1.13
log
@remove obsolete package
@
text
@##
##  postgresql81.spec -- OpenPKG RPM Package Specification
##  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.
##

#   package versions
%define       V_postgresql      8.1.9
%define       V_libpqpp         4.0
%define       V_libpqxx         2.5.5
%define       V_perl            5.8.8
%define       V_pgperl          2.0.2
%define       V_psqlodbc        08.02.0400
%define       V_slony1          1.2.6
%define       V_slony1_dir      1215
%define       V_pgcluster       1.5.0rc16
%define       V_pgcluster_dir   1296
%define       V_mysqlcompat     1.0b3
%define       V_mysqlcompat_dir 548

#   package information
Name:         postgresql81
Summary:      PostgreSQL Database (OLD VERSION)
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:      20070427

#   package options
%option       with_server       yes
%option       with_cxx          no
%option       with_perl         no
%option       with_odbc         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
%option       with_setproctitle no

#   list of sources
Source0:      ftp://ftp.postgresql.org/pub/source/v%{V_postgresql}/postgresql-%{V_postgresql}.tar.bz2
Source1:      ftp://gborg.postgresql.org/pub/libpqpp/stable/libpq++-%{V_libpqpp}.tar.gz
Source2:      ftp://gborg.postgresql.org/pub/libpqxx/stable/libpqxx-%{V_libpqxx}.tar.gz
Source3:      ftp://gborg.postgresql.org/pub/pgperl/stable/pgperl-%{V_pgperl}.tar.gz
Source4:      ftp://ftp.postgresql.org/pub/odbc/versions/src/psqlodbc-%{V_psqlodbc}.tar.gz
Source5:      http://pgfoundry.org/frs/download.php/%{V_slony1_dir}/slony1-%{V_slony1}-tar.bz2
Source6:      http://pgfoundry.org/frs/download.php/%{V_pgcluster_dir}/pgcluster-%{V_pgcluster}-patch.tar.gz
Source7:      http://pgfoundry.org/frs/download.php/%{V_mysqlcompat_dir}/mysqlcompat-%{V_mysqlcompat}.tar.gz
Source8:      rc.postgresql
Source9:      pg_migrate
Patch0:       postgresql81.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_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.

    NOTICE: THIS IS AN OLD VERSION!

%track
    prog postgresql81 = {
        version   = %{V_postgresql}
        url       = ftp://ftp.postgresql.org/pub/source/
        regex     = v(8\.1(\.\d+)*)(?!beta)
        url       = ftp://ftp.postgresql.org/pub/source/v__NEWVER__/
        regex     = postgresql-(8\.1(\.\d+)*)\.tar\.(?:gz|bz2)
    }
    prog postgresql81:libpq++ = {
        version   = %{V_libpqpp}
        url       = ftp://gborg.postgresql.org/pub/libpqpp/stable/
        regex     = libpq\+\+-(__VER__)\.tar\.gz
    }
    prog postgresql81:libpqxx = {
        version   = %{V_libpqxx}
        url       = ftp://gborg.postgresql.org/pub/libpqxx/stable/
        regex     = libpqxx-(__VER__)\.tar\.gz
    }
    prog postgresql81:pgperl = {
        version   = %{V_pgperl}
        url       = ftp://gborg.postgresql.org/pub/pgperl/stable/
        regex     = pgperl-(__VER__)\.tar\.gz
    }
    prog postgresql81:psqlodbc = {
        version   = %{V_psqlodbc}
        url       = ftp://ftp.postgresql.org/pub/odbc/versions/src/
        regex     = psqlodbc-(\d{2}\.\d{2}\.\d{4})\.tar\.gz
    }
    prog postgresql81:slony1 = {
        version   = %{V_slony1}.%{V_slony1_dir}
        url       = http://pgfoundry.org/frs/?group_id=1000122
        regex     = /(\d+/slony1-\d+\.\d+\.\d+)[-.]tar\.bz2
        transform = "s/^(\\d+)\/slony1-(\d+\.\d+\.\d+)$/$2.$1/; $_"
    }
    prog postgresql81:pgcluster = {
        version   = %{V_pgcluster}.%{V_pgcluster_dir}
        url       = http://pgfoundry.org/frs/?group_id=1000072
        regex     = /(\d+/pgcluster-1\.[56]\.__VER__)-patch\.tar\.gz
        transform = "s/^(\\d+)\/pgcluster-(.+)$/$2.$1/; $_"
    }
    prog postgresql81: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
    %setup -q -n postgresql-%{V_postgresql} -T -D -a 2
    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 3
%endif
%if "%{with_odbc}" == "yes"
    %setup -q -n postgresql-%{V_postgresql} -T -D -a 4
%endif
%if "%{with_slony1}" == "yes"
    %setup -q -n postgresql-%{V_postgresql} -T -D -a 5
%endif
%if "%{with_pgcluster}" == "yes"
    %setup -q -n postgresql-%{V_postgresql} -T -D -a 6
    sed -e '/^diff.*libpq\.rc/,/^diff/d' pgcluster-*-patch |\
    sed -e 's;(char .)\(ptr .= readlen\);\1;' |\
    %{l_patch} -p1
%endif
%if "%{with_mysqlcompat}" == "yes"
    %setup -q -n postgresql-%{V_postgresql} -T -D -a 7
%endif
%if "%{with_kerberos}" == "yes"
    %{l_shtool} subst \
        -e 's;krb5 -ldes -lasn1 -lroken;krb5 -lk5crypto -lkrb5support -lcom_err;g' \
        configure
%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"
%if "%{with_setproctitle}" == "no"
      echo "ac_cv_lib_util_setproctitle=no"
      echo "ac_cv_func_setproctitle=no"
      echo "ac_cv_func_setproctitle_func=no"
%endif
    ) >config.cache
    export CC="%{l_cc}"
    export CFLAGS="%{l_cflags -O}"
    export CPPFLAGS="%{l_cppflags readline}"
    export LDFLAGS="%{l_ldflags}"
%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 %{l_cppflags kerberos}"
    LDFLAGS="$LDFLAGS %{l_ldflags kerberos}"
%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"
    ( cd libpq++-%{V_libpqpp}
      CXX="%{l_cxx}"
      CFLAGS="%{l_cflags -O}"
      CPPFLAGS="-DHAVE_NAMESPACE_STD -DHAVE_CXX_STRING_HEADER -DDLLIMPORT= "
      CPPFLAGS="$CPPFLAGS -I. -I../src/interfaces/libpq -I../src/interfaces"
      CPPFLAGS="$CPPFLAGS -I../src/include %{l_cppflags}"
      LDFLAGS="%{l_ldflags}"
      OBJS="pgconnection.o pgdatabase.o pgtransdb.o pgcursordb.o pglobject.o"
      for o in $OBJS; do
          $CXX $CFLAGS $CPPFLAGS $LDFLAGS -c -o $o `echo $o | sed -e 's;\.o$;.cc;'`
      done
      rm -f libpq++.a
      ar rc libpq++.a $OBJS
    ) || exit $?
    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 Slony-1 replication engine
%if "%{with_slony1}" == "yes"
    ( cd slony1-%{V_slony1}
      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 migration utility
%if "%{with_compat}" == "yes"
    l_pguser="postgres"
    l_pgpass="postgres"
%else
    l_pguser="postgresql"
    l_pgpass="postgresql"
%endif
    %{l_shtool} install -c -m 755 %{l_value -s -a} \
        -e "s;@@l_pguser@@;${l_pguser};g" \
        -e "s;@@l_pgpass@@;${l_pgpass};g" \
        %{SOURCE pg_migrate} \
        $RPM_BUILD_ROOT%{l_prefix}/bin/

    #   install C++ bindings (both old and new one)
%if "%{with_cxx}" == "yes"
    ( cd libpq++-%{V_libpqpp}
      %{l_shtool} mkdir -f -p -m 755 \
          $RPM_BUILD_ROOT%{l_prefix}/include/libpq++
      %{l_shtool} install -c -m 644 \
          libpq++.h pgconnection.h pgdatabase.h pgtransdb.h pgcursordb.h pglobject.h \
          $RPM_BUILD_ROOT%{l_prefix}/include/libpq++/
      %{l_shtool} install -c -m 644 \
          libpq++.a \
          $RPM_BUILD_ROOT%{l_prefix}/lib/
    ) || exit $?
    ( 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 Slony-1 replication engine
%if "%{with_slony1}" == "yes"
    ( cd slony1-%{V_slony1}
      %{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

    #   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 [ $1 -eq 1 ]; then
        #   create initial database
%if "%{with_compat}" == "yes"
        l_pguser="postgres"
        l_pgpass="postgres"
%else
        l_pguser="postgresql"
        l_pgpass="postgresql"
%endif
        su - %{l_rusr} -c \
            "LC_CTYPE=C; export LC_CTYPE; umask 022; \
            rm -rf $RPM_INSTALL_PREFIX/var/postgresql/db/*; \
            echo $l_pgpass >$RPM_INSTALL_PREFIX/var/postgresql/run/pw; \
            $RPM_INSTALL_PREFIX/bin/pg_initdb \
                -U $l_pguser --pwfile=$RPM_INSTALL_PREFIX/var/postgresql/run/pw \
                -D $RPM_INSTALL_PREFIX/var/postgresql/db; \
            rm -f $RPM_INSTALL_PREFIX/var/postgresql/run/pw" 2>&1 |\
        $RPM_INSTALL_PREFIX/lib/openpkg/shtool prop \
            -p "Creating initial PostgreSQL DB in $RPM_INSTALL_PREFIX/var/postgresql/db"

        #   adjust initial authentication configuration
        cp $RPM_INSTALL_PREFIX/var/postgresql/db/pg_hba.conf \
           $RPM_INSTALL_PREFIX/var/postgresql/db/pg_hba.conf.old
        ( cat $RPM_INSTALL_PREFIX/var/postgresql/db/pg_hba.conf.old |\
          sed -e 's;^\([^#]\);# \1;' -e 's;^$;#;'
          echo ""
          echo "#   OpenPKG PostgreSQL default access policy"
          echo "local all all                           md5"
          echo "host  all all 127.0.0.1 255.255.255.255 md5"
          echo ""
        ) >$RPM_INSTALL_PREFIX/var/postgresql/db/pg_hba.conf
        rm -f $RPM_INSTALL_PREFIX/var/postgresql/db/pg_hba.conf.old

        #   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 "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/psql -U $l_pguser -d template1 \\"
          echo "      -c \"ALTER ROLE $l_pguser WITH PASSWORD '<new-password>'\""
          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> LOGIN"
          echo "                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; chown <user> /u/<user>/.pgpass"
          echo "After this the user <user> will be able to connect to his RDBMS with:"
          echo "    \$ psql"
        ) | %{l_rpmtool} msg -b -t notice

        #   optionally link into ODBC
%if "%{with_odbc}" == "yes"
        ( 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"
%endif
    fi
    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 ".$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

@


1.12
log
@modifying package: postgresql81-8.1.9 20070421 -> 20070427
@
text
@@


1.11
log
@modifying package: postgresql81-8.1.9 20070420 -> 20070421
@
text
@d31 1
a31 1
%define       V_psqlodbc        08.02.0300
d50 1
a50 1
Release:      20070421
d371 1
a371 1
          --with-unixodbc \
@


1.10
log
@upgrading package: postgresql81 8.1.8 -> 8.1.9
@
text
@d31 1
a31 1
%define       V_psqlodbc        08.02.0200
d50 1
a50 1
Release:      20070420
@


1.9
log
@get rid of direct /etc/rc call and replace them with openpkg
@
text
@d26 1
a26 1
%define       V_postgresql      8.1.8
d50 1
a50 1
Release:      20070418
@


1.8
log
@modifying package: postgresql81-8.1.8 20070219 -> 20070302
@
text
@d50 1
a50 1
Release:      20070302
d677 1
a677 1
          echo "    \$ $RPM_INSTALL_PREFIX/etc/rc postgresql start"
@


1.7
log
@modifying package: postgresql81-8.1.8 20070207 -> 20070219
@
text
@d34 2
a35 2
%define       V_pgcluster       1.5.0rc15
%define       V_pgcluster_dir   1274
d50 1
a50 1
Release:      20070219
@


1.6
log
@upgrading package: postgresql81 8.1.7 -> 8.1.8
@
text
@d34 2
a35 2
%define       V_pgcluster       1.5.0rc14
%define       V_pgcluster_dir   1219
d50 1
a50 1
Release:      20070207
@


1.5
log
@upgrading package: postgresql81 8.1.6 -> 8.1.7
@
text
@d26 1
a26 1
%define       V_postgresql      8.1.7
d50 1
a50 1
Release:      20070202
@


1.4
log
@use the PostgreSQL 8 world order name: ROLE instead of USER
@
text
@d26 1
a26 1
%define       V_postgresql      8.1.6
d50 1
a50 1
Release:      20070110
@


1.3
log
@modifying package: postgresql81-8.1.6 20070109 -> 20070110
@
text
@d680 1
a680 1
          echo "      -c \"ALTER USER $l_pguser WITH PASSWORD '<new-password>'\""
@


1.2
log
@modifying package: postgresql81-8.1.6 20070106 -> 20070109
@
text
@d34 2
a35 2
%define       V_pgcluster       1.5.0rc13
%define       V_pgcluster_dir   1207
d50 1
a50 1
Release:      20070109
@


1.1
log
@Upgrade OpenPKG-CURRENT from PostgreSQL 8.1 to 8.2 world order:
- *CREATED*          -> postgresql81-8.1.6
- postgresql-8.1.6   -> postgresql82-8.2.1
- postgresql82-8.2.1 -> *REMOVED*
@
text
@d32 2
a33 2
%define       V_slony1          1.2.5
%define       V_slony1_dir      1211
d50 1
a50 1
Release:      20070106
@

