postgresql.spec 18 KB

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