postgresql.spec 22 KB

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