postgresql83.spec 31 KB

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