head	1.18;
access;
symbols
	OPENPKG_E1_MP_HEAD:1.18
	OPENPKG_E1_MP:1.18
	OPENPKG_2_4_RELEASE:1.17.2.1
	OPENPKG_2_4_SOLID:1.17.0.2
	OPENPKG_2_4_SOLID_BP:1.17
	OPENPKG_CW_FP:1.11
	OPENPKG_2_3_RELEASE:1.5.2.1
	OPENPKG_2_3_SOLID:1.5.0.2
	OPENPKG_2_3_SOLID_BP:1.5;
locks; strict;
comment	@-- @;


1.18
date	2005.06.22.17.04.26;	author rse;	state dead;
branches;
next	1.17;

1.17
date	2005.05.19.18.58.35;	author rse;	state Exp;
branches
	1.17.2.1;
next	1.16;

1.16
date	2005.05.15.17.51.55;	author rse;	state Exp;
branches;
next	1.15;

1.15
date	2005.05.06.07.09.14;	author rse;	state Exp;
branches;
next	1.14;

1.14
date	2005.04.18.11.24.37;	author rse;	state Exp;
branches;
next	1.13;

1.13
date	2005.04.08.06.12.51;	author rse;	state Exp;
branches;
next	1.12;

1.12
date	2005.03.24.11.20.05;	author rse;	state Exp;
branches;
next	1.11;

1.11
date	2005.03.21.19.53.24;	author rse;	state Exp;
branches;
next	1.10;

1.10
date	2005.03.12.19.25.44;	author rse;	state Exp;
branches;
next	1.9;

1.9
date	2005.03.05.19.41.55;	author rse;	state Exp;
branches;
next	1.8;

1.8
date	2005.03.02.19.57.29;	author rse;	state Exp;
branches;
next	1.7;

1.7
date	2005.02.28.14.45.09;	author ms;	state Exp;
branches;
next	1.6;

1.6
date	2005.02.24.16.05.35;	author rse;	state Exp;
branches;
next	1.5;

1.5
date	2005.02.20.09.02.51;	author rse;	state Exp;
branches
	1.5.2.1;
next	1.4;

1.4
date	2005.02.08.19.05.20;	author rse;	state Exp;
branches;
next	1.3;

1.3
date	2005.02.03.18.32.43;	author rse;	state Exp;
branches;
next	1.2;

1.2
date	2005.02.01.06.37.44;	author rse;	state Exp;
branches;
next	1.1;

1.1
date	2005.01.18.10.00.28;	author rse;	state Exp;
branches;
next	;

1.17.2.1
date	2005.06.15.19.03.57;	author rse;	state Exp;
branches;
next	;

1.5.2.1
date	2005.02.21.17.08.15;	author rse;	state Exp;
branches;
next	;


desc
@@


1.18
log
@PostgreSQL 7.x was still included as a PLUS package in OpenPKG 2.4 and is obsoleted by the BASE package of PostgreSQL 8.0, so finally remove this package at all. If someone really needs a PostgreSQL 7.x package they still can get it from CVS, of course.
@
text
@##
##  postgresql7.spec -- OpenPKG RPM Package Specification
##  Copyright (c) 2000-2005 OpenPKG Foundation e.V. <http://openpkg.net/>
##  Copyright (c) 2000-2005 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      7.4.8
%define       V_libpqpp         4.0
%define       V_libpqxx         2.5.3
%define       V_pgperl          2.0.2
%define       V_psqlodbc        08.00.0101
%define       V_slony1          1.0.5
%define       V_pgpool          2.5.2

#   package information
Name:         postgresql7
Summary:      PostgreSQL Database
URL:          http://www.postgresql.org/
Vendor:       PostgreSQL Group
Packager:     OpenPKG
Distribution: OpenPKG
Class:        PLUS
Group:        Database
License:      GPL
Version:      %{V_postgresql}
Release:      20050519

#   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_pgpool   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://developer.postgresql.org/~wieck/slony1/download/slony1-%{V_slony1}.tar.gz
Source6:      http://www2b.biglobe.ne.jp/~caco/pgpool/pgpool-%{V_pgpool}.tar.gz
Source7:      rc.postgresql
Source8:      pg_migrate
Patch0:       postgresql7.patch

