postgresql82.spec 30 KB

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