postgresql/postgresql.spec

Tue, 28 Aug 2012 18:29:00 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 28 Aug 2012 18:29:00 +0200
changeset 532
e5f1af644b30
parent 301
51b6f3cffaff
child 699
da76d565ccd3
permissions
-rw-r--r--

Massively update modules from Drupal 6.x to 7.x, and add diverse OpenID modules.
Unfortunately many modules available to Drupal 6.x installations have not been
since maintained or ported to 7.x causing this package to diminish in both size
and utility.

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

mercurial