diff options
Diffstat (limited to 'main/postgresql-bdr')
-rw-r--r-- | main/postgresql-bdr/APKBUILD | 122 | ||||
-rw-r--r-- | main/postgresql-bdr/initdb.patch | 18 | ||||
-rw-r--r-- | main/postgresql-bdr/pgbdr-restore.confd | 16 | ||||
-rw-r--r-- | main/postgresql-bdr/pgbdr-restore.initd | 36 | ||||
-rw-r--r-- | main/postgresql-bdr/postgresql-bdr-osxflags.patch | 11 | ||||
-rw-r--r-- | main/postgresql-bdr/postgresql-bdr.confd | 55 | ||||
-rw-r--r-- | main/postgresql-bdr/postgresql-bdr.initd | 152 | ||||
-rw-r--r-- | main/postgresql-bdr/postgresql-bdr.pre-upgrade | 32 |
8 files changed, 442 insertions, 0 deletions
diff --git a/main/postgresql-bdr/APKBUILD b/main/postgresql-bdr/APKBUILD new file mode 100644 index 0000000000..9a097d930a --- /dev/null +++ b/main/postgresql-bdr/APKBUILD @@ -0,0 +1,122 @@ +# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org> +pkgname=postgresql-bdr +pkgver=9.4.1_p2 +_ver=${pkgver/_p/_bdr} +pkgrel=2 +pkgdesc="A sophisticated object-relational DBMS with bidirectional replication support (BDR)" +url="https://wiki.postgresql.org/wiki/BDR_Administration" +arch="all" +license="BSD" +depends="bash postgresql-client" +install="$pkgname.pre-upgrade" +depends_dev="readline-dev openssl-dev zlib-dev libxml2-dev" +makedepends="$depends_dev perl bison flex-dev" +subpackages="$pkgname-dev $pkgname-dbg $pkgname-libpq $pkgname-client + $pkgname-contrib" +provides="postgresql" +patches="initdb.patch + postgresql-bdr-osxflags.patch + " +source="http://packages.2ndquadrant.com/postgresql-bdr94-2ndquadrant/tarballs/postgresql-bdr-$_ver.tar.bz2 + $patches + $pkgname.initd + $pkgname.confd + pgbdr-restore.initd + pgbdr-restore.confd + " + +_builddir="$srcdir"/$pkgname-$_ver + +prepare() { + cd "$_builddir" + for i in $patches; do + msg "Applying patch $i" + patch -p1 -i "$srcdir"/$i || return 1 + done + # sanity check of conf.d + ( + . "$srcdir"/$pkgname.confd + _datadir=/var/lib/postgresql/${pkgver%.*}/data + if [ "$_datadir" != "$PGDATA" ]; then + die "PGDATA is $PGDATA while $_datadir is expected" + fi + ) || return 1 + #rm doc/src/Makefile || return 1 +} + +build() { + cd "$_builddir" + ./configure \ + --build=$CBUILD \ + --host=$CHOST \ + --prefix=/usr \ + --mandir=/usr/share/man \ + --with-openssl \ + || return 1 + + # configure/programs.m4 doesn't properly detect flex + # and offers manual user override + #make FLEX="/usr/bin/flex" JADEFLAGS="-E 999999" OSXFLAGS="-E 999999" \ + #world || return 1 + # Dont' build doc since it throws tons of openjade/osx errors + make FLEX="/usr/bin/flex" all || return 1 +} + +package() { + cd "$_builddir" + # Don't install docs + make DESTDIR="$pkgdir" install || return 1 + + install -D -m755 "$srcdir"/$pkgname.initd \ + "$pkgdir"/etc/init.d/$pkgname || return 1 + install -D -m644 "$srcdir"/$pkgname.confd \ + "$pkgdir"/etc/conf.d/$pkgname || return 1 + install -D -m755 "$srcdir"/pgbdr-restore.initd \ + "$pkgdir"/etc/init.d/pgbdr-restore || return 1 + install -D -m644 "$srcdir"/pgbdr-restore.confd \ + "$pkgdir"/etc/conf.d/pgbdr-restore || return 1 +} + +libpq() { + depends= + pkgdesc="PostgreSQL libraries" + mkdir -p "$subpkgdir"/usr/lib + mv "$pkgdir"/usr/lib/libpq.so* "$subpkgdir"/usr/lib/ +} + +client() { + depends= + pkgdesc="PostgreSQL client" + mkdir -p "$subpkgdir"/usr/bin + mv "$pkgdir"/usr/bin/psql "$subpkgdir"/usr/bin/ +} + +contrib() { + depends= + pkgdesc="Extension modules distributed with PostgreSQL" + cd "$_builddir" + make DESTDIR="$subpkgdir" FLEX="/usr/bin/flex" -C contrib install \ + || return 1 +} + +md5sums="2e3454e8222cd313e952e4056ffe4324 postgresql-bdr-9.4.1_bdr2.tar.bz2 +00f0fc07fb8447f7e174c4cee0661722 initdb.patch +8dec4e9dc132304b5d33586acbcdbf90 postgresql-bdr-osxflags.patch +901e76a1b9eedd08893f1aee23637f16 postgresql-bdr.initd +199747784fcba0a92e55283b90993d78 postgresql-bdr.confd +ee617d41ea865bab9247e3c5a39d597d pgbdr-restore.initd +bf45384752b320b369f1425939763178 pgbdr-restore.confd" +sha256sums="0e4691c62baea78df50bb4e07b11f5c044041364770c5ef935fc76e479c8d304 postgresql-bdr-9.4.1_bdr2.tar.bz2 +36a65229bf31b20a95ff2e2cac1a6ece0c61afdcd0b544759ad12f34d1b98a39 initdb.patch +d6f0f3eebca1c524c746c54be289e9816b00ad27fbfa834c2caee76c47daf155 postgresql-bdr-osxflags.patch +c173ffd6c3ce4348fdcee8c8511a2e09af3bed350a3cdef6cadc1700e79063b4 postgresql-bdr.initd +70ac7bf24556c16e6324b4efe76fba425bb09a2f7e74afbb5f988333eb8df724 postgresql-bdr.confd +68fe8f740e57e1454d8f1d7072b395a02c0637c32b804b25c228390c603e1344 pgbdr-restore.initd +31414d8b57c4cd2116b6014de3f1329875151910753fbd616daec4554866d02f pgbdr-restore.confd" +sha512sums="9ffc15b80d7c48ad8894fe290c1bd6870ea1468e66b07d583d2ddb69b0ebee6ad6cdc17eeed945ef58883830bc1b664fc47d228b6300050e3004c51c2c38a9d2 postgresql-bdr-9.4.1_bdr2.tar.bz2 +6f7fdceb1a5aba3f00894ae88afdf25e5f9c7a0ffc00b11211011a6415ea73639d6a67f516cab66c6487484bab26ded3c93471d6d41ac0d3822926c22274f2ba initdb.patch +1973863bfc208ce20ca2dd82557ebbd4fcddd1219d6a80f2e83550d0110d39f034cb829cca3ee9208f513a24b032267b94559c740ddddb10a4f24c630194eb5e postgresql-bdr-osxflags.patch +861e4f5091cb2b3c80ce0afddb09275ed7e130c717235cdb7a3e58599424f13c11855e158e584b7342df18d47f7a7d71e945b8899337f82a3ea814a11fff39c0 postgresql-bdr.initd +e906e23241bed2624719c1e7e5305695cce1cb520f26f6a4c6bbb994f59db3cc4c63afcfe0e7fb705ad4691dd0a911770012fc16819e4c2686c7029e1e4a4a45 postgresql-bdr.confd +f4739a297fa7862a15c4b11dd5043ef7b6b5366a19640446c50857e5a774c1829a997d786461ec58ebc929e3fa1a3a6170cadb5eb90166d529a2b8096ebeeeaf pgbdr-restore.initd +c14a5684e914abb3b0ee71bbf15eed71a9264deacaa404a6e3af6bfc330d93e7598624d0ed11a94263106cc660f7f54c8ff57e759033cf606a795f69ff6c1c7c pgbdr-restore.confd" diff --git a/main/postgresql-bdr/initdb.patch b/main/postgresql-bdr/initdb.patch new file mode 100644 index 0000000000..e919d9fc1b --- /dev/null +++ b/main/postgresql-bdr/initdb.patch @@ -0,0 +1,18 @@ +--- ./src/bin/initdb/initdb.c.orig 2013-09-09 14:38:21.712409752 +0000 ++++ ./src/bin/initdb/initdb.c 2013-09-09 14:40:19.453755379 +0000 +@@ -3652,14 +3652,6 @@ + strlcpy(bin_dir, argv[0], sizeof(bin_dir)); + get_parent_directory(bin_dir); + +- printf(_("\nSuccess. You can now start the database server using:\n\n" +- " %s%s%spostgres%s -D %s%s%s\n" +- "or\n" +- " %s%s%spg_ctl%s -D %s%s%s -l logfile start\n\n"), +- QUOTE_PATH, bin_dir, (strlen(bin_dir) > 0) ? DIR_SEP : "", QUOTE_PATH, +- QUOTE_PATH, pgdata_native, QUOTE_PATH, +- QUOTE_PATH, bin_dir, (strlen(bin_dir) > 0) ? DIR_SEP : "", QUOTE_PATH, +- QUOTE_PATH, pgdata_native, QUOTE_PATH); +- ++ printf(_("\nSuccess.\n\n")); + return 0; + } diff --git a/main/postgresql-bdr/pgbdr-restore.confd b/main/postgresql-bdr/pgbdr-restore.confd new file mode 100644 index 0000000000..84a179f6cd --- /dev/null +++ b/main/postgresql-bdr/pgbdr-restore.confd @@ -0,0 +1,16 @@ + +# Enable this to dump databases on shutdown and restore on boot +# +#PGDUMP="/var/lib/postgresql/backup/databases.pgdump" + +# The dump file will be deleted once restored unless KEEP_DUMP is set. +# This is to avoid accidental restoring of running database. If you know what +# you are doing and want keep the dump, then enable the KEEP_DUMP option +# below. +# +#KEEP_DUMP=yes + +# If you enable KEEP_DUMP above you probably also want the --clean option +# the the pg_dumpall command. +#PG_DUMPALL_OPTS="--clean" + diff --git a/main/postgresql-bdr/pgbdr-restore.initd b/main/postgresql-bdr/pgbdr-restore.initd new file mode 100644 index 0000000000..eef552bd5e --- /dev/null +++ b/main/postgresql-bdr/pgbdr-restore.initd @@ -0,0 +1,36 @@ +#!/sbin/runscript + +extra_commands="${opts} dump restore purge" + +depend() { + need postgresql-bdr +} + +restore() { + yesno "$PGDUMP" && return 0 + ebegin "Restoring PostgreSQL $PGDUMP" + psql -U ${PG_USER:-postgres} ${PSQL_OPTS} -f "$PGDUMP" >/dev/null 2>/dev/null + local res=$? + yesno "$KEEP_DUMP" || rm -f "$PGDUMP" + eend $res + /etc/init.d/postgresql reload +} + +dump() { + yesno "$PGDUMP" && return 0 + mkdir -p "$( dirname "$PGDUMP" )" + ebegin "Saving PostgreSQL databases to $PGDUMP" + pg_dumpall -U ${PG_USER:-postgres} ${PG_DUMPALL_OPTS} -f "$PGDUMP" + eend $? +} + +purge() { + yesno "$PGDUMP" && return 0 + ebegin "Removing temporary $PGDUMP PostgreSQL backup" + rm -f "$PGDUMP" + eend $? +} + +start() { + restore +} diff --git a/main/postgresql-bdr/postgresql-bdr-osxflags.patch b/main/postgresql-bdr/postgresql-bdr-osxflags.patch new file mode 100644 index 0000000000..fd3d9c14b5 --- /dev/null +++ b/main/postgresql-bdr/postgresql-bdr-osxflags.patch @@ -0,0 +1,11 @@ +--- a/doc/src/sgml/Makefile ++++ b/doc/src/sgml/Makefile +@@ -245,7 +245,7 @@ + # if we try to do "make all" in a VPATH build without the explicit + # $(srcdir) on the postgres.sgml dependency in this rule. GNU make bug? + postgres.xml: $(srcdir)/postgres.sgml $(ALMOSTALLSGML) +- $(OSX) -D. -x lower -i include-xslt-index $< >postgres.xmltmp ++ $(OSX) $(OSXFLAGS) -D. -x lower -i include-xslt-index $< >postgres.xmltmp + $(PERL) -p -e 's/\[(aacute|acirc|aelig|agrave|amp|aring|atilde|auml|bull|copy|eacute|egrave|gt|iacute|lt|mdash|nbsp|ntilde|oacute|ocirc|oslash|ouml|pi|quot|scaron|uuml) *\]/\&\1;/gi;' \ + -e '$$_ .= qq{<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">\n} if $$. == 1;' \ + <postgres.xmltmp > $@ diff --git a/main/postgresql-bdr/postgresql-bdr.confd b/main/postgresql-bdr/postgresql-bdr.confd new file mode 100644 index 0000000000..c6e8c6d993 --- /dev/null +++ b/main/postgresql-bdr/postgresql-bdr.confd @@ -0,0 +1,55 @@ +# Which port and socket to bind PostgreSQL +PGPORT="5432" + +# How long to wait for server to start in seconds +START_TIMEOUT=10 + +# NICE_QUIT ignores new connections and wait for clients to disconnect from +# server before shutting down. NICE_TIMEOUT in seconds determines how long to +# wait for this to succeed. +NICE_TIMEOUT=60 + +# Forecfully disconnect clients from server and shut down. This is performed +# after NICE_QUIT. Terminated client connections have their open transactions +# rolled back. +# Set RUDE_QUIT to "NO" to disable. RUDE_TIMEOUT in seconds. +RUDE_QUIT="YES" +RUDE_TIMEOUT=30 + +# If the server still fails to shutdown, you can force it to quit by setting +# this to YES and a recover-run will execute on the next startup. +# Set FORCE_QUIT to "YES" to enable. FORCE_TIMEOUT in seconds. +FORCE_QUIT="NO" +FORCE_TIMEOUT=2 + +# Extra options to run postmaster with, e.g.: +# -N is the maximal number of client connections +# -B is the number of shared buffers and has to be at least 2x the value for -N +# Please read the man-page to postmaster for more options. Many of these +# options can be set directly in the configuration file. +#PGOPTS="-N 512 -B 1024" + +# Pass extra environment variables. If you have to export environment variables +# for the database process, this can be done here. +# Don't forget to escape quotes. +#PG_EXTRA_ENV="PGPASSFILE=\"/path/to/.pgpass\"" + +############################################################################## +# +# The following values should not be arbitrarily changed. +# +# The initscript uses these variables to inform PostgreSQL where to find +# its data directory and configuration files. +# +############################################################################## + +# PostgreSQL's Database Directory +PGDATA="/var/lib/postgresql/9.4/data" + +# Additional options to pass to initdb. +# See `man initdb' for available options. +#PG_INITDB_OPTS="--locale=en_US.UTF-8" + +# Automatically set up a new database if missing on startup +AUTO_SETUP=yes + diff --git a/main/postgresql-bdr/postgresql-bdr.initd b/main/postgresql-bdr/postgresql-bdr.initd new file mode 100644 index 0000000000..d47c50540a --- /dev/null +++ b/main/postgresql-bdr/postgresql-bdr.initd @@ -0,0 +1,152 @@ +#!/sbin/runscript +# Copyright 1999-2008 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/dev-db/postgresql-server/files/postgresql.init-8.3,v 1.4 2008/09/28 22:53:02 caleb Exp $ +# Modifications to support Alpine Linux pg-restore + +extra_started_commands="reload" +extra_stopped_commands="setup" + +depend() { + use net + after firewall +} + +get_config() { + [ -f ${PGDATA%/}/postgresql.conf ] || return 1 + eval echo $(sed -e 's:#.*::' ${PGDATA%/}/postgresql.conf | awk '$1 == "'$1'" { print ($2 == "=" ? $3 : $2) }') +} + + +checkconfig() { + configured_port=$(get_config port) + : ${configured_port:=${PGPORT:-5432}} + socket_path=$(get_config unix_socket_directories) + : ${socket_path:=/var/run/postgresql} + + checkpath -d -m 0770 -o postgres:postgres ${socket_path} + + if [ -n "$WAIT_FOR_START" ]; then + START_TIMEOUT=$WAIT_FOR_START + fi + + [ -d "$PGDATA/base" ] && return 0 + if [ -z "$AUTO_SETUP" ] ; then + eerror "Database not found at: $PGDATA" + eerror "Please make sure that PGDATA points to the right path." + eerror "You can run '/etc/init.d/postgresql setup' to setup a new database cluster." + return 1 + fi + setup +} + +start() { + checkconfig || return 1 + + ebegin "Starting PostgreSQL" + + if [ -f "$PGDATA/postmaster.pid" ] ; then + rm -f "$PGDATA/postmaster.pid" + fi + + local retval= x= extraenv= + for x in ${PG_EXTRA_ENV} ; do + extraenv="${extraenv} --env ${x}" + done + + start-stop-daemon --start \ + --user ${PGUSER:-postgres} \ + --group ${PGGROUP:-postgres} \ + --env "PGPORT=${configured_port}" \ + ${extraenv} \ + --pidfile ${PGDATA}/postmaster.pid \ + --wait 100 \ + --exec /usr/bin/pg_ctl \ + -- \ + start -s -w -t ${START_TIMEOUT:-10} \ + -l ${PGDATA}/postmaster.log \ + -D ${PGDATA} -o "$PGOPTS" + retval=$? + + if [ $retval -ne 0 ] ; then + eerror "Check the log for a possible explanation of the above error." + eerror " ${PGDATA}/postmaster.log" + fi + eend $retval +} + +stop() { + if [ -n "$WAIT_FOR_DISCONNECT" ]; then + NICE_TIMEOUT=$WAIT_FOR_DISCONNECT + fi + if [ -n "$WAIT_FOR_CLEANUP" ]; then + RUDE_QUIT=YES + RUDE_TIMEOUT=$WAIT_FOR_CLEANUP + fi + if [ -n "$WAIT_FOR_QUIT" ] && [ $WAIT_FOR_QUIT -ne 0 ]; then + FORCE_QUIT=YES + FORCE_TIMEOUT=$WAIT_FOR_QUIT + fi + + local seconds=${NICE_TIMEOUT} + local retval + local retries=SIGTERM/${NICE_TIMEOUT} + if [ "${RUDE_QUIT}" != "NO" ] ; then + retries="${retries}/SIGINT/${RUDE_TIMEOUT}" + seconds=$(( $seconds + ${NICE_TIMEOUT} )) + fi + if [ "${FORCE_QUIT}" = "YES" ] ; then + retries="${retries}/SIGQUIT/${FORCE_TIMEOUT}" + seconds=$(( $seconds + ${FORCE_TIMEOUT} )) + fi + + ebegin "Stopping PostgreSQL (this can take up to ${seconds} seconds)" + + # Loops through nice, rude, and force quit in one go. + start-stop-daemon --stop \ + --exec /usr/bin/postgres \ + --retry ${retries} \ + --progress \ + --pidfile ${PGDATA}/postmaster.pid + eend +} + +reload() { + ebegin "Reloading PostgreSQL configuration" + kill -HUP $(head -n1 ${PGDATA}/postmaster.pid) + eend $? +} + +setup() { + ebegin "Creating a new PostgreSQL database cluster" + + if [ -d "${PGDATA}/base" ] ; then + eend 1 "${PGDATA}/base already exists" + return + fi + + mkdir -p "${PGDATA}" 2>/dev/null + + # If the pg_hba.conf and friends exist, move them + local tmpdir="$( dirname "$PGDATA" )/tmp" + mkdir -p "${tmpdir}" >/dev/null + echo mv "${PGDATA}"/* "${tmpdir}" + mv "${PGDATA}"/* "${tmpdir}" 2>/dev/null + + rm -rf "${PGDATA}"/* 2>/dev/null + chown -Rf postgres:postgres "${PGDATA}" + chmod 0700 "${PGDATA}" + cd "${PGDATA}" # to avoid the: could not change directory to "/root" + su -c "/usr/bin/initdb --pgdata ${PGDATA}" postgres + local res=$? + + # move the pg_hba.conf and friends + mv $tmpdir/* "$PGDATA" 2>/dev/null + rm -rf $tmpdir 2>/dev/null + + # Do not send a SIGHUP to postmaster; its not necessary for a new database + # and allows pg-restore to do a blind restore of an old database + + eend $res +} + diff --git a/main/postgresql-bdr/postgresql-bdr.pre-upgrade b/main/postgresql-bdr/postgresql-bdr.pre-upgrade new file mode 100644 index 0000000000..6116252c19 --- /dev/null +++ b/main/postgresql-bdr/postgresql-bdr.pre-upgrade @@ -0,0 +1,32 @@ +#!/bin/sh + +new="$1" +old="$2" + +pgver=${new%.*} +compare=$(apk version -t "$old" $pgver) + +# check if we upgrade from earlier than $pgver and if it is running +if [ "$compare" != "<" ] || ! /etc/init.d/postgresql --quiet status; then + exit 0 +fi + +if [ -f /etc/conf.d/postgresql ]; then + . /etc/conf.d/postgresql +fi + +cat <<EOF +* You are upgrading to postgres $pgver wich is not compatible with the running +* See: http://www.postgresql.org/docs/$pgver/static/upgrading.html +* +* The corresponding steps for Alpine Linux is: +* +* pg_dumpall -U ${PGUSER:-postgres} > dumpfile +* /etc/init.d/postgresql stop +* apk add -u postgresql +* /etc/init.d/postgresql setup +* /etc/init.d/postgresql start +* psql -U ${PGUSER:-postgres} -f dumpfile +* +EOF +exit 1 |