From f151ae9f47ea9b25c17c5d2bef29be89689b860f Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sat, 28 Jan 2012 12:20:35 +0100 Subject: [PATCH] postgresql: update to 8.4.10, systemd switch. --- srcpkgs/postgresql/INSTALL | 13 ++--- srcpkgs/postgresql/files/postgresql-initdb | 33 +++++++++++++ srcpkgs/postgresql/files/postgresql.confd | 13 ++--- srcpkgs/postgresql/files/postgresql.rc | 47 ------------------- srcpkgs/postgresql/files/postgresql.service | 20 ++++++++ srcpkgs/postgresql/patches/plperl_5.14.patch | 35 -------------- srcpkgs/postgresql/postgresql-client.template | 16 ++----- .../postgresql/postgresql-libs-devel.template | 18 +++---- srcpkgs/postgresql/postgresql-libs.template | 8 +--- srcpkgs/postgresql/postgresql-plperl.template | 8 +--- .../postgresql/postgresql-plpython.template | 8 +--- srcpkgs/postgresql/postgresql-pltcl.template | 15 ++---- srcpkgs/postgresql/template | 40 ++++++++-------- 13 files changed, 101 insertions(+), 173 deletions(-) create mode 100644 srcpkgs/postgresql/files/postgresql-initdb delete mode 100644 srcpkgs/postgresql/files/postgresql.rc create mode 100644 srcpkgs/postgresql/files/postgresql.service delete mode 100644 srcpkgs/postgresql/patches/plperl_5.14.patch diff --git a/srcpkgs/postgresql/INSTALL b/srcpkgs/postgresql/INSTALL index e0084967fb..78064fc137 100644 --- a/srcpkgs/postgresql/INSTALL +++ b/srcpkgs/postgresql/INSTALL @@ -5,16 +5,11 @@ post) cat << _EOF ===================================================================== -Please note that to properly start the PostgreSQL server, -a sample configuration file should be copied to -/var/lib/postgresql/data from -/usr/share/postgresql/postgresql.conf.sample, edit it accordingly -and use the following the command: +To customize PostgreSQL's systemd initialization: + /etc/default/postgresql - $ /etc/init.d/postgresql start - -The configuration file for starting the service is available in -/etc/conf.d/postgresql. +To customize PostgreSQL's server configuration: + /etc/postgresql/postgresql.conf ===================================================================== _EOF diff --git a/srcpkgs/postgresql/files/postgresql-initdb b/srcpkgs/postgresql/files/postgresql-initdb new file mode 100644 index 0000000000..805c7d68dc --- /dev/null +++ b/srcpkgs/postgresql/files/postgresql-initdb @@ -0,0 +1,33 @@ +#!/bin/sh + +set -e + +. /etc/default/postgresql + +# 2nd clause is necessary to prevent symlinking the directory to itself when it +# doesn't exist yet +if [ "$PGROOT" != "/var/lib/postgresql" ]; then + echo "Creating symlink /var/lib/postgresql -> $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/postgresql +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 diff --git a/srcpkgs/postgresql/files/postgresql.confd b/srcpkgs/postgresql/files/postgresql.confd index 3f5e46af73..9c8b6520ab 100644 --- a/srcpkgs/postgresql/files/postgresql.confd +++ b/srcpkgs/postgresql/files/postgresql.confd @@ -1,16 +1,13 @@ # Configuration file for the PostgreSQL server. -# -# PostgreSQL's Database Directory -PGDATA="/var/lib/postgresql/data" + +# PostgreSQL's database directory +PGROOT="/var/lib/postgresql" # PostgreSQL's log file. PGLOG="/var/log/postgresql.log" -# PostgreSQL User -PGUSER="postgres" - -# PostgreSQL Group -PGGROUP="postgres" +# Passed to initdb if necessary +INITOPTS="--locale en_US.UTF-8" # Extra options to run postmaster with, e.g.: # -N is the maximal number of client connections diff --git a/srcpkgs/postgresql/files/postgresql.rc b/srcpkgs/postgresql/files/postgresql.rc deleted file mode 100644 index bed90702c3..0000000000 --- a/srcpkgs/postgresql/files/postgresql.rc +++ /dev/null @@ -1,47 +0,0 @@ -#!/sbin/runscript - -: ${PGLOG:=/var/log/postgresql.log} -extra_commands="reload" - -depend() -{ - use net - provide postgresql -} - -start_pre() -{ - if [ ! -d "$PGDATA" ] ; then - einfo "Creating PostgreSQL dbdir: ${PGDATA}" - mkdir -p ${PGDATA} && \ - chown -R ${PGUSER}.${PGGROUP} ${PGDATA} - einfo "Initializing PostgreSQL dbdir: ${PGDATA}" - su -l ${PGUSER} -c "/usr/bin/initdb -D ${PGDATA}" - fi - if [ ! -e ${PGLOG} ]; then - touch -f ${PGLOG} - chown ${PGUSER} ${PGLOG} - fi -} - -start() -{ - ebegin "Starting PostgreSQL" - su -l ${PGUSER} -c "/usr/bin/pg_ctl -D ${PGDATA} -l ${PGLOG} \ - -W start ${PGOPTS}" - eend $? -} - -stop() -{ - ebegin "Stopping PostgreSQL" - su -l ${PGUSER} -c "/usr/bin/pg_ctl -D ${PGDATA} -l ${PGLOG} -w stop" - eend $? -} - -reload() -{ - ebegin "Reloading PostgreSQL configuration" - su -l ${PGUSER} -c "/usr/bin/pg_ctl -D ${PGDATA} -l ${PGLOG} reload" - eend $? -} diff --git a/srcpkgs/postgresql/files/postgresql.service b/srcpkgs/postgresql/files/postgresql.service new file mode 100644 index 0000000000..d7d80d70de --- /dev/null +++ b/srcpkgs/postgresql/files/postgresql.service @@ -0,0 +1,20 @@ +[Unit] +Description=PostgreSQL database server + +[Service] +Type=forking +SyslogIdentifier=postgres +PIDFile=/var/lib/postgresql/data/postmaster.pid + +# initdb script takes care for symlinking $PGROOT to /var/lib/postgres +ExecStartPre=/lib/systemd/scripts/postgresql-initdb +ExecStart= /bin/su - postgres -m -c "/usr/bin/pg_ctl -s -D /var/lib/postgresql/data start" +ExecReload=/bin/su - postgres -m -c "/usr/bin/pg_ctl -s -D /var/lib/postgresql/data reload" +ExecStop= /bin/su - postgres -m -c "/usr/bin/pg_ctl -s -D /var/lib/postgresql/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 diff --git a/srcpkgs/postgresql/patches/plperl_5.14.patch b/srcpkgs/postgresql/patches/plperl_5.14.patch deleted file mode 100644 index f5b524b008..0000000000 --- a/srcpkgs/postgresql/patches/plperl_5.14.patch +++ /dev/null @@ -1,35 +0,0 @@ -*** src/pl/plperl/plperl.c ---- src/pl/plperl/plperl.c -*************** -*** 700,706 **** plperl_trusted_init(void) - if (!isGV_with_GP(sv) || !GvCV(sv)) - continue; - SvREFCNT_dec(GvCV(sv)); /* free the CV */ -! GvCV(sv) = NULL; /* prevent call via GV */ - } - hv_clear(stash); - /* invalidate assorted caches */ ---- 700,706 ---- - if (!isGV_with_GP(sv) || !GvCV(sv)) - continue; - SvREFCNT_dec(GvCV(sv)); /* free the CV */ -! GvCV_set(sv, NULL); /* prevent call via GV */ - } - hv_clear(stash); - /* invalidate assorted caches */ -*** src/pl/plperl/plperl.h ---- src/pl/plperl/plperl.h -*************** -*** 43,48 **** ---- 43,53 ---- - #undef bool - #endif - -+ /* supply GvCV_set if it's missing - ppport.h doesn't supply it, unfortunately */ -+ #ifndef GvCV_set -+ #define GvCV_set(gv, cv) (GvCV(gv) = cv) -+ #endif -+ - /* routines from spi_internal.c */ - int spi_DEBUG(void); - int spi_LOG(void); diff --git a/srcpkgs/postgresql/postgresql-client.template b/srcpkgs/postgresql/postgresql-client.template index ca0a44d7e3..1117a7b33e 100644 --- a/srcpkgs/postgresql/postgresql-client.template +++ b/srcpkgs/postgresql/postgresql-client.template @@ -1,6 +1,5 @@ # Template file for 'postgresql-client'. # -revision=1 short_desc="Client frontends programs for PostgreSQL" long_desc="${long_desc} @@ -13,21 +12,14 @@ long_desc="${long_desc} On a network, you can install this package on many client machines, while the server package may be installed on only one machine." -Add_dependency run libxslt - -do_install() -{ - mkdir -p ${DESTDIR}/usr/bin ${DESTDIR}/usr/share/man/man1 \ - ${DESTDIR}/usr/share/postgresql - +do_install() { for f in clusterdb createdb createlang createuser dropdb droplang \ dropuser pg_dump pg_dumpall pg_restore psql reindexdb \ vacuumdb; do - mv ${SRCPKGDESTDIR}/usr/bin/${f} ${DESTDIR}/usr/bin - mv ${SRCPKGDESTDIR}/usr/share/man/man1/${f}.1 \ - ${DESTDIR}/usr/share/man/man1 + vmove usr/bin/${f} usr/bin + vmove usr/share/man/man1/${f}.1 usr/share/man/man1 done - mv ${SRCPKGDESTDIR}/usr/share/man/man7 ${DESTDIR}/usr/share/man + vmove usr/share/man/man7 usr/share/man for d in $(find ${SRCPKGDESTDIR}/usr/share/locale \ -type f -name pgscripts\* -o \ -name psql\* -o \ diff --git a/srcpkgs/postgresql/postgresql-libs-devel.template b/srcpkgs/postgresql/postgresql-libs-devel.template index d22b96534f..d15a0c558a 100644 --- a/srcpkgs/postgresql/postgresql-libs-devel.template +++ b/srcpkgs/postgresql/postgresql-libs-devel.template @@ -1,6 +1,5 @@ # Template file for 'postgresql-libs-devel'. # -revision=1 short_desc="PostgreSQL shared libraries (development files)" long_desc="${long_desc} @@ -9,19 +8,14 @@ long_desc="${long_desc} Add_dependency run postgresql-libs -do_install() -{ - mkdir -p ${DESTDIR}/usr/lib/postgresql ${DESTDIR}/usr/bin \ - ${DESTDIR}/usr/share/man/man1 +do_install() { for f in pg_config ecpg; do - mv ${SRCPKGDESTDIR}/usr/bin/${f} ${DESTDIR}/usr/bin - mv ${SRCPKGDESTDIR}/usr/share/man/man1/${f}* \ - ${DESTDIR}/usr/share/man/man1 + vmove usr/bin/${f} usr/bin + vmove "usr/share/man/man1/${f}*" usr/share/man/man1 done - mv ${SRCPKGDESTDIR}/usr/include ${DESTDIR}/usr - mv ${SRCPKGDESTDIR}/usr/lib/*.a ${DESTDIR}/usr/lib - mv ${SRCPKGDESTDIR}/usr/lib/postgresql/pgxs \ - ${DESTDIR}/usr/lib/postgresql + vmove usr/include usr + vmove "usr/lib/*.a" usr/lib + vmove usr/lib/postgresql/pgxs usr/lib/postgresql for d in $(find ${SRCPKGDESTDIR}/usr/share/locale \ -type f -name pg_config\* -o -name ecpg\*); do mkdir -p ${DESTDIR}/$(dirname ${d#${SRCPKGDESTDIR}}) diff --git a/srcpkgs/postgresql/postgresql-libs.template b/srcpkgs/postgresql/postgresql-libs.template index 7fde7659b4..2004336e26 100644 --- a/srcpkgs/postgresql/postgresql-libs.template +++ b/srcpkgs/postgresql/postgresql-libs.template @@ -1,16 +1,12 @@ # Template file for 'postgresql-libs'. # -revision=1 short_desc="PostgreSQL shared libraries" long_desc="${long_desc} This package provides the shared libraries used by PostgreSQL applications." - -do_install() -{ - mkdir -p ${DESTDIR}/usr/lib - mv ${SRCPKGDESTDIR}/usr/lib/*.so* ${DESTDIR}/usr/lib +do_install() { + vmove "usr/lib/*.so*" usr/lib for d in $(find ${SRCPKGDESTDIR}/usr/share/locale \ -type f -name libpq5\*); do mkdir -p ${DESTDIR}/$(dirname ${d#${SRCPKGDESTDIR}}) diff --git a/srcpkgs/postgresql/postgresql-plperl.template b/srcpkgs/postgresql/postgresql-plperl.template index 2ccd53c368..403c64d6fc 100644 --- a/srcpkgs/postgresql/postgresql-plperl.template +++ b/srcpkgs/postgresql/postgresql-plperl.template @@ -1,6 +1,5 @@ # Template file for 'postgresql-plperl'. # -revision=1 short_desc="PL/Perl procedural language for PostgreSQL" long_desc="${long_desc} @@ -10,11 +9,8 @@ long_desc="${long_desc} Add_dependency run postgresql -do_install() -{ - mkdir -p ${DESTDIR}/usr/lib/postgresql - mv ${SRCPKGDESTDIR}/usr/lib/postgresql/plperl* \ - ${DESTDIR}/usr/lib/postgresql +do_install() { + vmove "usr/lib/postgresql/plperl*" usr/lib/postgresql for d in $(find ${SRCPKGDESTDIR}/usr/share/locale \ -type f -name plperl\*); do mkdir -p ${DESTDIR}/$(dirname ${d#${SRCPKGDESTDIR}}) diff --git a/srcpkgs/postgresql/postgresql-plpython.template b/srcpkgs/postgresql/postgresql-plpython.template index 4a3fea4e5d..b2e0c96ffb 100644 --- a/srcpkgs/postgresql/postgresql-plpython.template +++ b/srcpkgs/postgresql/postgresql-plpython.template @@ -1,6 +1,5 @@ # Template file for 'postgresql-plpython'. # -revision=1 short_desc="PL/Python procedural language for PostgreSQL" long_desc="${long_desc} @@ -10,11 +9,8 @@ long_desc="${long_desc} Add_dependency run postgresql -do_install() -{ - mkdir -p ${DESTDIR}/usr/lib/postgresql - mv ${SRCPKGDESTDIR}/usr/lib/postgresql/plpython* \ - ${DESTDIR}/usr/lib/postgresql +do_install() { + vmove "usr/lib/postgresql/plpython*" usr/lib/postgresql for d in $(find ${SRCPKGDESTDIR}/usr/share/locale \ -type f -name plpython\*); do mkdir -p ${DESTDIR}/$(dirname ${d#${SRCPKGDESTDIR}}) diff --git a/srcpkgs/postgresql/postgresql-pltcl.template b/srcpkgs/postgresql/postgresql-pltcl.template index 39eaf1e83c..6c820da6dd 100644 --- a/srcpkgs/postgresql/postgresql-pltcl.template +++ b/srcpkgs/postgresql/postgresql-pltcl.template @@ -1,6 +1,5 @@ # Template file for 'postgresql-pltcl'. # -revision=1 short_desc="PL/Tcl procedural language for PostgreSQL" long_desc="${long_desc} @@ -10,19 +9,13 @@ long_desc="${long_desc} Add_dependency run postgresql -do_install() -{ - mkdir -p ${DESTDIR}/usr/bin ${DESTDIR}/usr/lib/postgresql \ - ${DESTDIR}/usr/share/postgresql - - mv ${SRCPKGDESTDIR}/usr/bin/pltcl* ${DESTDIR}/usr/bin - mv ${SRCPKGDESTDIR}/usr/lib/postgresql/pltcl* \ - ${DESTDIR}/usr/lib/postgresql +do_install() { + vmove "usr/bin/pltcl*" usr/bin + vmove "usr/lib/postgresql/pltcl*" usr/lib/postgresql for d in $(find ${SRCPKGDESTDIR}/usr/share/locale \ -type f -name pltcl\*); do mkdir -p ${DESTDIR}/$(dirname ${d#${SRCPKGDESTDIR}}) mv ${d} ${DESTDIR}/$(dirname ${d#${SRCPKGDESTDIR}}) done - mv ${SRCPKGDESTDIR}/usr/share/postgresql/*.pltcl \ - ${DESTDIR}/usr/share/postgresql + vmove "usr/share/postgresql/*.pltcl" usr/share/postgresql } diff --git a/srcpkgs/postgresql/template b/srcpkgs/postgresql/template index 0711cffbdc..3f759c49bb 100644 --- a/srcpkgs/postgresql/template +++ b/srcpkgs/postgresql/template @@ -1,19 +1,18 @@ # Template file for 'postgresql' pkgname=postgresql -version=8.4.8 +version=8.4.10 distfiles="ftp://ftp.postgresql.org/pub/source/v${version}/${pkgname}-${version}.tar.bz2" build_style=gnu-configure configure_args="--with-docdir=/usr/share/doc --with-openssl --with-python --with-pam --datadir=/usr/share/postgresql --enable-thread-safety --with-perl --with-tcl --without-ldap --without-gssapi --without-krb5 --without-bonjour --with-libxml --with-libxslt --disable-rpath ---with-system-tzdata=/usr/share/zoneinfo --enable-nls --with-gnu-ld" -revision=1 +--with-system-tzdata=/usr/share/zoneinfo --enable-nls" short_desc="Sophisticated open-source Object-Relational DBMS" maintainer="Juan RP " homepage="http://www.postgresql.org" license="BSD" -checksum=3e90ef2a86a9f4831e21ff4a574fbfb8e1b8c097af637c93ec43c64c684a0938 +checksum=749f83e9d467b07dcd012fdf2b1615c577b410fd219b44a27bb7097bb1b07cfb long_desc=" PostgreSQL is a powerful, open source object-relational database system. It has more than 15 years of active development and a proven architecture @@ -25,36 +24,35 @@ subpackages="${pkgname}-doc ${pkgname}-libs ${pkgname}-libs-devel" subpackages="${subpackages} ${pkgname}-plperl ${pkgname}-plpython" subpackages="${subpackages} ${pkgname}-pltcl ${pkgname}-client" -conf_files="/etc/conf.d/postgresql" +conf_files=" +/etc/default/${pkgname} +/etc/pam.d/${pkgname} +/etc/${pkgname}/${pkgname}.conf" + +systemd_services="${pkgname}.service on" # Create 'postgres' user for the server. system_accounts="postgres" -postgres_homedir="/var/lib/postgresql" +postgres_homedir="/var/lib/${pkgname}" postgres_shell="/bin/sh" postgres_descr="PostgreSQL database server user" -# Add the OpenRC service. -openrc_services="postgresql default false" - - Add_dependency build flex Add_dependency build gettext +Add_dependency build readline-devel +Add_dependency build openssl-devel Add_dependency build perl Add_dependency build tcl-devel Add_dependency build python-devel -Add_dependency build openssl-devel -Add_dependency build zlib-devel Add_dependency build libxml2-devel Add_dependency build libxslt-devel Add_dependency build pam-devel -Add_dependency build readline-devel -post_install() -{ - install -D -m644 ${FILESDIR}/postgresql.confd \ - ${DESTDIR}/etc/conf.d/postgresql - install -D -m755 ${FILESDIR}/postgresql.rc \ - ${DESTDIR}/etc/init.d/postgresql - install -D -m644 ${FILESDIR}/postgresql.pam \ - ${DESTDIR}/etc/pam.d/postgresql +post_install() { + vinstall ${FILESDIR}/${pkgname}.confd 644 etc/default ${pkgname} + vinstall ${FILESDIR}/${pkgname}.service 644 lib/systemd/system + vinstall ${FILESDIR}/${pkgname}-initdb 755 lib/systemd/scripts + vinstall ${FILESDIR}/${pkgname}.pam 644 etc/pam.d ${pkgname} + vinstall ${DESTDIR}/usr/share/${pkgname}/${pkgname}.conf.sample \ + 644 etc/${pkgname} ${pkgname}.conf }