|
|
@@ -40,7 +40,7 @@ Distribution: OpenPKG [BASE]
|
|
|
Group: Database
|
|
|
License: GPL
|
|
|
Version: %{V_postgresql}
|
|
|
-Release: 20030722
|
|
|
+Release: 20030723
|
|
|
|
|
|
# package options
|
|
|
%option with_cxx no
|
|
|
@@ -319,38 +319,33 @@ AutoReqProv: no
|
|
|
rm -rf $RPM_BUILD_ROOT
|
|
|
|
|
|
%pre
|
|
|
- if [ $1 -gt 1 ]; then
|
|
|
- # upgrading of installation
|
|
|
- if [ -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION -a \
|
|
|
- -f $RPM_INSTALL_PREFIX/bin/pg_migrate ]; then
|
|
|
- # database migration dumping hint
|
|
|
- v_old_all=`cat $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION`
|
|
|
- v_old_maj=`echo "$v_old_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
|
|
|
- v_new_all="%{V_postgresql}"
|
|
|
- v_new_maj=`echo "$v_new_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
|
|
|
- if [ ".$v_old_maj" != ".$v_new_maj" ]; then
|
|
|
- if [ ! -f $RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2 -a ".$PG_MIGRATE" != .ignore ]; then
|
|
|
- ( echo "You are upgrading from PostgreSQL $v_old_all to PostgresSQL $v_new_all,"
|
|
|
- echo "which is a major version change. We expect a database incompatibility,"
|
|
|
- echo "so we strongly recommend that you backup your existing database"
|
|
|
- echo "($RPM_INSTALL_PREFIX/var/postgresql/db/) first by running:"
|
|
|
- echo " \$ $RPM_INSTALL_PREFIX/bin/pg_migrate dump"
|
|
|
- echo "Alternatively, if you want force this package to be installed without"
|
|
|
- echo "performing a database dump, run the following command before upgrading:"
|
|
|
- echo " \$ PG_MIGRATE=ignore; export PG_MIGRATE"
|
|
|
- ) | %{l_rpmtool} msg -b -t error
|
|
|
- exit 1
|
|
|
- fi
|
|
|
+ # before upgrade, check migration dump, save status and stop service
|
|
|
+ [ $1 -eq 2 ] || exit 0
|
|
|
+ if [ -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION -a \
|
|
|
+ -f $RPM_INSTALL_PREFIX/bin/pg_migrate ]; then
|
|
|
+ # database migration dumping hint
|
|
|
+ v_old_all=`cat $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION`
|
|
|
+ v_old_maj=`echo "$v_old_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
|
|
|
+ v_new_all="%{V_postgresql}"
|
|
|
+ v_new_maj=`echo "$v_new_all" | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
|
|
|
+ if [ ".$v_old_maj" != ".$v_new_maj" ]; then
|
|
|
+ if [ ! -f $RPM_INSTALL_PREFIX/var/postgresql/db.dump.sql.bz2 -a ".$PG_MIGRATE" != .ignore ]; then
|
|
|
+ ( echo "You are upgrading from PostgreSQL $v_old_all to PostgresSQL $v_new_all,"
|
|
|
+ echo "which is a major version change. We expect a database incompatibility,"
|
|
|
+ echo "so we strongly recommend that you backup your existing database"
|
|
|
+ echo "($RPM_INSTALL_PREFIX/var/postgresql/db/) first by running:"
|
|
|
+ echo " \$ $RPM_INSTALL_PREFIX/bin/pg_migrate dump"
|
|
|
+ echo "Alternatively, if you want force this package to be installed without"
|
|
|
+ echo "performing a database dump, run the following command before upgrading:"
|
|
|
+ echo " \$ PG_MIGRATE=ignore; export PG_MIGRATE"
|
|
|
+ ) | %{l_rpmtool} msg -b -t error
|
|
|
+ exit 1
|
|
|
fi
|
|
|
fi
|
|
|
- rm -f $RPM_INSTALL_PREFIX/var/posgresql/RESTART >/dev/null 2>&1 || true
|
|
|
- if [ ".`$l_prefix/etc/rc postgresql status 2>&1 | grep 'is running'`" != . ]; then
|
|
|
- echo "Shutting down currently running database engine." | %{l_rpmtool} msg -b -t notice
|
|
|
- $RPM_INSTALL_PREFIX/etc/rc postgresql stop
|
|
|
- touch $RPM_INSTALL_PREFIX/var/posgresql/RESTART
|
|
|
- sleep 4
|
|
|
- fi
|
|
|
fi
|
|
|
+ eval `%{l_rc} postgresql status 2>/dev/null | tee %{l_tmpfile}`
|
|
|
+ %{l_rc} postgresql stop 2>/dev/null
|
|
|
+ exit 0
|
|
|
|
|
|
%post
|
|
|
if [ $1 -eq 1 ]; then
|
|
|
@@ -401,14 +396,11 @@ AutoReqProv: no
|
|
|
echo "Threading = 2"
|
|
|
) | $RPM_INSTALL_PREFIX/bin/odbcinst -i -d -r
|
|
|
%endif
|
|
|
- elif [ $1 -gt 1 ]; then
|
|
|
- # upgrading of installation
|
|
|
- if [ -f $RPM_INSTALL_PREFIX/var/posgresql/RESTART ]; then
|
|
|
- echo "Starting database engine again." | %{l_rpmtool} msg -b -t notice
|
|
|
- $RPM_INSTALL_PREFIX/etc/rc postgresql start
|
|
|
- rm -f $RPM_INSTALL_PREFIX/var/posgresql/RESTART >/dev/null 2>&1 || true
|
|
|
- sleep 2
|
|
|
- fi
|
|
|
+ fi
|
|
|
+ if [ $1 -eq 2 ]; then
|
|
|
+ # after upgrade, restore status
|
|
|
+ { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null 2>&1
|
|
|
+ [ ".$postgresql_active" = .yes ] && %{l_rc} postgresql start
|
|
|
if [ -f $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION -a ".$PG_MIGRATE" != .ignore ]; then
|
|
|
# database migration restoring hint
|
|
|
v_old_all=`cat $RPM_INSTALL_PREFIX/var/postgresql/db/PG_VERSION`
|
|
|
@@ -425,4 +417,12 @@ AutoReqProv: no
|
|
|
fi
|
|
|
fi
|
|
|
fi
|
|
|
+ exit 0
|
|
|
+
|
|
|
+%preun
|
|
|
+ # before erase, stop service and remove log files
|
|
|
+ [ $1 -eq 0 ] || exit 0
|
|
|
+ %{l_rc} postgresql stop 2>/dev/null
|
|
|
+ rm -f $RPM_INSTALL_PREFIX/var/postgresql/run/* >/dev/null 2>&1 || true
|
|
|
+ exit 0
|
|
|
|