Re: BUG #1495: RPM: wrong quoting of error message about old database format after upgrading - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #1495: RPM: wrong quoting of error message about old database format after upgrading
Date
Msg-id 2751.1109022753@sss.pgh.pa.us
Whole thread Raw
In response to BUG #1495: RPM: wrong quoting of error message about old database format after upgrading  ("Markus Bertheau" <twanger@bluetwanger.de>)
List pgsql-bugs
"Markus Bertheau" <twanger@bluetwanger.de> writes:
> Description:        RPM: wrong quoting of error message about old database
> format after upgrading

> [bertheau@dicaprio ~]$ sudo /etc/init.d/postgresql start

> An old version of the database format was found.\nYou need to upgrade the
> data format before using PostgreSQL.\nSee (Your System's documentation
> directory)/postgresql-8.0/README.rpm-dist for more information.

> This is the literal output. The \n's are overquoted.

Good catch.  That code has got worse problems too: it ought to be able
to report the correct location of the README.rpm-dist file, but it fails
because of confusion about which version number to use.

I've applied fixes in Red Hat's current RPMs, as attached.

            regards, tom lane

Index: postgresql.init
===================================================================
RCS file: /cvs/dist/rpms/postgresql/devel/postgresql.init,v
retrieving revision 1.19
retrieving revision 1.20
diff -c -r1.19 -r1.20
*** postgresql.init    19 Jan 2005 05:02:10 -0000    1.19
--- postgresql.init    21 Feb 2005 21:44:36 -0000    1.20
***************
*** 62,69 ****
  # postgres-owned processes laying about.


! # PGVERSION is:
! PGVERSION=8.0

  # Source function library.
  INITD=/etc/rc.d/init.d
--- 62,72 ----
  # postgres-owned processes laying about.


! # PGVERSION is the full package version, e.g., 7.4.7
! # Note: the specfile ordinarily updates this during install
! PGVERSION=xxxx
! # PGMAJORVERSION is major version, e.g., 7.4 (this should match PG_VERSION)
! PGMAJORVERSION=`echo "$PGVERSION" | sed 's/^\([0-9]*\.[0-9]*\).*$/\1/'`

  # Source function library.
  INITD=/etc/rc.d/init.d
***************
*** 134,140 ****
      then
      # Check version of existing PGDATA

!         if [ `cat "$PGDATA/PG_VERSION"` != "$PGVERSION" ]
          then
              SYSDOCDIR="(Your System's documentation directory)"
              if [ -d "/usr/doc/postgresql-$PGVERSION" ]
--- 137,143 ----
      then
      # Check version of existing PGDATA

!         if [ x`cat "$PGDATA/PG_VERSION"` != x"$PGMAJORVERSION" ]
          then
              SYSDOCDIR="(Your System's documentation directory)"
              if [ -d "/usr/doc/postgresql-$PGVERSION" ]
***************
*** 154,160 ****
                  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." 
              exit 1
          fi

--- 157,165 ----
                  SYSDOCDIR=/usr/share/doc/packages
              fi
              echo
!             echo $"An old version of the database format was found."
!             echo $"You need to upgrade the data format before using PostgreSQL."
!             echo $"See $SYSDOCDIR/postgresql-$PGVERSION/README.rpm-dist for more information."
              exit 1
          fi

Index: postgresql.spec
===================================================================
RCS file: /cvs/dist/rpms/postgresql/devel/postgresql.spec,v
retrieving revision 1.43
retrieving revision 1.44
diff -c -r1.43 -r1.44
*** postgresql.spec    31 Jan 2005 03:15:07 -0000    1.43
--- postgresql.spec    21 Feb 2005 21:44:36 -0000    1.44
***************
*** 64,70 ****
  # Pre-release RPM's should not be put up on the public ftp.postgresql.org server
  # -- only test releases or full releases should be.

! Release: 1
  License: BSD
  Group: Applications/Databases
  Source0: ftp://ftp.postgresql.org/pub/source/v%{version}/postgresql-%{version}.tar.bz2
--- 64,70 ----
  # Pre-release RPM's should not be put up on the public ftp.postgresql.org server
  # -- only test releases or full releases should be.

! Release: 2
  License: BSD
  Group: Applications/Databases
  Source0: ftp://ftp.postgresql.org/pub/source/v%{version}/postgresql-%{version}.tar.bz2
***************
*** 483,489 ****
  if [ -d /etc/rc.d/init.d ]
  then
      install -d $RPM_BUILD_ROOT/etc/rc.d/init.d
!     install -m 755 %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/postgresql
  fi

  # Remove stuff we don't want to ship.
--- 483,490 ----
  if [ -d /etc/rc.d/init.d ]
  then
      install -d $RPM_BUILD_ROOT/etc/rc.d/init.d
!     sed 's/^PGVERSION=.*$/PGVERSION=%{version}/' <%{SOURCE3} >postgresql.init
!     install -m 755 postgresql.init $RPM_BUILD_ROOT/etc/rc.d/init.d/postgresql
  fi

  # Remove stuff we don't want to ship.
***************
*** 784,789 ****
--- 785,794 ----
  %endif

  %changelog
+ * Mon Feb 21 2005 Tom Lane <tgl@redhat.com> 8.0.1-2
+ - Repair improper error message in init script when PGVERSION doesn't match.
+ - Arrange for auto update of version embedded in init script.
+
  * Sun Jan 30 2005 Tom Lane <tgl@redhat.com> 8.0.1-1
  - Update to PostgreSQL 8.0.1.
  - Add versionless symlinks to jar files (bz#145744)

pgsql-bugs by date:

Previous
From: "Magnus Hagander"
Date:
Subject: Re: problem installing postgresql-8.0.1 on Windows 2K
Next
From: Tom Lane
Date:
Subject: Re: BUG #1490: contrib .sql.in sed command bogus