postgresql/postgresql.spec

changeset 300
382048971a24
child 301
51b6f3cffaff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/postgresql/postgresql.spec	Mon Nov 22 16:54:26 2010 +0100
     1.3 @@ -0,0 +1,820 @@
     1.4 +##
     1.5 +##  postgresql.spec -- OpenPKG RPM Package Specification
     1.6 +##  Copyright (c) 2000-2010 OpenPKG Foundation e.V. <http://openpkg.net/>
     1.7 +##
     1.8 +##  Permission to use, copy, modify, and distribute this software for
     1.9 +##  any purpose with or without fee is hereby granted, provided that
    1.10 +##  the above copyright notice and this permission notice appear in all
    1.11 +##  copies.
    1.12 +##
    1.13 +##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    1.14 +##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    1.15 +##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    1.16 +##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
    1.17 +##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    1.18 +##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    1.19 +##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    1.20 +##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    1.21 +##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    1.22 +##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    1.23 +##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    1.24 +##  SUCH DAMAGE.
    1.25 +##
    1.26 +
    1.27 +#   package versions
    1.28 +%define       V_postgresql      9.0.0
    1.29 +%define       V_postgresql_dist 9.0.0
    1.30 +%define       V_postgresql_dir  9.0.0
    1.31 +%define       V_libpqxx         3.1
    1.32 +%define       V_perl            5.10.0
    1.33 +%define       V_pgperl          2.0.2
    1.34 +%define       V_psqlodbc        09.00.0200
    1.35 +%define       V_pgjdbc          9.0-801
    1.36 +%define       V_slony1_major    1.2
    1.37 +%define       V_slony1_minor    21
    1.38 +%define       V_pgcluster       1.9.0rc5
    1.39 +%define       V_pgcluster_dir   1706
    1.40 +%define       V_mysqlcompat     1.0b3
    1.41 +%define       V_mysqlcompat_dir 548
    1.42 +
    1.43 +#   package information
    1.44 +Name:         postgresql
    1.45 +Summary:      PostgreSQL Database
    1.46 +URL:          http://www.postgresql.org/
    1.47 +Vendor:       PostgreSQL Group
    1.48 +Packager:     OpenPKG Foundation e.V.
    1.49 +Distribution: OpenPKG Community
    1.50 +Class:        BASE
    1.51 +Group:        Database
    1.52 +License:      GPL
    1.53 +Version:      %{V_postgresql}
    1.54 +Release:      20101101
    1.55 +
    1.56 +#   package options
    1.57 +%option       with_server       yes
    1.58 +%option       with_cxx          no
    1.59 +%option       with_perl         no
    1.60 +%option       with_odbc         no
    1.61 +%option       with_jdbc         no
    1.62 +%option       with_compat       no
    1.63 +%option       with_tcl          no
    1.64 +%option       with_slony1       no
    1.65 +%option       with_pgcluster    no
    1.66 +%option       with_kerberos     no
    1.67 +%option       with_mysqlcompat  no
    1.68 +%option       with_xml          no
    1.69 +%option       with_uuid         no
    1.70 +%option       with_conversion   no
    1.71 +
    1.72 +#   list of sources
    1.73 +Source0:      ftp://ftp.postgresql.org/pub/source/v%{V_postgresql_dir}/postgresql-%{V_postgresql_dist}.tar.bz2
    1.74 +Source1:      http://pqxx.org/download/software/libpqxx/libpqxx-%{V_libpqxx}.tar.gz
    1.75 +Source2:      ftp://gborg.postgresql.org/pub/pgperl/stable/pgperl-%{V_pgperl}.tar.gz
    1.76 +Source3:      ftp://ftp.postgresql.org/pub/odbc/versions/src/psqlodbc-%{V_psqlodbc}.tar.gz
    1.77 +Source4:      http://slony.info/downloads/%{V_slony1_major}/source/slony1-%{V_slony1_major}.%{V_slony1_minor}.tar.bz2
    1.78 +Source5:      http://pgfoundry.org/frs/download.php/%{V_pgcluster_dir}/pgcluster-%{V_pgcluster}.patch.tar.gz
    1.79 +Source6:      http://pgfoundry.org/frs/download.php/%{V_mysqlcompat_dir}/mysqlcompat-%{V_mysqlcompat}.tar.gz
    1.80 +Source7:      http://jdbc.postgresql.org/download/postgresql-jdbc-%{V_pgjdbc}.src.tar.gz
    1.81 +Source8:      rc.postgresql
    1.82 +Source9:      pg_migrate
    1.83 +Source10:     pg_passwd
    1.84 +Patch0:       postgresql.patch
    1.85 +
    1.86 +#   build information
    1.87 +BuildPreReq:  OpenPKG, openpkg >= 20100101, make, gcc, flex, bison, gzip
    1.88 +PreReq:       OpenPKG, openpkg >= 20100101
    1.89 +BuildPreReq:  readline, zlib, openssl, getopt
    1.90 +PreReq:       readline, zlib, openssl, getopt
    1.91 +%if "%{with_perl}" == "yes"
    1.92 +BuildPreReq:  perl >= %{V_perl}, perl-openpkg >= %{V_perl}-20061013
    1.93 +PreReq:       perl >= %{V_perl}
    1.94 +%endif
    1.95 +%if "%{with_odbc}" == "yes"
    1.96 +BuildPreReq:  unixodbc
    1.97 +PreReq:       unixodbc
    1.98 +%endif
    1.99 +%if "%{with_jdbc}" == "yes"
   1.100 +BuildPreReq:  java, JAVA-JDK, ant
   1.101 +PreReq:       java, JAVA-JDK
   1.102 +%endif
   1.103 +%if "%{with_tcl}" == "yes"
   1.104 +BuildPreReq:  tcl, tcl::with_x11 = yes, X11
   1.105 +PreReq:       tcl, tcl::with_x11 = yes, X11
   1.106 +%endif
   1.107 +%if "%{with_kerberos}" == "yes"
   1.108 +BuildPreReq:  KERBEROS
   1.109 +PreReq:       KERBEROS
   1.110 +%endif
   1.111 +%if "%{with_xml}" == "yes"
   1.112 +BuildPreReq:  libxml, libxslt, zlib
   1.113 +PreReq:       libxml, libxslt, zlib
   1.114 +%endif
   1.115 +%if "%{with_uuid}" == "yes"
   1.116 +BuildPreReq:  uuid
   1.117 +PreReq:       uuid
   1.118 +%endif
   1.119 +
   1.120 +%description
   1.121 +    PostgreSQL is a sophisticated Object-Relational Database Management
   1.122 +    System (ORDBMS). It is fully ACID compliant and has full support
   1.123 +    for foreign keys, joins, views, triggers, and stored procedures (in
   1.124 +    multiple languages). It includes most SQL92 and SQL99 data types
   1.125 +    and also supports storage of binary large objects. It is the most
   1.126 +    advanced Open-Source RDBMS available anywhere.
   1.127 +
   1.128 +    As an enterprise class RDBMS, PostgreSQL boasts sophisticated
   1.129 +    features such as Multi-Version Concurrency Control (MVCC), Point In
   1.130 +    Time Recovery (PITR), tablespaces, asynchronous replication, nested
   1.131 +    transactions (savepoints), online/hot backups, a sophisticated
   1.132 +    query planner/optimizer, and Write Ahead Logging (WAL) for fault
   1.133 +    tolerance. It supports international character sets, multibyte
   1.134 +    character encodings, Unicode, and it is locale-aware for sorting,
   1.135 +    case-sensitivity, and formatting. It is highly scalable both in the
   1.136 +    sheer quantity of data it can manage and in the number of concurrent
   1.137 +    users it can accommodate.
   1.138 +
   1.139 +%track
   1.140 +    prog postgresql = {
   1.141 +        version   = %{V_postgresql_dist}
   1.142 +        url       = ftp://ftp.postgresql.org/pub/source/
   1.143 +        regex     = v(\d+\.\d+(\.\d+)*(?:beta\d*)?)
   1.144 +        url       = ftp://ftp.postgresql.org/pub/source/v__NEWVER__/
   1.145 +        regex     = postgresql-(\d+(\.\d+)+)\.tar\.(bz2|gz)
   1.146 +    }
   1.147 +    prog postgresql:libpqxx = {
   1.148 +        version   = %{V_libpqxx}
   1.149 +        url       = http://pqxx.org/development/libpqxx/wiki/DownloadPage
   1.150 +        regex     = libpqxx-(__VER__)\.tar\.gz
   1.151 +    }
   1.152 +    prog postgresql:pgperl = {
   1.153 +        version   = %{V_pgperl}
   1.154 +        url       = ftp://gborg.postgresql.org/pub/pgperl/stable/
   1.155 +        regex     = pgperl-(__VER__)\.tar\.gz
   1.156 +    }
   1.157 +    prog postgresql:psqlodbc = {
   1.158 +        version   = %{V_psqlodbc}
   1.159 +        url       = ftp://ftp.postgresql.org/pub/odbc/versions/src/
   1.160 +        regex     = psqlodbc-(\d{2}\.\d{2}\.\d{4})\.tar\.gz
   1.161 +    }
   1.162 +    prog postgresql:jdbc = {
   1.163 +        version   = %{V_pgjdbc}
   1.164 +        url       = http://jdbc.postgresql.org/download.html
   1.165 +        regex     = postgresql-jdbc-(\d+\.\d+-\d+)\.src\.tar\.gz
   1.166 +    }
   1.167 +    prog postgresql:slony1 = {
   1.168 +        version   = %{V_slony1_major}.%{V_slony1_minor}
   1.169 +        url       = http://slony.info/downloads/%{V_slony1_major}/source/
   1.170 +        regex     = slony1-(\d+\.\d+\.\d+)\.tar\.bz2
   1.171 +    }
   1.172 +    prog postgresql:pgcluster = {
   1.173 +        version   = %{V_pgcluster}.%{V_pgcluster_dir}
   1.174 +        url       = http://pgfoundry.org/frs/?group_id=1000072
   1.175 +        regex     = /(\d+/pgcluster-__VER__)\.patch\.tar\.gz
   1.176 +        transform = "s/^(\\d+)\/pgcluster-(.+)$/$2.$1/; $_"
   1.177 +    }
   1.178 +    prog postgresql:mysqlcompat = {
   1.179 +        version   = %{V_mysqlcompat}.%{V_mysqlcompat_dir}
   1.180 +        url       = http://pgfoundry.org/frs/?group_id=1000154
   1.181 +        regex     = (\d+/mysqlcompat-__VER__)\.tar\.gz
   1.182 +        transform = "s/^(\\d+)\/mysqlcompat-(.+)$/$2.$1/; $_"
   1.183 +    }
   1.184 +
   1.185 +%prep
   1.186 +    %setup -q
   1.187 +    %patch -p0
   1.188 +%if "%{with_cxx}" == "yes"
   1.189 +    %setup -q -T -D -a 1
   1.190 +    case "%{l_platform -t}" in
   1.191 +        *-sunos* )
   1.192 +            %{l_shtool} subst \
   1.193 +                -e 's;strerror_r(0,0,0);strerror((int)0);g' \
   1.194 +                -e 's;strerror_r((int)0, (char \*)0, (size_t)0);strerror((int)0);g' \
   1.195 +                libpqxx-%{V_libpqxx}/configure
   1.196 +            %{l_shtool} subst \
   1.197 +                -e 's;strerror_r(err, buf, sizeof(buf));strerror(err);g' \
   1.198 +                libpqxx-%{V_libpqxx}/src/largeobject.cxx \
   1.199 +                libpqxx-%{V_libpqxx}/configure
   1.200 +            %{l_shtool} subst \
   1.201 +                -e 's;\(strerror(err) ==\) -1;\1 (char *)-1;' \
   1.202 +                libpqxx-%{V_libpqxx}/src/largeobject.cxx
   1.203 +            ;;
   1.204 +    esac
   1.205 +    %{l_shtool} subst \
   1.206 +        -e 's;^function \(add_compiler_opts() {\);\1;' \
   1.207 +        libpqxx-%{V_libpqxx}/configure
   1.208 +%endif
   1.209 +%if "%{with_perl}" == "yes"
   1.210 +    %setup -q -T -D -a 2
   1.211 +%endif
   1.212 +%if "%{with_odbc}" == "yes"
   1.213 +    %setup -q -T -D -a 3
   1.214 +%endif
   1.215 +%if "%{with_slony1}" == "yes"
   1.216 +    %setup -q -T -D -a 4
   1.217 +%endif
   1.218 +%if "%{with_pgcluster}" == "yes"
   1.219 +    %setup -q -T -D -a 5
   1.220 +    sed -e '/^diff.*libpq\.rc/,/^diff/d' pgcluster-*-patch |\
   1.221 +    %{l_patch} -p1
   1.222 +%endif
   1.223 +%if "%{with_mysqlcompat}" == "yes"
   1.224 +    %setup -q -T -D -a 6
   1.225 +%endif
   1.226 +%if "%{with_jdbc}" == "yes"
   1.227 +    %setup -q -T -D -a 7
   1.228 +%endif
   1.229 +
   1.230 +    #   adjust source tree
   1.231 +    %{l_shtool} subst \
   1.232 +        -e 's;\(#define.*DEFAULT_PGSOCKET_DIR[^"]*"\)/tmp\("\);\1%{l_prefix}/var/postgresql/run\2;' \
   1.233 +        src/include/pg_config_manual.h
   1.234 +    %{l_shtool} subst \
   1.235 +        -e 's;^\(sqlmansect *=\).*$;\1 7;' \
   1.236 +        src/makefiles/Makefile.solaris
   1.237 +%if "%{with_conversion}" == "yes"
   1.238 +    %{l_shtool} subst \
   1.239 +        -e '/^SQLSCRIPT =/{x;s/.*/enable_shared = yes/;G;}' \
   1.240 +        src/backend/utils/mb/conversion_procs/Makefile
   1.241 +    %{l_shtool} subst \
   1.242 +        -e '/^all:/{x;s/.*/enable_shared = yes/;G;}' \
   1.243 +        src/backend/utils/mb/conversion_procs/proc.mk
   1.244 +%endif
   1.245 +%if "%{with_uuid}" == "yes"
   1.246 +    %{l_shtool} subst \
   1.247 +        -e '/^SHLIB_LINK/{x;s/.*/enable_shared = yes/;G;}' \
   1.248 +        contrib/uuid-ossp/Makefile
   1.249 +%endif
   1.250 +    %{l_shtool} subst \
   1.251 +        -e 's;# Shared library stuff;enable_shared = yes;g' \
   1.252 +        src/pl/plpgsql/src/Makefile
   1.253 +
   1.254 +%build
   1.255 +
   1.256 +    #   configure package
   1.257 +    echo "ac_cv_func_isinf=no" >config.cache
   1.258 +    export CC="%{l_cc}"
   1.259 +    export CFLAGS="%{l_cflags -O}"
   1.260 +    export CPPFLAGS="%{l_cppflags readline}"
   1.261 +    export LDFLAGS="%{l_ldflags}"
   1.262 +    export LIBS=""
   1.263 +%if "%{with_slony1}" == "yes"
   1.264 +    CFLAGS="$CFLAGS -pthread"
   1.265 +%endif
   1.266 +%if "%{with_tcl}" == "yes"
   1.267 +    CPPFLAGS="$CPPFLAGS %{l_cppflags tcl}"
   1.268 +    LDFLAGS="$LDFLAGS -L`%{l_rc} --query x11_libdir`"
   1.269 +%endif
   1.270 +%if "%{with_kerberos}" == "yes"
   1.271 +    CPPFLAGS="$CPPFLAGS `krb5-config --cflags`"
   1.272 +    LIBS="$LIBS `krb5-config --libs`"
   1.273 +%endif
   1.274 +%if "%{with_pgcluster}" == "yes"
   1.275 +    case "%{l_platform -t}" in
   1.276 +        *-freebsd* ) LIBS="$LIBS -lcompat" ;;
   1.277 +    esac
   1.278 +%endif
   1.279 +%if "%{with_xml}" == "yes"
   1.280 +    LIBS="$LIBS -liconv"
   1.281 +%endif
   1.282 +    export TAR="%{l_tar}"
   1.283 +    export YACC="bison -y"
   1.284 +    ./configure \
   1.285 +        --cache-file=./config.cache \
   1.286 +        --prefix=%{l_prefix} \
   1.287 +        --mandir=%{l_prefix}/man \
   1.288 +        --sysconfdir=%{l_prefix}/etc/postgresql \
   1.289 +        --includedir=%{l_prefix}/include/postgresql \
   1.290 +        --with-openssl \
   1.291 +        --with-readline \
   1.292 +        --with-zlib \
   1.293 +%if "%{with_tcl}" == "yes"
   1.294 +        --with-tcl \
   1.295 +        --with-tclconfig="%{l_prefix}/lib" \
   1.296 +        --with-tkconfig="%{l_prefix}/lib" \
   1.297 +%endif
   1.298 +%if "%{with_slony1}" == "yes"
   1.299 +        --enable-thread-safety \
   1.300 +%endif
   1.301 +%if "%{with_kerberos}" == "yes"
   1.302 +        --with-krb5 \
   1.303 +        --with-krb-srvnam=postgresql \
   1.304 +%endif
   1.305 +%if "%{with_xml}" == "yes"
   1.306 +        --with-libxml \
   1.307 +        --with-libxslt \
   1.308 +%endif
   1.309 +%if "%{with_uuid}" == "yes"
   1.310 +        --with-ossp-uuid \
   1.311 +%endif
   1.312 +        --disable-shared
   1.313 +
   1.314 +    #   build package
   1.315 +    %{l_make} %{l_mflags}
   1.316 +
   1.317 +    #   build C++ bindings (both old and new one)
   1.318 +%if "%{with_cxx}" == "yes"
   1.319 +    ln -s `pwd`/src/interfaces/libpq/*.h src/include/
   1.320 +    ( cd libpqxx-%{V_libpqxx}
   1.321 +      %{l_shtool} subst \
   1.322 +          -e 's;\(cut\)\( .*/configitems\)\( -f [0-9]\);\1\3\2;g' \
   1.323 +          configure
   1.324 +      ( echo "#!/bin/sh"
   1.325 +        echo "case \"\$1\" in"
   1.326 +        echo "   --includedir ) echo \"`pwd`/../src/include\" ;;"
   1.327 +        echo "   --libdir     ) echo \"`pwd`/../src/interfaces/libpq\" ;;"
   1.328 +        echo "esac"
   1.329 +      ) >pg_config
   1.330 +      chmod a+x pg_config
   1.331 +      export PG_CONFIG=`pwd`/pg_config
   1.332 +      export CC="%{l_cc}"
   1.333 +      export CXX="%{l_cxx}"
   1.334 +      export CFLAGS="%{l_cflags -O}"
   1.335 +      export CXXFLAGS="%{l_cxxflags -O}"
   1.336 +      export CPPFLAGS="-I`pwd`/../src/include %{l_cppflags}"
   1.337 +      export LDFLAGS="%{l_ldflags}"
   1.338 +      export LIBS="-lssl -lcrypto -lcrypt"
   1.339 +      case "%{l_platform -t}" in
   1.340 +          *-sunos* ) LIBS="$LIBS -lsocket -lnsl" ;;
   1.341 +      esac
   1.342 +      ./configure \
   1.343 +          --disable-shared
   1.344 +      %{l_make} %{l_mflags -O}
   1.345 +    ) || exit $?
   1.346 +%endif
   1.347 +
   1.348 +    #   build Perl bindings
   1.349 +%if "%{with_perl}" == "yes"
   1.350 +    %{l_prefix}/bin/perl-openpkg prepare
   1.351 +    ( cd Pg-%{V_pgperl}
   1.352 +      export POSTGRES_INCLUDE=dummy
   1.353 +      export POSTGRES_LIB=dummy
   1.354 +      %{l_shtool} subst \
   1.355 +          -e 's;-I$POSTGRES_INCLUDE;-I../src/interfaces/libpq -I../src/include;' \
   1.356 +          -e 's;-L$POSTGRES_LIB;-L../src/interfaces/libpq;' \
   1.357 +          -e 's;-lpq;-lpq %{l_ldflags} -lssl -lcrypto -lcrypt;' \
   1.358 +          Makefile.PL
   1.359 +    ) || exit $?
   1.360 +    ( export POSTGRES_INCLUDE=dummy
   1.361 +      export POSTGRES_LIB=dummy
   1.362 +      %{l_prefix}/bin/perl-openpkg -d Pg-%{V_pgperl} configure build
   1.363 +    ) || exit $?
   1.364 +%endif
   1.365 +
   1.366 +    #   build ODBC driver
   1.367 +%if "%{with_odbc}" == "yes"
   1.368 +    ( cd psqlodbc-%{V_psqlodbc}
   1.369 +      export CC="%{l_cc}"
   1.370 +      export CXX="%{l_cxx}"
   1.371 +      export CFLAGS="%{l_cflags -O}"
   1.372 +      export CXXFLAGS="%{l_cxxflags -O}"
   1.373 +      export CPPFLAGS="-I`pwd`/../src/include"
   1.374 +      CPPFLAGS="$CPPFLAGS -I`pwd`/../src/interfaces -I`pwd`/../src/interfaces/libpq"
   1.375 +      CPPFLAGS="$CPPFLAGS %{l_cppflags}"
   1.376 +      export LDFLAGS="-L`pwd`/../src/interfaces/libpq %{l_ldflags}"
   1.377 +      export LIBS="-lssl -lcrypto"
   1.378 +      ./configure \
   1.379 +          --prefix=%{l_prefix} \
   1.380 +          --with-unixodbc=%{l_prefix} \
   1.381 +          --with-odbcinst=%{l_prefix}/etc/unixodbc
   1.382 +      %{l_make} %{l_mflags -O}
   1.383 +    ) || exit $?
   1.384 +%endif
   1.385 +
   1.386 +    #   build JDBC driver
   1.387 +%if "%{with_jdbc}" == "yes"
   1.388 +    ( cd postgresql-jdbc-%{V_pgjdbc}.src
   1.389 +      export JAVA_PLATFORM="sun-jdk"
   1.390 +      eval `%{l_prefix}/bin/java-toolkit -e`
   1.391 +      %{l_prefix}/bin/ant
   1.392 +    ) || exit $?
   1.393 +%endif
   1.394 +
   1.395 +    #   build Slony-1 replication engine
   1.396 +%if "%{with_slony1}" == "yes"
   1.397 +    ( cd slony1-%{V_slony1_major}.%{V_slony1_minor}
   1.398 +      ln  ../src/pl/plpgsql/src/libplpgsql.so \
   1.399 +          ../src/pl/plpgsql/src/plpgsql.so
   1.400 +      %{l_shtool} subst \
   1.401 +          -e 's;-lpq;-lpq @LIBS@;' \
   1.402 +          Makefile.global.in
   1.403 +      export CC="%{l_cc}"
   1.404 +      export CFLAGS="%{l_cflags -O}"
   1.405 +      export CPPFLAGS="%{l_cppflags}"
   1.406 +      export LDFLAGS="%{l_ldflags}"
   1.407 +      export LIBS="-lssl -lcrypto -lcrypt"
   1.408 +      ./configure \
   1.409 +          --prefix=%{l_prefix} \
   1.410 +          --sysconfdir=%{l_prefix}/etc/postgresql \
   1.411 +          --with-pgconfigdir=../src/bin/pg_config \
   1.412 +          --with-pgincludedir=../src/include \
   1.413 +          --with-pgincludeserverdir=../src/interfaces/libpq \
   1.414 +          --with-pglibdir=../src/interfaces/libpq \
   1.415 +          --with-pgpkglibdir=../src/pl/plpgsql/src \
   1.416 +          --with-pgsharedir=../src/backend/utils/misc
   1.417 +      %{l_make} %{l_mflags -O}
   1.418 +    ) || exit $?
   1.419 +%endif
   1.420 +
   1.421 +    #   build OSSP uuid based UUID generator functions
   1.422 +%if "%{with_uuid}" == "yes"
   1.423 +    ( cd contrib/uuid-ossp
   1.424 +      %{l_make} %{l_mflags}
   1.425 +      %{l_make} %{l_mflags} uuid-ossp.so
   1.426 +    ) || exit $?
   1.427 +%endif
   1.428 +
   1.429 +    #   rebuild pg_config with hard-coded path to avoid that it provides
   1.430 +    #   dynamically resolved paths which circumvent symlinks, etc.
   1.431 +    ( cd src/bin/pg_config
   1.432 +      %{l_shtool} subst \
   1.433 +          -e 's:find_my_exec(argv.0., mypath):0; strcpy(mypath, "%{l_prefix}/bin/pg_config"):' \
   1.434 +          pg_config.c
   1.435 +      %{l_make} %{l_mflags}
   1.436 +    ) || exit $?
   1.437 +
   1.438 +%install
   1.439 +
   1.440 +    #   perform standard installation procedure
   1.441 +    cp /dev/null register.txt
   1.442 +    %{l_make} %{l_mflags} install install-docs DESTDIR=$RPM_BUILD_ROOT
   1.443 +
   1.444 +    #   strip down installation
   1.445 +    rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/doc
   1.446 +    strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
   1.447 +    rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgaccess.1
   1.448 +    rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgtclsh.1
   1.449 +    rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgtksh.1
   1.450 +
   1.451 +    #   namespace adjustments to installation
   1.452 +    for prog in \
   1.453 +        createdb createlang createuser dropdb droplang clusterdb \
   1.454 +        dropuser initdb vacuumdb reindexdb; do
   1.455 +%if "%{with_compat}" == "yes"
   1.456 +        cmd="ln"
   1.457 +%else
   1.458 +        cmd="mv"
   1.459 +%endif
   1.460 +        $cmd $RPM_BUILD_ROOT%{l_prefix}/bin/$prog \
   1.461 +             $RPM_BUILD_ROOT%{l_prefix}/bin/pg_$prog
   1.462 +        $cmd $RPM_BUILD_ROOT%{l_prefix}/man/man1/$prog.1 \
   1.463 +             $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_$prog.1
   1.464 +    done
   1.465 +    ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man7
   1.466 +      for man in *.7; do
   1.467 +          mv $man pg_$man
   1.468 +      done
   1.469 +    ) || exit $?
   1.470 +
   1.471 +    #   create additional directories
   1.472 +    %{l_shtool} mkdir -f -p -m 755 \
   1.473 +%if "%{with_slony1}" == "yes" || "%{with_pgcluster}" == "yes"
   1.474 +        $RPM_BUILD_ROOT%{l_prefix}/etc/postgresql \
   1.475 +%endif
   1.476 +        $RPM_BUILD_ROOT%{l_prefix}/var/postgresql/db \
   1.477 +        $RPM_BUILD_ROOT%{l_prefix}/var/postgresql/run
   1.478 +
   1.479 +    #   install addon utilities
   1.480 +    %{l_shtool} install -c -m 755 %{l_value -s -a} \
   1.481 +        %{SOURCE pg_migrate} $RPM_BUILD_ROOT%{l_prefix}/bin/
   1.482 +    %{l_shtool} install -c -m 755 %{l_value -s -a} \
   1.483 +        -e "s;@l_bash@;%{l_bash};g" \
   1.484 +        %{SOURCE pg_passwd} $RPM_BUILD_ROOT%{l_prefix}/bin/
   1.485 +
   1.486 +    #   install C++ bindings (both old and new one)
   1.487 +%if "%{with_cxx}" == "yes"
   1.488 +    ( cd libpqxx-%{V_libpqxx}
   1.489 +      %{l_shtool} mkdir -f -p -m 755 \
   1.490 +          $RPM_BUILD_ROOT%{l_prefix}/include/pqxx
   1.491 +      %{l_shtool} install -c -m 644 \
   1.492 +          include/pqxx/* \
   1.493 +          $RPM_BUILD_ROOT%{l_prefix}/include/pqxx/
   1.494 +      rm -f $RPM_BUILD_ROOT%{l_prefix}/include/pqxx/Makefile*
   1.495 +      rm -f $RPM_BUILD_ROOT%{l_prefix}/include/pqxx/config.h*
   1.496 +      %{l_shtool} install -c -m 644 \
   1.497 +          src/.libs/libpqxx.a \
   1.498 +          $RPM_BUILD_ROOT%{l_prefix}/lib/
   1.499 +    ) || exit $?
   1.500 +%endif
   1.501 +
   1.502 +    #   install Perl binding
   1.503 +%if "%{with_perl}" == "yes"
   1.504 +    ( export POSTGRES_INCLUDE=dummy
   1.505 +      export POSTGRES_LIB=dummy
   1.506 +      %{l_prefix}/bin/perl-openpkg -d Pg-%{V_pgperl} install
   1.507 +    ) || exit $?
   1.508 +    %{l_prefix}/bin/perl-openpkg -F perl-openpkg-files fixate cleanup
   1.509 +%else
   1.510 +    >perl-openpkg-files
   1.511 +%endif
   1.512 +
   1.513 +    #   install ODBC driver
   1.514 +%if "%{with_odbc}" == "yes"
   1.515 +    ( cd psqlodbc-%{V_psqlodbc}
   1.516 +      %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
   1.517 +    ) || exit $?
   1.518 +%endif
   1.519 +
   1.520 +    #   install JDBC driver
   1.521 +%if "%{with_jdbc}" == "yes"
   1.522 +    ( cd postgresql-jdbc-%{V_pgjdbc}.src
   1.523 +      %{l_shtool} install -c -m 644 \
   1.524 +          jars/postgresql.jar $RPM_BUILD_ROOT%{l_prefix}/lib/
   1.525 +    ) || exit $?
   1.526 +%endif
   1.527 +
   1.528 +    #   install Slony-1 replication engine
   1.529 +%if "%{with_slony1}" == "yes"
   1.530 +    ( cd slony1-%{V_slony1_major}.%{V_slony1_minor}
   1.531 +      %{l_shtool} subst \
   1.532 +          -e 's;$(SQL_NAME80);$(SQL_NAME74);g' \
   1.533 +          src/xxid/Makefile
   1.534 +      %{l_make} %{l_mflags} install \
   1.535 +          DESTDIR=$RPM_BUILD_ROOT \
   1.536 +          pgconfigdir=%{l_prefix}/bin \
   1.537 +          pgincludedir=%{l_prefix}/include/postgresql \
   1.538 +          pgincludeserverdir=%{l_prefix}/include/postgresql/libpq \
   1.539 +          pglibdir=%{l_prefix}/lib/postgresql \
   1.540 +          pgpkglibdir=%{l_prefix}/lib/postgresql \
   1.541 +          pgsharedir=%{l_prefix}/share/postgresql
   1.542 +      rm -f $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/slony1*v7[34].sql
   1.543 +      rm -f $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/xxid.v73.sql
   1.544 +      mv $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/xxid.v74.sql \
   1.545 +         $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/xxid.sql
   1.546 +      ( echo "#   Slony-1 configuration for replication engine slon(1)"
   1.547 +        echo "SLON_CLUSTER_NAME=\"example\""
   1.548 +        echo "SLON_CONNECT_DBNAME=\"example\""
   1.549 +        echo "SLON_CONNECT_USER=\"postgresql\""
   1.550 +        echo "SLON_CONNECT_PASS=\"postgresql\""
   1.551 +        echo "SLON_CONNECT_HOST=\"localhost\""
   1.552 +        echo "SLON_SYNC_INTERVAL=\"10000\""
   1.553 +        echo "SLON_SYNC_TIMEOUT=\"60000\""
   1.554 +        echo "SLON_SYNC_GROUPSIZE=\"6\""
   1.555 +        echo "SLON_SYNC_LOGLEVEL=\"1\""
   1.556 +      ) >$RPM_BUILD_ROOT%{l_prefix}/etc/postgresql/slony1.conf
   1.557 +    ) || exit $?
   1.558 +%endif
   1.559 +
   1.560 +    #   install OSSP uuid based UUID generator functions
   1.561 +%if "%{with_uuid}" == "yes"
   1.562 +    ( cd contrib/uuid-ossp
   1.563 +      %{l_shtool} install -c -m 644 \
   1.564 +          uuid-ossp.sql uuid-ossp.so \
   1.565 +          $RPM_BUILD_ROOT%{l_prefix}/lib/postgresql/
   1.566 +    ) || exit $?
   1.567 +%endif
   1.568 +
   1.569 +    #   adjust default configuration for hourly auto-vacuum operation
   1.570 +    %{l_shtool} subst \
   1.571 +        -e 's;^# *\(stats_start_collector *=\) *[^#]*\(#.*\);\1 on \2;' \
   1.572 +        -e 's;^# *\(stats_row_level *=\) *[^#]*\(#.*\);\1 on \2;' \
   1.573 +        -e 's;^# *\(autovacuum *=\) *[^#]*\(#.*\);\1 on \2;' \
   1.574 +        -e 's;^# *\(autovacuum_naptime *=\) *[^#]*\(#.*\);\1 1h \2;' \
   1.575 +        $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/postgresql.conf.sample
   1.576 +
   1.577 +    #   post-adjust pgcluster configuration filenames
   1.578 +%if "%{with_pgcluster}" == "yes"
   1.579 +    cp $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/pgreplicate.conf.sample \
   1.580 +       $RPM_BUILD_ROOT%{l_prefix}/etc/postgresql/pgreplicate.conf
   1.581 +%endif
   1.582 +
   1.583 +    #   install MySQL compatibility layer
   1.584 +%if "%{with_mysqlcompat}" == "yes"
   1.585 +    %{l_shtool} mkdir -f -p -m 755 \
   1.586 +        $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/mysqlcompat
   1.587 +    %{l_shtool} install -c -m 644 \
   1.588 +        mysqlcompat-%{V_mysqlcompat}/README \
   1.589 +        mysqlcompat-%{V_mysqlcompat}/*.sql \
   1.590 +        $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/mysqlcompat/
   1.591 +%endif
   1.592 +
   1.593 +    #   install run-command script
   1.594 +    %{l_shtool} mkdir -f -p -m 755 \
   1.595 +        $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
   1.596 +    %{l_shtool} install -c -m 755 %{l_value -s -a} \
   1.597 +        %{SOURCE rc.postgresql} \
   1.598 +        $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
   1.599 +
   1.600 +    #   optionally strip down to client-only installation
   1.601 +%if "%{with_server}" != "yes"
   1.602 +    rm -f  $RPM_BUILD_ROOT%{l_prefix}/bin/pg_[a-bd-z]*
   1.603 +    rm -f  $RPM_BUILD_ROOT%{l_prefix}/bin/pg_c[a-np-z]*
   1.604 +    rm -f  $RPM_BUILD_ROOT%{l_prefix}/bin/pg_controldata
   1.605 +    rm -f  $RPM_BUILD_ROOT%{l_prefix}/bin/post*
   1.606 +    rm -f  $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_[a-bd-z]*
   1.607 +    rm -f  $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_c[a-np-z]*
   1.608 +    rm -f  $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_controldata.1
   1.609 +    rm -f  $RPM_BUILD_ROOT%{l_prefix}/man/man1/post*
   1.610 +    rm -rf $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
   1.611 +    rm -rf $RPM_BUILD_ROOT%{l_prefix}/include/postgresql/server
   1.612 +    rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/postgresql
   1.613 +    rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/postgresql
   1.614 +    rm -rf $RPM_BUILD_ROOT%{l_prefix}/var/postgresql
   1.615 +%endif
   1.616 +
   1.617 +    #   determine installation files
   1.618 +    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
   1.619 +%if "%{with_server}" == "yes"
   1.620 +        %{l_files_std} `cat perl-openpkg-files` \
   1.621 +%if "%{with_slony1}" == "yes" || "%{with_pgcluster}" == "yes"
   1.622 +        '%config %{l_prefix}/etc/postgresql/*' \
   1.623 +%endif
   1.624 +        '%attr(700,%{l_rusr},%{l_rgrp}) %dir %{l_prefix}/var/postgresql/db' \
   1.625 +        '%attr(755,%{l_rusr},%{l_rgrp}) %dir %{l_prefix}/var/postgresql/run'
   1.626 +%else
   1.627 +        %{l_files_std} `cat perl-openpkg-files`
   1.628 +%endif
   1.629 +
   1.630 +%files -f files
   1.631 +
   1.632 +%clean
   1.633 +
   1.634 +%pre
   1.635 +%if "%{with_server}" == "yes"
   1.636 +    #   before upgrade, check migration dump, save status and stop service
   1.637 +    [ $1 -eq 2 ] || exit 0
   1.638 +    if [ -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION -a \
   1.639 +         -f $RPM_INSTALL_PREFIX/bin/pg_migrate ]; then
   1.640 +        #   database migration dumping hint
   1.641 +        v_old_all=`cat $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION`
   1.642 +        v_old_maj=`echo "$v_old_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
   1.643 +        v_new_all="%{V_postgresql}"
   1.644 +        v_new_maj=`echo "$v_new_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
   1.645 +        if [ ".$v_old_maj" != ".$v_new_maj" ]; then
   1.646 +            ( echo "You are upgrading from PostgreSQL $v_old_all to PostgresSQL $v_new_all,"
   1.647 +              echo "which is a major version change. We expect a database incompatibility,"
   1.648 +              echo "so a full database backup and restore is required!"
   1.649 +            ) | %{l_rpmtool} msg -b -t notice
   1.650 +            if [ ".$RPM_POSTGRESQL_MIGRATE" != .ignore ]; then
   1.651 +                if [ ! -f $RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2 ]; then
   1.652 +                    ( echo "We are performing a full backup of your existing database"
   1.653 +                      echo "($RPM_INSTALL_PREFIX/var/postgresql/db/) for you by running:"
   1.654 +                      echo "    \$ $RPM_INSTALL_PREFIX/bin/pg_migrate dump"
   1.655 +                      echo "If this fails for some reasons, try to dump your data manually:"
   1.656 +                      echo "    \$ $RPM_INSTALL_PREFIX/bin/pg_dumpall -U postgresql -o | \\ "
   1.657 +                      echo "      $RPM_INSTALL_PREFIX/lib/openpkg/bzip2 -9 \\ "
   1.658 +                      echo "      >$RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2"
   1.659 +                      echo "Alternatively, if you want to force this package to be installed without"
   1.660 +                      echo "a previously created database dump, run the following command"
   1.661 +                      echo "before trying this package upgrade again:"
   1.662 +                      echo "    \$ RPM_POSTGRESQL_MIGRATE=ignore; export RPM_POSTGRESQL_MIGRATE"
   1.663 +                    ) | %{l_rpmtool} msg -b -t notice
   1.664 +                    $RPM_INSTALL_PREFIX/bin/pg_migrate dump
   1.665 +                    if [ $? -ne 0 ] || [ ! -f $RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2 ]; then
   1.666 +                        ( echo "Automatic database dump creation failed!"
   1.667 +                          echo "PLEASE INVESTIGATE MANUALLY YOURSELF!"
   1.668 +                        ) | %{l_rpmtool} msg -b -t error
   1.669 +                        exit 1
   1.670 +                    fi
   1.671 +                fi
   1.672 +            fi
   1.673 +        fi
   1.674 +    fi
   1.675 +    eval `%{l_rc} postgresql status 2>/dev/null | tee %{l_tmpfile}`
   1.676 +    %{l_rc} postgresql stop 2>/dev/null
   1.677 +    exit 0
   1.678 +%endif
   1.679 +
   1.680 +%post
   1.681 +%if "%{with_server}" == "yes"
   1.682 +%if "%{with_compat}" == "yes"
   1.683 +    l_pguser="postgres"
   1.684 +    l_pgpass="postgres"
   1.685 +%else
   1.686 +    l_pguser="postgresql"
   1.687 +    l_pgpass="postgresql"
   1.688 +%endif
   1.689 +    if [ $1 -eq 1 ]; then
   1.690 +        #   create initial database
   1.691 +        su - %{l_rusr} -c \
   1.692 +            "LC_CTYPE=C; export LC_CTYPE; umask 077; \
   1.693 +            rm -rf $RPM_INSTALL_PREFIX/var/postgresql/db/*; \
   1.694 +            echo $l_pgpass >$RPM_INSTALL_PREFIX/var/postgresql/run/pg_initdb.pw; \
   1.695 +            $RPM_INSTALL_PREFIX/bin/pg_initdb \
   1.696 +                --encoding=SQL_ASCII --locale=C --auth=md5 --username=$l_pguser \
   1.697 +                --pwfile=$RPM_INSTALL_PREFIX/var/postgresql/run/pg_initdb.pw \
   1.698 +                --pgdata=$RPM_INSTALL_PREFIX/var/postgresql/db; \
   1.699 +            rm -f $RPM_INSTALL_PREFIX/var/postgresql/run/pg_initdb.pw" 2>&1 | \
   1.700 +        $RPM_INSTALL_PREFIX/lib/openpkg/shtool prop \
   1.701 +            -p "Creating initial PostgreSQL DB in $RPM_INSTALL_PREFIX/var/postgresql/db"
   1.702 +        if [ ! -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION ]; then
   1.703 +            echo "ERROR: failed to create initial PostgreSQL database" 1>&2
   1.704 +            exit 1
   1.705 +        fi
   1.706 +        ( umask 077
   1.707 +          ( echo "##"
   1.708 +            echo "##  pg_superuser.conf -- PostgreSQL database superuser configuration"
   1.709 +            echo "##"
   1.710 +            echo ""
   1.711 +            echo "superuser_database=\"template1\""
   1.712 +            echo "superuser_username=\"$l_pguser\""
   1.713 +            echo "superuser_password=\"$l_pgpass\""
   1.714 +            echo ""
   1.715 +          ) >$RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf
   1.716 +          chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf || exit $?
   1.717 +          chmod 600 $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf || exit $?
   1.718 +        ) || exit $?
   1.719 +
   1.720 +        #   display information about next steps
   1.721 +        ( echo "An initial PostgreSQL DB was created with the two standard"
   1.722 +          echo "databases 'template0' and 'template1'. The owner of both"
   1.723 +          echo "is the DB user '$l_pguser'. Its initial password is '$l_pgpass'."
   1.724 +          echo ""
   1.725 +          echo "After starting PostgreSQL with"
   1.726 +          echo "    \$ $RPM_INSTALL_PREFIX/bin/openpkg rc postgresql start"
   1.727 +          echo "you should immediately change this with the following command:"
   1.728 +          echo "    \$ $RPM_INSTALL_PREFIX/bin/pg_passwd postgresql template1"
   1.729 +          echo ""
   1.730 +          echo "Then you usually create a database for a user <user> (assuming that"
   1.731 +          echo "his home directory is /u/<user>) with password <password> under"
   1.732 +          echo "path /u/<user>/rdbms with the commands:"
   1.733 +          echo "    \$ mkdir /u/<user>/rdbms"
   1.734 +          echo "    \$ chmod 700 /u/<user>/rdbms"
   1.735 +          echo "    \$ chown %{l_rusr}:%{l_rgrp} /u/<user>/rdbms"
   1.736 +          echo "    \$ $RPM_INSTALL_PREFIX/bin/psql -U $l_pguser -d template1"
   1.737 +          echo "    template1=> CREATE ROLE <user>"
   1.738 +          echo "                LOGIN ENCRYPTED PASSWORD '<password>'"
   1.739 +          echo "                NOCREATEDB NOCREATEROLE;"
   1.740 +          echo "    template1=> CREATE TABLESPACE <user> OWNER <user>"
   1.741 +          echo "                LOCATION '/u/<user>/rdbms';"
   1.742 +          echo "    template1=> CREATE DATABASE <user> OWNER <user>"
   1.743 +          echo "                TABLESPACE <user>;"
   1.744 +          echo "    \$ echo 'localhost:*:<user>:<user>:<password>' >>/u/<user>/.pgpass"
   1.745 +          echo "    \$ chmod 600 <user> /u/<user>/.pgpass"
   1.746 +          echo "    \$ chown <user> /u/<user>/.pgpass"
   1.747 +          echo "After this the user <user> will be able to connect to his RDBMS with:"
   1.748 +          echo "    \$ $RPM_INSTALL_PREFIX/bin/psql"
   1.749 +        ) | %{l_rpmtool} msg -b -t notice
   1.750 +    fi
   1.751 +
   1.752 +%if "%{with_odbc}" == "yes"
   1.753 +    #   optionally link into ODBC
   1.754 +    if ! $RPM_INSTALL_PREFIX/bin/odbcinst -q -d -n "PostgreSQL" >/dev/null 2>&1; then
   1.755 +        ( echo "[PostgreSQL]"
   1.756 +          echo "Description     = PostgreSQL ODBC driver"
   1.757 +          echo "Driver          = $RPM_INSTALL_PREFIX/lib/psqlodbc.so"
   1.758 +          echo "Threading       = 2"
   1.759 +        ) | $RPM_INSTALL_PREFIX/bin/odbcinst -i -d -r -n "PostgreSQL"
   1.760 +    fi
   1.761 +%endif
   1.762 +
   1.763 +    if [ $1 -eq 2 ]; then
   1.764 +        #   after upgrade, restore status
   1.765 +        { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null 2>&1
   1.766 +        [ ".$postgresql_active" = .yes ] && %{l_rc} postgresql start
   1.767 +        if [   -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION -a \
   1.768 +             ! -f $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf ]; then
   1.769 +            ( umask 077
   1.770 +              ( echo "##"
   1.771 +                echo "##  pg_superuser.conf -- PostgreSQL database superuser configuration"
   1.772 +                echo "##"
   1.773 +                echo ""
   1.774 +                echo "superuser_database=\"template1\""
   1.775 +                echo "superuser_username=\"$l_pguser\""
   1.776 +                echo "superuser_password=\"\""
   1.777 +                echo ""
   1.778 +              ) >$RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf
   1.779 +              chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf || exit $?
   1.780 +              chmod 600 $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf || exit $?
   1.781 +            ) || exit $?
   1.782 +            ( echo "Created still missing \"pg_superuser.conf\" configuration file."
   1.783 +              echo "You should update its content by resetting the PostgreSQL"
   1.784 +              echo "superuser account password with the following command:"
   1.785 +              echo "    \$ $RPM_INSTALL_PREFIX/bin/pg_passwd postgresql template1"
   1.786 +            ) | %{l_rpmtool} msg -b -t warn
   1.787 +        fi
   1.788 +        if [ -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION -a ".$PG_MIGRATE" != .ignore ]; then
   1.789 +            #   database migration restoring hint
   1.790 +            v_old_all=`cat $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION`
   1.791 +            v_old_maj=`echo "$v_old_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
   1.792 +            v_new_all="%{V_postgresql}"
   1.793 +            v_new_maj=`echo "$v_new_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
   1.794 +            if [ ".$v_old_maj" != ".$v_new_maj" ]; then
   1.795 +                ( echo "You upgraded from PostgreSQL $v_old_all to PostgresSQL $v_new_all,"
   1.796 +                  echo "which is a major version upgrade. We expect a database incompatibility,"
   1.797 +                  echo "so we strongly recommend you to recreate the existing database under"
   1.798 +                  echo "$RPM_INSTALL_PREFIX/var/postgresql/db/ by running the following command:"
   1.799 +                  echo "    \$ $RPM_INSTALL_PREFIX/bin/pg_migrate restore"
   1.800 +                  echo "If this fails for some reasons, try to restore your data manually:"
   1.801 +                  echo "    \$ $RPM_INSTALL_PREFIX/lib/openpkg/bzip2 -d -c \\ "
   1.802 +                  echo "      $RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2 | \\ "
   1.803 +                  echo "      $RPM_INSTALL_PREFIX/bin/psql -U postgresql -d template1"
   1.804 +                ) | %{l_rpmtool} msg -b -t warn
   1.805 +            fi
   1.806 +        fi
   1.807 +    fi
   1.808 +    exit 0
   1.809 +%endif
   1.810 +
   1.811 +%preun
   1.812 +%if "%{with_server}" == "yes"
   1.813 +    #   before erase, stop service and remove log files
   1.814 +    [ $1 -eq 0 ] || exit 0
   1.815 +    %{l_rc} postgresql stop 2>/dev/null
   1.816 +    rm -f $RPM_INSTALL_PREFIX/var/postgresql/run/* >/dev/null 2>&1 || true
   1.817 +    #   optionally unlink from ODBC
   1.818 +%if "%{with_odbc}" == "yes"
   1.819 +    $RPM_INSTALL_PREFIX/bin/odbcinst -u -d -n "PostgreSQL"
   1.820 +%endif
   1.821 +    exit 0
   1.822 +%endif
   1.823 +

mercurial