postgresql/postgresql.spec

Mon, 28 Jan 2013 17:37:18 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Mon, 28 Jan 2013 17:37:18 +0100
changeset 758
a2c6460cfb16
parent 500
7911e95d7847
permissions
-rw-r--r--

Correct socket error reporting improvement with IPv6 portable code,
after helpful recommendation by Saúl Ibarra Corretgé on OSips devlist.

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

mercurial