postgresql/postgresql.spec

Fri, 03 Aug 2012 15:42:27 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 03 Aug 2012 15:42:27 +0200
changeset 456
f243ce94972c
parent 300
382048971a24
child 500
7911e95d7847
permissions
-rw-r--r--

Import package vendor original specs for necessary manipulations.

     1 ##
     2 ##  postgresql.spec -- OpenPKG RPM Package Specification
     3 ##  Copyright (c) 2000-2010 OpenPKG Foundation e.V. <http://openpkg.net/>
     4 ##
     5 ##  Permission to use, copy, modify, and distribute this software for
     6 ##  any purpose with or without fee is hereby granted, provided that
     7 ##  the above copyright notice and this permission notice appear in all
     8 ##  copies.
     9 ##
    10 ##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    11 ##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    12 ##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    13 ##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
    14 ##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    15 ##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    16 ##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    17 ##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    18 ##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    19 ##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    20 ##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    21 ##  SUCH DAMAGE.
    22 ##
    24 #   package versions
    25 %define       V_postgresql      9.0.0
    26 %define       V_postgresql_dist 9.0.0
    27 %define       V_postgresql_dir  9.0.0
    28 %define       V_libpqxx         3.1
    29 %define       V_perl            5.10.0
    30 %define       V_pgperl          2.0.2
    31 %define       V_psqlodbc        09.00.0200
    32 %define       V_pgjdbc          9.0-801
    33 %define       V_slony1_major    1.2
    34 %define       V_slony1_minor    21
    35 %define       V_pgcluster       1.9.0rc5
    36 %define       V_pgcluster_dir   1706
    37 %define       V_mysqlcompat     1.0b3
    38 %define       V_mysqlcompat_dir 548
    40 #   package information
    41 Name:         postgresql
    42 Summary:      PostgreSQL Database
    43 URL:          http://www.postgresql.org/
    44 Vendor:       PostgreSQL Group
    45 Packager:     OpenPKG Foundation e.V.
    46 Distribution: OpenPKG Community
    47 Class:        BASE
    48 Group:        Database
    49 License:      GPL
    50 Version:      %{V_postgresql}
    51 Release:      20101120
    53 #   package options
    54 %option       with_server       yes
    55 %option       with_cxx          no
    56 %option       with_perl         no
    57 %option       with_odbc         no
    58 %option       with_jdbc         no
    59 %option       with_compat       no
    60 %option       with_tcl          no
    61 %option       with_slony1       no
    62 %option       with_pgcluster    no
    63 %option       with_kerberos     no
    64 %option       with_mysqlcompat  no
    65 %option       with_xml          no
    66 %option       with_uuid         no
    67 %option       with_conversion   no
    69 #   list of sources
    70 Source0:      ftp://ftp.postgresql.org/pub/source/v%{V_postgresql_dir}/postgresql-%{V_postgresql_dist}.tar.bz2
    71 Source1:      http://pqxx.org/download/software/libpqxx/libpqxx-%{V_libpqxx}.tar.gz
    72 Source2:      ftp://gborg.postgresql.org/pub/pgperl/stable/pgperl-%{V_pgperl}.tar.gz
    73 Source3:      ftp://ftp.postgresql.org/pub/odbc/versions/src/psqlodbc-%{V_psqlodbc}.tar.gz
    74 Source4:      http://slony.info/downloads/%{V_slony1_major}/source/slony1-%{V_slony1_major}.%{V_slony1_minor}.tar.bz2
    75 Source5:      http://pgfoundry.org/frs/download.php/%{V_pgcluster_dir}/pgcluster-%{V_pgcluster}.patch.tar.gz
    76 Source6:      http://pgfoundry.org/frs/download.php/%{V_mysqlcompat_dir}/mysqlcompat-%{V_mysqlcompat}.tar.gz
    77 Source7:      http://jdbc.postgresql.org/download/postgresql-jdbc-%{V_pgjdbc}.src.tar.gz
    78 Source8:      rc.postgresql
    79 Source9:      pg_migrate
    80 Source10:     pg_passwd
    81 Patch0:       postgresql.patch
    83 #   build information
    84 Prefix:       %{l_prefix}
    85 BuildRoot:    %{l_buildroot}
    86 BuildPreReq:  OpenPKG, openpkg >= 20060823, make, gcc, flex, bison, gzip
    87 PreReq:       OpenPKG, openpkg >= 20060823
    88 BuildPreReq:  readline, zlib, openssl, getopt
    89 PreReq:       readline, zlib, openssl, getopt
    90 %if "%{with_perl}" == "yes"
    91 BuildPreReq:  perl >= %{V_perl}, perl-openpkg >= %{V_perl}-20061013
    92 PreReq:       perl >= %{V_perl}
    93 %endif
    94 %if "%{with_odbc}" == "yes"
    95 BuildPreReq:  unixodbc
    96 PreReq:       unixodbc
    97 %endif
    98 %if "%{with_jdbc}" == "yes"
    99 BuildPreReq:  java, JAVA-JDK, ant
   100 PreReq:       java, JAVA-JDK
   101 %endif
   102 %if "%{with_tcl}" == "yes"
   103 BuildPreReq:  tcl, tcl::with_x11 = yes, X11
   104 PreReq:       tcl, tcl::with_x11 = yes, X11
   105 %endif
   106 %if "%{with_kerberos}" == "yes"
   107 BuildPreReq:  KERBEROS
   108 PreReq:       KERBEROS
   109 %endif
   110 %if "%{with_xml}" == "yes"
   111 BuildPreReq:  libxml, libxslt, zlib
   112 PreReq:       libxml, libxslt, zlib
   113 %endif
   114 %if "%{with_uuid}" == "yes"
   115 BuildPreReq:  uuid
   116 PreReq:       uuid
   117 %endif
   119 %description
   120     PostgreSQL is a sophisticated Object-Relational Database Management
   121     System (ORDBMS). It is fully ACID compliant and has full support
   122     for foreign keys, joins, views, triggers, and stored procedures (in
   123     multiple languages). It includes most SQL92 and SQL99 data types
   124     and also supports storage of binary large objects. It is the most
   125     advanced Open-Source RDBMS available anywhere.
   127     As an enterprise class RDBMS, PostgreSQL boasts sophisticated
   128     features such as Multi-Version Concurrency Control (MVCC), Point In
   129     Time Recovery (PITR), tablespaces, asynchronous replication, nested
   130     transactions (savepoints), online/hot backups, a sophisticated
   131     query planner/optimizer, and Write Ahead Logging (WAL) for fault
   132     tolerance. It supports international character sets, multibyte
   133     character encodings, Unicode, and it is locale-aware for sorting,
   134     case-sensitivity, and formatting. It is highly scalable both in the
   135     sheer quantity of data it can manage and in the number of concurrent
   136     users it can accommodate.
   138 %track
   139     prog postgresql = {
   140         version   = %{V_postgresql_dist}
   141         url       = ftp://ftp.postgresql.org/pub/source/
   142         regex     = v(\d+\.\d+(\.\d+)*(?:beta\d*)?)
   143         url       = ftp://ftp.postgresql.org/pub/source/v__NEWVER__/
   144         regex     = postgresql-(\d+(\.\d+)+)\.tar\.(bz2|gz)
   145     }
   146     prog postgresql:libpqxx = {
   147         version   = %{V_libpqxx}
   148         url       = http://pqxx.org/development/libpqxx/wiki/DownloadPage
   149         regex     = libpqxx-(__VER__)\.tar\.gz
   150     }
   151     prog postgresql:pgperl = {
   152         version   = %{V_pgperl}
   153         url       = ftp://gborg.postgresql.org/pub/pgperl/stable/
   154         regex     = pgperl-(__VER__)\.tar\.gz
   155     }
   156     prog postgresql:psqlodbc = {
   157         version   = %{V_psqlodbc}
   158         url       = ftp://ftp.postgresql.org/pub/odbc/versions/src/
   159         regex     = psqlodbc-(\d{2}\.\d{2}\.\d{4})\.tar\.gz
   160     }
   161     prog postgresql:jdbc = {
   162         version   = %{V_pgjdbc}
   163         url       = http://jdbc.postgresql.org/download.html
   164         regex     = postgresql-jdbc-(\d+\.\d+-\d+)\.src\.tar\.gz
   165     }
   166     prog postgresql:slony1 = {
   167         version   = %{V_slony1_major}.%{V_slony1_minor}
   168         url       = http://slony.info/downloads/%{V_slony1_major}/source/
   169         regex     = slony1-(\d+\.\d+\.\d+)\.tar\.bz2
   170     }
   171     prog postgresql:pgcluster = {
   172         version   = %{V_pgcluster}.%{V_pgcluster_dir}
   173         url       = http://pgfoundry.org/frs/?group_id=1000072
   174         regex     = /(\d+/pgcluster-__VER__)\.patch\.tar\.gz
   175         transform = "s/^(\\d+)\/pgcluster-(.+)$/$2.$1/; $_"
   176     }
   177     prog postgresql:mysqlcompat = {
   178         version   = %{V_mysqlcompat}.%{V_mysqlcompat_dir}
   179         url       = http://pgfoundry.org/frs/?group_id=1000154
   180         regex     = (\d+/mysqlcompat-__VER__)\.tar\.gz
   181         transform = "s/^(\\d+)\/mysqlcompat-(.+)$/$2.$1/; $_"
   182     }
   184 %prep
   185     %setup -q
   186     %patch -p0
   187 %if "%{with_cxx}" == "yes"
   188     %setup -q -T -D -a 1
   189     case "%{l_platform -t}" in
   190         *-sunos* )
   191             %{l_shtool} subst \
   192                 -e 's;strerror_r(0,0,0);strerror((int)0);g' \
   193                 -e 's;strerror_r((int)0, (char \*)0, (size_t)0);strerror((int)0);g' \
   194                 libpqxx-%{V_libpqxx}/configure
   195             %{l_shtool} subst \
   196                 -e 's;strerror_r(err, buf, sizeof(buf));strerror(err);g' \
   197                 libpqxx-%{V_libpqxx}/src/largeobject.cxx \
   198                 libpqxx-%{V_libpqxx}/configure
   199             %{l_shtool} subst \
   200                 -e 's;\(strerror(err) ==\) -1;\1 (char *)-1;' \
   201                 libpqxx-%{V_libpqxx}/src/largeobject.cxx
   202             ;;
   203     esac
   204     %{l_shtool} subst \
   205         -e 's;^function \(add_compiler_opts() {\);\1;' \
   206         libpqxx-%{V_libpqxx}/configure
   207 %endif
   208 %if "%{with_perl}" == "yes"
   209     %setup -q -T -D -a 2
   210 %endif
   211 %if "%{with_odbc}" == "yes"
   212     %setup -q -T -D -a 3
   213 %endif
   214 %if "%{with_slony1}" == "yes"
   215     %setup -q -T -D -a 4
   216 %endif
   217 %if "%{with_pgcluster}" == "yes"
   218     %setup -q -T -D -a 5
   219     sed -e '/^diff.*libpq\.rc/,/^diff/d' pgcluster-*-patch |\
   220     %{l_patch} -p1
   221 %endif
   222 %if "%{with_mysqlcompat}" == "yes"
   223     %setup -q -T -D -a 6
   224 %endif
   225 %if "%{with_jdbc}" == "yes"
   226     %setup -q -T -D -a 7
   227 %endif
   229     #   adjust source tree
   230     %{l_shtool} subst \
   231         -e 's;\(#define.*DEFAULT_PGSOCKET_DIR[^"]*"\)/tmp\("\);\1%{l_prefix}/var/postgresql/run\2;' \
   232         src/include/pg_config_manual.h
   233     %{l_shtool} subst \
   234         -e 's;^\(sqlmansect *=\).*$;\1 7;' \
   235         src/makefiles/Makefile.solaris
   236 %if "%{with_conversion}" == "yes"
   237     %{l_shtool} subst \
   238         -e '/^SQLSCRIPT =/{x;s/.*/enable_shared = yes/;G;}' \
   239         src/backend/utils/mb/conversion_procs/Makefile
   240     %{l_shtool} subst \
   241         -e '/^all:/{x;s/.*/enable_shared = yes/;G;}' \
   242         src/backend/utils/mb/conversion_procs/proc.mk
   243 %endif
   244 %if "%{with_uuid}" == "yes"
   245     %{l_shtool} subst \
   246         -e '/^SHLIB_LINK/{x;s/.*/enable_shared = yes/;G;}' \
   247         contrib/uuid-ossp/Makefile
   248 %endif
   249     %{l_shtool} subst \
   250         -e 's;# Shared library stuff;enable_shared = yes;g' \
   251         src/pl/plpgsql/src/Makefile
   253 %build
   255     #   configure package
   256     echo "ac_cv_func_isinf=no" >config.cache
   257     export CC="%{l_cc}"
   258     export CFLAGS="%{l_cflags -O}"
   259     export CPPFLAGS="%{l_cppflags readline}"
   260     export LDFLAGS="%{l_ldflags}"
   261     export LIBS=""
   262 %if "%{with_slony1}" == "yes"
   263     CFLAGS="$CFLAGS -pthread"
   264 %endif
   265 %if "%{with_tcl}" == "yes"
   266     CPPFLAGS="$CPPFLAGS %{l_cppflags tcl}"
   267     LDFLAGS="$LDFLAGS -L`%{l_rc} --query x11_libdir`"
   268 %endif
   269 %if "%{with_kerberos}" == "yes"
   270     CPPFLAGS="$CPPFLAGS `krb5-config --cflags`"
   271     LIBS="$LIBS `krb5-config --libs`"
   272 %endif
   273 %if "%{with_pgcluster}" == "yes"
   274     case "%{l_platform -t}" in
   275         *-freebsd* ) LIBS="$LIBS -lcompat" ;;
   276     esac
   277 %endif
   278 %if "%{with_xml}" == "yes"
   279     LIBS="$LIBS -liconv"
   280 %endif
   281     export TAR="%{l_tar}"
   282     export YACC="bison -y"
   283     ./configure \
   284         --cache-file=./config.cache \
   285         --prefix=%{l_prefix} \
   286         --mandir=%{l_prefix}/man \
   287         --sysconfdir=%{l_prefix}/etc/postgresql \
   288         --includedir=%{l_prefix}/include/postgresql \
   289         --with-openssl \
   290         --with-readline \
   291         --with-zlib \
   292 %if "%{with_tcl}" == "yes"
   293         --with-tcl \
   294         --with-tclconfig="%{l_prefix}/lib" \
   295         --with-tkconfig="%{l_prefix}/lib" \
   296 %endif
   297 %if "%{with_slony1}" == "yes"
   298         --enable-thread-safety \
   299 %endif
   300 %if "%{with_kerberos}" == "yes"
   301         --with-krb5 \
   302         --with-krb-srvnam=postgresql \
   303 %endif
   304 %if "%{with_xml}" == "yes"
   305         --with-libxml \
   306         --with-libxslt \
   307 %endif
   308 %if "%{with_uuid}" == "yes"
   309         --with-ossp-uuid \
   310 %endif
   311         --disable-shared
   313     #   build package
   314     %{l_make} %{l_mflags}
   316     #   build C++ bindings (both old and new one)
   317 %if "%{with_cxx}" == "yes"
   318     ln -s `pwd`/src/interfaces/libpq/*.h src/include/
   319     ( cd libpqxx-%{V_libpqxx}
   320       %{l_shtool} subst \
   321           -e 's;\(cut\)\( .*/configitems\)\( -f [0-9]\);\1\3\2;g' \
   322           configure
   323       ( echo "#!/bin/sh"
   324         echo "case \"\$1\" in"
   325         echo "   --includedir ) echo \"`pwd`/../src/include\" ;;"
   326         echo "   --libdir     ) echo \"`pwd`/../src/interfaces/libpq\" ;;"
   327         echo "esac"
   328       ) >pg_config
   329       chmod a+x pg_config
   330       export PG_CONFIG=`pwd`/pg_config
   331       export CC="%{l_cc}"
   332       export CXX="%{l_cxx}"
   333       export CFLAGS="%{l_cflags -O}"
   334       export CXXFLAGS="%{l_cxxflags -O}"
   335       export CPPFLAGS="-I`pwd`/../src/include %{l_cppflags}"
   336       export LDFLAGS="%{l_ldflags}"
   337       export LIBS="-lssl -lcrypto -lcrypt"
   338       case "%{l_platform -t}" in
   339           *-sunos* ) LIBS="$LIBS -lsocket -lnsl" ;;
   340       esac
   341       ./configure \
   342           --disable-shared
   343       %{l_make} %{l_mflags -O}
   344     ) || exit $?
   345 %endif
   347     #   build Perl bindings
   348 %if "%{with_perl}" == "yes"
   349     %{l_prefix}/bin/perl-openpkg prepare
   350     ( cd Pg-%{V_pgperl}
   351       export POSTGRES_INCLUDE=dummy
   352       export POSTGRES_LIB=dummy
   353       %{l_shtool} subst \
   354           -e 's;-I$POSTGRES_INCLUDE;-I../src/interfaces/libpq -I../src/include;' \
   355           -e 's;-L$POSTGRES_LIB;-L../src/interfaces/libpq;' \
   356           -e 's;-lpq;-lpq %{l_ldflags} -lssl -lcrypto -lcrypt;' \
   357           Makefile.PL
   358     ) || exit $?
   359     ( export POSTGRES_INCLUDE=dummy
   360       export POSTGRES_LIB=dummy
   361       %{l_prefix}/bin/perl-openpkg -d Pg-%{V_pgperl} configure build
   362     ) || exit $?
   363 %endif
   365     #   build ODBC driver
   366 %if "%{with_odbc}" == "yes"
   367     ( cd psqlodbc-%{V_psqlodbc}
   368       export CC="%{l_cc}"
   369       export CXX="%{l_cxx}"
   370       export CFLAGS="%{l_cflags -O}"
   371       export CXXFLAGS="%{l_cxxflags -O}"
   372       export CPPFLAGS="-I`pwd`/../src/include"
   373       CPPFLAGS="$CPPFLAGS -I`pwd`/../src/interfaces -I`pwd`/../src/interfaces/libpq"
   374       CPPFLAGS="$CPPFLAGS %{l_cppflags}"
   375       export LDFLAGS="-L`pwd`/../src/interfaces/libpq %{l_ldflags}"
   376       export LIBS="-lssl -lcrypto"
   377       ./configure \
   378           --prefix=%{l_prefix} \
   379           --with-unixodbc=%{l_prefix} \
   380           --with-odbcinst=%{l_prefix}/etc/unixodbc
   381       %{l_make} %{l_mflags -O}
   382     ) || exit $?
   383 %endif
   385     #   build JDBC driver
   386 %if "%{with_jdbc}" == "yes"
   387     ( cd postgresql-jdbc-%{V_pgjdbc}.src
   388       export JAVA_PLATFORM="sun-jdk"
   389       eval `%{l_prefix}/bin/java-toolkit -e`
   390       %{l_prefix}/bin/ant
   391     ) || exit $?
   392 %endif
   394     #   build Slony-1 replication engine
   395 %if "%{with_slony1}" == "yes"
   396     ( cd slony1-%{V_slony1_major}.%{V_slony1_minor}
   397       ln  ../src/pl/plpgsql/src/libplpgsql.so \
   398           ../src/pl/plpgsql/src/plpgsql.so
   399       %{l_shtool} subst \
   400           -e 's;-lpq;-lpq @LIBS@;' \
   401           Makefile.global.in
   402       export CC="%{l_cc}"
   403       export CFLAGS="%{l_cflags -O}"
   404       export CPPFLAGS="%{l_cppflags}"
   405       export LDFLAGS="%{l_ldflags}"
   406       export LIBS="-lssl -lcrypto -lcrypt"
   407       ./configure \
   408           --prefix=%{l_prefix} \
   409           --sysconfdir=%{l_prefix}/etc/postgresql \
   410           --with-pgconfigdir=../src/bin/pg_config \
   411           --with-pgincludedir=../src/include \
   412           --with-pgincludeserverdir=../src/interfaces/libpq \
   413           --with-pglibdir=../src/interfaces/libpq \
   414           --with-pgpkglibdir=../src/pl/plpgsql/src \
   415           --with-pgsharedir=../src/backend/utils/misc
   416       %{l_make} %{l_mflags -O}
   417     ) || exit $?
   418 %endif
   420     #   build OSSP uuid based UUID generator functions
   421 %if "%{with_uuid}" == "yes"
   422     ( cd contrib/uuid-ossp
   423       %{l_make} %{l_mflags}
   424       %{l_make} %{l_mflags} uuid-ossp.so
   425     ) || exit $?
   426 %endif
   428     #   rebuild pg_config with hard-coded path to avoid that it provides
   429     #   dynamically resolved paths which circumvent symlinks, etc.
   430     ( cd src/bin/pg_config
   431       %{l_shtool} subst \
   432           -e 's:find_my_exec(argv.0., mypath):0; strcpy(mypath, "%{l_prefix}/bin/pg_config"):' \
   433           pg_config.c
   434       %{l_make} %{l_mflags}
   435     ) || exit $?
   437 %install
   439     #   perform standard installation procedure
   440     cp /dev/null register.txt
   441     %{l_make} %{l_mflags} install install-docs DESTDIR=$RPM_BUILD_ROOT
   443     #   strip down installation
   444     rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/doc
   445     strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
   446     rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgaccess.1
   447     rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgtclsh.1
   448     rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgtksh.1
   450     #   namespace adjustments to installation
   451     for prog in \
   452         createdb createlang createuser dropdb droplang clusterdb \
   453         dropuser initdb vacuumdb reindexdb; do
   454 %if "%{with_compat}" == "yes"
   455         cmd="ln"
   456 %else
   457         cmd="mv"
   458 %endif
   459         $cmd $RPM_BUILD_ROOT%{l_prefix}/bin/$prog \
   460              $RPM_BUILD_ROOT%{l_prefix}/bin/pg_$prog
   461         $cmd $RPM_BUILD_ROOT%{l_prefix}/man/man1/$prog.1 \
   462              $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_$prog.1
   463     done
   464     ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man7
   465       for man in *.7; do
   466           mv $man pg_$man
   467       done
   468     ) || exit $?
   470     #   create additional directories
   471     %{l_shtool} mkdir -f -p -m 755 \
   472 %if "%{with_slony1}" == "yes" || "%{with_pgcluster}" == "yes"
   473         $RPM_BUILD_ROOT%{l_prefix}/etc/postgresql \
   474 %endif
   475         $RPM_BUILD_ROOT%{l_prefix}/var/postgresql/db \
   476         $RPM_BUILD_ROOT%{l_prefix}/var/postgresql/run
   478     #   install addon utilities
   479     %{l_shtool} install -c -m 755 %{l_value -s -a} \
   480         %{SOURCE pg_migrate} $RPM_BUILD_ROOT%{l_prefix}/bin/
   481     %{l_shtool} install -c -m 755 %{l_value -s -a} \
   482         -e "s;@l_bash@;%{l_bash};g" \
   483         %{SOURCE pg_passwd} $RPM_BUILD_ROOT%{l_prefix}/bin/
   485     #   install C++ bindings (both old and new one)
   486 %if "%{with_cxx}" == "yes"
   487     ( cd libpqxx-%{V_libpqxx}
   488       %{l_shtool} mkdir -f -p -m 755 \
   489           $RPM_BUILD_ROOT%{l_prefix}/include/pqxx
   490       %{l_shtool} install -c -m 644 \
   491           include/pqxx/* \
   492           $RPM_BUILD_ROOT%{l_prefix}/include/pqxx/
   493       rm -f $RPM_BUILD_ROOT%{l_prefix}/include/pqxx/Makefile*
   494       rm -f $RPM_BUILD_ROOT%{l_prefix}/include/pqxx/config.h*
   495       %{l_shtool} install -c -m 644 \
   496           src/.libs/libpqxx.a \
   497           $RPM_BUILD_ROOT%{l_prefix}/lib/
   498     ) || exit $?
   499 %endif
   501     #   install Perl binding
   502 %if "%{with_perl}" == "yes"
   503     ( export POSTGRES_INCLUDE=dummy
   504       export POSTGRES_LIB=dummy
   505       %{l_prefix}/bin/perl-openpkg -d Pg-%{V_pgperl} install
   506     ) || exit $?
   507     %{l_prefix}/bin/perl-openpkg -F perl-openpkg-files fixate cleanup
   508 %else
   509     >perl-openpkg-files
   510 %endif
   512     #   install ODBC driver
   513 %if "%{with_odbc}" == "yes"
   514     ( cd psqlodbc-%{V_psqlodbc}
   515       %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
   516     ) || exit $?
   517 %endif
   519     #   install JDBC driver
   520 %if "%{with_jdbc}" == "yes"
   521     ( cd postgresql-jdbc-%{V_pgjdbc}.src
   522       %{l_shtool} install -c -m 644 \
   523           jars/postgresql.jar $RPM_BUILD_ROOT%{l_prefix}/lib/
   524     ) || exit $?
   525 %endif
   527     #   install Slony-1 replication engine
   528 %if "%{with_slony1}" == "yes"
   529     ( cd slony1-%{V_slony1_major}.%{V_slony1_minor}
   530       %{l_shtool} subst \
   531           -e 's;$(SQL_NAME80);$(SQL_NAME74);g' \
   532           src/xxid/Makefile
   533       %{l_make} %{l_mflags} install \
   534           DESTDIR=$RPM_BUILD_ROOT \
   535           pgconfigdir=%{l_prefix}/bin \
   536           pgincludedir=%{l_prefix}/include/postgresql \
   537           pgincludeserverdir=%{l_prefix}/include/postgresql/libpq \
   538           pglibdir=%{l_prefix}/lib/postgresql \
   539           pgpkglibdir=%{l_prefix}/lib/postgresql \
   540           pgsharedir=%{l_prefix}/share/postgresql
   541       rm -f $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/slony1*v7[34].sql
   542       rm -f $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/xxid.v73.sql
   543       mv $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/xxid.v74.sql \
   544          $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/xxid.sql
   545       ( echo "#   Slony-1 configuration for replication engine slon(1)"
   546         echo "SLON_CLUSTER_NAME=\"example\""
   547         echo "SLON_CONNECT_DBNAME=\"example\""
   548         echo "SLON_CONNECT_USER=\"postgresql\""
   549         echo "SLON_CONNECT_PASS=\"postgresql\""
   550         echo "SLON_CONNECT_HOST=\"localhost\""
   551         echo "SLON_SYNC_INTERVAL=\"10000\""
   552         echo "SLON_SYNC_TIMEOUT=\"60000\""
   553         echo "SLON_SYNC_GROUPSIZE=\"6\""
   554         echo "SLON_SYNC_LOGLEVEL=\"1\""
   555       ) >$RPM_BUILD_ROOT%{l_prefix}/etc/postgresql/slony1.conf
   556     ) || exit $?
   557 %endif
   559     #   install OSSP uuid based UUID generator functions
   560 %if "%{with_uuid}" == "yes"
   561     ( cd contrib/uuid-ossp
   562       %{l_shtool} install -c -m 644 \
   563           uuid-ossp.sql uuid-ossp.so \
   564           $RPM_BUILD_ROOT%{l_prefix}/lib/postgresql/
   565     ) || exit $?
   566 %endif
   568     #   adjust default configuration for hourly auto-vacuum operation
   569     %{l_shtool} subst \
   570         -e 's;^# *\(stats_start_collector *=\) *[^#]*\(#.*\);\1 on \2;' \
   571         -e 's;^# *\(stats_row_level *=\) *[^#]*\(#.*\);\1 on \2;' \
   572         -e 's;^# *\(autovacuum *=\) *[^#]*\(#.*\);\1 on \2;' \
   573         -e 's;^# *\(autovacuum_naptime *=\) *[^#]*\(#.*\);\1 1h \2;' \
   574         $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/postgresql.conf.sample
   576     #   post-adjust pgcluster configuration filenames
   577 %if "%{with_pgcluster}" == "yes"
   578     cp $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/pgreplicate.conf.sample \
   579        $RPM_BUILD_ROOT%{l_prefix}/etc/postgresql/pgreplicate.conf
   580 %endif
   582     #   install MySQL compatibility layer
   583 %if "%{with_mysqlcompat}" == "yes"
   584     %{l_shtool} mkdir -f -p -m 755 \
   585         $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/mysqlcompat
   586     %{l_shtool} install -c -m 644 \
   587         mysqlcompat-%{V_mysqlcompat}/README \
   588         mysqlcompat-%{V_mysqlcompat}/*.sql \
   589         $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/mysqlcompat/
   590 %endif
   592     #   install run-command script
   593     %{l_shtool} mkdir -f -p -m 755 \
   594         $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
   595     %{l_shtool} install -c -m 755 %{l_value -s -a} \
   596         %{SOURCE rc.postgresql} \
   597         $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
   599     #   optionally strip down to client-only installation
   600 %if "%{with_server}" != "yes"
   601     rm -f  $RPM_BUILD_ROOT%{l_prefix}/bin/pg_[a-bd-z]*
   602     rm -f  $RPM_BUILD_ROOT%{l_prefix}/bin/pg_c[a-np-z]*
   603     rm -f  $RPM_BUILD_ROOT%{l_prefix}/bin/pg_controldata
   604     rm -f  $RPM_BUILD_ROOT%{l_prefix}/bin/post*
   605     rm -f  $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_[a-bd-z]*
   606     rm -f  $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_c[a-np-z]*
   607     rm -f  $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_controldata.1
   608     rm -f  $RPM_BUILD_ROOT%{l_prefix}/man/man1/post*
   609     rm -rf $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
   610     rm -rf $RPM_BUILD_ROOT%{l_prefix}/include/postgresql/server
   611     rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/postgresql
   612     rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/postgresql
   613     rm -rf $RPM_BUILD_ROOT%{l_prefix}/var/postgresql
   614 %endif
   616     #   determine installation files
   617     %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
   618 %if "%{with_server}" == "yes"
   619         %{l_files_std} `cat perl-openpkg-files` \
   620 %if "%{with_slony1}" == "yes" || "%{with_pgcluster}" == "yes"
   621         '%config %{l_prefix}/etc/postgresql/*' \
   622 %endif
   623         '%attr(700,%{l_rusr},%{l_rgrp}) %dir %{l_prefix}/var/postgresql/db' \
   624         '%attr(755,%{l_rusr},%{l_rgrp}) %dir %{l_prefix}/var/postgresql/run'
   625 %else
   626         %{l_files_std} `cat perl-openpkg-files`
   627 %endif
   629 %files -f files
   631 %clean
   632     rm -rf $RPM_BUILD_ROOT
   634 %pre
   635 %if "%{with_server}" == "yes"
   636     #   before upgrade, check migration dump, save status and stop service
   637     [ $1 -eq 2 ] || exit 0
   638     if [ -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION -a \
   639          -f $RPM_INSTALL_PREFIX/bin/pg_migrate ]; then
   640         #   database migration dumping hint
   641         v_old_all=`cat $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION`
   642         v_old_maj=`echo "$v_old_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
   643         v_new_all="%{V_postgresql}"
   644         v_new_maj=`echo "$v_new_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
   645         if [ ".$v_old_maj" != ".$v_new_maj" ]; then
   646             ( echo "You are upgrading from PostgreSQL $v_old_all to PostgresSQL $v_new_all,"
   647               echo "which is a major version change. We expect a database incompatibility,"
   648               echo "so a full database backup and restore is required!"
   649             ) | %{l_rpmtool} msg -b -t notice
   650             if [ ".$RPM_POSTGRESQL_MIGRATE" != .ignore ]; then
   651                 if [ ! -f $RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2 ]; then
   652                     ( echo "We are performing a full backup of your existing database"
   653                       echo "($RPM_INSTALL_PREFIX/var/postgresql/db/) for you by running:"
   654                       echo "    \$ $RPM_INSTALL_PREFIX/bin/pg_migrate dump"
   655                       echo "If this fails for some reasons, try to dump your data manually:"
   656                       echo "    \$ $RPM_INSTALL_PREFIX/bin/pg_dumpall -U postgresql -o | \\ "
   657                       echo "      $RPM_INSTALL_PREFIX/lib/openpkg/bzip2 -9 \\ "
   658                       echo "      >$RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2"
   659                       echo "Alternatively, if you want to force this package to be installed without"
   660                       echo "a previously created database dump, run the following command"
   661                       echo "before trying this package upgrade again:"
   662                       echo "    \$ RPM_POSTGRESQL_MIGRATE=ignore; export RPM_POSTGRESQL_MIGRATE"
   663                     ) | %{l_rpmtool} msg -b -t notice
   664                     $RPM_INSTALL_PREFIX/bin/pg_migrate dump
   665                     if [ $? -ne 0 ] || [ ! -f $RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2 ]; then
   666                         ( echo "Automatic database dump creation failed!"
   667                           echo "PLEASE INVESTIGATE MANUALLY YOURSELF!"
   668                         ) | %{l_rpmtool} msg -b -t error
   669                         exit 1
   670                     fi
   671                 fi
   672             fi
   673         fi
   674     fi
   675     eval `%{l_rc} postgresql status 2>/dev/null | tee %{l_tmpfile}`
   676     %{l_rc} postgresql stop 2>/dev/null
   677     exit 0
   678 %endif
   680 %post
   681 %if "%{with_server}" == "yes"
   682 %if "%{with_compat}" == "yes"
   683     l_pguser="postgres"
   684     l_pgpass="postgres"
   685 %else
   686     l_pguser="postgresql"
   687     l_pgpass="postgresql"
   688 %endif
   689     if [ $1 -eq 1 ]; then
   690         #   create initial database
   691         su - %{l_rusr} -c \
   692             "LC_CTYPE=C; export LC_CTYPE; umask 077; \
   693             rm -rf $RPM_INSTALL_PREFIX/var/postgresql/db/*; \
   694             echo $l_pgpass >$RPM_INSTALL_PREFIX/var/postgresql/run/pg_initdb.pw; \
   695             $RPM_INSTALL_PREFIX/bin/pg_initdb \
   696                 --encoding=SQL_ASCII --locale=C --auth=md5 --username=$l_pguser \
   697                 --pwfile=$RPM_INSTALL_PREFIX/var/postgresql/run/pg_initdb.pw \
   698                 --pgdata=$RPM_INSTALL_PREFIX/var/postgresql/db; \
   699             rm -f $RPM_INSTALL_PREFIX/var/postgresql/run/pg_initdb.pw" 2>&1 | \
   700         $RPM_INSTALL_PREFIX/lib/openpkg/shtool prop \
   701             -p "Creating initial PostgreSQL DB in $RPM_INSTALL_PREFIX/var/postgresql/db"
   702         if [ ! -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION ]; then
   703             echo "ERROR: failed to create initial PostgreSQL database" 1>&2
   704             exit 1
   705         fi
   706         ( umask 077
   707           ( echo "##"
   708             echo "##  pg_superuser.conf -- PostgreSQL database superuser configuration"
   709             echo "##"
   710             echo ""
   711             echo "superuser_database=\"template1\""
   712             echo "superuser_username=\"$l_pguser\""
   713             echo "superuser_password=\"$l_pgpass\""
   714             echo ""
   715           ) >$RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf
   716           chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf || exit $?
   717           chmod 600 $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf || exit $?
   718         ) || exit $?
   720         #   display information about next steps
   721         ( echo "An initial PostgreSQL DB was created with the two standard"
   722           echo "databases 'template0' and 'template1'. The owner of both"
   723           echo "is the DB user '$l_pguser'. Its initial password is '$l_pgpass'."
   724           echo ""
   725           echo "After starting PostgreSQL with"
   726           echo "    \$ $RPM_INSTALL_PREFIX/bin/openpkg rc postgresql start"
   727           echo "you should immediately change this with the following command:"
   728           echo "    \$ $RPM_INSTALL_PREFIX/bin/pg_passwd postgresql template1"
   729           echo ""
   730           echo "Then you usually create a database for a user <user> (assuming that"
   731           echo "his home directory is /u/<user>) with password <password> under"
   732           echo "path /u/<user>/rdbms with the commands:"
   733           echo "    \$ mkdir /u/<user>/rdbms"
   734           echo "    \$ chmod 700 /u/<user>/rdbms"
   735           echo "    \$ chown %{l_rusr}:%{l_rgrp} /u/<user>/rdbms"
   736           echo "    \$ $RPM_INSTALL_PREFIX/bin/psql -U $l_pguser -d template1"
   737           echo "    template1=> CREATE ROLE <user>"
   738           echo "                LOGIN ENCRYPTED PASSWORD '<password>'"
   739           echo "                NOCREATEDB NOCREATEROLE;"
   740           echo "    template1=> CREATE TABLESPACE <user> OWNER <user>"
   741           echo "                LOCATION '/u/<user>/rdbms';"
   742           echo "    template1=> CREATE DATABASE <user> OWNER <user>"
   743           echo "                TABLESPACE <user>;"
   744           echo "    \$ echo 'localhost:*:<user>:<user>:<password>' >>/u/<user>/.pgpass"
   745           echo "    \$ chmod 600 <user> /u/<user>/.pgpass"
   746           echo "    \$ chown <user> /u/<user>/.pgpass"
   747           echo "After this the user <user> will be able to connect to his RDBMS with:"
   748           echo "    \$ $RPM_INSTALL_PREFIX/bin/psql"
   749         ) | %{l_rpmtool} msg -b -t notice
   750     fi
   752 %if "%{with_odbc}" == "yes"
   753     #   optionally link into ODBC
   754     if ! $RPM_INSTALL_PREFIX/bin/odbcinst -q -d -n "PostgreSQL" >/dev/null 2>&1; then
   755         ( echo "[PostgreSQL]"
   756           echo "Description     = PostgreSQL ODBC driver"
   757           echo "Driver          = $RPM_INSTALL_PREFIX/lib/psqlodbc.so"
   758           echo "Threading       = 2"
   759         ) | $RPM_INSTALL_PREFIX/bin/odbcinst -i -d -r -n "PostgreSQL"
   760     fi
   761 %endif
   763     if [ $1 -eq 2 ]; then
   764         #   after upgrade, restore status
   765         { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null 2>&1
   766         [ ".$postgresql_active" = .yes ] && %{l_rc} postgresql start
   767         if [   -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION -a \
   768              ! -f $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf ]; then
   769             ( umask 077
   770               ( echo "##"
   771                 echo "##  pg_superuser.conf -- PostgreSQL database superuser configuration"
   772                 echo "##"
   773                 echo ""
   774                 echo "superuser_database=\"template1\""
   775                 echo "superuser_username=\"$l_pguser\""
   776                 echo "superuser_password=\"\""
   777                 echo ""
   778               ) >$RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf
   779               chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf || exit $?
   780               chmod 600 $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf || exit $?
   781             ) || exit $?
   782             ( echo "Created still missing \"pg_superuser.conf\" configuration file."
   783               echo "You should update its content by resetting the PostgreSQL"
   784               echo "superuser account password with the following command:"
   785               echo "    \$ $RPM_INSTALL_PREFIX/bin/pg_passwd postgresql template1"
   786             ) | %{l_rpmtool} msg -b -t warn
   787         fi
   788         if [ -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION -a ".$PG_MIGRATE" != .ignore ]; then
   789             #   database migration restoring hint
   790             v_old_all=`cat $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION`
   791             v_old_maj=`echo "$v_old_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
   792             v_new_all="%{V_postgresql}"
   793             v_new_maj=`echo "$v_new_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
   794             if [ ".$v_old_maj" != ".$v_new_maj" ]; then
   795                 ( echo "You upgraded from PostgreSQL $v_old_all to PostgresSQL $v_new_all,"
   796                   echo "which is a major version upgrade. We expect a database incompatibility,"
   797                   echo "so we strongly recommend you to recreate the existing database under"
   798                   echo "$RPM_INSTALL_PREFIX/var/postgresql/db/ by running the following command:"
   799                   echo "    \$ $RPM_INSTALL_PREFIX/bin/pg_migrate restore"
   800                   echo "If this fails for some reasons, try to restore your data manually:"
   801                   echo "    \$ $RPM_INSTALL_PREFIX/lib/openpkg/bzip2 -d -c \\ "
   802                   echo "      $RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2 | \\ "
   803                   echo "      $RPM_INSTALL_PREFIX/bin/psql -U postgresql -d template1"
   804                 ) | %{l_rpmtool} msg -b -t warn
   805             fi
   806         fi
   807     fi
   808     exit 0
   809 %endif
   811 %preun
   812 %if "%{with_server}" == "yes"
   813     #   before erase, stop service and remove log files
   814     [ $1 -eq 0 ] || exit 0
   815     %{l_rc} postgresql stop 2>/dev/null
   816     rm -f $RPM_INSTALL_PREFIX/var/postgresql/run/* >/dev/null 2>&1 || true
   817     #   optionally unlink from ODBC
   818 %if "%{with_odbc}" == "yes"
   819     $RPM_INSTALL_PREFIX/bin/odbcinst -u -d -n "PostgreSQL"
   820 %endif
   821     exit 0
   822 %endif

mercurial