michael@300: ## michael@300: ## postgresql.spec -- OpenPKG RPM Package Specification michael@300: ## Copyright (c) 2000-2010 OpenPKG Foundation e.V. michael@300: ## michael@300: ## Permission to use, copy, modify, and distribute this software for michael@300: ## any purpose with or without fee is hereby granted, provided that michael@300: ## the above copyright notice and this permission notice appear in all michael@300: ## copies. michael@300: ## michael@300: ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED michael@300: ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF michael@300: ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. michael@300: ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR michael@300: ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, michael@300: ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT michael@300: ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF michael@300: ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND michael@300: ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, michael@300: ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT michael@300: ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF michael@300: ## SUCH DAMAGE. michael@300: ## michael@300: michael@300: # package versions michael@300: %define V_postgresql 9.0.0 michael@300: %define V_postgresql_dist 9.0.0 michael@300: %define V_postgresql_dir 9.0.0 michael@300: %define V_libpqxx 3.1 michael@300: %define V_perl 5.10.0 michael@300: %define V_pgperl 2.0.2 michael@300: %define V_psqlodbc 09.00.0200 michael@300: %define V_pgjdbc 9.0-801 michael@300: %define V_slony1_major 1.2 michael@300: %define V_slony1_minor 21 michael@300: %define V_pgcluster 1.9.0rc5 michael@300: %define V_pgcluster_dir 1706 michael@300: %define V_mysqlcompat 1.0b3 michael@300: %define V_mysqlcompat_dir 548 michael@300: michael@300: # package information michael@300: Name: postgresql michael@300: Summary: PostgreSQL Database michael@300: URL: http://www.postgresql.org/ michael@300: Vendor: PostgreSQL Group michael@300: Packager: OpenPKG Foundation e.V. michael@300: Distribution: OpenPKG Community michael@300: Class: BASE michael@300: Group: Database michael@300: License: GPL michael@300: Version: %{V_postgresql} michael@301: Release: 20101120 michael@300: michael@300: # package options michael@300: %option with_server yes michael@300: %option with_cxx no michael@300: %option with_perl no michael@300: %option with_odbc no michael@300: %option with_jdbc no michael@300: %option with_compat no michael@300: %option with_tcl no michael@300: %option with_slony1 no michael@300: %option with_pgcluster no michael@300: %option with_kerberos no michael@300: %option with_mysqlcompat no michael@300: %option with_xml no michael@300: %option with_uuid no michael@300: %option with_conversion no michael@300: michael@300: # list of sources michael@300: Source0: ftp://ftp.postgresql.org/pub/source/v%{V_postgresql_dir}/postgresql-%{V_postgresql_dist}.tar.bz2 michael@300: Source1: http://pqxx.org/download/software/libpqxx/libpqxx-%{V_libpqxx}.tar.gz michael@300: Source2: ftp://gborg.postgresql.org/pub/pgperl/stable/pgperl-%{V_pgperl}.tar.gz michael@300: Source3: ftp://ftp.postgresql.org/pub/odbc/versions/src/psqlodbc-%{V_psqlodbc}.tar.gz michael@300: Source4: http://slony.info/downloads/%{V_slony1_major}/source/slony1-%{V_slony1_major}.%{V_slony1_minor}.tar.bz2 michael@300: Source5: http://pgfoundry.org/frs/download.php/%{V_pgcluster_dir}/pgcluster-%{V_pgcluster}.patch.tar.gz michael@300: Source6: http://pgfoundry.org/frs/download.php/%{V_mysqlcompat_dir}/mysqlcompat-%{V_mysqlcompat}.tar.gz michael@300: Source7: http://jdbc.postgresql.org/download/postgresql-jdbc-%{V_pgjdbc}.src.tar.gz michael@300: Source8: rc.postgresql michael@300: Source9: pg_migrate michael@300: Source10: pg_passwd michael@300: Patch0: postgresql.patch michael@300: michael@300: # build information michael@301: Prefix: %{l_prefix} michael@301: BuildRoot: %{l_buildroot} michael@301: BuildPreReq: OpenPKG, openpkg >= 20060823, make, gcc, flex, bison, gzip michael@301: PreReq: OpenPKG, openpkg >= 20060823 michael@300: BuildPreReq: readline, zlib, openssl, getopt michael@300: PreReq: readline, zlib, openssl, getopt michael@300: %if "%{with_perl}" == "yes" michael@300: BuildPreReq: perl >= %{V_perl}, perl-openpkg >= %{V_perl}-20061013 michael@300: PreReq: perl >= %{V_perl} michael@300: %endif michael@300: %if "%{with_odbc}" == "yes" michael@300: BuildPreReq: unixodbc michael@300: PreReq: unixodbc michael@300: %endif michael@300: %if "%{with_jdbc}" == "yes" michael@300: BuildPreReq: java, JAVA-JDK, ant michael@300: PreReq: java, JAVA-JDK michael@300: %endif michael@300: %if "%{with_tcl}" == "yes" michael@300: BuildPreReq: tcl, tcl::with_x11 = yes, X11 michael@300: PreReq: tcl, tcl::with_x11 = yes, X11 michael@300: %endif michael@300: %if "%{with_kerberos}" == "yes" michael@300: BuildPreReq: KERBEROS michael@300: PreReq: KERBEROS michael@300: %endif michael@300: %if "%{with_xml}" == "yes" michael@300: BuildPreReq: libxml, libxslt, zlib michael@300: PreReq: libxml, libxslt, zlib michael@300: %endif michael@300: %if "%{with_uuid}" == "yes" michael@300: BuildPreReq: uuid michael@300: PreReq: uuid michael@300: %endif michael@300: michael@300: %description michael@300: PostgreSQL is a sophisticated Object-Relational Database Management michael@300: System (ORDBMS). It is fully ACID compliant and has full support michael@300: for foreign keys, joins, views, triggers, and stored procedures (in michael@300: multiple languages). It includes most SQL92 and SQL99 data types michael@300: and also supports storage of binary large objects. It is the most michael@300: advanced Open-Source RDBMS available anywhere. michael@300: michael@300: As an enterprise class RDBMS, PostgreSQL boasts sophisticated michael@300: features such as Multi-Version Concurrency Control (MVCC), Point In michael@300: Time Recovery (PITR), tablespaces, asynchronous replication, nested michael@300: transactions (savepoints), online/hot backups, a sophisticated michael@300: query planner/optimizer, and Write Ahead Logging (WAL) for fault michael@300: tolerance. It supports international character sets, multibyte michael@300: character encodings, Unicode, and it is locale-aware for sorting, michael@300: case-sensitivity, and formatting. It is highly scalable both in the michael@300: sheer quantity of data it can manage and in the number of concurrent michael@300: users it can accommodate. michael@300: michael@300: %track michael@300: prog postgresql = { michael@300: version = %{V_postgresql_dist} michael@300: url = ftp://ftp.postgresql.org/pub/source/ michael@300: regex = v(\d+\.\d+(\.\d+)*(?:beta\d*)?) michael@300: url = ftp://ftp.postgresql.org/pub/source/v__NEWVER__/ michael@300: regex = postgresql-(\d+(\.\d+)+)\.tar\.(bz2|gz) michael@300: } michael@300: prog postgresql:libpqxx = { michael@300: version = %{V_libpqxx} michael@300: url = http://pqxx.org/development/libpqxx/wiki/DownloadPage michael@300: regex = libpqxx-(__VER__)\.tar\.gz michael@300: } michael@300: prog postgresql:pgperl = { michael@300: version = %{V_pgperl} michael@300: url = ftp://gborg.postgresql.org/pub/pgperl/stable/ michael@300: regex = pgperl-(__VER__)\.tar\.gz michael@300: } michael@300: prog postgresql:psqlodbc = { michael@300: version = %{V_psqlodbc} michael@300: url = ftp://ftp.postgresql.org/pub/odbc/versions/src/ michael@300: regex = psqlodbc-(\d{2}\.\d{2}\.\d{4})\.tar\.gz michael@300: } michael@300: prog postgresql:jdbc = { michael@300: version = %{V_pgjdbc} michael@300: url = http://jdbc.postgresql.org/download.html michael@300: regex = postgresql-jdbc-(\d+\.\d+-\d+)\.src\.tar\.gz michael@300: } michael@300: prog postgresql:slony1 = { michael@300: version = %{V_slony1_major}.%{V_slony1_minor} michael@300: url = http://slony.info/downloads/%{V_slony1_major}/source/ michael@300: regex = slony1-(\d+\.\d+\.\d+)\.tar\.bz2 michael@300: } michael@300: prog postgresql:pgcluster = { michael@300: version = %{V_pgcluster}.%{V_pgcluster_dir} michael@300: url = http://pgfoundry.org/frs/?group_id=1000072 michael@300: regex = /(\d+/pgcluster-__VER__)\.patch\.tar\.gz michael@300: transform = "s/^(\\d+)\/pgcluster-(.+)$/$2.$1/; $_" michael@300: } michael@300: prog postgresql:mysqlcompat = { michael@300: version = %{V_mysqlcompat}.%{V_mysqlcompat_dir} michael@300: url = http://pgfoundry.org/frs/?group_id=1000154 michael@300: regex = (\d+/mysqlcompat-__VER__)\.tar\.gz michael@300: transform = "s/^(\\d+)\/mysqlcompat-(.+)$/$2.$1/; $_" michael@300: } michael@300: michael@300: %prep michael@300: %setup -q michael@300: %patch -p0 michael@300: %if "%{with_cxx}" == "yes" michael@300: %setup -q -T -D -a 1 michael@300: case "%{l_platform -t}" in michael@300: *-sunos* ) michael@300: %{l_shtool} subst \ michael@300: -e 's;strerror_r(0,0,0);strerror((int)0);g' \ michael@300: -e 's;strerror_r((int)0, (char \*)0, (size_t)0);strerror((int)0);g' \ michael@300: libpqxx-%{V_libpqxx}/configure michael@300: %{l_shtool} subst \ michael@300: -e 's;strerror_r(err, buf, sizeof(buf));strerror(err);g' \ michael@300: libpqxx-%{V_libpqxx}/src/largeobject.cxx \ michael@300: libpqxx-%{V_libpqxx}/configure michael@300: %{l_shtool} subst \ michael@300: -e 's;\(strerror(err) ==\) -1;\1 (char *)-1;' \ michael@300: libpqxx-%{V_libpqxx}/src/largeobject.cxx michael@300: ;; michael@300: esac michael@300: %{l_shtool} subst \ michael@300: -e 's;^function \(add_compiler_opts() {\);\1;' \ michael@300: libpqxx-%{V_libpqxx}/configure michael@300: %endif michael@300: %if "%{with_perl}" == "yes" michael@300: %setup -q -T -D -a 2 michael@300: %endif michael@300: %if "%{with_odbc}" == "yes" michael@300: %setup -q -T -D -a 3 michael@300: %endif michael@300: %if "%{with_slony1}" == "yes" michael@300: %setup -q -T -D -a 4 michael@300: %endif michael@300: %if "%{with_pgcluster}" == "yes" michael@300: %setup -q -T -D -a 5 michael@300: sed -e '/^diff.*libpq\.rc/,/^diff/d' pgcluster-*-patch |\ michael@300: %{l_patch} -p1 michael@300: %endif michael@300: %if "%{with_mysqlcompat}" == "yes" michael@300: %setup -q -T -D -a 6 michael@300: %endif michael@300: %if "%{with_jdbc}" == "yes" michael@300: %setup -q -T -D -a 7 michael@300: %endif michael@300: michael@300: # adjust source tree michael@300: %{l_shtool} subst \ michael@300: -e 's;\(#define.*DEFAULT_PGSOCKET_DIR[^"]*"\)/tmp\("\);\1%{l_prefix}/var/postgresql/run\2;' \ michael@300: src/include/pg_config_manual.h michael@300: %{l_shtool} subst \ michael@300: -e 's;^\(sqlmansect *=\).*$;\1 7;' \ michael@300: src/makefiles/Makefile.solaris michael@300: %if "%{with_conversion}" == "yes" michael@300: %{l_shtool} subst \ michael@300: -e '/^SQLSCRIPT =/{x;s/.*/enable_shared = yes/;G;}' \ michael@300: src/backend/utils/mb/conversion_procs/Makefile michael@300: %{l_shtool} subst \ michael@300: -e '/^all:/{x;s/.*/enable_shared = yes/;G;}' \ michael@300: src/backend/utils/mb/conversion_procs/proc.mk michael@300: %endif michael@300: %if "%{with_uuid}" == "yes" michael@300: %{l_shtool} subst \ michael@300: -e '/^SHLIB_LINK/{x;s/.*/enable_shared = yes/;G;}' \ michael@300: contrib/uuid-ossp/Makefile michael@300: %endif michael@300: %{l_shtool} subst \ michael@300: -e 's;# Shared library stuff;enable_shared = yes;g' \ michael@300: src/pl/plpgsql/src/Makefile michael@300: michael@300: %build michael@300: michael@300: # configure package michael@300: echo "ac_cv_func_isinf=no" >config.cache michael@300: export CC="%{l_cc}" michael@300: export CFLAGS="%{l_cflags -O}" michael@300: export CPPFLAGS="%{l_cppflags readline}" michael@300: export LDFLAGS="%{l_ldflags}" michael@300: export LIBS="" michael@300: %if "%{with_slony1}" == "yes" michael@300: CFLAGS="$CFLAGS -pthread" michael@300: %endif michael@300: %if "%{with_tcl}" == "yes" michael@300: CPPFLAGS="$CPPFLAGS %{l_cppflags tcl}" michael@300: LDFLAGS="$LDFLAGS -L`%{l_rc} --query x11_libdir`" michael@300: %endif michael@300: %if "%{with_kerberos}" == "yes" michael@300: CPPFLAGS="$CPPFLAGS `krb5-config --cflags`" michael@300: LIBS="$LIBS `krb5-config --libs`" michael@300: %endif michael@300: %if "%{with_pgcluster}" == "yes" michael@300: case "%{l_platform -t}" in michael@300: *-freebsd* ) LIBS="$LIBS -lcompat" ;; michael@300: esac michael@300: %endif michael@300: %if "%{with_xml}" == "yes" michael@300: LIBS="$LIBS -liconv" michael@300: %endif michael@300: export TAR="%{l_tar}" michael@300: export YACC="bison -y" michael@300: ./configure \ michael@300: --cache-file=./config.cache \ michael@300: --prefix=%{l_prefix} \ michael@300: --mandir=%{l_prefix}/man \ michael@300: --sysconfdir=%{l_prefix}/etc/postgresql \ michael@300: --includedir=%{l_prefix}/include/postgresql \ michael@300: --with-openssl \ michael@300: --with-readline \ michael@300: --with-zlib \ michael@300: %if "%{with_tcl}" == "yes" michael@300: --with-tcl \ michael@300: --with-tclconfig="%{l_prefix}/lib" \ michael@300: --with-tkconfig="%{l_prefix}/lib" \ michael@300: %endif michael@300: %if "%{with_slony1}" == "yes" michael@300: --enable-thread-safety \ michael@300: %endif michael@300: %if "%{with_kerberos}" == "yes" michael@300: --with-krb5 \ michael@300: --with-krb-srvnam=postgresql \ michael@300: %endif michael@300: %if "%{with_xml}" == "yes" michael@300: --with-libxml \ michael@300: --with-libxslt \ michael@300: %endif michael@300: %if "%{with_uuid}" == "yes" michael@300: --with-ossp-uuid \ michael@300: %endif michael@300: --disable-shared michael@300: michael@300: # build package michael@300: %{l_make} %{l_mflags} michael@300: michael@300: # build C++ bindings (both old and new one) michael@300: %if "%{with_cxx}" == "yes" michael@300: ln -s `pwd`/src/interfaces/libpq/*.h src/include/ michael@300: ( cd libpqxx-%{V_libpqxx} michael@300: %{l_shtool} subst \ michael@300: -e 's;\(cut\)\( .*/configitems\)\( -f [0-9]\);\1\3\2;g' \ michael@300: configure michael@300: ( echo "#!/bin/sh" michael@300: echo "case \"\$1\" in" michael@300: echo " --includedir ) echo \"`pwd`/../src/include\" ;;" michael@300: echo " --libdir ) echo \"`pwd`/../src/interfaces/libpq\" ;;" michael@300: echo "esac" michael@300: ) >pg_config michael@300: chmod a+x pg_config michael@300: export PG_CONFIG=`pwd`/pg_config michael@300: export CC="%{l_cc}" michael@300: export CXX="%{l_cxx}" michael@300: export CFLAGS="%{l_cflags -O}" michael@300: export CXXFLAGS="%{l_cxxflags -O}" michael@300: export CPPFLAGS="-I`pwd`/../src/include %{l_cppflags}" michael@300: export LDFLAGS="%{l_ldflags}" michael@300: export LIBS="-lssl -lcrypto -lcrypt" michael@300: case "%{l_platform -t}" in michael@300: *-sunos* ) LIBS="$LIBS -lsocket -lnsl" ;; michael@300: esac michael@300: ./configure \ michael@300: --disable-shared michael@300: %{l_make} %{l_mflags -O} michael@300: ) || exit $? michael@300: %endif michael@300: michael@300: # build Perl bindings michael@300: %if "%{with_perl}" == "yes" michael@300: %{l_prefix}/bin/perl-openpkg prepare michael@300: ( cd Pg-%{V_pgperl} michael@300: export POSTGRES_INCLUDE=dummy michael@300: export POSTGRES_LIB=dummy michael@300: %{l_shtool} subst \ michael@300: -e 's;-I$POSTGRES_INCLUDE;-I../src/interfaces/libpq -I../src/include;' \ michael@300: -e 's;-L$POSTGRES_LIB;-L../src/interfaces/libpq;' \ michael@300: -e 's;-lpq;-lpq %{l_ldflags} -lssl -lcrypto -lcrypt;' \ michael@300: Makefile.PL michael@300: ) || exit $? michael@300: ( export POSTGRES_INCLUDE=dummy michael@300: export POSTGRES_LIB=dummy michael@300: %{l_prefix}/bin/perl-openpkg -d Pg-%{V_pgperl} configure build michael@300: ) || exit $? michael@300: %endif michael@300: michael@300: # build ODBC driver michael@300: %if "%{with_odbc}" == "yes" michael@300: ( cd psqlodbc-%{V_psqlodbc} michael@300: export CC="%{l_cc}" michael@300: export CXX="%{l_cxx}" michael@300: export CFLAGS="%{l_cflags -O}" michael@300: export CXXFLAGS="%{l_cxxflags -O}" michael@300: export CPPFLAGS="-I`pwd`/../src/include" michael@300: CPPFLAGS="$CPPFLAGS -I`pwd`/../src/interfaces -I`pwd`/../src/interfaces/libpq" michael@300: CPPFLAGS="$CPPFLAGS %{l_cppflags}" michael@300: export LDFLAGS="-L`pwd`/../src/interfaces/libpq %{l_ldflags}" michael@300: export LIBS="-lssl -lcrypto" michael@300: ./configure \ michael@300: --prefix=%{l_prefix} \ michael@300: --with-unixodbc=%{l_prefix} \ michael@300: --with-odbcinst=%{l_prefix}/etc/unixodbc michael@300: %{l_make} %{l_mflags -O} michael@300: ) || exit $? michael@300: %endif michael@300: michael@300: # build JDBC driver michael@300: %if "%{with_jdbc}" == "yes" michael@300: ( cd postgresql-jdbc-%{V_pgjdbc}.src michael@300: export JAVA_PLATFORM="sun-jdk" michael@300: eval `%{l_prefix}/bin/java-toolkit -e` michael@300: %{l_prefix}/bin/ant michael@300: ) || exit $? michael@300: %endif michael@300: michael@300: # build Slony-1 replication engine michael@300: %if "%{with_slony1}" == "yes" michael@300: ( cd slony1-%{V_slony1_major}.%{V_slony1_minor} michael@300: ln ../src/pl/plpgsql/src/libplpgsql.so \ michael@300: ../src/pl/plpgsql/src/plpgsql.so michael@300: %{l_shtool} subst \ michael@300: -e 's;-lpq;-lpq @LIBS@;' \ michael@300: Makefile.global.in michael@300: export CC="%{l_cc}" michael@300: export CFLAGS="%{l_cflags -O}" michael@300: export CPPFLAGS="%{l_cppflags}" michael@300: export LDFLAGS="%{l_ldflags}" michael@300: export LIBS="-lssl -lcrypto -lcrypt" michael@300: ./configure \ michael@300: --prefix=%{l_prefix} \ michael@300: --sysconfdir=%{l_prefix}/etc/postgresql \ michael@300: --with-pgconfigdir=../src/bin/pg_config \ michael@300: --with-pgincludedir=../src/include \ michael@300: --with-pgincludeserverdir=../src/interfaces/libpq \ michael@300: --with-pglibdir=../src/interfaces/libpq \ michael@300: --with-pgpkglibdir=../src/pl/plpgsql/src \ michael@300: --with-pgsharedir=../src/backend/utils/misc michael@300: %{l_make} %{l_mflags -O} michael@300: ) || exit $? michael@300: %endif michael@300: michael@300: # build OSSP uuid based UUID generator functions michael@300: %if "%{with_uuid}" == "yes" michael@300: ( cd contrib/uuid-ossp michael@300: %{l_make} %{l_mflags} michael@300: %{l_make} %{l_mflags} uuid-ossp.so michael@300: ) || exit $? michael@300: %endif michael@300: michael@300: # rebuild pg_config with hard-coded path to avoid that it provides michael@300: # dynamically resolved paths which circumvent symlinks, etc. michael@300: ( cd src/bin/pg_config michael@300: %{l_shtool} subst \ michael@300: -e 's:find_my_exec(argv.0., mypath):0; strcpy(mypath, "%{l_prefix}/bin/pg_config"):' \ michael@300: pg_config.c michael@300: %{l_make} %{l_mflags} michael@300: ) || exit $? michael@300: michael@300: %install michael@300: michael@300: # perform standard installation procedure michael@300: cp /dev/null register.txt michael@300: %{l_make} %{l_mflags} install install-docs DESTDIR=$RPM_BUILD_ROOT michael@300: michael@300: # strip down installation michael@300: rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/doc michael@300: strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true michael@300: rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgaccess.1 michael@300: rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgtclsh.1 michael@300: rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgtksh.1 michael@300: michael@300: # namespace adjustments to installation michael@300: for prog in \ michael@300: createdb createlang createuser dropdb droplang clusterdb \ michael@300: dropuser initdb vacuumdb reindexdb; do michael@300: %if "%{with_compat}" == "yes" michael@300: cmd="ln" michael@300: %else michael@300: cmd="mv" michael@300: %endif michael@300: $cmd $RPM_BUILD_ROOT%{l_prefix}/bin/$prog \ michael@300: $RPM_BUILD_ROOT%{l_prefix}/bin/pg_$prog michael@300: $cmd $RPM_BUILD_ROOT%{l_prefix}/man/man1/$prog.1 \ michael@300: $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_$prog.1 michael@300: done michael@300: ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man7 michael@300: for man in *.7; do michael@300: mv $man pg_$man michael@300: done michael@300: ) || exit $? michael@300: michael@300: # create additional directories michael@300: %{l_shtool} mkdir -f -p -m 755 \ michael@300: %if "%{with_slony1}" == "yes" || "%{with_pgcluster}" == "yes" michael@300: $RPM_BUILD_ROOT%{l_prefix}/etc/postgresql \ michael@300: %endif michael@300: $RPM_BUILD_ROOT%{l_prefix}/var/postgresql/db \ michael@300: $RPM_BUILD_ROOT%{l_prefix}/var/postgresql/run michael@300: michael@300: # install addon utilities michael@300: %{l_shtool} install -c -m 755 %{l_value -s -a} \ michael@300: %{SOURCE pg_migrate} $RPM_BUILD_ROOT%{l_prefix}/bin/ michael@300: %{l_shtool} install -c -m 755 %{l_value -s -a} \ michael@300: -e "s;@l_bash@;%{l_bash};g" \ michael@300: %{SOURCE pg_passwd} $RPM_BUILD_ROOT%{l_prefix}/bin/ michael@300: michael@300: # install C++ bindings (both old and new one) michael@300: %if "%{with_cxx}" == "yes" michael@300: ( cd libpqxx-%{V_libpqxx} michael@300: %{l_shtool} mkdir -f -p -m 755 \ michael@300: $RPM_BUILD_ROOT%{l_prefix}/include/pqxx michael@300: %{l_shtool} install -c -m 644 \ michael@300: include/pqxx/* \ michael@300: $RPM_BUILD_ROOT%{l_prefix}/include/pqxx/ michael@300: rm -f $RPM_BUILD_ROOT%{l_prefix}/include/pqxx/Makefile* michael@300: rm -f $RPM_BUILD_ROOT%{l_prefix}/include/pqxx/config.h* michael@300: %{l_shtool} install -c -m 644 \ michael@300: src/.libs/libpqxx.a \ michael@300: $RPM_BUILD_ROOT%{l_prefix}/lib/ michael@300: ) || exit $? michael@300: %endif michael@300: michael@300: # install Perl binding michael@300: %if "%{with_perl}" == "yes" michael@300: ( export POSTGRES_INCLUDE=dummy michael@300: export POSTGRES_LIB=dummy michael@300: %{l_prefix}/bin/perl-openpkg -d Pg-%{V_pgperl} install michael@300: ) || exit $? michael@300: %{l_prefix}/bin/perl-openpkg -F perl-openpkg-files fixate cleanup michael@300: %else michael@300: >perl-openpkg-files michael@300: %endif michael@300: michael@300: # install ODBC driver michael@300: %if "%{with_odbc}" == "yes" michael@300: ( cd psqlodbc-%{V_psqlodbc} michael@300: %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT" michael@300: ) || exit $? michael@300: %endif michael@300: michael@300: # install JDBC driver michael@300: %if "%{with_jdbc}" == "yes" michael@300: ( cd postgresql-jdbc-%{V_pgjdbc}.src michael@300: %{l_shtool} install -c -m 644 \ michael@300: jars/postgresql.jar $RPM_BUILD_ROOT%{l_prefix}/lib/ michael@300: ) || exit $? michael@300: %endif michael@300: michael@300: # install Slony-1 replication engine michael@300: %if "%{with_slony1}" == "yes" michael@300: ( cd slony1-%{V_slony1_major}.%{V_slony1_minor} michael@300: %{l_shtool} subst \ michael@300: -e 's;$(SQL_NAME80);$(SQL_NAME74);g' \ michael@300: src/xxid/Makefile michael@300: %{l_make} %{l_mflags} install \ michael@300: DESTDIR=$RPM_BUILD_ROOT \ michael@300: pgconfigdir=%{l_prefix}/bin \ michael@300: pgincludedir=%{l_prefix}/include/postgresql \ michael@300: pgincludeserverdir=%{l_prefix}/include/postgresql/libpq \ michael@300: pglibdir=%{l_prefix}/lib/postgresql \ michael@300: pgpkglibdir=%{l_prefix}/lib/postgresql \ michael@300: pgsharedir=%{l_prefix}/share/postgresql michael@300: rm -f $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/slony1*v7[34].sql michael@300: rm -f $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/xxid.v73.sql michael@300: mv $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/xxid.v74.sql \ michael@300: $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/xxid.sql michael@300: ( echo "# Slony-1 configuration for replication engine slon(1)" michael@300: echo "SLON_CLUSTER_NAME=\"example\"" michael@300: echo "SLON_CONNECT_DBNAME=\"example\"" michael@300: echo "SLON_CONNECT_USER=\"postgresql\"" michael@300: echo "SLON_CONNECT_PASS=\"postgresql\"" michael@300: echo "SLON_CONNECT_HOST=\"localhost\"" michael@300: echo "SLON_SYNC_INTERVAL=\"10000\"" michael@300: echo "SLON_SYNC_TIMEOUT=\"60000\"" michael@300: echo "SLON_SYNC_GROUPSIZE=\"6\"" michael@300: echo "SLON_SYNC_LOGLEVEL=\"1\"" michael@300: ) >$RPM_BUILD_ROOT%{l_prefix}/etc/postgresql/slony1.conf michael@300: ) || exit $? michael@300: %endif michael@300: michael@300: # install OSSP uuid based UUID generator functions michael@300: %if "%{with_uuid}" == "yes" michael@300: ( cd contrib/uuid-ossp michael@300: %{l_shtool} install -c -m 644 \ michael@300: uuid-ossp.sql uuid-ossp.so \ michael@300: $RPM_BUILD_ROOT%{l_prefix}/lib/postgresql/ michael@300: ) || exit $? michael@300: %endif michael@300: michael@300: # adjust default configuration for hourly auto-vacuum operation michael@300: %{l_shtool} subst \ michael@300: -e 's;^# *\(stats_start_collector *=\) *[^#]*\(#.*\);\1 on \2;' \ michael@300: -e 's;^# *\(stats_row_level *=\) *[^#]*\(#.*\);\1 on \2;' \ michael@300: -e 's;^# *\(autovacuum *=\) *[^#]*\(#.*\);\1 on \2;' \ michael@300: -e 's;^# *\(autovacuum_naptime *=\) *[^#]*\(#.*\);\1 1h \2;' \ michael@300: $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/postgresql.conf.sample michael@300: michael@300: # post-adjust pgcluster configuration filenames michael@300: %if "%{with_pgcluster}" == "yes" michael@300: cp $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/pgreplicate.conf.sample \ michael@300: $RPM_BUILD_ROOT%{l_prefix}/etc/postgresql/pgreplicate.conf michael@300: %endif michael@300: michael@300: # install MySQL compatibility layer michael@300: %if "%{with_mysqlcompat}" == "yes" michael@300: %{l_shtool} mkdir -f -p -m 755 \ michael@300: $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/mysqlcompat michael@300: %{l_shtool} install -c -m 644 \ michael@300: mysqlcompat-%{V_mysqlcompat}/README \ michael@300: mysqlcompat-%{V_mysqlcompat}/*.sql \ michael@300: $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/mysqlcompat/ michael@300: %endif michael@300: michael@300: # install run-command script michael@300: %{l_shtool} mkdir -f -p -m 755 \ michael@300: $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d michael@300: %{l_shtool} install -c -m 755 %{l_value -s -a} \ michael@300: %{SOURCE rc.postgresql} \ michael@300: $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ michael@300: michael@300: # optionally strip down to client-only installation michael@300: %if "%{with_server}" != "yes" michael@300: rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/pg_[a-bd-z]* michael@300: rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/pg_c[a-np-z]* michael@300: rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/pg_controldata michael@300: rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/post* michael@300: rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_[a-bd-z]* michael@300: rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_c[a-np-z]* michael@300: rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_controldata.1 michael@300: rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/post* michael@300: rm -rf $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d michael@300: rm -rf $RPM_BUILD_ROOT%{l_prefix}/include/postgresql/server michael@300: rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/postgresql michael@300: rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/postgresql michael@300: rm -rf $RPM_BUILD_ROOT%{l_prefix}/var/postgresql michael@300: %endif michael@300: michael@300: # determine installation files michael@300: %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \ michael@300: %if "%{with_server}" == "yes" michael@300: %{l_files_std} `cat perl-openpkg-files` \ michael@300: %if "%{with_slony1}" == "yes" || "%{with_pgcluster}" == "yes" michael@300: '%config %{l_prefix}/etc/postgresql/*' \ michael@300: %endif michael@300: '%attr(700,%{l_rusr},%{l_rgrp}) %dir %{l_prefix}/var/postgresql/db' \ michael@300: '%attr(755,%{l_rusr},%{l_rgrp}) %dir %{l_prefix}/var/postgresql/run' michael@300: %else michael@300: %{l_files_std} `cat perl-openpkg-files` michael@300: %endif michael@300: michael@300: %files -f files michael@300: michael@300: %clean michael@301: rm -rf $RPM_BUILD_ROOT michael@300: michael@300: %pre michael@300: %if "%{with_server}" == "yes" michael@300: # before upgrade, check migration dump, save status and stop service michael@300: [ $1 -eq 2 ] || exit 0 michael@300: if [ -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION -a \ michael@300: -f $RPM_INSTALL_PREFIX/bin/pg_migrate ]; then michael@300: # database migration dumping hint michael@300: v_old_all=`cat $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION` michael@300: v_old_maj=`echo "$v_old_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'` michael@300: v_new_all="%{V_postgresql}" michael@300: v_new_maj=`echo "$v_new_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'` michael@300: if [ ".$v_old_maj" != ".$v_new_maj" ]; then michael@300: ( echo "You are upgrading from PostgreSQL $v_old_all to PostgresSQL $v_new_all," michael@300: echo "which is a major version change. We expect a database incompatibility," michael@300: echo "so a full database backup and restore is required!" michael@300: ) | %{l_rpmtool} msg -b -t notice michael@300: if [ ".$RPM_POSTGRESQL_MIGRATE" != .ignore ]; then michael@300: if [ ! -f $RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2 ]; then michael@300: ( echo "We are performing a full backup of your existing database" michael@300: echo "($RPM_INSTALL_PREFIX/var/postgresql/db/) for you by running:" michael@300: echo " \$ $RPM_INSTALL_PREFIX/bin/pg_migrate dump" michael@300: echo "If this fails for some reasons, try to dump your data manually:" michael@300: echo " \$ $RPM_INSTALL_PREFIX/bin/pg_dumpall -U postgresql -o | \\ " michael@300: echo " $RPM_INSTALL_PREFIX/lib/openpkg/bzip2 -9 \\ " michael@300: echo " >$RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2" michael@300: echo "Alternatively, if you want to force this package to be installed without" michael@300: echo "a previously created database dump, run the following command" michael@300: echo "before trying this package upgrade again:" michael@300: echo " \$ RPM_POSTGRESQL_MIGRATE=ignore; export RPM_POSTGRESQL_MIGRATE" michael@300: ) | %{l_rpmtool} msg -b -t notice michael@300: $RPM_INSTALL_PREFIX/bin/pg_migrate dump michael@300: if [ $? -ne 0 ] || [ ! -f $RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2 ]; then michael@300: ( echo "Automatic database dump creation failed!" michael@300: echo "PLEASE INVESTIGATE MANUALLY YOURSELF!" michael@300: ) | %{l_rpmtool} msg -b -t error michael@300: exit 1 michael@300: fi michael@300: fi michael@300: fi michael@300: fi michael@300: fi michael@300: eval `%{l_rc} postgresql status 2>/dev/null | tee %{l_tmpfile}` michael@300: %{l_rc} postgresql stop 2>/dev/null michael@300: exit 0 michael@300: %endif michael@300: michael@300: %post michael@300: %if "%{with_server}" == "yes" michael@300: %if "%{with_compat}" == "yes" michael@300: l_pguser="postgres" michael@300: l_pgpass="postgres" michael@300: %else michael@300: l_pguser="postgresql" michael@300: l_pgpass="postgresql" michael@300: %endif michael@300: if [ $1 -eq 1 ]; then michael@300: # create initial database michael@300: su - %{l_rusr} -c \ michael@300: "LC_CTYPE=C; export LC_CTYPE; umask 077; \ michael@300: rm -rf $RPM_INSTALL_PREFIX/var/postgresql/db/*; \ michael@300: echo $l_pgpass >$RPM_INSTALL_PREFIX/var/postgresql/run/pg_initdb.pw; \ michael@300: $RPM_INSTALL_PREFIX/bin/pg_initdb \ michael@300: --encoding=SQL_ASCII --locale=C --auth=md5 --username=$l_pguser \ michael@300: --pwfile=$RPM_INSTALL_PREFIX/var/postgresql/run/pg_initdb.pw \ michael@300: --pgdata=$RPM_INSTALL_PREFIX/var/postgresql/db; \ michael@300: rm -f $RPM_INSTALL_PREFIX/var/postgresql/run/pg_initdb.pw" 2>&1 | \ michael@300: $RPM_INSTALL_PREFIX/lib/openpkg/shtool prop \ michael@300: -p "Creating initial PostgreSQL DB in $RPM_INSTALL_PREFIX/var/postgresql/db" michael@300: if [ ! -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION ]; then michael@300: echo "ERROR: failed to create initial PostgreSQL database" 1>&2 michael@300: exit 1 michael@300: fi michael@300: ( umask 077 michael@300: ( echo "##" michael@300: echo "## pg_superuser.conf -- PostgreSQL database superuser configuration" michael@300: echo "##" michael@300: echo "" michael@300: echo "superuser_database=\"template1\"" michael@300: echo "superuser_username=\"$l_pguser\"" michael@300: echo "superuser_password=\"$l_pgpass\"" michael@300: echo "" michael@300: ) >$RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf michael@300: chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf || exit $? michael@300: chmod 600 $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf || exit $? michael@300: ) || exit $? michael@300: michael@300: # display information about next steps michael@300: ( echo "An initial PostgreSQL DB was created with the two standard" michael@300: echo "databases 'template0' and 'template1'. The owner of both" michael@300: echo "is the DB user '$l_pguser'. Its initial password is '$l_pgpass'." michael@300: echo "" michael@300: echo "After starting PostgreSQL with" michael@300: echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc postgresql start" michael@300: echo "you should immediately change this with the following command:" michael@300: echo " \$ $RPM_INSTALL_PREFIX/bin/pg_passwd postgresql template1" michael@300: echo "" michael@300: echo "Then you usually create a database for a user (assuming that" michael@300: echo "his home directory is /u/) with password under" michael@300: echo "path /u//rdbms with the commands:" michael@300: echo " \$ mkdir /u//rdbms" michael@300: echo " \$ chmod 700 /u//rdbms" michael@300: echo " \$ chown %{l_rusr}:%{l_rgrp} /u//rdbms" michael@300: echo " \$ $RPM_INSTALL_PREFIX/bin/psql -U $l_pguser -d template1" michael@300: echo " template1=> CREATE ROLE " michael@300: echo " LOGIN ENCRYPTED PASSWORD ''" michael@300: echo " NOCREATEDB NOCREATEROLE;" michael@300: echo " template1=> CREATE TABLESPACE OWNER " michael@300: echo " LOCATION '/u//rdbms';" michael@300: echo " template1=> CREATE DATABASE OWNER " michael@300: echo " TABLESPACE ;" michael@300: echo " \$ echo 'localhost:*:::' >>/u//.pgpass" michael@300: echo " \$ chmod 600 /u//.pgpass" michael@300: echo " \$ chown /u//.pgpass" michael@300: echo "After this the user will be able to connect to his RDBMS with:" michael@300: echo " \$ $RPM_INSTALL_PREFIX/bin/psql" michael@300: ) | %{l_rpmtool} msg -b -t notice michael@300: fi michael@300: michael@300: %if "%{with_odbc}" == "yes" michael@300: # optionally link into ODBC michael@300: if ! $RPM_INSTALL_PREFIX/bin/odbcinst -q -d -n "PostgreSQL" >/dev/null 2>&1; then michael@300: ( echo "[PostgreSQL]" michael@300: echo "Description = PostgreSQL ODBC driver" michael@300: echo "Driver = $RPM_INSTALL_PREFIX/lib/psqlodbc.so" michael@300: echo "Threading = 2" michael@300: ) | $RPM_INSTALL_PREFIX/bin/odbcinst -i -d -r -n "PostgreSQL" michael@300: fi michael@300: %endif michael@300: michael@300: if [ $1 -eq 2 ]; then michael@300: # after upgrade, restore status michael@300: { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null 2>&1 michael@300: [ ".$postgresql_active" = .yes ] && %{l_rc} postgresql start michael@300: if [ -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION -a \ michael@300: ! -f $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf ]; then michael@300: ( umask 077 michael@300: ( echo "##" michael@300: echo "## pg_superuser.conf -- PostgreSQL database superuser configuration" michael@300: echo "##" michael@300: echo "" michael@300: echo "superuser_database=\"template1\"" michael@300: echo "superuser_username=\"$l_pguser\"" michael@300: echo "superuser_password=\"\"" michael@300: echo "" michael@300: ) >$RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf michael@300: chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf || exit $? michael@300: chmod 600 $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf || exit $? michael@300: ) || exit $? michael@300: ( echo "Created still missing \"pg_superuser.conf\" configuration file." michael@300: echo "You should update its content by resetting the PostgreSQL" michael@300: echo "superuser account password with the following command:" michael@300: echo " \$ $RPM_INSTALL_PREFIX/bin/pg_passwd postgresql template1" michael@300: ) | %{l_rpmtool} msg -b -t warn michael@300: fi michael@300: if [ -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION -a ".$PG_MIGRATE" != .ignore ]; then michael@300: # database migration restoring hint michael@300: v_old_all=`cat $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION` michael@300: v_old_maj=`echo "$v_old_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'` michael@300: v_new_all="%{V_postgresql}" michael@300: v_new_maj=`echo "$v_new_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'` michael@300: if [ ".$v_old_maj" != ".$v_new_maj" ]; then michael@300: ( echo "You upgraded from PostgreSQL $v_old_all to PostgresSQL $v_new_all," michael@300: echo "which is a major version upgrade. We expect a database incompatibility," michael@300: echo "so we strongly recommend you to recreate the existing database under" michael@300: echo "$RPM_INSTALL_PREFIX/var/postgresql/db/ by running the following command:" michael@300: echo " \$ $RPM_INSTALL_PREFIX/bin/pg_migrate restore" michael@300: echo "If this fails for some reasons, try to restore your data manually:" michael@300: echo " \$ $RPM_INSTALL_PREFIX/lib/openpkg/bzip2 -d -c \\ " michael@300: echo " $RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2 | \\ " michael@300: echo " $RPM_INSTALL_PREFIX/bin/psql -U postgresql -d template1" michael@300: ) | %{l_rpmtool} msg -b -t warn michael@300: fi michael@300: fi michael@300: fi michael@300: exit 0 michael@300: %endif michael@300: michael@300: %preun michael@300: %if "%{with_server}" == "yes" michael@300: # before erase, stop service and remove log files michael@300: [ $1 -eq 0 ] || exit 0 michael@300: %{l_rc} postgresql stop 2>/dev/null michael@300: rm -f $RPM_INSTALL_PREFIX/var/postgresql/run/* >/dev/null 2>&1 || true michael@300: # optionally unlink from ODBC michael@300: %if "%{with_odbc}" == "yes" michael@300: $RPM_INSTALL_PREFIX/bin/odbcinst -u -d -n "PostgreSQL" michael@300: %endif michael@300: exit 0 michael@300: %endif michael@300: