From 280fb616f0b51df2508b34ffb671a035cfd281d4 Mon Sep 17 00:00:00 2001 From: Paul Labedan Date: Wed, 31 May 2017 09:00:41 +0200 Subject: add dev-db/postgres with valgrind support --- dev-db/postgresql/Manifest | 10 + dev-db/postgresql/files/pg_ctl-exit-status.patch | 12 + .../files/postgresql-9.4-no-server.patch | 151 +++++++ .../files/postgresql-9.4.10-no-server.patch | 151 +++++++ dev-db/postgresql/files/postgresql-check-db-dir | 35 ++ dev-db/postgresql/files/postgresql.confd | 58 +++ dev-db/postgresql/files/postgresql.init | 137 ++++++ dev-db/postgresql/files/postgresql.service | 55 +++ dev-db/postgresql/metadata.xml | 21 + dev-db/postgresql/postgresql-9.4.12-r2.ebuild | 477 +++++++++++++++++++++ 10 files changed, 1107 insertions(+) create mode 100644 dev-db/postgresql/Manifest create mode 100644 dev-db/postgresql/files/pg_ctl-exit-status.patch create mode 100644 dev-db/postgresql/files/postgresql-9.4-no-server.patch create mode 100644 dev-db/postgresql/files/postgresql-9.4.10-no-server.patch create mode 100644 dev-db/postgresql/files/postgresql-check-db-dir create mode 100644 dev-db/postgresql/files/postgresql.confd create mode 100644 dev-db/postgresql/files/postgresql.init create mode 100644 dev-db/postgresql/files/postgresql.service create mode 100644 dev-db/postgresql/metadata.xml create mode 100644 dev-db/postgresql/postgresql-9.4.12-r2.ebuild diff --git a/dev-db/postgresql/Manifest b/dev-db/postgresql/Manifest new file mode 100644 index 0000000..815e260 --- /dev/null +++ b/dev-db/postgresql/Manifest @@ -0,0 +1,10 @@ +AUX pg_ctl-exit-status.patch 283 SHA256 bfa7d6cd233ebb0a3e0a1c818433fb6c7d03282752c62d88af295d683e447937 SHA512 3f0c9187e315a5dde86b2c99d108f702416a69aceda4b00ed0fa5b6d93b883a1e1a38640cb091282a3a8441b5f7264e28d755667fd3395e6c34ad060b107d813 WHIRLPOOL 95f669116d56c7423385f07302106c950a0b1c5050dc4ab5650066d935be09b954cdc8b8fb7ce97c8f90f89a49063405dca4b79b433c5856a56c7e44362123ad +AUX postgresql-9.4-no-server.patch 4345 SHA256 3f4a5f26a56ed2e7a2aa6bcf35a2dd2d9e4ca7c20951fadd339969c1edcaecf5 SHA512 f7860f9826c27faa40db66796e644e83c2036698679075f131bad437a0cdf19b1478dbeb216175960d752e92cb2ab5757668dfcb24885ff6d8445226eb3d316e WHIRLPOOL 4386c97ca5be6860da4daa1656d0543427f1f22dae2bf47ac1b7760664b515dccff1ed43d51560ee0081dd2ea3917d25ad05245f5a2dcd45434a01d13d96942c +AUX postgresql-9.4.10-no-server.patch 4356 SHA256 c163e530aec0bce6966c9310084caba06c27aa3db3187fd1ae74de68f67cc37c SHA512 1abfb624b01b925a834c1c4f292246fd676cb7f2241a4e26bf52ce9b8c4dc2e4beeb4eea326c44f758d45034d5f18370280a8b18114bffaba1841e9ddac45174 WHIRLPOOL 384a411d715f806a6eb0c8b8ddc2f4a3420f3886267d1e35297505215d80dbb2d01725c9ee2924f56f793339173d43a8d42b84a7bfc33ecf1c5ca61cbc4b07b9 +AUX postgresql-check-db-dir 1013 SHA256 bd39dc7d112c42330afb94abff0739afe5b02268fff7c89f60306f6e7c22956f SHA512 2f34ee0cb6a889500ccfca7621ada6ee1bb06dc146f3c556938152dd3d7c0312266bb4db5f4099838d93ade26e2b8866dfddb3576cb5a737431ea2befd0cec6f WHIRLPOOL 7e7cbcd2caa2ebc97e96fa50a340b44b8abf3d1cfefeaa5676ac78860735719f27a98b1ded02108d349e75db4b533bc4fb31402cff7e3cbe1e2651a1c43781a3 +AUX postgresql.confd 2202 SHA256 57c1ad0b14e8458024c713dd8cc2390023b95c27ba4cbd637333b1020f11f398 SHA512 ad4e66196f70d543d396ae72db6b0beb2cf8861f612dceaa1a1333b139475262e84bcf40774155254ed1cda7ada830d76f60b27982d0cb840360cc13fbbcecbc WHIRLPOOL aa012a5f302dccb362e54b6fea1ae6193330cc41c632b132c890f8a578f6f97a7ee9773057ea607b4f4914c97cd845dd4778c1bc29ea62b5ee1ff0e5c56f2211 +AUX postgresql.init 4162 SHA256 031f010ca5f70ce7b763c7d1f1adf13fce1c09dcd0afcefa057dd1b3bff45063 SHA512 e0052fda5d71b9ba06ad7a4517c7bb2d6bb186acf3686095d7217b63e4f5b45f21e3f90c1ac9b0238143d458081eedc36167af6abefe95e197c31f9e429d87a8 WHIRLPOOL 43db9eeef47aa3457e4c455e550e779537531b30714cadd584df3ad137ac6dea4d25344bb811a2f46a5836636b012628110062d600b5b74ea091a07b780900d9 +AUX postgresql.service 1768 SHA256 a5882f4f4b8d391a1226c5dc514df83342107c94880e32eaf174d152f280de88 SHA512 92c60a21ac87a298742d0aa0f4180218cebfa5644762c32a27b1314d92a581eb4f6cbcf41b20f29509c6eec9f6f236a57d2c944aa1eca35d7f8d29e2865b47d7 WHIRLPOOL 5f58b28a903311b4b59452d44c1cec3dab792bbb59b73eb5ae3926f64f45a5926bbdc7a17f460ea66256c940aefa560c89ffa49999fedfff69f223a63bf33a03 +DIST postgresql-9.4.12.tar.bz2 17833119 SHA256 fca055481875d1c49e31c28443f56472a1474b3fbe25b7ae64440c6118f82e64 SHA512 69951f9e66069aad1049a0ea9fdcd7bf2f84b42e7c6e0f761d78ab22131a39cf56448ef0ddc28170b66970bf53edf2d2355530fcfc0a2dca92b66d69686b7ecb WHIRLPOOL ca023aab29d7993e236c52df58d6fae6f9bd1649cf20f1e1b118ff232dc41674001d3dc9bc945e3f9dd61779dde27cb93265b89d3615e47f49ea46751d8e97c3 +EBUILD postgresql-9.4.12-r2.ebuild 14403 SHA256 1bb4e19961242b2b55af8812ca3cf4c20ebf30a21a72870eb430b153a8c57be8 SHA512 ede049d41e84f099816a38ea00d973671f029512637aa818dd6bd06e6ee44017723e5be7ddc569ed39eefff99bc59e80ce44fd5e3db96d00ce7683fec9573ee3 WHIRLPOOL c802f5ba1930618515975faa6550ff069980855b8a80c2488cae5f832f065ae59e4556495b51a379cc72d69259e13fb6320f12a3c4b4578f83f0359e0baebc1f +MISC metadata.xml 751 SHA256 97274deca46bb3ef708b8fe348946d9119220d8ba34bf90c0044675a00eeb5f2 SHA512 726f30ec991194427b2dbcdf650778dbe0f169cb305d569918404d403deef397aef7ec3f1a5269c15f7ec7fc5506dc534203323379f1d0acc475eeb8d75d0cf1 WHIRLPOOL 8372aaaaa2044be729eaa5d2e620dff368f16bacd450a48b048338a51f1500fc85fe5865d68f3e06b783732e823566b6dc7b7bc4f6149893cda8e452daefc331 diff --git a/dev-db/postgresql/files/pg_ctl-exit-status.patch b/dev-db/postgresql/files/pg_ctl-exit-status.patch new file mode 100644 index 0000000..bbbd449 --- /dev/null +++ b/dev-db/postgresql/files/pg_ctl-exit-status.patch @@ -0,0 +1,12 @@ +diff -Naur a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c +--- a/src/bin/pg_ctl/pg_ctl.c 2011-04-14 23:18:15 -0400 ++++ b/src/bin/pg_ctl/pg_ctl.c 2011-08-01 19:44:54 -0400 +@@ -975,7 +975,7 @@ + } + } + printf(_("%s: no server running\n"), progname); +- exit(1); ++ exit(3); + } + + diff --git a/dev-db/postgresql/files/postgresql-9.4-no-server.patch b/dev-db/postgresql/files/postgresql-9.4-no-server.patch new file mode 100644 index 0000000..c46146e --- /dev/null +++ b/dev-db/postgresql/files/postgresql-9.4-no-server.patch @@ -0,0 +1,151 @@ +diff -Naur a/contrib/Makefile b/contrib/Makefile +--- a/contrib/Makefile 2013-05-06 20:57:06.000000000 +0000 ++++ b/contrib/Makefile 2013-06-09 01:48:22.351874929 +0000 +@@ -5,64 +5,10 @@ + include $(top_builddir)/src/Makefile.global + + SUBDIRS = \ +- adminpack \ +- auth_delay \ +- auto_explain \ +- btree_gin \ +- btree_gist \ +- chkpass \ +- citext \ +- cube \ +- dblink \ +- dict_int \ +- dict_xsyn \ +- dummy_seclabel \ +- earthdistance \ +- file_fdw \ +- fuzzystrmatch \ +- hstore \ +- intagg \ +- intarray \ +- isn \ +- lo \ +- ltree \ + oid2name \ +- pageinspect \ +- passwordcheck \ +- pg_archivecleanup \ +- pg_buffercache \ +- pg_freespacemap \ +- pg_prewarm \ +- pg_standby \ +- pg_stat_statements \ +- pg_test_fsync \ +- pg_test_timing \ +- pg_trgm \ +- pg_upgrade \ +- pg_upgrade_support \ + pgbench \ +- pgcrypto \ +- pgrowlocks \ +- pgstattuple \ +- pg_xlogdump \ +- postgres_fdw \ +- seg \ +- spi \ +- tablefunc \ +- tcn \ +- test_decoding \ +- test_parser \ +- test_shm_mq \ +- tsearch2 \ +- unaccent \ +- vacuumlo \ +- worker_spi ++ vacuumlo + +-ifeq ($(with_openssl),yes) +-SUBDIRS += sslinfo +-else +-ALWAYS_SUBDIRS += sslinfo +-endif + + ifeq ($(with_ossp_uuid),yes) + SUBDIRS += uuid-ossp +diff -Naur a/src/backend/Makefile b/src/backend/Makefile +--- a/src/backend/Makefile 2013-05-06 20:57:06.000000000 +0000 ++++ b/src/backend/Makefile 2013-06-09 01:50:19.655864258 +0000 +@@ -47,7 +47,7 @@ + + ########################################################################## + +-all: submake-libpgport submake-schemapg postgres $(POSTGRES_IMP) ++all: someheaders + + ifneq ($(PORTNAME), cygwin) + ifneq ($(PORTNAME), win32) +@@ -116,7 +116,7 @@ + endif # aix + + # Update the commonly used headers before building the subdirectories +-$(SUBDIRS:%=%-recursive): $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/catalog/schemapg.h $(top_builddir)/src/include/utils/fmgroids.h $(top_builddir)/src/include/utils/errcodes.h $(top_builddir)/src/include/utils/probes.h ++someheaders $(SUBDIRS:%=%-recursive): $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/catalog/schemapg.h $(top_builddir)/src/include/utils/fmgroids.h $(top_builddir)/src/include/utils/errcodes.h $(top_builddir)/src/include/utils/probes.h + + # run this unconditionally to avoid needing to know its dependencies here: + submake-schemapg: +@@ -209,23 +209,8 @@ + + ########################################################################## + +-install: all installdirs install-bin +-ifeq ($(PORTNAME), cygwin) +-ifeq ($(MAKE_DLL), true) +- $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a' +-endif +-endif +-ifeq ($(PORTNAME), win32) +-ifeq ($(MAKE_DLL), true) +- $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a' +-endif +-endif +- $(MAKE) -C catalog install-data +- $(MAKE) -C tsearch install-data +- $(INSTALL_DATA) $(srcdir)/libpq/pg_hba.conf.sample '$(DESTDIR)$(datadir)/pg_hba.conf.sample' +- $(INSTALL_DATA) $(srcdir)/libpq/pg_ident.conf.sample '$(DESTDIR)$(datadir)/pg_ident.conf.sample' +- $(INSTALL_DATA) $(srcdir)/utils/misc/postgresql.conf.sample '$(DESTDIR)$(datadir)/postgresql.conf.sample' +- $(INSTALL_DATA) $(srcdir)/access/transam/recovery.conf.sample '$(DESTDIR)$(datadir)/recovery.conf.sample' ++install: ++ + + install-bin: postgres $(POSTGRES_IMP) installdirs + $(INSTALL_PROGRAM) postgres$(X) '$(DESTDIR)$(bindir)/postgres$(X)' +diff -Naur a/src/bin/Makefile b/src/bin/Makefile +--- a/src/bin/Makefile 2013-05-06 20:57:06.000000000 +0000 ++++ b/src/bin/Makefile 2013-06-09 01:51:56.143824442 +0000 +@@ -13,8 +13,7 @@ + top_builddir = ../.. + include $(top_builddir)/src/Makefile.global + +-SUBDIRS = initdb pg_ctl pg_dump \ +- psql scripts pg_config pg_controldata pg_resetxlog pg_basebackup ++SUBDIRS = pg_dump psql scripts pg_config + + ifeq ($(PORTNAME), win32) + SUBDIRS += pgevent +diff -Naur a/src/Makefile b/src/Makefile +--- a/src/Makefile 2013-05-06 20:57:06.000000000 +0000 ++++ b/src/Makefile 2013-06-09 01:54:30.479704228 +0000 +@@ -15,17 +15,11 @@ + SUBDIRS = \ + common \ + port \ +- timezone \ + backend \ +- backend/utils/mb/conversion_procs \ +- backend/snowball \ + include \ + interfaces \ +- backend/replication/libpqwalreceiver \ + bin \ +- pl \ +- makefiles \ +- test/regress ++ makefiles + + # There are too many interdependencies between the subdirectories, so + # don't attempt parallel make here. diff --git a/dev-db/postgresql/files/postgresql-9.4.10-no-server.patch b/dev-db/postgresql/files/postgresql-9.4.10-no-server.patch new file mode 100644 index 0000000..81fc383 --- /dev/null +++ b/dev-db/postgresql/files/postgresql-9.4.10-no-server.patch @@ -0,0 +1,151 @@ +diff -Naruw a/contrib/Makefile b/contrib/Makefile +--- a/contrib/Makefile 2016-10-24 16:12:53.000000000 -0400 ++++ b/contrib/Makefile 2016-10-27 13:38:23.361545396 -0400 +@@ -5,64 +5,10 @@ + include $(top_builddir)/src/Makefile.global + + SUBDIRS = \ +- adminpack \ +- auth_delay \ +- auto_explain \ +- btree_gin \ +- btree_gist \ +- chkpass \ +- citext \ +- cube \ +- dblink \ +- dict_int \ +- dict_xsyn \ +- dummy_seclabel \ +- earthdistance \ +- file_fdw \ +- fuzzystrmatch \ +- hstore \ +- intagg \ +- intarray \ +- isn \ +- lo \ +- ltree \ + oid2name \ +- pageinspect \ +- passwordcheck \ +- pg_archivecleanup \ +- pg_buffercache \ +- pg_freespacemap \ +- pg_prewarm \ +- pg_standby \ +- pg_stat_statements \ +- pg_test_fsync \ +- pg_test_timing \ +- pg_trgm \ +- pg_upgrade \ +- pg_upgrade_support \ + pgbench \ +- pgcrypto \ +- pgrowlocks \ +- pgstattuple \ +- pg_xlogdump \ +- postgres_fdw \ +- seg \ +- spi \ +- tablefunc \ +- tcn \ +- test_decoding \ +- test_parser \ +- test_shm_mq \ +- tsearch2 \ +- unaccent \ +- vacuumlo \ +- worker_spi ++ vacuumlo + +-ifeq ($(with_openssl),yes) +-SUBDIRS += sslinfo +-else +-ALWAYS_SUBDIRS += sslinfo +-endif + + ifneq ($(with_uuid),no) + SUBDIRS += uuid-ossp +diff -Naruw a/src/backend/Makefile b/src/backend/Makefile +--- a/src/backend/Makefile 2016-10-24 16:12:53.000000000 -0400 ++++ b/src/backend/Makefile 2016-10-27 14:04:47.617000374 -0400 +@@ -47,7 +47,7 @@ + + ########################################################################## + +-all: submake-libpgport submake-schemapg postgres $(POSTGRES_IMP) ++all: someheaders + + ifneq ($(PORTNAME), cygwin) + ifneq ($(PORTNAME), win32) +@@ -106,7 +106,7 @@ + endif # aix + + # Update the commonly used headers before building the subdirectories +-$(SUBDIRS:%=%-recursive): $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/catalog/schemapg.h $(top_builddir)/src/include/utils/fmgroids.h $(top_builddir)/src/include/utils/errcodes.h $(top_builddir)/src/include/utils/probes.h ++someheaders $(SUBDIRS:%=%-recursive): $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/catalog/schemapg.h $(top_builddir)/src/include/utils/fmgroids.h $(top_builddir)/src/include/utils/errcodes.h $(top_builddir)/src/include/utils/probes.h + + # run this unconditionally to avoid needing to know its dependencies here: + submake-schemapg: +@@ -199,23 +199,7 @@ + + ########################################################################## + +-install: all installdirs install-bin +-ifeq ($(PORTNAME), cygwin) +-ifeq ($(MAKE_DLL), true) +- $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a' +-endif +-endif +-ifeq ($(PORTNAME), win32) +-ifeq ($(MAKE_DLL), true) +- $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a' +-endif +-endif +- $(MAKE) -C catalog install-data +- $(MAKE) -C tsearch install-data +- $(INSTALL_DATA) $(srcdir)/libpq/pg_hba.conf.sample '$(DESTDIR)$(datadir)/pg_hba.conf.sample' +- $(INSTALL_DATA) $(srcdir)/libpq/pg_ident.conf.sample '$(DESTDIR)$(datadir)/pg_ident.conf.sample' +- $(INSTALL_DATA) $(srcdir)/utils/misc/postgresql.conf.sample '$(DESTDIR)$(datadir)/postgresql.conf.sample' +- $(INSTALL_DATA) $(srcdir)/access/transam/recovery.conf.sample '$(DESTDIR)$(datadir)/recovery.conf.sample' ++install: + + install-bin: postgres $(POSTGRES_IMP) installdirs + $(INSTALL_PROGRAM) postgres$(X) '$(DESTDIR)$(bindir)/postgres$(X)' +diff -Naruw a/src/bin/Makefile b/src/bin/Makefile +--- a/src/bin/Makefile 2016-10-24 16:12:53.000000000 -0400 ++++ b/src/bin/Makefile 2016-10-27 13:41:34.443930143 -0400 +@@ -13,8 +13,7 @@ + top_builddir = ../.. + include $(top_builddir)/src/Makefile.global + +-SUBDIRS = initdb pg_ctl pg_dump \ +- psql scripts pg_config pg_controldata pg_resetxlog pg_basebackup ++SUBDIRS = pg_dump psql scripts pg_config + + ifeq ($(PORTNAME), win32) + SUBDIRS += pgevent +diff -Naruw a/src/Makefile b/src/Makefile +--- a/src/Makefile 2016-10-24 16:12:53.000000000 -0400 ++++ b/src/Makefile 2016-10-27 13:43:09.296792018 -0400 +@@ -15,18 +15,11 @@ + SUBDIRS = \ + common \ + port \ +- timezone \ + backend \ +- backend/utils/mb/conversion_procs \ +- backend/snowball \ + include \ + interfaces \ +- backend/replication/libpqwalreceiver \ + bin \ +- pl \ +- makefiles \ +- test/regress \ +- test/perl ++ makefiles + + # There are too many interdependencies between the subdirectories, so + # don't attempt parallel make here. diff --git a/dev-db/postgresql/files/postgresql-check-db-dir b/dev-db/postgresql/files/postgresql-check-db-dir new file mode 100644 index 0000000..7f89919 --- /dev/null +++ b/dev-db/postgresql/files/postgresql-check-db-dir @@ -0,0 +1,35 @@ +#!/bin/sh +# Copyright 1999-2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +eerror() { + echo "$@" >&2 +} + +# Check that DATA_DIR has been set +if [ -z ${DATA_DIR} ] ; then + eerror "DATA_DIR not set" + exit 1 +fi + +# Check that DATA_DIR exists +if [ ! -d ${DATA_DIR} ] ; then + eerror "Directory not found: ${DATA_DIR}" + eerror "HINT: Ensure that DATA_DIR points to the right path." + eerror "HINT: Or perhaps you need to create the database cluster:" + eerror " emerge --config dev-db/postgresql:@SLOT@" + exit 1 +fi + +# Check for the existence of PostgreSQL's config files, and set the +# proper mode and ownership. +# Only three files should be checked as potentially other files +# may be in PGDATA that should not be touched. +for file in postgresql pg_hba pg_ident ; do + file="${PGDATA%/}/${file}.conf" + if [ ! -f ${file} ] ; then + eerror "${file} not found" + eerror "HINT: mv ${DATA_DIR%/}/*.conf ${PGDATA}" + exit 1 + fi +done diff --git a/dev-db/postgresql/files/postgresql.confd b/dev-db/postgresql/files/postgresql.confd new file mode 100644 index 0000000..07b465d --- /dev/null +++ b/dev-db/postgresql/files/postgresql.confd @@ -0,0 +1,58 @@ +# 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. +# +# `emerge --config dev-db/postgresql:@SLOT@' uses these values to +# determine where to create the data directory, where to place the +# configuration files, and any additional options to pass to initdb. +# +# The initscript also uses these variables to inform PostgreSQL where to find +# its data directory and configuration files. +# +############################################################################## + +# Location of configuration files +PGDATA="/etc/postgresql-@SLOT@/" + +# Where the data directory is located/to be created +DATA_DIR="/var/lib/postgresql/@SLOT@/data" + +# Additional options to pass to initdb. +# See `man initdb' for available options. +PG_INITDB_OPTS="--encoding=UTF8" diff --git a/dev-db/postgresql/files/postgresql.init b/dev-db/postgresql/files/postgresql.init new file mode 100644 index 0000000..35dd316 --- /dev/null +++ b/dev-db/postgresql/files/postgresql.init @@ -0,0 +1,137 @@ +#!/sbin/openrc-run +# Copyright 1999-2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +extra_started_commands="reload" + +get_config() { + [ -f ${PGDATA%/}/postgresql.conf ] || return 1 + + eval echo $(sed -e 's:#.*::' ${PGDATA%/}/postgresql.conf \ + | awk '$1 == "'$1'" { print ($2 == "=" ? $3 : $2) }') +} + +depend() { + use net + provide postgresql + + if [ "$(get_config log_destination)" = "syslog" ]; then + use logger + fi +} + +configured_port=$(get_config port) +: ${configured_port:=${PGPORT}} +socket_path=$(get_config unix_socket_directory) +: ${socket_path:=/run/postgresql} + +checkconfig() { + # Check that DATA_DIR has been set + if [ -z ${DATA_DIR} ] ; then + eerror "DATA_DIR not set" + eerror "HINT: Perhaps you need to update /etc/conf.d/postgresql-@SLOT@" + return 1 + fi + + # Check that DATA_DIR exists + if [ ! -d ${DATA_DIR} ] ; then + eerror "Directory not found: ${DATA_DIR}" + eerror "HINT: Ensure that DATA_DIR points to the right path." + eerror "HINT: Or perhaps you need to create the database cluster:" + eerror " emerge --config dev-db/postgresql:@SLOT@" + return 1 + fi + + # Check for the existence of PostgreSQL's config files, and set the + # proper mode and ownership. + # Only three files should be checked as potentially other files + # may be in PGDATA that should not be touched. + local file + for file in postgresql pg_hba pg_ident ; do + file="${PGDATA%/}/${file}.conf" + if [ -f ${file} ] ; then + checkpath -f -m 0600 -o postgres:postgres ${file} + else + eerror "${file} not found" + eerror "HINT: mv ${DATA_DIR%/}/*.conf ${PGDATA}" + return 1 + fi + done + + # Set the proper permission for the socket path and create it if + # it doesn't exist. + checkpath -d -m 1775 -o postgres:postgres ${socket_path} + if [ -e ${socket_path%/}/.s.PGSQL.${configured_port} ] ; then + eerror "Socket conflict." + eerror "A server is already listening on:" + eerror " ${socket_path%/}/.s.PGSQL.${configured_port}" + eerror "HINT: Change PGPORT to listen on a different socket." + return 1 + fi +} + +start() { + checkconfig || return 1 + + ebegin "Starting PostgreSQL" + + rm -f ${DATA_DIR%/}/postmaster.pid + + local extraenv + local x + for x in ${PG_EXTRA_ENV} ; do + extraenv="${extraenv} --env ${x}" + done + + start-stop-daemon --start \ + --user postgres \ + --env "PGPORT=${configured_port}" \ + ${extraenv} \ + --pidfile ${DATA_DIR%/}/postmaster.pid \ + --exec /usr/@LIBDIR@/postgresql-@SLOT@/bin/pg_ctl \ + -- start -s -w -t ${START_TIMEOUT} -l ${DATA_DIR%/}/postmaster.log \ + -D ${PGDATA} -o "--data-directory=${DATA_DIR} ${PGOPTS}" + local retval=$? + + if [ $retval -ne 0 ] ; then + eerror "Check the log for a possible explanation of the above error. The log may be" + eerror " ${DATA_DIR%/}/postmaster.log" + eerror "Or wherever you configured PostgreSQL @SLOT@ log messages to be sent." + eend $retval + return $retval + fi + + eend $retval +} + +stop() { + local seconds=$(( ${NICE_TIMEOUT} + ${RUDE_TIMEOUT} + ${FORCE_TIMEOUT} )) + ebegin "Stopping PostgreSQL (this can take up to ${seconds} seconds)" + + local retval + local retries=SIGTERM/${NICE_TIMEOUT} + + if [ "${RUDE_QUIT}" != "NO" ] ; then + einfo "RUDE_QUIT enabled." + retries="${retries}/SIGINT/${RUDE_TIMEOUT}" + fi + if [ "${FORCE_QUIT}" = "YES" ] ; then + einfo "FORCE_QUIT enabled." + ewarn "A recover-run might be executed on next startup." + retries="${retries}/SIGQUIT/${FORCE_TIMEOUT}" + fi + + # Loops through nice, rude, and force quit in one go. + start-stop-daemon --stop \ + --exec /usr/@LIBDIR@/postgresql-@SLOT@/bin/postgres \ + --retry ${retries} \ + --pidfile ${DATA_DIR%/}/postmaster.pid + + eend +} + +reload() { + ebegin "Reloading PostgreSQL configuration" + kill -HUP $(head -n1 ${DATA_DIR%/}/postmaster.pid) + eend $? +} diff --git a/dev-db/postgresql/files/postgresql.service b/dev-db/postgresql/files/postgresql.service new file mode 100644 index 0000000..a607169 --- /dev/null +++ b/dev-db/postgresql/files/postgresql.service @@ -0,0 +1,55 @@ +# It's not recommended to modify this file in-place, because it will be +# overwritten during package upgrades. If you want to customize, the +# best way is to create file +# "/etc/systemd/system/postgresql-@SLOT@.service.d/*.conf" +# containing your changes + +# For example, if you want to change the server's port number to 5433, +# create a file named +# "/etc/systemd/system/postgresql-@SLOT@.service.d/port.conf" +# containing: +# [Service] +# Environment=PGPORT=5433 +# This will override the setting appearing below. + +[Unit] +Description=PostgreSQL database server +After=network.target + +[Service] +Type=forking + +User=postgres +Group=postgres + +# Port number for server to listen on +Environment=PGPORT=5432 + +# Location of configuration files +Environment=PGDATA=/etc/postgresql-@SLOT@ + +# Where the data directory is located +Environment=DATA_DIR=/var/lib/postgresql/@SLOT@/data + +# Where to send early-startup messages from the server (before the logging +# options of postgresql.conf take effect) +# This is normally controlled by the global default set by systemd +# StandardOutput=syslog + +ExecStartPre=/usr/bin/postgresql-@SLOT@-check-db-dir +ExecStart=/usr/@LIBDIR@/postgresql-@SLOT@/bin/pg_ctl start -D ${DATA_DIR} -s -l ${DATA_DIR}/postmaster.log -o "-p ${PGPORT} -D ${PGDATA} --data-directory=${DATA_DIR}" -w -t 300 +ExecStop=/usr/@LIBDIR@/postgresql-@SLOT@/bin/pg_ctl stop -D ${DATA_DIR} -s -m fast +ExecReload=/usr/@LIBDIR@/postgresql-@SLOT@/bin/pg_ctl reload -D ${DATA_DIR} -s + +# Give a reasonable amount of time for the server to start up/shut down +TimeoutSec=300 + +# Disable OOM kill on the postmaster +OOMScoreAdjust=-1000 + +# Make sure the required runtimedir is present +RuntimeDirectory=postgresql +RuntimeDirectoryMode=1775 + +[Install] +WantedBy=multi-user.target diff --git a/dev-db/postgresql/metadata.xml b/dev-db/postgresql/metadata.xml new file mode 100644 index 0000000..c02f777 --- /dev/null +++ b/dev-db/postgresql/metadata.xml @@ -0,0 +1,21 @@ + + + + + pgsql-bugs@gentoo.org + PostgreSQL and Related Package Development + + + + Use double precision floating-point numbers instead of 64-bit + integers for timestamp storage. + + + Disable to build and install the clients and libraries only. + + + Enable server side UUID generation (via + dev-libs/ossp-uuid). + + + diff --git a/dev-db/postgresql/postgresql-9.4.12-r2.ebuild b/dev-db/postgresql/postgresql-9.4.12-r2.ebuild new file mode 100644 index 0000000..b37bed3 --- /dev/null +++ b/dev-db/postgresql/postgresql-9.4.12-r2.ebuild @@ -0,0 +1,477 @@ +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +EAPI="5" + +PYTHON_COMPAT=( python2_7 python3_{4,5,6} ) + +inherit eutils flag-o-matic linux-info multilib pam prefix python-single-r1 \ + systemd user versionator + +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-macos ~x86-solaris" + +SLOT="$(get_version_component_range 1-2)" + +SRC_URI="mirror://postgresql/source/v${PV}/postgresql-${PV}.tar.bz2" + +LICENSE="POSTGRESQL GPL-2" +DESCRIPTION="PostgreSQL RDBMS" +HOMEPAGE="http://www.postgresql.org/" + +LINGUAS="af cs de en es fa fr hr hu it ko nb pl pt_BR ro ru sk sl sv tr + zh_CN zh_TW" +IUSE="doc kerberos kernel_linux ldap libressl nls pam perl -pg_legacytimestamp python + +readline selinux +server ssl static-libs tcl threads uuid valgrind xml zlib" + +for lingua in ${LINGUAS}; do + IUSE+=" linguas_${lingua}" +done +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" + +wanted_languages() { + local enable_langs + + for lingua in ${LINGUAS} ; do + use linguas_${lingua} && enable_langs+="${lingua} " + done + + echo -n ${enable_langs} +} + +CDEPEND=" +>=app-eselect/eselect-postgresql-2.0 +sys-apps/less +virtual/libintl +kerberos? ( virtual/krb5 ) +ldap? ( net-nds/openldap ) +pam? ( virtual/pam ) +perl? ( >=dev-lang/perl-5.8:= ) +python? ( ${PYTHON_DEPS} ) +readline? ( sys-libs/readline:0= ) +ssl? ( + !libressl? ( >=dev-libs/openssl-0.9.6-r1:0= ) + libressl? ( dev-libs/libressl:= ) +) +tcl? ( >=dev-lang/tcl-8:0= ) +xml? ( dev-libs/libxml2 dev-libs/libxslt ) +zlib? ( sys-libs/zlib ) +" + +# uuid flags -- depend on sys-apps/util-linux for Linux libcs, or if no +# supported libc in use depend on dev-libs/ossp-uuid. For BSD systems, +# the libc includes UUID functions. +UTIL_LINUX_LIBC=( elibc_{glibc,uclibc,musl} ) +BSD_LIBC=( elibc_{Free,Net,Open}BSD ) + +nest_usedep() { + local front back + while [[ ${#} -gt 1 ]]; do + front+="${1}? ( " + back+=" )" + shift + done + echo "${front}${1}${back}" +} + +IUSE+=" ${UTIL_LINUX_LIBC[@]} ${BSD_LIBC[@]}" +CDEPEND+=" +uuid? ( + ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )} + $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} ${BSD_LIBC[@]/#/!} dev-libs/ossp-uuid) +)" + +DEPEND="${CDEPEND} +!! /dev/null; then + canonicalise=realpath + elif type -p readlink > /dev/null; then + canonicalise='readlink -f' + else + # can't die, subshell + die "No readlink nor realpath found, cannot canonicalise" + fi + + local l + # First remove any symlinks in /usr/bin that may have been created + # by the old eselect + for l in $(find "${ROOT%/}/usr/bin" -mindepth 1 -maxdepth 1 -type l) ; do + if [[ $(${canonicalise} "${l}") == *postgresql-${SLOT}* ]] ; then + rm "${l}" || ewarn "Couldn't remove ${l}" + fi + done + + # Then move the symlinks created by the ebuild to their proper place. + for l in "${ED}"/usr/bin/*tmp ; do + mv "${l}" "${l%tmp}" \ + || ewarn "Couldn't rename $(basename ${l}) to $(basename ${l%tmp})" + done +} + +pkg_postinst() { + postgresql-config update + + elog "If you need a global psqlrc-file, you can place it in:" + elog " ${EROOT%/}/etc/postgresql-${SLOT}/" + + if use server ; then + elog + elog "Gentoo specific documentation:" + elog "https://wiki.gentoo.org/wiki/PostgreSQL" + elog + elog "Official documentation:" + elog "http://www.postgresql.org/docs/${SLOT}/static/index.html" + elog + elog "The default location of the Unix-domain socket is:" + elog " ${EROOT%/}/run/postgresql/" + elog + elog "Before initializing the database, you may want to edit PG_INITDB_OPTS" + elog "so that it contains your preferred locale in:" + elog " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}" + elog + elog "Then, execute the following command to setup the initial database" + elog "environment:" + elog " emerge --config =${CATEGORY}/${PF}" + fi +} + +pkg_prerm() { + if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then + ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?" + ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL" + + ebegin "Resuming removal in 10 seconds (Control-C to cancel)" + sleep 10 + eend 0 + fi +} + +pkg_postrm() { + postgresql-config update +} + +pkg_config() { + use server || die "USE flag 'server' not enabled. Nothing to configure." + + [[ -f "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" ]] \ + && source "${EROOT%/}/etc/conf.d/postgresql-${SLOT}" + [[ -z "${PGDATA}" ]] && PGDATA="${EROOT%/}/etc/postgresql-${SLOT}/" + [[ -z "${DATA_DIR}" ]] \ + && DATA_DIR="${EROOT%/}/var/lib/postgresql/${SLOT}/data" + + # environment.bz2 may not contain the same locale as the current system + # locale. Unset and source from the current system locale. + if [ -f "${EROOT%/}/etc/env.d/02locale" ]; then + unset LANG + unset LC_CTYPE + unset LC_NUMERIC + unset LC_TIME + unset LC_COLLATE + unset LC_MONETARY + unset LC_MESSAGES + unset LC_ALL + source "${EROOT%/}/etc/env.d/02locale" + [ -n "${LANG}" ] && export LANG + [ -n "${LC_CTYPE}" ] && export LC_CTYPE + [ -n "${LC_NUMERIC}" ] && export LC_NUMERIC + [ -n "${LC_TIME}" ] && export LC_TIME + [ -n "${LC_COLLATE}" ] && export LC_COLLATE + [ -n "${LC_MONETARY}" ] && export LC_MONETARY + [ -n "${LC_MESSAGES}" ] && export LC_MESSAGES + [ -n "${LC_ALL}" ] && export LC_ALL + fi + + einfo "You can modify the paths and options passed to initdb by editing:" + einfo " ${EROOT%/}/etc/conf.d/postgresql-${SLOT}" + einfo + einfo "Information on options that can be passed to initdb are found at:" + einfo " http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html" + einfo " http://www.postgresql.org/docs/${SLOT}/static/app-initdb.html" + einfo + einfo "PG_INITDB_OPTS is currently set to:" + if [[ -z "${PG_INITDB_OPTS}" ]] ; then + einfo " (none)" + else + einfo " ${PG_INITDB_OPTS}" + fi + einfo + einfo "Configuration files will be installed to:" + einfo " ${PGDATA}" + einfo + einfo "The database cluster will be created in:" + einfo " ${DATA_DIR}" + einfo + + ebegin "Continuing initialization in 5 seconds (Control-C to cancel)" + sleep 5 + eend 0 + + if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then + eerror "The given directory, '${DATA_DIR}', is not empty." + eerror "Modify DATA_DIR to point to an empty directory." + die "${DATA_DIR} is not empty." + fi + + einfo "Creating the data directory ..." + if [[ ${EUID} == 0 ]] ; then + mkdir -p "${DATA_DIR}" + chown -Rf postgres:postgres "${DATA_DIR}" + chmod 0700 "${DATA_DIR}" + fi + + einfo "Initializing the database ..." + + if [[ ${EUID} == 0 ]] ; then + su postgres -c "${EROOT%/}/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -D \"${DATA_DIR}\" ${PG_INITDB_OPTS}" + else + "${EROOT%/}"/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb -U postgres -D "${DATA_DIR}" ${PG_INITDB_OPTS} + fi + + if [[ "${DATA_DIR%/}" != "${PGDATA%/}" ]] ; then + mv "${DATA_DIR%/}"/{pg_{hba,ident},postgresql}.conf "${PGDATA}" + ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}" + fi + + # unix_socket_directory has no effect in postgresql.conf as it's + # overridden in the initscript + sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf + + cat <<- EOF >> "${PGDATA%/}"/postgresql.conf + # This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522 + # On the off-chance that you might need to work with UTF-8 encoded + # characters in PL/Perl + plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";' + EOF + + einfo "The autovacuum function, which was in contrib, has been moved to the main" + einfo "PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled" + einfo "by default. You can disable it in the cluster's:" + einfo " ${PGDATA%/}/postgresql.conf" + einfo + einfo "The PostgreSQL server, by default, will log events to:" + einfo " ${DATA_DIR%/}/postmaster.log" + einfo + if use prefix ; then + einfo "The location of the configuration files have moved to:" + einfo " ${PGDATA}" + einfo "To start the server:" + einfo " pg_ctl start -D ${DATA_DIR} -o '-D ${PGDATA} --data-directory=${DATA_DIR}'" + einfo "To stop:" + einfo " pg_ctl stop -D ${DATA_DIR}" + einfo + einfo "Or move the configuration files back:" + einfo "mv ${PGDATA}*.conf ${DATA_DIR}" + else + einfo "You should use the '${EROOT%/}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL" + einfo "instead of 'pg_ctl'." + fi +} + +src_test() { + if use server && [[ ${UID} -ne 0 ]] ; then + emake check + + einfo "If you think other tests besides the regression tests are necessary, please" + einfo "submit a bug including a patch for this ebuild to enable them." + else + use server || \ + ewarn 'Tests cannot be run without the "server" use flag enabled.' + [[ ${UID} -eq 0 ]] || \ + ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.' + + ewarn 'Skipping.' + fi +} -- cgit v1.2.3-65-gdbad