postgresql.spec 19 KB

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