postgresql.spec 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  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.7
  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_major 1.2
  31. %define V_slony1_minor 13
  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: 20080323
  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://slony.info/downloads/%{V_slony1_major}/source/slony1-%{V_slony1_major}.%{V_slony1_minor}.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_major}.%{V_slony1_minor}
  150. url = http://slony.info/downloads/%{V_slony1_major}/source/
  151. regex = slony1-(\d+\.\d+\.\d+)\.tar\.bz2
  152. }
  153. prog postgresql:pgcluster = {
  154. version = %{V_pgcluster}.%{V_pgcluster_dir}
  155. url = http://pgfoundry.org/frs/?group_id=1000072
  156. regex = /(\d+/pgcluster-__VER__)\.patch\.tar\.gz
  157. transform = "s/^(\\d+)\/pgcluster-(.+)$/$2.$1/; $_"
  158. }
  159. prog postgresql:mysqlcompat = {
  160. version = %{V_mysqlcompat}.%{V_mysqlcompat_dir}
  161. url = http://pgfoundry.org/frs/?group_id=1000154
  162. regex = (\d+/mysqlcompat-__VER__)\.tar\.gz
  163. transform = "s/^(\\d+)\/mysqlcompat-(.+)$/$2.$1/; $_"
  164. }
  165. %prep
  166. %setup -q
  167. %patch -p0
  168. %if "%{with_cxx}" == "yes"
  169. %setup -q -T -D -a 1
  170. case "%{l_platform -t}" in
  171. *-sunos* )
  172. %{l_shtool} subst \
  173. -e 's;strerror_r(0,0,0);strerror((int)0);g' \
  174. -e 's;strerror_r((int)0, (char \*)0, (size_t)0);strerror((int)0);g' \
  175. libpqxx-%{V_libpqxx}/configure
  176. %{l_shtool} subst \
  177. -e 's;strerror_r(err, buf, sizeof(buf));strerror(err);g' \
  178. libpqxx-%{V_libpqxx}/src/largeobject.cxx \
  179. libpqxx-%{V_libpqxx}/configure
  180. %{l_shtool} subst \
  181. -e 's;\(strerror(err) ==\) -1;\1 (char *)-1;' \
  182. libpqxx-%{V_libpqxx}/src/largeobject.cxx
  183. ;;
  184. esac
  185. %{l_shtool} subst \
  186. -e 's;^function \(add_compiler_opts() {\);\1;' \
  187. libpqxx-%{V_libpqxx}/configure
  188. %endif
  189. %if "%{with_perl}" == "yes"
  190. %setup -q -T -D -a 2
  191. %endif
  192. %if "%{with_odbc}" == "yes"
  193. %setup -q -T -D -a 3
  194. %endif
  195. %if "%{with_slony1}" == "yes"
  196. %setup -q -T -D -a 4
  197. %endif
  198. %if "%{with_pgcluster}" == "yes"
  199. %setup -q -T -D -a 5
  200. sed -e '/^diff.*libpq\.rc/,/^diff/d' pgcluster-*-patch |\
  201. %{l_patch} -p1
  202. %endif
  203. %if "%{with_mysqlcompat}" == "yes"
  204. %setup -q -T -D -a 6
  205. %endif
  206. %if "%{with_jdbc}" == "yes"
  207. %setup -q -T -D -a 7
  208. %endif
  209. # adjust source tree
  210. %{l_shtool} subst \
  211. -e 's;\(#define.*DEFAULT_PGSOCKET_DIR[^"]*"\)/tmp\("\);\1%{l_prefix}/var/postgresql/run\2;' \
  212. src/include/pg_config_manual.h
  213. %{l_shtool} subst \
  214. -e 's;^\(sqlmansect *=\).*$;\1 7;' \
  215. src/makefiles/Makefile.solaris
  216. %{l_shtool} subst \
  217. -e 's;$(INSTALL_SHLIB);#$(INSTALL_SHLIB);g' \
  218. src/backend/utils/mb/conversion_procs/proc.mk
  219. %{l_shtool} subst \
  220. -e 's;# Shared library stuff;enable_shared = yes;g' \
  221. src/pl/plpgsql/src/Makefile
  222. %build
  223. rm -rf $RPM_BUILD_ROOT
  224. # configure package
  225. echo "ac_cv_func_isinf=no" >config.cache
  226. export CC="%{l_cc}"
  227. export CFLAGS="%{l_cflags -O}"
  228. export CPPFLAGS="%{l_cppflags readline}"
  229. export LDFLAGS="%{l_ldflags}"
  230. export LIBS=""
  231. %if "%{with_slony1}" == "yes"
  232. CFLAGS="$CFLAGS -pthread"
  233. %endif
  234. %if "%{with_tcl}" == "yes"
  235. CPPFLAGS="$CPPFLAGS %{l_cppflags tcl}"
  236. LDFLAGS="$LDFLAGS -L`%{l_rc} --query x11_libdir`"
  237. %endif
  238. %if "%{with_kerberos}" == "yes"
  239. CPPFLAGS="$CPPFLAGS `krb5-config --cflags`"
  240. LIBS="$LIBS `krb5-config --libs`"
  241. %endif
  242. %if "%{with_pgcluster}" == "yes"
  243. case "%{l_platform -t}" in
  244. *-freebsd* ) LIBS="$LIBS -lcompat" ;;
  245. esac
  246. %endif
  247. export TAR="%{l_tar}"
  248. export YACC="bison -y"
  249. ./configure \
  250. --cache-file=./config.cache \
  251. --prefix=%{l_prefix} \
  252. --sysconfdir=%{l_prefix}/etc/postgresql \
  253. --includedir=%{l_prefix}/include/postgresql \
  254. --with-openssl \
  255. --with-readline \
  256. --with-zlib \
  257. %if "%{with_tcl}" == "yes"
  258. --with-tcl \
  259. --with-tclconfig="%{l_prefix}/lib" \
  260. --with-tkconfig="%{l_prefix}/lib" \
  261. %endif
  262. %if "%{with_slony1}" == "yes"
  263. --enable-thread-safety \
  264. %endif
  265. %if "%{with_kerberos}" == "yes"
  266. --with-krb5 \
  267. --with-krb-srvnam=postgresql \
  268. %endif
  269. %if "%{with_int_datetime}" == "yes"
  270. --enable-integer-datetimes \
  271. %endif
  272. --disable-syslog \
  273. --disable-shared
  274. # build package
  275. %{l_make} %{l_mflags}
  276. # build C++ bindings (both old and new one)
  277. %if "%{with_cxx}" == "yes"
  278. ln -s `pwd`/src/interfaces/libpq/*.h src/include/
  279. ( cd libpqxx-%{V_libpqxx}
  280. %{l_shtool} subst \
  281. -e 's;\(cut\)\( .*/configitems\)\( -f [0-9]\);\1\3\2;g' \
  282. configure
  283. ( echo "#!/bin/sh"
  284. echo "case \"\$1\" in"
  285. echo " --includedir ) echo \"`pwd`/../src/include\" ;;"
  286. echo " --libdir ) echo \"`pwd`/../src/interfaces/libpq\" ;;"
  287. echo "esac"
  288. ) >pg_config
  289. chmod a+x pg_config
  290. export PG_CONFIG=`pwd`/pg_config
  291. export CC="%{l_cc}"
  292. export CXX="%{l_cxx}"
  293. export CFLAGS="%{l_cflags -O}"
  294. export CXXFLAGS="%{l_cxxflags -O}"
  295. export CPPFLAGS="-I`pwd`/../src/include %{l_cppflags}"
  296. export LDFLAGS="%{l_ldflags}"
  297. export LIBS="-lssl -lcrypto -lcrypt"
  298. case "%{l_platform -t}" in
  299. *-sunos* ) LIBS="$LIBS -lsocket -lnsl" ;;
  300. esac
  301. ./configure \
  302. --disable-shared
  303. %{l_make} %{l_mflags -O}
  304. ) || exit $?
  305. %endif
  306. # build Perl bindings
  307. %if "%{with_perl}" == "yes"
  308. %{l_prefix}/bin/perl-openpkg prepare
  309. ( cd Pg-%{V_pgperl}
  310. export POSTGRES_INCLUDE=dummy
  311. export POSTGRES_LIB=dummy
  312. %{l_shtool} subst \
  313. -e 's;-I$POSTGRES_INCLUDE;-I../src/interfaces/libpq -I../src/include;' \
  314. -e 's;-L$POSTGRES_LIB;-L../src/interfaces/libpq;' \
  315. -e 's;-lpq;-lpq %{l_ldflags} -lssl -lcrypto -lcrypt;' \
  316. Makefile.PL
  317. ) || exit $?
  318. ( export POSTGRES_INCLUDE=dummy
  319. export POSTGRES_LIB=dummy
  320. %{l_prefix}/bin/perl-openpkg -d Pg-%{V_pgperl} configure build
  321. ) || exit $?
  322. %endif
  323. # build ODBC driver
  324. %if "%{with_odbc}" == "yes"
  325. ( cd psqlodbc-%{V_psqlodbc}
  326. export CC="%{l_cc}"
  327. export CXX="%{l_cxx}"
  328. export CFLAGS="%{l_cflags -O}"
  329. export CXXFLAGS="%{l_cxxflags -O}"
  330. export CPPFLAGS="-I`pwd`/../src/include"
  331. CPPFLAGS="$CPPFLAGS -I`pwd`/../src/interfaces -I`pwd`/../src/interfaces/libpq"
  332. CPPFLAGS="$CPPFLAGS %{l_cppflags}"
  333. export LDFLAGS="-L`pwd`/../src/interfaces/libpq %{l_ldflags}"
  334. ./configure \
  335. --prefix=%{l_prefix} \
  336. --with-unixodbc=%{l_prefix} \
  337. --with-odbcinst=%{l_prefix}/etc/unixodbc
  338. %{l_make} %{l_mflags -O}
  339. ) || exit $?
  340. %endif
  341. # build JDBC driver
  342. %if "%{with_jdbc}" == "yes"
  343. ( cd postgresql-jdbc-%{V_pgjdbc}.src
  344. export JAVA_PLATFORM="sun-jdk"
  345. eval `%{l_prefix}/bin/java-toolkit -e`
  346. %{l_prefix}/bin/ant
  347. ) || exit $?
  348. %endif
  349. # build Slony-1 replication engine
  350. %if "%{with_slony1}" == "yes"
  351. ( cd slony1-%{V_slony1_major}.%{V_slony1_minor}
  352. ln ../src/pl/plpgsql/src/libplpgsql.so \
  353. ../src/pl/plpgsql/src/plpgsql.so
  354. %{l_shtool} subst \
  355. -e 's;-lpq;-lpq @LIBS@;' \
  356. Makefile.global.in
  357. export CC="%{l_cc}"
  358. export CFLAGS="%{l_cflags -O}"
  359. export CPPFLAGS="%{l_cppflags}"
  360. export LDFLAGS="%{l_ldflags}"
  361. export LIBS="-lssl -lcrypto -lcrypt"
  362. ./configure \
  363. --prefix=%{l_prefix} \
  364. --sysconfdir=%{l_prefix}/etc/postgresql \
  365. --with-pgconfigdir=../src/bin/pg_config \
  366. --with-pgincludedir=../src/include \
  367. --with-pgincludeserverdir=../src/interfaces/libpq \
  368. --with-pglibdir=../src/interfaces/libpq \
  369. --with-pgpkglibdir=../src/pl/plpgsql/src \
  370. --with-pgsharedir=../src/backend/utils/misc
  371. %{l_make} %{l_mflags -O}
  372. ) || exit $?
  373. %endif
  374. # rebuild pg_config with hard-coded path to avoid that it provides
  375. # dynamically resolved paths which circumvent symlinks, etc.
  376. ( cd src/bin/pg_config
  377. %{l_shtool} subst \
  378. -e 's:find_my_exec(argv.0., mypath):0; strcpy(mypath, "%{l_prefix}/bin/pg_config"):' \
  379. pg_config.c
  380. %{l_make} %{l_mflags}
  381. ) || exit $?
  382. %install
  383. rm -rf $RPM_BUILD_ROOT
  384. # perform standard installation procedure
  385. cp /dev/null register.txt
  386. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  387. # strip down installation
  388. rm -rf $RPM_BUILD_ROOT%{l_prefix}/doc
  389. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  390. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgaccess.1
  391. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgtclsh.1
  392. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgtksh.1
  393. # namespace adjustments to installation
  394. for prog in \
  395. createdb createlang createuser dropdb droplang clusterdb \
  396. dropuser initdb ipcclean vacuumdb reindexdb; do
  397. %if "%{with_compat}" == "yes"
  398. cmd="ln"
  399. %else
  400. cmd="mv"
  401. %endif
  402. $cmd $RPM_BUILD_ROOT%{l_prefix}/bin/$prog \
  403. $RPM_BUILD_ROOT%{l_prefix}/bin/pg_$prog
  404. $cmd $RPM_BUILD_ROOT%{l_prefix}/man/man1/$prog.1 \
  405. $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_$prog.1
  406. done
  407. ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man7
  408. for man in *.7; do
  409. mv $man pg_$man
  410. done
  411. ) || exit $?
  412. # create additional directories
  413. %{l_shtool} mkdir -f -p -m 755 \
  414. %if "%{with_slony1}" == "yes" || "%{with_pgcluster}" == "yes"
  415. $RPM_BUILD_ROOT%{l_prefix}/etc/postgresql \
  416. %endif
  417. $RPM_BUILD_ROOT%{l_prefix}/var/postgresql/db \
  418. $RPM_BUILD_ROOT%{l_prefix}/var/postgresql/run
  419. # install addon utilities
  420. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  421. %{SOURCE pg_migrate} $RPM_BUILD_ROOT%{l_prefix}/bin/
  422. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  423. -e "s;@l_bash@;%{l_bash};g" \
  424. %{SOURCE pg_passwd} $RPM_BUILD_ROOT%{l_prefix}/bin/
  425. # install C++ bindings (both old and new one)
  426. %if "%{with_cxx}" == "yes"
  427. ( cd libpqxx-%{V_libpqxx}
  428. %{l_shtool} mkdir -f -p -m 755 \
  429. $RPM_BUILD_ROOT%{l_prefix}/include/pqxx
  430. %{l_shtool} install -c -m 644 \
  431. include/pqxx/* \
  432. $RPM_BUILD_ROOT%{l_prefix}/include/pqxx/
  433. rm -f $RPM_BUILD_ROOT%{l_prefix}/include/pqxx/Makefile*
  434. rm -f $RPM_BUILD_ROOT%{l_prefix}/include/pqxx/config.h*
  435. %{l_shtool} install -c -m 644 \
  436. src/.libs/libpqxx.a \
  437. $RPM_BUILD_ROOT%{l_prefix}/lib/
  438. ) || exit $?
  439. %endif
  440. # install Perl binding
  441. %if "%{with_perl}" == "yes"
  442. ( export POSTGRES_INCLUDE=dummy
  443. export POSTGRES_LIB=dummy
  444. %{l_prefix}/bin/perl-openpkg -d Pg-%{V_pgperl} install
  445. ) || exit $?
  446. %{l_prefix}/bin/perl-openpkg -F perl-openpkg-files fixate cleanup
  447. %else
  448. >perl-openpkg-files
  449. %endif
  450. # install ODBC driver
  451. %if "%{with_odbc}" == "yes"
  452. ( cd psqlodbc-%{V_psqlodbc}
  453. %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
  454. ) || exit $?
  455. %endif
  456. # install JDBC driver
  457. %if "%{with_jdbc}" == "yes"
  458. ( cd postgresql-jdbc-%{V_pgjdbc}.src
  459. %{l_shtool} install -c -m 644 \
  460. jars/postgresql.jar $RPM_BUILD_ROOT%{l_prefix}/lib/
  461. ) || exit $?
  462. %endif
  463. # install Slony-1 replication engine
  464. %if "%{with_slony1}" == "yes"
  465. ( cd slony1-%{V_slony1_major}.%{V_slony1_minor}
  466. %{l_shtool} subst \
  467. -e 's;$(SQL_NAME80);$(SQL_NAME74);g' \
  468. src/xxid/Makefile
  469. %{l_make} %{l_mflags} install \
  470. DESTDIR=$RPM_BUILD_ROOT \
  471. pgconfigdir=%{l_prefix}/bin \
  472. pgincludedir=%{l_prefix}/include/postgresql \
  473. pgincludeserverdir=%{l_prefix}/include/postgresql/libpq \
  474. pglibdir=%{l_prefix}/lib/postgresql \
  475. pgpkglibdir=%{l_prefix}/lib/postgresql \
  476. pgsharedir=%{l_prefix}/share/postgresql
  477. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/slony1*v7[34].sql
  478. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/xxid.v73.sql
  479. mv $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/xxid.v74.sql \
  480. $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/xxid.sql
  481. ( echo "# Slony-1 configuration for replication engine slon(1)"
  482. echo "SLON_CLUSTER_NAME=\"example\""
  483. echo "SLON_CONNECT_DBNAME=\"example\""
  484. echo "SLON_CONNECT_USER=\"postgresql\""
  485. echo "SLON_CONNECT_PASS=\"postgresql\""
  486. echo "SLON_CONNECT_HOST=\"localhost\""
  487. echo "SLON_SYNC_INTERVAL=\"10000\""
  488. echo "SLON_SYNC_TIMEOUT=\"60000\""
  489. echo "SLON_SYNC_GROUPSIZE=\"6\""
  490. echo "SLON_SYNC_LOGLEVEL=\"1\""
  491. ) >$RPM_BUILD_ROOT%{l_prefix}/etc/postgresql/slony1.conf
  492. ) || exit $?
  493. %endif
  494. # adjust default configuration for hourly auto-vacuum operation
  495. %{l_shtool} subst \
  496. -e 's;^# *\(stats_start_collector *=\) *[^#]*\(#.*\);\1 on \2;' \
  497. -e 's;^# *\(stats_row_level *=\) *[^#]*\(#.*\);\1 on \2;' \
  498. -e 's;^# *\(autovacuum *=\) *[^#]*\(#.*\);\1 on \2;' \
  499. -e 's;^# *\(autovacuum_naptime *=\) *[^#]*\(#.*\);\1 1h \2;' \
  500. $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/postgresql.conf.sample
  501. # post-adjust pgcluster configuration filenames
  502. %if "%{with_pgcluster}" == "yes"
  503. cp $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/pgreplicate.conf.sample \
  504. $RPM_BUILD_ROOT%{l_prefix}/etc/postgresql/pgreplicate.conf
  505. %endif
  506. # install MySQL compatibility layer
  507. %if "%{with_mysqlcompat}" == "yes"
  508. %{l_shtool} mkdir -f -p -m 755 \
  509. $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/mysqlcompat
  510. %{l_shtool} install -c -m 644 \
  511. mysqlcompat-%{V_mysqlcompat}/README \
  512. mysqlcompat-%{V_mysqlcompat}/*.sql \
  513. $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/mysqlcompat/
  514. %endif
  515. # install run-command script
  516. %{l_shtool} mkdir -f -p -m 755 \
  517. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  518. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  519. %{SOURCE rc.postgresql} \
  520. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  521. # optionally strip down to client-only installation
  522. %if "%{with_server}" != "yes"
  523. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/pg_[a-bd-z]*
  524. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/pg_c[a-np-z]*
  525. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/pg_controldata
  526. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/post*
  527. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_[a-bd-z]*
  528. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_c[a-np-z]*
  529. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_controldata.1
  530. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/post*
  531. rm -rf $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  532. rm -rf $RPM_BUILD_ROOT%{l_prefix}/include/postgresql/server
  533. rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/postgresql
  534. rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/postgresql
  535. rm -rf $RPM_BUILD_ROOT%{l_prefix}/var/postgresql
  536. %endif
  537. # determine installation files
  538. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  539. %if "%{with_server}" == "yes"
  540. %{l_files_std} `cat perl-openpkg-files` \
  541. %if "%{with_slony1}" == "yes" || "%{with_pgcluster}" == "yes"
  542. '%config %{l_prefix}/etc/postgresql/*' \
  543. %endif
  544. '%attr(700,%{l_rusr},%{l_rgrp}) %dir %{l_prefix}/var/postgresql/db' \
  545. '%attr(755,%{l_rusr},%{l_rgrp}) %dir %{l_prefix}/var/postgresql/run'
  546. %else
  547. %{l_files_std} `cat perl-openpkg-files`
  548. %endif
  549. %files -f files
  550. %clean
  551. rm -rf $RPM_BUILD_ROOT
  552. %pre
  553. %if "%{with_server}" == "yes"
  554. # before upgrade, check migration dump, save status and stop service
  555. [ $1 -eq 2 ] || exit 0
  556. if [ -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION -a \
  557. -f $RPM_INSTALL_PREFIX/bin/pg_migrate ]; then
  558. # database migration dumping hint
  559. v_old_all=`cat $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION`
  560. v_old_maj=`echo "$v_old_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
  561. v_new_all="%{V_postgresql}"
  562. v_new_maj=`echo "$v_new_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
  563. if [ ".$v_old_maj" != ".$v_new_maj" ]; then
  564. if [ ! -f $RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2 -a ".$RPM_POSTGRESQL_MIGRATE" != .ignore ]; then
  565. ( echo "You are upgrading from PostgreSQL $v_old_all to PostgresSQL $v_new_all,"
  566. echo "which is a major version change. We expect a database incompatibility,"
  567. echo "so we strongly recommend that you backup your existing database"
  568. echo "($RPM_INSTALL_PREFIX/var/postgresql/db/) first by running:"
  569. echo " \$ $RPM_INSTALL_PREFIX/bin/pg_migrate dump"
  570. echo "If this fails for some reasons, try to dump your data manually:"
  571. echo " \$ $RPM_INSTALL_PREFIX/bin/pg_dumpall -U postgresql -o | \\ "
  572. echo " $RPM_INSTALL_PREFIX/lib/openpkg/bzip2 -9 \\ "
  573. echo " >$RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2"
  574. echo "Alternatively, if you want to force this package to be installed without"
  575. echo "performing a database dump, run the following command before upgrading:"
  576. echo " \$ RPM_POSTGRESQL_MIGRATE=ignore; export RPM_POSTGRESQL_MIGRATE"
  577. ) | %{l_rpmtool} msg -b -t error
  578. exit 1
  579. fi
  580. fi
  581. fi
  582. eval `%{l_rc} postgresql status 2>/dev/null | tee %{l_tmpfile}`
  583. %{l_rc} postgresql stop 2>/dev/null
  584. exit 0
  585. %endif
  586. %post
  587. %if "%{with_server}" == "yes"
  588. %if "%{with_compat}" == "yes"
  589. l_pguser="postgres"
  590. l_pgpass="postgres"
  591. %else
  592. l_pguser="postgresql"
  593. l_pgpass="postgresql"
  594. %endif
  595. if [ $1 -eq 1 ]; then
  596. # create initial database
  597. su - %{l_rusr} -c \
  598. "LC_CTYPE=C; export LC_CTYPE; umask 077; \
  599. rm -rf $RPM_INSTALL_PREFIX/var/postgresql/db/*; \
  600. echo $l_pgpass >$RPM_INSTALL_PREFIX/var/postgresql/run/pg_initdb.pw; \
  601. $RPM_INSTALL_PREFIX/bin/pg_initdb \
  602. --encoding=SQL_ASCII --locale=C --auth=md5 --username=$l_pguser \
  603. --pwfile=$RPM_INSTALL_PREFIX/var/postgresql/run/pg_initdb.pw \
  604. --pgdata=$RPM_INSTALL_PREFIX/var/postgresql/db; \
  605. rm -f $RPM_INSTALL_PREFIX/var/postgresql/run/pg_initdb.pw" 2>&1 | \
  606. $RPM_INSTALL_PREFIX/lib/openpkg/shtool prop \
  607. -p "Creating initial PostgreSQL DB in $RPM_INSTALL_PREFIX/var/postgresql/db"
  608. if [ ! -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION ]; then
  609. echo "ERROR: failed to create initial PostgreSQL database" 1>&2
  610. exit 1
  611. fi
  612. ( umask 077
  613. ( echo "##"
  614. echo "## pg_superuser.conf -- PostgreSQL database superuser configuration"
  615. echo "##"
  616. echo ""
  617. echo "superuser_database=\"template1\""
  618. echo "superuser_username=\"$l_pguser\""
  619. echo "superuser_password=\"$l_pgpass\""
  620. echo ""
  621. ) >$RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf
  622. chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf || exit $?
  623. chmod 600 $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf || exit $?
  624. ) || exit $?
  625. # display information about next steps
  626. ( echo "An initial PostgreSQL DB was created with the two standard"
  627. echo "databases 'template0' and 'template1'. The owner of both"
  628. echo "is the DB user '$l_pguser'. Its initial password is '$l_pgpass'."
  629. echo ""
  630. echo "After starting PostgreSQL with"
  631. echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc postgresql start"
  632. echo "you should immediately change this with the following command:"
  633. echo " \$ $RPM_INSTALL_PREFIX/bin/pg_passwd postgresql template1"
  634. echo ""
  635. echo "Then you usually create a database for a user <user> (assuming that"
  636. echo "his home directory is /u/<user>) with password <password> under"
  637. echo "path /u/<user>/rdbms with the commands:"
  638. echo " \$ mkdir /u/<user>/rdbms"
  639. echo " \$ chmod 700 /u/<user>/rdbms"
  640. echo " \$ chown %{l_rusr}:%{l_rgrp} /u/<user>/rdbms"
  641. echo " \$ $RPM_INSTALL_PREFIX/bin/psql -U $l_pguser -d template1"
  642. echo " template1=> CREATE ROLE <user>"
  643. echo " LOGIN ENCRYPTED PASSWORD '<password>'"
  644. echo " NOCREATEDB NOCREATEROLE;"
  645. echo " template1=> CREATE TABLESPACE <user> OWNER <user>"
  646. echo " LOCATION '/u/<user>/rdbms';"
  647. echo " template1=> CREATE DATABASE <user> OWNER <user>"
  648. echo " TABLESPACE <user>;"
  649. echo " \$ echo 'localhost:*:<user>:<user>:<password>' >>/u/<user>/.pgpass"
  650. echo " \$ chmod 600 <user> /u/<user>/.pgpass"
  651. echo " \$ chown <user> /u/<user>/.pgpass"
  652. echo "After this the user <user> will be able to connect to his RDBMS with:"
  653. echo " \$ $RPM_INSTALL_PREFIX/bin/psql"
  654. ) | %{l_rpmtool} msg -b -t notice
  655. fi
  656. %if "%{with_odbc}" == "yes"
  657. # optionally link into ODBC
  658. if ! $RPM_INSTALL_PREFIX/bin/odbcinst -q -d -n "PostgreSQL" >/dev/null 2>&1; then
  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. fi
  665. %endif
  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