postgresql.spec 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806
  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.4
  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.0400
  31. %define V_pgjdbc 8.2-506
  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: 20070912
  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. %if "%{with_kerberos}" == "yes"
  220. %{l_shtool} subst \
  221. -e 's;krb5 -ldes -lasn1 -lroken;krb5 -lk5crypto -lkrb5support -lcom_err;g' \
  222. configure
  223. %endif
  224. # adjust source tree
  225. %{l_shtool} subst \
  226. -e 's;\(#define.*DEFAULT_PGSOCKET_DIR[^"]*"\)/tmp\("\);\1%{l_prefix}/var/postgresql/run\2;' \
  227. src/include/pg_config_manual.h
  228. %{l_shtool} subst \
  229. -e 's;^\(sqlmansect *=\).*$;\1 7;' \
  230. src/makefiles/Makefile.solaris
  231. %{l_shtool} subst \
  232. -e 's;$(INSTALL_SHLIB);#$(INSTALL_SHLIB);g' \
  233. src/backend/utils/mb/conversion_procs/proc.mk
  234. %{l_shtool} subst \
  235. -e 's;# Shared library stuff;enable_shared = yes;g' \
  236. src/pl/plpgsql/src/Makefile
  237. %build
  238. rm -rf $RPM_BUILD_ROOT
  239. # configure package
  240. echo "ac_cv_func_isinf=no" >config.cache
  241. export CC="%{l_cc}"
  242. export CFLAGS="%{l_cflags -O}"
  243. export CPPFLAGS="%{l_cppflags readline}"
  244. export LDFLAGS="%{l_ldflags}"
  245. export LIBS=""
  246. %if "%{with_slony1}" == "yes"
  247. CFLAGS="$CFLAGS -pthread"
  248. %endif
  249. %if "%{with_tcl}" == "yes"
  250. CPPFLAGS="$CPPFLAGS %{l_cppflags tcl}"
  251. LDFLAGS="$LDFLAGS -L`%{l_rc} --query x11_libdir`"
  252. %endif
  253. %if "%{with_kerberos}" == "yes"
  254. CPPFLAGS="$CPPFLAGS %{l_cppflags kerberos}"
  255. LDFLAGS="$LDFLAGS %{l_ldflags kerberos}"
  256. %endif
  257. %if "%{with_pgcluster}" == "yes"
  258. case "%{l_platform -t}" in
  259. *-freebsd* ) LIBS="$LIBS -lcompat" ;;
  260. esac
  261. %endif
  262. export TAR="%{l_tar}"
  263. export YACC="bison -y"
  264. ./configure \
  265. --cache-file=./config.cache \
  266. --prefix=%{l_prefix} \
  267. --sysconfdir=%{l_prefix}/etc/postgresql \
  268. --includedir=%{l_prefix}/include/postgresql \
  269. --with-openssl \
  270. --with-readline \
  271. --with-zlib \
  272. %if "%{with_tcl}" == "yes"
  273. --with-tcl \
  274. --with-tclconfig="%{l_prefix}/lib" \
  275. --with-tkconfig="%{l_prefix}/lib" \
  276. %endif
  277. %if "%{with_slony1}" == "yes"
  278. --enable-thread-safety \
  279. %endif
  280. %if "%{with_kerberos}" == "yes"
  281. --with-krb5 \
  282. --with-krb-srvnam=postgresql \
  283. %endif
  284. %if "%{with_int_datetime}" == "yes"
  285. --enable-integer-datetimes \
  286. %endif
  287. --disable-syslog \
  288. --disable-shared
  289. # build package
  290. %{l_make} %{l_mflags}
  291. # build C++ bindings (both old and new one)
  292. %if "%{with_cxx}" == "yes"
  293. ( cd libpq++-%{V_libpqpp}
  294. CXX="%{l_cxx}"
  295. CFLAGS="%{l_cflags -O}"
  296. CPPFLAGS="-DHAVE_NAMESPACE_STD -DHAVE_CXX_STRING_HEADER -DDLLIMPORT= "
  297. CPPFLAGS="$CPPFLAGS -I. -I../src/interfaces/libpq -I../src/interfaces"
  298. CPPFLAGS="$CPPFLAGS -I../src/include %{l_cppflags}"
  299. LDFLAGS="%{l_ldflags}"
  300. OBJS="pgconnection.o pgdatabase.o pgtransdb.o pgcursordb.o pglobject.o"
  301. for o in $OBJS; do
  302. $CXX $CFLAGS $CPPFLAGS $LDFLAGS -c -o $o `echo $o | sed -e 's;\.o$;.cc;'`
  303. done
  304. rm -f libpq++.a
  305. ar rc libpq++.a $OBJS
  306. ) || exit $?
  307. ln -s `pwd`/src/interfaces/libpq/*.h src/include/
  308. ( cd libpqxx-%{V_libpqxx}
  309. %{l_shtool} subst \
  310. -e 's;\(cut\)\( .*/configitems\)\( -f [0-9]\);\1\3\2;g' \
  311. configure
  312. ( echo "#!/bin/sh"
  313. echo "case \"\$1\" in"
  314. echo " --includedir ) echo \"`pwd`/../src/include\" ;;"
  315. echo " --libdir ) echo \"`pwd`/../src/interfaces/libpq\" ;;"
  316. echo "esac"
  317. ) >pg_config
  318. chmod a+x pg_config
  319. export PG_CONFIG=`pwd`/pg_config
  320. export CC="%{l_cc}"
  321. export CXX="%{l_cxx}"
  322. export CFLAGS="%{l_cflags -O}"
  323. export CXXFLAGS="%{l_cxxflags -O}"
  324. export CPPFLAGS="-I`pwd`/../src/include %{l_cppflags}"
  325. export LDFLAGS="%{l_ldflags}"
  326. export LIBS="-lssl -lcrypto -lcrypt"
  327. case "%{l_platform -t}" in
  328. *-sunos* ) LIBS="$LIBS -lsocket -lnsl" ;;
  329. esac
  330. ./configure \
  331. --disable-shared
  332. %{l_make} %{l_mflags -O}
  333. ) || exit $?
  334. %endif
  335. # build Perl bindings
  336. %if "%{with_perl}" == "yes"
  337. %{l_prefix}/bin/perl-openpkg prepare
  338. ( cd Pg-%{V_pgperl}
  339. export POSTGRES_INCLUDE=dummy
  340. export POSTGRES_LIB=dummy
  341. %{l_shtool} subst \
  342. -e 's;-I$POSTGRES_INCLUDE;-I../src/interfaces/libpq -I../src/include;' \
  343. -e 's;-L$POSTGRES_LIB;-L../src/interfaces/libpq;' \
  344. -e 's;-lpq;-lpq %{l_ldflags} -lssl -lcrypto -lcrypt;' \
  345. Makefile.PL
  346. ) || exit $?
  347. ( export POSTGRES_INCLUDE=dummy
  348. export POSTGRES_LIB=dummy
  349. %{l_prefix}/bin/perl-openpkg -d Pg-%{V_pgperl} configure build
  350. ) || exit $?
  351. %endif
  352. # build ODBC driver
  353. %if "%{with_odbc}" == "yes"
  354. ( cd psqlodbc-%{V_psqlodbc}
  355. export CC="%{l_cc}"
  356. export CXX="%{l_cxx}"
  357. export CFLAGS="%{l_cflags -O}"
  358. export CXXFLAGS="%{l_cxxflags -O}"
  359. export CPPFLAGS="-I`pwd`/../src/include"
  360. CPPFLAGS="$CPPFLAGS -I`pwd`/../src/interfaces -I`pwd`/../src/interfaces/libpq"
  361. CPPFLAGS="$CPPFLAGS %{l_cppflags}"
  362. export LDFLAGS="-L`pwd`/../src/interfaces/libpq %{l_ldflags}"
  363. ./configure \
  364. --prefix=%{l_prefix} \
  365. --with-unixodbc=%{l_prefix} \
  366. --with-odbcinst=%{l_prefix}/etc/unixodbc
  367. %{l_make} %{l_mflags -O}
  368. ) || exit $?
  369. %endif
  370. # build JDBC driver
  371. %if "%{with_jdbc}" == "yes"
  372. ( cd postgresql-jdbc-%{V_pgjdbc}.src
  373. export JAVA_PLATFORM="sun-jdk"
  374. eval `%{l_prefix}/bin/java-toolkit -e`
  375. %{l_prefix}/bin/ant
  376. ) || exit $?
  377. %endif
  378. # build Slony-1 replication engine
  379. %if "%{with_slony1}" == "yes"
  380. ( cd slony1-%{V_slony1}
  381. ln ../src/pl/plpgsql/src/libplpgsql.so \
  382. ../src/pl/plpgsql/src/plpgsql.so
  383. %{l_shtool} subst \
  384. -e 's;-lpq;-lpq @LIBS@;' \
  385. Makefile.global.in
  386. export CC="%{l_cc}"
  387. export CFLAGS="%{l_cflags -O}"
  388. export CPPFLAGS="%{l_cppflags}"
  389. export LDFLAGS="%{l_ldflags}"
  390. export LIBS="-lssl -lcrypto -lcrypt"
  391. ./configure \
  392. --prefix=%{l_prefix} \
  393. --sysconfdir=%{l_prefix}/etc/postgresql \
  394. --with-pgconfigdir=../src/bin/pg_config \
  395. --with-pgincludedir=../src/include \
  396. --with-pgincludeserverdir=../src/interfaces/libpq \
  397. --with-pglibdir=../src/interfaces/libpq \
  398. --with-pgpkglibdir=../src/pl/plpgsql/src \
  399. --with-pgsharedir=../src/backend/utils/misc
  400. %{l_make} %{l_mflags -O}
  401. ) || exit $?
  402. %endif
  403. # rebuild pg_config with hard-coded path to avoid that it provides
  404. # dynamically resolved paths which circumvent symlinks, etc.
  405. ( cd src/bin/pg_config
  406. %{l_shtool} subst \
  407. -e 's:find_my_exec(argv.0., mypath):0; strcpy(mypath, "%{l_prefix}/bin/pg_config"):' \
  408. pg_config.c
  409. %{l_make} %{l_mflags}
  410. ) || exit $?
  411. %install
  412. rm -rf $RPM_BUILD_ROOT
  413. # perform standard installation procedure
  414. cp /dev/null register.txt
  415. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  416. # strip down installation
  417. rm -rf $RPM_BUILD_ROOT%{l_prefix}/doc
  418. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  419. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgaccess.1
  420. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgtclsh.1
  421. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgtksh.1
  422. # namespace adjustments to installation
  423. for prog in \
  424. createdb createlang createuser dropdb droplang clusterdb \
  425. dropuser initdb ipcclean vacuumdb reindexdb; do
  426. %if "%{with_compat}" == "yes"
  427. cmd="ln"
  428. %else
  429. cmd="mv"
  430. %endif
  431. $cmd $RPM_BUILD_ROOT%{l_prefix}/bin/$prog \
  432. $RPM_BUILD_ROOT%{l_prefix}/bin/pg_$prog
  433. $cmd $RPM_BUILD_ROOT%{l_prefix}/man/man1/$prog.1 \
  434. $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_$prog.1
  435. done
  436. ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man7
  437. for man in *.7; do
  438. mv $man pg_$man
  439. done
  440. ) || exit $?
  441. # create additional directories
  442. %{l_shtool} mkdir -f -p -m 755 \
  443. %if "%{with_slony1}" == "yes" || "%{with_pgcluster}" == "yes"
  444. $RPM_BUILD_ROOT%{l_prefix}/etc/postgresql \
  445. %endif
  446. $RPM_BUILD_ROOT%{l_prefix}/var/postgresql/db \
  447. $RPM_BUILD_ROOT%{l_prefix}/var/postgresql/run
  448. # install addon utilities
  449. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  450. %{SOURCE pg_migrate} $RPM_BUILD_ROOT%{l_prefix}/bin/
  451. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  452. -e "s;@l_bash@;%{l_bash};g" \
  453. %{SOURCE pg_passwd} $RPM_BUILD_ROOT%{l_prefix}/bin/
  454. # install C++ bindings (both old and new one)
  455. %if "%{with_cxx}" == "yes"
  456. ( cd libpq++-%{V_libpqpp}
  457. %{l_shtool} mkdir -f -p -m 755 \
  458. $RPM_BUILD_ROOT%{l_prefix}/include/libpq++
  459. %{l_shtool} install -c -m 644 \
  460. libpq++.h pgconnection.h pgdatabase.h pgtransdb.h pgcursordb.h pglobject.h \
  461. $RPM_BUILD_ROOT%{l_prefix}/include/libpq++/
  462. %{l_shtool} install -c -m 644 \
  463. libpq++.a \
  464. $RPM_BUILD_ROOT%{l_prefix}/lib/
  465. ) || exit $?
  466. ( cd libpqxx-%{V_libpqxx}
  467. %{l_shtool} mkdir -f -p -m 755 \
  468. $RPM_BUILD_ROOT%{l_prefix}/include/pqxx
  469. %{l_shtool} install -c -m 644 \
  470. include/pqxx/* \
  471. $RPM_BUILD_ROOT%{l_prefix}/include/pqxx/
  472. rm -f $RPM_BUILD_ROOT%{l_prefix}/include/pqxx/Makefile*
  473. rm -f $RPM_BUILD_ROOT%{l_prefix}/include/pqxx/config.h*
  474. %{l_shtool} install -c -m 644 \
  475. src/.libs/libpqxx.a \
  476. $RPM_BUILD_ROOT%{l_prefix}/lib/
  477. ) || exit $?
  478. %endif
  479. # install Perl binding
  480. %if "%{with_perl}" == "yes"
  481. ( export POSTGRES_INCLUDE=dummy
  482. export POSTGRES_LIB=dummy
  483. %{l_prefix}/bin/perl-openpkg -d Pg-%{V_pgperl} install
  484. ) || exit $?
  485. %{l_prefix}/bin/perl-openpkg -F perl-openpkg-files fixate cleanup
  486. %else
  487. >perl-openpkg-files
  488. %endif
  489. # install ODBC driver
  490. %if "%{with_odbc}" == "yes"
  491. ( cd psqlodbc-%{V_psqlodbc}
  492. %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
  493. ) || exit $?
  494. %endif
  495. # install JDBC driver
  496. %if "%{with_jdbc}" == "yes"
  497. ( cd postgresql-jdbc-%{V_pgjdbc}.src
  498. %{l_shtool} install -c -m 644 \
  499. jars/postgresql.jar $RPM_BUILD_ROOT%{l_prefix}/lib/
  500. ) || exit $?
  501. %endif
  502. # install Slony-1 replication engine
  503. %if "%{with_slony1}" == "yes"
  504. ( cd slony1-%{V_slony1}
  505. %{l_shtool} subst \
  506. -e 's;$(SQL_NAME80);$(SQL_NAME74);g' \
  507. src/xxid/Makefile
  508. %{l_make} %{l_mflags} install \
  509. DESTDIR=$RPM_BUILD_ROOT \
  510. pgconfigdir=%{l_prefix}/bin \
  511. pgincludedir=%{l_prefix}/include/postgresql \
  512. pgincludeserverdir=%{l_prefix}/include/postgresql/libpq \
  513. pglibdir=%{l_prefix}/lib/postgresql \
  514. pgpkglibdir=%{l_prefix}/lib/postgresql \
  515. pgsharedir=%{l_prefix}/share/postgresql
  516. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/slony1*v7[34].sql
  517. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/xxid.v73.sql
  518. mv $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/xxid.v74.sql \
  519. $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/xxid.sql
  520. ( echo "# Slony-1 configuration for replication engine slon(1)"
  521. echo "SLON_CLUSTER_NAME=\"example\""
  522. echo "SLON_CONNECT_DBNAME=\"example\""
  523. echo "SLON_CONNECT_USER=\"postgresql\""
  524. echo "SLON_CONNECT_PASS=\"postgresql\""
  525. echo "SLON_CONNECT_HOST=\"localhost\""
  526. echo "SLON_SYNC_INTERVAL=\"10000\""
  527. echo "SLON_SYNC_TIMEOUT=\"60000\""
  528. echo "SLON_SYNC_GROUPSIZE=\"6\""
  529. echo "SLON_SYNC_LOGLEVEL=\"1\""
  530. ) >$RPM_BUILD_ROOT%{l_prefix}/etc/postgresql/slony1.conf
  531. ) || exit $?
  532. %endif
  533. # adjust default configuration for hourly auto-vacuum operation
  534. %{l_shtool} subst \
  535. -e 's;^# *\(stats_start_collector *=\) *[^#]*\(#.*\);\1 on \2;' \
  536. -e 's;^# *\(stats_row_level *=\) *[^#]*\(#.*\);\1 on \2;' \
  537. -e 's;^# *\(autovacuum *=\) *[^#]*\(#.*\);\1 on \2;' \
  538. -e 's;^# *\(autovacuum_naptime *=\) *[^#]*\(#.*\);\1 1h \2;' \
  539. $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/postgresql.conf.sample
  540. # post-adjust pgcluster configuration filenames
  541. %if "%{with_pgcluster}" == "yes"
  542. cp $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/pgreplicate.conf.sample \
  543. $RPM_BUILD_ROOT%{l_prefix}/etc/postgresql/pgreplicate.conf
  544. %endif
  545. # install MySQL compatibility layer
  546. %if "%{with_mysqlcompat}" == "yes"
  547. %{l_shtool} mkdir -f -p -m 755 \
  548. $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/mysqlcompat
  549. %{l_shtool} install -c -m 644 \
  550. mysqlcompat-%{V_mysqlcompat}/README \
  551. mysqlcompat-%{V_mysqlcompat}/*.sql \
  552. $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/mysqlcompat/
  553. %endif
  554. # install run-command script
  555. %{l_shtool} mkdir -f -p -m 755 \
  556. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  557. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  558. %{SOURCE rc.postgresql} \
  559. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  560. # optionally strip down to client-only installation
  561. %if "%{with_server}" != "yes"
  562. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/pg_[a-bd-z]*
  563. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/pg_c[a-np-z]*
  564. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/pg_controldata
  565. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/post*
  566. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_[a-bd-z]*
  567. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_c[a-np-z]*
  568. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_controldata.1
  569. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/post*
  570. rm -rf $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  571. rm -rf $RPM_BUILD_ROOT%{l_prefix}/include/postgresql/server
  572. rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/postgresql
  573. rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/postgresql
  574. rm -rf $RPM_BUILD_ROOT%{l_prefix}/var/postgresql
  575. %endif
  576. # determine installation files
  577. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  578. %if "%{with_server}" == "yes"
  579. %{l_files_std} `cat perl-openpkg-files` \
  580. %if "%{with_slony1}" == "yes" || "%{with_pgcluster}" == "yes"
  581. '%config %{l_prefix}/etc/postgresql/*' \
  582. %endif
  583. '%attr(700,%{l_rusr},%{l_rgrp}) %dir %{l_prefix}/var/postgresql/db' \
  584. '%attr(755,%{l_rusr},%{l_rgrp}) %dir %{l_prefix}/var/postgresql/run'
  585. %else
  586. %{l_files_std} `cat perl-openpkg-files`
  587. %endif
  588. %files -f files
  589. %clean
  590. rm -rf $RPM_BUILD_ROOT
  591. %pre
  592. %if "%{with_server}" == "yes"
  593. # before upgrade, check migration dump, save status and stop service
  594. [ $1 -eq 2 ] || exit 0
  595. if [ -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION -a \
  596. -f $RPM_INSTALL_PREFIX/bin/pg_migrate ]; then
  597. # database migration dumping hint
  598. v_old_all=`cat $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION`
  599. v_old_maj=`echo "$v_old_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
  600. v_new_all="%{V_postgresql}"
  601. v_new_maj=`echo "$v_new_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
  602. if [ ".$v_old_maj" != ".$v_new_maj" ]; then
  603. if [ ! -f $RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2 -a ".$RPM_POSTGRESQL_MIGRATE" != .ignore ]; then
  604. ( echo "You are upgrading from PostgreSQL $v_old_all to PostgresSQL $v_new_all,"
  605. echo "which is a major version change. We expect a database incompatibility,"
  606. echo "so we strongly recommend that you backup your existing database"
  607. echo "($RPM_INSTALL_PREFIX/var/postgresql/db/) first by running:"
  608. echo " \$ $RPM_INSTALL_PREFIX/bin/pg_migrate dump"
  609. echo "If this fails for some reasons, try to dump your data manually:"
  610. echo " \$ $RPM_INSTALL_PREFIX/bin/pg_dumpall -U postgresql -o | \\ "
  611. echo " $RPM_INSTALL_PREFIX/lib/openpkg/bzip2 -9 \\ "
  612. echo " >$RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2"
  613. echo "Alternatively, if you want to force this package to be installed without"
  614. echo "performing a database dump, run the following command before upgrading:"
  615. echo " \$ RPM_POSTGRESQL_MIGRATE=ignore; export RPM_POSTGRESQL_MIGRATE"
  616. ) | %{l_rpmtool} msg -b -t error
  617. exit 1
  618. fi
  619. fi
  620. fi
  621. eval `%{l_rc} postgresql status 2>/dev/null | tee %{l_tmpfile}`
  622. %{l_rc} postgresql stop 2>/dev/null
  623. exit 0
  624. %endif
  625. %post
  626. %if "%{with_server}" == "yes"
  627. %if "%{with_compat}" == "yes"
  628. l_pguser="postgres"
  629. l_pgpass="postgres"
  630. %else
  631. l_pguser="postgresql"
  632. l_pgpass="postgresql"
  633. %endif
  634. if [ $1 -eq 1 ]; then
  635. # create initial database
  636. su - %{l_rusr} -c \
  637. "LC_CTYPE=C; export LC_CTYPE; umask 077; \
  638. rm -rf $RPM_INSTALL_PREFIX/var/postgresql/db/*; \
  639. echo $l_pgpass >$RPM_INSTALL_PREFIX/var/postgresql/run/pg_initdb.pw; \
  640. $RPM_INSTALL_PREFIX/bin/pg_initdb \
  641. --encoding=SQL_ASCII --locale=C --auth=md5 --username=$l_pguser \
  642. --pwfile=$RPM_INSTALL_PREFIX/var/postgresql/run/pg_initdb.pw \
  643. --pgdata=$RPM_INSTALL_PREFIX/var/postgresql/db; \
  644. rm -f $RPM_INSTALL_PREFIX/var/postgresql/run/pg_initdb.pw" 2>&1 | \
  645. $RPM_INSTALL_PREFIX/lib/openpkg/shtool prop \
  646. -p "Creating initial PostgreSQL DB in $RPM_INSTALL_PREFIX/var/postgresql/db"
  647. if [ ! -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION ]; then
  648. echo "ERROR: failed to create initial PostgreSQL database" 1>&2
  649. exit 1
  650. fi
  651. ( umask 077
  652. ( echo "##"
  653. echo "## pg_superuser.conf -- PostgreSQL database superuser configuration"
  654. echo "##"
  655. echo ""
  656. echo "superuser_database=\"template1\""
  657. echo "superuser_username=\"$l_pguser\""
  658. echo "superuser_password=\"$l_pgpass\""
  659. echo ""
  660. ) >$RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf
  661. chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf || exit $?
  662. chmod 600 $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf || exit $?
  663. ) || exit $?
  664. # display information about next steps
  665. ( echo "An initial PostgreSQL DB was created with the two standard"
  666. echo "databases 'template0' and 'template1'. The owner of both"
  667. echo "is the DB user '$l_pguser'. Its initial password is '$l_pgpass'."
  668. echo ""
  669. echo "After starting PostgreSQL with"
  670. echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc postgresql start"
  671. echo "you should immediately change this with the following command:"
  672. echo " \$ $RPM_INSTALL_PREFIX/bin/pg_passwd postgresql template1"
  673. echo ""
  674. echo "Then you usually create a database for a user <user> (assuming that"
  675. echo "his home directory is /u/<user>) with password <password> under"
  676. echo "path /u/<user>/rdbms with the commands:"
  677. echo " \$ mkdir /u/<user>/rdbms"
  678. echo " \$ chmod 700 /u/<user>/rdbms"
  679. echo " \$ chown %{l_rusr}:%{l_rgrp} /u/<user>/rdbms"
  680. echo " \$ $RPM_INSTALL_PREFIX/bin/psql -U $l_pguser -d template1"
  681. echo " template1=> CREATE ROLE <user>"
  682. echo " LOGIN ENCRYPTED PASSWORD '<password>'"
  683. echo " NOCREATEDB NOCREATEROLE;"
  684. echo " template1=> CREATE TABLESPACE <user> OWNER <user>"
  685. echo " LOCATION '/u/<user>/rdbms';"
  686. echo " template1=> CREATE DATABASE <user> OWNER <user>"
  687. echo " TABLESPACE <user>;"
  688. echo " \$ echo 'localhost:*:<user>:<user>:<password>' >>/u/<user>/.pgpass"
  689. echo " \$ chmod 600 <user> /u/<user>/.pgpass"
  690. echo " \$ chown <user> /u/<user>/.pgpass"
  691. echo "After this the user <user> will be able to connect to his RDBMS with:"
  692. echo " \$ $RPM_INSTALL_PREFIX/bin/psql"
  693. ) | %{l_rpmtool} msg -b -t notice
  694. # optionally link into ODBC
  695. %if "%{with_odbc}" == "yes"
  696. ( echo "[PostgreSQL]"
  697. echo "Description = PostgreSQL ODBC driver"
  698. echo "Driver = $RPM_INSTALL_PREFIX/lib/psqlodbc.so"
  699. echo "Threading = 2"
  700. ) | $RPM_INSTALL_PREFIX/bin/odbcinst -i -d -r -n "PostgreSQL"
  701. %endif
  702. fi
  703. if [ $1 -eq 2 ]; then
  704. # after upgrade, restore status
  705. { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null 2>&1
  706. [ ".$postgresql_active" = .yes ] && %{l_rc} postgresql start
  707. if [ -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION -a \
  708. ! -f $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf ]; then
  709. ( umask 077
  710. ( echo "##"
  711. echo "## pg_superuser.conf -- PostgreSQL database superuser configuration"
  712. echo "##"
  713. echo ""
  714. echo "superuser_database=\"template1\""
  715. echo "superuser_username=\"$l_pguser\""
  716. echo "superuser_password=\"\""
  717. echo ""
  718. ) >$RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf
  719. chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf || exit $?
  720. chmod 600 $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf || exit $?
  721. ) || exit $?
  722. ( echo "Created still missing \"pg_superuser.conf\" configuration file."
  723. echo "You should update its content by resetting the PostgreSQL"
  724. echo "superuser account password with the following command:"
  725. echo " \$ $RPM_INSTALL_PREFIX/bin/pg_passwd postgresql template1"
  726. ) | %{l_rpmtool} msg -b -t warn
  727. fi
  728. if [ -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION -a ".$PG_MIGRATE" != .ignore ]; then
  729. # database migration restoring hint
  730. v_old_all=`cat $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION`
  731. v_old_maj=`echo "$v_old_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
  732. v_new_all="%{V_postgresql}"
  733. v_new_maj=`echo "$v_new_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
  734. if [ ".$v_old_maj" != ".$v_new_maj" ]; then
  735. ( echo "You upgraded from PostgreSQL $v_old_all to PostgresSQL $v_new_all,"
  736. echo "which is a major version upgrade. We expect a database incompatibility,"
  737. echo "so we strongly recommend you to recreate the existing database under"
  738. echo "$RPM_INSTALL_PREFIX/var/postgresql/db/ by running the following command:"
  739. echo " \$ $RPM_INSTALL_PREFIX/bin/pg_migrate restore"
  740. echo "If this fails for some reasons, try to restore your data manually:"
  741. echo " \$ $RPM_INSTALL_PREFIX/lib/openpkg/bzip2 -d -c \\ "
  742. echo " $RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2 | \\ "
  743. echo " $RPM_INSTALL_PREFIX/bin/psql -U postgresql -d template1"
  744. ) | %{l_rpmtool} msg -b -t warn
  745. fi
  746. fi
  747. fi
  748. exit 0
  749. %endif
  750. %preun
  751. %if "%{with_server}" == "yes"
  752. # before erase, stop service and remove log files
  753. [ $1 -eq 0 ] || exit 0
  754. %{l_rc} postgresql stop 2>/dev/null
  755. rm -f $RPM_INSTALL_PREFIX/var/postgresql/run/* >/dev/null 2>&1 || true
  756. # optionally unlink from ODBC
  757. %if "%{with_odbc}" == "yes"
  758. $RPM_INSTALL_PREFIX/bin/odbcinst -u -d -n "PostgreSQL"
  759. %endif
  760. exit 0
  761. %endif