#   build information
Prefix:       %{l_prefix}
BuildRoot:    %{l_buildroot}
BuildPreReq:  OpenPKG, openpkg >= 20040130, make, gcc, flex, bison, gzip
PreReq:       OpenPKG, openpkg >= 20040130
BuildPreReq:  readline, zlib, openssl, getopt
PreReq:       readline, zlib, openssl, getopt
%if "%{with_perl}" == "yes"
BuildPreReq:  perl, perl-openpkg >= 5.8.3-20040126
PreReq:       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
AutoReq:      no
AutoReqProv:  no
Provides:     postgresql = %{version}

%description
    PostgreSQL is a sophisticated Object-Relational DBMS, supporting
    almost all SQL constructs, including subselects, transactions,
    and user-defined types and functions. It is the most advanced
    open-source database available anywhere.

%track
    prog postgresql7 = {
        version   = %{V_postgresql}
        url       = ftp://ftp.postgresql.org/pub/source/
        regex     = v(7\.\d+(\.\d+)*)(?!beta)
        url       = ftp://ftp.postgresql.org/pub/source/v__NEWVER__/
        regex     = postgresql-(\d+\.\d+(\.\d+)*)\.tar\.(?:gz|bz2)
    }
    prog postgresql7:libpq++ = {
        version   = %{V_libpqpp}
        url       = ftp://gborg.postgresql.org/pub/libpqpp/stable/
        regex     = libpq\+\+-(__VER__)\.tar\.gz
    }
    prog postgresql7:libpqxx = {
        version   = %{V_libpqxx}
        url       = ftp://gborg.postgresql.org/pub/libpqxx/stable/
        regex     = libpqxx-(__VER__)\.tar\.gz
    }
    prog postgresql7:pgperl = {
        version   = %{V_pgperl}
        url       = ftp://gborg.postgresql.org/pub/pgperl/stable/
        regex     = pgperl-(__VER__)\.tar\.gz
    }
    prog postgresql7:psqlodbc = {
        version   = %{V_psqlodbc}
        url       = ftp://ftp.postgresql.org/pub/odbc/versions/src/
        regex     = psqlodbc-(\d{2}\.\d{2}\.\d{4})\.tar\.gz
    }
    prog postgresql7:slony1 = {
        version   = %{V_slony1}
        url       = http://developer.postgresql.org/~wieck/slony1/download/
        regex     = slony1-(\d+\.\d+\.\d+)\.tar\.gz
    }
    prog postgresql7:pgpool = {
        version   = %{V_pgpool}
        url       = http://www2b.biglobe.ne.jp/~caco/pgpool/
        regex     = pgpool-(__VER__)\.tar\.gz
    }

%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
%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_pgpool}" == "yes"
    %setup -q -n postgresql-%{V_postgresql} -T -D -a 6
%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
    CC="%{l_cc}" \
%if "%{with_slony1}" == "yes"
    CFLAGS="%{l_cflags -O} -pthread" \
%else
    CFLAGS="%{l_cflags -O}" \
%endif
%if "%{with_tcl}" == "yes"
    CPPFLAGS="%{l_cppflags readline tcl} -DOPENSSL_DISABLE_OLD_DES_SUPPORT" \
    LDFLAGS="%{l_ldflags} -L`%{l_rc} --query x11_libdir`" \
%else
    CPPFLAGS="%{l_cppflags readline} -DOPENSSL_DISABLE_OLD_DES_SUPPORT" \
    LDFLAGS="%{l_ldflags}" \
%endif
    TAR="%{l_tar}" \
    YACC="bison -y" \
    ./configure \
        --cache-file=./config.cache \
        --prefix=%{l_prefix} \
        --includedir=%{l_prefix}/include/postgresql \
        --with-openssl=%{l_prefix} \
        --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
        --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"
      ./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 \
          --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}
      %{l_shtool} subst \
          -e 's;-lpq;-lpq -lssl -lcrypto -lcrypt;' \
          src/slon/Makefile src/slonik/Makefile
      export CC="%{l_cc}"
      export CFLAGS="%{l_cflags -O}"
      export CPPFLAGS="%{l_cppflags}"
      ./configure \
          --prefix=%{l_prefix} \
          --with-pgsourcetree=`pwd`/..
      %{l_make} %{l_mflags -O}
    ) || exit $?
