postgresql.spec 28 KB

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