postgresql.spec 30 KB

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