%endif

    #   build pgpool frontend
%if "%{with_pgpool}" == "yes"
    ( cd pgpool-%{V_pgpool}
      export CC="%{l_cc}"
      export CFLAGS="%{l_cflags -O} %{l_cppflags}"
      export LDFLAGS="%{l_ldflags}"
      export LIBS="-lgetopt"
      ./configure \
          --prefix=%{l_prefix} \
          --sysconfdir=%{l_prefix}/etc/postgresql \
          --with-pgsrc=/dummy
      %{l_make} %{l_mflags}
    ) || exit $?
%endif

%install
    rm -rf $RPM_BUILD_ROOT

    #   perform standard installation procedure
    cp /dev/null register.txt
    %{l_make} %{l_mflags} install install-all-headers 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 initlocation ipcclean vacuumdb; 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 \
        $RPM_BUILD_ROOT%{l_prefix}/etc/postgresql \
        $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/*.h \
          $RPM_BUILD_ROOT%{l_prefix}/include/pqxx/
      %{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_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
      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

    #   install pgpool frontend
%if "%{with_pgpool}" == "yes"
    ( cd pgpool-%{V_pgpool}
      %{l_shtool} install -c -s -m 755 \
          pgpool $RPM_BUILD_ROOT%{l_prefix}/bin/
      %{l_shtool} install -c -m 644 \
          -e "s;\(socket_dir = \).*;\1'%{l_prefix}/var/postgresql/run';" \
          -e "s;\(backend_socket_dir = \).*;\1'%{l_prefix}/var/postgresql/run';" \
          -e "s;\(logdir = \).*;\1'%{l_prefix}/var/postgresql/run';" \
          pgpool.conf.sample $RPM_BUILD_ROOT%{l_prefix}/etc/postgresql/pgpool.conf
    ) || exit $?
%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` \
        '%config %{l_prefix}/etc/postgresql/*' \
        '%attr(700,%{l_rusr},%{l_rgrp}) %dir %{l_prefix}/var/postgresql/db' \
        '%attr(755,%{l_rusr},%{l_rgrp}) %dir %{l_prefix}/var/postgresql/run' \
        '%config %{l_prefix}/var/postgresql/db/*.conf'
%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; \
            (echo $l_pguser; echo $l_pgpass) |\
            $RPM_INSTALL_PREFIX/bin/pg_initdb \
                -U $l_pguser -W -D $RPM_INSTALL_PREFIX/var/postgresql/db" 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 you should change this as soon as"
          echo "possible with the following command:"
          echo "\$ $RPM_INSTALL_PREFIX/bin/psql -U $l_pguser -d template1 \\"
          echo "  -c \"ALTER USER $l_pguser WITH PASSWORD '<new-password>'\""
        ) | %{l_rpmtool} msg -b -t notice

        #   optionally link into unixODBC
%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
%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
    exit 0
%endif

@


1.17
log
@modifying package: postgresql7-7.4.8 20050515 -> 20050519
@
text
@@


1.17.2.1
log
@bump release numbers for OpenPKG 2.4
@
text
@d45 1
a45 1
Release:      2.4.0
d72 2
a73 2
BuildPreReq:  OpenPKG, openpkg >= 2.4.0, make, gcc, flex, bison, gzip
PreReq:       OpenPKG, openpkg >= 2.4.0
d77 1
a77 1
BuildPreReq:  perl, perl-openpkg >= 5.8.3-2.4.0
@


1.16
log
@modifying package: postgresql7-7.4.8 20050506 -> 20050515
@
text
@d28 1
a28 1
%define       V_libpqxx         2.5.2
d45 1
a45 1
Release:      20050515
@


1.15
log
@upgrading package: postgresql7 7.4.7 -> 7.4.8
@
text
@d28 1
a28 1
%define       V_libpqxx         2.5.0
d45 1
a45 1
Release:      20050506
@


1.14
log
@track only releases of slony1
@
text
@d26 1
a26 1
%define       V_postgresql      7.4.7
d45 1
a45 1
Release:      20050418
@


1.13
log
@perl-openpkg is required under built-time only
@
text
@d45 1
a45 1
Release:      20050408
d129 1
a129 1
        regex     = slony1-(__VER__)\.tar\.gz
@


1.12
log
@Adjust the copyright declaration in this (RSE's) copy of the OpenPKG
source code now that the fork point for C&W was established (CVS tag
OPENPKG_CW_FP), the shared copyright agreement between RSE and C&W is
no longer active (as C&W no longer officially sponsors OpenPKG) and the
new shared copyright from RSE can be taken over by the newly established
juristic entity OpenPKG Foundation e.V. (instead of the non-juristic
entity OpenPKG Project).
@
text
@d45 1
a45 1
Release:      20050321
d78 1
a78 1
PreReq:       perl, perl-openpkg >= 5.8.3-20040126
@


1.11
log
@modifying package: postgresql7-7.4.7 20050312 -> 20050321
@
text
@d2 3
a4 4
##  postgresql7.spec -- OpenPKG RPM Specification
##  Copyright (c) 2000-2005 The OpenPKG Project <http://www.openpkg.org/>
##  Copyright (c) 2000-2005 Ralf S. Engelschall <rse@@engelschall.com>
##  Copyright (c) 2000-2005 Cable & Wireless <http://www.cw.com/>
d39 1
a39 1
Packager:     The OpenPKG Project
@


1.10
log
@modifying package: postgresql7-7.4.7 20050305 -> 20050312
@
text
@d29 1
a29 1
%define       V_libpqxx         2.4.4
d46 1
a46 1
Release:      20050312
@


1.9
log
@modifying package: postgresql7-7.4.7 20050302 -> 20050305
@
text
@d33 1
a33 1
%define       V_pgpool          2.5.1
d46 1
a46 1
Release:      20050305
@


1.8
log
@modifying package: postgresql7-7.4.7 20050228 -> 20050302
@
text
@d31 1
a31 1
%define       V_psqlodbc        08.00.0100
d46 1
a46 1
Release:      20050302
@


1.7
log
@modifying package: postgresql7-7.4.7 20050224 -> 20050228
@
text
@d31 1
a31 1
%define       V_psqlodbc        07.03.0200
d46 1
a46 1
Release:      20050228
d63 1
a63 1
Source4:      ftp://ftp.us.postgresql.org/odbc/versions/src/psqlodbc-%{V_psqlodbc}.tar.gz
@


1.6
log
@ggrrrr... a numbered package is not allowed to be BASE, it can be at maximum PLUS by definition
@
text
@d29 1
a29 1
%define       V_libpqxx         2.4.3
d46 1
a46 1
Release:      20050224
@


1.5
log
@modifying package: postgresql7-7.4.7 20050208 -> 20050220
@
text
@d42 1
a42 1
Class:        BASE
d46 1
a46 1
Release:      20050220
@


1.5.2.1
log
@bump release numbers for OpenPKG 2.3
@
text
@d46 1
a46 1
Release:      2.3.0
d73 2
a74 2
BuildPreReq:  OpenPKG, openpkg >= 2.3.0, make, gcc, flex, bison, gzip
PreReq:       OpenPKG, openpkg >= 2.3.0
d78 2
a79 2
BuildPreReq:  perl, perl-openpkg >= 5.8.3-2.3.0
PreReq:       perl, perl-openpkg >= 5.8.3-2.3.0
@


1.4
log
@modifying package: postgresql7-7.4.7 20050203 -> 20050208
@
text
@d33 1
a33 1
%define       V_pgpool          2.5
d46 1
a46 1
Release:      20050208
@


1.3
log
@modifying package: postgresql7-7.4.7 20050201 -> 20050203
@
text
@d29 1
a29 1
%define       V_libpqxx         2.4.2
d46 1
a46 1
Release:      20050203
@


1.2
log
@upgrading package: postgresql7 7.4.6 -> 7.4.7
@
text
@d33 1
a33 1
%define       V_pgpool          2.4
d46 1
a46 1
Release:      20050201
@


1.1
log
@new package: postgresql7 7.4.6 (PostgreSQL Database)
@
text
@d27 1
a27 1
%define       V_postgresql      7.4.6
d46 1
a46 1
Release:      20050118
@

