Browse Source

postgresql-9.4.4-2

git-svn-id: http://trac.vinelinux.org/repos/projects/specs@9618 ec354946-7b23-47d6-9f5a-488ba84defc7
tomop 8 years ago
parent
commit
cc09598321
2 changed files with 45 additions and 22 deletions
  1. 39 2
      p/postgresql/postgresql-vl.spec
  2. 6 20
      p/postgresql/postgresql.init

+ 39 - 2
p/postgresql/postgresql-vl.spec

@@ -20,7 +20,7 @@ Summary: PostgreSQL client programs and libraries.
 Summary(ja): PostgreSQL のクライアントプログラム群およびライブラリ
 Name: postgresql
 Version: %{pgver}.4
-Release: 1%{?_dist_release}
+Release: 2%{?_dist_release}
 # Conventions for PostgreSQL Global Development Group RPM releases:
 #
 # Official PostgreSQL Development Group RPMS have a PGDG after the release number.
@@ -394,7 +394,8 @@ install -m644 src/Makefile.shlib $RPM_BUILD_ROOT%{_includedir}/pgsql
 
 # initscript
 install -d $RPM_BUILD_ROOT/etc/rc.d/init.d
-sed "s/^PGVERSION=.*/PGVERSION=%{pgver}/" %{SOURCE3} \
+sed -e "s/@pgver@/%{pgver}/" \
+	-e "s|@docdir@|%{_docdir}/postgresql-%{version}|" %{SOURCE3} \
 	> $RPM_BUILD_ROOT/etc/rc.d/init.d/postgresql
 chmod 755 $RPM_BUILD_ROOT/etc/rc.d/init.d/postgresql
 
@@ -483,6 +484,38 @@ chown postgres.postgres /var/log/pgsql
 chmod 0700 /var/log/pgsql
 
 
+if [ $1 -gt 1 ]; then
+  if [ -e /var/lib/pgsql/data/PG_VERSION ]; then
+    PGVER=`cat /var/lib/pgsql/data/PG_VERSION`
+    if [ "x%{pgver}" != "x$PGVER" -a ! -d /var/lib/pgsql/$PGVER ]; then
+      mkdir -p /var/lib/pgsql/$PGVER/{bin,share,%{_lib}/postgresql}
+      mv -f /var/lib/pgsql/data /var/lib/pgsql/$PGVER/
+      cp -af %{_datadir}/pgsql /var/lib/pgsql/$PGVER/share/
+      for f in %{_libdir}/postgresql/*; do
+        cp -af $f /var/lib/pgsql/$PGVER/%{_lib}/postgresql/
+      done
+      for f in `rpm -ql %{name}-server | grep /usr/bin/`; do
+        cp -af $f /var/lib/pgsql/$PGVER/bin/
+      done
+
+      cat - <<EOF > /var/lib/pgsql/pgsql_upgrade.sh
+#!/bin/sh
+
+sudo -u postgres pg_upgrade -d /var/lib/pgsql/$PGVER/data/ -D /var/lib/pgsql/data -b /var/lib/pgsql/$PGVER/bin/ -B /usr/bin
+
+EOF
+      chown postgres.postgres /var/lib/pgsql/pgsql_upgrade.sh
+      chmod 700 /var/lib/pgsql/pgsql_upgrade.sh
+
+      cat - <<EOF
+ The old database was saved into /var/lib/pgsql/$PGVER/data/ and
+a migration script was created as /var/lib/pgsql/pgsql_upgrade.sh
+
+EOF
+	fi
+  fi
+fi
+
 %post server
 chkconfig --add postgresql
 /sbin/ldconfig
@@ -735,6 +768,10 @@ rm -rf $RPM_BUILD_ROOT
 %endif
 
 %changelog
+* Sat Jun 20 2015 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 9.4.4-2
+- fixed initscript.
+- modified %%pre to prepare for pg_upgrade.
+
 * Sat Jun 13 2015 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 9.4.4-1
 - new upstream release.
 

+ 6 - 20
p/postgresql/postgresql.init

@@ -59,9 +59,12 @@
 # Version 9.0 IWAI, Masaharu <iwaim.sub@gmail.com>
 # fix su(1) paramaters in start() and stop().
 
+# Version 9.4 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 
+# fixed $NAME and warning messages.
+
 # PGVERSION must be replaced real version
 # In vine new postgresql.spec, version must be replaced by building
-PGVERSION=9.0
+PGVERSION=@pgver@
 
 # Source function library.
 INITD=/etc/rc.d/init.d
@@ -74,7 +77,7 @@ TYPESET=`typeset -f|grep "declare"`
 . /etc/sysconfig/network
 
 # Find the name of the script
-NAME=`basename $0`
+NAME=postgresql
 
 # Set defaults for port and database directory
 PGPORT=5432
@@ -108,25 +111,8 @@ start(){
 
 		if [ `cat $PGDATA/PG_VERSION` != $PGVERSION ]
 		then
-			SYSDOCDIR="(Your System's documentation directory)"
-			if [ -d /usr/doc/postgresql-$PGVERSION ]
-			then
-				SYSDOCDIR=/usr/doc
-			fi
-			if [ -d /usr/share/doc/postgresql-$PGVERSION ]
-			then
-				SYSDOCDIR=/usr/share/doc
-			fi
-			if [ -d /usr/doc/packages/postgresql-$PGVERSION ]
-			then
-				SYSDOCDIR=/usr/doc/packages
-			fi
-			if [ -d /usr/share/doc/packages/postgresql-$PGVERSION ]
-			then
-				SYSDOCDIR=/usr/share/doc/packages
-			fi
 			echo
-			echo $"An old version of the database format was found.\nYou need to upgrade the data format before using PostgreSQL.\nSee $SYSDOCDIR/postgresql-$PGVERSION/README.rpm-dist for more information."
+			echo $"An old version of the database format was found.\nYou need to upgrade the data format before using PostgreSQL.\nSee @docdir@/README.rpm-dist for more information."
 			exit 1
 #                       This doesn't seem to do anything useful...
 #		else