postgresql.spec 31 KB

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