postgresql.spec 30 KB

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