[arch-commits] Commit in postgresql/trunk (6 files)

Dan McGee dan at archlinux.org
Sat Sep 15 16:46:19 UTC 2012


    Date: Saturday, September 15, 2012 @ 12:46:19
  Author: dan
Revision: 166686

upgpkg: postgresql 9.2.0-1

* Major version upgrade
* systemd support. Adapt postgresql-check-db-dir script from Fedora and model service file after theirs

Added:
  postgresql/trunk/postgresql-check-db-dir
  postgresql/trunk/postgresql.service
Modified:
  postgresql/trunk/PKGBUILD
  postgresql/trunk/postgresql.install
Deleted:
  postgresql/trunk/postgresql-initdb
  postgresql/trunk/postgresql.service

-------------------------+
 PKGBUILD                |   24 +++++++++++-----------
 postgresql-check-db-dir |   49 ++++++++++++++++++++++++++++++++++++++++++++++
 postgresql-initdb       |   33 ------------------------------
 postgresql.install      |   10 ++++++---
 postgresql.service      |   47 +++++++++++++++++++++++++-------------------
 5 files changed, 95 insertions(+), 68 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2012-09-15 16:03:08 UTC (rev 166685)
+++ PKGBUILD	2012-09-15 16:46:19 UTC (rev 166686)
@@ -3,30 +3,30 @@
 
 pkgbase=postgresql
 pkgname=('postgresql-libs' 'postgresql-docs' 'postgresql')
-pkgver=9.1.4
+pkgver=9.2.0
 _majorver=${pkgver%.*}
-pkgrel=2
+pkgrel=1
 arch=('i686' 'x86_64')
 url="http://www.postgresql.org/"
 license=('custom:PostgreSQL')
 makedepends=('krb5' 'libxml2' 'python2' 'perl' 'tcl' 'openssl>=1.0.0')
