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