postgresql8.spec 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. ##
  2. ## postgresql8.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2005 The OpenPKG Project <http://www.openpkg.org/>
  4. ## Copyright (c) 2000-2005 Ralf S. Engelschall <rse@engelschall.com>
  5. ## Copyright (c) 2000-2005 Cable & Wireless <http://www.cw.com/>
  6. ##
  7. ## Permission to use, copy, modify, and distribute this software for
  8. ## any purpose with or without fee is hereby granted, provided that
  9. ## the above copyright notice and this permission notice appear in all
  10. ## copies.
  11. ##
  12. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  13. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  16. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  17. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  18. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  19. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  21. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  22. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  23. ## SUCH DAMAGE.
  24. ##
  25. # package versions
  26. %define V_postgresql 8.0.0
  27. %define V_postgresql_rc 1
  28. %define V_libpqpp 4.0
  29. %define V_libpqxx 2.4.2
  30. %define V_pgperl 2.0.2
  31. %define V_psqlodbc 07.03.0200
  32. %define V_slony1 1.0.5
  33. %define V_pgpool 2.4
  34. # package information
  35. Name: postgresql8
  36. Summary: PostgreSQL Database
  37. URL: http://www.postgresql.org/
  38. Vendor: PostgreSQL Group
  39. Packager: The OpenPKG Project
  40. Distribution: OpenPKG
  41. Class: BASE
  42. Group: Database
  43. License: GPL
  44. Version: %{V_postgresql}rc%{V_postgresql_rc}
  45. Release: 20050110
  46. # package options
  47. %option with_server yes
  48. %option with_cxx no
  49. %option with_perl no
  50. %option with_odbc no
  51. %option with_compat no
  52. %option with_tcl no
  53. %option with_slony1 no
  54. %option with_pgpool no
  55. # list of sources
  56. Source0: ftp://ftp.postgresql.org/pub/source/v%{V_postgresql}beta/postgresql-%{V_postgresql}rc%{V_postgresql_rc}.tar.bz2
  57. Source1: ftp://gborg.postgresql.org/pub/libpqpp/stable/libpq++-%{V_libpqpp}.tar.gz
  58. Source2: ftp://gborg.postgresql.org/pub/libpqxx/stable/libpqxx-%{V_libpqxx}.tar.gz
  59. Source3: ftp://gborg.postgresql.org/pub/pgperl/stable/pgperl-%{V_pgperl}.tar.gz
  60. Source4: ftp://ftp.us.postgresql.org/odbc/versions/src/psqlodbc-%{V_psqlodbc}.tar.gz
  61. Source5: http://developer.postgresql.org/~wieck/slony1/download/slony1-%{V_slony1}.tar.gz
  62. Source6: http://www2b.biglobe.ne.jp/~caco/pgpool/pgpool-%{V_pgpool}.tar.gz
  63. Source7: rc.postgresql
  64. Source8: pg_migrate
  65. Patch0: postgresql8.patch
  66. # build information
  67. Prefix: %{l_prefix}
  68. BuildRoot: %{l_buildroot}
  69. BuildPreReq: OpenPKG, openpkg >= 20040130, make, gcc, flex, bison, gzip
  70. PreReq: OpenPKG, openpkg >= 20040130
  71. BuildPreReq: readline, zlib, openssl, getopt
  72. PreReq: readline, zlib, openssl, getopt
  73. %if "%{with_perl}" == "yes"
  74. BuildPreReq: perl, perl-openpkg >= 5.8.3-20040126
  75. PreReq: perl, perl-openpkg >= 5.8.3-20040126
  76. %endif
  77. %if "%{with_odbc}" == "yes"
  78. BuildPreReq: unixodbc
  79. PreReq: unixodbc
  80. %endif
  81. %if "%{with_tcl}" == "yes"
  82. BuildPreReq: tcl, tcl::with_x11 = yes, X11
  83. PreReq: tcl, tcl::with_x11 = yes, X11
  84. %endif
  85. AutoReq: no
  86. AutoReqProv: no
  87. Provides: postgresql = %{version}
  88. %description
  89. PostgreSQL is a sophisticated Object-Relational DBMS, supporting
  90. almost all SQL constructs, including subselects, transactions,
  91. and user-defined types and functions. It is the most advanced
  92. open-source database available anywhere.
  93. %track
  94. prog postgresql8 = {
  95. version = %{V_postgresql}
  96. url = ftp://ftp.postgresql.org/pub/source/
  97. regex = v(8\.\d+(\.\d+)*)(?!beta)
  98. url = ftp://ftp.postgresql.org/pub/source/v__NEWVER__/
  99. regex = postgresql-(\d+\.\d+(\.\d+)*((beta|rc)\d+))?\.tar\.(?:gz|bz2)
  100. }
  101. prog postgresql8:libpq++ = {
  102. version = %{V_libpqpp}
  103. url = ftp://gborg.postgresql.org/pub/libpqpp/stable/
  104. regex = libpq\+\+-(__VER__)\.tar\.gz
  105. }
  106. prog postgresql8:libpqxx = {
  107. version = %{V_libpqxx}
  108. url = ftp://gborg.postgresql.org/pub/libpqxx/stable/
  109. regex = libpqxx-(__VER__)\.tar\.gz
  110. }
  111. prog postgresql8:pgperl = {
  112. version = %{V_pgperl}
  113. url = ftp://gborg.postgresql.org/pub/pgperl/stable/
  114. regex = pgperl-(__VER__)\.tar\.gz
  115. }
  116. prog postgresql8:psqlodbc = {
  117. version = %{V_psqlodbc}
  118. url = ftp://ftp.postgresql.org/pub/odbc/versions/src/
  119. regex = psqlodbc-(\d{2}\.\d{2}\.\d{4})\.tar\.gz
  120. }
  121. prog postgresql8:slony1 = {
  122. version = %{V_slony1}
  123. url = http://developer.postgresql.org/~wieck/slony1/download/
  124. regex = slony1-(__VER__)\.tar\.gz
  125. }
  126. prog postgresql8:pgpool = {
  127. version = %{V_pgpool}
  128. url = http://www2b.biglobe.ne.jp/~caco/pgpool/
  129. regex = pgpool-(__VER__)\.tar\.gz
  130. }
  131. %prep
  132. %setup -q -n postgresql-%{V_postgresql}rc%{V_postgresql_rc}
  133. %patch -p0
  134. %if "%{with_cxx}" == "yes"
  135. %setup -q -n postgresql-%{V_postgresql}rc%{V_postgresql_rc} -T -D -a 1
  136. %setup -q -n postgresql-%{V_postgresql}rc%{V_postgresql_rc} -T -D -a 2
  137. %endif
  138. %if "%{with_perl}" == "yes"
  139. %setup -q -n postgresql-%{V_postgresql}rc%{V_postgresql_rc} -T -D -a 3
  140. %endif
  141. %if "%{with_odbc}" == "yes"
  142. %setup -q -n postgresql-%{V_postgresql}rc%{V_postgresql_rc} -T -D -a 4
  143. %endif
  144. %if "%{with_slony1}" == "yes"
  145. %setup -q -n postgresql-%{V_postgresql}rc%{V_postgresql_rc} -T -D -a 5
  146. %endif
  147. %if "%{with_pgpool}" == "yes"
  148. %setup -q -n postgresql-%{V_postgresql}rc%{V_postgresql_rc} -T -D -a 6
  149. %endif
  150. # adjust source tree
  151. %{l_shtool} subst \
  152. -e 's;\(#define.*DEFAULT_PGSOCKET_DIR[^"]*"\)/tmp\("\);\1%{l_prefix}/var/postgresql/run\2;' \
  153. src/include/pg_config_manual.h
  154. %{l_shtool} subst \
  155. -e 's;^\(sqlmansect *=\).*$;\1 7;' \
  156. src/makefiles/Makefile.solaris
  157. %{l_shtool} subst \
  158. -e 's;$(INSTALL_SHLIB);#$(INSTALL_SHLIB);g' \
  159. src/backend/utils/mb/conversion_procs/proc.mk
  160. %{l_shtool} subst \
  161. -e 's;# Shared library stuff;enable_shared = yes;g' \
  162. src/pl/plpgsql/src/Makefile
  163. %build
  164. rm -rf $RPM_BUILD_ROOT
  165. # configure package
  166. CC="%{l_cc}" \
  167. %if "%{with_slony1}" == "yes"
  168. CFLAGS="%{l_cflags -O} -pthread" \
  169. %else
  170. CFLAGS="%{l_cflags -O}" \
  171. %endif
  172. %if "%{with_tcl}" == "yes"
  173. CPPFLAGS="%{l_cppflags readline tcl} -DOPENSSL_DISABLE_OLD_DES_SUPPORT" \
  174. LDFLAGS="%{l_ldflags} -L`%{l_rc} --query x11_libdir`" \
  175. %else
  176. CPPFLAGS="%{l_cppflags readline} -DOPENSSL_DISABLE_OLD_DES_SUPPORT" \
  177. LDFLAGS="%{l_ldflags}" \
  178. %endif
  179. TAR="%{l_tar}" \
  180. YACC="bison -y" \
  181. ./configure \
  182. --cache-file=./config.cache \
  183. --prefix=%{l_prefix} \
  184. --includedir=%{l_prefix}/include/postgresql \
  185. --with-openssl \
  186. --with-readline \
  187. --with-zlib \
  188. %if "%{with_tcl}" == "yes"
  189. --with-tcl \
  190. --with-tclconfig="%{l_prefix}/lib" \
  191. --with-tkconfig="%{l_prefix}/lib" \
  192. %endif
  193. %if "%{with_slony1}" == "yes"
  194. --enable-thread-safety \
  195. %endif
  196. --disable-syslog \
  197. --disable-shared
  198. # build package
  199. %{l_make} %{l_mflags}
  200. # build C++ bindings (both old and new one)
  201. %if "%{with_cxx}" == "yes"
  202. ( cd libpq++-%{V_libpqpp}
  203. CXX="%{l_cxx}"
  204. CFLAGS="%{l_cflags -O}"
  205. CPPFLAGS="-DHAVE_NAMESPACE_STD -DHAVE_CXX_STRING_HEADER -DDLLIMPORT= "
  206. CPPFLAGS="$CPPFLAGS -I. -I../src/interfaces/libpq -I../src/interfaces"
  207. CPPFLAGS="$CPPFLAGS -I../src/include %{l_cppflags}"
  208. LDFLAGS="%{l_ldflags}"
  209. OBJS="pgconnection.o pgdatabase.o pgtransdb.o pgcursordb.o pglobject.o"
  210. for o in $OBJS; do
  211. $CXX $CFLAGS $CPPFLAGS $LDFLAGS -c -o $o `echo $o | sed -e 's;\.o$;.cc;'`
  212. done
  213. rm -f libpq++.a
  214. ar rc libpq++.a $OBJS
  215. ) || exit $?
  216. ln -s `pwd`/src/interfaces/libpq/*.h src/include/
  217. ( cd libpqxx-%{V_libpqxx}
  218. %{l_shtool} subst \
  219. -e 's;\(cut\)\( .*/configitems\)\( -f [0-9]\);\1\3\2;g' \
  220. configure
  221. ( echo "#!/bin/sh"
  222. echo "case \"\$1\" in"
  223. echo " --includedir ) echo \"`pwd`/../src/include\" ;;"
  224. echo " --libdir ) echo \"`pwd`/../src/interfaces/libpq\" ;;"
  225. echo "esac"
  226. ) >pg_config
  227. chmod a+x pg_config
  228. export PG_CONFIG=`pwd`/pg_config
  229. export CC="%{l_cc}"
  230. export CXX="%{l_cxx}"
  231. export CFLAGS="%{l_cflags -O}"
  232. export CXXFLAGS="%{l_cxxflags -O}"
  233. export CPPFLAGS="-I`pwd`/../src/include %{l_cppflags}"
  234. export LDFLAGS="%{l_ldflags}"
  235. export LIBS="-lssl -lcrypto -lcrypt"
  236. case "%{l_platform -t}" in
  237. *-sunos* ) LIBS="$LIBS -lsocket -lnsl" ;;
  238. esac
  239. ./configure \
  240. --disable-shared
  241. %{l_make} %{l_mflags -O}
  242. ) || exit $?
  243. %endif
  244. # build Perl bindings
  245. %if "%{with_perl}" == "yes"
  246. %{l_prefix}/bin/perl-openpkg prepare
  247. ( cd Pg-%{V_pgperl}
  248. export POSTGRES_INCLUDE=dummy
  249. export POSTGRES_LIB=dummy
  250. %{l_shtool} subst \
  251. -e 's;-I$POSTGRES_INCLUDE;-I../src/interfaces/libpq -I../src/include;' \
  252. -e 's;-L$POSTGRES_LIB;-L../src/interfaces/libpq;' \
  253. -e 's;-lpq;-lpq %{l_ldflags} -lssl -lcrypto -lcrypt;' \
  254. Makefile.PL
  255. ) || exit $?
  256. ( export POSTGRES_INCLUDE=dummy
  257. export POSTGRES_LIB=dummy
  258. %{l_prefix}/bin/perl-openpkg -d Pg-%{V_pgperl} configure build
  259. ) || exit $?
  260. %endif
  261. # build ODBC driver
  262. %if "%{with_odbc}" == "yes"
  263. ( cd psqlodbc-%{V_psqlodbc}
  264. export CC="%{l_cc}"
  265. export CXX="%{l_cxx}"
  266. export CFLAGS="%{l_cflags -O}"
  267. export CXXFLAGS="%{l_cxxflags -O}"
  268. export CPPFLAGS="-I`pwd`/../src/include"
  269. CPPFLAGS="$CPPFLAGS -I`pwd`/../src/interfaces -I`pwd`/../src/interfaces/libpq"
  270. CPPFLAGS="$CPPFLAGS %{l_cppflags}"
  271. export LDFLAGS="-L`pwd`/../src/interfaces/libpq %{l_ldflags}"
  272. ./configure \
  273. --prefix=%{l_prefix} \
  274. --with-unixodbc \
  275. --with-odbcinst=%{l_prefix}/etc/unixodbc
  276. %{l_make} %{l_mflags -O}
  277. ) || exit $?
  278. %endif
  279. # build Slony-1 replication engine
  280. %if "%{with_slony1}" == "yes"
  281. ( cd slony1-%{V_slony1}
  282. %{l_shtool} subst \
  283. -e 's;-lpq;-lpq -lssl -lcrypto -lcrypt;' \
  284. src/slon/Makefile src/slonik/Makefile
  285. export CC="%{l_cc}"
  286. export CFLAGS="%{l_cflags -O}"
  287. export CPPFLAGS="%{l_cppflags}"
  288. ./configure \
  289. --prefix=%{l_prefix} \
  290. --with-pgsourcetree=`pwd`/..
  291. %{l_make} %{l_mflags -O}
  292. ) || exit $?
  293. %endif
  294. # build pgpool frontend
  295. %if "%{with_pgpool}" == "yes"
  296. ( cd pgpool-%{V_pgpool}
  297. export CC="%{l_cc}"
  298. export CFLAGS="%{l_cflags -O} %{l_cppflags}"
  299. export LDFLAGS="%{l_ldflags}"
  300. export LIBS="-lgetopt"
  301. ./configure \
  302. --prefix=%{l_prefix} \
  303. --sysconfdir=%{l_prefix}/etc/postgresql \
  304. --with-pgsrc=/dummy
  305. %{l_make} %{l_mflags}
  306. ) || exit $?
  307. %endif
  308. %install
  309. rm -rf $RPM_BUILD_ROOT
  310. # perform standard installation procedure
  311. cp /dev/null register.txt
  312. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  313. # strip down installation
  314. rm -rf $RPM_BUILD_ROOT%{l_prefix}/doc
  315. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  316. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgaccess.1
  317. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgtclsh.1
  318. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgtksh.1
  319. # namespace adjustments to installation
  320. for prog in \
  321. createdb createlang createuser dropdb droplang clusterdb \
  322. dropuser initdb ipcclean vacuumdb; do
  323. %if "%{with_compat}" == "yes"
  324. cmd="ln"
  325. %else
  326. cmd="mv"
  327. %endif
  328. $cmd $RPM_BUILD_ROOT%{l_prefix}/bin/$prog \
  329. $RPM_BUILD_ROOT%{l_prefix}/bin/pg_$prog
  330. $cmd $RPM_BUILD_ROOT%{l_prefix}/man/man1/$prog.1 \
  331. $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_$prog.1
  332. done
  333. ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man7
  334. for man in *.7; do
  335. mv $man pg_$man
  336. done
  337. ) || exit $?
  338. # create additional directories
  339. %{l_shtool} mkdir -f -p -m 755 \
  340. $RPM_BUILD_ROOT%{l_prefix}/etc/postgresql \
  341. $RPM_BUILD_ROOT%{l_prefix}/var/postgresql/db \
  342. $RPM_BUILD_ROOT%{l_prefix}/var/postgresql/run
  343. # install migration utility
  344. %if "%{with_compat}" == "yes"
  345. l_pguser="postgres"
  346. l_pgpass="postgres"
  347. %else
  348. l_pguser="postgresql"
  349. l_pgpass="postgresql"
  350. %endif
  351. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  352. -e "s;@l_pguser@;${l_pguser};g" \
  353. -e "s;@l_pgpass@;${l_pgpass};g" \
  354. %{SOURCE pg_migrate} \
  355. $RPM_BUILD_ROOT%{l_prefix}/bin/
  356. # install C++ bindings (both old and new one)
  357. %if "%{with_cxx}" == "yes"
  358. ( cd libpq++-%{V_libpqpp}
  359. %{l_shtool} mkdir -f -p -m 755 \
  360. $RPM_BUILD_ROOT%{l_prefix}/include/libpq++
  361. %{l_shtool} install -c -m 644 \
  362. libpq++.h pgconnection.h pgdatabase.h pgtransdb.h pgcursordb.h pglobject.h \
  363. $RPM_BUILD_ROOT%{l_prefix}/include/libpq++/
  364. %{l_shtool} install -c -m 644 \
  365. libpq++.a \
  366. $RPM_BUILD_ROOT%{l_prefix}/lib/
  367. ) || exit $?
  368. ( cd libpqxx-%{V_libpqxx}
  369. %{l_shtool} mkdir -f -p -m 755 \
  370. $RPM_BUILD_ROOT%{l_prefix}/include/pqxx
  371. %{l_shtool} install -c -m 644 \
  372. include/pqxx/* \
  373. $RPM_BUILD_ROOT%{l_prefix}/include/pqxx/
  374. rm -f $RPM_BUILD_ROOT%{l_prefix}/include/pqxx/Makefile*
  375. rm -f $RPM_BUILD_ROOT%{l_prefix}/include/pqxx/config.h*
  376. %{l_shtool} install -c -m 644 \
  377. src/.libs/libpqxx.a \
  378. $RPM_BUILD_ROOT%{l_prefix}/lib/
  379. ) || exit $?
  380. %endif
  381. # install Perl binding
  382. %if "%{with_perl}" == "yes"
  383. ( export POSTGRES_INCLUDE=dummy
  384. export POSTGRES_LIB=dummy
  385. %{l_prefix}/bin/perl-openpkg -d Pg-%{V_pgperl} install
  386. ) || exit $?
  387. %{l_prefix}/bin/perl-openpkg -F perl-openpkg-files fixate cleanup
  388. %else
  389. >perl-openpkg-files
  390. %endif
  391. # install ODBC driver
  392. %if "%{with_odbc}" == "yes"
  393. ( cd psqlodbc-%{V_psqlodbc}
  394. %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
  395. ) || exit $?
  396. %endif
  397. # install Slony-1 replication engine
  398. %if "%{with_slony1}" == "yes"
  399. ( cd slony1-%{V_slony1}
  400. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  401. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/slony1*v7[34].sql
  402. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/xxid.v73.sql
  403. mv $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/xxid.v74.sql \
  404. $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/xxid.sql
  405. ( echo "# Slony-1 configuration for replication engine slon(1)"
  406. echo "SLON_CLUSTER_NAME=\"example\""
  407. echo "SLON_CONNECT_DBNAME=\"example\""
  408. echo "SLON_CONNECT_USER=\"postgresql\""
  409. echo "SLON_CONNECT_PASS=\"postgresql\""
  410. echo "SLON_CONNECT_HOST=\"localhost\""
  411. echo "SLON_SYNC_INTERVAL=\"10000\""
  412. echo "SLON_SYNC_TIMEOUT=\"60000\""
  413. echo "SLON_SYNC_GROUPSIZE=\"6\""
  414. echo "SLON_SYNC_LOGLEVEL=\"1\""
  415. ) >$RPM_BUILD_ROOT%{l_prefix}/etc/postgresql/slony1.conf
  416. ) || exit $?
  417. %endif
  418. # install pgpool frontend
  419. %if "%{with_pgpool}" == "yes"
  420. ( cd pgpool-%{V_pgpool}
  421. %{l_shtool} install -c -s -m 755 \
  422. pgpool $RPM_BUILD_ROOT%{l_prefix}/bin/
  423. %{l_shtool} install -c -m 644 \
  424. -e "s;\(socket_dir = \).*;\1'%{l_prefix}/var/postgresql/run';" \
  425. -e "s;\(backend_socket_dir = \).*;\1'%{l_prefix}/var/postgresql/run';" \
  426. -e "s;\(logdir = \).*;\1'%{l_prefix}/var/postgresql/run';" \
  427. pgpool.conf.sample $RPM_BUILD_ROOT%{l_prefix}/etc/postgresql/pgpool.conf
  428. ) || exit $?
  429. %endif
  430. # install run-command script
  431. %{l_shtool} mkdir -f -p -m 755 \
  432. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  433. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  434. %{SOURCE rc.postgresql} \
  435. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  436. # optionally strip down to client-only installation
  437. %if "%{with_server}" != "yes"
  438. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/pg_[a-bd-z]*
  439. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/pg_c[a-np-z]*
  440. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/pg_controldata
  441. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/post*
  442. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_[a-bd-z]*
  443. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_c[a-np-z]*
  444. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_controldata.1
  445. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/post*
  446. rm -rf $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  447. rm -rf $RPM_BUILD_ROOT%{l_prefix}/include/postgresql/server
  448. rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/postgresql
  449. rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/postgresql
  450. rm -rf $RPM_BUILD_ROOT%{l_prefix}/var/postgresql
  451. %endif
  452. # determine installation files
  453. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  454. %if "%{with_server}" == "yes"
  455. %{l_files_std} `cat perl-openpkg-files` \
  456. '%config %{l_prefix}/etc/postgresql/*' \
  457. '%attr(700,%{l_rusr},%{l_rgrp}) %dir %{l_prefix}/var/postgresql/db' \
  458. '%attr(755,%{l_rusr},%{l_rgrp}) %dir %{l_prefix}/var/postgresql/run' \
  459. '%config %{l_prefix}/var/postgresql/db/*.conf'
  460. %else
  461. %{l_files_std} `cat perl-openpkg-files`
  462. %endif
  463. %files -f files
  464. %clean
  465. rm -rf $RPM_BUILD_ROOT
  466. %pre
  467. %if "%{with_server}" == "yes"
  468. # before upgrade, check migration dump, save status and stop service
  469. [ $1 -eq 2 ] || exit 0
  470. if [ -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION -a \
  471. -f $RPM_INSTALL_PREFIX/bin/pg_migrate ]; then
  472. # database migration dumping hint
  473. v_old_all=`cat $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION`
  474. v_old_maj=`echo "$v_old_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
  475. v_new_all="%{V_postgresql}"
  476. v_new_maj=`echo "$v_new_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
  477. if [ ".$v_old_maj" != ".$v_new_maj" ]; then
  478. if [ ! -f $RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2 -a ".$RPM_POSTGRESQL_MIGRATE" != .ignore ]; then
  479. ( echo "You are upgrading from PostgreSQL $v_old_all to PostgresSQL $v_new_all,"
  480. echo "which is a major version change. We expect a database incompatibility,"
  481. echo "so we strongly recommend that you backup your existing database"
  482. echo "($RPM_INSTALL_PREFIX/var/postgresql/db/) first by running:"
  483. echo " \$ $RPM_INSTALL_PREFIX/bin/pg_migrate dump"
  484. echo "If this fails for some reasons, try to dump your data manually:"
  485. echo " \$ $RPM_INSTALL_PREFIX/bin/pg_dumpall -U postgresql -o | \\ "
  486. echo " $RPM_INSTALL_PREFIX/lib/openpkg/bzip2 -9 \\ "
  487. echo " >$RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2"
  488. echo "Alternatively, if you want to force this package to be installed without"
  489. echo "performing a database dump, run the following command before upgrading:"
  490. echo " \$ RPM_POSTGRESQL_MIGRATE=ignore; export RPM_POSTGRESQL_MIGRATE"
  491. ) | %{l_rpmtool} msg -b -t error
  492. exit 1
  493. fi
  494. fi
  495. fi
  496. eval `%{l_rc} postgresql status 2>/dev/null | tee %{l_tmpfile}`
  497. %{l_rc} postgresql stop 2>/dev/null
  498. exit 0
  499. %endif
  500. %post
  501. %if "%{with_server}" == "yes"
  502. if [ $1 -eq 1 ]; then
  503. # create initial database
  504. %if "%{with_compat}" == "yes"
  505. l_pguser="postgres"
  506. l_pgpass="postgres"
  507. %else
  508. l_pguser="postgresql"
  509. l_pgpass="postgresql"
  510. %endif
  511. su - %{l_rusr} -c \
  512. "LC_CTYPE=C; export LC_CTYPE; umask 022; \
  513. (echo $l_pguser; echo $l_pgpass) |\
  514. $RPM_INSTALL_PREFIX/bin/pg_initdb \
  515. -U $l_pguser -W -D $RPM_INSTALL_PREFIX/var/postgresql/db" 2>&1 |\
  516. $RPM_INSTALL_PREFIX/lib/openpkg/shtool prop \
  517. -p "Creating initial PostgreSQL DB in $RPM_INSTALL_PREFIX/var/postgresql/db"
  518. # adjust initial authentication configuration
  519. cp $RPM_INSTALL_PREFIX/var/postgresql/db/pg_hba.conf \
  520. $RPM_INSTALL_PREFIX/var/postgresql/db/pg_hba.conf.old
  521. ( cat $RPM_INSTALL_PREFIX/var/postgresql/db/pg_hba.conf.old |\
  522. sed -e 's;^\([^#]\);# \1;' -e 's;^$;#;'
  523. echo ""
  524. echo "# OpenPKG PostgreSQL default access policy"
  525. echo "local all all md5"
  526. echo "host all all 127.0.0.1 255.255.255.255 md5"
  527. echo ""
  528. ) >$RPM_INSTALL_PREFIX/var/postgresql/db/pg_hba.conf
  529. rm -f $RPM_INSTALL_PREFIX/var/postgresql/db/pg_hba.conf.old
  530. # display information about next steps
  531. ( echo "An initial PostgreSQL DB was created with the two standard"
  532. echo "databases 'template0' and 'template1'. The owner of both"
  533. echo "is the DB user '$l_pguser'. Its initial password is '$l_pgpass'."
  534. echo "After starting PostgreSQL you should change this as soon as"
  535. echo "possible with the following command:"
  536. echo "\$ $RPM_INSTALL_PREFIX/bin/psql -U $l_pguser -d template1 \\"
  537. echo " -c \"ALTER USER $l_pguser WITH PASSWORD '<new-password>'\""
  538. ) | %{l_rpmtool} msg -b -t notice
  539. # optionally link into unixODBC
  540. %if "%{with_odbc}" == "yes"
  541. ( echo "[PostgreSQL]"
  542. echo "Description = PostgreSQL ODBC driver"
  543. echo "Driver = $RPM_INSTALL_PREFIX/lib/psqlodbc.so"
  544. echo "Threading = 2"
  545. ) | $RPM_INSTALL_PREFIX/bin/odbcinst -i -d -r
  546. %endif
  547. fi
  548. if [ $1 -eq 2 ]; then
  549. # after upgrade, restore status
  550. { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null 2>&1
  551. [ ".$postgresql_active" = .yes ] && %{l_rc} postgresql start
  552. if [ -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION -a ".$PG_MIGRATE" != .ignore ]; then
  553. # database migration restoring hint
  554. v_old_all=`cat $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION`
  555. v_old_maj=`echo "$v_old_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
  556. v_new_all="%{V_postgresql}"
  557. v_new_maj=`echo "$v_new_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
  558. if [ ".$v_old_maj" != ".$v_new_maj" ]; then
  559. ( echo "You upgraded from PostgreSQL $v_old_all to PostgresSQL $v_new_all,"
  560. echo "which is a major version upgrade. We expect a database incompatibility,"
  561. echo "so we strongly recommend you to recreate the existing database under"
  562. echo "$RPM_INSTALL_PREFIX/var/postgresql/db/ by running the following command:"
  563. echo " \$ $RPM_INSTALL_PREFIX/bin/pg_migrate restore"
  564. echo "If this fails for some reasons, try to restore your data manually:"
  565. echo " \$ $RPM_INSTALL_PREFIX/lib/openpkg/bzip2 -d -c \\ "
  566. echo " $RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2 | \\ "
  567. echo " $RPM_INSTALL_PREFIX/bin/psql -U postgresql -d template1"
  568. ) | %{l_rpmtool} msg -b -t warn
  569. fi
  570. fi
  571. fi
  572. exit 0
  573. %endif
  574. %preun
  575. %if "%{with_server}" == "yes"
  576. # before erase, stop service and remove log files
  577. [ $1 -eq 0 ] || exit 0
  578. %{l_rc} postgresql stop 2>/dev/null
  579. rm -f $RPM_INSTALL_PREFIX/var/postgresql/run/* >/dev/null 2>&1 || true
  580. exit 0
  581. %endif