-source=(ftp://ftp.postgresql.org/pub/source/v${pkgver}/postgresql-${pkgver}.tar.bz2
+source=(http://ftp.postgresql.org/pub/source/v${pkgver}/postgresql-${pkgver}.tar.bz2
         postgresql.rcd postgresql.confd postgresql.pam postgresql.logrotate
-        postgresql.service postgresql-initdb)
-md5sums=('a8035688dba988b782725ac1aec60186'
+        postgresql.service postgresql-check-db-dir)
+md5sums=('8c4c32a4abe8cf61b02c8366181ede50'
          '1ddd1df8010549f237e7983bb326025e'
          'a54d09a20ab1672adf08f037df188d53'
          '96f82c38f3f540b53f3e5144900acf17'
          'd28e443f9f65a5712c52018b84e27137'
-         '1ec1fbf1ce998324248c543e6cc2c5e6'
-         '1488a98a5d5d96a04416e4f5872223bf')
-sha256sums=('a0795a8eb3ae2d1a2914b63bf143d20182835d90699915ff43567c041d3c9712'
+         'f0d46e63198db0a1e51dcd4a0599cd33'
+         '505e0e4abfc746cae9558584d471a03c')
+sha256sums=('3731c607df492bbb57f37917b49f57719c0d6f823720426431fff10d82b1fe33'
             '9f6307b1358892e304f9474a456f0cb9160cfb8812a9da0430abe647f8a9cf45'
             '3de5c059eead8816db15c2c5588e6196d6c4b0d704faf1a20912796cf589ba81'
             '57dfd072fd7ef0018c6b0a798367aac1abb5979060ff3f9df22d1048bb71c0d5'
             '6abb842764bbed74ea4a269d24f1e73d1c0b1d8ecd6e2e6fb5fb10590298605e'
-            '7014ccc8f3bbac8be9473a43fca2ed4037ee04e56d8e07d6027b3b4ef0317c89'
-            'c22f82a3cf5b555935039853fab2d7e5ff6188cdb1fb528fa9171a87b94f42b0')
+            'af41dd8c1e6b124880fb4347c9fa4adabdef5b6e6bd13601cac25eb9e7bc7774'
+            '3a3279d290f556bf7a362670e32b491794f47ed218f6b8c6acef366a3291f669')
 
 build() {
   cd "${srcdir}/postgresql-${pkgver}"
@@ -139,8 +139,8 @@
   install -D -m755 "${srcdir}/postgresql.rcd" "${pkgdir}/etc/rc.d/postgresql"
   install -D -m644 "${srcdir}/postgresql.service" \
     "${pkgdir}/usr/lib/systemd/system/postgresql.service"
-  install -D -m755 "${srcdir}/postgresql-initdb" \
-    "${pkgdir}/usr/lib/systemd/scripts/postgresql-initdb"
+  install -D -m755 "${srcdir}/postgresql-check-db-dir" \
+    "${pkgdir}/usr/bin/postgresql-check-db-dir"
 
   # install conf file
   install -D -m644 ${srcdir}/postgresql.confd \

Added: postgresql-check-db-dir
===================================================================
--- postgresql-check-db-dir	                        (rev 0)
+++ postgresql-check-db-dir	2012-09-15 16:46:19 UTC (rev 166686)
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+# This script verifies that the postgresql data directory has been correctly
+# initialized.  We do not want to automatically initdb it, because that has
+# a risk of catastrophic failure (ie, overwriting a valuable database) in
+# corner cases, such as a remotely mounted database on a volume that's a
+# bit slow to mount.  But we can at least emit a message advising newbies
+# what to do.
+
+PGDATA="$1"
+
+if [ -z "$PGDATA" ]
+then
+    echo "Usage: $0 database-path"
+    exit 1
+fi
+
+# PGMAJORVERSION is major version
+PGMAJORVERSION=9.2
+# PREVMAJORVERSION is the previous major version, e.g., 8.4, for upgrades
+PREVMAJORVERSION=9.1
+
+# Check for the PGDATA structure
+if [ -f "$PGDATA/PG_VERSION" ] && [ -d "$PGDATA/base" ]
+then
+    # Check version of existing PGDATA
+    if [ x`cat "$PGDATA/PG_VERSION"` = x"$PGMAJORVERSION" ]
+    then
+        : A-OK
+    elif [ x`cat "$PGDATA/PG_VERSION"` = x"$PREVMAJORVERSION" ]
+    then
+        echo $"An old version of the database format was found."
+        echo $"See https://wiki.archlinux.org/index.php/PostgreSQL#Upgrading_PostgreSQL"
+        exit 1
+    else
+        echo $"An old version of the database format was found."
+        echo $"You need to dump and reload before using PostgreSQL $PGMAJORVERSION."
+        echo $"See http://www.postgresql.org/docs/9.2/static/upgrading.html"
+        exit 1
+    fi
+else
+    # No existing PGDATA! Warn the user to initdb it.
+    echo $"\"$PGDATA\" is missing or empty. Use a command like"
+    echo $"  su - postgres -c \"initdb --locale en_US.UTF-8 -D '$PGDATA'\""
+    echo $"with relevant options, to initialize the database cluster."
+    exit 1
+fi
+
+exit 0


Property changes on: postgresql/trunk/postgresql-check-db-dir
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Deleted: postgresql-initdb
===================================================================
--- postgresql-initdb	2012-09-15 16:03:08 UTC (rev 166685)
+++ postgresql-initdb	2012-09-15 16:46:19 UTC (rev 166686)
@@ -1,33 +0,0 @@
-#!/bin/sh
-
-set -e
-
-. /etc/conf.d/postgresql
-
-# 2nd clause is necessary to prevent symlinking the directory to itself when it
-# doesn't exist yet
-if [ ! /var/lib/postgres -ef "$PGROOT" ] && [ /var/lib/postgres != "$PGROOT" ]; then
-    echo "Creating symlink /var/lib/postgres -> $PGROOT"
-
-    # Remove /var/lib/postgres if empty dir, but not if symlink
-    if [ ! -L /var/lib/postgres ] && [ -d /var/lib/postgres ]; then
-        rmdir /var/lib/postgres
-    fi
-
-    ln -sf "$PGROOT" /var/lib/postgres
-fi
-
-PGDATA="$PGROOT/data"
-
-if [ ! -d "$PGDATA" ]; then
-    echo "Initializing database in $PGDATA"
-
-    mkdir -p "$PGDATA"
-    chown -R postgres:postgres "$PGDATA"
-
-    su - postgres -m -c "/usr/bin/initdb $INITOPTS -D '$PGDATA'" >/dev/null
-
-    if [ -f /etc/postgresql/postgresql.conf ]; then
-        ln -sf /etc/postgresql/postgresql.conf "$PGDATA/postgresql.conf"
-    fi
-fi

Modified: postgresql.install
===================================================================
--- postgresql.install	2012-09-15 16:03:08 UTC (rev 166685)
+++ postgresql.install	2012-09-15 16:46:19 UTC (rev 166686)
@@ -2,9 +2,13 @@
   if [ ! -d '/var/lib/postgres' ]; then
     mkdir -p '/var/lib/postgres'
   fi
-  getent group postgres >/dev/null || groupadd -g 88 postgres
-  getent passwd postgres >/dev/null || useradd -c 'PostgreSQL user' -u 88 -g postgres -d '/var/lib/postgres' -s /bin/bash postgres
-  passwd -l postgres >/dev/null
+  if ! getent group postgres >/dev/null; then
+    groupadd -g 88 postgres
+  fi
+  if ! getent passwd postgres >/dev/null; then
+    useradd -c 'PostgreSQL user' -u 88 -g postgres -d '/var/lib/postgres' -s /bin/bash postgres
+    passwd -l postgres >/dev/null
+  fi
 }
 
 post_upgrade() {

Deleted: postgresql.service
===================================================================
--- postgresql.service	2012-09-15 16:03:08 UTC (rev 166685)
+++ postgresql.service	2012-09-15 16:46:19 UTC (rev 166686)
@@ -1,20 +0,0 @@
-[Unit]
-Description=PostgreSQL database server
-
-[Service]
-Type=forking
-SyslogIdentifier=postgres
-PIDFile=/var/lib/postgres/data/postmaster.pid
-
-# initdb script takes care for symlinking $PGROOT to /var/lib/postgres
-ExecStartPre=/usr/lib/systemd/scripts/postgresql-initdb
-ExecStart= /bin/su - postgres -m -c "/usr/bin/pg_ctl -s -D /var/lib/postgres/data start"
-ExecReload=/bin/su - postgres -m -c "/usr/bin/pg_ctl -s -D /var/lib/postgres/data reload"
-ExecStop=  /bin/su - postgres -m -c "/usr/bin/pg_ctl -s -D /var/lib/postgres/data stop -m fast"
-
-# Due to PostgreSQL's use of shared memory, OOM killer is often overzealous in
-# killing Postgres
-OOMScoreAdjust=-200
-
-[Install]
-WantedBy=multi-user.target

Added: postgresql.service
===================================================================
--- postgresql.service	                        (rev 0)
+++ postgresql.service	2012-09-15 16:46:19 UTC (rev 166686)
@@ -0,0 +1,27 @@
+[Unit]
+Description=PostgreSQL database server
+After=network.target
+
+[Service]
+Type=forking
+TimeoutSec=120
+User=postgres
+Group=postgres
+
+Environment=PGROOT=/var/lib/postgres
+Environment=PGLOG=/var/log/postgresql.log
+
+SyslogIdentifier=postgres
+PIDFile=/var/lib/postgres/data/postmaster.pid
+
+ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data
+ExecStart= /usr/bin/pg_ctl -s -D ${PGROOT}/data start -w -t 120
+ExecReload=/usr/bin/pg_ctl -s -D ${PGROOT}/data reload
+ExecStop=  /usr/bin/pg_ctl -s -D ${PGROOT}/data stop -m fast
+
+# Due to PostgreSQL's use of shared memory, OOM killer is often overzealous in
+# killing Postgres, so adjust it downward
+OOMScoreAdjust=-200
+
+[Install]
+WantedBy=multi-user.target




More information about the arch-commits mailing list