postgresql.spec 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. ##
  2. ## postgresql.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2020 OpenPKG Project <http://openpkg.org/>
  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 12.3
  25. %define V_postgresql_dist 12.3
  26. %define V_postgresql_dir 12.3
  27. # package information
  28. Name: postgresql
  29. Summary: PostgreSQL Database
  30. URL: http://www.postgresql.org/
  31. Vendor: PostgreSQL Group
  32. Packager: OpenPKG Project
  33. Distribution: OpenPKG Community
  34. Class: BASE
  35. Group: Database
  36. License: BSD
  37. Version: %{V_postgresql}
  38. Release: 20200514
  39. # package options
  40. %option with_server yes
  41. %option with_readline yes
  42. %option with_icu no
  43. %option with_threads no
  44. %option with_kerberos no
  45. %option with_ldap no
  46. %option with_perl no
  47. %option with_python no
  48. # list of sources
  49. Source0: https://ftp.postgresql.org/pub/source/v%{V_postgresql_dir}/postgresql-%{V_postgresql_dist}.tar.bz2
  50. Source1: rc.postgresql
  51. Source2: pg_migrate
  52. Source3: pg_passwd
  53. Patch0: postgresql.patch
  54. # build information
  55. BuildPreReq: OpenPKG, openpkg >= 20160101, make, gcc, flex, bison, gzip, pkgconfig
  56. PreReq: OpenPKG, openpkg >= 20160101
  57. BuildPreReq: zlib, openssl
  58. PreReq: zlib, openssl
  59. %if "%{with_readline}" == "yes"
  60. BuildPreReq: readline
  61. PreReq: readline
  62. %endif
  63. %if "%{with_icu}" == "yes"
  64. BuildPreReq: icu
  65. PreReq: icu
  66. %endif
  67. %if "%{with_kerberos}" == "yes"
  68. BuildPreReq: KERBEROS
  69. PreReq: KERBEROS
  70. %endif
  71. %if "%{with_ldap}" == "yes"
  72. BuildPreReq: openldap
  73. PreReq: openldap
  74. %endif
  75. %if "%{with_perl}" == "yes"
  76. BuildPreReq: perl
  77. PreReq: perl
  78. %endif
  79. %if "%{with_python}" == "yes"
  80. BuildPreReq: python
  81. PreReq: python
  82. %endif
  83. %description
  84. PostgreSQL is a sophisticated Object-Relational Database Management
  85. System (ORDBMS). It is fully ACID compliant and has full support
  86. for foreign keys, joins, views, triggers, and stored procedures
  87. (in multiple languages). It includes most SQL92 and SQL99 data
  88. types and also supports storage of binary large objects. It is
  89. the most advanced Open-Source RDBMS available anywhere. As an
  90. enterprise class RDBMS, PostgreSQL boasts sophisticated features
  91. such as Multi-Version Concurrency Control (MVCC), Point In Time
  92. Recovery (PITR), tablespaces, asynchronous replication, nested
  93. transactions (savepoints), online/hot backups, a sophisticated
  94. query planner/optimizer, and Write Ahead Logging (WAL) for fault
  95. tolerance. It supports international character sets, multibyte
  96. character encodings, Unicode, and it is locale-aware for sorting,
  97. case-sensitivity, and formatting. It is highly scalable both in the
  98. sheer quantity of data it can manage and in the number of concurrent
  99. users it can accommodate.
  100. %track
  101. prog postgresql = {
  102. version = %{V_postgresql_dist}
  103. url = http://www.postgresql.org/ftp/source/
  104. regex = v(\d+\.\d+(?:\.\d+)?)
  105. }
  106. %prep
  107. %setup -q
  108. %patch -p0
  109. %build
  110. # adjust source tree
  111. %{l_shtool} subst \
  112. -e 's;\(#define.*DEFAULT_PGSOCKET_DIR[^"]*"\)/tmp\("\);\1%{l_prefix}/var/postgresql/run\2;' \
  113. src/include/pg_config_manual.h
  114. %{l_shtool} subst \
  115. -e 's;^\(sqlmansect *=\).*$;\1 7;' \
  116. src/makefiles/Makefile.solaris
  117. %{l_shtool} subst \
  118. -e 's;# Shared library stuff;enable_shared = yes;g' \
  119. src/pl/plpgsql/src/Makefile
  120. # configure package
  121. echo "ac_cv_func_isinf=no" >config.cache
  122. export CC="%{l_cc}"
  123. export CFLAGS="%{l_cflags -O}"
  124. export CPPFLAGS="%{l_cppflags}"
  125. export LDFLAGS="%{l_ldflags}"
  126. export LIBS=""
  127. %if "%{with_readline}" == "yes"
  128. CFLAGS="$CFLAGS `pkg-config readline --cflags-only-other`"
  129. CPPFLAGS="$CPPFLAGS %{l_cppflags readline .} `pkg-config readline --cflags-only-I`"
  130. LDFLAGS="$LDFLAGS `pkg-config readline --libs-only-l`"
  131. LIBS="$LIBS `pkg-config readline --libs-only-l`"
  132. %endif
  133. %if "%{with_kerberos}" == "yes"
  134. CPPFLAGS="$CPPFLAGS `krb5-config --cflags`"
  135. LIBS="$LIBS `krb5-config --libs`"
  136. %endif
  137. %if "%{with_ldap}" == "yes"
  138. LIBS="$LIBS -lldap -llber -lssl -lcrypto"
  139. %endif
  140. export TAR="%{l_tar}"
  141. export YACC="bison -y"
  142. ./configure \
  143. --cache-file=./config.cache \
  144. --prefix=%{l_prefix} \
  145. --mandir=%{l_prefix}/man \
  146. --sysconfdir=%{l_prefix}/etc/postgresql \
  147. --includedir=%{l_prefix}/include/postgresql \
  148. --with-zlib \
  149. --with-openssl \
  150. %if "%{with_readline}" == "yes"
  151. --with-readline \
  152. %else
  153. --without-readline \
  154. %endif
  155. %if "%{with_icu}" == "yes"
  156. --with-icu \
  157. %else
  158. --without-icu \
  159. %endif
  160. %if "%{with_threads}" == "yes"
  161. --enable-thread-safety \
  162. %else
  163. --disable-thread-safety \
  164. %endif
  165. %if "%{with_kerberos}" == "yes"
  166. --with-krb5 \
  167. --with-krb-srvnam=postgresql \
  168. %endif
  169. %if "%{with_ldap}" == "yes"
  170. --with-ldap \
  171. %endif
  172. %if "%{with_perl}" == "yes"
  173. --with-perl \
  174. %endif
  175. %if "%{with_python}" == "yes"
  176. --with-python \
  177. %endif
  178. --disable-shared
  179. # build package
  180. %{l_make} %{l_mflags}
  181. # rebuild pg_config with hard-coded path to avoid that it provides
  182. # dynamically resolved paths which circumvent symlinks, etc.
  183. ( cd src/bin/pg_config
  184. %{l_shtool} subst \
  185. -e 's:find_my_exec(argv.0., mypath):0; strcpy(mypath, "%{l_prefix}/bin/pg_config"):' \
  186. pg_config.c
  187. %{l_make} %{l_mflags}
  188. ) || exit $?
  189. %install
  190. # perform standard installation procedure
  191. cp /dev/null register.txt
  192. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  193. ( cd doc/src/sgml
  194. touch man-stamp
  195. %{l_make} %{l_mflags} install-man DESTDIR=$RPM_BUILD_ROOT
  196. ) || exit $?
  197. # strip down installation
  198. rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/doc
  199. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  200. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgaccess.1
  201. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgtclsh.1
  202. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgtksh.1
  203. # namespace adjustments to installation
  204. for prog in \
  205. createdb createuser dropdb clusterdb \
  206. dropuser initdb vacuumdb reindexdb; do
  207. mv $RPM_BUILD_ROOT%{l_prefix}/bin/$prog \
  208. $RPM_BUILD_ROOT%{l_prefix}/bin/pg_$prog
  209. mv $RPM_BUILD_ROOT%{l_prefix}/man/man1/$prog.1 \
  210. $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_$prog.1
  211. done
  212. ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man7
  213. for man in *.7; do
  214. mv $man pg_$man
  215. done
  216. ) || exit $?
  217. # create additional directories
  218. %{l_shtool} mkdir -f -p -m 755 \
  219. $RPM_BUILD_ROOT%{l_prefix}/var/postgresql/db \
  220. $RPM_BUILD_ROOT%{l_prefix}/var/postgresql/run \
  221. $RPM_BUILD_ROOT%{l_prefix}/var/postgresql/log
  222. # install addon utilities
  223. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  224. %{SOURCE pg_migrate} $RPM_BUILD_ROOT%{l_prefix}/bin/
  225. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  226. -e "s;@l_bash@;%{l_bash};g" \
  227. %{SOURCE pg_passwd} $RPM_BUILD_ROOT%{l_prefix}/bin/
  228. # adjust default configuration for hourly auto-vacuum operation
  229. %{l_shtool} subst \
  230. -e 's;^# *\(track_counts *=\) *[^#]*\(#.*\);\1 on \2;' \
  231. -e 's;^# *\(autovacuum *=\) *[^#]*\(#.*\);\1 on \2;' \
  232. $RPM_BUILD_ROOT%{l_prefix}/share/postgresql/postgresql.conf.sample
  233. # install run-command script
  234. %{l_shtool} mkdir -f -p -m 755 \
  235. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  236. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  237. %{SOURCE rc.postgresql} \
  238. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  239. # optionally strip down to client-only installation
  240. %if "%{with_server}" != "yes"
  241. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/pg_[a-bd-z]*
  242. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/pg_c[a-np-z]*
  243. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/pg_controldata
  244. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/post*
  245. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_[a-bd-z]*
  246. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_c[a-np-z]*
  247. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_controldata.1
  248. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/post*
  249. rm -rf $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  250. rm -rf $RPM_BUILD_ROOT%{l_prefix}/include/postgresql/server
  251. rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/postgresql
  252. rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/postgresql
  253. rm -rf $RPM_BUILD_ROOT%{l_prefix}/var/postgresql
  254. %endif
  255. # determine installation files
  256. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  257. %if "%{with_server}" == "yes"
  258. %{l_files_std} \
  259. '%attr(700,%{l_rusr},%{l_rgrp}) %dir %{l_prefix}/var/postgresql/db' \
  260. '%attr(755,%{l_rusr},%{l_rgrp}) %dir %{l_prefix}/var/postgresql/run' \
  261. '%attr(755,%{l_rusr},%{l_rgrp}) %dir %{l_prefix}/var/postgresql/log'
  262. %else
  263. %{l_files_std}
  264. %endif
  265. %files -f files
  266. %clean
  267. %pre
  268. %if "%{with_server}" == "yes"
  269. # before upgrade, check migration dump, save status and stop service
  270. [ $1 -eq 2 ] || exit 0
  271. if [ -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION -a \
  272. -f $RPM_INSTALL_PREFIX/bin/pg_migrate ]; then
  273. # database migration dumping hint
  274. v_old_all=`cat $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION`
  275. v_old_maj=`echo "$v_old_all" | sed -e 's/^\([0-9]*\)\..*/\1/'`
  276. v_new_all="%{V_postgresql}"
  277. v_new_maj=`echo "$v_new_all" | sed -e 's/^\([0-9]*\)\..*/\1/'`
  278. if [ ".$v_old_maj" != ".$v_new_maj" ]; then
  279. ( echo "You are upgrading from PostgreSQL $v_old_maj to PostgresSQL $v_new_maj,"
  280. echo "which is a major version change. We expect a database incompatibility,"
  281. echo "so a full database backup and restore is required!"
  282. ) | %{l_rpmtool} msg -b -t notice
  283. if [ ".$RPM_POSTGRESQL_MIGRATE" != .ignore ]; then
  284. if [ ! -f $RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2 ]; then
  285. ( echo "We are performing a full backup of your existing database"
  286. echo "($RPM_INSTALL_PREFIX/var/postgresql/db/) for you by running:"
  287. echo " \$ $RPM_INSTALL_PREFIX/bin/pg_migrate dump"
  288. echo "If this fails for some reasons, try to dump your data manually:"
  289. echo " \$ $RPM_INSTALL_PREFIX/bin/pg_dumpall -U postgresql -o | \\ "
  290. echo " $RPM_INSTALL_PREFIX/lib/openpkg/bzip2 -9 \\ "
  291. echo " >$RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2"
  292. echo "Alternatively, if you want to force this package to be installed without"
  293. echo "a previously created database dump, run the following command"
  294. echo "before trying this package upgrade again:"
  295. echo " \$ RPM_POSTGRESQL_MIGRATE=ignore; export RPM_POSTGRESQL_MIGRATE"
  296. ) | %{l_rpmtool} msg -b -t notice
  297. $RPM_INSTALL_PREFIX/bin/pg_migrate dump
  298. if [ $? -ne 0 ] || [ ! -f $RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2 ]; then
  299. ( echo "Automatic database dump creation failed!"
  300. echo "PLEASE INVESTIGATE MANUALLY YOURSELF!"
  301. ) | %{l_rpmtool} msg -b -t error
  302. exit 1
  303. fi
  304. fi
  305. fi
  306. fi
  307. fi
  308. eval `%{l_rc} postgresql status 2>/dev/null | tee %{l_tmpfile}`
  309. %{l_rc} postgresql stop 2>/dev/null
  310. exit 0
  311. %endif
  312. %post
  313. %if "%{with_server}" == "yes"
  314. l_pguser="postgresql"
  315. l_pgpass="postgresql"
  316. if [ $1 -eq 1 ]; then
  317. # create initial database
  318. su - %{l_rusr} -c \
  319. "LC_CTYPE=C; export LC_CTYPE; umask 077; \
  320. rm -rf $RPM_INSTALL_PREFIX/var/postgresql/db/*; \
  321. echo $l_pgpass >$RPM_INSTALL_PREFIX/var/postgresql/run/pg_initdb.pw; \
  322. $RPM_INSTALL_PREFIX/bin/pg_initdb \
  323. --encoding=SQL_ASCII --locale=C --auth=md5 --username=$l_pguser \
  324. --pwfile=$RPM_INSTALL_PREFIX/var/postgresql/run/pg_initdb.pw \
  325. --pgdata=$RPM_INSTALL_PREFIX/var/postgresql/db; \
  326. rm -f $RPM_INSTALL_PREFIX/var/postgresql/run/pg_initdb.pw" 2>&1 | \
  327. $RPM_INSTALL_PREFIX/lib/openpkg/shtool prop \
  328. -p "Creating initial PostgreSQL DB in $RPM_INSTALL_PREFIX/var/postgresql/db"
  329. if [ ! -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION ]; then
  330. echo "ERROR: failed to create initial PostgreSQL database" 1>&2
  331. exit 1
  332. fi
  333. ( umask 077
  334. ( echo "##"
  335. echo "## pg_superuser.conf -- PostgreSQL database superuser configuration"
  336. echo "##"
  337. echo ""
  338. echo "superuser_database=\"template1\""
  339. echo "superuser_username=\"$l_pguser\""
  340. echo "superuser_password=\"$l_pgpass\""
  341. echo ""
  342. ) >$RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf
  343. chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf || exit $?
  344. chmod 600 $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf || exit $?
  345. ) || exit $?
  346. # display information about next steps
  347. ( echo "An initial PostgreSQL DB was created with the two standard"
  348. echo "databases 'template0' and 'template1'. The owner of both"
  349. echo "is the DB user '$l_pguser'. Its initial password is '$l_pgpass'."
  350. echo ""
  351. echo "After starting PostgreSQL with"
  352. echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc postgresql start"
  353. echo "you should immediately change this with the following command:"
  354. echo " \$ $RPM_INSTALL_PREFIX/bin/pg_passwd postgresql template1"
  355. echo ""
  356. echo "Then you usually create a database <database> for a user <user>"
  357. echo "and with password <password>:"
  358. echo " \$ $RPM_INSTALL_PREFIX/bin/psql -U $l_pguser -d template1"
  359. echo " template1=> CREATE ROLE <user>"
  360. echo " LOGIN ENCRYPTED PASSWORD '<password>'"
  361. echo " NOCREATEDB NOCREATEROLE;"
  362. echo " template1=> CREATE DATABASE <database> OWNER <user>;"
  363. echo " template1=> \\q"
  364. echo ""
  365. echo "Or you can create a database for a user <user> (assuming that"
  366. echo "his home directory is /u/<user>) with password <password> under"
  367. echo "path /u/<user>/rdbms with the commands:"
  368. echo " \$ mkdir /u/<user>/rdbms"
  369. echo " \$ chmod 700 /u/<user>/rdbms"
  370. echo " \$ chown %{l_rusr}:%{l_rgrp} /u/<user>/rdbms"
  371. echo " \$ $RPM_INSTALL_PREFIX/bin/psql -U $l_pguser -d template1"
  372. echo " template1=> CREATE ROLE <user>"
  373. echo " LOGIN ENCRYPTED PASSWORD '<password>'"
  374. echo " NOCREATEDB NOCREATEROLE;"
  375. echo " template1=> CREATE TABLESPACE <user> OWNER <user>"
  376. echo " LOCATION '/u/<user>/rdbms';"
  377. echo " template1=> CREATE DATABASE <user> OWNER <user>"
  378. echo " TABLESPACE <user>;"
  379. echo " template1=> \\q"
  380. echo ""
  381. echo "The user <user> will be able to connect to his database with:"
  382. echo " \$ echo 'localhost:*:<database>:<user>:<password>' >>~/.pgpass"
  383. echo " \$ chmod 600 ~/.pgpass"
  384. echo " \$ $RPM_INSTALL_PREFIX/bin/psql"
  385. ) | %{l_rpmtool} msg -b -t notice
  386. fi
  387. if [ $1 -eq 2 ]; then
  388. # after upgrade, restore status
  389. { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null 2>&1
  390. [ ".$postgresql_active" = .yes ] && %{l_rc} postgresql start
  391. if [ -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION -a \
  392. ! -f $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf ]; then
  393. ( umask 077
  394. ( echo "##"
  395. echo "## pg_superuser.conf -- PostgreSQL database superuser configuration"
  396. echo "##"
  397. echo ""
  398. echo "superuser_database=\"template1\""
  399. echo "superuser_username=\"$l_pguser\""
  400. echo "superuser_password=\"\""
  401. echo ""
  402. ) >$RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf
  403. chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf || exit $?
  404. chmod 600 $RPM_INSTALL_PREFIX/var/postgresql/db/pg_superuser.conf || exit $?
  405. ) || exit $?
  406. ( echo "Created still missing \"pg_superuser.conf\" configuration file."
  407. echo "You should update its content by resetting the PostgreSQL"
  408. echo "superuser account password with the following command:"
  409. echo " \$ $RPM_INSTALL_PREFIX/bin/pg_passwd postgresql template1"
  410. ) | %{l_rpmtool} msg -b -t warn
  411. fi
  412. if [ -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION -a ".$PG_MIGRATE" != .ignore ]; then
  413. # database migration restoring hint
  414. v_old_all=`cat $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION`
  415. v_old_maj=`echo "$v_old_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
  416. v_new_all="%{V_postgresql}"
  417. v_new_maj=`echo "$v_new_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
  418. if [ ".$v_old_maj" != ".$v_new_maj" ]; then
  419. ( echo "You upgraded from PostgreSQL $v_old_all to PostgresSQL $v_new_all,"
  420. echo "which is a major version upgrade. We expect a database incompatibility,"
  421. echo "so we strongly recommend you to recreate the existing database under"
  422. echo "$RPM_INSTALL_PREFIX/var/postgresql/db/ by running the following command:"
  423. echo " \$ $RPM_INSTALL_PREFIX/bin/pg_migrate restore"
  424. echo "If this fails for some reasons, try to restore your data manually:"
  425. echo " \$ $RPM_INSTALL_PREFIX/lib/openpkg/bzip2 -d -c \\ "
  426. echo " $RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2 | \\ "
  427. echo " $RPM_INSTALL_PREFIX/bin/psql -U postgresql -d template1"
  428. ) | %{l_rpmtool} msg -b -t warn
  429. fi
  430. fi
  431. fi
  432. exit 0
  433. %endif
  434. %preun
  435. %if "%{with_server}" == "yes"
  436. # before erase, stop service and remove log files
  437. [ $1 -eq 0 ] || exit 0
  438. %{l_rc} postgresql stop 2>/dev/null
  439. rm -f $RPM_INSTALL_PREFIX/var/postgresql/run/* >/dev/null 2>&1 || true
  440. rm -f $RPM_INSTALL_PREFIX/var/postgresql/log/* >/dev/null 2>&1 || true
  441. exit 0
  442. %endif