From 401101f9c8077911929d3f2b60a37098460a5d89 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Thu, 24 Mar 2022 23:59:54 +0000 Subject: gentoo resync : 25.03.2022 --- dev-db/Manifest.gz | Bin 16129 -> 16130 bytes dev-db/mysql-super-smack/Manifest | 4 +- .../files/mysql-super-smack-1.3-autotools.patch | 255 ++++ dev-db/mysql-super-smack/metadata.xml | 12 +- .../mysql-super-smack-1.3-r5.ebuild | 70 ++ dev-db/mysql-workbench/Manifest | 2 +- .../mysql-workbench/mysql-workbench-8.0.27.ebuild | 4 +- dev-db/percona-server/Manifest | 4 +- .../percona-server-8.0.25.15-r1.ebuild | 1274 +++++++++++++++++++ .../percona-server/percona-server-8.0.25.15.ebuild | 1273 ------------------- .../percona-server-8.0.26.16-r1.ebuild | 1276 ++++++++++++++++++++ .../percona-server/percona-server-8.0.26.16.ebuild | 1275 ------------------- dev-db/pgtap/Manifest | 2 +- dev-db/pgtap/pgtap-1.2.0-r1.ebuild | 38 - dev-db/pgtap/pgtap-1.2.0-r2.ebuild | 38 + dev-db/postgresql/Manifest | 25 +- dev-db/postgresql/files/postgres-llvm14.patch | 154 +++ dev-db/postgresql/postgresql-10.19-r1.ebuild | 453 +++++++ dev-db/postgresql/postgresql-10.19.ebuild | 453 ------- dev-db/postgresql/postgresql-10.20-r1.ebuild | 453 +++++++ dev-db/postgresql/postgresql-10.20.ebuild | 453 ------- dev-db/postgresql/postgresql-11.14-r1.ebuild | 453 +++++++ dev-db/postgresql/postgresql-11.14.ebuild | 450 ------- dev-db/postgresql/postgresql-11.15-r1.ebuild | 453 +++++++ dev-db/postgresql/postgresql-11.15.ebuild | 450 ------- dev-db/postgresql/postgresql-12.10-r1.ebuild | 454 +++++++ dev-db/postgresql/postgresql-12.10.ebuild | 450 ------- dev-db/postgresql/postgresql-12.9-r1.ebuild | 454 +++++++ dev-db/postgresql/postgresql-12.9.ebuild | 450 ------- dev-db/postgresql/postgresql-13.5-r1.ebuild | 466 +++++++ dev-db/postgresql/postgresql-13.5.ebuild | 462 ------- dev-db/postgresql/postgresql-13.6-r2.ebuild | 466 +++++++ dev-db/postgresql/postgresql-13.6.ebuild | 462 ------- dev-db/postgresql/postgresql-14.1-r1.ebuild | 466 +++++++ dev-db/postgresql/postgresql-14.1.ebuild | 462 ------- dev-db/postgresql/postgresql-14.2-r1.ebuild | 463 +++++++ dev-db/postgresql/postgresql-14.2.ebuild | 462 ------- dev-db/postgresql/postgresql-9.6.24-r1.ebuild | 474 ++++++++ dev-db/postgresql/postgresql-9.6.24.ebuild | 474 -------- dev-db/postgresql/postgresql-9999.ebuild | 2 +- 40 files changed, 8152 insertions(+), 7639 deletions(-) create mode 100644 dev-db/mysql-super-smack/files/mysql-super-smack-1.3-autotools.patch create mode 100644 dev-db/mysql-super-smack/mysql-super-smack-1.3-r5.ebuild create mode 100644 dev-db/percona-server/percona-server-8.0.25.15-r1.ebuild delete mode 100644 dev-db/percona-server/percona-server-8.0.25.15.ebuild create mode 100644 dev-db/percona-server/percona-server-8.0.26.16-r1.ebuild delete mode 100644 dev-db/percona-server/percona-server-8.0.26.16.ebuild delete mode 100644 dev-db/pgtap/pgtap-1.2.0-r1.ebuild create mode 100644 dev-db/pgtap/pgtap-1.2.0-r2.ebuild create mode 100644 dev-db/postgresql/files/postgres-llvm14.patch create mode 100644 dev-db/postgresql/postgresql-10.19-r1.ebuild delete mode 100644 dev-db/postgresql/postgresql-10.19.ebuild create mode 100644 dev-db/postgresql/postgresql-10.20-r1.ebuild delete mode 100644 dev-db/postgresql/postgresql-10.20.ebuild create mode 100644 dev-db/postgresql/postgresql-11.14-r1.ebuild delete mode 100644 dev-db/postgresql/postgresql-11.14.ebuild create mode 100644 dev-db/postgresql/postgresql-11.15-r1.ebuild delete mode 100644 dev-db/postgresql/postgresql-11.15.ebuild create mode 100644 dev-db/postgresql/postgresql-12.10-r1.ebuild delete mode 100644 dev-db/postgresql/postgresql-12.10.ebuild create mode 100644 dev-db/postgresql/postgresql-12.9-r1.ebuild delete mode 100644 dev-db/postgresql/postgresql-12.9.ebuild create mode 100644 dev-db/postgresql/postgresql-13.5-r1.ebuild delete mode 100644 dev-db/postgresql/postgresql-13.5.ebuild create mode 100644 dev-db/postgresql/postgresql-13.6-r2.ebuild delete mode 100644 dev-db/postgresql/postgresql-13.6.ebuild create mode 100644 dev-db/postgresql/postgresql-14.1-r1.ebuild delete mode 100644 dev-db/postgresql/postgresql-14.1.ebuild create mode 100644 dev-db/postgresql/postgresql-14.2-r1.ebuild delete mode 100644 dev-db/postgresql/postgresql-14.2.ebuild create mode 100644 dev-db/postgresql/postgresql-9.6.24-r1.ebuild delete mode 100644 dev-db/postgresql/postgresql-9.6.24.ebuild (limited to 'dev-db') diff --git a/dev-db/Manifest.gz b/dev-db/Manifest.gz index 18d955c76b9f..20e3a917f172 100644 Binary files a/dev-db/Manifest.gz and b/dev-db/Manifest.gz differ diff --git a/dev-db/mysql-super-smack/Manifest b/dev-db/mysql-super-smack/Manifest index 3640a6687222..4cec062c2b3a 100644 --- a/dev-db/mysql-super-smack/Manifest +++ b/dev-db/mysql-super-smack/Manifest @@ -1,8 +1,10 @@ AUX mysql-super-smack-1.2.destdir.patch 420 BLAKE2B be3b49d142a32f6ed00edbd6085d20f202f1d3061ad2e1463f2ea7be434ae1114bd9b776a03840ae9e4baff209b43a25b089a0e3863181273146e462dfcb3e7c SHA512 9319fb29af0e91bedc969a0c5f02bcac386274aa179af7ef3130b18ac9bfa36a0a422a76e50abb777323cac242283c1b680051689a6269ab7e567b5ae53a216b AUX mysql-super-smack-1.3-automake-1.13.patch 7680 BLAKE2B 99a28b7c857575b8e824d0e3f5ae87668a47e1e234315ad3657c5e388051164bcc03cadc9f80d9eac82f2b4f79864a595944a2ec896885b52044264ca3529755 SHA512 b74994f03b136c7642423ee5eb1346134ed127a9ca0996df83ed777f49f9dff3efe93889bc3a375868afec38be20303ffbede98dcfd3b6ec5921f0e417b5a000 +AUX mysql-super-smack-1.3-autotools.patch 6988 BLAKE2B aaf6d8cedd4a01f2f11cd80b953ea6787fa2e218ee452b009e49c1e16b05f3548072f0e65a6eed6effbcb29c65f8d576181b30e7f503242f4b0d835e79020be1 SHA512 9aa29299b945b84e6979c0c9f0184c7e0ffafdcb63ead926b05a11c3f12f6e88b1bd3157e24c6623da26bc5d5d2a5eeb20c0870286db2b4708981c9b3a27c8d3 AUX mysql-super-smack-1.3-gen-data.patch 2265 BLAKE2B 42f85a5779968d13262ddf3b726d4522912bc29c4d81fce41fe61caeab85c7fa93be5c3497dc21a0acabc67e59446cc941deb6fb98ac2154cf7f84214b500ff6 SHA512 6a08a3ccc158e7c8e0500a8d3231d0b1fc0d0f4a41e2a5bf40426e480c6fc373b0fa7ff5c08b5d40afe559a34b97fd00412c43fe9212047f2c4d063b98ac2154 AUX mysql-super-smack-1.3.amd64.patch 702 BLAKE2B e986f6c487d05c9de0ee3f3a397a2c63d21c05209efc48e8fa173975b88839baa6100150d0cdd6df42b7435cc8a411b5235cf92a586850ae3d57cb564a8b95a8 SHA512 5ac9c130534d5cea6caa70f6373850181ae81c68c1eb3cb9e7a774bdeeafdf822582fe9cb548b9eb1268a2b4edc516461b95238454abefcdd25677066d720da9 AUX mysql-super-smack-1.3.gcc4.3.patch 241 BLAKE2B 5f7dae8deb353e6129cedc5a085b933928caf3731b3ad673a56366886ece5cd8b60fdc78657bc3b0925dd171fbeba7e6df24261524efbc6f40ef9b473a11cf9f SHA512 500d8e7ee919b5359b14d22a2e9d26c0ed8cd0936376cd5179be3a92f99c753dd4b3a6cdee417468721a60aa727e09763aff64ce055e43c7ccd52b4937aaff30 DIST super-smack-1.3.tar.gz 155375 BLAKE2B aabcd6ab6c7da0e847c734bd57b7228a0c37f41aac789e63a8285b5a0fb43360101728ff6a2dc84b63cf9c0b5361770aa909382f9e2f50abdc2ea1e8407f835b SHA512 5343fa78bdf483c1019c9e25d1fdb15581342d49b863a536eb1cf8c38bde5641fdf135fe5a8ec87f74051fd9766b2f5e4f09f963afe2eb1cd7ea41edfa260920 EBUILD mysql-super-smack-1.3-r4.ebuild 1654 BLAKE2B 3650bff6eae5f0e512f9971b6b8ce99c16fdf8068aba0c83d8de264e1561c319ac7f433741fb5b08d31569ec16615d6b58c2d73685dcd814b9db3d636f26ac68 SHA512 f5b78b4d4a81d6d6b7bf75d05bdb555f4ec59ecf594cb5706f11c2ae24f8760c43d87c43c9b18e4f8bbf08de0b08f629ce81fa95567030952f356ab5306730ed -MISC metadata.xml 319 BLAKE2B 101e797ba4616414281cfd6869070b696b224aabfa5fdc6215f6d4597133a67b9db84d3f246cad312dc4c3b4323a921f8887df4abe7993e32c14cf6912614499 SHA512 6585f781b8d569fd1bb926dc0cbd4350b5a6e2cb0640c2523ed3483276c8d4b411ddeff7f7f3e9a4363551a3a8910a5e32bb075f25c545275c83ce92a90c49dc +EBUILD mysql-super-smack-1.3-r5.ebuild 1533 BLAKE2B a38d6249753a8b8027465b0d960616a6729d3680d198a6e7f8d8d6d606655242137db2b428421ef48de0d7d32007800e296549929627e207ff8cdd8e2c84944f SHA512 edd555b3037c6019a75c29dde46c0215d1ad65d23646c3e180f37669166cce3cca8e5765ada984686fff52027cc7308d42b739e42a6c82a6693ee5b3fc01c00c +MISC metadata.xml 323 BLAKE2B 9b0447d87c9b774dd35df6f600a65277fa0ff42abaae9abcbdf8cfef461feba9b1d333699d5a210799ee1f5408e1fe7e47faababa5ff63ebcb5833ac68349964 SHA512 d0c11eddb2bd8b7c1d8dc0b30cf6d5f9bf990e5f2846caae2960f973ca9896f5c37049ba1dd95397347fe02c4b8a1a167c88b71f19ff3ee9c27b2ff6d587aa40 diff --git a/dev-db/mysql-super-smack/files/mysql-super-smack-1.3-autotools.patch b/dev-db/mysql-super-smack/files/mysql-super-smack-1.3-autotools.patch new file mode 100644 index 000000000000..97e1e1aaccc6 --- /dev/null +++ b/dev-db/mysql-super-smack/files/mysql-super-smack-1.3-autotools.patch @@ -0,0 +1,255 @@ +--- a/configure.in ++++ b/configure.in +@@ -16,9 +16,9 @@ + + # Process this file with autoconf to produce a configure script. + +-AC_INIT() ++AC_INIT([super-smack], [1.1]) + AM_CONFIG_HEADER(config.h) +-AM_INIT_AUTOMAKE(super-smack, 1.1) ++AM_INIT_AUTOMAKE + AC_DEFINE_UNQUOTED(VERSION, "$VERSION") + + # Checks for programs. +@@ -31,6 +31,14 @@ + AM_PROG_LEX + AC_PROG_YACC + ++AH_TEMPLATE([HAVE_CRYPT], [Define if we have a crypt()]) ++AH_TEMPLATE([HAVE_MYSQL], [MySQL Support]) ++AH_TEMPLATE([HAVE_ORACLE], [PostgreSQL Support]) ++AH_TEMPLATE([HAVE_PGSQL], [Oracle Support]) ++AH_TEMPLATE([SMACK_DATADIR], [Sample .smack data files]) ++ ++AC_CONFIG_MACRO_DIRS([m4]) ++ + # get super-smack datadir + AC_ARG_WITH(datadir, + [ --with-datadir=DIR Specify default smack datadir], +diff -aurwN a/m4/crypt.m4 b/m4/crypt.m4 +--- a/m4/crypt.m4 ++++ b/m4/crypt.m4 +@@ -0,0 +1,5 @@ ++AC_DEFUN([AC_FUNC_CRYPT], [ ++ AC_CHECK_LIB(crypt, crypt) ++ AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT)) ++]) ++ +diff -aruwN a/m4/lex.m4 b/m4/lex.m4 +--- a/m4/lex.m4 ++++ b/m4/lex.m4 +@@ -0,0 +1,6 @@ ++AC_DEFUN([AM_PROG_LEX], ++[missing_dir=ifelse([$1],,`cd $ac_aux_dir && pwd`,$1) ++AC_CHECK_PROGS(LEX, flex lex, "$missing_dir/missing flex") ++AC_PROG_LEX ++AC_DECL_YYTEXT]) ++ +diff -aurwN a/m4/libz.m4 b/m4/libz.m4 +--- a/m4/libz.m4 ++++ b/m4/libz.m4 +@@ -0,0 +1,4 @@ ++AC_DEFUN([AC_LIB_Z], [ ++ AC_CHECK_LIB(z, compress) ++]) ++ +diff -aurwN a/m4/mysql.m4 b/m4/mysql.m4 +--- a/m4/mysql.m4 ++++ b/m4/mysql.m4 +@@ -0,0 +1,76 @@ ++#serial 1 ++AC_DEFUN([AC_LIB_MYSQL], [ ++ AC_ARG_WITH(mysql-lib, ++ [ --with-mysql-lib=DIR Look for MySQL client library in DIR], ++ mysql_lib=$withval, mysql_lib="") ++ ++ if test "x$want_mysql" = "xyes" ++ then ++ AC_MSG_CHECKING([for libmysqlclient]) ++ AC_MSG_RESULT() ++ ++ mysql_ok=no ++ ++ SAVE_LIBS=$LIBS ++ ++ mysql_lib="$mysql_lib /usr/lib /usr/lib/mysql \ ++ /usr/local/lib /usr/local/lib/mysql \ ++ /usr/local/mysql/lib" ++ ++ for dir in $mysql_lib; do ++ if test "x$mysql_found" != "xyes" ++ then ++ if test -f "$dir/libmysqlclient.so" ; ++ then ++ LIBS="-L$dir $SAVE_LIBS $LIBZ_LIB" ++ MYSQL_LIB="-L$dir -lmysqlclient $LIBZ_LIB" ++ AC_SUBST(MYSQL_LIB) ++ AC_CHECK_LIB(mysqlclient, mysql_real_connect, ++ mysql_ok=yes, mysql_ok=no) ++ fi ++ fi ++ done ++ ++ if test "x$mysql_ok" != "xyes" ++ then ++ AC_MSG_ERROR([Could not find libmysqlclient in '$mysql_lib']) ++ fi ++ fi ++]) ++ ++AC_DEFUN([AC_HEADER_MYSQL], [ ++ AC_ARG_WITH(mysql-include, ++ [ --with-mysql-include=DIR ++ Look for MySQL include files in DIR], ++ mysql_include=$withval, mysql_include="") ++ ++ if test "x$want_mysql" = "xyes" ++ then ++ AC_MSG_CHECKING([for mysql.h]) ++ AC_MSG_RESULT() ++ ++ mysql_found=no ++ ++ mysql_include="$mysql_include /usr/include /usr/include/mysql \ ++ /usr/local/include /usr/local/include/mysql \ ++ /usr/local/mysql/include" ++ ++ for dir in $mysql_include; do ++ if test "x$mysql_found" != "xyes" ++ then ++ if test -f "$dir/mysql.h" ++ then ++ MYSQL_INCLUDE="-I$dir" ++ AC_SUBST(MYSQL_INCLUDE) ++ mysql_found=yes ++ fi ++ fi ++ done ++ ++ if test "x$mysql_found" != "xyes" ++ then ++ AC_MSG_ERROR([Could not find mysql.h in '$mysql_include']) ++ fi ++ fi ++]) ++ +diff -aurwN a/m4/oracle.m4 b/m4/oracle.m4 +--- a/m4/oracle.m4 ++++ b/m4/oracle.m4 +@@ -0,0 +1,10 @@ ++AC_DEFUN([AC_LIB_ORACLE], [ ++ ORACLE_LIB="" ++ AC_SUBST(ORACLE_LIB) ++]) ++ ++AC_DEFUN([AC_HEADER_ORACLE], [ ++ ORACLE_INCLUDE="" ++ AC_SUBST(ORACLE_INCLUDE) ++]) ++ +diff -aurwN a/m4/postgresql.m4 b/m4/postgresql.m4 +--- a/m4/postgresql.m4 ++++ b/m4/postgresql.m4 +@@ -0,0 +1,75 @@ ++AC_DEFUN([AC_LIB_PGSQL], [ ++ AC_ARG_WITH(pgsql-lib, ++ [ --with-pgsql-lib=DIR Look for PostgreSQL client library in DIR], ++ pgsql_lib=$withval, pgsql_lib="") ++ ++ if test "x$want_pgsql" = "xyes" ++ then ++ AC_MSG_CHECKING([for libpq]) ++ AC_MSG_RESULT() ++ ++ pgsql_ok=no ++ ++ SAVE_LIBS=$LIBS ++ ++ pgsql_lib="$pgsql_lib /usr/lib /usr/lib/pgsql \ ++ /usr/local/lib /usr/local/lib/pgsql \ ++ /usr/local/pgsql/lib" ++ ++ for dir in $pgsql_lib; do ++ if test "x$pgsql_found" != "xyes" ++ then ++ if test -f "$dir/libpq.so" ++ then ++ LIBS="-L$dir $SAVE_LIBS" ++ PGSQL_LIB="-L$dir -lpq" ++ AC_SUBST(PGSQL_LIB) ++ AC_CHECK_LIB(pq, PQconnectdb, ++ pgsql_ok=yes, pgsql_ok=no) ++ fi ++ fi ++ done ++ ++ if test "x$pgsql_ok" != "xyes" ++ then ++ AC_MSG_ERROR([Could not find libpq in '$pgsql_lib']) ++ fi ++ fi ++]) ++ ++AC_DEFUN([AC_HEADER_PGSQL], [ ++ AC_ARG_WITH(pgsql-include, ++ [ --with-pgsql-include=DIR ++ Look for PostgreSQL include files in DIR], ++ pgsql_include=$withval, pgsql_include="") ++ ++ if test "x$want_pgsql" = "xyes" ++ then ++ AC_MSG_CHECKING([for libpq-fe.h]) ++ AC_MSG_RESULT() ++ ++ pgsql_found=no ++ ++ pgsql_include="$pgsql_include /usr/include /usr/include/pgsql \ ++ /usr/local/include /usr/local/include/pgsql \ ++ /usr/local/pgsql/include" ++ ++ for dir in $pgsql_include; do ++ if test "x$pgsql_found" != "xyes" ++ then ++ if test -f "$dir/libpq-fe.h" ++ then ++ PGSQL_INCLUDE="-I$dir" ++ AC_SUBST(PGSQL_INCLUDE) ++ pgsql_found=yes ++ fi ++ fi ++ done ++ ++ if test "x$pgsql_found" != "xyes" ++ then ++ AC_MSG_ERROR([Could not find libpq-fe.h in '$pgsql_include']) ++ fi ++ fi ++]) ++ +diff -aurwN a/src/Makefile.am b/src/Makefile.am +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -16,7 +16,8 @@ + + # Process this file with automake to create Makefile.in + +-INCLUDES = @MYSQL_INCLUDE@ @PGSQL_INCLUDE@ @ORACLE_INCLUDE@ ++AM_CPPFLAGS = @MYSQL_INCLUDE@ @PGSQL_INCLUDE@ @ORACLE_INCLUDE@ ++BUILT_SOURCES = super-smack-yacc.hh + + noinst_PROGRAMS=test-dictionary test-client test_tcp_client + bin_PROGRAMS=super-smack super-smack-gen-data +diff -aurN a/src/super-smack-lex.ll b/src/super-smack-lex.ll +--- a/src/super-smack-lex.ll ++++ b/src/super-smack-lex.ll +@@ -6,7 +6,7 @@ + #include + #include "query.h" + #include "parse.h" +- #include "super-smack-yacc.h" ++ #include "super-smack-yacc.hh" + + static string q_str = ""; + %} + diff --git a/dev-db/mysql-super-smack/metadata.xml b/dev-db/mysql-super-smack/metadata.xml index ee3ef09ebf87..80c2abfd5594 100644 --- a/dev-db/mysql-super-smack/metadata.xml +++ b/dev-db/mysql-super-smack/metadata.xml @@ -1,9 +1,11 @@ - robbat2@gentoo.org - -mysql-bugs@gentoo.org -MySQL - + + robbat2@gentoo.org + + + mysql-bugs@gentoo.org + MySQL + diff --git a/dev-db/mysql-super-smack/mysql-super-smack-1.3-r5.ebuild b/dev-db/mysql-super-smack/mysql-super-smack-1.3-r5.ebuild new file mode 100644 index 000000000000..e47e1a187676 --- /dev/null +++ b/dev-db/mysql-super-smack/mysql-super-smack-1.3-r5.ebuild @@ -0,0 +1,70 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit autotools flag-o-matic + +MY_P="super-smack-${PV}" + +DESCRIPTION="Benchmarking, stress testing, and load generation tool for MySQL & PostGreSQL" +HOMEPAGE="http://vegan.net/tony/supersmack/" +SRC_URI="mirror://gentoo/${MY_P}.tar.gz" +S="${WORKDIR}/${MY_P}" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~amd64 ~ppc ~x86" +IUSE="+mysql postgres" +REQUIRED_USE="|| ( mysql postgres )" + +DEPEND=" + sys-libs/zlib:= + mysql? ( dev-db/mysql-connector-c:= ) + postgres? ( dev-db/postgresql:*[server] )" +RDEPEND=" + ${DEPEND} + mysql? ( virtual/mysql )" +BDEPEND=" + sys-devel/bison + sys-devel/flex" + +PATCHES=( + "${FILESDIR}"/${PN}-1.2.destdir.patch + "${FILESDIR}"/${PN}-1.3.amd64.patch + "${FILESDIR}"/${PN}-1.3.gcc4.3.patch + "${FILESDIR}"/${PN}-1.3-gen-data.patch + "${FILESDIR}"/${PN}-1.3-autotools.patch +) + +src_prepare() { + default + # Clean up files so eautoreconf does not pick up any + # deprecated autotools macros. + rm acinclude.m4 aclocal.m4 acconfig.h config.status config.h || die + + eautoreconf +} + +src_configure() { + append-cxxflags -std=gnu++98 + + local myeconfargs=( + $(usev mysql --with-mysql) + $(usev postgres --with-pgsql) + --with-datadir="${EPREFIX}"/var/tmp/super-smack + --with-smacks-dir="${EPREFIX}"/usr/share/super-smack + ) + econf "${myeconfargs[@]}" +} + +src_install() { + default + dodoc MANUAL TUTORIAL + + keepdir /var/tmp/super-smack +} + +pkg_postinst() { + elog "The gen-data binary is now installed as super-smack-gen-data" +} diff --git a/dev-db/mysql-workbench/Manifest b/dev-db/mysql-workbench/Manifest index f294f92779d5..5c6f881355f6 100644 --- a/dev-db/mysql-workbench/Manifest +++ b/dev-db/mysql-workbench/Manifest @@ -4,5 +4,5 @@ DIST antlr-4.9.1-complete.jar 2100605 BLAKE2B 6fcdc184900cd30e42b3e1b6f56bcccbf1 DIST mysql-workbench-community-8.0.26-src.tar.gz 19282576 BLAKE2B 4b05d42a10ad3cc88d6447ff5ed1344ac8ef75564e2b69a55f603930f3ff75cd9ac00fd82b6b7339bdbf9524a593fadc32070c6cb5f77e9eeb6ad8e24cc59e7c SHA512 33b28b74b5c7d75c7b3c017cdebc48f3453d0aed2e8ebb20052e462479d0147e164d409e040ab8d1828c2209ad3bc41ab9684e91f86769bf7c1fa0ee117e888c DIST mysql-workbench-community-8.0.27-src.tar.gz 19282580 BLAKE2B 53069dbf26f1ba5975a9b28cf96cae660db8654dd60e5f7cdf112db48e7d4fd41beeb74a9ff870ae38b2d651de4ed7edffec32ba3eb8914bb329ff414ec7e7d4 SHA512 827d7abb8e04b0ec4a730eac163b4e2b62f5cde25d7326b4cb95b5f924b1e7c5bc87b1a8ca64dbab59232f4dd042b41cb1e53b97a9484549d0d6c2b7c8a14741 EBUILD mysql-workbench-8.0.26-r1.ebuild 2773 BLAKE2B 79bf4e4144cb9d7704c93290eca97185b78ecec676fef873644305c307ce22e63245e4460e0849db417114c64b9579c03e316fda9c06b74a8fd33ab981b2d1a2 SHA512 5483b9ce7bf2746957451710e89f19de915d2a82c437982d27c5c7d8d190c7050e906b130171830f49a08d7348ec1bcf5eb8bd77a1dc42a4d5f8fe0e370dca05 -EBUILD mysql-workbench-8.0.27.ebuild 2774 BLAKE2B 83c0cbe225d039d7bc8db06db454a304c250df7e1746c35040d4e082af94c428b2bc05d41ed85c8f6aec27818b3e5db292e1b7c812ef886ee98aa3813f5d0f82 SHA512 1d0729aae221c90da2284ba94e87780fe1126f060b39fea4a0327261db483f9a68b329cee0676eb5b477cad06bdbe11103800434fe0ceb5680bb834909611815 +EBUILD mysql-workbench-8.0.27.ebuild 2773 BLAKE2B 606596a3bccd80135395a6edf53bf2e645c10de8fd4af99465dc8f2937e1f3c21857f4efef899c39fa6e06d76bb5c7eb592f249753b1a6d3a05454c1d49d43af SHA512 9909e2a199c7c6f1e9fc8f3ed7b7f9227403bdbe71bfb6ce42eb9344b1e00271396dcbd62382cc4c3d121c67154ad3b9011e025347c60065756180f718a49d58 MISC metadata.xml 311 BLAKE2B 78ae228a5e7307e8ed03ddab6b38d288bb7811f0a04d460fa13096fd8350b9b097dffcc1fb8e7f173834d49c108e482b8c8fc6ba65ffbaf6697c4e7075167ccd SHA512 72243543b91ee6b5560444cb1082dac192e2b17b5746e52b92076b483e14ced459ac54fad595307a6e7b53f48d1466d81b1ea4c1829d128f7b977fae87a176cc diff --git a/dev-db/mysql-workbench/mysql-workbench-8.0.27.ebuild b/dev-db/mysql-workbench/mysql-workbench-8.0.27.ebuild index 6ce9aed7c684..273419842bc6 100644 --- a/dev-db/mysql-workbench/mysql-workbench-8.0.27.ebuild +++ b/dev-db/mysql-workbench/mysql-workbench-8.0.27.ebuild @@ -1,4 +1,4 @@ -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=7 @@ -20,7 +20,7 @@ SRC_URI="https://cdn.mysql.com/Downloads/MySQLGUITools/${MY_P}.tar.gz LICENSE="GPL-2" SLOT="0" -KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux" +KEYWORDS="amd64 ~x86 ~amd64-linux ~x86-linux" IUSE="debug doc" REQUIRED_USE="${PYTHON_REQUIRED_USE}" diff --git a/dev-db/percona-server/Manifest b/dev-db/percona-server/Manifest index a020a9ec2a47..35c5bda6e74a 100644 --- a/dev-db/percona-server/Manifest +++ b/dev-db/percona-server/Manifest @@ -6,6 +6,6 @@ DIST percona-server-8.0.25-15.tar.gz 531072362 BLAKE2B aa6867a8ac72325596393723c DIST percona-server-8.0.25.15-patches-01.tar.xz 7624 BLAKE2B b06495859f3df546bc42e69ec77007a335103020313524ed728309764fea8ca2ea6f246938852ab2fb5ea12b4d901af5ebb9abff4d99b7e56d6ffd501d10bd38 SHA512 69b2d478046666d7c5dbffe662f4e000fd1c2c8789bcaeea72b8bb229ad85d8cd54a293c74440f93c56dc07a06143553ff989711787e6cd610a8e23bb353a1df DIST percona-server-8.0.26-16.tar.gz 532328971 BLAKE2B bef32f7a26261f3b0d89bd9b95b826101e2e84c662ce2200a2d9d8a612d949804d233905db71bfab5aa04458e7773231659d67ea09e08e68df8ef5eca4391f39 SHA512 9ae60e2d81dfaabc214692cd0919c2fc3ba698bd0a399e42df662766c1d67714f6f3cfe6416019b26e7866bc59b78d99fc5767f64ede1ca8e5a344995c1ff4c0 DIST percona-server-8.0.26.16-patches-01.tar.xz 8144 BLAKE2B 28a4eaec657c09a6f8290b654dd5316d44a4cbf94e418edee3754742f21df56a058de9332c15abbb7c8bbd3ed6fc63e48e6c5fa77524dccf44ff1d5a89085a6b SHA512 4a128a89abc1f48582b0c6ab841643fa0b7e018eaa32414e775705cd1e8c2dcacecd334face9db33775ca3a2a862528e1cc7f2bfd8b259b7367f0f2ebdee52c4 -EBUILD percona-server-8.0.25.15.ebuild 42717 BLAKE2B e7067ee46740fc6c40cbee53fe4ac5bc602eebec871e07bea21c64beab3a053923afaed3ee1c3f74c13885245337e410c108055dcbb3c5c358c22bfb2ddb1cac SHA512 5676a89d5b5d925132fdb3b9cdd15c334476076f231f267667f11d0df7fdf9de650a614fef2afc1e4a08f2463fdb398c0c2b5207b41a83a0b79901bbc501d550 -EBUILD percona-server-8.0.26.16.ebuild 42897 BLAKE2B ace80127ce9448e1ba3772dcca7fefd85a96e14b96d3811d3705fee4cd719917d5975f6dcc43b8ff2e617bfc20d2ebed3c482b93d8a1324c3a24eaf06f847355 SHA512 0d718b32128c5a1067226b41ff4cf31c9fa29f40ecd7ca7c933d16019495ab2d5555a88a4b4c82d4f1b90b2073d9032558b84c63b58d286ce4d1fbe70a9610d1 +EBUILD percona-server-8.0.25.15-r1.ebuild 42774 BLAKE2B aa76031b06b60df189df39d4246839a782dbe99af24b0d4f7032b0a70ffba4917c0f9609aff50487b798e43b919dfeb0132186767c3c6b76034af6bebfa32d57 SHA512 d2460e2c893de9110b1b73c0ad224e708aed5aeb6ea77f654a5c1d5b3ee1dc624ab7d6087ed08bfe0b1538ad73e3b3c9db51756cc45c869194a057084a7b3baf +EBUILD percona-server-8.0.26.16-r1.ebuild 42954 BLAKE2B 51dbe6e6e8be119ffbca5ec2ed41a90765a4ffd09e716fd785381d3e90ac5ac61de1359e9cc4c66e4e389faa012b5df1986d088e805108f186ed667adb79d555 SHA512 26345d4f08ddb975660e1fec3b4ec6ce29b0c0503e3c1367540c54687f89e41f0304a0adcca31f8e10f57fb95d980135e48fb3dbd7d4b3b6b12527d719574066 MISC metadata.xml 1011 BLAKE2B 59166664921919352aa3bd37c1b8b8e9f5fe142698db249105908afd61f4747ddcbffa3a7f22869381126cbb9f609eebde2d103b0dc283410cbbc6fa67a4964c SHA512 aef0bef1758e147e1a7120d5147388501efe7d3bc56dcb464521fcff8ee99052213415c2388b19aa4d4252120f9e56f1edfacd5cd8ced8bcec5422b8e7df282c diff --git a/dev-db/percona-server/percona-server-8.0.25.15-r1.ebuild b/dev-db/percona-server/percona-server-8.0.25.15-r1.ebuild new file mode 100644 index 000000000000..1960a9053c03 --- /dev/null +++ b/dev-db/percona-server/percona-server-8.0.25.15-r1.ebuild @@ -0,0 +1,1274 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="7" + +CMAKE_MAKEFILE_GENERATOR=emake + +inherit check-reqs cmake flag-o-matic linux-info \ + multiprocessing prefix toolchain-funcs + +MY_BOOST_VERSION="1.73.0" +MY_PV=$(ver_rs 3 '-') +MY_PV="${MY_PV//_pre*}" +MY_PN="Percona-Server" +MY_P="${PN}-${MY_PV}" +MY_MAJOR_PV=$(ver_cut 1-2) +MY_RELEASE_NOTES_URI="https://www.percona.com/doc/percona-server/${MY_MAJOR_PV}/" + +# Patch version +PATCH_SET="https://dev.gentoo.org/~whissi/dist/percona-server/${PN}-8.0.25.15-patches-01.tar.xz" + +SRC_URI="https://www.percona.com/downloads/${MY_PN}-${MY_MAJOR_PV}/${MY_PN}-${MY_PV}/source/tarball/${PN}-${MY_PV}.tar.gz + https://dl.bintray.com/boostorg/release/${MY_BOOST_VERSION}/source/boost_$(ver_rs 1- _ ${MY_BOOST_VERSION}).tar.bz2 + ${PATCH_SET} +" + +HOMEPAGE="https://www.percona.com/software/mysql-database/percona-server https://github.com/percona/percona-server" +DESCRIPTION="Fully compatible, enhanced and open source drop-in replacement for MySQL" +LICENSE="GPL-2" +SLOT="8.0" +IUSE="cjk cracklib debug jemalloc latin1 ldap numa pam +perl profiling + rocksdb router selinux +server tcmalloc test tokudb tokudb-backup-plugin" + +RESTRICT="!test? ( test )" + +REQUIRED_USE="?? ( tcmalloc jemalloc ) + cjk? ( server ) + jemalloc? ( server ) + numa? ( server ) + profiling? ( server ) + router? ( server ) + tcmalloc? ( server )" + +KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 -riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris ~x86-solaris" + +# Shorten the path because the socket path length must be shorter than 107 chars +# and we will run a mysql server during test phase +S="${WORKDIR}/mysql" + +# Be warned, *DEPEND are version-dependant +# These are used for both runtime and compiletime +# openldap < dep for bug #835647 (we need ldap_r) +COMMON_DEPEND=" + >=app-arch/lz4-0_p131:= + app-arch/zstd:= + sys-libs/ncurses:0= + >=sys-libs/zlib-1.2.3:0= + >=dev-libs/openssl-1.0.0:0= + server? ( + dev-libs/icu:= + dev-libs/libevent:=[ssl,threads] + >=dev-libs/protobuf-3.8:= + net-libs/libtirpc:= + net-misc/curl:= + cjk? ( app-text/mecab:= ) + ldap? ( + dev-libs/cyrus-sasl + /dev/null) + [[ -z "${aio_max_nr}" || ${aio_max_nr} -lt 250000 ]] \ + && die "FEATURES=test will require fs.aio-max-nr=250000 at minimum!" + + if use latin1 ; then + # Upstream only supports tests with default charset + die "Testing with USE=latin1 is not supported." + fi + fi + + if use kernel_linux ; then + if use numa ; then + linux-info_get_any_version + + local CONFIG_CHECK="~NUMA" + + local WARNING_NUMA="This package expects NUMA support in kernel which this system does not have at the moment;" + WARNING_NUMA+=" Either expect runtime errors, enable NUMA support in kernel or rebuild the package without NUMA support" + + check_extra_config + fi + fi + + use server && check-reqs_pkg_setup + fi +} + +src_unpack() { + unpack ${A} + + mv -f "${WORKDIR}/${MY_P}" "${S}" || die +} + +src_prepare() { + eapply "${WORKDIR}"/mysql-patches + + # Avoid rpm call which would trigger sandbox, #692368 + sed -i \ + -e 's/MY_RPM rpm/MY_RPM rpmNOTEXISTENT/' \ + CMakeLists.txt || die + + if use jemalloc ; then + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" || die + fi + + if use tcmalloc ; then + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" || die + fi + + # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux + if [[ -d "${S}/support-files/SELinux" ]] ; then + echo > "${S}/support-files/SELinux/CMakeLists.txt" || die + fi + + # Remove man pages for client-lib tools we don't install + rm \ + man/my_print_defaults.1 \ + man/perror.1 \ + man/zlib_decompress.1 \ + || die + + cmake_src_prepare +} + +src_configure() { + # Bug #114895, bug #110149 + filter-flags "-O" "-O[01]" + + append-cxxflags -felide-constructors + + # code is not C++17 ready, bug #786402 + append-cxxflags -std=c++14 + + # bug #283926, with GCC4.4, this is required to get correct behavior. + append-flags -fno-strict-aliasing + + CMAKE_BUILD_TYPE="RelWithDebInfo" + + # debug hack wrt #497532 + mycmakeargs=( + -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" + -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql" + -DSYSCONFDIR="${EPREFIX}/etc/mysql" + -DINSTALL_BINDIR=bin + -DINSTALL_DOCDIR=share/doc/${PF} + -DINSTALL_DOCREADMEDIR=share/doc/${PF} + -DINSTALL_INCLUDEDIR=include/mysql + -DINSTALL_INFODIR=share/info + -DINSTALL_LIBDIR=$(get_libdir) + -DINSTALL_MANDIR=share/man + -DINSTALL_MYSQLSHAREDIR=share/mysql + -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" + -DINSTALL_SBINDIR=sbin + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mysql" + -DCOMPILATION_COMMENT="Gentoo Linux ${PF}" + -DWITH_UNIT_TESTS=$(usex test ON OFF) + # Using bundled editline to get CTRL+C working + -DWITH_EDITLINE=bundled + -DWITH_ZLIB=system + -DWITH_SSL=system + -DWITH_LIBWRAP=0 + -DENABLED_LOCAL_INFILE=1 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DWITH_DEFAULT_COMPILER_OPTIONS=0 + # The build forces this to be defined when cross-compiling. We pass it + # all the time for simplicity and to make sure it is actually correct. + -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1) + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DWITH_CURL=system + -DWITH_BOOST="${WORKDIR}/boost_$(ver_rs 1- _ ${MY_BOOST_VERSION})" + -DWITH_ROUTER=$(usex router ON OFF) + ) + + if is-flagq -fno-lto ; then + einfo "LTO disabled via {C,CXX,F,FC}FLAGS" + mycmakeargs+=( -DWITH_LTO=OFF ) + elif is-flagq -flto ; then + einfo "LTO forced via {C,CXX,F,FC}FLAGS" + myconf+=( -DWITH_LTO=ON ) + else + # Disable automagic + myconf+=( -DWITH_LTO=OFF ) + fi + + if use test ; then + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test ) + else + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) + fi + + mycmakeargs+=( -DWITHOUT_CLIENTLIBS=YES ) + + mycmakeargs+=( + -DWITH_ICU=system + -DWITH_LZ4=system + # Our dev-libs/rapidjson doesn't carry necessary fixes for std::regex + -DWITH_RAPIDJSON=bundled + -DWITH_ZSTD=system + ) + + if [[ -n "${MYSQL_DEFAULT_CHARSET}" && -n "${MYSQL_DEFAULT_COLLATION}" ]] ; then + ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}" + ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}." + ewarn "You MUST file bugs without these variables set." + ewarn "Tests will probably fail!" + + mycmakeargs+=( + -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET} + -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION} + ) + elif use latin1 ; then + mycmakeargs+=( + -DDEFAULT_CHARSET=latin1 + -DDEFAULT_COLLATION=latin1_swedish_ci + ) + else + mycmakeargs+=( + -DDEFAULT_CHARSET=utf8mb4 + -DDEFAULT_COLLATION=utf8mb4_0900_ai_ci + ) + fi + + if use server ; then + mycmakeargs+=( + -DWITH_AUTHENTICATION_LDAP=$(usex ldap system OFF) + -DWITH_COREDUMPER=OFF + -DWITH_EXTRA_CHARSETS=all + -DWITH_DEBUG=$(usex debug) + -DWITH_MECAB=$(usex cjk system OFF) + -DWITH_LIBEVENT=system + -DWITH_PROTOBUF=system + -DWITH_NUMA=$(usex numa ON OFF) + -DWITH_PAM=$(usex pam) + ) + + if use profiling ; then + # Setting to OFF doesn't work: Once set, profiling options will be added + # to `mysqld --help` output via sql/sys_vars.cc causing + # "main.mysqld--help-notwin" test to fail + mycmakeargs+=( -DENABLED_PROFILING=ON ) + fi + + # Storage engines + mycmakeargs+=( + -DWITH_EXAMPLE_STORAGE_ENGINE=0 + -DWITH_ARCHIVE_STORAGE_ENGINE=1 + -DWITH_BLACKHOLE_STORAGE_ENGINE=1 + -DWITH_CSV_STORAGE_ENGINE=1 + -DWITH_FEDERATED_STORAGE_ENGINE=1 + -DWITH_HEAP_STORAGE_ENGINE=1 + -DWITH_INNOBASE_STORAGE_ENGINE=1 + -DWITH_INNODB_MEMCACHED=0 + -DWITH_MYISAMMRG_STORAGE_ENGINE=1 + -DWITH_MYISAM_STORAGE_ENGINE=1 + -DWITH_ROCKSDB=$(usex rocksdb 1 0) + -DWITH_TOKUDB=$(usex tokudb 1 0) + ) + else + mycmakeargs+=( + -DWITHOUT_SERVER=1 + -DWITH_SYSTEMD=no + ) + fi + + cmake_src_configure +} + +# Official test instructions: +# ulimit -n 16500 && \ +# USE='perl server' \ +# FEATURES='test userpriv' \ +# ebuild mysql-X.X.XX.ebuild \ +# digest clean package +src_test() { + _disable_test() { + local rawtestname bug reason + rawtestname="${1}" ; shift + bug="${1}" ; shift + reason="${@}" + ewarn "test '${rawtestname}' disabled: '${reason}' (BUG#${bug})" + echo ${rawtestname} : BUG#${bug} ${reason} >> "${T}/disabled.def" + } + + local TESTDIR="${BUILD_DIR}/mysql-test" + local retstatus_unit + local retstatus_tests + + # Run CTest (test-units) + cmake_src_test + retstatus_unit=$? + + # Ensure that parallel runs don't die + export MTR_BUILD_THREAD="$((${RANDOM} % 100))" + + if [[ -z "${MTR_PARALLEL}" ]] ; then + local -x MTR_PARALLEL=$(makeopts_jobs) + + if [[ ${MTR_PARALLEL} -gt 4 ]] ; then + # Running multiple tests in parallel usually require higher ulimit + # and fs.aio-max-nr setting. In addition, tests like main.multi_update + # are known to hit timeout when system is busy. + # To avoid test failure we will limit MTR_PARALLEL to 4 instead of + # using "auto". + local info_msg="Parallel MySQL test suite jobs limited to 4 (MAKEOPTS=${MTR_PARALLEL})" + info_msg+=" to avoid test failures. Set MTR_PARALLEL if you know what you are doing!" + einfo "${info_msg}" + unset info_msg + MTR_PARALLEL=4 + fi + else + einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" + fi + + # create directories because mysqladmin might run out of order + mkdir -p "${T}"/var-tests{,/log} || die + + # Run mysql tests + pushd "${TESTDIR}" &>/dev/null || die + + touch "${T}/disabled.def" + + local -a disabled_tests + disabled_tests+=( "auth_sec.atomic_rename_user;103512;Depends on user running test" ) + disabled_tests+=( "auth_sec.keyring_file_data_qa;0;Won't work with user privileges" ) + disabled_tests+=( "gis.geometry_class_attri_prop;5452;Known rounding error with latest AMD processors (PS)" ) + disabled_tests+=( "gis.geometry_property_function_issimple;5452;Known rounding error with latest AMD processors (PS)" ) + disabled_tests+=( "gis.gis_bugs_crashes;5452;Known rounding error with latest AMD processors (PS)" ) + disabled_tests+=( "gis.spatial_analysis_functions_buffer;5452;Known rounding error with latest AMD processors (PS)" ) + disabled_tests+=( "gis.spatial_analysis_functions_centroid;5452;Known rounding error with latest AMD processors (PS)" ) + disabled_tests+=( "gis.spatial_analysis_functions_distance;5452;Known rounding error with latest AMD processors (PS)" ) + disabled_tests+=( "gis.spatial_op_testingfunc_mix;5452;Known rounding error with latest AMD processors (PS)" ) + disabled_tests+=( "gis.spatial_operators_intersection;5452;Known rounding error with latest AMD processors (PS)" ) + disabled_tests+=( "gis.spatial_utility_function_distance_sphere;5452;Known rounding error with latest AMD processors (PS)" ) + disabled_tests+=( "gis.spatial_utility_function_simplify;5452;Known rounding error with latest AMD processors (PS)" ) + disabled_tests+=( "group_replication.gr_ssl_options2;0;Sporadic failing test" ) + disabled_tests+=( "innodb.alter_kill;0;Known test failure -- no upstream bug yet" ) + disabled_tests+=( "innodb.percona_changed_page_bmp_flush;6807;False positive on Gentoo (PS)" ) + disabled_tests+=( "innodb.percona_changed_page_bmp_log_resize;0;Sporadic failing test" ) + disabled_tests+=( "innodb.percona_log_encrypt_change_mk;6039;False positive on Gentoo (PS)" ) + disabled_tests+=( "innodb.percona_log_encrypt_change_rk;6805;False positive on Gentoo (PS)" ) + disabled_tests+=( "innodb.percona_log_encrypt_failure;0;Requires proper keyring setup" ) + disabled_tests+=( "innodb.upgrade_orphan;0;Sporadic failing test" ) + disabled_tests+=( "main.coredump;0;Known test failure" ) + disabled_tests+=( "main.derived_limit;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) + disabled_tests+=( "main.explain_tree;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) + disabled_tests+=( "main.myisam-blob;0;Sporadic failing test" ) + disabled_tests+=( "main.mysql_load_data_local_dir;7416;Known test failure" ) + disabled_tests+=( "main.mysqlpump_basic_lz4;6042;Extra tool output causes false positive" ) + disabled_tests+=( "main.ssl_bug75311;5996;Known test failure" ) + disabled_tests+=( "main.ssl_san;6808;False positive on IPv6-enabled hosts" ) + disabled_tests+=( "main.subquery_bugs;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) + disabled_tests+=( "main.subquery_sj_dupsweed;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) + disabled_tests+=( "main.subquery_sj_dupsweed_bka;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) + disabled_tests+=( "main.subquery_sj_dupsweed_bka_nobnl;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) + disabled_tests+=( "main.subquery_sj_firstmatch;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) + disabled_tests+=( "main.subquery_sj_firstmatch_bka;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) + disabled_tests+=( "main.subquery_sj_firstmatch_bka_nobnl;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) + disabled_tests+=( "main.subquery_sj_mat_bka_nobnl;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) + disabled_tests+=( "main.window_std_var;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) + disabled_tests+=( "main.window_std_var_optimized;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) + disabled_tests+=( "main.with_recursive;6804;Known rounding error with latest AMD processors" ) + disabled_tests+=( "rpl_gtid.rpl_gtid_stm_drop_table;90612;Known test failure" ) + disabled_tests+=( "rpl_gtid.rpl_multi_source_mtr_includes;0;Know failure - no upstream bug yet" ) + disabled_tests+=( "sys_vars.innodb_sys_tablespace_encrypt_basic;7415;Known test failure" ) + disabled_tests+=( "sys_vars.myisam_data_pointer_size_func;87935;Test will fail on slow hardware" ) + disabled_tests+=( "x.message_compressed_payload;0;False positive caused by protobuff-3.11+" ) + disabled_tests+=( "x.message_protobuf_nested;6803;False positive caused by protobuff-3.11+" ) + + if ! hash zip 1>/dev/null 2>&1 ; then + # no need to force dep app-arch/zip for one test + disabled_tests+=( "innodb.discarded_partition_create;0;Requires app-arch/zip" ) + disabled_tests+=( "innodb.partition_upgrade_create;0;Requires app-arch/zip" ) + fi + + if has_version ">=dev-libs/openssl-3" ; then + # >=dev-libs/openssl-3 defaults to security level 1 which disallow + # TLSv1/1.1 but tests will require TLSv1/1.1. + einfo "Set OpenSSL configuration for test suite ..." + cat > "${T}/openssl_tlsv1.cnf" <<- EOF || die + openssl_conf = default_conf + + [ req ] + default_bits = 2048 + default_keyfile = privkey.pem + distinguished_name = req_distinguished_name + + [ req_distinguished_name ] + countryName = Country Name (2 letter code) + countryName_default = AU + countryName_min = 2 + countryName_max = 2 + + stateOrProvinceName = State or Province Name (full name) + stateOrProvinceName_default = Some-State + + localityName = Locality Name (eg, city) + + 0.organizationName = Organization Name (eg, company) + 0.organizationName_default = Internet Widgits Pty Ltd + + organizationalUnitName = Organizational Unit Name (eg, section) + + commonName = Common Name (e.g. server FQDN or YOUR name) + commonName_max = 64 + + emailAddress = Email Address + emailAddress_max = 64 + + [default_conf] + ssl_conf = ssl_sect + + [ssl_sect] + system_default = system_default_sect + + [system_default_sect] + CipherString = DEFAULT@SECLEVEL=0 + EOF + + local -x OPENSSL_CONF="${T}/openssl_tlsv1.cnf" + + disabled_tests+=( "x.connection_tls_version;0;Not compatible with OpenSSL 3.x error messages" ) + fi + + local test_infos_str test_infos_arr + for test_infos_str in "${disabled_tests[@]}" ; do + IFS=';' read -r -a test_infos_arr <<< "${test_infos_str}" + + if [[ ${#test_infos_arr[@]} != 3 ]] ; then + die "Invalid test data set, not matching format: ${test_infos_str}" + fi + + _disable_test "${test_infos_arr[0]}" "${test_infos_arr[1]}" "${test_infos_arr[2]}" + done + unset test_infos_str test_infos_arr + + if [[ -z "${MTR_VAULT_TOKEN}" ]] ; then + local impossible_test + for impossible_test in \ + encryption.default_table_encryption_var \ + keyring_vault.innodb_online_alter_encryption \ + keyring_vault.innodb_row_log_encryption \ + keyring_vault.install_keyring_vault \ + keyring_vault.keyring_udf \ + keyring_vault.keyring_vault_config \ + keyring_vault.keyring_vault_config_qa \ + keyring_vault.keyring_vault_timeout \ + keyring_vault.key_rotation_qa \ + keyring_vault.rpl_key_rotation \ + keyring_vault.table_encrypt_2 \ + keyring_vault.table_encrypt_2_directory \ + keyring_vault.table_encrypt_2_keyring \ + keyring_vault.table_encrypt_5 \ + keyring_vault.table_encrypt_5_directory \ + keyring_vault.table_encrypt_kill \ + keyring_vault.temp_table_encrypt_keyring_vault \ + main.persisted_variables \ + ; do + _disable_test "${impossible_test}" "0" "MTR_VAULT_TOKEN is not set" + done + fi + + # Try to increase file limits to increase test coverage + if ! ulimit -n 16500 1>/dev/null 2>&1 ; then + # Upper limit comes from parts.partition_* tests + ewarn "For maximum test coverage please raise open file limit to 16500 (ulimit -n 16500) before calling the package manager." + + if ! ulimit -n 4162 1>/dev/null 2>&1 ; then + # Medium limit comes from '[Warning] Buffered warning: Could not increase number of max_open_files to more than 3000 (request: 4162)' + ewarn "For medium test coverage please raise open file limit to 4162 (ulimit -n 4162) before calling the package manager." + + if ! ulimit -n 3000 1>/dev/null 2>&1 ; then + ewarn "For minimum test coverage please raise open file limit to 3000 (ulimit -n 3000) before calling the package manager." + else + einfo "Will run test suite with open file limit set to 3000 (minimum test coverage)." + fi + else + einfo "Will run test suite with open file limit set to 4162 (medium test coverage)." + fi + else + einfo "Will run test suite with open file limit set to 16500 (best test coverage)." + fi + + # run mysql-test tests + perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def" + retstatus_tests=$? + + popd &>/dev/null || die + + # Cleanup is important for these testcases. + pkill -9 -f "${S}/ndb" 2>/dev/null + pkill -9 -f "${S}/sql" 2>/dev/null + + local failures="" + [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit" + [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests" + + [[ -z "$failures" ]] || die "Test failures: $failures" + einfo "Tests successfully completed" +} + +src_install() { + cmake_src_install + + # Make sure the vars are correctly initialized + mysql_init_vars + + # Convenience links + einfo "Making Convenience links for mysqlcheck multi-call binary" + dosym "mysqlcheck" "/usr/bin/mysqlanalyze" + dosym "mysqlcheck" "/usr/bin/mysqlrepair" + dosym "mysqlcheck" "/usr/bin/mysqloptimize" + + # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir + if [[ -d "${ED}/usr/data" ]] ; then + rm -Rf "${ED}/usr/data" || die + fi + + # Unless they explicitly specific USE=test, then do not install the + # testsuite. It DOES have a use to be installed, esp. when you want to do a + # validation of your database configuration after tuning it. + if ! use test ; then + rm -rf "${ED}/${MY_SHAREDSTATEDIR#${EPREFIX}}/mysql-test" + fi + + # Configuration stuff + einfo "Building default configuration ..." + insinto "${MY_SYSCONFDIR#${EPREFIX}}" + [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf + cp "${FILESDIR}/my.cnf-5.7" "${TMPDIR}/my.cnf" || die + eprefixify "${TMPDIR}/my.cnf" + doins "${TMPDIR}/my.cnf" + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mysql.d" + cp "${FILESDIR}/my.cnf-8.0.distro-client" "${TMPDIR}/50-distro-client.cnf" || die + eprefixify "${TMPDIR}/50-distro-client.cnf" + doins "${TMPDIR}/50-distro-client.cnf" + + mycnf_src="my.cnf-8.0.distro-server" + sed -e "s!@DATADIR@!${MY_DATADIR}!g" \ + "${FILESDIR}/${mycnf_src}" \ + > "${TMPDIR}/my.cnf.ok" || die + + if use prefix ; then + sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \ + "${TMPDIR}/my.cnf.ok" || die + fi + + if use latin1 ; then + sed -i \ + -e "/character-set/s|utf8mb4|latin1|g" \ + "${TMPDIR}/my.cnf.ok" || die + fi + + eprefixify "${TMPDIR}/my.cnf.ok" + + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf + + #Remove mytop if perl is not selected + [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop" + + if use router ; then + rm -rf \ + "${ED}/usr/LICENSE.router" \ + "${ED}/usr/README.router" \ + "${ED}/usr/run" \ + "${ED}/usr/var" \ + || die + fi + + # Kill old libmysqclient_r symlinks if they exist. Time to fix what depends on them. + find "${D}" -name 'libmysqlclient_r.*' -type l -delete || die +} + +pkg_postinst() { + # Make sure the vars are correctly initialized + mysql_init_vars + + # Create log directory securely if it does not exist + # NOTE: $MY_LOGDIR contains $EPREFIX by default + [[ -d "${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${MY_LOGDIR}" + + # Note about configuration change + einfo + elog "This version of ${PN} reorganizes the configuration from a single my.cnf" + elog "to several files in /etc/mysql/mysql.d." + elog "Please backup any changes you made to /etc/mysql/my.cnf" + elog "and add them as a new file under /etc/mysql/mysql.d with a .cnf extension." + elog "You may have as many files as needed and they are read alphabetically." + elog "Be sure the options have the appropriate section headers, i.e. [mysqld]." + einfo + + if [[ -z "${REPLACING_VERSIONS}" ]] ; then + einfo + elog "You might want to run:" + elog " \"emerge --config =${CATEGORY}/${PF}\"" + elog "if this is a new install." + einfo + else + einfo + elog "Upgrade process for ${PN}-8.x has changed. Please read" + elog "https://dev.mysql.com/doc/refman/8.0/en/upgrade-binary-package.html" + einfo + fi +} + +pkg_config() { + _getoptval() { + local section="$1" + local flag="--${2}=" + local extra_options="${3}" + local cmd=( + "${my_print_defaults_binary}" + "${extra_options}" + "${section}" + ) + local results=( $(eval "${cmd[@]}" 2>/dev/null | sed -n "/^${flag}/s,${flag},,gp") ) + + if [[ ${#results[@]} -gt 0 ]] ; then + # When option is set multiple times only return last value + echo "${results[-1]}" + fi + } + + _mktemp_dry() { + # emktemp has no --dry-run option + local template="${1}" + + if [[ -z "${template}" ]] ; then + if [[ -z "${T}" ]] ; then + template="/tmp/XXXXXXX" + else + template="${T}/XXXXXXX" + fi + fi + + local template_wo_X=${template//X/} + local n_X + let n_X=${#template}-${#template_wo_X} + if [[ ${n_X} -lt 3 ]] ; then + echo "${FUNCNAME[0]}: too few X's in template ‘${template}’" >&2 + return + fi + + local attempts=0 + local character tmpfile + while [[ true ]] ; do + let attempts=attempts+1 + + new_file= + while read -n1 character ; do + if [[ "${character}" == "X" ]] ; then + tmpfile+="${RANDOM:0:1}" + else + tmpfile+="${character}" + fi + done < <(echo -n "${template}") + + if [[ ! -f "${tmpfile}" ]] + then + echo "${tmpfile}" + return + fi + + if [[ ${attempts} -ge 100 ]] ; then + echo "${FUNCNAME[0]}: Cannot create temporary file after 100 attempts." >&2 + return + fi + done + } + + local mysqld_binary="${EROOT}/usr/sbin/mysqld" + if [[ ! -x "${mysqld_binary}" ]] ; then + die "'${mysqld_binary}' not found! Please re-install ${CATEGORY}/${PN}!" + fi + + local mysql_binary="${EROOT}/usr/bin/mysql" + if [[ ! -x "${mysql_binary}" ]] ; then + die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!" + fi + + local my_print_defaults_binary="${EROOT}/usr/bin/my_print_defaults" + if [[ ! -x "${my_print_defaults_binary}" ]] ; then + die "'${my_print_defaults_binary}' not found! Please re-install dev-db/mysql-connector-c!" + fi + + if [[ -z "${MYSQL_USER}" ]] ; then + MYSQL_USER=mysql + if use prefix ; then + MYSQL_USER=$(id -u -n 2>/dev/null) + if [[ -z "${MYSQL_USER}" ]] ; then + die "Failed to determine current username!" + fi + fi + fi + + if [[ -z "${MYSQL_GROUP}" ]] ; then + MYSQL_GROUP=mysql + if use prefix ; then + MYSQL_GROUP=$(id -g -n 2>/dev/null) + if [[ -z "${MYSQL_GROUP}" ]] ; then + die "Failed to determine current user groupname!" + fi + fi + fi + + # my_print_defaults needs to read stuff in $HOME/.my.cnf + local -x HOME="${EROOT}/root" + + # Make sure the vars are correctly initialized + mysql_init_vars + + # Read currently set data directory + MY_DATADIR="$(_getoptval mysqld datadir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" + + # Bug #213475 - MySQL _will_ object strenously if your machine is named + # localhost. Also causes weird failures. + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" + + if [[ -z "${MY_DATADIR}" ]] ; then + die "Sorry, unable to find MY_DATADIR!" + elif [[ -d "${MY_DATADIR}/mysql" ]] ; then + ewarn "Looks like your data directory '${MY_DATADIR}' is already initialized!" + ewarn "Please rename or delete its content if you wish to initialize a new data directory." + die "${PN} data directory at '${MY_DATADIR}' looks already initialized!" + fi + + MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" + MYSQL_TMPDIR=${MYSQL_TMPDIR%/} + # These are dir+prefix + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} + + # Create missing directories. + # Always check if mysql user can write to directory even if we just + # created directory because a parent directory might be not + # accessible for that user. + PID_DIR="${EROOT}/run/mysqld" + if [[ ! -d "${PID_DIR}" ]] ; then + einfo "Creating ${PN} PID directory '${PID_DIR}' ..." + install -d -m 755 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${PID_DIR}" \ + || die "Failed to create PID directory '${PID_DIR}'!" + fi + + local _pid_dir_testfile="$(_mktemp_dry "${PID_DIR}/.pkg_config-access-test.XXXXXXXXX")" + [[ -z "${_pid_dir_testfile}" ]] \ + && die "_mktemp_dry() for '${PID_DIR}/.pkg_config-access-test.XXXXXXXXX' failed!" + + if use prefix ; then + touch "${_pid_dir_testfile}" &>/dev/null + else + su -s /bin/sh -c "touch ${_pid_dir_testfile}" ${MYSQL_USER} &>/dev/null + fi + + if [[ $? -ne 0 ]] ; then + die "${MYSQL_USER} user cannot write into PID dir '${PID_DIR}'!" + else + rm "${_pid_dir_testfile}" || die + unset _pid_dir_testfile + fi + + if [[ ! -d "${MY_DATADIR}" ]] ; then + einfo "Creating ${PN} data directory '${MY_DATADIR}' ..." + install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MY_DATADIR}" \ + || die "Failed to create ${PN} data directory '${MY_DATADIR}'!" + fi + + local _my_datadir_testfile="$(_mktemp_dry "${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX")" + [[ -z "${_my_datadir_testfile}" ]] \ + && die "_mktemp_dry() for '${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX' failed!" + + if use prefix ; then + touch "${_my_datadir_testfile}" &>/dev/null + else + su -s /bin/sh -c "touch ${_my_datadir_testfile}" ${MYSQL_USER} &>/dev/null + fi + + if [[ $? -ne 0 ]] ; then + die "${MYSQL_USER} user cannot write into data directory '${MY_DATADIR}'!" + else + rm "${_my_datadir_testfile}" || die + unset _my_datadir_testfile + fi + + if [[ -n "${MYSQL_TMPDIR}" && ! -d "${MYSQL_TMPDIR}" ]] ; then + einfo "Creating ${PN} tmpdir '${MYSQL_TMPDIR}' ..." + install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_TMPDIR}" \ + || die "Failed to create ${PN} tmpdir '${MYSQL_TMPDIR}'!" + fi + + if [[ -z "${MYSQL_TMPDIR}" ]] ; then + MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")" + [[ -z "${MYSQL_TMPDIR}" ]] \ + && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!" + + mkdir "${MYSQL_TMPDIR}" || die + chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die + fi + + # Now we need to test MYSQL_TMPDIR... + local _my_tmpdir_testfile="$(_mktemp_dry "${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX")" + [[ -z "${_my_tmpdir_testfile}" ]] \ + && die "_mktemp_dry() for '${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX' failed!" + + if use prefix ; then + touch "${_my_tmpdir_testfile}" &>/dev/null + else + su -s /bin/sh -c "touch ${_my_tmpdir_testfile}" ${MYSQL_USER} &>/dev/null + fi + + if [[ $? -ne 0 ]] ; then + die "${MYSQL_USER} user cannot write into tmpdir '${MYSQL_TMPDIR}'!" + else + rm "${_my_tmpdir_testfile}" || die + unset _my_tmpdir_testfile + fi + + if [[ -n "${MYSQL_LOG_BIN}" && ! -d "${MYSQL_LOG_BIN}" ]] ; then + einfo "Creating ${PN} log-bin directory '${MYSQL_LOG_BIN}' ..." + install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_LOG_BIN}" \ + || die "Failed to create ${PN} log-bin directory '${MYSQL_LOG_BIN}'" + fi + + if [[ -n "${MYSQL_LOG_BIN}" ]] ; then + local _my_logbin_testfile="$(_mktemp_dry "${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX")" + [[ -z "${_my_logbin_testfile}" ]] \ + && die "_mktemp_dry() for '${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX' failed!" + + if use prefix ; then + touch "${_my_logbin_testfile}" &>/dev/null + else + su -s /bin/sh -c "touch ${_my_logbin_testfile}" ${MYSQL_USER} &>/dev/null + fi + + if [[ $? -ne 0 ]] ; then + die "${MYSQL_USER} user cannot write into log-bin directory '${MYSQL_LOG_BIN}'!" + else + rm "${_my_logbin_testfile}" || die + unset _my_logbin_testfile + fi + fi + + if [[ -n "${MYSQL_RELAY_LOG}" && ! -d "${MYSQL_RELAY_LOG}" ]] ; then + einfo "Creating ${PN} relay-log directory '${MYSQL_RELAY_LOG}' ..." + install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_RELAY_LOG}" \ + || die "Failed to create ${PN} relay-log directory '${MYSQL_RELAY_LOG}'!" + fi + + if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then + local _my_relaylog_testfile="$(_mktemp_dry "${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX")" + [[ -z "${_my_relaylog_testfile}" ]] \ + && die "_mktemp_dry() for '${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX' failed!" + + if use prefix ; then + touch "${_my_relaylog_testfile}" &>/dev/null + else + su -s /bin/sh -c "touch ${_my_relaylog_testfile}" ${MYSQL_USER} &>/dev/null + fi + + if [[ $? -ne 0 ]] ; then + die "${MYSQL_USER} user cannot write into relay-log directory '${MYSQL_RELAY_LOG}'!" + else + rm "${_my_relaylog_testfile}" || die + unset _my_relaylog_testfile + fi + fi + + local mysql_install_log="$(_mktemp_dry "${MYSQL_TMPDIR}/install_db.XXXXXXXXX.log")" + if [[ -z "${mysql_install_log}" ]] ; then + die "_mktemp_dry() for '${MYSQL_TMPDIR}/install_db.XXXXXXXXX.log' failed!" + else + # make sure file is writable for MYSQL_USER... + touch "${mysql_install_log}" || die + chown ${MYSQL_USER} "${mysql_install_log}" || die + fi + + local mysqld_logfile="$(_mktemp_dry "${MYSQL_TMPDIR}/install_mysqld.XXXXXXXXX.log")" + if [[ -z "${mysqld_logfile}" ]] ; then + die "_mktemp_dry() for '${MYSQL_TMPDIR}/install_mysqld.XXXXXXXXX.log' failed!" + else + # make sure file is writable for MYSQL_USER... + touch "${mysqld_logfile}" || die + chown ${MYSQL_USER} "${mysqld_logfile}" || die + fi + + echo "" + einfo "Detected settings:" + einfo "==================" + einfo "MySQL User:\t\t\t\t${MYSQL_USER}" + einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}" + einfo "MySQL DATA directory:\t\t${MY_DATADIR}" + einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}" + + if [[ -n "${MYSQL_LOG_BIN}" ]] ; then + einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}" + fi + + if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then + einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}" + fi + + einfo "PID DIR:\t\t\t\t${PID_DIR}" + einfo "Install db log:\t\t\t${mysql_install_log}" + einfo "Install server log:\t\t\t${mysqld_logfile}" + + local -a config_files + + local config_file="${EROOT}/etc/mysql/mysql.d/50-distro-client.cnf" + if [[ -f "${config_file}" ]] ; then + config_files+=( "${config_file}" ) + else + ewarn "Client configuration '${config_file}' not found; Skipping configuration of default authentication plugin for client ..." + fi + + config_file="${EROOT}/etc/mysql/mysql.d/50-distro-server.cnf" + if [[ -f "${config_file}" ]] ; then + config_files+=( "${config_file}" ) + else + ewarn "Server configuration '${config_file}' not found; Skipping configuration of default authentication plugin for mysqld ..." + fi + + if [[ ${#config_files[@]} -gt 0 ]] ; then + if [[ -z "${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" ]] ; then + local user_answer + + echo + einfo "Please select default authentication plugin (enter number or plugin name):" + einfo "1) caching_sha2_password [MySQL 8.0 default]" + einfo "2) mysql_native_password [MySQL 5.7 default]" + einfo + einfo "For details see:" + einfo "https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password" + read -p " >" user_answer + echo + + case "${user_answer}" in + 1|caching_sha2_password) + MYSQL_DEFAULT_AUTHENTICATION_PLUGIN=caching_sha2_password + ;; + 2|mysql_native_password) + MYSQL_DEFAULT_AUTHENTICATION_PLUGIN=mysql_native_password + ;; + '') + die "No authentication plugin selected!" + ;; + *) + die "Authentication plugin '${user_answer}' is unknown/unsupported!" + ;; + esac + + echo "Selected authentication plugin: ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" >> "${mysql_install_log}" + + unset user_answer + fi + + local cfg_option cfg_option_tabs cfg_section + for config_file in "${config_files[@]}" ; do + cfg_option="default-authentication-plugin" + cfg_section="mysqld" + cfg_option_tabs="\t\t" + if [[ "${config_file}" == *client.cnf ]] ; then + cfg_option="default-auth" + cfg_section="client" + cfg_option_tabs="\t\t\t\t" + fi + + if grep -qE "^(loose-)?${cfg_option}\b.*=" "${config_file}" 2>/dev/null ; then + einfo "Ensuring that ${cfg_option} is set to '${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}' in '${config_file}' ..." + sed -i \ + -e "s/^\(loose-\)\?${cfg_option}\b.*=.*/loose-${cfg_option}${cfg_option_tabs}= ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}/" \ + "${config_file}" || die "Failed to change ${cfg_option} in '${config_file}'!" + else + einfo "Setting ${cfg_option} to '${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}' in '${config_file}' ..." + sed -i \ + -e "/^\[${cfg_section}\]$/a loose-${cfg_option}${cfg_option_tabs}= ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" \ + "${config_file}" || die "Failed to add ${cfg_option} to '${config_file}'!" + fi + done + unset cfg_option cfg_option_tabs cfg_section + fi + unset config_files config_file + + echo + + if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then + local tmp_mysqld_password_source= + + for tmp_mysqld_password_source in mysql client ; do + einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..." + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)" + if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then + if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]] ; then + ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!" + MYSQL_ROOT_PASSWORD= + continue + fi + + einfo "Found password in '${tmp_mysqld_password_source}' section!" + break + fi + done + + # Sometimes --show is required to display passwords in some implementations of my_print_defaults + if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]] ; then + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)" + fi + + unset tmp_mysqld_password_source + fi + + if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then + local pwd1="a" + local pwd2="b" + + echo + einfo "No password for mysql 'root' user was specified via environment" + einfo "variable MYSQL_ROOT_PASSWORD and no password was found in config" + einfo "file like '${HOME}/.my.cnf'." + einfo "To continue please provide a password for the mysql 'root' user" + einfo "now on console:" + ewarn "NOTE: Please avoid [\"'\\_%] characters in the password!" + read -rsp " >" pwd1 ; echo + + einfo "Retype the password" + read -rsp " >" pwd2 ; echo + + if [[ "x$pwd1" != "x$pwd2" ]] ; then + die "Passwords are not the same!" + fi + + MYSQL_ROOT_PASSWORD="${pwd1}" + unset pwd1 pwd2 + + echo + fi + + local -a mysqld_options + + # Fix bug 446200. Don't reference host my.cnf, needs to come first, + # see http://bugs.mysql.com/bug.php?id=31312 + use prefix && mysqld_options+=( "--defaults-file='${MY_SYSCONFDIR}/my.cnf'" ) + + # Figure out which options we need to disable to do the setup + local helpfile="${TMPDIR}/mysqld-help" + "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null + + local opt optexp optfull + for opt in host-cache name-resolve networking slave-start \ + federated ssl log-bin relay-log slow-query-log external-locking \ + log-slave-updates \ + ; do + optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}" + egrep -sq -- "${optexp}" "${helpfile}" && mysqld_options+=( "${optfull}" ) + done + + # Prepare timezones, see + # https://dev.mysql.com/doc/mysql/en/time-zone-support.html + local tz_sql="$(_mktemp_dry "${MYSQL_TMPDIR}/tz.XXXXXXXXX.sql")" + [[ -z "${tz_sql}" ]] \ + && die "_mktemp_dry() for '${MYSQL_TMPDIR}/tz.XXXXXXXXX.sql' failed!" + + echo "USE mysql;" >"${tz_sql}" + "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" >> "${tz_sql}" 2>/dev/null + if [[ $? -ne 0 ]] ; then + die "mysql_tzinfo_to_sql failed!" + fi + + # --initialize-insecure will not set root password + # --initialize would set a random one in the log which we don't need as we set it ourselves + local cmd=( + "${mysqld_binary}" + "${mysqld_options[@]}" + "--initialize-insecure" + "--init-file='${tz_sql}'" + "--basedir='${EROOT}/usr'" + "--datadir='${MY_DATADIR}'" + "--tmpdir='${MYSQL_TMPDIR}'" + "--log-error='${mysql_install_log}'" + "--user=${MYSQL_USER}" + ) + + einfo "Initializing ${PN} data directory: ${cmd[@]}" + eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1 + + if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql.ibd" ]] ; then + grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_install_log}" 1>&2 + die "Failed to initialize ${PN} data directory. Please review '${mysql_install_log}'!" + fi + + rm "${tz_sql}" || die + + local x=${RANDOM} + local socket="${EROOT}${PID_DIR}/mysqld${x}.sock" + local pidfile="${EROOT}${PID_DIR}/mysqld${x}.pid" + unset x + + cmd=( + "${mysqld_binary}" + "${mysqld_options[@]}" + "--basedir='${EROOT}/usr'" + "--datadir='${MY_DATADIR}'" + "--tmpdir='${MYSQL_TMPDIR}'" + --max_allowed_packet=8M + --net_buffer_length=16K + "--socket='${socket}'" + "--pid-file='${pidfile}'" + "--log-error='${mysqld_logfile}'" + "--user=${MYSQL_USER}" + ) + + einfo "Starting mysqld to finalize initialization: ${cmd[@]}" + eval "${cmd[@]}" >>"${mysqld_logfile}" 2>&1 & + + echo -n "Waiting for mysqld to accept connections " + local maxtry=15 + while [[ ! -S "${socket}" && "${maxtry}" -gt 1 ]] ; do + maxtry=$((${maxtry}-1)) + echo -n "." + sleep 1 + done + + if [[ -S "${socket}" ]] ; then + # Even with a socket we don't know if mysqld will abort + # start due to an error so just wait a little bit more... + maxtry=5 + while [[ -S "${socket}" && "${maxtry}" -gt 1 ]] ; do + maxtry=$((${maxtry}-1)) + echo -n "." + sleep 1 + done + fi + + echo + + if [[ ! -S "${socket}" ]] ; then + grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysqld_logfile}" 1>&2 + die "mysqld was unable to start from initialized data directory. Please review '${mysqld_logfile}'!" + fi + + local mysql_logfile="${TMPDIR}/set_root_pw.log" + touch "${mysql_logfile}" || die + + ebegin "Setting root password" + # Do this from memory, as we don't want clear text passwords in temp files + local sql="ALTER USER 'root'@'localhost' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}'" + cmd=( + "${mysql_binary}" + --no-defaults + "--socket='${socket}'" + -hlocalhost + "-e \"${sql}\"" + ) + eval "${cmd[@]}" >"${mysql_logfile}" 2>&1 + local rc=$? + eend ${rc} + + if [[ ${rc} -ne 0 ]] ; then + # Poor man's solution which tries to avoid having password + # in log. NOTE: sed can fail if user didn't follow advice + # and included character which will require escaping... + sed -i -e "s/${MYSQL_ROOT_PASSWORD}/*****/" "${mysql_logfile}" 2>/dev/null + + grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_logfile}" + die "Failed to set ${PN} root password. Please review '${mysql_logfile}'!" + fi + + # Stop the server + if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then + echo -n "Stopping the server " + pkill -F "${pidfile}" &>/dev/null + + maxtry=10 + while [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; do + maxtry=$((${maxtry}-1)) + echo -n "." + sleep 1 + done + + echo + + if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then + # We somehow failed to stop server. + # However, not a fatal error. Just warn the user. + ewarn "WARNING: mysqld[$(cat "${pidfile}")] is still running!" + fi + fi + + einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!" +} diff --git a/dev-db/percona-server/percona-server-8.0.25.15.ebuild b/dev-db/percona-server/percona-server-8.0.25.15.ebuild deleted file mode 100644 index a6db5af0b52e..000000000000 --- a/dev-db/percona-server/percona-server-8.0.25.15.ebuild +++ /dev/null @@ -1,1273 +0,0 @@ -# Copyright 1999-2021 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI="7" - -CMAKE_MAKEFILE_GENERATOR=emake - -inherit check-reqs cmake flag-o-matic linux-info \ - multiprocessing prefix toolchain-funcs - -MY_BOOST_VERSION="1.73.0" -MY_PV=$(ver_rs 3 '-') -MY_PV="${MY_PV//_pre*}" -MY_PN="Percona-Server" -MY_P="${PN}-${MY_PV}" -MY_MAJOR_PV=$(ver_cut 1-2) -MY_RELEASE_NOTES_URI="https://www.percona.com/doc/percona-server/${MY_MAJOR_PV}/" - -# Patch version -PATCH_SET="https://dev.gentoo.org/~whissi/dist/percona-server/${PN}-8.0.25.15-patches-01.tar.xz" - -SRC_URI="https://www.percona.com/downloads/${MY_PN}-${MY_MAJOR_PV}/${MY_PN}-${MY_PV}/source/tarball/${PN}-${MY_PV}.tar.gz - https://dl.bintray.com/boostorg/release/${MY_BOOST_VERSION}/source/boost_$(ver_rs 1- _ ${MY_BOOST_VERSION}).tar.bz2 - ${PATCH_SET} -" - -HOMEPAGE="https://www.percona.com/software/mysql-database/percona-server https://github.com/percona/percona-server" -DESCRIPTION="Fully compatible, enhanced and open source drop-in replacement for MySQL" -LICENSE="GPL-2" -SLOT="8.0" -IUSE="cjk cracklib debug jemalloc latin1 ldap numa pam +perl profiling - rocksdb router selinux +server tcmalloc test tokudb tokudb-backup-plugin" - -RESTRICT="!test? ( test )" - -REQUIRED_USE="?? ( tcmalloc jemalloc ) - cjk? ( server ) - jemalloc? ( server ) - numa? ( server ) - profiling? ( server ) - router? ( server ) - tcmalloc? ( server )" - -KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 -riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris ~x86-solaris" - -# Shorten the path because the socket path length must be shorter than 107 chars -# and we will run a mysql server during test phase -S="${WORKDIR}/mysql" - -# Be warned, *DEPEND are version-dependant -# These are used for both runtime and compiletime -COMMON_DEPEND=" - >=app-arch/lz4-0_p131:= - app-arch/zstd:= - sys-libs/ncurses:0= - >=sys-libs/zlib-1.2.3:0= - >=dev-libs/openssl-1.0.0:0= - server? ( - dev-libs/icu:= - dev-libs/libevent:=[ssl,threads] - >=dev-libs/protobuf-3.8:= - net-libs/libtirpc:= - net-misc/curl:= - cjk? ( app-text/mecab:= ) - ldap? ( - dev-libs/cyrus-sasl - net-nds/openldap - ) - jemalloc? ( dev-libs/jemalloc:0= ) - kernel_linux? ( - dev-libs/libaio:0= - sys-process/procps:0= - ) - numa? ( sys-process/numactl ) - pam? ( sys-libs/pam:0= ) - tcmalloc? ( dev-util/google-perftools:0= ) - ) -" -DEPEND="${COMMON_DEPEND} - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) - virtual/yacc - server? ( net-libs/rpcsvc-proto ) - test? ( - acct-group/mysql acct-user/mysql - dev-perl/JSON - ) -" -RDEPEND="${COMMON_DEPEND} - !dev-db/mariadb !dev-db/mariadb-galera !dev-db/mysql !dev-db/mysql-cluster - !dev-db/percona-server:0 - !dev-db/percona-server:5.7 - selinux? ( sec-policy/selinux-mysql ) - !prefix? ( - acct-group/mysql acct-user/mysql - dev-db/mysql-init-scripts - ) -" -# For other stuff to bring us in -# dev-perl/DBD-mysql is needed by some scripts installed by MySQL -PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )" - -mysql_init_vars() { - : ${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mysql"} - : ${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"} - : ${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"} - : ${MY_LOGDIR="${EPREFIX}/var/log/mysql"} - MY_DATADIR="${MY_LOCALSTATEDIR}" - - export MY_SHAREDSTATEDIR MY_SYSCONFDIR - export MY_LOCALSTATEDIR MY_LOGDIR - export MY_DATADIR -} - -pkg_pretend() { - if [[ ${MERGE_TYPE} != binary ]] ; then - if use server ; then - CHECKREQS_DISK_BUILD="3G" - - if has test $FEATURES ; then - CHECKREQS_DISK_BUILD="9G" - fi - - check-reqs_pkg_pretend - fi - fi -} - -pkg_setup() { - if [[ ${MERGE_TYPE} != binary ]] ; then - CHECKREQS_DISK_BUILD="3G" - - if has test ${FEATURES} ; then - CHECKREQS_DISK_BUILD="9G" - - # Bug #213475 - MySQL _will_ object strenuously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if ! has userpriv ${FEATURES} ; then - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." - fi - - local aio_max_nr=$(sysctl -n fs.aio-max-nr 2>/dev/null) - [[ -z "${aio_max_nr}" || ${aio_max_nr} -lt 250000 ]] \ - && die "FEATURES=test will require fs.aio-max-nr=250000 at minimum!" - - if use latin1 ; then - # Upstream only supports tests with default charset - die "Testing with USE=latin1 is not supported." - fi - fi - - if use kernel_linux ; then - if use numa ; then - linux-info_get_any_version - - local CONFIG_CHECK="~NUMA" - - local WARNING_NUMA="This package expects NUMA support in kernel which this system does not have at the moment;" - WARNING_NUMA+=" Either expect runtime errors, enable NUMA support in kernel or rebuild the package without NUMA support" - - check_extra_config - fi - fi - - use server && check-reqs_pkg_setup - fi -} - -src_unpack() { - unpack ${A} - - mv -f "${WORKDIR}/${MY_P}" "${S}" || die -} - -src_prepare() { - eapply "${WORKDIR}"/mysql-patches - - # Avoid rpm call which would trigger sandbox, #692368 - sed -i \ - -e 's/MY_RPM rpm/MY_RPM rpmNOTEXISTENT/' \ - CMakeLists.txt || die - - if use jemalloc ; then - echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" || die - fi - - if use tcmalloc ; then - echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" || die - fi - - # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux - if [[ -d "${S}/support-files/SELinux" ]] ; then - echo > "${S}/support-files/SELinux/CMakeLists.txt" || die - fi - - # Remove man pages for client-lib tools we don't install - rm \ - man/my_print_defaults.1 \ - man/perror.1 \ - man/zlib_decompress.1 \ - || die - - cmake_src_prepare -} - -src_configure() { - # Bug #114895, bug #110149 - filter-flags "-O" "-O[01]" - - append-cxxflags -felide-constructors - - # code is not C++17 ready, bug #786402 - append-cxxflags -std=c++14 - - # bug #283926, with GCC4.4, this is required to get correct behavior. - append-flags -fno-strict-aliasing - - CMAKE_BUILD_TYPE="RelWithDebInfo" - - # debug hack wrt #497532 - mycmakeargs=( - -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" - -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" - -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql" - -DSYSCONFDIR="${EPREFIX}/etc/mysql" - -DINSTALL_BINDIR=bin - -DINSTALL_DOCDIR=share/doc/${PF} - -DINSTALL_DOCREADMEDIR=share/doc/${PF} - -DINSTALL_INCLUDEDIR=include/mysql - -DINSTALL_INFODIR=share/info - -DINSTALL_LIBDIR=$(get_libdir) - -DINSTALL_MANDIR=share/man - -DINSTALL_MYSQLSHAREDIR=share/mysql - -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" - -DINSTALL_SBINDIR=sbin - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mysql" - -DCOMPILATION_COMMENT="Gentoo Linux ${PF}" - -DWITH_UNIT_TESTS=$(usex test ON OFF) - # Using bundled editline to get CTRL+C working - -DWITH_EDITLINE=bundled - -DWITH_ZLIB=system - -DWITH_SSL=system - -DWITH_LIBWRAP=0 - -DENABLED_LOCAL_INFILE=1 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DWITH_DEFAULT_COMPILER_OPTIONS=0 - # The build forces this to be defined when cross-compiling. We pass it - # all the time for simplicity and to make sure it is actually correct. - -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1) - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DWITH_CURL=system - -DWITH_BOOST="${WORKDIR}/boost_$(ver_rs 1- _ ${MY_BOOST_VERSION})" - -DWITH_ROUTER=$(usex router ON OFF) - ) - - if is-flagq -fno-lto ; then - einfo "LTO disabled via {C,CXX,F,FC}FLAGS" - mycmakeargs+=( -DWITH_LTO=OFF ) - elif is-flagq -flto ; then - einfo "LTO forced via {C,CXX,F,FC}FLAGS" - myconf+=( -DWITH_LTO=ON ) - else - # Disable automagic - myconf+=( -DWITH_LTO=OFF ) - fi - - if use test ; then - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test ) - else - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) - fi - - mycmakeargs+=( -DWITHOUT_CLIENTLIBS=YES ) - - mycmakeargs+=( - -DWITH_ICU=system - -DWITH_LZ4=system - # Our dev-libs/rapidjson doesn't carry necessary fixes for std::regex - -DWITH_RAPIDJSON=bundled - -DWITH_ZSTD=system - ) - - if [[ -n "${MYSQL_DEFAULT_CHARSET}" && -n "${MYSQL_DEFAULT_COLLATION}" ]] ; then - ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}" - ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}." - ewarn "You MUST file bugs without these variables set." - ewarn "Tests will probably fail!" - - mycmakeargs+=( - -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET} - -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION} - ) - elif use latin1 ; then - mycmakeargs+=( - -DDEFAULT_CHARSET=latin1 - -DDEFAULT_COLLATION=latin1_swedish_ci - ) - else - mycmakeargs+=( - -DDEFAULT_CHARSET=utf8mb4 - -DDEFAULT_COLLATION=utf8mb4_0900_ai_ci - ) - fi - - if use server ; then - mycmakeargs+=( - -DWITH_AUTHENTICATION_LDAP=$(usex ldap system OFF) - -DWITH_COREDUMPER=OFF - -DWITH_EXTRA_CHARSETS=all - -DWITH_DEBUG=$(usex debug) - -DWITH_MECAB=$(usex cjk system OFF) - -DWITH_LIBEVENT=system - -DWITH_PROTOBUF=system - -DWITH_NUMA=$(usex numa ON OFF) - -DWITH_PAM=$(usex pam) - ) - - if use profiling ; then - # Setting to OFF doesn't work: Once set, profiling options will be added - # to `mysqld --help` output via sql/sys_vars.cc causing - # "main.mysqld--help-notwin" test to fail - mycmakeargs+=( -DENABLED_PROFILING=ON ) - fi - - # Storage engines - mycmakeargs+=( - -DWITH_EXAMPLE_STORAGE_ENGINE=0 - -DWITH_ARCHIVE_STORAGE_ENGINE=1 - -DWITH_BLACKHOLE_STORAGE_ENGINE=1 - -DWITH_CSV_STORAGE_ENGINE=1 - -DWITH_FEDERATED_STORAGE_ENGINE=1 - -DWITH_HEAP_STORAGE_ENGINE=1 - -DWITH_INNOBASE_STORAGE_ENGINE=1 - -DWITH_INNODB_MEMCACHED=0 - -DWITH_MYISAMMRG_STORAGE_ENGINE=1 - -DWITH_MYISAM_STORAGE_ENGINE=1 - -DWITH_ROCKSDB=$(usex rocksdb 1 0) - -DWITH_TOKUDB=$(usex tokudb 1 0) - ) - else - mycmakeargs+=( - -DWITHOUT_SERVER=1 - -DWITH_SYSTEMD=no - ) - fi - - cmake_src_configure -} - -# Official test instructions: -# ulimit -n 16500 && \ -# USE='perl server' \ -# FEATURES='test userpriv' \ -# ebuild mysql-X.X.XX.ebuild \ -# digest clean package -src_test() { - _disable_test() { - local rawtestname bug reason - rawtestname="${1}" ; shift - bug="${1}" ; shift - reason="${@}" - ewarn "test '${rawtestname}' disabled: '${reason}' (BUG#${bug})" - echo ${rawtestname} : BUG#${bug} ${reason} >> "${T}/disabled.def" - } - - local TESTDIR="${BUILD_DIR}/mysql-test" - local retstatus_unit - local retstatus_tests - - # Run CTest (test-units) - cmake_src_test - retstatus_unit=$? - - # Ensure that parallel runs don't die - export MTR_BUILD_THREAD="$((${RANDOM} % 100))" - - if [[ -z "${MTR_PARALLEL}" ]] ; then - local -x MTR_PARALLEL=$(makeopts_jobs) - - if [[ ${MTR_PARALLEL} -gt 4 ]] ; then - # Running multiple tests in parallel usually require higher ulimit - # and fs.aio-max-nr setting. In addition, tests like main.multi_update - # are known to hit timeout when system is busy. - # To avoid test failure we will limit MTR_PARALLEL to 4 instead of - # using "auto". - local info_msg="Parallel MySQL test suite jobs limited to 4 (MAKEOPTS=${MTR_PARALLEL})" - info_msg+=" to avoid test failures. Set MTR_PARALLEL if you know what you are doing!" - einfo "${info_msg}" - unset info_msg - MTR_PARALLEL=4 - fi - else - einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" - fi - - # create directories because mysqladmin might run out of order - mkdir -p "${T}"/var-tests{,/log} || die - - # Run mysql tests - pushd "${TESTDIR}" &>/dev/null || die - - touch "${T}/disabled.def" - - local -a disabled_tests - disabled_tests+=( "auth_sec.atomic_rename_user;103512;Depends on user running test" ) - disabled_tests+=( "auth_sec.keyring_file_data_qa;0;Won't work with user privileges" ) - disabled_tests+=( "gis.geometry_class_attri_prop;5452;Known rounding error with latest AMD processors (PS)" ) - disabled_tests+=( "gis.geometry_property_function_issimple;5452;Known rounding error with latest AMD processors (PS)" ) - disabled_tests+=( "gis.gis_bugs_crashes;5452;Known rounding error with latest AMD processors (PS)" ) - disabled_tests+=( "gis.spatial_analysis_functions_buffer;5452;Known rounding error with latest AMD processors (PS)" ) - disabled_tests+=( "gis.spatial_analysis_functions_centroid;5452;Known rounding error with latest AMD processors (PS)" ) - disabled_tests+=( "gis.spatial_analysis_functions_distance;5452;Known rounding error with latest AMD processors (PS)" ) - disabled_tests+=( "gis.spatial_op_testingfunc_mix;5452;Known rounding error with latest AMD processors (PS)" ) - disabled_tests+=( "gis.spatial_operators_intersection;5452;Known rounding error with latest AMD processors (PS)" ) - disabled_tests+=( "gis.spatial_utility_function_distance_sphere;5452;Known rounding error with latest AMD processors (PS)" ) - disabled_tests+=( "gis.spatial_utility_function_simplify;5452;Known rounding error with latest AMD processors (PS)" ) - disabled_tests+=( "group_replication.gr_ssl_options2;0;Sporadic failing test" ) - disabled_tests+=( "innodb.alter_kill;0;Known test failure -- no upstream bug yet" ) - disabled_tests+=( "innodb.percona_changed_page_bmp_flush;6807;False positive on Gentoo (PS)" ) - disabled_tests+=( "innodb.percona_changed_page_bmp_log_resize;0;Sporadic failing test" ) - disabled_tests+=( "innodb.percona_log_encrypt_change_mk;6039;False positive on Gentoo (PS)" ) - disabled_tests+=( "innodb.percona_log_encrypt_change_rk;6805;False positive on Gentoo (PS)" ) - disabled_tests+=( "innodb.percona_log_encrypt_failure;0;Requires proper keyring setup" ) - disabled_tests+=( "innodb.upgrade_orphan;0;Sporadic failing test" ) - disabled_tests+=( "main.coredump;0;Known test failure" ) - disabled_tests+=( "main.derived_limit;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) - disabled_tests+=( "main.explain_tree;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) - disabled_tests+=( "main.myisam-blob;0;Sporadic failing test" ) - disabled_tests+=( "main.mysql_load_data_local_dir;7416;Known test failure" ) - disabled_tests+=( "main.mysqlpump_basic_lz4;6042;Extra tool output causes false positive" ) - disabled_tests+=( "main.ssl_bug75311;5996;Known test failure" ) - disabled_tests+=( "main.ssl_san;6808;False positive on IPv6-enabled hosts" ) - disabled_tests+=( "main.subquery_bugs;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) - disabled_tests+=( "main.subquery_sj_dupsweed;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) - disabled_tests+=( "main.subquery_sj_dupsweed_bka;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) - disabled_tests+=( "main.subquery_sj_dupsweed_bka_nobnl;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) - disabled_tests+=( "main.subquery_sj_firstmatch;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) - disabled_tests+=( "main.subquery_sj_firstmatch_bka;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) - disabled_tests+=( "main.subquery_sj_firstmatch_bka_nobnl;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) - disabled_tests+=( "main.subquery_sj_mat_bka_nobnl;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) - disabled_tests+=( "main.window_std_var;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) - disabled_tests+=( "main.window_std_var_optimized;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) - disabled_tests+=( "main.with_recursive;6804;Known rounding error with latest AMD processors" ) - disabled_tests+=( "rpl_gtid.rpl_gtid_stm_drop_table;90612;Known test failure" ) - disabled_tests+=( "rpl_gtid.rpl_multi_source_mtr_includes;0;Know failure - no upstream bug yet" ) - disabled_tests+=( "sys_vars.innodb_sys_tablespace_encrypt_basic;7415;Known test failure" ) - disabled_tests+=( "sys_vars.myisam_data_pointer_size_func;87935;Test will fail on slow hardware" ) - disabled_tests+=( "x.message_compressed_payload;0;False positive caused by protobuff-3.11+" ) - disabled_tests+=( "x.message_protobuf_nested;6803;False positive caused by protobuff-3.11+" ) - - if ! hash zip 1>/dev/null 2>&1 ; then - # no need to force dep app-arch/zip for one test - disabled_tests+=( "innodb.discarded_partition_create;0;Requires app-arch/zip" ) - disabled_tests+=( "innodb.partition_upgrade_create;0;Requires app-arch/zip" ) - fi - - if has_version ">=dev-libs/openssl-3" ; then - # >=dev-libs/openssl-3 defaults to security level 1 which disallow - # TLSv1/1.1 but tests will require TLSv1/1.1. - einfo "Set OpenSSL configuration for test suite ..." - cat > "${T}/openssl_tlsv1.cnf" <<- EOF || die - openssl_conf = default_conf - - [ req ] - default_bits = 2048 - default_keyfile = privkey.pem - distinguished_name = req_distinguished_name - - [ req_distinguished_name ] - countryName = Country Name (2 letter code) - countryName_default = AU - countryName_min = 2 - countryName_max = 2 - - stateOrProvinceName = State or Province Name (full name) - stateOrProvinceName_default = Some-State - - localityName = Locality Name (eg, city) - - 0.organizationName = Organization Name (eg, company) - 0.organizationName_default = Internet Widgits Pty Ltd - - organizationalUnitName = Organizational Unit Name (eg, section) - - commonName = Common Name (e.g. server FQDN or YOUR name) - commonName_max = 64 - - emailAddress = Email Address - emailAddress_max = 64 - - [default_conf] - ssl_conf = ssl_sect - - [ssl_sect] - system_default = system_default_sect - - [system_default_sect] - CipherString = DEFAULT@SECLEVEL=0 - EOF - - local -x OPENSSL_CONF="${T}/openssl_tlsv1.cnf" - - disabled_tests+=( "x.connection_tls_version;0;Not compatible with OpenSSL 3.x error messages" ) - fi - - local test_infos_str test_infos_arr - for test_infos_str in "${disabled_tests[@]}" ; do - IFS=';' read -r -a test_infos_arr <<< "${test_infos_str}" - - if [[ ${#test_infos_arr[@]} != 3 ]] ; then - die "Invalid test data set, not matching format: ${test_infos_str}" - fi - - _disable_test "${test_infos_arr[0]}" "${test_infos_arr[1]}" "${test_infos_arr[2]}" - done - unset test_infos_str test_infos_arr - - if [[ -z "${MTR_VAULT_TOKEN}" ]] ; then - local impossible_test - for impossible_test in \ - encryption.default_table_encryption_var \ - keyring_vault.innodb_online_alter_encryption \ - keyring_vault.innodb_row_log_encryption \ - keyring_vault.install_keyring_vault \ - keyring_vault.keyring_udf \ - keyring_vault.keyring_vault_config \ - keyring_vault.keyring_vault_config_qa \ - keyring_vault.keyring_vault_timeout \ - keyring_vault.key_rotation_qa \ - keyring_vault.rpl_key_rotation \ - keyring_vault.table_encrypt_2 \ - keyring_vault.table_encrypt_2_directory \ - keyring_vault.table_encrypt_2_keyring \ - keyring_vault.table_encrypt_5 \ - keyring_vault.table_encrypt_5_directory \ - keyring_vault.table_encrypt_kill \ - keyring_vault.temp_table_encrypt_keyring_vault \ - main.persisted_variables \ - ; do - _disable_test "${impossible_test}" "0" "MTR_VAULT_TOKEN is not set" - done - fi - - # Try to increase file limits to increase test coverage - if ! ulimit -n 16500 1>/dev/null 2>&1 ; then - # Upper limit comes from parts.partition_* tests - ewarn "For maximum test coverage please raise open file limit to 16500 (ulimit -n 16500) before calling the package manager." - - if ! ulimit -n 4162 1>/dev/null 2>&1 ; then - # Medium limit comes from '[Warning] Buffered warning: Could not increase number of max_open_files to more than 3000 (request: 4162)' - ewarn "For medium test coverage please raise open file limit to 4162 (ulimit -n 4162) before calling the package manager." - - if ! ulimit -n 3000 1>/dev/null 2>&1 ; then - ewarn "For minimum test coverage please raise open file limit to 3000 (ulimit -n 3000) before calling the package manager." - else - einfo "Will run test suite with open file limit set to 3000 (minimum test coverage)." - fi - else - einfo "Will run test suite with open file limit set to 4162 (medium test coverage)." - fi - else - einfo "Will run test suite with open file limit set to 16500 (best test coverage)." - fi - - # run mysql-test tests - perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def" - retstatus_tests=$? - - popd &>/dev/null || die - - # Cleanup is important for these testcases. - pkill -9 -f "${S}/ndb" 2>/dev/null - pkill -9 -f "${S}/sql" 2>/dev/null - - local failures="" - [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit" - [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests" - - [[ -z "$failures" ]] || die "Test failures: $failures" - einfo "Tests successfully completed" -} - -src_install() { - cmake_src_install - - # Make sure the vars are correctly initialized - mysql_init_vars - - # Convenience links - einfo "Making Convenience links for mysqlcheck multi-call binary" - dosym "mysqlcheck" "/usr/bin/mysqlanalyze" - dosym "mysqlcheck" "/usr/bin/mysqlrepair" - dosym "mysqlcheck" "/usr/bin/mysqloptimize" - - # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir - if [[ -d "${ED}/usr/data" ]] ; then - rm -Rf "${ED}/usr/data" || die - fi - - # Unless they explicitly specific USE=test, then do not install the - # testsuite. It DOES have a use to be installed, esp. when you want to do a - # validation of your database configuration after tuning it. - if ! use test ; then - rm -rf "${ED}/${MY_SHAREDSTATEDIR#${EPREFIX}}/mysql-test" - fi - - # Configuration stuff - einfo "Building default configuration ..." - insinto "${MY_SYSCONFDIR#${EPREFIX}}" - [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf - cp "${FILESDIR}/my.cnf-5.7" "${TMPDIR}/my.cnf" || die - eprefixify "${TMPDIR}/my.cnf" - doins "${TMPDIR}/my.cnf" - insinto "${MY_SYSCONFDIR#${EPREFIX}}/mysql.d" - cp "${FILESDIR}/my.cnf-8.0.distro-client" "${TMPDIR}/50-distro-client.cnf" || die - eprefixify "${TMPDIR}/50-distro-client.cnf" - doins "${TMPDIR}/50-distro-client.cnf" - - mycnf_src="my.cnf-8.0.distro-server" - sed -e "s!@DATADIR@!${MY_DATADIR}!g" \ - "${FILESDIR}/${mycnf_src}" \ - > "${TMPDIR}/my.cnf.ok" || die - - if use prefix ; then - sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \ - "${TMPDIR}/my.cnf.ok" || die - fi - - if use latin1 ; then - sed -i \ - -e "/character-set/s|utf8mb4|latin1|g" \ - "${TMPDIR}/my.cnf.ok" || die - fi - - eprefixify "${TMPDIR}/my.cnf.ok" - - newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf - - #Remove mytop if perl is not selected - [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop" - - if use router ; then - rm -rf \ - "${ED}/usr/LICENSE.router" \ - "${ED}/usr/README.router" \ - "${ED}/usr/run" \ - "${ED}/usr/var" \ - || die - fi - - # Kill old libmysqclient_r symlinks if they exist. Time to fix what depends on them. - find "${D}" -name 'libmysqlclient_r.*' -type l -delete || die -} - -pkg_postinst() { - # Make sure the vars are correctly initialized - mysql_init_vars - - # Create log directory securely if it does not exist - # NOTE: $MY_LOGDIR contains $EPREFIX by default - [[ -d "${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${MY_LOGDIR}" - - # Note about configuration change - einfo - elog "This version of ${PN} reorganizes the configuration from a single my.cnf" - elog "to several files in /etc/mysql/mysql.d." - elog "Please backup any changes you made to /etc/mysql/my.cnf" - elog "and add them as a new file under /etc/mysql/mysql.d with a .cnf extension." - elog "You may have as many files as needed and they are read alphabetically." - elog "Be sure the options have the appropriate section headers, i.e. [mysqld]." - einfo - - if [[ -z "${REPLACING_VERSIONS}" ]] ; then - einfo - elog "You might want to run:" - elog " \"emerge --config =${CATEGORY}/${PF}\"" - elog "if this is a new install." - einfo - else - einfo - elog "Upgrade process for ${PN}-8.x has changed. Please read" - elog "https://dev.mysql.com/doc/refman/8.0/en/upgrade-binary-package.html" - einfo - fi -} - -pkg_config() { - _getoptval() { - local section="$1" - local flag="--${2}=" - local extra_options="${3}" - local cmd=( - "${my_print_defaults_binary}" - "${extra_options}" - "${section}" - ) - local results=( $(eval "${cmd[@]}" 2>/dev/null | sed -n "/^${flag}/s,${flag},,gp") ) - - if [[ ${#results[@]} -gt 0 ]] ; then - # When option is set multiple times only return last value - echo "${results[-1]}" - fi - } - - _mktemp_dry() { - # emktemp has no --dry-run option - local template="${1}" - - if [[ -z "${template}" ]] ; then - if [[ -z "${T}" ]] ; then - template="/tmp/XXXXXXX" - else - template="${T}/XXXXXXX" - fi - fi - - local template_wo_X=${template//X/} - local n_X - let n_X=${#template}-${#template_wo_X} - if [[ ${n_X} -lt 3 ]] ; then - echo "${FUNCNAME[0]}: too few X's in template ‘${template}’" >&2 - return - fi - - local attempts=0 - local character tmpfile - while [[ true ]] ; do - let attempts=attempts+1 - - new_file= - while read -n1 character ; do - if [[ "${character}" == "X" ]] ; then - tmpfile+="${RANDOM:0:1}" - else - tmpfile+="${character}" - fi - done < <(echo -n "${template}") - - if [[ ! -f "${tmpfile}" ]] - then - echo "${tmpfile}" - return - fi - - if [[ ${attempts} -ge 100 ]] ; then - echo "${FUNCNAME[0]}: Cannot create temporary file after 100 attempts." >&2 - return - fi - done - } - - local mysqld_binary="${EROOT}/usr/sbin/mysqld" - if [[ ! -x "${mysqld_binary}" ]] ; then - die "'${mysqld_binary}' not found! Please re-install ${CATEGORY}/${PN}!" - fi - - local mysql_binary="${EROOT}/usr/bin/mysql" - if [[ ! -x "${mysql_binary}" ]] ; then - die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!" - fi - - local my_print_defaults_binary="${EROOT}/usr/bin/my_print_defaults" - if [[ ! -x "${my_print_defaults_binary}" ]] ; then - die "'${my_print_defaults_binary}' not found! Please re-install dev-db/mysql-connector-c!" - fi - - if [[ -z "${MYSQL_USER}" ]] ; then - MYSQL_USER=mysql - if use prefix ; then - MYSQL_USER=$(id -u -n 2>/dev/null) - if [[ -z "${MYSQL_USER}" ]] ; then - die "Failed to determine current username!" - fi - fi - fi - - if [[ -z "${MYSQL_GROUP}" ]] ; then - MYSQL_GROUP=mysql - if use prefix ; then - MYSQL_GROUP=$(id -g -n 2>/dev/null) - if [[ -z "${MYSQL_GROUP}" ]] ; then - die "Failed to determine current user groupname!" - fi - fi - fi - - # my_print_defaults needs to read stuff in $HOME/.my.cnf - local -x HOME="${EROOT}/root" - - # Make sure the vars are correctly initialized - mysql_init_vars - - # Read currently set data directory - MY_DATADIR="$(_getoptval mysqld datadir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" - - # Bug #213475 - MySQL _will_ object strenously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if [[ -z "${MY_DATADIR}" ]] ; then - die "Sorry, unable to find MY_DATADIR!" - elif [[ -d "${MY_DATADIR}/mysql" ]] ; then - ewarn "Looks like your data directory '${MY_DATADIR}' is already initialized!" - ewarn "Please rename or delete its content if you wish to initialize a new data directory." - die "${PN} data directory at '${MY_DATADIR}' looks already initialized!" - fi - - MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" - MYSQL_TMPDIR=${MYSQL_TMPDIR%/} - # These are dir+prefix - MYSQL_LOG_BIN="$(_getoptval mysqld log-bin "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" - MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} - MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" - MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} - - # Create missing directories. - # Always check if mysql user can write to directory even if we just - # created directory because a parent directory might be not - # accessible for that user. - PID_DIR="${EROOT}/run/mysqld" - if [[ ! -d "${PID_DIR}" ]] ; then - einfo "Creating ${PN} PID directory '${PID_DIR}' ..." - install -d -m 755 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${PID_DIR}" \ - || die "Failed to create PID directory '${PID_DIR}'!" - fi - - local _pid_dir_testfile="$(_mktemp_dry "${PID_DIR}/.pkg_config-access-test.XXXXXXXXX")" - [[ -z "${_pid_dir_testfile}" ]] \ - && die "_mktemp_dry() for '${PID_DIR}/.pkg_config-access-test.XXXXXXXXX' failed!" - - if use prefix ; then - touch "${_pid_dir_testfile}" &>/dev/null - else - su -s /bin/sh -c "touch ${_pid_dir_testfile}" ${MYSQL_USER} &>/dev/null - fi - - if [[ $? -ne 0 ]] ; then - die "${MYSQL_USER} user cannot write into PID dir '${PID_DIR}'!" - else - rm "${_pid_dir_testfile}" || die - unset _pid_dir_testfile - fi - - if [[ ! -d "${MY_DATADIR}" ]] ; then - einfo "Creating ${PN} data directory '${MY_DATADIR}' ..." - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MY_DATADIR}" \ - || die "Failed to create ${PN} data directory '${MY_DATADIR}'!" - fi - - local _my_datadir_testfile="$(_mktemp_dry "${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX")" - [[ -z "${_my_datadir_testfile}" ]] \ - && die "_mktemp_dry() for '${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX' failed!" - - if use prefix ; then - touch "${_my_datadir_testfile}" &>/dev/null - else - su -s /bin/sh -c "touch ${_my_datadir_testfile}" ${MYSQL_USER} &>/dev/null - fi - - if [[ $? -ne 0 ]] ; then - die "${MYSQL_USER} user cannot write into data directory '${MY_DATADIR}'!" - else - rm "${_my_datadir_testfile}" || die - unset _my_datadir_testfile - fi - - if [[ -n "${MYSQL_TMPDIR}" && ! -d "${MYSQL_TMPDIR}" ]] ; then - einfo "Creating ${PN} tmpdir '${MYSQL_TMPDIR}' ..." - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_TMPDIR}" \ - || die "Failed to create ${PN} tmpdir '${MYSQL_TMPDIR}'!" - fi - - if [[ -z "${MYSQL_TMPDIR}" ]] ; then - MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")" - [[ -z "${MYSQL_TMPDIR}" ]] \ - && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!" - - mkdir "${MYSQL_TMPDIR}" || die - chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die - fi - - # Now we need to test MYSQL_TMPDIR... - local _my_tmpdir_testfile="$(_mktemp_dry "${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX")" - [[ -z "${_my_tmpdir_testfile}" ]] \ - && die "_mktemp_dry() for '${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX' failed!" - - if use prefix ; then - touch "${_my_tmpdir_testfile}" &>/dev/null - else - su -s /bin/sh -c "touch ${_my_tmpdir_testfile}" ${MYSQL_USER} &>/dev/null - fi - - if [[ $? -ne 0 ]] ; then - die "${MYSQL_USER} user cannot write into tmpdir '${MYSQL_TMPDIR}'!" - else - rm "${_my_tmpdir_testfile}" || die - unset _my_tmpdir_testfile - fi - - if [[ -n "${MYSQL_LOG_BIN}" && ! -d "${MYSQL_LOG_BIN}" ]] ; then - einfo "Creating ${PN} log-bin directory '${MYSQL_LOG_BIN}' ..." - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_LOG_BIN}" \ - || die "Failed to create ${PN} log-bin directory '${MYSQL_LOG_BIN}'" - fi - - if [[ -n "${MYSQL_LOG_BIN}" ]] ; then - local _my_logbin_testfile="$(_mktemp_dry "${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX")" - [[ -z "${_my_logbin_testfile}" ]] \ - && die "_mktemp_dry() for '${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX' failed!" - - if use prefix ; then - touch "${_my_logbin_testfile}" &>/dev/null - else - su -s /bin/sh -c "touch ${_my_logbin_testfile}" ${MYSQL_USER} &>/dev/null - fi - - if [[ $? -ne 0 ]] ; then - die "${MYSQL_USER} user cannot write into log-bin directory '${MYSQL_LOG_BIN}'!" - else - rm "${_my_logbin_testfile}" || die - unset _my_logbin_testfile - fi - fi - - if [[ -n "${MYSQL_RELAY_LOG}" && ! -d "${MYSQL_RELAY_LOG}" ]] ; then - einfo "Creating ${PN} relay-log directory '${MYSQL_RELAY_LOG}' ..." - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_RELAY_LOG}" \ - || die "Failed to create ${PN} relay-log directory '${MYSQL_RELAY_LOG}'!" - fi - - if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then - local _my_relaylog_testfile="$(_mktemp_dry "${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX")" - [[ -z "${_my_relaylog_testfile}" ]] \ - && die "_mktemp_dry() for '${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX' failed!" - - if use prefix ; then - touch "${_my_relaylog_testfile}" &>/dev/null - else - su -s /bin/sh -c "touch ${_my_relaylog_testfile}" ${MYSQL_USER} &>/dev/null - fi - - if [[ $? -ne 0 ]] ; then - die "${MYSQL_USER} user cannot write into relay-log directory '${MYSQL_RELAY_LOG}'!" - else - rm "${_my_relaylog_testfile}" || die - unset _my_relaylog_testfile - fi - fi - - local mysql_install_log="$(_mktemp_dry "${MYSQL_TMPDIR}/install_db.XXXXXXXXX.log")" - if [[ -z "${mysql_install_log}" ]] ; then - die "_mktemp_dry() for '${MYSQL_TMPDIR}/install_db.XXXXXXXXX.log' failed!" - else - # make sure file is writable for MYSQL_USER... - touch "${mysql_install_log}" || die - chown ${MYSQL_USER} "${mysql_install_log}" || die - fi - - local mysqld_logfile="$(_mktemp_dry "${MYSQL_TMPDIR}/install_mysqld.XXXXXXXXX.log")" - if [[ -z "${mysqld_logfile}" ]] ; then - die "_mktemp_dry() for '${MYSQL_TMPDIR}/install_mysqld.XXXXXXXXX.log' failed!" - else - # make sure file is writable for MYSQL_USER... - touch "${mysqld_logfile}" || die - chown ${MYSQL_USER} "${mysqld_logfile}" || die - fi - - echo "" - einfo "Detected settings:" - einfo "==================" - einfo "MySQL User:\t\t\t\t${MYSQL_USER}" - einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}" - einfo "MySQL DATA directory:\t\t${MY_DATADIR}" - einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}" - - if [[ -n "${MYSQL_LOG_BIN}" ]] ; then - einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}" - fi - - if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then - einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}" - fi - - einfo "PID DIR:\t\t\t\t${PID_DIR}" - einfo "Install db log:\t\t\t${mysql_install_log}" - einfo "Install server log:\t\t\t${mysqld_logfile}" - - local -a config_files - - local config_file="${EROOT}/etc/mysql/mysql.d/50-distro-client.cnf" - if [[ -f "${config_file}" ]] ; then - config_files+=( "${config_file}" ) - else - ewarn "Client configuration '${config_file}' not found; Skipping configuration of default authentication plugin for client ..." - fi - - config_file="${EROOT}/etc/mysql/mysql.d/50-distro-server.cnf" - if [[ -f "${config_file}" ]] ; then - config_files+=( "${config_file}" ) - else - ewarn "Server configuration '${config_file}' not found; Skipping configuration of default authentication plugin for mysqld ..." - fi - - if [[ ${#config_files[@]} -gt 0 ]] ; then - if [[ -z "${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" ]] ; then - local user_answer - - echo - einfo "Please select default authentication plugin (enter number or plugin name):" - einfo "1) caching_sha2_password [MySQL 8.0 default]" - einfo "2) mysql_native_password [MySQL 5.7 default]" - einfo - einfo "For details see:" - einfo "https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password" - read -p " >" user_answer - echo - - case "${user_answer}" in - 1|caching_sha2_password) - MYSQL_DEFAULT_AUTHENTICATION_PLUGIN=caching_sha2_password - ;; - 2|mysql_native_password) - MYSQL_DEFAULT_AUTHENTICATION_PLUGIN=mysql_native_password - ;; - '') - die "No authentication plugin selected!" - ;; - *) - die "Authentication plugin '${user_answer}' is unknown/unsupported!" - ;; - esac - - echo "Selected authentication plugin: ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" >> "${mysql_install_log}" - - unset user_answer - fi - - local cfg_option cfg_option_tabs cfg_section - for config_file in "${config_files[@]}" ; do - cfg_option="default-authentication-plugin" - cfg_section="mysqld" - cfg_option_tabs="\t\t" - if [[ "${config_file}" == *client.cnf ]] ; then - cfg_option="default-auth" - cfg_section="client" - cfg_option_tabs="\t\t\t\t" - fi - - if grep -qE "^(loose-)?${cfg_option}\b.*=" "${config_file}" 2>/dev/null ; then - einfo "Ensuring that ${cfg_option} is set to '${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}' in '${config_file}' ..." - sed -i \ - -e "s/^\(loose-\)\?${cfg_option}\b.*=.*/loose-${cfg_option}${cfg_option_tabs}= ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}/" \ - "${config_file}" || die "Failed to change ${cfg_option} in '${config_file}'!" - else - einfo "Setting ${cfg_option} to '${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}' in '${config_file}' ..." - sed -i \ - -e "/^\[${cfg_section}\]$/a loose-${cfg_option}${cfg_option_tabs}= ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" \ - "${config_file}" || die "Failed to add ${cfg_option} to '${config_file}'!" - fi - done - unset cfg_option cfg_option_tabs cfg_section - fi - unset config_files config_file - - echo - - if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then - local tmp_mysqld_password_source= - - for tmp_mysqld_password_source in mysql client ; do - einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..." - MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)" - if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then - if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]] ; then - ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!" - MYSQL_ROOT_PASSWORD= - continue - fi - - einfo "Found password in '${tmp_mysqld_password_source}' section!" - break - fi - done - - # Sometimes --show is required to display passwords in some implementations of my_print_defaults - if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]] ; then - MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)" - fi - - unset tmp_mysqld_password_source - fi - - if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then - local pwd1="a" - local pwd2="b" - - echo - einfo "No password for mysql 'root' user was specified via environment" - einfo "variable MYSQL_ROOT_PASSWORD and no password was found in config" - einfo "file like '${HOME}/.my.cnf'." - einfo "To continue please provide a password for the mysql 'root' user" - einfo "now on console:" - ewarn "NOTE: Please avoid [\"'\\_%] characters in the password!" - read -rsp " >" pwd1 ; echo - - einfo "Retype the password" - read -rsp " >" pwd2 ; echo - - if [[ "x$pwd1" != "x$pwd2" ]] ; then - die "Passwords are not the same!" - fi - - MYSQL_ROOT_PASSWORD="${pwd1}" - unset pwd1 pwd2 - - echo - fi - - local -a mysqld_options - - # Fix bug 446200. Don't reference host my.cnf, needs to come first, - # see http://bugs.mysql.com/bug.php?id=31312 - use prefix && mysqld_options+=( "--defaults-file='${MY_SYSCONFDIR}/my.cnf'" ) - - # Figure out which options we need to disable to do the setup - local helpfile="${TMPDIR}/mysqld-help" - "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null - - local opt optexp optfull - for opt in host-cache name-resolve networking slave-start \ - federated ssl log-bin relay-log slow-query-log external-locking \ - log-slave-updates \ - ; do - optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}" - egrep -sq -- "${optexp}" "${helpfile}" && mysqld_options+=( "${optfull}" ) - done - - # Prepare timezones, see - # https://dev.mysql.com/doc/mysql/en/time-zone-support.html - local tz_sql="$(_mktemp_dry "${MYSQL_TMPDIR}/tz.XXXXXXXXX.sql")" - [[ -z "${tz_sql}" ]] \ - && die "_mktemp_dry() for '${MYSQL_TMPDIR}/tz.XXXXXXXXX.sql' failed!" - - echo "USE mysql;" >"${tz_sql}" - "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" >> "${tz_sql}" 2>/dev/null - if [[ $? -ne 0 ]] ; then - die "mysql_tzinfo_to_sql failed!" - fi - - # --initialize-insecure will not set root password - # --initialize would set a random one in the log which we don't need as we set it ourselves - local cmd=( - "${mysqld_binary}" - "${mysqld_options[@]}" - "--initialize-insecure" - "--init-file='${tz_sql}'" - "--basedir='${EROOT}/usr'" - "--datadir='${MY_DATADIR}'" - "--tmpdir='${MYSQL_TMPDIR}'" - "--log-error='${mysql_install_log}'" - "--user=${MYSQL_USER}" - ) - - einfo "Initializing ${PN} data directory: ${cmd[@]}" - eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1 - - if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql.ibd" ]] ; then - grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_install_log}" 1>&2 - die "Failed to initialize ${PN} data directory. Please review '${mysql_install_log}'!" - fi - - rm "${tz_sql}" || die - - local x=${RANDOM} - local socket="${EROOT}${PID_DIR}/mysqld${x}.sock" - local pidfile="${EROOT}${PID_DIR}/mysqld${x}.pid" - unset x - - cmd=( - "${mysqld_binary}" - "${mysqld_options[@]}" - "--basedir='${EROOT}/usr'" - "--datadir='${MY_DATADIR}'" - "--tmpdir='${MYSQL_TMPDIR}'" - --max_allowed_packet=8M - --net_buffer_length=16K - "--socket='${socket}'" - "--pid-file='${pidfile}'" - "--log-error='${mysqld_logfile}'" - "--user=${MYSQL_USER}" - ) - - einfo "Starting mysqld to finalize initialization: ${cmd[@]}" - eval "${cmd[@]}" >>"${mysqld_logfile}" 2>&1 & - - echo -n "Waiting for mysqld to accept connections " - local maxtry=15 - while [[ ! -S "${socket}" && "${maxtry}" -gt 1 ]] ; do - maxtry=$((${maxtry}-1)) - echo -n "." - sleep 1 - done - - if [[ -S "${socket}" ]] ; then - # Even with a socket we don't know if mysqld will abort - # start due to an error so just wait a little bit more... - maxtry=5 - while [[ -S "${socket}" && "${maxtry}" -gt 1 ]] ; do - maxtry=$((${maxtry}-1)) - echo -n "." - sleep 1 - done - fi - - echo - - if [[ ! -S "${socket}" ]] ; then - grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysqld_logfile}" 1>&2 - die "mysqld was unable to start from initialized data directory. Please review '${mysqld_logfile}'!" - fi - - local mysql_logfile="${TMPDIR}/set_root_pw.log" - touch "${mysql_logfile}" || die - - ebegin "Setting root password" - # Do this from memory, as we don't want clear text passwords in temp files - local sql="ALTER USER 'root'@'localhost' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}'" - cmd=( - "${mysql_binary}" - --no-defaults - "--socket='${socket}'" - -hlocalhost - "-e \"${sql}\"" - ) - eval "${cmd[@]}" >"${mysql_logfile}" 2>&1 - local rc=$? - eend ${rc} - - if [[ ${rc} -ne 0 ]] ; then - # Poor man's solution which tries to avoid having password - # in log. NOTE: sed can fail if user didn't follow advice - # and included character which will require escaping... - sed -i -e "s/${MYSQL_ROOT_PASSWORD}/*****/" "${mysql_logfile}" 2>/dev/null - - grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_logfile}" - die "Failed to set ${PN} root password. Please review '${mysql_logfile}'!" - fi - - # Stop the server - if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then - echo -n "Stopping the server " - pkill -F "${pidfile}" &>/dev/null - - maxtry=10 - while [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; do - maxtry=$((${maxtry}-1)) - echo -n "." - sleep 1 - done - - echo - - if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then - # We somehow failed to stop server. - # However, not a fatal error. Just warn the user. - ewarn "WARNING: mysqld[$(cat "${pidfile}")] is still running!" - fi - fi - - einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!" -} diff --git a/dev-db/percona-server/percona-server-8.0.26.16-r1.ebuild b/dev-db/percona-server/percona-server-8.0.26.16-r1.ebuild new file mode 100644 index 000000000000..6264df78a218 --- /dev/null +++ b/dev-db/percona-server/percona-server-8.0.26.16-r1.ebuild @@ -0,0 +1,1276 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="7" + +CMAKE_MAKEFILE_GENERATOR=emake + +inherit check-reqs cmake flag-o-matic linux-info \ + multiprocessing prefix toolchain-funcs + +MY_BOOST_VERSION="1.73.0" +MY_PV=$(ver_rs 3 '-') +MY_PV="${MY_PV//_pre*}" +MY_PN="Percona-Server" +MY_P="${PN}-${MY_PV}" +MY_MAJOR_PV=$(ver_cut 1-2) +MY_RELEASE_NOTES_URI="https://www.percona.com/doc/percona-server/${MY_MAJOR_PV}/" + +# Patch version +PATCH_SET="https://dev.gentoo.org/~whissi/dist/percona-server/${PN}-8.0.26.16-patches-01.tar.xz" + +SRC_URI="https://www.percona.com/downloads/${MY_PN}-${MY_MAJOR_PV}/${MY_PN}-${MY_PV}/source/tarball/${PN}-${MY_PV}.tar.gz + https://dl.bintray.com/boostorg/release/${MY_BOOST_VERSION}/source/boost_$(ver_rs 1- _ ${MY_BOOST_VERSION}).tar.bz2 + ${PATCH_SET} +" + +HOMEPAGE="https://www.percona.com/software/mysql-database/percona-server https://github.com/percona/percona-server" +DESCRIPTION="Fully compatible, enhanced and open source drop-in replacement for MySQL" +LICENSE="GPL-2" +SLOT="8.0" +IUSE="cjk cracklib debug jemalloc latin1 ldap numa pam +perl profiling + rocksdb router selinux +server tcmalloc test tokudb tokudb-backup-plugin" + +RESTRICT="!test? ( test )" + +REQUIRED_USE="?? ( tcmalloc jemalloc ) + cjk? ( server ) + jemalloc? ( server ) + numa? ( server ) + profiling? ( server ) + router? ( server ) + tcmalloc? ( server )" + +KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 -riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris ~x86-solaris" + +# Shorten the path because the socket path length must be shorter than 107 chars +# and we will run a mysql server during test phase +S="${WORKDIR}/mysql" + +# Be warned, *DEPEND are version-dependant +# These are used for both runtime and compiletime +# openldap < dep for bug #835647 (we need ldap_r) +COMMON_DEPEND=" + >=app-arch/lz4-0_p131:= + app-arch/zstd:= + sys-libs/ncurses:0= + >=sys-libs/zlib-1.2.3:0= + >=dev-libs/openssl-1.0.0:0= + server? ( + dev-libs/icu:= + dev-libs/libevent:=[ssl,threads] + >=dev-libs/protobuf-3.8:= + net-libs/libtirpc:= + net-misc/curl:= + cjk? ( app-text/mecab:= ) + ldap? ( + dev-libs/cyrus-sasl + /dev/null) + [[ -z "${aio_max_nr}" || ${aio_max_nr} -lt 250000 ]] \ + && die "FEATURES=test will require fs.aio-max-nr=250000 at minimum!" + + if use latin1 ; then + # Upstream only supports tests with default charset + die "Testing with USE=latin1 is not supported." + fi + fi + + if use kernel_linux ; then + if use numa ; then + linux-info_get_any_version + + local CONFIG_CHECK="~NUMA" + + local WARNING_NUMA="This package expects NUMA support in kernel which this system does not have at the moment;" + WARNING_NUMA+=" Either expect runtime errors, enable NUMA support in kernel or rebuild the package without NUMA support" + + check_extra_config + fi + fi + + use server && check-reqs_pkg_setup + fi +} + +src_unpack() { + unpack ${A} + + mv -f "${WORKDIR}/${MY_P}" "${S}" || die +} + +src_prepare() { + eapply "${WORKDIR}"/mysql-patches + + # Avoid rpm call which would trigger sandbox, #692368 + sed -i \ + -e 's/MY_RPM rpm/MY_RPM rpmNOTEXISTENT/' \ + CMakeLists.txt || die + + if use jemalloc ; then + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" || die + fi + + if use tcmalloc ; then + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" || die + fi + + # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux + if [[ -d "${S}/support-files/SELinux" ]] ; then + echo > "${S}/support-files/SELinux/CMakeLists.txt" || die + fi + + # Remove man pages for client-lib tools we don't install + rm \ + man/my_print_defaults.1 \ + man/perror.1 \ + man/zlib_decompress.1 \ + || die + + cmake_src_prepare +} + +src_configure() { + # Bug #114895, bug #110149 + filter-flags "-O" "-O[01]" + + append-cxxflags -felide-constructors + + # code is not C++17 ready, bug #786402 + append-cxxflags -std=c++14 + + # bug #283926, with GCC4.4, this is required to get correct behavior. + append-flags -fno-strict-aliasing + + CMAKE_BUILD_TYPE="RelWithDebInfo" + + # debug hack wrt #497532 + mycmakeargs=( + -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" + -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql" + -DSYSCONFDIR="${EPREFIX}/etc/mysql" + -DINSTALL_BINDIR=bin + -DINSTALL_DOCDIR=share/doc/${PF} + -DINSTALL_DOCREADMEDIR=share/doc/${PF} + -DINSTALL_INCLUDEDIR=include/mysql + -DINSTALL_INFODIR=share/info + -DINSTALL_LIBDIR=$(get_libdir) + -DINSTALL_MANDIR=share/man + -DINSTALL_MYSQLSHAREDIR=share/mysql + -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" + -DINSTALL_SBINDIR=sbin + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mysql" + -DCOMPILATION_COMMENT="Gentoo Linux ${PF}" + -DWITH_UNIT_TESTS=$(usex test ON OFF) + # Using bundled editline to get CTRL+C working + -DWITH_EDITLINE=bundled + -DWITH_ZLIB=system + -DWITH_SSL=system + -DWITH_LIBWRAP=0 + -DENABLED_LOCAL_INFILE=1 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DWITH_DEFAULT_COMPILER_OPTIONS=0 + # The build forces this to be defined when cross-compiling. We pass it + # all the time for simplicity and to make sure it is actually correct. + -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1) + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DWITH_CURL=system + -DWITH_BOOST="${WORKDIR}/boost_$(ver_rs 1- _ ${MY_BOOST_VERSION})" + -DWITH_ROUTER=$(usex router ON OFF) + ) + + if is-flagq -fno-lto ; then + einfo "LTO disabled via {C,CXX,F,FC}FLAGS" + mycmakeargs+=( -DWITH_LTO=OFF ) + elif is-flagq -flto ; then + einfo "LTO forced via {C,CXX,F,FC}FLAGS" + myconf+=( -DWITH_LTO=ON ) + else + # Disable automagic + myconf+=( -DWITH_LTO=OFF ) + fi + + if use test ; then + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test ) + else + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) + fi + + mycmakeargs+=( -DWITHOUT_CLIENTLIBS=YES ) + + mycmakeargs+=( + -DWITH_ICU=system + -DWITH_LZ4=system + # Our dev-libs/rapidjson doesn't carry necessary fixes for std::regex + -DWITH_RAPIDJSON=bundled + -DWITH_ZSTD=system + ) + + if [[ -n "${MYSQL_DEFAULT_CHARSET}" && -n "${MYSQL_DEFAULT_COLLATION}" ]] ; then + ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}" + ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}." + ewarn "You MUST file bugs without these variables set." + ewarn "Tests will probably fail!" + + mycmakeargs+=( + -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET} + -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION} + ) + elif use latin1 ; then + mycmakeargs+=( + -DDEFAULT_CHARSET=latin1 + -DDEFAULT_COLLATION=latin1_swedish_ci + ) + else + mycmakeargs+=( + -DDEFAULT_CHARSET=utf8mb4 + -DDEFAULT_COLLATION=utf8mb4_0900_ai_ci + ) + fi + + if use server ; then + mycmakeargs+=( + -DWITH_AUTHENTICATION_LDAP=$(usex ldap system OFF) + -DWITH_COREDUMPER=OFF + -DWITH_EXTRA_CHARSETS=all + -DWITH_DEBUG=$(usex debug) + -DWITH_MECAB=$(usex cjk system OFF) + -DWITH_LIBEVENT=system + -DWITH_PROTOBUF=system + -DWITH_NUMA=$(usex numa ON OFF) + -DWITH_PAM=$(usex pam) + ) + + if use profiling ; then + # Setting to OFF doesn't work: Once set, profiling options will be added + # to `mysqld --help` output via sql/sys_vars.cc causing + # "main.mysqld--help-notwin" test to fail + mycmakeargs+=( -DENABLED_PROFILING=ON ) + fi + + # Storage engines + mycmakeargs+=( + -DWITH_EXAMPLE_STORAGE_ENGINE=0 + -DWITH_ARCHIVE_STORAGE_ENGINE=1 + -DWITH_BLACKHOLE_STORAGE_ENGINE=1 + -DWITH_CSV_STORAGE_ENGINE=1 + -DWITH_FEDERATED_STORAGE_ENGINE=1 + -DWITH_HEAP_STORAGE_ENGINE=1 + -DWITH_INNOBASE_STORAGE_ENGINE=1 + -DWITH_INNODB_MEMCACHED=0 + -DWITH_MYISAMMRG_STORAGE_ENGINE=1 + -DWITH_MYISAM_STORAGE_ENGINE=1 + -DWITH_ROCKSDB=$(usex rocksdb 1 0) + -DWITH_TOKUDB=$(usex tokudb 1 0) + ) + else + mycmakeargs+=( + -DWITHOUT_SERVER=1 + -DWITH_SYSTEMD=no + ) + fi + + cmake_src_configure +} + +# Official test instructions: +# ulimit -n 16500 && \ +# USE='perl server' \ +# FEATURES='test userpriv' \ +# ebuild mysql-X.X.XX.ebuild \ +# digest clean package +src_test() { + _disable_test() { + local rawtestname bug reason + rawtestname="${1}" ; shift + bug="${1}" ; shift + reason="${@}" + ewarn "test '${rawtestname}' disabled: '${reason}' (BUG#${bug})" + echo ${rawtestname} : BUG#${bug} ${reason} >> "${T}/disabled.def" + } + + local TESTDIR="${BUILD_DIR}/mysql-test" + local retstatus_tests + + if ! use server ; then + einfo "Skipping server tests due to minimal build." + return 0 + fi + + # Ensure that parallel runs don't die + export MTR_BUILD_THREAD="$((${RANDOM} % 100))" + + if [[ -z "${MTR_PARALLEL}" ]] ; then + local -x MTR_PARALLEL=$(makeopts_jobs) + + if [[ ${MTR_PARALLEL} -gt 4 ]] ; then + # Running multiple tests in parallel usually require higher ulimit + # and fs.aio-max-nr setting. In addition, tests like main.multi_update + # are known to hit timeout when system is busy. + # To avoid test failure we will limit MTR_PARALLEL to 4 instead of + # using "auto". + local info_msg="Parallel MySQL test suite jobs limited to 4 (MAKEOPTS=${MTR_PARALLEL})" + info_msg+=" to avoid test failures. Set MTR_PARALLEL if you know what you are doing!" + einfo "${info_msg}" + unset info_msg + MTR_PARALLEL=4 + fi + else + einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" + fi + + # create directories because mysqladmin might run out of order + mkdir -p "${T}"/var-tests{,/log} || die + + # Run mysql tests + pushd "${TESTDIR}" &>/dev/null || die + + touch "${T}/disabled.def" + + local -a disabled_tests + disabled_tests+=( "auth_sec.atomic_rename_user;103512;Depends on user running test" ) + disabled_tests+=( "auth_sec.keyring_file_data_qa;0;Won't work with user privileges" ) + disabled_tests+=( "gis.geometry_class_attri_prop;5452;Known rounding error with latest AMD processors (PS)" ) + disabled_tests+=( "gis.geometry_property_function_issimple;5452;Known rounding error with latest AMD processors (PS)" ) + disabled_tests+=( "gis.gis_bugs_crashes;5452;Known rounding error with latest AMD processors (PS)" ) + disabled_tests+=( "gis.spatial_analysis_functions_buffer;5452;Known rounding error with latest AMD processors (PS)" ) + disabled_tests+=( "gis.spatial_analysis_functions_centroid;5452;Known rounding error with latest AMD processors (PS)" ) + disabled_tests+=( "gis.spatial_analysis_functions_distance;5452;Known rounding error with latest AMD processors (PS)" ) + disabled_tests+=( "gis.spatial_op_testingfunc_mix;5452;Known rounding error with latest AMD processors (PS)" ) + disabled_tests+=( "gis.spatial_operators_intersection;5452;Known rounding error with latest AMD processors (PS)" ) + disabled_tests+=( "gis.spatial_utility_function_distance_sphere;5452;Known rounding error with latest AMD processors (PS)" ) + disabled_tests+=( "gis.spatial_utility_function_simplify;5452;Known rounding error with latest AMD processors (PS)" ) + disabled_tests+=( "group_replication.gr_ssl_options2;0;Sporadic failing test" ) + disabled_tests+=( "innodb.alter_kill;0;Known test failure -- no upstream bug yet" ) + disabled_tests+=( "innodb.percona_changed_page_bmp_flush;6807;False positive on Gentoo (PS)" ) + disabled_tests+=( "innodb.percona_changed_page_bmp_log_resize;0;Sporadic failing test" ) + disabled_tests+=( "innodb.percona_log_encrypt_change_mk;6039;False positive on Gentoo (PS)" ) + disabled_tests+=( "innodb.percona_log_encrypt_change_rk;6805;False positive on Gentoo (PS)" ) + disabled_tests+=( "innodb.percona_log_encrypt_failure;0;Requires proper keyring setup" ) + disabled_tests+=( "innodb.upgrade_orphan;0;Sporadic failing test" ) + disabled_tests+=( "main.coredump;0;Known test failure" ) + disabled_tests+=( "main.derived_limit;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) + disabled_tests+=( "main.explain_tree;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) + disabled_tests+=( "main.gis-precise;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) + disabled_tests+=( "main.mtr_unit_tests;7975;Known test failure (PS)" ) + disabled_tests+=( "main.myisam-blob;0;Sporadic failing test" ) + disabled_tests+=( "main.mysql_load_data_local_dir;7416;Known test failure" ) + disabled_tests+=( "main.mysqlpump_basic_lz4;6042;Extra tool output causes false positive" ) + disabled_tests+=( "main.ssl_bug75311;5996;Known test failure" ) + disabled_tests+=( "main.ssl_san;6808;False positive on IPv6-enabled hosts" ) + disabled_tests+=( "main.subquery_bugs;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) + disabled_tests+=( "main.subquery_sj_dupsweed;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) + disabled_tests+=( "main.subquery_sj_dupsweed_bka;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) + disabled_tests+=( "main.subquery_sj_dupsweed_bka_nobnl;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) + disabled_tests+=( "main.subquery_sj_firstmatch;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) + disabled_tests+=( "main.subquery_sj_firstmatch_bka;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) + disabled_tests+=( "main.subquery_sj_firstmatch_bka_nobnl;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) + disabled_tests+=( "main.subquery_sj_mat_bka_nobnl;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) + disabled_tests+=( "main.window_std_var;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) + disabled_tests+=( "main.window_std_var_optimized;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) + disabled_tests+=( "main.with_recursive;6804;Known rounding error with latest AMD processors" ) + disabled_tests+=( "rpl_gtid.rpl_gtid_stm_drop_table;90612;Known test failure" ) + disabled_tests+=( "rpl_gtid.rpl_multi_source_mtr_includes;0;Know failure - no upstream bug yet" ) + disabled_tests+=( "sys_vars.innodb_sys_tablespace_encrypt_basic;7415;Known test failure" ) + disabled_tests+=( "sys_vars.myisam_data_pointer_size_func;87935;Test will fail on slow hardware" ) + disabled_tests+=( "x.message_compressed_payload;0;False positive caused by protobuff-3.11+" ) + disabled_tests+=( "x.message_protobuf_nested;6803;False positive caused by protobuff-3.11+" ) + + if ! hash zip 1>/dev/null 2>&1 ; then + # no need to force dep app-arch/zip for one test + disabled_tests+=( "innodb.discarded_partition_create;0;Requires app-arch/zip" ) + disabled_tests+=( "innodb.partition_upgrade_create;0;Requires app-arch/zip" ) + fi + + if has_version ">=dev-libs/openssl-3" ; then + # >=dev-libs/openssl-3 defaults to security level 1 which disallow + # TLSv1/1.1 but tests will require TLSv1/1.1. + einfo "Set OpenSSL configuration for test suite ..." + cat > "${T}/openssl_tlsv1.cnf" <<- EOF || die + openssl_conf = default_conf + + [ req ] + default_bits = 2048 + default_keyfile = privkey.pem + distinguished_name = req_distinguished_name + + [ req_distinguished_name ] + countryName = Country Name (2 letter code) + countryName_default = AU + countryName_min = 2 + countryName_max = 2 + + stateOrProvinceName = State or Province Name (full name) + stateOrProvinceName_default = Some-State + + localityName = Locality Name (eg, city) + + 0.organizationName = Organization Name (eg, company) + 0.organizationName_default = Internet Widgits Pty Ltd + + organizationalUnitName = Organizational Unit Name (eg, section) + + commonName = Common Name (e.g. server FQDN or YOUR name) + commonName_max = 64 + + emailAddress = Email Address + emailAddress_max = 64 + + [default_conf] + ssl_conf = ssl_sect + + [ssl_sect] + system_default = system_default_sect + + [system_default_sect] + CipherString = DEFAULT@SECLEVEL=0 + EOF + + local -x OPENSSL_CONF="${T}/openssl_tlsv1.cnf" + + disabled_tests+=( "x.connection_tls_version;0;Not compatible with OpenSSL 3.x error messages" ) + fi + + local test_infos_str test_infos_arr + for test_infos_str in "${disabled_tests[@]}" ; do + IFS=';' read -r -a test_infos_arr <<< "${test_infos_str}" + + if [[ ${#test_infos_arr[@]} != 3 ]] ; then + die "Invalid test data set, not matching format: ${test_infos_str}" + fi + + _disable_test "${test_infos_arr[0]}" "${test_infos_arr[1]}" "${test_infos_arr[2]}" + done + unset test_infos_str test_infos_arr + + if [[ -z "${MTR_VAULT_TOKEN}" ]] ; then + local impossible_test + for impossible_test in \ + encryption.default_table_encryption_var \ + encryption.innodb-redo-nokeys2_release \ + keyring_vault.innodb_online_alter_encryption \ + keyring_vault.innodb_row_log_encryption \ + keyring_vault.install_keyring_vault \ + keyring_vault.keyring_udf \ + keyring_vault.keyring_vault_config \ + keyring_vault.keyring_vault_config_qa \ + keyring_vault.keyring_vault_timeout \ + keyring_vault.key_rotation_qa \ + keyring_vault.rpl_key_rotation \ + keyring_vault.table_encrypt_2 \ + keyring_vault.table_encrypt_2_directory \ + keyring_vault.table_encrypt_2_keyring \ + keyring_vault.table_encrypt_5 \ + keyring_vault.table_encrypt_5_directory \ + keyring_vault.table_encrypt_kill \ + keyring_vault.temp_table_encrypt_keyring_vault \ + main.persisted_variables \ + ; do + _disable_test "${impossible_test}" "0" "MTR_VAULT_TOKEN is not set" + done + fi + + # Try to increase file limits to increase test coverage + if ! ulimit -n 16500 1>/dev/null 2>&1 ; then + # Upper limit comes from parts.partition_* tests + ewarn "For maximum test coverage please raise open file limit to 16500 (ulimit -n 16500) before calling the package manager." + + if ! ulimit -n 4162 1>/dev/null 2>&1 ; then + # Medium limit comes from '[Warning] Buffered warning: Could not increase number of max_open_files to more than 3000 (request: 4162)' + ewarn "For medium test coverage please raise open file limit to 4162 (ulimit -n 4162) before calling the package manager." + + if ! ulimit -n 3000 1>/dev/null 2>&1 ; then + ewarn "For minimum test coverage please raise open file limit to 3000 (ulimit -n 3000) before calling the package manager." + else + einfo "Will run test suite with open file limit set to 3000 (minimum test coverage)." + fi + else + einfo "Will run test suite with open file limit set to 4162 (medium test coverage)." + fi + else + einfo "Will run test suite with open file limit set to 16500 (best test coverage)." + fi + + # run mysql-test tests + perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def" + retstatus_tests=$? + + popd &>/dev/null || die + + # Cleanup is important for these testcases. + pkill -9 -f "${S}/ndb" 2>/dev/null + pkill -9 -f "${S}/sql" 2>/dev/null + + local failures="" + [[ ${retstatus_tests} -eq 0 ]] || failures="${failures} tests" + + [[ -z "${failures}" ]] || die "Test failures: ${failures}" + einfo "Tests successfully completed" +} + +src_install() { + cmake_src_install + + # Make sure the vars are correctly initialized + mysql_init_vars + + # Convenience links + einfo "Making Convenience links for mysqlcheck multi-call binary" + dosym "mysqlcheck" "/usr/bin/mysqlanalyze" + dosym "mysqlcheck" "/usr/bin/mysqlrepair" + dosym "mysqlcheck" "/usr/bin/mysqloptimize" + + # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir + if [[ -d "${ED}/usr/data" ]] ; then + rm -Rf "${ED}/usr/data" || die + fi + + # Unless they explicitly specific USE=test, then do not install the + # testsuite. It DOES have a use to be installed, esp. when you want to do a + # validation of your database configuration after tuning it. + if ! use test ; then + rm -rf "${ED}/${MY_SHAREDSTATEDIR#${EPREFIX}}/mysql-test" + fi + + # Configuration stuff + einfo "Building default configuration ..." + insinto "${MY_SYSCONFDIR#${EPREFIX}}" + [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf + cp "${FILESDIR}/my.cnf-5.7" "${TMPDIR}/my.cnf" || die + eprefixify "${TMPDIR}/my.cnf" + doins "${TMPDIR}/my.cnf" + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mysql.d" + cp "${FILESDIR}/my.cnf-8.0.distro-client" "${TMPDIR}/50-distro-client.cnf" || die + eprefixify "${TMPDIR}/50-distro-client.cnf" + doins "${TMPDIR}/50-distro-client.cnf" + + mycnf_src="my.cnf-8.0.distro-server" + sed -e "s!@DATADIR@!${MY_DATADIR}!g" \ + "${FILESDIR}/${mycnf_src}" \ + > "${TMPDIR}/my.cnf.ok" || die + + if use prefix ; then + sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \ + "${TMPDIR}/my.cnf.ok" || die + fi + + if use latin1 ; then + sed -i \ + -e "/character-set/s|utf8mb4|latin1|g" \ + "${TMPDIR}/my.cnf.ok" || die + fi + + eprefixify "${TMPDIR}/my.cnf.ok" + + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf + + #Remove mytop if perl is not selected + [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop" + + if use router ; then + rm -rf \ + "${ED}/usr/LICENSE.router" \ + "${ED}/usr/README.router" \ + "${ED}/usr/run" \ + "${ED}/usr/var" \ + || die + fi + + # Kill old libmysqclient_r symlinks if they exist. Time to fix what depends on them. + find "${D}" -name 'libmysqlclient_r.*' -type l -delete || die +} + +pkg_postinst() { + # Make sure the vars are correctly initialized + mysql_init_vars + + # Create log directory securely if it does not exist + # NOTE: $MY_LOGDIR contains $EPREFIX by default + [[ -d "${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${MY_LOGDIR}" + + # Note about configuration change + einfo + elog "This version of ${PN} reorganizes the configuration from a single my.cnf" + elog "to several files in /etc/mysql/mysql.d." + elog "Please backup any changes you made to /etc/mysql/my.cnf" + elog "and add them as a new file under /etc/mysql/mysql.d with a .cnf extension." + elog "You may have as many files as needed and they are read alphabetically." + elog "Be sure the options have the appropriate section headers, i.e. [mysqld]." + einfo + + if [[ -z "${REPLACING_VERSIONS}" ]] ; then + einfo + elog "You might want to run:" + elog " \"emerge --config =${CATEGORY}/${PF}\"" + elog "if this is a new install." + einfo + else + einfo + elog "Upgrade process for ${PN}-8.x has changed. Please read" + elog "https://dev.mysql.com/doc/refman/8.0/en/upgrade-binary-package.html" + einfo + fi +} + +pkg_config() { + _getoptval() { + local section="$1" + local flag="--${2}=" + local extra_options="${3}" + local cmd=( + "${my_print_defaults_binary}" + "${extra_options}" + "${section}" + ) + local results=( $(eval "${cmd[@]}" 2>/dev/null | sed -n "/^${flag}/s,${flag},,gp") ) + + if [[ ${#results[@]} -gt 0 ]] ; then + # When option is set multiple times only return last value + echo "${results[-1]}" + fi + } + + _mktemp_dry() { + # emktemp has no --dry-run option + local template="${1}" + + if [[ -z "${template}" ]] ; then + if [[ -z "${T}" ]] ; then + template="/tmp/XXXXXXX" + else + template="${T}/XXXXXXX" + fi + fi + + local template_wo_X=${template//X/} + local n_X + let n_X=${#template}-${#template_wo_X} + if [[ ${n_X} -lt 3 ]] ; then + echo "${FUNCNAME[0]}: too few X's in template ‘${template}’" >&2 + return + fi + + local attempts=0 + local character tmpfile + while [[ true ]] ; do + let attempts=attempts+1 + + new_file= + while read -n1 character ; do + if [[ "${character}" == "X" ]] ; then + tmpfile+="${RANDOM:0:1}" + else + tmpfile+="${character}" + fi + done < <(echo -n "${template}") + + if [[ ! -f "${tmpfile}" ]] + then + echo "${tmpfile}" + return + fi + + if [[ ${attempts} -ge 100 ]] ; then + echo "${FUNCNAME[0]}: Cannot create temporary file after 100 attempts." >&2 + return + fi + done + } + + local mysqld_binary="${EROOT}/usr/sbin/mysqld" + if [[ ! -x "${mysqld_binary}" ]] ; then + die "'${mysqld_binary}' not found! Please re-install ${CATEGORY}/${PN}!" + fi + + local mysql_binary="${EROOT}/usr/bin/mysql" + if [[ ! -x "${mysql_binary}" ]] ; then + die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!" + fi + + local my_print_defaults_binary="${EROOT}/usr/bin/my_print_defaults" + if [[ ! -x "${my_print_defaults_binary}" ]] ; then + die "'${my_print_defaults_binary}' not found! Please re-install dev-db/mysql-connector-c!" + fi + + if [[ -z "${MYSQL_USER}" ]] ; then + MYSQL_USER=mysql + if use prefix ; then + MYSQL_USER=$(id -u -n 2>/dev/null) + if [[ -z "${MYSQL_USER}" ]] ; then + die "Failed to determine current username!" + fi + fi + fi + + if [[ -z "${MYSQL_GROUP}" ]] ; then + MYSQL_GROUP=mysql + if use prefix ; then + MYSQL_GROUP=$(id -g -n 2>/dev/null) + if [[ -z "${MYSQL_GROUP}" ]] ; then + die "Failed to determine current user groupname!" + fi + fi + fi + + # my_print_defaults needs to read stuff in $HOME/.my.cnf + local -x HOME="${EROOT}/root" + + # Make sure the vars are correctly initialized + mysql_init_vars + + # Read currently set data directory + MY_DATADIR="$(_getoptval mysqld datadir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" + + # Bug #213475 - MySQL _will_ object strenously if your machine is named + # localhost. Also causes weird failures. + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" + + if [[ -z "${MY_DATADIR}" ]] ; then + die "Sorry, unable to find MY_DATADIR!" + elif [[ -d "${MY_DATADIR}/mysql" ]] ; then + ewarn "Looks like your data directory '${MY_DATADIR}' is already initialized!" + ewarn "Please rename or delete its content if you wish to initialize a new data directory." + die "${PN} data directory at '${MY_DATADIR}' looks already initialized!" + fi + + MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" + MYSQL_TMPDIR=${MYSQL_TMPDIR%/} + # These are dir+prefix + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} + + # Create missing directories. + # Always check if mysql user can write to directory even if we just + # created directory because a parent directory might be not + # accessible for that user. + PID_DIR="${EROOT}/run/mysqld" + if [[ ! -d "${PID_DIR}" ]] ; then + einfo "Creating ${PN} PID directory '${PID_DIR}' ..." + install -d -m 755 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${PID_DIR}" \ + || die "Failed to create PID directory '${PID_DIR}'!" + fi + + local _pid_dir_testfile="$(_mktemp_dry "${PID_DIR}/.pkg_config-access-test.XXXXXXXXX")" + [[ -z "${_pid_dir_testfile}" ]] \ + && die "_mktemp_dry() for '${PID_DIR}/.pkg_config-access-test.XXXXXXXXX' failed!" + + if use prefix ; then + touch "${_pid_dir_testfile}" &>/dev/null + else + su -s /bin/sh -c "touch ${_pid_dir_testfile}" ${MYSQL_USER} &>/dev/null + fi + + if [[ $? -ne 0 ]] ; then + die "${MYSQL_USER} user cannot write into PID dir '${PID_DIR}'!" + else + rm "${_pid_dir_testfile}" || die + unset _pid_dir_testfile + fi + + if [[ ! -d "${MY_DATADIR}" ]] ; then + einfo "Creating ${PN} data directory '${MY_DATADIR}' ..." + install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MY_DATADIR}" \ + || die "Failed to create ${PN} data directory '${MY_DATADIR}'!" + fi + + local _my_datadir_testfile="$(_mktemp_dry "${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX")" + [[ -z "${_my_datadir_testfile}" ]] \ + && die "_mktemp_dry() for '${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX' failed!" + + if use prefix ; then + touch "${_my_datadir_testfile}" &>/dev/null + else + su -s /bin/sh -c "touch ${_my_datadir_testfile}" ${MYSQL_USER} &>/dev/null + fi + + if [[ $? -ne 0 ]] ; then + die "${MYSQL_USER} user cannot write into data directory '${MY_DATADIR}'!" + else + rm "${_my_datadir_testfile}" || die + unset _my_datadir_testfile + fi + + if [[ -n "${MYSQL_TMPDIR}" && ! -d "${MYSQL_TMPDIR}" ]] ; then + einfo "Creating ${PN} tmpdir '${MYSQL_TMPDIR}' ..." + install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_TMPDIR}" \ + || die "Failed to create ${PN} tmpdir '${MYSQL_TMPDIR}'!" + fi + + if [[ -z "${MYSQL_TMPDIR}" ]] ; then + MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")" + [[ -z "${MYSQL_TMPDIR}" ]] \ + && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!" + + mkdir "${MYSQL_TMPDIR}" || die + chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die + fi + + # Now we need to test MYSQL_TMPDIR... + local _my_tmpdir_testfile="$(_mktemp_dry "${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX")" + [[ -z "${_my_tmpdir_testfile}" ]] \ + && die "_mktemp_dry() for '${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX' failed!" + + if use prefix ; then + touch "${_my_tmpdir_testfile}" &>/dev/null + else + su -s /bin/sh -c "touch ${_my_tmpdir_testfile}" ${MYSQL_USER} &>/dev/null + fi + + if [[ $? -ne 0 ]] ; then + die "${MYSQL_USER} user cannot write into tmpdir '${MYSQL_TMPDIR}'!" + else + rm "${_my_tmpdir_testfile}" || die + unset _my_tmpdir_testfile + fi + + if [[ -n "${MYSQL_LOG_BIN}" && ! -d "${MYSQL_LOG_BIN}" ]] ; then + einfo "Creating ${PN} log-bin directory '${MYSQL_LOG_BIN}' ..." + install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_LOG_BIN}" \ + || die "Failed to create ${PN} log-bin directory '${MYSQL_LOG_BIN}'" + fi + + if [[ -n "${MYSQL_LOG_BIN}" ]] ; then + local _my_logbin_testfile="$(_mktemp_dry "${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX")" + [[ -z "${_my_logbin_testfile}" ]] \ + && die "_mktemp_dry() for '${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX' failed!" + + if use prefix ; then + touch "${_my_logbin_testfile}" &>/dev/null + else + su -s /bin/sh -c "touch ${_my_logbin_testfile}" ${MYSQL_USER} &>/dev/null + fi + + if [[ $? -ne 0 ]] ; then + die "${MYSQL_USER} user cannot write into log-bin directory '${MYSQL_LOG_BIN}'!" + else + rm "${_my_logbin_testfile}" || die + unset _my_logbin_testfile + fi + fi + + if [[ -n "${MYSQL_RELAY_LOG}" && ! -d "${MYSQL_RELAY_LOG}" ]] ; then + einfo "Creating ${PN} relay-log directory '${MYSQL_RELAY_LOG}' ..." + install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_RELAY_LOG}" \ + || die "Failed to create ${PN} relay-log directory '${MYSQL_RELAY_LOG}'!" + fi + + if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then + local _my_relaylog_testfile="$(_mktemp_dry "${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX")" + [[ -z "${_my_relaylog_testfile}" ]] \ + && die "_mktemp_dry() for '${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX' failed!" + + if use prefix ; then + touch "${_my_relaylog_testfile}" &>/dev/null + else + su -s /bin/sh -c "touch ${_my_relaylog_testfile}" ${MYSQL_USER} &>/dev/null + fi + + if [[ $? -ne 0 ]] ; then + die "${MYSQL_USER} user cannot write into relay-log directory '${MYSQL_RELAY_LOG}'!" + else + rm "${_my_relaylog_testfile}" || die + unset _my_relaylog_testfile + fi + fi + + local mysql_install_log="$(_mktemp_dry "${MYSQL_TMPDIR}/install_db.XXXXXXXXX.log")" + if [[ -z "${mysql_install_log}" ]] ; then + die "_mktemp_dry() for '${MYSQL_TMPDIR}/install_db.XXXXXXXXX.log' failed!" + else + # make sure file is writable for MYSQL_USER... + touch "${mysql_install_log}" || die + chown ${MYSQL_USER} "${mysql_install_log}" || die + fi + + local mysqld_logfile="$(_mktemp_dry "${MYSQL_TMPDIR}/install_mysqld.XXXXXXXXX.log")" + if [[ -z "${mysqld_logfile}" ]] ; then + die "_mktemp_dry() for '${MYSQL_TMPDIR}/install_mysqld.XXXXXXXXX.log' failed!" + else + # make sure file is writable for MYSQL_USER... + touch "${mysqld_logfile}" || die + chown ${MYSQL_USER} "${mysqld_logfile}" || die + fi + + echo "" + einfo "Detected settings:" + einfo "==================" + einfo "MySQL User:\t\t\t\t${MYSQL_USER}" + einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}" + einfo "MySQL DATA directory:\t\t${MY_DATADIR}" + einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}" + + if [[ -n "${MYSQL_LOG_BIN}" ]] ; then + einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}" + fi + + if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then + einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}" + fi + + einfo "PID DIR:\t\t\t\t${PID_DIR}" + einfo "Install db log:\t\t\t${mysql_install_log}" + einfo "Install server log:\t\t\t${mysqld_logfile}" + + local -a config_files + + local config_file="${EROOT}/etc/mysql/mysql.d/50-distro-client.cnf" + if [[ -f "${config_file}" ]] ; then + config_files+=( "${config_file}" ) + else + ewarn "Client configuration '${config_file}' not found; Skipping configuration of default authentication plugin for client ..." + fi + + config_file="${EROOT}/etc/mysql/mysql.d/50-distro-server.cnf" + if [[ -f "${config_file}" ]] ; then + config_files+=( "${config_file}" ) + else + ewarn "Server configuration '${config_file}' not found; Skipping configuration of default authentication plugin for mysqld ..." + fi + + if [[ ${#config_files[@]} -gt 0 ]] ; then + if [[ -z "${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" ]] ; then + local user_answer + + echo + einfo "Please select default authentication plugin (enter number or plugin name):" + einfo "1) caching_sha2_password [MySQL 8.0 default]" + einfo "2) mysql_native_password [MySQL 5.7 default]" + einfo + einfo "For details see:" + einfo "https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password" + read -p " >" user_answer + echo + + case "${user_answer}" in + 1|caching_sha2_password) + MYSQL_DEFAULT_AUTHENTICATION_PLUGIN=caching_sha2_password + ;; + 2|mysql_native_password) + MYSQL_DEFAULT_AUTHENTICATION_PLUGIN=mysql_native_password + ;; + '') + die "No authentication plugin selected!" + ;; + *) + die "Authentication plugin '${user_answer}' is unknown/unsupported!" + ;; + esac + + echo "Selected authentication plugin: ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" >> "${mysql_install_log}" + + unset user_answer + fi + + local cfg_option cfg_option_tabs cfg_section + for config_file in "${config_files[@]}" ; do + cfg_option="default-authentication-plugin" + cfg_section="mysqld" + cfg_option_tabs="\t\t" + if [[ "${config_file}" == *client.cnf ]] ; then + cfg_option="default-auth" + cfg_section="client" + cfg_option_tabs="\t\t\t\t" + fi + + if grep -qE "^(loose-)?${cfg_option}\b.*=" "${config_file}" 2>/dev/null ; then + einfo "Ensuring that ${cfg_option} is set to '${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}' in '${config_file}' ..." + sed -i \ + -e "s/^\(loose-\)\?${cfg_option}\b.*=.*/loose-${cfg_option}${cfg_option_tabs}= ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}/" \ + "${config_file}" || die "Failed to change ${cfg_option} in '${config_file}'!" + else + einfo "Setting ${cfg_option} to '${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}' in '${config_file}' ..." + sed -i \ + -e "/^\[${cfg_section}\]$/a loose-${cfg_option}${cfg_option_tabs}= ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" \ + "${config_file}" || die "Failed to add ${cfg_option} to '${config_file}'!" + fi + done + unset cfg_option cfg_option_tabs cfg_section + fi + unset config_files config_file + + echo + + if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then + local tmp_mysqld_password_source= + + for tmp_mysqld_password_source in mysql client ; do + einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..." + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)" + if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then + if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]] ; then + ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!" + MYSQL_ROOT_PASSWORD= + continue + fi + + einfo "Found password in '${tmp_mysqld_password_source}' section!" + break + fi + done + + # Sometimes --show is required to display passwords in some implementations of my_print_defaults + if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]] ; then + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)" + fi + + unset tmp_mysqld_password_source + fi + + if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then + local pwd1="a" + local pwd2="b" + + echo + einfo "No password for mysql 'root' user was specified via environment" + einfo "variable MYSQL_ROOT_PASSWORD and no password was found in config" + einfo "file like '${HOME}/.my.cnf'." + einfo "To continue please provide a password for the mysql 'root' user" + einfo "now on console:" + ewarn "NOTE: Please avoid [\"'\\_%] characters in the password!" + read -rsp " >" pwd1 ; echo + + einfo "Retype the password" + read -rsp " >" pwd2 ; echo + + if [[ "x$pwd1" != "x$pwd2" ]] ; then + die "Passwords are not the same!" + fi + + MYSQL_ROOT_PASSWORD="${pwd1}" + unset pwd1 pwd2 + + echo + fi + + local -a mysqld_options + + # Fix bug 446200. Don't reference host my.cnf, needs to come first, + # see http://bugs.mysql.com/bug.php?id=31312 + use prefix && mysqld_options+=( "--defaults-file='${MY_SYSCONFDIR}/my.cnf'" ) + + # Figure out which options we need to disable to do the setup + local helpfile="${TMPDIR}/mysqld-help" + "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null + + local opt optexp optfull + for opt in host-cache name-resolve networking slave-start \ + federated ssl log-bin relay-log slow-query-log external-locking \ + log-slave-updates \ + ; do + optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}" + egrep -sq -- "${optexp}" "${helpfile}" && mysqld_options+=( "${optfull}" ) + done + + # Prepare timezones, see + # https://dev.mysql.com/doc/mysql/en/time-zone-support.html + local tz_sql="$(_mktemp_dry "${MYSQL_TMPDIR}/tz.XXXXXXXXX.sql")" + [[ -z "${tz_sql}" ]] \ + && die "_mktemp_dry() for '${MYSQL_TMPDIR}/tz.XXXXXXXXX.sql' failed!" + + echo "USE mysql;" >"${tz_sql}" + "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" >> "${tz_sql}" 2>/dev/null + if [[ $? -ne 0 ]] ; then + die "mysql_tzinfo_to_sql failed!" + fi + + # --initialize-insecure will not set root password + # --initialize would set a random one in the log which we don't need as we set it ourselves + local cmd=( + "${mysqld_binary}" + "${mysqld_options[@]}" + "--initialize-insecure" + "--init-file='${tz_sql}'" + "--basedir='${EROOT}/usr'" + "--datadir='${MY_DATADIR}'" + "--tmpdir='${MYSQL_TMPDIR}'" + "--log-error='${mysql_install_log}'" + "--user=${MYSQL_USER}" + ) + + einfo "Initializing ${PN} data directory: ${cmd[@]}" + eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1 + + if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql.ibd" ]] ; then + grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_install_log}" 1>&2 + die "Failed to initialize ${PN} data directory. Please review '${mysql_install_log}'!" + fi + + rm "${tz_sql}" || die + + local x=${RANDOM} + local socket="${EROOT}${PID_DIR}/mysqld${x}.sock" + local pidfile="${EROOT}${PID_DIR}/mysqld${x}.pid" + unset x + + cmd=( + "${mysqld_binary}" + "${mysqld_options[@]}" + "--basedir='${EROOT}/usr'" + "--datadir='${MY_DATADIR}'" + "--tmpdir='${MYSQL_TMPDIR}'" + --max_allowed_packet=8M + --net_buffer_length=16K + "--socket='${socket}'" + "--pid-file='${pidfile}'" + "--log-error='${mysqld_logfile}'" + "--user=${MYSQL_USER}" + ) + + einfo "Starting mysqld to finalize initialization: ${cmd[@]}" + eval "${cmd[@]}" >>"${mysqld_logfile}" 2>&1 & + + echo -n "Waiting for mysqld to accept connections " + local maxtry=15 + while [[ ! -S "${socket}" && "${maxtry}" -gt 1 ]] ; do + maxtry=$((${maxtry}-1)) + echo -n "." + sleep 1 + done + + if [[ -S "${socket}" ]] ; then + # Even with a socket we don't know if mysqld will abort + # start due to an error so just wait a little bit more... + maxtry=5 + while [[ -S "${socket}" && "${maxtry}" -gt 1 ]] ; do + maxtry=$((${maxtry}-1)) + echo -n "." + sleep 1 + done + fi + + echo + + if [[ ! -S "${socket}" ]] ; then + grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysqld_logfile}" 1>&2 + die "mysqld was unable to start from initialized data directory. Please review '${mysqld_logfile}'!" + fi + + local mysql_logfile="${TMPDIR}/set_root_pw.log" + touch "${mysql_logfile}" || die + + ebegin "Setting root password" + # Do this from memory, as we don't want clear text passwords in temp files + local sql="ALTER USER 'root'@'localhost' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}'" + cmd=( + "${mysql_binary}" + --no-defaults + "--socket='${socket}'" + -hlocalhost + "-e \"${sql}\"" + ) + eval "${cmd[@]}" >"${mysql_logfile}" 2>&1 + local rc=$? + eend ${rc} + + if [[ ${rc} -ne 0 ]] ; then + # Poor man's solution which tries to avoid having password + # in log. NOTE: sed can fail if user didn't follow advice + # and included character which will require escaping... + sed -i -e "s/${MYSQL_ROOT_PASSWORD}/*****/" "${mysql_logfile}" 2>/dev/null + + grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_logfile}" + die "Failed to set ${PN} root password. Please review '${mysql_logfile}'!" + fi + + # Stop the server + if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then + echo -n "Stopping the server " + pkill -F "${pidfile}" &>/dev/null + + maxtry=10 + while [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; do + maxtry=$((${maxtry}-1)) + echo -n "." + sleep 1 + done + + echo + + if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then + # We somehow failed to stop server. + # However, not a fatal error. Just warn the user. + ewarn "WARNING: mysqld[$(cat "${pidfile}")] is still running!" + fi + fi + + einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!" +} diff --git a/dev-db/percona-server/percona-server-8.0.26.16.ebuild b/dev-db/percona-server/percona-server-8.0.26.16.ebuild deleted file mode 100644 index 9098b344ce11..000000000000 --- a/dev-db/percona-server/percona-server-8.0.26.16.ebuild +++ /dev/null @@ -1,1275 +0,0 @@ -# Copyright 1999-2021 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI="7" - -CMAKE_MAKEFILE_GENERATOR=emake - -inherit check-reqs cmake flag-o-matic linux-info \ - multiprocessing prefix toolchain-funcs - -MY_BOOST_VERSION="1.73.0" -MY_PV=$(ver_rs 3 '-') -MY_PV="${MY_PV//_pre*}" -MY_PN="Percona-Server" -MY_P="${PN}-${MY_PV}" -MY_MAJOR_PV=$(ver_cut 1-2) -MY_RELEASE_NOTES_URI="https://www.percona.com/doc/percona-server/${MY_MAJOR_PV}/" - -# Patch version -PATCH_SET="https://dev.gentoo.org/~whissi/dist/percona-server/${PN}-8.0.26.16-patches-01.tar.xz" - -SRC_URI="https://www.percona.com/downloads/${MY_PN}-${MY_MAJOR_PV}/${MY_PN}-${MY_PV}/source/tarball/${PN}-${MY_PV}.tar.gz - https://dl.bintray.com/boostorg/release/${MY_BOOST_VERSION}/source/boost_$(ver_rs 1- _ ${MY_BOOST_VERSION}).tar.bz2 - ${PATCH_SET} -" - -HOMEPAGE="https://www.percona.com/software/mysql-database/percona-server https://github.com/percona/percona-server" -DESCRIPTION="Fully compatible, enhanced and open source drop-in replacement for MySQL" -LICENSE="GPL-2" -SLOT="8.0" -IUSE="cjk cracklib debug jemalloc latin1 ldap numa pam +perl profiling - rocksdb router selinux +server tcmalloc test tokudb tokudb-backup-plugin" - -RESTRICT="!test? ( test )" - -REQUIRED_USE="?? ( tcmalloc jemalloc ) - cjk? ( server ) - jemalloc? ( server ) - numa? ( server ) - profiling? ( server ) - router? ( server ) - tcmalloc? ( server )" - -KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 -riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris ~x86-solaris" - -# Shorten the path because the socket path length must be shorter than 107 chars -# and we will run a mysql server during test phase -S="${WORKDIR}/mysql" - -# Be warned, *DEPEND are version-dependant -# These are used for both runtime and compiletime -COMMON_DEPEND=" - >=app-arch/lz4-0_p131:= - app-arch/zstd:= - sys-libs/ncurses:0= - >=sys-libs/zlib-1.2.3:0= - >=dev-libs/openssl-1.0.0:0= - server? ( - dev-libs/icu:= - dev-libs/libevent:=[ssl,threads] - >=dev-libs/protobuf-3.8:= - net-libs/libtirpc:= - net-misc/curl:= - cjk? ( app-text/mecab:= ) - ldap? ( - dev-libs/cyrus-sasl - net-nds/openldap - ) - jemalloc? ( dev-libs/jemalloc:0= ) - kernel_linux? ( - dev-libs/libaio:0= - sys-process/procps:0= - ) - numa? ( sys-process/numactl ) - pam? ( sys-libs/pam:0= ) - tcmalloc? ( dev-util/google-perftools:0= ) - ) -" -DEPEND="${COMMON_DEPEND} - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) - virtual/yacc - server? ( net-libs/rpcsvc-proto ) - test? ( - acct-group/mysql acct-user/mysql - dev-perl/JSON - ) -" -RDEPEND="${COMMON_DEPEND} - !dev-db/mariadb !dev-db/mariadb-galera !dev-db/mysql !dev-db/mysql-cluster - !dev-db/percona-server:0 - !dev-db/percona-server:5.7 - selinux? ( sec-policy/selinux-mysql ) - !prefix? ( - acct-group/mysql acct-user/mysql - dev-db/mysql-init-scripts - ) -" -# For other stuff to bring us in -# dev-perl/DBD-mysql is needed by some scripts installed by MySQL -PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )" - -mysql_init_vars() { - : ${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mysql"} - : ${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"} - : ${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"} - : ${MY_LOGDIR="${EPREFIX}/var/log/mysql"} - MY_DATADIR="${MY_LOCALSTATEDIR}" - - export MY_SHAREDSTATEDIR MY_SYSCONFDIR - export MY_LOCALSTATEDIR MY_LOGDIR - export MY_DATADIR -} - -pkg_pretend() { - if [[ ${MERGE_TYPE} != binary ]] ; then - if use server ; then - CHECKREQS_DISK_BUILD="3G" - - if has test $FEATURES ; then - CHECKREQS_DISK_BUILD="9G" - fi - - check-reqs_pkg_pretend - fi - fi -} - -pkg_setup() { - if [[ ${MERGE_TYPE} != binary ]] ; then - CHECKREQS_DISK_BUILD="3G" - - if has test ${FEATURES} ; then - CHECKREQS_DISK_BUILD="9G" - - # Bug #213475 - MySQL _will_ object strenuously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if ! has userpriv ${FEATURES} ; then - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." - fi - - local aio_max_nr=$(sysctl -n fs.aio-max-nr 2>/dev/null) - [[ -z "${aio_max_nr}" || ${aio_max_nr} -lt 250000 ]] \ - && die "FEATURES=test will require fs.aio-max-nr=250000 at minimum!" - - if use latin1 ; then - # Upstream only supports tests with default charset - die "Testing with USE=latin1 is not supported." - fi - fi - - if use kernel_linux ; then - if use numa ; then - linux-info_get_any_version - - local CONFIG_CHECK="~NUMA" - - local WARNING_NUMA="This package expects NUMA support in kernel which this system does not have at the moment;" - WARNING_NUMA+=" Either expect runtime errors, enable NUMA support in kernel or rebuild the package without NUMA support" - - check_extra_config - fi - fi - - use server && check-reqs_pkg_setup - fi -} - -src_unpack() { - unpack ${A} - - mv -f "${WORKDIR}/${MY_P}" "${S}" || die -} - -src_prepare() { - eapply "${WORKDIR}"/mysql-patches - - # Avoid rpm call which would trigger sandbox, #692368 - sed -i \ - -e 's/MY_RPM rpm/MY_RPM rpmNOTEXISTENT/' \ - CMakeLists.txt || die - - if use jemalloc ; then - echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" || die - fi - - if use tcmalloc ; then - echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" || die - fi - - # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux - if [[ -d "${S}/support-files/SELinux" ]] ; then - echo > "${S}/support-files/SELinux/CMakeLists.txt" || die - fi - - # Remove man pages for client-lib tools we don't install - rm \ - man/my_print_defaults.1 \ - man/perror.1 \ - man/zlib_decompress.1 \ - || die - - cmake_src_prepare -} - -src_configure() { - # Bug #114895, bug #110149 - filter-flags "-O" "-O[01]" - - append-cxxflags -felide-constructors - - # code is not C++17 ready, bug #786402 - append-cxxflags -std=c++14 - - # bug #283926, with GCC4.4, this is required to get correct behavior. - append-flags -fno-strict-aliasing - - CMAKE_BUILD_TYPE="RelWithDebInfo" - - # debug hack wrt #497532 - mycmakeargs=( - -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" - -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" - -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql" - -DSYSCONFDIR="${EPREFIX}/etc/mysql" - -DINSTALL_BINDIR=bin - -DINSTALL_DOCDIR=share/doc/${PF} - -DINSTALL_DOCREADMEDIR=share/doc/${PF} - -DINSTALL_INCLUDEDIR=include/mysql - -DINSTALL_INFODIR=share/info - -DINSTALL_LIBDIR=$(get_libdir) - -DINSTALL_MANDIR=share/man - -DINSTALL_MYSQLSHAREDIR=share/mysql - -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" - -DINSTALL_SBINDIR=sbin - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mysql" - -DCOMPILATION_COMMENT="Gentoo Linux ${PF}" - -DWITH_UNIT_TESTS=$(usex test ON OFF) - # Using bundled editline to get CTRL+C working - -DWITH_EDITLINE=bundled - -DWITH_ZLIB=system - -DWITH_SSL=system - -DWITH_LIBWRAP=0 - -DENABLED_LOCAL_INFILE=1 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DWITH_DEFAULT_COMPILER_OPTIONS=0 - # The build forces this to be defined when cross-compiling. We pass it - # all the time for simplicity and to make sure it is actually correct. - -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1) - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DWITH_CURL=system - -DWITH_BOOST="${WORKDIR}/boost_$(ver_rs 1- _ ${MY_BOOST_VERSION})" - -DWITH_ROUTER=$(usex router ON OFF) - ) - - if is-flagq -fno-lto ; then - einfo "LTO disabled via {C,CXX,F,FC}FLAGS" - mycmakeargs+=( -DWITH_LTO=OFF ) - elif is-flagq -flto ; then - einfo "LTO forced via {C,CXX,F,FC}FLAGS" - myconf+=( -DWITH_LTO=ON ) - else - # Disable automagic - myconf+=( -DWITH_LTO=OFF ) - fi - - if use test ; then - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test ) - else - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) - fi - - mycmakeargs+=( -DWITHOUT_CLIENTLIBS=YES ) - - mycmakeargs+=( - -DWITH_ICU=system - -DWITH_LZ4=system - # Our dev-libs/rapidjson doesn't carry necessary fixes for std::regex - -DWITH_RAPIDJSON=bundled - -DWITH_ZSTD=system - ) - - if [[ -n "${MYSQL_DEFAULT_CHARSET}" && -n "${MYSQL_DEFAULT_COLLATION}" ]] ; then - ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}" - ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}." - ewarn "You MUST file bugs without these variables set." - ewarn "Tests will probably fail!" - - mycmakeargs+=( - -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET} - -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION} - ) - elif use latin1 ; then - mycmakeargs+=( - -DDEFAULT_CHARSET=latin1 - -DDEFAULT_COLLATION=latin1_swedish_ci - ) - else - mycmakeargs+=( - -DDEFAULT_CHARSET=utf8mb4 - -DDEFAULT_COLLATION=utf8mb4_0900_ai_ci - ) - fi - - if use server ; then - mycmakeargs+=( - -DWITH_AUTHENTICATION_LDAP=$(usex ldap system OFF) - -DWITH_COREDUMPER=OFF - -DWITH_EXTRA_CHARSETS=all - -DWITH_DEBUG=$(usex debug) - -DWITH_MECAB=$(usex cjk system OFF) - -DWITH_LIBEVENT=system - -DWITH_PROTOBUF=system - -DWITH_NUMA=$(usex numa ON OFF) - -DWITH_PAM=$(usex pam) - ) - - if use profiling ; then - # Setting to OFF doesn't work: Once set, profiling options will be added - # to `mysqld --help` output via sql/sys_vars.cc causing - # "main.mysqld--help-notwin" test to fail - mycmakeargs+=( -DENABLED_PROFILING=ON ) - fi - - # Storage engines - mycmakeargs+=( - -DWITH_EXAMPLE_STORAGE_ENGINE=0 - -DWITH_ARCHIVE_STORAGE_ENGINE=1 - -DWITH_BLACKHOLE_STORAGE_ENGINE=1 - -DWITH_CSV_STORAGE_ENGINE=1 - -DWITH_FEDERATED_STORAGE_ENGINE=1 - -DWITH_HEAP_STORAGE_ENGINE=1 - -DWITH_INNOBASE_STORAGE_ENGINE=1 - -DWITH_INNODB_MEMCACHED=0 - -DWITH_MYISAMMRG_STORAGE_ENGINE=1 - -DWITH_MYISAM_STORAGE_ENGINE=1 - -DWITH_ROCKSDB=$(usex rocksdb 1 0) - -DWITH_TOKUDB=$(usex tokudb 1 0) - ) - else - mycmakeargs+=( - -DWITHOUT_SERVER=1 - -DWITH_SYSTEMD=no - ) - fi - - cmake_src_configure -} - -# Official test instructions: -# ulimit -n 16500 && \ -# USE='perl server' \ -# FEATURES='test userpriv' \ -# ebuild mysql-X.X.XX.ebuild \ -# digest clean package -src_test() { - _disable_test() { - local rawtestname bug reason - rawtestname="${1}" ; shift - bug="${1}" ; shift - reason="${@}" - ewarn "test '${rawtestname}' disabled: '${reason}' (BUG#${bug})" - echo ${rawtestname} : BUG#${bug} ${reason} >> "${T}/disabled.def" - } - - local TESTDIR="${BUILD_DIR}/mysql-test" - local retstatus_tests - - if ! use server ; then - einfo "Skipping server tests due to minimal build." - return 0 - fi - - # Ensure that parallel runs don't die - export MTR_BUILD_THREAD="$((${RANDOM} % 100))" - - if [[ -z "${MTR_PARALLEL}" ]] ; then - local -x MTR_PARALLEL=$(makeopts_jobs) - - if [[ ${MTR_PARALLEL} -gt 4 ]] ; then - # Running multiple tests in parallel usually require higher ulimit - # and fs.aio-max-nr setting. In addition, tests like main.multi_update - # are known to hit timeout when system is busy. - # To avoid test failure we will limit MTR_PARALLEL to 4 instead of - # using "auto". - local info_msg="Parallel MySQL test suite jobs limited to 4 (MAKEOPTS=${MTR_PARALLEL})" - info_msg+=" to avoid test failures. Set MTR_PARALLEL if you know what you are doing!" - einfo "${info_msg}" - unset info_msg - MTR_PARALLEL=4 - fi - else - einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" - fi - - # create directories because mysqladmin might run out of order - mkdir -p "${T}"/var-tests{,/log} || die - - # Run mysql tests - pushd "${TESTDIR}" &>/dev/null || die - - touch "${T}/disabled.def" - - local -a disabled_tests - disabled_tests+=( "auth_sec.atomic_rename_user;103512;Depends on user running test" ) - disabled_tests+=( "auth_sec.keyring_file_data_qa;0;Won't work with user privileges" ) - disabled_tests+=( "gis.geometry_class_attri_prop;5452;Known rounding error with latest AMD processors (PS)" ) - disabled_tests+=( "gis.geometry_property_function_issimple;5452;Known rounding error with latest AMD processors (PS)" ) - disabled_tests+=( "gis.gis_bugs_crashes;5452;Known rounding error with latest AMD processors (PS)" ) - disabled_tests+=( "gis.spatial_analysis_functions_buffer;5452;Known rounding error with latest AMD processors (PS)" ) - disabled_tests+=( "gis.spatial_analysis_functions_centroid;5452;Known rounding error with latest AMD processors (PS)" ) - disabled_tests+=( "gis.spatial_analysis_functions_distance;5452;Known rounding error with latest AMD processors (PS)" ) - disabled_tests+=( "gis.spatial_op_testingfunc_mix;5452;Known rounding error with latest AMD processors (PS)" ) - disabled_tests+=( "gis.spatial_operators_intersection;5452;Known rounding error with latest AMD processors (PS)" ) - disabled_tests+=( "gis.spatial_utility_function_distance_sphere;5452;Known rounding error with latest AMD processors (PS)" ) - disabled_tests+=( "gis.spatial_utility_function_simplify;5452;Known rounding error with latest AMD processors (PS)" ) - disabled_tests+=( "group_replication.gr_ssl_options2;0;Sporadic failing test" ) - disabled_tests+=( "innodb.alter_kill;0;Known test failure -- no upstream bug yet" ) - disabled_tests+=( "innodb.percona_changed_page_bmp_flush;6807;False positive on Gentoo (PS)" ) - disabled_tests+=( "innodb.percona_changed_page_bmp_log_resize;0;Sporadic failing test" ) - disabled_tests+=( "innodb.percona_log_encrypt_change_mk;6039;False positive on Gentoo (PS)" ) - disabled_tests+=( "innodb.percona_log_encrypt_change_rk;6805;False positive on Gentoo (PS)" ) - disabled_tests+=( "innodb.percona_log_encrypt_failure;0;Requires proper keyring setup" ) - disabled_tests+=( "innodb.upgrade_orphan;0;Sporadic failing test" ) - disabled_tests+=( "main.coredump;0;Known test failure" ) - disabled_tests+=( "main.derived_limit;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) - disabled_tests+=( "main.explain_tree;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) - disabled_tests+=( "main.gis-precise;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) - disabled_tests+=( "main.mtr_unit_tests;7975;Known test failure (PS)" ) - disabled_tests+=( "main.myisam-blob;0;Sporadic failing test" ) - disabled_tests+=( "main.mysql_load_data_local_dir;7416;Known test failure" ) - disabled_tests+=( "main.mysqlpump_basic_lz4;6042;Extra tool output causes false positive" ) - disabled_tests+=( "main.ssl_bug75311;5996;Known test failure" ) - disabled_tests+=( "main.ssl_san;6808;False positive on IPv6-enabled hosts" ) - disabled_tests+=( "main.subquery_bugs;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) - disabled_tests+=( "main.subquery_sj_dupsweed;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) - disabled_tests+=( "main.subquery_sj_dupsweed_bka;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) - disabled_tests+=( "main.subquery_sj_dupsweed_bka_nobnl;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) - disabled_tests+=( "main.subquery_sj_firstmatch;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) - disabled_tests+=( "main.subquery_sj_firstmatch_bka;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) - disabled_tests+=( "main.subquery_sj_firstmatch_bka_nobnl;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) - disabled_tests+=( "main.subquery_sj_mat_bka_nobnl;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) - disabled_tests+=( "main.window_std_var;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) - disabled_tests+=( "main.window_std_var_optimized;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) - disabled_tests+=( "main.with_recursive;6804;Known rounding error with latest AMD processors" ) - disabled_tests+=( "rpl_gtid.rpl_gtid_stm_drop_table;90612;Known test failure" ) - disabled_tests+=( "rpl_gtid.rpl_multi_source_mtr_includes;0;Know failure - no upstream bug yet" ) - disabled_tests+=( "sys_vars.innodb_sys_tablespace_encrypt_basic;7415;Known test failure" ) - disabled_tests+=( "sys_vars.myisam_data_pointer_size_func;87935;Test will fail on slow hardware" ) - disabled_tests+=( "x.message_compressed_payload;0;False positive caused by protobuff-3.11+" ) - disabled_tests+=( "x.message_protobuf_nested;6803;False positive caused by protobuff-3.11+" ) - - if ! hash zip 1>/dev/null 2>&1 ; then - # no need to force dep app-arch/zip for one test - disabled_tests+=( "innodb.discarded_partition_create;0;Requires app-arch/zip" ) - disabled_tests+=( "innodb.partition_upgrade_create;0;Requires app-arch/zip" ) - fi - - if has_version ">=dev-libs/openssl-3" ; then - # >=dev-libs/openssl-3 defaults to security level 1 which disallow - # TLSv1/1.1 but tests will require TLSv1/1.1. - einfo "Set OpenSSL configuration for test suite ..." - cat > "${T}/openssl_tlsv1.cnf" <<- EOF || die - openssl_conf = default_conf - - [ req ] - default_bits = 2048 - default_keyfile = privkey.pem - distinguished_name = req_distinguished_name - - [ req_distinguished_name ] - countryName = Country Name (2 letter code) - countryName_default = AU - countryName_min = 2 - countryName_max = 2 - - stateOrProvinceName = State or Province Name (full name) - stateOrProvinceName_default = Some-State - - localityName = Locality Name (eg, city) - - 0.organizationName = Organization Name (eg, company) - 0.organizationName_default = Internet Widgits Pty Ltd - - organizationalUnitName = Organizational Unit Name (eg, section) - - commonName = Common Name (e.g. server FQDN or YOUR name) - commonName_max = 64 - - emailAddress = Email Address - emailAddress_max = 64 - - [default_conf] - ssl_conf = ssl_sect - - [ssl_sect] - system_default = system_default_sect - - [system_default_sect] - CipherString = DEFAULT@SECLEVEL=0 - EOF - - local -x OPENSSL_CONF="${T}/openssl_tlsv1.cnf" - - disabled_tests+=( "x.connection_tls_version;0;Not compatible with OpenSSL 3.x error messages" ) - fi - - local test_infos_str test_infos_arr - for test_infos_str in "${disabled_tests[@]}" ; do - IFS=';' read -r -a test_infos_arr <<< "${test_infos_str}" - - if [[ ${#test_infos_arr[@]} != 3 ]] ; then - die "Invalid test data set, not matching format: ${test_infos_str}" - fi - - _disable_test "${test_infos_arr[0]}" "${test_infos_arr[1]}" "${test_infos_arr[2]}" - done - unset test_infos_str test_infos_arr - - if [[ -z "${MTR_VAULT_TOKEN}" ]] ; then - local impossible_test - for impossible_test in \ - encryption.default_table_encryption_var \ - encryption.innodb-redo-nokeys2_release \ - keyring_vault.innodb_online_alter_encryption \ - keyring_vault.innodb_row_log_encryption \ - keyring_vault.install_keyring_vault \ - keyring_vault.keyring_udf \ - keyring_vault.keyring_vault_config \ - keyring_vault.keyring_vault_config_qa \ - keyring_vault.keyring_vault_timeout \ - keyring_vault.key_rotation_qa \ - keyring_vault.rpl_key_rotation \ - keyring_vault.table_encrypt_2 \ - keyring_vault.table_encrypt_2_directory \ - keyring_vault.table_encrypt_2_keyring \ - keyring_vault.table_encrypt_5 \ - keyring_vault.table_encrypt_5_directory \ - keyring_vault.table_encrypt_kill \ - keyring_vault.temp_table_encrypt_keyring_vault \ - main.persisted_variables \ - ; do - _disable_test "${impossible_test}" "0" "MTR_VAULT_TOKEN is not set" - done - fi - - # Try to increase file limits to increase test coverage - if ! ulimit -n 16500 1>/dev/null 2>&1 ; then - # Upper limit comes from parts.partition_* tests - ewarn "For maximum test coverage please raise open file limit to 16500 (ulimit -n 16500) before calling the package manager." - - if ! ulimit -n 4162 1>/dev/null 2>&1 ; then - # Medium limit comes from '[Warning] Buffered warning: Could not increase number of max_open_files to more than 3000 (request: 4162)' - ewarn "For medium test coverage please raise open file limit to 4162 (ulimit -n 4162) before calling the package manager." - - if ! ulimit -n 3000 1>/dev/null 2>&1 ; then - ewarn "For minimum test coverage please raise open file limit to 3000 (ulimit -n 3000) before calling the package manager." - else - einfo "Will run test suite with open file limit set to 3000 (minimum test coverage)." - fi - else - einfo "Will run test suite with open file limit set to 4162 (medium test coverage)." - fi - else - einfo "Will run test suite with open file limit set to 16500 (best test coverage)." - fi - - # run mysql-test tests - perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def" - retstatus_tests=$? - - popd &>/dev/null || die - - # Cleanup is important for these testcases. - pkill -9 -f "${S}/ndb" 2>/dev/null - pkill -9 -f "${S}/sql" 2>/dev/null - - local failures="" - [[ ${retstatus_tests} -eq 0 ]] || failures="${failures} tests" - - [[ -z "${failures}" ]] || die "Test failures: ${failures}" - einfo "Tests successfully completed" -} - -src_install() { - cmake_src_install - - # Make sure the vars are correctly initialized - mysql_init_vars - - # Convenience links - einfo "Making Convenience links for mysqlcheck multi-call binary" - dosym "mysqlcheck" "/usr/bin/mysqlanalyze" - dosym "mysqlcheck" "/usr/bin/mysqlrepair" - dosym "mysqlcheck" "/usr/bin/mysqloptimize" - - # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir - if [[ -d "${ED}/usr/data" ]] ; then - rm -Rf "${ED}/usr/data" || die - fi - - # Unless they explicitly specific USE=test, then do not install the - # testsuite. It DOES have a use to be installed, esp. when you want to do a - # validation of your database configuration after tuning it. - if ! use test ; then - rm -rf "${ED}/${MY_SHAREDSTATEDIR#${EPREFIX}}/mysql-test" - fi - - # Configuration stuff - einfo "Building default configuration ..." - insinto "${MY_SYSCONFDIR#${EPREFIX}}" - [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf - cp "${FILESDIR}/my.cnf-5.7" "${TMPDIR}/my.cnf" || die - eprefixify "${TMPDIR}/my.cnf" - doins "${TMPDIR}/my.cnf" - insinto "${MY_SYSCONFDIR#${EPREFIX}}/mysql.d" - cp "${FILESDIR}/my.cnf-8.0.distro-client" "${TMPDIR}/50-distro-client.cnf" || die - eprefixify "${TMPDIR}/50-distro-client.cnf" - doins "${TMPDIR}/50-distro-client.cnf" - - mycnf_src="my.cnf-8.0.distro-server" - sed -e "s!@DATADIR@!${MY_DATADIR}!g" \ - "${FILESDIR}/${mycnf_src}" \ - > "${TMPDIR}/my.cnf.ok" || die - - if use prefix ; then - sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \ - "${TMPDIR}/my.cnf.ok" || die - fi - - if use latin1 ; then - sed -i \ - -e "/character-set/s|utf8mb4|latin1|g" \ - "${TMPDIR}/my.cnf.ok" || die - fi - - eprefixify "${TMPDIR}/my.cnf.ok" - - newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf - - #Remove mytop if perl is not selected - [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop" - - if use router ; then - rm -rf \ - "${ED}/usr/LICENSE.router" \ - "${ED}/usr/README.router" \ - "${ED}/usr/run" \ - "${ED}/usr/var" \ - || die - fi - - # Kill old libmysqclient_r symlinks if they exist. Time to fix what depends on them. - find "${D}" -name 'libmysqlclient_r.*' -type l -delete || die -} - -pkg_postinst() { - # Make sure the vars are correctly initialized - mysql_init_vars - - # Create log directory securely if it does not exist - # NOTE: $MY_LOGDIR contains $EPREFIX by default - [[ -d "${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${MY_LOGDIR}" - - # Note about configuration change - einfo - elog "This version of ${PN} reorganizes the configuration from a single my.cnf" - elog "to several files in /etc/mysql/mysql.d." - elog "Please backup any changes you made to /etc/mysql/my.cnf" - elog "and add them as a new file under /etc/mysql/mysql.d with a .cnf extension." - elog "You may have as many files as needed and they are read alphabetically." - elog "Be sure the options have the appropriate section headers, i.e. [mysqld]." - einfo - - if [[ -z "${REPLACING_VERSIONS}" ]] ; then - einfo - elog "You might want to run:" - elog " \"emerge --config =${CATEGORY}/${PF}\"" - elog "if this is a new install." - einfo - else - einfo - elog "Upgrade process for ${PN}-8.x has changed. Please read" - elog "https://dev.mysql.com/doc/refman/8.0/en/upgrade-binary-package.html" - einfo - fi -} - -pkg_config() { - _getoptval() { - local section="$1" - local flag="--${2}=" - local extra_options="${3}" - local cmd=( - "${my_print_defaults_binary}" - "${extra_options}" - "${section}" - ) - local results=( $(eval "${cmd[@]}" 2>/dev/null | sed -n "/^${flag}/s,${flag},,gp") ) - - if [[ ${#results[@]} -gt 0 ]] ; then - # When option is set multiple times only return last value - echo "${results[-1]}" - fi - } - - _mktemp_dry() { - # emktemp has no --dry-run option - local template="${1}" - - if [[ -z "${template}" ]] ; then - if [[ -z "${T}" ]] ; then - template="/tmp/XXXXXXX" - else - template="${T}/XXXXXXX" - fi - fi - - local template_wo_X=${template//X/} - local n_X - let n_X=${#template}-${#template_wo_X} - if [[ ${n_X} -lt 3 ]] ; then - echo "${FUNCNAME[0]}: too few X's in template ‘${template}’" >&2 - return - fi - - local attempts=0 - local character tmpfile - while [[ true ]] ; do - let attempts=attempts+1 - - new_file= - while read -n1 character ; do - if [[ "${character}" == "X" ]] ; then - tmpfile+="${RANDOM:0:1}" - else - tmpfile+="${character}" - fi - done < <(echo -n "${template}") - - if [[ ! -f "${tmpfile}" ]] - then - echo "${tmpfile}" - return - fi - - if [[ ${attempts} -ge 100 ]] ; then - echo "${FUNCNAME[0]}: Cannot create temporary file after 100 attempts." >&2 - return - fi - done - } - - local mysqld_binary="${EROOT}/usr/sbin/mysqld" - if [[ ! -x "${mysqld_binary}" ]] ; then - die "'${mysqld_binary}' not found! Please re-install ${CATEGORY}/${PN}!" - fi - - local mysql_binary="${EROOT}/usr/bin/mysql" - if [[ ! -x "${mysql_binary}" ]] ; then - die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!" - fi - - local my_print_defaults_binary="${EROOT}/usr/bin/my_print_defaults" - if [[ ! -x "${my_print_defaults_binary}" ]] ; then - die "'${my_print_defaults_binary}' not found! Please re-install dev-db/mysql-connector-c!" - fi - - if [[ -z "${MYSQL_USER}" ]] ; then - MYSQL_USER=mysql - if use prefix ; then - MYSQL_USER=$(id -u -n 2>/dev/null) - if [[ -z "${MYSQL_USER}" ]] ; then - die "Failed to determine current username!" - fi - fi - fi - - if [[ -z "${MYSQL_GROUP}" ]] ; then - MYSQL_GROUP=mysql - if use prefix ; then - MYSQL_GROUP=$(id -g -n 2>/dev/null) - if [[ -z "${MYSQL_GROUP}" ]] ; then - die "Failed to determine current user groupname!" - fi - fi - fi - - # my_print_defaults needs to read stuff in $HOME/.my.cnf - local -x HOME="${EROOT}/root" - - # Make sure the vars are correctly initialized - mysql_init_vars - - # Read currently set data directory - MY_DATADIR="$(_getoptval mysqld datadir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" - - # Bug #213475 - MySQL _will_ object strenously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if [[ -z "${MY_DATADIR}" ]] ; then - die "Sorry, unable to find MY_DATADIR!" - elif [[ -d "${MY_DATADIR}/mysql" ]] ; then - ewarn "Looks like your data directory '${MY_DATADIR}' is already initialized!" - ewarn "Please rename or delete its content if you wish to initialize a new data directory." - die "${PN} data directory at '${MY_DATADIR}' looks already initialized!" - fi - - MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" - MYSQL_TMPDIR=${MYSQL_TMPDIR%/} - # These are dir+prefix - MYSQL_LOG_BIN="$(_getoptval mysqld log-bin "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" - MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} - MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" - MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} - - # Create missing directories. - # Always check if mysql user can write to directory even if we just - # created directory because a parent directory might be not - # accessible for that user. - PID_DIR="${EROOT}/run/mysqld" - if [[ ! -d "${PID_DIR}" ]] ; then - einfo "Creating ${PN} PID directory '${PID_DIR}' ..." - install -d -m 755 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${PID_DIR}" \ - || die "Failed to create PID directory '${PID_DIR}'!" - fi - - local _pid_dir_testfile="$(_mktemp_dry "${PID_DIR}/.pkg_config-access-test.XXXXXXXXX")" - [[ -z "${_pid_dir_testfile}" ]] \ - && die "_mktemp_dry() for '${PID_DIR}/.pkg_config-access-test.XXXXXXXXX' failed!" - - if use prefix ; then - touch "${_pid_dir_testfile}" &>/dev/null - else - su -s /bin/sh -c "touch ${_pid_dir_testfile}" ${MYSQL_USER} &>/dev/null - fi - - if [[ $? -ne 0 ]] ; then - die "${MYSQL_USER} user cannot write into PID dir '${PID_DIR}'!" - else - rm "${_pid_dir_testfile}" || die - unset _pid_dir_testfile - fi - - if [[ ! -d "${MY_DATADIR}" ]] ; then - einfo "Creating ${PN} data directory '${MY_DATADIR}' ..." - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MY_DATADIR}" \ - || die "Failed to create ${PN} data directory '${MY_DATADIR}'!" - fi - - local _my_datadir_testfile="$(_mktemp_dry "${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX")" - [[ -z "${_my_datadir_testfile}" ]] \ - && die "_mktemp_dry() for '${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX' failed!" - - if use prefix ; then - touch "${_my_datadir_testfile}" &>/dev/null - else - su -s /bin/sh -c "touch ${_my_datadir_testfile}" ${MYSQL_USER} &>/dev/null - fi - - if [[ $? -ne 0 ]] ; then - die "${MYSQL_USER} user cannot write into data directory '${MY_DATADIR}'!" - else - rm "${_my_datadir_testfile}" || die - unset _my_datadir_testfile - fi - - if [[ -n "${MYSQL_TMPDIR}" && ! -d "${MYSQL_TMPDIR}" ]] ; then - einfo "Creating ${PN} tmpdir '${MYSQL_TMPDIR}' ..." - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_TMPDIR}" \ - || die "Failed to create ${PN} tmpdir '${MYSQL_TMPDIR}'!" - fi - - if [[ -z "${MYSQL_TMPDIR}" ]] ; then - MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")" - [[ -z "${MYSQL_TMPDIR}" ]] \ - && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!" - - mkdir "${MYSQL_TMPDIR}" || die - chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die - fi - - # Now we need to test MYSQL_TMPDIR... - local _my_tmpdir_testfile="$(_mktemp_dry "${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX")" - [[ -z "${_my_tmpdir_testfile}" ]] \ - && die "_mktemp_dry() for '${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX' failed!" - - if use prefix ; then - touch "${_my_tmpdir_testfile}" &>/dev/null - else - su -s /bin/sh -c "touch ${_my_tmpdir_testfile}" ${MYSQL_USER} &>/dev/null - fi - - if [[ $? -ne 0 ]] ; then - die "${MYSQL_USER} user cannot write into tmpdir '${MYSQL_TMPDIR}'!" - else - rm "${_my_tmpdir_testfile}" || die - unset _my_tmpdir_testfile - fi - - if [[ -n "${MYSQL_LOG_BIN}" && ! -d "${MYSQL_LOG_BIN}" ]] ; then - einfo "Creating ${PN} log-bin directory '${MYSQL_LOG_BIN}' ..." - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_LOG_BIN}" \ - || die "Failed to create ${PN} log-bin directory '${MYSQL_LOG_BIN}'" - fi - - if [[ -n "${MYSQL_LOG_BIN}" ]] ; then - local _my_logbin_testfile="$(_mktemp_dry "${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX")" - [[ -z "${_my_logbin_testfile}" ]] \ - && die "_mktemp_dry() for '${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX' failed!" - - if use prefix ; then - touch "${_my_logbin_testfile}" &>/dev/null - else - su -s /bin/sh -c "touch ${_my_logbin_testfile}" ${MYSQL_USER} &>/dev/null - fi - - if [[ $? -ne 0 ]] ; then - die "${MYSQL_USER} user cannot write into log-bin directory '${MYSQL_LOG_BIN}'!" - else - rm "${_my_logbin_testfile}" || die - unset _my_logbin_testfile - fi - fi - - if [[ -n "${MYSQL_RELAY_LOG}" && ! -d "${MYSQL_RELAY_LOG}" ]] ; then - einfo "Creating ${PN} relay-log directory '${MYSQL_RELAY_LOG}' ..." - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_RELAY_LOG}" \ - || die "Failed to create ${PN} relay-log directory '${MYSQL_RELAY_LOG}'!" - fi - - if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then - local _my_relaylog_testfile="$(_mktemp_dry "${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX")" - [[ -z "${_my_relaylog_testfile}" ]] \ - && die "_mktemp_dry() for '${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX' failed!" - - if use prefix ; then - touch "${_my_relaylog_testfile}" &>/dev/null - else - su -s /bin/sh -c "touch ${_my_relaylog_testfile}" ${MYSQL_USER} &>/dev/null - fi - - if [[ $? -ne 0 ]] ; then - die "${MYSQL_USER} user cannot write into relay-log directory '${MYSQL_RELAY_LOG}'!" - else - rm "${_my_relaylog_testfile}" || die - unset _my_relaylog_testfile - fi - fi - - local mysql_install_log="$(_mktemp_dry "${MYSQL_TMPDIR}/install_db.XXXXXXXXX.log")" - if [[ -z "${mysql_install_log}" ]] ; then - die "_mktemp_dry() for '${MYSQL_TMPDIR}/install_db.XXXXXXXXX.log' failed!" - else - # make sure file is writable for MYSQL_USER... - touch "${mysql_install_log}" || die - chown ${MYSQL_USER} "${mysql_install_log}" || die - fi - - local mysqld_logfile="$(_mktemp_dry "${MYSQL_TMPDIR}/install_mysqld.XXXXXXXXX.log")" - if [[ -z "${mysqld_logfile}" ]] ; then - die "_mktemp_dry() for '${MYSQL_TMPDIR}/install_mysqld.XXXXXXXXX.log' failed!" - else - # make sure file is writable for MYSQL_USER... - touch "${mysqld_logfile}" || die - chown ${MYSQL_USER} "${mysqld_logfile}" || die - fi - - echo "" - einfo "Detected settings:" - einfo "==================" - einfo "MySQL User:\t\t\t\t${MYSQL_USER}" - einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}" - einfo "MySQL DATA directory:\t\t${MY_DATADIR}" - einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}" - - if [[ -n "${MYSQL_LOG_BIN}" ]] ; then - einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}" - fi - - if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then - einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}" - fi - - einfo "PID DIR:\t\t\t\t${PID_DIR}" - einfo "Install db log:\t\t\t${mysql_install_log}" - einfo "Install server log:\t\t\t${mysqld_logfile}" - - local -a config_files - - local config_file="${EROOT}/etc/mysql/mysql.d/50-distro-client.cnf" - if [[ -f "${config_file}" ]] ; then - config_files+=( "${config_file}" ) - else - ewarn "Client configuration '${config_file}' not found; Skipping configuration of default authentication plugin for client ..." - fi - - config_file="${EROOT}/etc/mysql/mysql.d/50-distro-server.cnf" - if [[ -f "${config_file}" ]] ; then - config_files+=( "${config_file}" ) - else - ewarn "Server configuration '${config_file}' not found; Skipping configuration of default authentication plugin for mysqld ..." - fi - - if [[ ${#config_files[@]} -gt 0 ]] ; then - if [[ -z "${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" ]] ; then - local user_answer - - echo - einfo "Please select default authentication plugin (enter number or plugin name):" - einfo "1) caching_sha2_password [MySQL 8.0 default]" - einfo "2) mysql_native_password [MySQL 5.7 default]" - einfo - einfo "For details see:" - einfo "https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password" - read -p " >" user_answer - echo - - case "${user_answer}" in - 1|caching_sha2_password) - MYSQL_DEFAULT_AUTHENTICATION_PLUGIN=caching_sha2_password - ;; - 2|mysql_native_password) - MYSQL_DEFAULT_AUTHENTICATION_PLUGIN=mysql_native_password - ;; - '') - die "No authentication plugin selected!" - ;; - *) - die "Authentication plugin '${user_answer}' is unknown/unsupported!" - ;; - esac - - echo "Selected authentication plugin: ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" >> "${mysql_install_log}" - - unset user_answer - fi - - local cfg_option cfg_option_tabs cfg_section - for config_file in "${config_files[@]}" ; do - cfg_option="default-authentication-plugin" - cfg_section="mysqld" - cfg_option_tabs="\t\t" - if [[ "${config_file}" == *client.cnf ]] ; then - cfg_option="default-auth" - cfg_section="client" - cfg_option_tabs="\t\t\t\t" - fi - - if grep -qE "^(loose-)?${cfg_option}\b.*=" "${config_file}" 2>/dev/null ; then - einfo "Ensuring that ${cfg_option} is set to '${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}' in '${config_file}' ..." - sed -i \ - -e "s/^\(loose-\)\?${cfg_option}\b.*=.*/loose-${cfg_option}${cfg_option_tabs}= ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}/" \ - "${config_file}" || die "Failed to change ${cfg_option} in '${config_file}'!" - else - einfo "Setting ${cfg_option} to '${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}' in '${config_file}' ..." - sed -i \ - -e "/^\[${cfg_section}\]$/a loose-${cfg_option}${cfg_option_tabs}= ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" \ - "${config_file}" || die "Failed to add ${cfg_option} to '${config_file}'!" - fi - done - unset cfg_option cfg_option_tabs cfg_section - fi - unset config_files config_file - - echo - - if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then - local tmp_mysqld_password_source= - - for tmp_mysqld_password_source in mysql client ; do - einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..." - MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)" - if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then - if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]] ; then - ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!" - MYSQL_ROOT_PASSWORD= - continue - fi - - einfo "Found password in '${tmp_mysqld_password_source}' section!" - break - fi - done - - # Sometimes --show is required to display passwords in some implementations of my_print_defaults - if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]] ; then - MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)" - fi - - unset tmp_mysqld_password_source - fi - - if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then - local pwd1="a" - local pwd2="b" - - echo - einfo "No password for mysql 'root' user was specified via environment" - einfo "variable MYSQL_ROOT_PASSWORD and no password was found in config" - einfo "file like '${HOME}/.my.cnf'." - einfo "To continue please provide a password for the mysql 'root' user" - einfo "now on console:" - ewarn "NOTE: Please avoid [\"'\\_%] characters in the password!" - read -rsp " >" pwd1 ; echo - - einfo "Retype the password" - read -rsp " >" pwd2 ; echo - - if [[ "x$pwd1" != "x$pwd2" ]] ; then - die "Passwords are not the same!" - fi - - MYSQL_ROOT_PASSWORD="${pwd1}" - unset pwd1 pwd2 - - echo - fi - - local -a mysqld_options - - # Fix bug 446200. Don't reference host my.cnf, needs to come first, - # see http://bugs.mysql.com/bug.php?id=31312 - use prefix && mysqld_options+=( "--defaults-file='${MY_SYSCONFDIR}/my.cnf'" ) - - # Figure out which options we need to disable to do the setup - local helpfile="${TMPDIR}/mysqld-help" - "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null - - local opt optexp optfull - for opt in host-cache name-resolve networking slave-start \ - federated ssl log-bin relay-log slow-query-log external-locking \ - log-slave-updates \ - ; do - optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}" - egrep -sq -- "${optexp}" "${helpfile}" && mysqld_options+=( "${optfull}" ) - done - - # Prepare timezones, see - # https://dev.mysql.com/doc/mysql/en/time-zone-support.html - local tz_sql="$(_mktemp_dry "${MYSQL_TMPDIR}/tz.XXXXXXXXX.sql")" - [[ -z "${tz_sql}" ]] \ - && die "_mktemp_dry() for '${MYSQL_TMPDIR}/tz.XXXXXXXXX.sql' failed!" - - echo "USE mysql;" >"${tz_sql}" - "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" >> "${tz_sql}" 2>/dev/null - if [[ $? -ne 0 ]] ; then - die "mysql_tzinfo_to_sql failed!" - fi - - # --initialize-insecure will not set root password - # --initialize would set a random one in the log which we don't need as we set it ourselves - local cmd=( - "${mysqld_binary}" - "${mysqld_options[@]}" - "--initialize-insecure" - "--init-file='${tz_sql}'" - "--basedir='${EROOT}/usr'" - "--datadir='${MY_DATADIR}'" - "--tmpdir='${MYSQL_TMPDIR}'" - "--log-error='${mysql_install_log}'" - "--user=${MYSQL_USER}" - ) - - einfo "Initializing ${PN} data directory: ${cmd[@]}" - eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1 - - if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql.ibd" ]] ; then - grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_install_log}" 1>&2 - die "Failed to initialize ${PN} data directory. Please review '${mysql_install_log}'!" - fi - - rm "${tz_sql}" || die - - local x=${RANDOM} - local socket="${EROOT}${PID_DIR}/mysqld${x}.sock" - local pidfile="${EROOT}${PID_DIR}/mysqld${x}.pid" - unset x - - cmd=( - "${mysqld_binary}" - "${mysqld_options[@]}" - "--basedir='${EROOT}/usr'" - "--datadir='${MY_DATADIR}'" - "--tmpdir='${MYSQL_TMPDIR}'" - --max_allowed_packet=8M - --net_buffer_length=16K - "--socket='${socket}'" - "--pid-file='${pidfile}'" - "--log-error='${mysqld_logfile}'" - "--user=${MYSQL_USER}" - ) - - einfo "Starting mysqld to finalize initialization: ${cmd[@]}" - eval "${cmd[@]}" >>"${mysqld_logfile}" 2>&1 & - - echo -n "Waiting for mysqld to accept connections " - local maxtry=15 - while [[ ! -S "${socket}" && "${maxtry}" -gt 1 ]] ; do - maxtry=$((${maxtry}-1)) - echo -n "." - sleep 1 - done - - if [[ -S "${socket}" ]] ; then - # Even with a socket we don't know if mysqld will abort - # start due to an error so just wait a little bit more... - maxtry=5 - while [[ -S "${socket}" && "${maxtry}" -gt 1 ]] ; do - maxtry=$((${maxtry}-1)) - echo -n "." - sleep 1 - done - fi - - echo - - if [[ ! -S "${socket}" ]] ; then - grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysqld_logfile}" 1>&2 - die "mysqld was unable to start from initialized data directory. Please review '${mysqld_logfile}'!" - fi - - local mysql_logfile="${TMPDIR}/set_root_pw.log" - touch "${mysql_logfile}" || die - - ebegin "Setting root password" - # Do this from memory, as we don't want clear text passwords in temp files - local sql="ALTER USER 'root'@'localhost' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}'" - cmd=( - "${mysql_binary}" - --no-defaults - "--socket='${socket}'" - -hlocalhost - "-e \"${sql}\"" - ) - eval "${cmd[@]}" >"${mysql_logfile}" 2>&1 - local rc=$? - eend ${rc} - - if [[ ${rc} -ne 0 ]] ; then - # Poor man's solution which tries to avoid having password - # in log. NOTE: sed can fail if user didn't follow advice - # and included character which will require escaping... - sed -i -e "s/${MYSQL_ROOT_PASSWORD}/*****/" "${mysql_logfile}" 2>/dev/null - - grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_logfile}" - die "Failed to set ${PN} root password. Please review '${mysql_logfile}'!" - fi - - # Stop the server - if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then - echo -n "Stopping the server " - pkill -F "${pidfile}" &>/dev/null - - maxtry=10 - while [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; do - maxtry=$((${maxtry}-1)) - echo -n "." - sleep 1 - done - - echo - - if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then - # We somehow failed to stop server. - # However, not a fatal error. Just warn the user. - ewarn "WARNING: mysqld[$(cat "${pidfile}")] is still running!" - fi - fi - - einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!" -} diff --git a/dev-db/pgtap/Manifest b/dev-db/pgtap/Manifest index f113ef9f0c4a..2c1c095c76f7 100644 --- a/dev-db/pgtap/Manifest +++ b/dev-db/pgtap/Manifest @@ -3,6 +3,6 @@ DIST pgtap-1.1.0.zip 306590 BLAKE2B efde91e26fafc8300fa39b80d90eef134ebf3a309fca DIST pgtap-1.2.0.zip 319374 BLAKE2B 1cea77860a1928ed7cbf4ddb0bb8ff418023bf88e377196ae2b505c065321e3003179227077567e676a8c551230d259ecd1cdb590001fc71bcc821b87fb3d0f6 SHA512 5569bea5e7879787a91fa9b2baae5cbff1db5b9a5a096db2a9a064012d65e02c52bd1520422b5e6f87fb5b6e64845371188ea53c43a277aee68ffc05d5152ed7 EBUILD pgtap-0.99.0.ebuild 584 BLAKE2B d50187a368d9a9485183a2a3dc9f23aef3fdc9b4f304f7b01eb4b5da1649ca19fb2c9fe60fa4dfc968153946da1e8457b650f7e67a343e402114df02ce9a324c SHA512 e8b2bfbe1fd3bc012dc7b87d92ebc7c7f026296c4c09881255225f648a6540f2c092580ea351d9f780672db61cf4195cf35c2285ca2b6a58cdf3c5c32536d278 EBUILD pgtap-1.1.0.ebuild 638 BLAKE2B 1c44e86675592fbbef365d8aec2194c83dfdd0e56dd175159eb77bc3ba5a3ce904af9e149cc385cbeedc9847e656c7d8276dc329d09a654edaece1a224182a2b SHA512 c6f7b1c68c3be187b9f7332794cdc51a08bc6507aa9e530aa1bf302869fd0f69c9ef08092bb23d52eba368963ead74bedca374e9d2a3b36b26479977a9d4ed39 -EBUILD pgtap-1.2.0-r1.ebuild 776 BLAKE2B f7f35bb8ce49aa3af59de0cd58b742de118f8c72b4ea4297aa7303d609a660661238e9948f4cf5474fc90a25402b3d444c11b087ef5fe4e97213bc6a73b808fe SHA512 591ec6c2d26986fdc5579ae95f48b8a75524422ba68a8c1bc35d8cd0d3acd3f9f65ca0fd653b17574f724db5335d1cba1375293d1ec1d3eb29002765b81dd6cb +EBUILD pgtap-1.2.0-r2.ebuild 795 BLAKE2B 1f43593a1e5c1e448f3a8fe6bcd2d4de8d4596294d1203fb75c79e3e1bed03d430ed22d1bbb4e19f492a5d30b4dbbb1d55830802f4ce37b3a54b3fa8dfc40eb7 SHA512 e951c154f9571219aab874b79478732a6fa704170adb803406986711c94e080e31a2319694bc149db6d967ae95ee827e872078fd225d51a5657d75ddea2e3c55 EBUILD pgtap-1.2.0.ebuild 638 BLAKE2B ee4f80c5bc1891454996ca3a5572b66bbf5816b503eba567210527683691d8a08d67f6eef73f568dd2df98368d30bfc650e10e6219025cd3c88d7c5ac92f127e SHA512 087436540027476c4958df8536c34d00d1c8c8bcfe629bb158f22d342858c7a0342c1695e705a161e52521407bbfe522f24650f180561c6ac4bcf13bb135a699 MISC metadata.xml 629 BLAKE2B e7052e443d1a9c728bce35231d7aa287b2844409cc69ecb42b563000a7908e1db49d1a85fe01e8bcafb27fc2741181869895582a77286a0eb16b101ca672d3c4 SHA512 9a3f6c41f8a6577b0c2e29d81549644cf2c74f742aa3f4fca182e6588cc380ac3d2fa5ca07b931d41b24ba0021b81f462d316071ecaa1c3d813cbfa76603f063 diff --git a/dev-db/pgtap/pgtap-1.2.0-r1.ebuild b/dev-db/pgtap/pgtap-1.2.0-r1.ebuild deleted file mode 100644 index 747da8ca2c29..000000000000 --- a/dev-db/pgtap/pgtap-1.2.0-r1.ebuild +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 1999-2022 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=7 - -POSTGRES_COMPAT=( 9.6 {10..14} ) - -inherit postgres-multi - -DESCRIPTION="Unit testing for PostgreSQL" -HOMEPAGE="https://pgtap.org/" -SRC_URI="https://api.pgxn.org/dist/${PN}/${PV}/${P}.zip" - -LICENSE="POSTGRESQL" -SLOT="0" -KEYWORDS="~amd64" -IUSE="" - -DEPEND="${POSTGRES_DEP} - app-arch/unzip - dev-perl/TAP-Parser-SourceHandler-pgTAP -" -RDEPEND="${DEPEND}" - -# Tests requires a running database that match up with the current -# testing slot. Won't run from ${ED}, want's to install too early. -RESTRICT="test" - -src_configure() { - : -} - -src_install() { - default - - rm -r ${ED}/usr/share/doc/postgresql* || die "Failed to remove improper doc locations" - dodoc doc/pgtap.mmd -} diff --git a/dev-db/pgtap/pgtap-1.2.0-r2.ebuild b/dev-db/pgtap/pgtap-1.2.0-r2.ebuild new file mode 100644 index 000000000000..c622db920eb2 --- /dev/null +++ b/dev-db/pgtap/pgtap-1.2.0-r2.ebuild @@ -0,0 +1,38 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +POSTGRES_COMPAT=( 9.6 {10..14} ) + +inherit postgres-multi + +DESCRIPTION="Unit testing for PostgreSQL" +HOMEPAGE="https://pgtap.org/" +SRC_URI="https://api.pgxn.org/dist/${PN}/${PV}/${P}.zip" + +LICENSE="POSTGRESQL" +SLOT="0" +KEYWORDS="~amd64" +IUSE="" + +DEPEND="${POSTGRES_DEP} + app-arch/unzip + dev-perl/TAP-Parser-SourceHandler-pgTAP +" +RDEPEND="${DEPEND}" + +# Tests requires a running database that match up with the current +# testing slot. Won't run from ${ED}, want's to install too early. +RESTRICT="test" + +src_configure() { + : +} + +src_install() { + postgres-multi_src_install + + rm -r ${ED}/usr/share/doc/postgresql* || die "Failed to remove improper doc locations" + dodoc doc/pgtap.mmd +} diff --git a/dev-db/postgresql/Manifest b/dev-db/postgresql/Manifest index 708c44aa562e..b26aeeaa1b46 100644 --- a/dev-db/postgresql/Manifest +++ b/dev-db/postgresql/Manifest @@ -1,3 +1,4 @@ +AUX postgres-llvm14.patch 4963 BLAKE2B 66e50d40cd9491ef1757d9b5756b07af683e98d8a6b3e808f90699745b6a772f921695d1528d9d486240690b2efb55b39a184032e205b857609d27430cd6eb9f SHA512 c74841faa6120450481dccc94af3700313c389494e8adacc02ab1d655592dac08e97e6828452140b901548af58f857e3290650c3318c86f9e63d3c5a8ae90fc5 AUX postgresql-10.0-icu68.patch 606 BLAKE2B ebe222879ddd0e97da8762ad85994beced0d706d2db140db9b3e588951f485763f698d70a8ff4e4bbfe1d66f8762bf3d329bc97aaa70bf5b36f0e2e72e53a508 SHA512 1c3c994c79155845d6b3d1a92df002d4127fc576eb837f892aef0ba2e0b914d107c35656f9e5946084892693054cb935e85eb5902be2296fd04c7cf958ba98ea AUX postgresql-10.2-no-server.patch 3117 BLAKE2B 399e295e393aa84aeaefbe236bf63e091414c9f3d9238ef8f4af3ec955cc0ded6324f4241ee4e78ee1aa775524768f65b15d5064cf4330f5b3149bed2e13aad3 SHA512 1888985a0fa67241b18d3c21c1ededc34666c55f6f4f3806efbe4dcb5a2e30d6d08c955a3bbcc52f589bc5bb857d1c09bd82b555069637a71afe9062994199fd AUX postgresql-11_beta1-no-server.patch 3080 BLAKE2B 29d4f5d8e26e9360490876d2d51cb29cc340128fe77c0bd76248073157c9e5be09c788cc4344e09c0c2bf2f57e274d5f31f211d1950ee3f47660dfdc4cb7b455 SHA512 42c39e602a019d1d44c39795904fb37a7f14b4623fa90b066f4f26a743d80b6eeaef2e8c7de4c47dddf53d7e89cbe5a2a3473b456ddc76fc0e96f57ff6a9df69 @@ -22,16 +23,16 @@ DIST postgresql-13.6.tar.bz2 21257213 BLAKE2B f5ea95fd9ffc8846e0aaf5bac03b02afa7 DIST postgresql-14.1.tar.bz2 21887101 BLAKE2B a496dfd513c52339d1b3cb72773f9611721fd7c5d2a702d6fd71f650a1d41c3d7bf6574eba23671c7f9f11718e007f51f9547949bdc3d7fe1ea2248ebfb8d70b SHA512 4a0bec157d5464bb9e5f5c0eb0efdede55526e03f6f4d660b87d161a47705eb152fa0878960b1581bce42a5ed28a1f457825ea54e8d22e34b5b8eb36473ceefd DIST postgresql-14.2.tar.bz2 21964841 BLAKE2B 6460533a40064404f18642147b949cf7c85d036c45ede478fb9af8919895ee7b09dc78b89ed08a292226911f07cfc9e46d7f2d42e0aaea546c5e97a291d599b9 SHA512 19aeb6528605dbcf5df84048b2eed8f54b202576134d3fe3900bb8f073179c4258d2581acd745887e7e6fa86ebdb5f7b159ffaa0a645d601efee7c5f7730456b DIST postgresql-9.6.24.tar.bz2 19047518 BLAKE2B 63b53cfb2c9381fe09ed76ef3cad1ec5014bcd3b4dea388cda5b4ad8b8084abc15a38dcd62e0c3fe0bcc922749e7a4bef4ec39287c4b1ea952b8245bbc72bc2e SHA512 c17ef8e7149bd136f6058e20b28f9a7307625614e37ff837feb7a6fa37b6932dfab6379285120c9bb0198961eb446c9979d5ee1f3e8583b09f981f52bee33505 -EBUILD postgresql-10.19.ebuild 13406 BLAKE2B 8b13ef233f11306debff7e81c00a1e222cf98a817dbfad8b06bcaf1c85b0d7c50b0f1089aa8057f58c69cc4444aaf7f5f6a7bca8ae903305aa871b172176d1b6 SHA512 1f2751c8e56ecceb98eebdcd47d93d6a4359a0302cbe346557deb610f6ac96b4744fd878bd37ab49f893ebd55c0eba2ea646209f4498fb7ea3d6ae717d0a33be -EBUILD postgresql-10.20.ebuild 13414 BLAKE2B 1359953281cdabefa0b62dab1977771a0b1b6ec3b66428ae3d45ffab4c68c538de931c6c79f669c016ebd8c4ce540752aee54d195c918556dac8fdb3128f4997 SHA512 bfa7410311d6ec57f2d0c2af84034e45d339843c4e008d8ab972347c7ba4ca98fcab1116ad1a5877986269fb4de373043f265a77a8bb51e31e7c20f7bada5a99 -EBUILD postgresql-11.14.ebuild 13388 BLAKE2B c48815de53abe5328a03c1d427fb63b1f4b48d15defcd7e10b86b2e55247839d2e6f8a27ec6fc73eda4701240d950c14d8896f031139725776356a72af3a9791 SHA512 dd7210480b744b38e66329057b55a4051921d0603a859c6cfb251285e35cf038f08944e033eb3ef741448c2bfd3e6916df69547b04ae35d5e8fada11a98b1b86 -EBUILD postgresql-11.15.ebuild 13396 BLAKE2B ee8e0c4ae7aff0ffb7ba1d307c723136921e401dd22541cf70da85a0dd2fdcbd7e187bbe33b08a81ca9a6649eb68291c6356f70d6d9ee68a8c22015c26ba4770 SHA512 8d4db523440b61897923b761e72df70b21e69b11d119d13859c3f2c64bd7441ffd7741134227f45905c30eb3eaa3c6d8822bb572fbf645fa21506c4990799ff3 -EBUILD postgresql-12.10.ebuild 13368 BLAKE2B e8cbcad7b27990e0368e5091aeea8486865e98413222522aa72cd657259c0afc44eadd98a9f2e4e41be4b0d7899fd09a1731acfb3f4c5803818c7d3a4564ffd5 SHA512 c8a07b12e39b0a0a220dfc8e3ec808073be54ef3b0be299acd8353316ba88e827c640779c0a66973057c7d88f5d9ad811480bfb7f33d589d1c934f59580b4c43 -EBUILD postgresql-12.9.ebuild 13360 BLAKE2B 995ab8160f9efd010777423d968e36482458f206e810900f2621724cefb8db1cbd9bab7a89aa68b79d23be163cab4f1a11dbbc982f804c2ac12a1f1dce464f0e SHA512 f486c23e4e34b1de2a768f3b9745982003a8b84c4d0f2e19dd9cb3d48c70144b435315e787c8e77c80da8c1e17ccb9a9d4da09f7cd0a36e81e7892b21e08664e -EBUILD postgresql-13.5.ebuild 13798 BLAKE2B f8b94f053f91d1fda023233f0b1f302af553448b3f5543a7020f9f7f05e072914d25667c6ca5903601e06d98b0ca9586c14ba275d531b4d8c9b5638ef9b15e41 SHA512 9b8fd5caadfab9e0a15733e782b3d4ab3852e446e9ea6c28aa50adac14a6f716630cf101e0ad15fb4983a91ddeec02df0b025b92e0070be0d51a2af8d728499f -EBUILD postgresql-13.6.ebuild 13806 BLAKE2B ca2671a77d6b1fcade98d12fe277101d85739d4251a38fe71450908b3875a036b136d838170585a5ee5435900bfe601d5ff1622447ef89f1ff1cc215507e47d9 SHA512 c56bda1468d427bec5745405016a4bebff76e2d9c7eb0d31ee36228a418739144f1ffb337d76974f5e1973d13c8164073eef9d2d363edc4984580685f2cbabc7 -EBUILD postgresql-14.1.ebuild 13794 BLAKE2B 3a99312b8f728e49f10bfe8d174fd6e8a8e7bee887fa51b7a9235253503ed331f8599046af1d479f2c8a497fc54ef71c74e0dfddffebe79b1980fea0d8f09626 SHA512 8811c1715f245ca8eec52e2e837a49cb40dafb760e5203d9008db8bd50e2f23bacdcaa3c901e58d4a7998eeccd9145b91d4f41285952abb14c24c3eee0d53823 -EBUILD postgresql-14.2.ebuild 13794 BLAKE2B 3a99312b8f728e49f10bfe8d174fd6e8a8e7bee887fa51b7a9235253503ed331f8599046af1d479f2c8a497fc54ef71c74e0dfddffebe79b1980fea0d8f09626 SHA512 8811c1715f245ca8eec52e2e837a49cb40dafb760e5203d9008db8bd50e2f23bacdcaa3c901e58d4a7998eeccd9145b91d4f41285952abb14c24c3eee0d53823 -EBUILD postgresql-9.6.24.ebuild 14326 BLAKE2B 946d0c681c44ec7b13a2d7dc63cf7e8f29bf41e4419863d2f85a86c7f6e747177550abfede7618c49a7d25b40a298f8901429e303c7eea9f774aec964ec012ea SHA512 a52d6bda4f8670d9024afb6c78daf9413f28b90cd4d9fbf81018ca7807f211b372da29465a72051cdc15a1e44e0946d2ee93c2fa347a04a26667a5015eb31de1 -EBUILD postgresql-9999.ebuild 14100 BLAKE2B b6ad36c1fa6e89db3876719b0950f77ffbd63cb36a3289285cac7661dfc6126ee49f83699aebc0b087262abf3d1f37eb84ab79c5e72a4dee18c4c4e09218a7e2 SHA512 4cb7274fc8cec788146ca4b164dd3c32647fd069c6ce85100c3279ec34ddf37229a6254b92804cb57d7c766d7b15a4c35b5a390260a57808a2f395184d858228 +EBUILD postgresql-10.19-r1.ebuild 13408 BLAKE2B 242cefd43604dfa557e83172783731f608a350467b1e546a935d1507acb54a2a714bc67175ce5846f82577516b07f4f74de59ae59481363c6c8cf40cb090e5e3 SHA512 2f02d8194f9a1eb51a69e6b8bf1f5b6bf461ce7b77dd983d13d2ccda3c10c1daab2a24c6472c7bd367548eeef53b5ce2dbcb77cfc3a00104787d426c140dbc09 +EBUILD postgresql-10.20-r1.ebuild 13416 BLAKE2B d70e618b0bc07941ff8dd794a64c3cf94798f470c24b0222f505e5c36188ccf51477e1c9a35e71dd753250a7f5fe744297a017289006bcffe2b38ddd3c744179 SHA512 aa03b4ac07f61e75b71ea664546f0a6011d6afe93e6e487c36a634156441422465f6e2680587f8ff3bde2fba04f071c60ab35502099a8657e942a5b24f76754c +EBUILD postgresql-11.14-r1.ebuild 13449 BLAKE2B f077ebe227322eb51ed8a1a24c2fd4e22662eb277acbec3d536b87f8d1baa09fd728d5a790106b1a1acc25ec0e2605d5d3d6111d4bb69c956d6c972caaafc71e SHA512 2f31ca8f2a23c9a98dc43d6af8314105f761293d78cb9efdb59579e02abc20403cac0e06bca1d25c3fb6e09811dbe1b3774ccd4a8bb2a6ebe505bc45e105d972 +EBUILD postgresql-11.15-r1.ebuild 13457 BLAKE2B dee96904f9cdcbd4ba3bdfde139235901e42d8152c9d3450706a8bfbb65d612da6df97e68a441c65e0a156f2ded4f59ed19d084941683fcb64b46a05310fc9d8 SHA512 35a5a7ce237ffddd3d3267f78c4f89307a8c959d2d4f541d9dc5776554c16fab540d32fee34b67215300f02cc0d3a02e06ad8f818a841e0ec0778c2d84bbef28 +EBUILD postgresql-12.10-r1.ebuild 13475 BLAKE2B 26e617cf110875369197783e7a74c59658af39c946ef571c7094f24445fc4ab932e4fdb7415d15c021fe278ea72b982f4e27343807e5335e9aa56022dd4c26a4 SHA512 b29a8e68e286fada99424285e5094ade01b91affbafe80fa4f4f5f437d9ca739535e1ba05acb4efd2ae0027f991e5eb98e6ae52dd25681699dec000c69220ec2 +EBUILD postgresql-12.9-r1.ebuild 13467 BLAKE2B e49ff0c7521e57f25675f92d7a23605686bce7e1dd15220bde2b4a79e3f21e4dc1c372578b92f768f5b7458a0d7436e35f83a2fd70900fa418e99e64b945879e SHA512 0e60c3f3b3d2b9fbfeba5d77361c57cc5014f204939d2549b23c539cb9b3cf8af4865e51796432ea913f521939528955a3fb1dc2044bc91a30c98e617eaf50ff +EBUILD postgresql-13.5-r1.ebuild 13905 BLAKE2B 6ec1336e5279a881cbd8426158ab60ddca6b75db0cf4f86c09d25bc69650c4dbb8ddf10ccb45d6469b0b8c779c5c76d7479509dc64685cf69f71a54cbde26166 SHA512 7cfe12c09ba8d19160e3ea010b0167803b754d74a04e5d50484c5df30d581c46bda04db4a2fc8c2230ea918d8954a3f29a3413b6a9d75da18b100ce7b4758249 +EBUILD postgresql-13.6-r2.ebuild 13913 BLAKE2B ec5aeab2c539b6387e8ef60568d2b0159401453b08956c6bf935de50e6a45f7a7e46f2778a82ec4c79ff76863596536d6cbdbf3530521e5a1207f122bd44dd8c SHA512 bf1c154aadae65943ad6e76111674498fc449ca80a9c7b940fbb83dd0e753e49976b2d9e66e7bb2f879030b403d1932b27261fff4839d77d6e4f20e478640b5c +EBUILD postgresql-14.1-r1.ebuild 13901 BLAKE2B 20cbadf06f628a0003aab687e0ca53966763f11dd84dac386d54daabbfa398075cdfdae267a46144ff30c6cc022dfcb81403da8cf9d08638e35f622dec2565b0 SHA512 ac64ca0e454a5276e19d337495aff2f38b3e6308994db8cd004ac209ea70179eab81553fda8f1e3c9c5dff5e1b7f4d444a460d58a2490ee345fa06c96ed614a6 +EBUILD postgresql-14.2-r1.ebuild 13854 BLAKE2B aff48fafb0a5728a70dffbee12f80dc5f2dcf2ceda30af05b1cb409a434e491c66dfe970b26899c377ff362994903c58020c31444ef31ff7478c9a688991bb09 SHA512 63953e91dae73e3675dd65e2c0665ef3822f73a365e759de18e5241418b659e3802d201c5620f51e139171b8cc981454d95dfcfbf108f956e197335a33584d00 +EBUILD postgresql-9.6.24-r1.ebuild 14328 BLAKE2B 9e2d97a2caee5f87d4fafebbc6903d6e48195e7a06f7e6ecbef7612e7113a29b431d04d087bf3543af7a468255926fd1d3f10df08bf8789cff07f9931185189e SHA512 9d361a663d1905314eaac7321b91dbb89b47c02610795ffeaea2ab056063d660e30531f90d14714357487e1561c9aced8d71082325e2398e7c87fd6e7c683d31 +EBUILD postgresql-9999.ebuild 14102 BLAKE2B 821a52a05174b6b4d9c539d01563a45a0edded846b1533b5cc87ccfd45fcfd56bf2e77c49ec8ee1f5cf79d7174f0aaade405591e70aa5d7d81c068fc33fee923 SHA512 e1d8c3ce0347b9db2ba4aeec48cf08d99e522eb5663ae0b84b510baf07be4a06c83a9b6c951952a949a7c3984e373048db0f518ce234117d54ce773fc735ccb2 MISC metadata.xml 716 BLAKE2B c881b294d82137c80ddfde58ef50074a2e2b92e6883e6ebc5d8c71a366e8cbb0568756b2044fc411dd18e89da0e5625df80b876820e0abeaccc24d26880d5145 SHA512 dd045716ced95dbac8763aea347125d27bdb230eeb64bfc932f94110eda2ad42aa892e9cb19595c0d2f4a593d2629d9709a7aea792ac16661a2c210158368ba3 diff --git a/dev-db/postgresql/files/postgres-llvm14.patch b/dev-db/postgresql/files/postgres-llvm14.patch new file mode 100644 index 000000000000..2c7b91d75153 --- /dev/null +++ b/dev-db/postgresql/files/postgres-llvm14.patch @@ -0,0 +1,154 @@ +From d9f7ad54e552262ee0090e88d5abd3e04fcdeac8 Mon Sep 17 00:00:00 2001 +From: Thomas Munro +Date: Wed, 16 Mar 2022 11:35:00 +1300 +Subject: [PATCH] Back-patch LLVM 14 API changes. + +Since LLVM 14 has stopped changing and is about to be released, +back-patch the following changes from the master branch: + + e6a7600202105919bffd62b3dfd941f4a94e082b + 807fee1a39de6bb8184082012e643951abb9ad1d + a56e7b66010f330782243de9e25ac2a6596be0e1 + +Back-patch to 11, where LLVM JIT support came in. +--- + src/backend/jit/llvm/Makefile | 6 +++++ + src/backend/jit/llvm/llvmjit_error.cpp | 35 +++++++++++++++++++++---- + src/backend/jit/llvm/llvmjit_inline.cpp | 12 ++++++++- + 3 files changed, 47 insertions(+), 6 deletions(-) + +diff --git a/src/backend/jit/llvm/Makefile b/src/backend/jit/llvm/Makefile +index 0268bd46d5..2da122a391 100644 +--- a/src/backend/jit/llvm/Makefile ++++ b/src/backend/jit/llvm/Makefile +@@ -22,6 +22,12 @@ endif + PGFILEDESC = "llvmjit - JIT using LLVM" + NAME = llvmjit + ++# LLVM 14 produces deprecation warnings. We'll need to make some changes ++# before the relevant functions are removed, but for now silence the warnings. ++ifeq ($(GCC), yes) ++LLVM_CFLAGS += -Wno-deprecated-declarations ++endif ++ + # All files in this directory use LLVM. + CFLAGS += $(LLVM_CFLAGS) + CXXFLAGS += $(LLVM_CXXFLAGS) +diff --git a/src/backend/jit/llvm/llvmjit_error.cpp b/src/backend/jit/llvm/llvmjit_error.cpp +index f4720732a3..5ad92f3090 100644 +--- a/src/backend/jit/llvm/llvmjit_error.cpp ++++ b/src/backend/jit/llvm/llvmjit_error.cpp +@@ -23,15 +23,22 @@ extern "C" + + #include "jit/llvmjit.h" + ++#include + + static int fatal_new_handler_depth = 0; + static std::new_handler old_new_handler = NULL; + + static void fatal_system_new_handler(void); + #if LLVM_VERSION_MAJOR > 4 ++static void fatal_llvm_new_handler(void *user_data, const char *reason, bool gen_crash_diag); ++#if LLVM_VERSION_MAJOR < 14 + static void fatal_llvm_new_handler(void *user_data, const std::string& reason, bool gen_crash_diag); + #endif ++#endif ++static void fatal_llvm_error_handler(void *user_data, const char *reason, bool gen_crash_diag); ++#if LLVM_VERSION_MAJOR < 14 + static void fatal_llvm_error_handler(void *user_data, const std::string& reason, bool gen_crash_diag); ++#endif + + + /* +@@ -129,23 +136,41 @@ fatal_system_new_handler(void) + #if LLVM_VERSION_MAJOR > 4 + static void + fatal_llvm_new_handler(void *user_data, +- const std::string& reason, ++ const char *reason, + bool gen_crash_diag) + { + ereport(FATAL, + (errcode(ERRCODE_OUT_OF_MEMORY), + errmsg("out of memory"), +- errdetail("While in LLVM: %s", reason.c_str()))); ++ errdetail("While in LLVM: %s", reason))); ++} ++#if LLVM_VERSION_MAJOR < 14 ++static void ++fatal_llvm_new_handler(void *user_data, ++ const std::string& reason, ++ bool gen_crash_diag) ++{ ++ fatal_llvm_new_handler(user_data, reason.c_str(), gen_crash_diag); + } + #endif ++#endif + + static void + fatal_llvm_error_handler(void *user_data, +- const std::string& reason, ++ const char *reason, + bool gen_crash_diag) + { + ereport(FATAL, + (errcode(ERRCODE_OUT_OF_MEMORY), +- errmsg("fatal llvm error: %s", +- reason.c_str()))); ++ errmsg("fatal llvm error: %s", reason))); + } ++ ++#if LLVM_VERSION_MAJOR < 14 ++static void ++fatal_llvm_error_handler(void *user_data, ++ const std::string& reason, ++ bool gen_crash_diag) ++{ ++ fatal_llvm_error_handler(user_data, reason.c_str(), gen_crash_diag); ++} ++#endif +diff --git a/src/backend/jit/llvm/llvmjit_inline.cpp b/src/backend/jit/llvm/llvmjit_inline.cpp +index 6f03595db5..9bb4b672a7 100644 +--- a/src/backend/jit/llvm/llvmjit_inline.cpp ++++ b/src/backend/jit/llvm/llvmjit_inline.cpp +@@ -594,7 +594,11 @@ function_inlinable(llvm::Function &F, + if (F.materialize()) + elog(FATAL, "failed to materialize metadata"); + +- if (F.getAttributes().hasFnAttribute(llvm::Attribute::NoInline)) ++#if LLVM_VERSION_MAJOR < 14 ++#define hasFnAttr hasFnAttribute ++#endif ++ ++ if (F.getAttributes().hasFnAttr(llvm::Attribute::NoInline)) + { + ilog(DEBUG1, "ineligibile to import %s due to noinline", + F.getName().data()); +@@ -871,7 +875,9 @@ create_redirection_function(std::unique_ptr &importMod, + llvm::Function *AF; + llvm::BasicBlock *BB; + llvm::CallInst *fwdcall; ++#if LLVM_VERSION_MAJOR < 14 + llvm::Attribute inlineAttribute; ++#endif + + AF = llvm::Function::Create(F->getFunctionType(), + LinkageTypes::AvailableExternallyLinkage, +@@ -880,9 +886,13 @@ create_redirection_function(std::unique_ptr &importMod, + + Builder.SetInsertPoint(BB); + fwdcall = Builder.CreateCall(F, &*AF->arg_begin()); ++#if LLVM_VERSION_MAJOR < 14 + inlineAttribute = llvm::Attribute::get(Context, + llvm::Attribute::AlwaysInline); + fwdcall->addAttribute(~0U, inlineAttribute); ++#else ++ fwdcall->addFnAttr(llvm::Attribute::AlwaysInline); ++#endif + Builder.CreateRet(fwdcall); + + return AF; +-- +2.30.2 + diff --git a/dev-db/postgresql/postgresql-10.19-r1.ebuild b/dev-db/postgresql/postgresql-10.19-r1.ebuild new file mode 100644 index 000000000000..2451592a1f77 --- /dev/null +++ b/dev-db/postgresql/postgresql-10.19-r1.ebuild @@ -0,0 +1,453 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +PYTHON_COMPAT=( python3_{8,9,10} ) + +inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd tmpfiles + +KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~mips ppc ppc64 ~s390 sparc x86 ~ppc-macos ~x86-solaris" + +SLOT=$(ver_cut 1) + +MY_PV=${PV/_/} +S="${WORKDIR}/${PN}-${MY_PV}" + +SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2" + +LICENSE="POSTGRESQL GPL-2" +DESCRIPTION="PostgreSQL RDBMS" +HOMEPAGE="https://www.postgresql.org/" + +IUSE="debug doc icu kerberos ldap nls pam perl + python +readline selinux +server systemd ssl static-libs tcl + threads uuid xml zlib" + +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" + +CDEPEND=" +>=app-eselect/eselect-postgresql-2.0 +acct-group/postgres +acct-user/postgres +sys-apps/less +virtual/libcrypt:= +virtual/libintl +icu? ( dev-libs/icu:= ) +kerberos? ( virtual/krb5 ) +ldap? ( net-nds/openldap:= ) +pam? ( sys-libs/pam ) +perl? ( >=dev-lang/perl-5.8:= ) +python? ( ${PYTHON_DEPS} ) +readline? ( sys-libs/readline:0= ) +server? ( systemd? ( sys-apps/systemd ) ) +ssl? ( >=dev-libs/openssl-0.9.6-r1:0= ) +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,musl} ) + +nest_usedep() { + local front back + while [[ ${#} -gt 1 ]]; do + front+="${1}? ( " + back+=" )" + shift + done + echo "${front}${1}${back}" +} + +CDEPEND+=" +uuid? ( + ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )} + $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid) +)" + +DEPEND="${CDEPEND} +sys-devel/bison +sys-devel/flex +nls? ( sys-devel/gettext ) +xml? ( virtual/pkgconfig ) +" + +RDEPEND="${CDEPEND} +selinux? ( sec-policy/selinux-postgresql ) +" + +pkg_setup() { + use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup + + use python && python-single-r1_pkg_setup +} + +src_prepare() { + # Work around PPC{,64} compilation bug where bool is already defined + sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die + + # Set proper run directory + sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \ + -i src/include/pg_config_manual.h || die + + # Rely on $PATH being in the proper order so that the correct + # install program is used for modules utilizing PGXS in both + # hardened and non-hardened environments. (Bug #528786) + sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die + + use server || eapply "${FILESDIR}/${PN}-10.2-no-server.patch" + + if use pam ; then + sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \ + -i src/backend/libpq/auth.c || \ + die 'PGSQL_PAM_SERVICE rename failed.' + fi + + # https://bugs.gentoo.org/753257 + # https://bugs.gentoo.org/766225 + eapply "${FILESDIR}"/postgresql-10.0-icu68.patch + + eapply_user +} + +src_configure() { + case ${CHOST} in + *-darwin*|*-solaris*) + use nls && append-libs intl + ;; + esac + + export LDFLAGS_SL="${LDFLAGS}" + export LDFLAGS_EX="${LDFLAGS}" + + local PO="${EPREFIX}" + + local i uuid_config="" + if use uuid; then + for i in ${UTIL_LINUX_LIBC[@]}; do + use ${i} && uuid_config="--with-uuid=e2fs" + done + [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp" + fi + + econf \ + --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \ + --datadir="${PO}/usr/share/postgresql-${SLOT}" \ + --includedir="${PO}/usr/include/postgresql-${SLOT}" \ + --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \ + --sysconfdir="${PO}/etc/postgresql-${SLOT}" \ + --with-system-tzdata="${PO}/usr/share/zoneinfo" \ + $(use_enable !alpha spinlocks) \ + $(use_enable debug) \ + $(use_enable threads thread-safety) \ + $(use_with icu) \ + $(use_with kerberos gssapi) \ + $(use_with ldap) \ + $(use_with pam) \ + $(use_with perl) \ + $(use_with python) \ + $(use_with readline) \ + $(use_with ssl openssl) \ + $(usex server "$(use_with systemd)" '--without-systemd') \ + $(use_with tcl) \ + ${uuid_config} \ + $(use_with xml libxml) \ + $(use_with xml libxslt) \ + $(use_with zlib) \ + $(use_enable nls) +} + +src_compile() { + emake + emake -C contrib +} + +src_install() { + emake DESTDIR="${D}" install + emake DESTDIR="${D}" install -C contrib + + dodoc README HISTORY doc/{TODO,bug.template} + + # man pages are already built, but if we have the target make them, + # they'll be generated from source before being installed so we + # manually install man pages. + # We use ${SLOT} instead of doman for postgresql.eselect + insinto /usr/share/postgresql-${SLOT}/man/ + doins -r doc/src/sgml/man{1,3,7} + if ! use server; then + # Remove man pages for non-existent binaries + serverman=( + initdb + pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby} + pg_{test_{fsync,timing},upgrade,waldump} + post{gres,master} + ) + for m in ${serverman[@]} ; do + rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1" + done + fi + docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7} + + # Create slot specific man pages + local bn f mansec slotted_name + for mansec in 1 3 7 ; do + local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}" + + mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir" + pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed" + + for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do + bn=$(basename "${f}") + slotted_name=${bn%.${mansec}}${SLOT}.${mansec} + case ${bn} in + TABLE.7|WITH.7) + echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name} + ;; + *) + echo ".so ${rel_manpath}/${bn}" > ${slotted_name} + ;; + esac + done + + popd > /dev/null + done + + insinto /etc/postgresql-${SLOT} + newins src/bin/psql/psqlrc.sample psqlrc + + # Don't delete libpg{port,common}.a (Bug #571046). They're always + # needed by extensions utilizing PGXS. + use static-libs || \ + find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \ + -delete + + # Make slot specific links to programs + local f bn + for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \ + -mindepth 1 -maxdepth 1) + do + bn=$(basename "${f}") + dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \ + "/usr/bin/${bn}${SLOT/.}" + done + + if use doc ; then + docinto html + dodoc doc/src/sgml/html/* + fi + + if use server; then + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} + + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT} + + if use systemd; then + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.service-9.6-r1" | \ + systemd_newunit - ${PN}-${SLOT}.service + newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir + newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf + fi + + use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session + + if use prefix ; then + keepdir /run/postgresql + fperms 1775 /run/postgresql + fi + fi +} + +pkg_postinst() { + use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf + 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 "https://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}" + + if [[ -n ${REPLACING_VERSIONS} ]] ; then + ewarn "If your system is using 'pg_stat_statements' and you are running a" + ewarn "version of PostgreSQL ${SLOT}, we advise that you execute" + ewarn "the following command after upgrading:" + ewarn + ewarn "ALTER EXTENSION pg_stat_statements UPDATE;" + fi + 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 " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html" + einfo " https://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 + if ! use systemd; then + einfo "The PostgreSQL server, by default, will log events to:" + einfo " ${DATA_DIR%/}/postmaster.log" + einfo + fi + 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}" + elif use systemd; then + einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL" + einfo "instead of 'pg_ctl'." + 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 +} diff --git a/dev-db/postgresql/postgresql-10.19.ebuild b/dev-db/postgresql/postgresql-10.19.ebuild deleted file mode 100644 index df3f68c9aec9..000000000000 --- a/dev-db/postgresql/postgresql-10.19.ebuild +++ /dev/null @@ -1,453 +0,0 @@ -# Copyright 1999-2022 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=7 - -PYTHON_COMPAT=( python3_{8,9,10} ) - -inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd tmpfiles - -KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~mips ppc ppc64 ~s390 sparc x86 ~ppc-macos ~x86-solaris" - -SLOT=$(ver_cut 1) - -MY_PV=${PV/_/} -S="${WORKDIR}/${PN}-${MY_PV}" - -SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2" - -LICENSE="POSTGRESQL GPL-2" -DESCRIPTION="PostgreSQL RDBMS" -HOMEPAGE="https://www.postgresql.org/" - -IUSE="debug doc icu kerberos ldap nls pam perl - python +readline selinux +server systemd ssl static-libs tcl - threads uuid xml zlib" - -REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" - -CDEPEND=" ->=app-eselect/eselect-postgresql-2.0 -acct-group/postgres -acct-user/postgres -sys-apps/less -virtual/libcrypt:= -virtual/libintl -icu? ( dev-libs/icu:= ) -kerberos? ( virtual/krb5 ) -ldap? ( net-nds/openldap ) -pam? ( sys-libs/pam ) -perl? ( >=dev-lang/perl-5.8:= ) -python? ( ${PYTHON_DEPS} ) -readline? ( sys-libs/readline:0= ) -server? ( systemd? ( sys-apps/systemd ) ) -ssl? ( >=dev-libs/openssl-0.9.6-r1:0= ) -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,musl} ) - -nest_usedep() { - local front back - while [[ ${#} -gt 1 ]]; do - front+="${1}? ( " - back+=" )" - shift - done - echo "${front}${1}${back}" -} - -CDEPEND+=" -uuid? ( - ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )} - $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid) -)" - -DEPEND="${CDEPEND} -sys-devel/bison -sys-devel/flex -nls? ( sys-devel/gettext ) -xml? ( virtual/pkgconfig ) -" - -RDEPEND="${CDEPEND} -selinux? ( sec-policy/selinux-postgresql ) -" - -pkg_setup() { - use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup - - use python && python-single-r1_pkg_setup -} - -src_prepare() { - # Work around PPC{,64} compilation bug where bool is already defined - sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die - - # Set proper run directory - sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \ - -i src/include/pg_config_manual.h || die - - # Rely on $PATH being in the proper order so that the correct - # install program is used for modules utilizing PGXS in both - # hardened and non-hardened environments. (Bug #528786) - sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die - - use server || eapply "${FILESDIR}/${PN}-10.2-no-server.patch" - - if use pam ; then - sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \ - -i src/backend/libpq/auth.c || \ - die 'PGSQL_PAM_SERVICE rename failed.' - fi - - # https://bugs.gentoo.org/753257 - # https://bugs.gentoo.org/766225 - eapply "${FILESDIR}"/postgresql-10.0-icu68.patch - - eapply_user -} - -src_configure() { - case ${CHOST} in - *-darwin*|*-solaris*) - use nls && append-libs intl - ;; - esac - - export LDFLAGS_SL="${LDFLAGS}" - export LDFLAGS_EX="${LDFLAGS}" - - local PO="${EPREFIX}" - - local i uuid_config="" - if use uuid; then - for i in ${UTIL_LINUX_LIBC[@]}; do - use ${i} && uuid_config="--with-uuid=e2fs" - done - [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp" - fi - - econf \ - --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \ - --datadir="${PO}/usr/share/postgresql-${SLOT}" \ - --includedir="${PO}/usr/include/postgresql-${SLOT}" \ - --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \ - --sysconfdir="${PO}/etc/postgresql-${SLOT}" \ - --with-system-tzdata="${PO}/usr/share/zoneinfo" \ - $(use_enable !alpha spinlocks) \ - $(use_enable debug) \ - $(use_enable threads thread-safety) \ - $(use_with icu) \ - $(use_with kerberos gssapi) \ - $(use_with ldap) \ - $(use_with pam) \ - $(use_with perl) \ - $(use_with python) \ - $(use_with readline) \ - $(use_with ssl openssl) \ - $(usex server "$(use_with systemd)" '--without-systemd') \ - $(use_with tcl) \ - ${uuid_config} \ - $(use_with xml libxml) \ - $(use_with xml libxslt) \ - $(use_with zlib) \ - $(use_enable nls) -} - -src_compile() { - emake - emake -C contrib -} - -src_install() { - emake DESTDIR="${D}" install - emake DESTDIR="${D}" install -C contrib - - dodoc README HISTORY doc/{TODO,bug.template} - - # man pages are already built, but if we have the target make them, - # they'll be generated from source before being installed so we - # manually install man pages. - # We use ${SLOT} instead of doman for postgresql.eselect - insinto /usr/share/postgresql-${SLOT}/man/ - doins -r doc/src/sgml/man{1,3,7} - if ! use server; then - # Remove man pages for non-existent binaries - serverman=( - initdb - pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby} - pg_{test_{fsync,timing},upgrade,waldump} - post{gres,master} - ) - for m in ${serverman[@]} ; do - rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1" - done - fi - docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7} - - # Create slot specific man pages - local bn f mansec slotted_name - for mansec in 1 3 7 ; do - local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}" - - mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir" - pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed" - - for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do - bn=$(basename "${f}") - slotted_name=${bn%.${mansec}}${SLOT}.${mansec} - case ${bn} in - TABLE.7|WITH.7) - echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name} - ;; - *) - echo ".so ${rel_manpath}/${bn}" > ${slotted_name} - ;; - esac - done - - popd > /dev/null - done - - insinto /etc/postgresql-${SLOT} - newins src/bin/psql/psqlrc.sample psqlrc - - # Don't delete libpg{port,common}.a (Bug #571046). They're always - # needed by extensions utilizing PGXS. - use static-libs || \ - find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \ - -delete - - # Make slot specific links to programs - local f bn - for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \ - -mindepth 1 -maxdepth 1) - do - bn=$(basename "${f}") - dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \ - "/usr/bin/${bn}${SLOT/.}" - done - - if use doc ; then - docinto html - dodoc doc/src/sgml/html/* - fi - - if use server; then - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} - - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT} - - if use systemd; then - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.service-9.6-r1" | \ - systemd_newunit - ${PN}-${SLOT}.service - newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir - newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf - fi - - use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session - - if use prefix ; then - keepdir /run/postgresql - fperms 1775 /run/postgresql - fi - fi -} - -pkg_postinst() { - use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf - 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 "https://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}" - - if [[ -n ${REPLACING_VERSIONS} ]] ; then - ewarn "If your system is using 'pg_stat_statements' and you are running a" - ewarn "version of PostgreSQL ${SLOT}, we advise that you execute" - ewarn "the following command after upgrading:" - ewarn - ewarn "ALTER EXTENSION pg_stat_statements UPDATE;" - fi - 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 " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html" - einfo " https://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 - if ! use systemd; then - einfo "The PostgreSQL server, by default, will log events to:" - einfo " ${DATA_DIR%/}/postmaster.log" - einfo - fi - 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}" - elif use systemd; then - einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL" - einfo "instead of 'pg_ctl'." - 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 -} diff --git a/dev-db/postgresql/postgresql-10.20-r1.ebuild b/dev-db/postgresql/postgresql-10.20-r1.ebuild new file mode 100644 index 000000000000..93f17aa04271 --- /dev/null +++ b/dev-db/postgresql/postgresql-10.20-r1.ebuild @@ -0,0 +1,453 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +PYTHON_COMPAT=( python3_{8,9,10} ) + +inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd tmpfiles + +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~ppc-macos ~x86-solaris" + +SLOT=$(ver_cut 1) + +MY_PV=${PV/_/} +S="${WORKDIR}/${PN}-${MY_PV}" + +SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2" + +LICENSE="POSTGRESQL GPL-2" +DESCRIPTION="PostgreSQL RDBMS" +HOMEPAGE="https://www.postgresql.org/" + +IUSE="debug doc icu kerberos ldap nls pam perl + python +readline selinux +server systemd ssl static-libs tcl + threads uuid xml zlib" + +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" + +CDEPEND=" +>=app-eselect/eselect-postgresql-2.0 +acct-group/postgres +acct-user/postgres +sys-apps/less +virtual/libcrypt:= +virtual/libintl +icu? ( dev-libs/icu:= ) +kerberos? ( virtual/krb5 ) +ldap? ( net-nds/openldap:= ) +pam? ( sys-libs/pam ) +perl? ( >=dev-lang/perl-5.8:= ) +python? ( ${PYTHON_DEPS} ) +readline? ( sys-libs/readline:0= ) +server? ( systemd? ( sys-apps/systemd ) ) +ssl? ( >=dev-libs/openssl-0.9.6-r1:0= ) +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,musl} ) + +nest_usedep() { + local front back + while [[ ${#} -gt 1 ]]; do + front+="${1}? ( " + back+=" )" + shift + done + echo "${front}${1}${back}" +} + +CDEPEND+=" +uuid? ( + ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )} + $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid) +)" + +DEPEND="${CDEPEND} +sys-devel/bison +sys-devel/flex +nls? ( sys-devel/gettext ) +xml? ( virtual/pkgconfig ) +" + +RDEPEND="${CDEPEND} +selinux? ( sec-policy/selinux-postgresql ) +" + +pkg_setup() { + use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup + + use python && python-single-r1_pkg_setup +} + +src_prepare() { + # Work around PPC{,64} compilation bug where bool is already defined + sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die + + # Set proper run directory + sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \ + -i src/include/pg_config_manual.h || die + + # Rely on $PATH being in the proper order so that the correct + # install program is used for modules utilizing PGXS in both + # hardened and non-hardened environments. (Bug #528786) + sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die + + use server || eapply "${FILESDIR}/${PN}-10.2-no-server.patch" + + if use pam ; then + sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \ + -i src/backend/libpq/auth.c || \ + die 'PGSQL_PAM_SERVICE rename failed.' + fi + + # https://bugs.gentoo.org/753257 + # https://bugs.gentoo.org/766225 + eapply "${FILESDIR}"/postgresql-10.0-icu68.patch + + eapply_user +} + +src_configure() { + case ${CHOST} in + *-darwin*|*-solaris*) + use nls && append-libs intl + ;; + esac + + export LDFLAGS_SL="${LDFLAGS}" + export LDFLAGS_EX="${LDFLAGS}" + + local PO="${EPREFIX}" + + local i uuid_config="" + if use uuid; then + for i in ${UTIL_LINUX_LIBC[@]}; do + use ${i} && uuid_config="--with-uuid=e2fs" + done + [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp" + fi + + econf \ + --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \ + --datadir="${PO}/usr/share/postgresql-${SLOT}" \ + --includedir="${PO}/usr/include/postgresql-${SLOT}" \ + --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \ + --sysconfdir="${PO}/etc/postgresql-${SLOT}" \ + --with-system-tzdata="${PO}/usr/share/zoneinfo" \ + $(use_enable !alpha spinlocks) \ + $(use_enable debug) \ + $(use_enable threads thread-safety) \ + $(use_with icu) \ + $(use_with kerberos gssapi) \ + $(use_with ldap) \ + $(use_with pam) \ + $(use_with perl) \ + $(use_with python) \ + $(use_with readline) \ + $(use_with ssl openssl) \ + $(usex server "$(use_with systemd)" '--without-systemd') \ + $(use_with tcl) \ + ${uuid_config} \ + $(use_with xml libxml) \ + $(use_with xml libxslt) \ + $(use_with zlib) \ + $(use_enable nls) +} + +src_compile() { + emake + emake -C contrib +} + +src_install() { + emake DESTDIR="${D}" install + emake DESTDIR="${D}" install -C contrib + + dodoc README HISTORY doc/{TODO,bug.template} + + # man pages are already built, but if we have the target make them, + # they'll be generated from source before being installed so we + # manually install man pages. + # We use ${SLOT} instead of doman for postgresql.eselect + insinto /usr/share/postgresql-${SLOT}/man/ + doins -r doc/src/sgml/man{1,3,7} + if ! use server; then + # Remove man pages for non-existent binaries + serverman=( + initdb + pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby} + pg_{test_{fsync,timing},upgrade,waldump} + post{gres,master} + ) + for m in ${serverman[@]} ; do + rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1" + done + fi + docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7} + + # Create slot specific man pages + local bn f mansec slotted_name + for mansec in 1 3 7 ; do + local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}" + + mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir" + pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed" + + for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do + bn=$(basename "${f}") + slotted_name=${bn%.${mansec}}${SLOT}.${mansec} + case ${bn} in + TABLE.7|WITH.7) + echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name} + ;; + *) + echo ".so ${rel_manpath}/${bn}" > ${slotted_name} + ;; + esac + done + + popd > /dev/null + done + + insinto /etc/postgresql-${SLOT} + newins src/bin/psql/psqlrc.sample psqlrc + + # Don't delete libpg{port,common}.a (Bug #571046). They're always + # needed by extensions utilizing PGXS. + use static-libs || \ + find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \ + -delete + + # Make slot specific links to programs + local f bn + for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \ + -mindepth 1 -maxdepth 1) + do + bn=$(basename "${f}") + dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \ + "/usr/bin/${bn}${SLOT/.}" + done + + if use doc ; then + docinto html + dodoc doc/src/sgml/html/* + fi + + if use server; then + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} + + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT} + + if use systemd; then + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.service-9.6-r1" | \ + systemd_newunit - ${PN}-${SLOT}.service + newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir + newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf + fi + + use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session + + if use prefix ; then + keepdir /run/postgresql + fperms 1775 /run/postgresql + fi + fi +} + +pkg_postinst() { + use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf + 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 "https://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}" + + if [[ -n ${REPLACING_VERSIONS} ]] ; then + ewarn "If your system is using 'pg_stat_statements' and you are running a" + ewarn "version of PostgreSQL ${SLOT}, we advise that you execute" + ewarn "the following command after upgrading:" + ewarn + ewarn "ALTER EXTENSION pg_stat_statements UPDATE;" + fi + 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 " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html" + einfo " https://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 + if ! use systemd; then + einfo "The PostgreSQL server, by default, will log events to:" + einfo " ${DATA_DIR%/}/postmaster.log" + einfo + fi + 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}" + elif use systemd; then + einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL" + einfo "instead of 'pg_ctl'." + 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 +} diff --git a/dev-db/postgresql/postgresql-10.20.ebuild b/dev-db/postgresql/postgresql-10.20.ebuild deleted file mode 100644 index ebb0a2ed17f5..000000000000 --- a/dev-db/postgresql/postgresql-10.20.ebuild +++ /dev/null @@ -1,453 +0,0 @@ -# Copyright 1999-2022 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=7 - -PYTHON_COMPAT=( python3_{8,9,10} ) - -inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd tmpfiles - -KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~ppc-macos ~x86-solaris" - -SLOT=$(ver_cut 1) - -MY_PV=${PV/_/} -S="${WORKDIR}/${PN}-${MY_PV}" - -SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2" - -LICENSE="POSTGRESQL GPL-2" -DESCRIPTION="PostgreSQL RDBMS" -HOMEPAGE="https://www.postgresql.org/" - -IUSE="debug doc icu kerberos ldap nls pam perl - python +readline selinux +server systemd ssl static-libs tcl - threads uuid xml zlib" - -REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" - -CDEPEND=" ->=app-eselect/eselect-postgresql-2.0 -acct-group/postgres -acct-user/postgres -sys-apps/less -virtual/libcrypt:= -virtual/libintl -icu? ( dev-libs/icu:= ) -kerberos? ( virtual/krb5 ) -ldap? ( net-nds/openldap ) -pam? ( sys-libs/pam ) -perl? ( >=dev-lang/perl-5.8:= ) -python? ( ${PYTHON_DEPS} ) -readline? ( sys-libs/readline:0= ) -server? ( systemd? ( sys-apps/systemd ) ) -ssl? ( >=dev-libs/openssl-0.9.6-r1:0= ) -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,musl} ) - -nest_usedep() { - local front back - while [[ ${#} -gt 1 ]]; do - front+="${1}? ( " - back+=" )" - shift - done - echo "${front}${1}${back}" -} - -CDEPEND+=" -uuid? ( - ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )} - $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid) -)" - -DEPEND="${CDEPEND} -sys-devel/bison -sys-devel/flex -nls? ( sys-devel/gettext ) -xml? ( virtual/pkgconfig ) -" - -RDEPEND="${CDEPEND} -selinux? ( sec-policy/selinux-postgresql ) -" - -pkg_setup() { - use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup - - use python && python-single-r1_pkg_setup -} - -src_prepare() { - # Work around PPC{,64} compilation bug where bool is already defined - sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die - - # Set proper run directory - sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \ - -i src/include/pg_config_manual.h || die - - # Rely on $PATH being in the proper order so that the correct - # install program is used for modules utilizing PGXS in both - # hardened and non-hardened environments. (Bug #528786) - sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die - - use server || eapply "${FILESDIR}/${PN}-10.2-no-server.patch" - - if use pam ; then - sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \ - -i src/backend/libpq/auth.c || \ - die 'PGSQL_PAM_SERVICE rename failed.' - fi - - # https://bugs.gentoo.org/753257 - # https://bugs.gentoo.org/766225 - eapply "${FILESDIR}"/postgresql-10.0-icu68.patch - - eapply_user -} - -src_configure() { - case ${CHOST} in - *-darwin*|*-solaris*) - use nls && append-libs intl - ;; - esac - - export LDFLAGS_SL="${LDFLAGS}" - export LDFLAGS_EX="${LDFLAGS}" - - local PO="${EPREFIX}" - - local i uuid_config="" - if use uuid; then - for i in ${UTIL_LINUX_LIBC[@]}; do - use ${i} && uuid_config="--with-uuid=e2fs" - done - [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp" - fi - - econf \ - --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \ - --datadir="${PO}/usr/share/postgresql-${SLOT}" \ - --includedir="${PO}/usr/include/postgresql-${SLOT}" \ - --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \ - --sysconfdir="${PO}/etc/postgresql-${SLOT}" \ - --with-system-tzdata="${PO}/usr/share/zoneinfo" \ - $(use_enable !alpha spinlocks) \ - $(use_enable debug) \ - $(use_enable threads thread-safety) \ - $(use_with icu) \ - $(use_with kerberos gssapi) \ - $(use_with ldap) \ - $(use_with pam) \ - $(use_with perl) \ - $(use_with python) \ - $(use_with readline) \ - $(use_with ssl openssl) \ - $(usex server "$(use_with systemd)" '--without-systemd') \ - $(use_with tcl) \ - ${uuid_config} \ - $(use_with xml libxml) \ - $(use_with xml libxslt) \ - $(use_with zlib) \ - $(use_enable nls) -} - -src_compile() { - emake - emake -C contrib -} - -src_install() { - emake DESTDIR="${D}" install - emake DESTDIR="${D}" install -C contrib - - dodoc README HISTORY doc/{TODO,bug.template} - - # man pages are already built, but if we have the target make them, - # they'll be generated from source before being installed so we - # manually install man pages. - # We use ${SLOT} instead of doman for postgresql.eselect - insinto /usr/share/postgresql-${SLOT}/man/ - doins -r doc/src/sgml/man{1,3,7} - if ! use server; then - # Remove man pages for non-existent binaries - serverman=( - initdb - pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby} - pg_{test_{fsync,timing},upgrade,waldump} - post{gres,master} - ) - for m in ${serverman[@]} ; do - rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1" - done - fi - docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7} - - # Create slot specific man pages - local bn f mansec slotted_name - for mansec in 1 3 7 ; do - local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}" - - mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir" - pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed" - - for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do - bn=$(basename "${f}") - slotted_name=${bn%.${mansec}}${SLOT}.${mansec} - case ${bn} in - TABLE.7|WITH.7) - echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name} - ;; - *) - echo ".so ${rel_manpath}/${bn}" > ${slotted_name} - ;; - esac - done - - popd > /dev/null - done - - insinto /etc/postgresql-${SLOT} - newins src/bin/psql/psqlrc.sample psqlrc - - # Don't delete libpg{port,common}.a (Bug #571046). They're always - # needed by extensions utilizing PGXS. - use static-libs || \ - find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \ - -delete - - # Make slot specific links to programs - local f bn - for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \ - -mindepth 1 -maxdepth 1) - do - bn=$(basename "${f}") - dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \ - "/usr/bin/${bn}${SLOT/.}" - done - - if use doc ; then - docinto html - dodoc doc/src/sgml/html/* - fi - - if use server; then - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} - - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT} - - if use systemd; then - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.service-9.6-r1" | \ - systemd_newunit - ${PN}-${SLOT}.service - newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir - newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf - fi - - use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session - - if use prefix ; then - keepdir /run/postgresql - fperms 1775 /run/postgresql - fi - fi -} - -pkg_postinst() { - use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf - 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 "https://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}" - - if [[ -n ${REPLACING_VERSIONS} ]] ; then - ewarn "If your system is using 'pg_stat_statements' and you are running a" - ewarn "version of PostgreSQL ${SLOT}, we advise that you execute" - ewarn "the following command after upgrading:" - ewarn - ewarn "ALTER EXTENSION pg_stat_statements UPDATE;" - fi - 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 " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html" - einfo " https://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 - if ! use systemd; then - einfo "The PostgreSQL server, by default, will log events to:" - einfo " ${DATA_DIR%/}/postmaster.log" - einfo - fi - 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}" - elif use systemd; then - einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL" - einfo "instead of 'pg_ctl'." - 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 -} diff --git a/dev-db/postgresql/postgresql-11.14-r1.ebuild b/dev-db/postgresql/postgresql-11.14-r1.ebuild new file mode 100644 index 000000000000..8ec21798e0ae --- /dev/null +++ b/dev-db/postgresql/postgresql-11.14-r1.ebuild @@ -0,0 +1,453 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +PYTHON_COMPAT=( python3_{8,9,10} ) +LLVM_MAX_SLOT=13 + +inherit flag-o-matic linux-info llvm multilib pam prefix python-single-r1 systemd tmpfiles + +KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~mips ppc ppc64 ~s390 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" + +SLOT=$(ver_cut 1) + +MY_PV=${PV/_/} +S="${WORKDIR}/${PN}-${MY_PV}" + +SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2" + +LICENSE="POSTGRESQL GPL-2" +DESCRIPTION="PostgreSQL RDBMS" +HOMEPAGE="https://www.postgresql.org/" + +IUSE="debug doc icu kerberos ldap llvm nls pam + perl python +readline selinux +server systemd ssl static-libs tcl + threads uuid xml zlib" + +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" + +CDEPEND=" +>=app-eselect/eselect-postgresql-2.0 +acct-group/postgres +acct-user/postgres +sys-apps/less +virtual/libintl +icu? ( dev-libs/icu:= ) +kerberos? ( virtual/krb5 ) +ldap? ( net-nds/openldap:= ) +llvm? ( + =dev-lang/perl-5.8:= ) +python? ( ${PYTHON_DEPS} ) +readline? ( sys-libs/readline:0= ) +server? ( systemd? ( sys-apps/systemd ) ) +ssl? ( >=dev-libs/openssl-0.9.6-r1:0= ) +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,musl} ) + +nest_usedep() { + local front back + while [[ ${#} -gt 1 ]]; do + front+="${1}? ( " + back+=" )" + shift + done + echo "${front}${1}${back}" +} + +CDEPEND+=" +uuid? ( + ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )} + $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid) +)" + +DEPEND="${CDEPEND} +sys-devel/bison +sys-devel/flex +nls? ( sys-devel/gettext ) +xml? ( virtual/pkgconfig ) +" + +RDEPEND="${CDEPEND} +selinux? ( sec-policy/selinux-postgresql ) +" + +pkg_setup() { + use llvm && llvm_pkg_setup + + use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup + + use python && python-single-r1_pkg_setup +} + +src_prepare() { + # Set proper run directory + sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \ + -i src/include/pg_config_manual.h || die + + # Rely on $PATH being in the proper order so that the correct + # install program is used for modules utilizing PGXS in both + # hardened and non-hardened environments. (Bug #528786) + sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die + + use server || eapply "${FILESDIR}/${PN}-11_beta1-no-server.patch" + + if use pam ; then + sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \ + -i src/backend/libpq/auth.c || \ + die 'PGSQL_PAM_SERVICE rename failed.' + fi + + eapply_user +} + +src_configure() { + case ${CHOST} in + *-darwin*|*-solaris*) + use nls && append-libs intl + ;; + esac + + export LDFLAGS_SL="${LDFLAGS}" + export LDFLAGS_EX="${LDFLAGS}" + + local PO="${EPREFIX}" + + local i uuid_config="" + if use uuid; then + for i in ${UTIL_LINUX_LIBC[@]}; do + use ${i} && uuid_config="--with-uuid=e2fs" + done + [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp" + fi + + econf \ + --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \ + --datadir="${PO}/usr/share/postgresql-${SLOT}" \ + --includedir="${PO}/usr/include/postgresql-${SLOT}" \ + --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \ + --sysconfdir="${PO}/etc/postgresql-${SLOT}" \ + --with-system-tzdata="${PO}/usr/share/zoneinfo" \ + $(use_enable !alpha spinlocks) \ + $(use_enable debug) \ + $(use_enable threads thread-safety) \ + $(use_with icu) \ + $(use_with kerberos gssapi) \ + $(use_with ldap) \ + $(use_with llvm) \ + $(use_with pam) \ + $(use_with perl) \ + $(use_with python) \ + $(use_with readline) \ + $(use_with ssl openssl) \ + $(usex server "$(use_with systemd)" '--without-systemd') \ + $(use_with tcl) \ + ${uuid_config} \ + $(use_with xml libxml) \ + $(use_with xml libxslt) \ + $(use_with zlib) \ + $(use_enable nls) +} + +src_compile() { + emake + emake -C contrib +} + +src_install() { + emake DESTDIR="${D}" install + emake DESTDIR="${D}" install -C contrib + + dodoc README HISTORY doc/{TODO,bug.template} + + # man pages are already built, but if we have the target make them, + # they'll be generated from source before being installed so we + # manually install man pages. + # We use ${SLOT} instead of doman for postgresql.eselect + insinto /usr/share/postgresql-${SLOT}/man/ + doins -r doc/src/sgml/man{1,3,7} + if ! use server; then + # Remove man pages for non-existent binaries + serverman=( + initdb + pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby} + pg_{test_{fsync,timing},upgrade,waldump} + post{gres,master} + ) + for m in ${serverman[@]} ; do + rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1" + done + fi + docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7} + + # Create slot specific man pages + local bn f mansec slotted_name + for mansec in 1 3 7 ; do + local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}" + + mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir" + pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed" + + for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do + bn=$(basename "${f}") + slotted_name=${bn%.${mansec}}${SLOT}.${mansec} + case ${bn} in + TABLE.7|WITH.7) + echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name} + ;; + *) + echo ".so ${rel_manpath}/${bn}" > ${slotted_name} + ;; + esac + done + + popd > /dev/null + done + + insinto /etc/postgresql-${SLOT} + newins src/bin/psql/psqlrc.sample psqlrc + + # Don't delete libpg{port,common}.a (Bug #571046). They're always + # needed by extensions utilizing PGXS. + use static-libs || \ + find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \ + -delete + + # Make slot specific links to programs + local f bn + for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \ + -mindepth 1 -maxdepth 1) + do + bn=$(basename "${f}") + dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \ + "/usr/bin/${bn}${SLOT/.}" + done + + if use doc ; then + docinto html + dodoc doc/src/sgml/html/* + fi + + if use server; then + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} + + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT} + + if use systemd; then + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.service-9.6-r1" | \ + systemd_newunit - ${PN}-${SLOT}.service + newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir + newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf + fi + + use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session + + if use prefix ; then + keepdir /run/postgresql + fperms 1775 /run/postgresql + fi + fi +} + +pkg_postinst() { + use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf + 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 "https://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}" + + if [[ -n ${REPLACING_VERSIONS} ]] ; then + ewarn "If your system is using 'pg_stat_statements' and you are running a" + ewarn "version of PostgreSQL ${SLOT}, we advise that you execute" + ewarn "the following command after upgrading:" + ewarn + ewarn "ALTER EXTENSION pg_stat_statements UPDATE;" + fi + 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 " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html" + einfo " https://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 "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs" + mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR" + chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown" + 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 + if ! use systemd; then + einfo "The PostgreSQL server, by default, will log events to:" + einfo " ${DATA_DIR%/}/postmaster.log" + einfo + fi + 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}" + elif use systemd; then + einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL" + einfo "instead of 'pg_ctl'." + 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 +} diff --git a/dev-db/postgresql/postgresql-11.14.ebuild b/dev-db/postgresql/postgresql-11.14.ebuild deleted file mode 100644 index 0614243cb8c4..000000000000 --- a/dev-db/postgresql/postgresql-11.14.ebuild +++ /dev/null @@ -1,450 +0,0 @@ -# Copyright 1999-2022 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=7 - -PYTHON_COMPAT=( python3_{8,9,10} ) - -inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd tmpfiles - -KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~mips ppc ppc64 ~s390 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" - -SLOT=$(ver_cut 1) - -MY_PV=${PV/_/} -S="${WORKDIR}/${PN}-${MY_PV}" - -SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2" - -LICENSE="POSTGRESQL GPL-2" -DESCRIPTION="PostgreSQL RDBMS" -HOMEPAGE="https://www.postgresql.org/" - -IUSE="debug doc icu kerberos ldap llvm nls pam - perl python +readline selinux +server systemd ssl static-libs tcl - threads uuid xml zlib" - -REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" - -CDEPEND=" ->=app-eselect/eselect-postgresql-2.0 -acct-group/postgres -acct-user/postgres -sys-apps/less -virtual/libintl -icu? ( dev-libs/icu:= ) -kerberos? ( virtual/krb5 ) -ldap? ( net-nds/openldap ) -llvm? ( - sys-devel/llvm:= - sys-devel/clang:= -) -pam? ( sys-libs/pam ) -perl? ( >=dev-lang/perl-5.8:= ) -python? ( ${PYTHON_DEPS} ) -readline? ( sys-libs/readline:0= ) -server? ( systemd? ( sys-apps/systemd ) ) -ssl? ( >=dev-libs/openssl-0.9.6-r1:0= ) -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,musl} ) - -nest_usedep() { - local front back - while [[ ${#} -gt 1 ]]; do - front+="${1}? ( " - back+=" )" - shift - done - echo "${front}${1}${back}" -} - -CDEPEND+=" -uuid? ( - ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )} - $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid) -)" - -DEPEND="${CDEPEND} -sys-devel/bison -sys-devel/flex -nls? ( sys-devel/gettext ) -xml? ( virtual/pkgconfig ) -" - -RDEPEND="${CDEPEND} -selinux? ( sec-policy/selinux-postgresql ) -" - -pkg_setup() { - use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup - - use python && python-single-r1_pkg_setup -} - -src_prepare() { - # Set proper run directory - sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \ - -i src/include/pg_config_manual.h || die - - # Rely on $PATH being in the proper order so that the correct - # install program is used for modules utilizing PGXS in both - # hardened and non-hardened environments. (Bug #528786) - sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die - - use server || eapply "${FILESDIR}/${PN}-11_beta1-no-server.patch" - - if use pam ; then - sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \ - -i src/backend/libpq/auth.c || \ - die 'PGSQL_PAM_SERVICE rename failed.' - fi - - eapply_user -} - -src_configure() { - case ${CHOST} in - *-darwin*|*-solaris*) - use nls && append-libs intl - ;; - esac - - export LDFLAGS_SL="${LDFLAGS}" - export LDFLAGS_EX="${LDFLAGS}" - - local PO="${EPREFIX}" - - local i uuid_config="" - if use uuid; then - for i in ${UTIL_LINUX_LIBC[@]}; do - use ${i} && uuid_config="--with-uuid=e2fs" - done - [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp" - fi - - econf \ - --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \ - --datadir="${PO}/usr/share/postgresql-${SLOT}" \ - --includedir="${PO}/usr/include/postgresql-${SLOT}" \ - --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \ - --sysconfdir="${PO}/etc/postgresql-${SLOT}" \ - --with-system-tzdata="${PO}/usr/share/zoneinfo" \ - $(use_enable !alpha spinlocks) \ - $(use_enable debug) \ - $(use_enable threads thread-safety) \ - $(use_with icu) \ - $(use_with kerberos gssapi) \ - $(use_with ldap) \ - $(use_with llvm) \ - $(use_with pam) \ - $(use_with perl) \ - $(use_with python) \ - $(use_with readline) \ - $(use_with ssl openssl) \ - $(usex server "$(use_with systemd)" '--without-systemd') \ - $(use_with tcl) \ - ${uuid_config} \ - $(use_with xml libxml) \ - $(use_with xml libxslt) \ - $(use_with zlib) \ - $(use_enable nls) -} - -src_compile() { - emake - emake -C contrib -} - -src_install() { - emake DESTDIR="${D}" install - emake DESTDIR="${D}" install -C contrib - - dodoc README HISTORY doc/{TODO,bug.template} - - # man pages are already built, but if we have the target make them, - # they'll be generated from source before being installed so we - # manually install man pages. - # We use ${SLOT} instead of doman for postgresql.eselect - insinto /usr/share/postgresql-${SLOT}/man/ - doins -r doc/src/sgml/man{1,3,7} - if ! use server; then - # Remove man pages for non-existent binaries - serverman=( - initdb - pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby} - pg_{test_{fsync,timing},upgrade,waldump} - post{gres,master} - ) - for m in ${serverman[@]} ; do - rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1" - done - fi - docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7} - - # Create slot specific man pages - local bn f mansec slotted_name - for mansec in 1 3 7 ; do - local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}" - - mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir" - pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed" - - for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do - bn=$(basename "${f}") - slotted_name=${bn%.${mansec}}${SLOT}.${mansec} - case ${bn} in - TABLE.7|WITH.7) - echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name} - ;; - *) - echo ".so ${rel_manpath}/${bn}" > ${slotted_name} - ;; - esac - done - - popd > /dev/null - done - - insinto /etc/postgresql-${SLOT} - newins src/bin/psql/psqlrc.sample psqlrc - - # Don't delete libpg{port,common}.a (Bug #571046). They're always - # needed by extensions utilizing PGXS. - use static-libs || \ - find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \ - -delete - - # Make slot specific links to programs - local f bn - for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \ - -mindepth 1 -maxdepth 1) - do - bn=$(basename "${f}") - dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \ - "/usr/bin/${bn}${SLOT/.}" - done - - if use doc ; then - docinto html - dodoc doc/src/sgml/html/* - fi - - if use server; then - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} - - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT} - - if use systemd; then - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.service-9.6-r1" | \ - systemd_newunit - ${PN}-${SLOT}.service - newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir - newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf - fi - - use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session - - if use prefix ; then - keepdir /run/postgresql - fperms 1775 /run/postgresql - fi - fi -} - -pkg_postinst() { - use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf - 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 "https://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}" - - if [[ -n ${REPLACING_VERSIONS} ]] ; then - ewarn "If your system is using 'pg_stat_statements' and you are running a" - ewarn "version of PostgreSQL ${SLOT}, we advise that you execute" - ewarn "the following command after upgrading:" - ewarn - ewarn "ALTER EXTENSION pg_stat_statements UPDATE;" - fi - 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 " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html" - einfo " https://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 "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs" - mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR" - chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown" - 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 - if ! use systemd; then - einfo "The PostgreSQL server, by default, will log events to:" - einfo " ${DATA_DIR%/}/postmaster.log" - einfo - fi - 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}" - elif use systemd; then - einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL" - einfo "instead of 'pg_ctl'." - 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 -} diff --git a/dev-db/postgresql/postgresql-11.15-r1.ebuild b/dev-db/postgresql/postgresql-11.15-r1.ebuild new file mode 100644 index 000000000000..4be0a8926b5d --- /dev/null +++ b/dev-db/postgresql/postgresql-11.15-r1.ebuild @@ -0,0 +1,453 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +PYTHON_COMPAT=( python3_{8,9,10} ) +LLVM_MAX_SLOT=13 + +inherit flag-o-matic linux-info llvm multilib pam prefix python-single-r1 systemd tmpfiles + +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" + +SLOT=$(ver_cut 1) + +MY_PV=${PV/_/} +S="${WORKDIR}/${PN}-${MY_PV}" + +SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2" + +LICENSE="POSTGRESQL GPL-2" +DESCRIPTION="PostgreSQL RDBMS" +HOMEPAGE="https://www.postgresql.org/" + +IUSE="debug doc icu kerberos ldap llvm nls pam + perl python +readline selinux +server systemd ssl static-libs tcl + threads uuid xml zlib" + +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" + +CDEPEND=" +>=app-eselect/eselect-postgresql-2.0 +acct-group/postgres +acct-user/postgres +sys-apps/less +virtual/libintl +icu? ( dev-libs/icu:= ) +kerberos? ( virtual/krb5 ) +ldap? ( net-nds/openldap:= ) +llvm? ( + =dev-lang/perl-5.8:= ) +python? ( ${PYTHON_DEPS} ) +readline? ( sys-libs/readline:0= ) +server? ( systemd? ( sys-apps/systemd ) ) +ssl? ( >=dev-libs/openssl-0.9.6-r1:0= ) +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,musl} ) + +nest_usedep() { + local front back + while [[ ${#} -gt 1 ]]; do + front+="${1}? ( " + back+=" )" + shift + done + echo "${front}${1}${back}" +} + +CDEPEND+=" +uuid? ( + ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )} + $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid) +)" + +DEPEND="${CDEPEND} +sys-devel/bison +sys-devel/flex +nls? ( sys-devel/gettext ) +xml? ( virtual/pkgconfig ) +" + +RDEPEND="${CDEPEND} +selinux? ( sec-policy/selinux-postgresql ) +" + +pkg_setup() { + use llvm && llvm_pkg_setup + + use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup + + use python && python-single-r1_pkg_setup +} + +src_prepare() { + # Set proper run directory + sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \ + -i src/include/pg_config_manual.h || die + + # Rely on $PATH being in the proper order so that the correct + # install program is used for modules utilizing PGXS in both + # hardened and non-hardened environments. (Bug #528786) + sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die + + use server || eapply "${FILESDIR}/${PN}-11_beta1-no-server.patch" + + if use pam ; then + sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \ + -i src/backend/libpq/auth.c || \ + die 'PGSQL_PAM_SERVICE rename failed.' + fi + + eapply_user +} + +src_configure() { + case ${CHOST} in + *-darwin*|*-solaris*) + use nls && append-libs intl + ;; + esac + + export LDFLAGS_SL="${LDFLAGS}" + export LDFLAGS_EX="${LDFLAGS}" + + local PO="${EPREFIX}" + + local i uuid_config="" + if use uuid; then + for i in ${UTIL_LINUX_LIBC[@]}; do + use ${i} && uuid_config="--with-uuid=e2fs" + done + [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp" + fi + + econf \ + --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \ + --datadir="${PO}/usr/share/postgresql-${SLOT}" \ + --includedir="${PO}/usr/include/postgresql-${SLOT}" \ + --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \ + --sysconfdir="${PO}/etc/postgresql-${SLOT}" \ + --with-system-tzdata="${PO}/usr/share/zoneinfo" \ + $(use_enable !alpha spinlocks) \ + $(use_enable debug) \ + $(use_enable threads thread-safety) \ + $(use_with icu) \ + $(use_with kerberos gssapi) \ + $(use_with ldap) \ + $(use_with llvm) \ + $(use_with pam) \ + $(use_with perl) \ + $(use_with python) \ + $(use_with readline) \ + $(use_with ssl openssl) \ + $(usex server "$(use_with systemd)" '--without-systemd') \ + $(use_with tcl) \ + ${uuid_config} \ + $(use_with xml libxml) \ + $(use_with xml libxslt) \ + $(use_with zlib) \ + $(use_enable nls) +} + +src_compile() { + emake + emake -C contrib +} + +src_install() { + emake DESTDIR="${D}" install + emake DESTDIR="${D}" install -C contrib + + dodoc README HISTORY doc/{TODO,bug.template} + + # man pages are already built, but if we have the target make them, + # they'll be generated from source before being installed so we + # manually install man pages. + # We use ${SLOT} instead of doman for postgresql.eselect + insinto /usr/share/postgresql-${SLOT}/man/ + doins -r doc/src/sgml/man{1,3,7} + if ! use server; then + # Remove man pages for non-existent binaries + serverman=( + initdb + pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby} + pg_{test_{fsync,timing},upgrade,waldump} + post{gres,master} + ) + for m in ${serverman[@]} ; do + rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1" + done + fi + docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7} + + # Create slot specific man pages + local bn f mansec slotted_name + for mansec in 1 3 7 ; do + local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}" + + mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir" + pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed" + + for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do + bn=$(basename "${f}") + slotted_name=${bn%.${mansec}}${SLOT}.${mansec} + case ${bn} in + TABLE.7|WITH.7) + echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name} + ;; + *) + echo ".so ${rel_manpath}/${bn}" > ${slotted_name} + ;; + esac + done + + popd > /dev/null + done + + insinto /etc/postgresql-${SLOT} + newins src/bin/psql/psqlrc.sample psqlrc + + # Don't delete libpg{port,common}.a (Bug #571046). They're always + # needed by extensions utilizing PGXS. + use static-libs || \ + find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \ + -delete + + # Make slot specific links to programs + local f bn + for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \ + -mindepth 1 -maxdepth 1) + do + bn=$(basename "${f}") + dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \ + "/usr/bin/${bn}${SLOT/.}" + done + + if use doc ; then + docinto html + dodoc doc/src/sgml/html/* + fi + + if use server; then + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} + + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT} + + if use systemd; then + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.service-9.6-r1" | \ + systemd_newunit - ${PN}-${SLOT}.service + newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir + newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf + fi + + use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session + + if use prefix ; then + keepdir /run/postgresql + fperms 1775 /run/postgresql + fi + fi +} + +pkg_postinst() { + use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf + 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 "https://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}" + + if [[ -n ${REPLACING_VERSIONS} ]] ; then + ewarn "If your system is using 'pg_stat_statements' and you are running a" + ewarn "version of PostgreSQL ${SLOT}, we advise that you execute" + ewarn "the following command after upgrading:" + ewarn + ewarn "ALTER EXTENSION pg_stat_statements UPDATE;" + fi + 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 " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html" + einfo " https://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 "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs" + mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR" + chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown" + 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 + if ! use systemd; then + einfo "The PostgreSQL server, by default, will log events to:" + einfo " ${DATA_DIR%/}/postmaster.log" + einfo + fi + 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}" + elif use systemd; then + einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL" + einfo "instead of 'pg_ctl'." + 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 +} diff --git a/dev-db/postgresql/postgresql-11.15.ebuild b/dev-db/postgresql/postgresql-11.15.ebuild deleted file mode 100644 index bc66c22563cc..000000000000 --- a/dev-db/postgresql/postgresql-11.15.ebuild +++ /dev/null @@ -1,450 +0,0 @@ -# Copyright 1999-2022 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=7 - -PYTHON_COMPAT=( python3_{8,9,10} ) - -inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd tmpfiles - -KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" - -SLOT=$(ver_cut 1) - -MY_PV=${PV/_/} -S="${WORKDIR}/${PN}-${MY_PV}" - -SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2" - -LICENSE="POSTGRESQL GPL-2" -DESCRIPTION="PostgreSQL RDBMS" -HOMEPAGE="https://www.postgresql.org/" - -IUSE="debug doc icu kerberos ldap llvm nls pam - perl python +readline selinux +server systemd ssl static-libs tcl - threads uuid xml zlib" - -REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" - -CDEPEND=" ->=app-eselect/eselect-postgresql-2.0 -acct-group/postgres -acct-user/postgres -sys-apps/less -virtual/libintl -icu? ( dev-libs/icu:= ) -kerberos? ( virtual/krb5 ) -ldap? ( net-nds/openldap ) -llvm? ( - sys-devel/llvm:= - sys-devel/clang:= -) -pam? ( sys-libs/pam ) -perl? ( >=dev-lang/perl-5.8:= ) -python? ( ${PYTHON_DEPS} ) -readline? ( sys-libs/readline:0= ) -server? ( systemd? ( sys-apps/systemd ) ) -ssl? ( >=dev-libs/openssl-0.9.6-r1:0= ) -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,musl} ) - -nest_usedep() { - local front back - while [[ ${#} -gt 1 ]]; do - front+="${1}? ( " - back+=" )" - shift - done - echo "${front}${1}${back}" -} - -CDEPEND+=" -uuid? ( - ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )} - $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid) -)" - -DEPEND="${CDEPEND} -sys-devel/bison -sys-devel/flex -nls? ( sys-devel/gettext ) -xml? ( virtual/pkgconfig ) -" - -RDEPEND="${CDEPEND} -selinux? ( sec-policy/selinux-postgresql ) -" - -pkg_setup() { - use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup - - use python && python-single-r1_pkg_setup -} - -src_prepare() { - # Set proper run directory - sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \ - -i src/include/pg_config_manual.h || die - - # Rely on $PATH being in the proper order so that the correct - # install program is used for modules utilizing PGXS in both - # hardened and non-hardened environments. (Bug #528786) - sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die - - use server || eapply "${FILESDIR}/${PN}-11_beta1-no-server.patch" - - if use pam ; then - sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \ - -i src/backend/libpq/auth.c || \ - die 'PGSQL_PAM_SERVICE rename failed.' - fi - - eapply_user -} - -src_configure() { - case ${CHOST} in - *-darwin*|*-solaris*) - use nls && append-libs intl - ;; - esac - - export LDFLAGS_SL="${LDFLAGS}" - export LDFLAGS_EX="${LDFLAGS}" - - local PO="${EPREFIX}" - - local i uuid_config="" - if use uuid; then - for i in ${UTIL_LINUX_LIBC[@]}; do - use ${i} && uuid_config="--with-uuid=e2fs" - done - [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp" - fi - - econf \ - --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \ - --datadir="${PO}/usr/share/postgresql-${SLOT}" \ - --includedir="${PO}/usr/include/postgresql-${SLOT}" \ - --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \ - --sysconfdir="${PO}/etc/postgresql-${SLOT}" \ - --with-system-tzdata="${PO}/usr/share/zoneinfo" \ - $(use_enable !alpha spinlocks) \ - $(use_enable debug) \ - $(use_enable threads thread-safety) \ - $(use_with icu) \ - $(use_with kerberos gssapi) \ - $(use_with ldap) \ - $(use_with llvm) \ - $(use_with pam) \ - $(use_with perl) \ - $(use_with python) \ - $(use_with readline) \ - $(use_with ssl openssl) \ - $(usex server "$(use_with systemd)" '--without-systemd') \ - $(use_with tcl) \ - ${uuid_config} \ - $(use_with xml libxml) \ - $(use_with xml libxslt) \ - $(use_with zlib) \ - $(use_enable nls) -} - -src_compile() { - emake - emake -C contrib -} - -src_install() { - emake DESTDIR="${D}" install - emake DESTDIR="${D}" install -C contrib - - dodoc README HISTORY doc/{TODO,bug.template} - - # man pages are already built, but if we have the target make them, - # they'll be generated from source before being installed so we - # manually install man pages. - # We use ${SLOT} instead of doman for postgresql.eselect - insinto /usr/share/postgresql-${SLOT}/man/ - doins -r doc/src/sgml/man{1,3,7} - if ! use server; then - # Remove man pages for non-existent binaries - serverman=( - initdb - pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby} - pg_{test_{fsync,timing},upgrade,waldump} - post{gres,master} - ) - for m in ${serverman[@]} ; do - rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1" - done - fi - docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7} - - # Create slot specific man pages - local bn f mansec slotted_name - for mansec in 1 3 7 ; do - local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}" - - mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir" - pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed" - - for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do - bn=$(basename "${f}") - slotted_name=${bn%.${mansec}}${SLOT}.${mansec} - case ${bn} in - TABLE.7|WITH.7) - echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name} - ;; - *) - echo ".so ${rel_manpath}/${bn}" > ${slotted_name} - ;; - esac - done - - popd > /dev/null - done - - insinto /etc/postgresql-${SLOT} - newins src/bin/psql/psqlrc.sample psqlrc - - # Don't delete libpg{port,common}.a (Bug #571046). They're always - # needed by extensions utilizing PGXS. - use static-libs || \ - find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \ - -delete - - # Make slot specific links to programs - local f bn - for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \ - -mindepth 1 -maxdepth 1) - do - bn=$(basename "${f}") - dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \ - "/usr/bin/${bn}${SLOT/.}" - done - - if use doc ; then - docinto html - dodoc doc/src/sgml/html/* - fi - - if use server; then - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} - - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT} - - if use systemd; then - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.service-9.6-r1" | \ - systemd_newunit - ${PN}-${SLOT}.service - newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir - newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf - fi - - use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session - - if use prefix ; then - keepdir /run/postgresql - fperms 1775 /run/postgresql - fi - fi -} - -pkg_postinst() { - use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf - 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 "https://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}" - - if [[ -n ${REPLACING_VERSIONS} ]] ; then - ewarn "If your system is using 'pg_stat_statements' and you are running a" - ewarn "version of PostgreSQL ${SLOT}, we advise that you execute" - ewarn "the following command after upgrading:" - ewarn - ewarn "ALTER EXTENSION pg_stat_statements UPDATE;" - fi - 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 " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html" - einfo " https://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 "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs" - mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR" - chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown" - 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 - if ! use systemd; then - einfo "The PostgreSQL server, by default, will log events to:" - einfo " ${DATA_DIR%/}/postmaster.log" - einfo - fi - 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}" - elif use systemd; then - einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL" - einfo "instead of 'pg_ctl'." - 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 -} diff --git a/dev-db/postgresql/postgresql-12.10-r1.ebuild b/dev-db/postgresql/postgresql-12.10-r1.ebuild new file mode 100644 index 000000000000..3c97b24fd2a4 --- /dev/null +++ b/dev-db/postgresql/postgresql-12.10-r1.ebuild @@ -0,0 +1,454 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +PYTHON_COMPAT=( python3_{8,9,10} ) +LLVM_MAX_SLOT=14 + +inherit flag-o-matic linux-info llvm multilib pam prefix python-single-r1 systemd tmpfiles + +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" + +SLOT=$(ver_cut 1) + +MY_PV=${PV/_/} +S="${WORKDIR}/${PN}-${MY_PV}" + +SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2" + +LICENSE="POSTGRESQL GPL-2" +DESCRIPTION="PostgreSQL RDBMS" +HOMEPAGE="https://www.postgresql.org/" + +IUSE="debug doc icu kerberos ldap llvm nls pam + perl python +readline selinux +server systemd ssl static-libs tcl + threads uuid xml zlib" + +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" + +CDEPEND=" +>=app-eselect/eselect-postgresql-2.0 +acct-group/postgres +acct-user/postgres +sys-apps/less +virtual/libintl +icu? ( dev-libs/icu:= ) +kerberos? ( virtual/krb5 ) +ldap? ( net-nds/openldap:= ) +llvm? ( + =dev-lang/perl-5.8:= ) +python? ( ${PYTHON_DEPS} ) +readline? ( sys-libs/readline:0= ) +server? ( systemd? ( sys-apps/systemd ) ) +ssl? ( >=dev-libs/openssl-0.9.6-r1:0= ) +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,musl} ) + +nest_usedep() { + local front back + while [[ ${#} -gt 1 ]]; do + front+="${1}? ( " + back+=" )" + shift + done + echo "${front}${1}${back}" +} + +CDEPEND+=" +uuid? ( + ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )} + $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid) +)" + +DEPEND="${CDEPEND} +sys-devel/bison +sys-devel/flex +nls? ( sys-devel/gettext ) +xml? ( virtual/pkgconfig ) +" + +RDEPEND="${CDEPEND} +selinux? ( sec-policy/selinux-postgresql ) +" + +pkg_setup() { + llvm_pkg_setup + + use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup + + use python && python-single-r1_pkg_setup +} + +src_prepare() { + # Set proper run directory + sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \ + -i src/include/pg_config_manual.h || die + + # Rely on $PATH being in the proper order so that the correct + # install program is used for modules utilizing PGXS in both + # hardened and non-hardened environments. (Bug #528786) + sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die + + use server || eapply "${FILESDIR}/${PN}-12.1-no-server.patch" + use server && eapply "${FILESDIR}/postgres-llvm14.patch" + + if use pam ; then + sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \ + -i src/backend/libpq/auth.c || \ + die 'PGSQL_PAM_SERVICE rename failed.' + fi + + eapply_user +} + +src_configure() { + case ${CHOST} in + *-darwin*|*-solaris*) + use nls && append-libs intl + ;; + esac + + export LDFLAGS_SL="${LDFLAGS}" + export LDFLAGS_EX="${LDFLAGS}" + + local PO="${EPREFIX}" + + local i uuid_config="" + if use uuid; then + for i in ${UTIL_LINUX_LIBC[@]}; do + use ${i} && uuid_config="--with-uuid=e2fs" + done + [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp" + fi + + econf \ + --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \ + --datadir="${PO}/usr/share/postgresql-${SLOT}" \ + --includedir="${PO}/usr/include/postgresql-${SLOT}" \ + --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \ + --sysconfdir="${PO}/etc/postgresql-${SLOT}" \ + --with-system-tzdata="${PO}/usr/share/zoneinfo" \ + $(use_enable !alpha spinlocks) \ + $(use_enable debug) \ + $(use_enable threads thread-safety) \ + $(use_with icu) \ + $(use_with kerberos gssapi) \ + $(use_with ldap) \ + $(use_with llvm) \ + $(use_with pam) \ + $(use_with perl) \ + $(use_with python) \ + $(use_with readline) \ + $(use_with ssl openssl) \ + $(usex server "$(use_with systemd)" '--without-systemd') \ + $(use_with tcl) \ + ${uuid_config} \ + $(use_with xml libxml) \ + $(use_with xml libxslt) \ + $(use_with zlib) \ + $(use_enable nls) +} + +src_compile() { + emake + emake -C contrib +} + +src_install() { + emake DESTDIR="${D}" install + emake DESTDIR="${D}" install -C contrib + + dodoc README HISTORY + + # man pages are already built, but if we have the target make them, + # they'll be generated from source before being installed so we + # manually install man pages. + # We use ${SLOT} instead of doman for postgresql.eselect + insinto /usr/share/postgresql-${SLOT}/man/ + doins -r doc/src/sgml/man{1,3,7} + if ! use server; then + # Remove man pages for non-existent binaries + serverman=( + initdb + pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby} + pg_{test_{fsync,timing},upgrade,waldump} + post{gres,master} + ) + for m in ${serverman[@]} ; do + rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1" + done + fi + docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7} + + # Create slot specific man pages + local bn f mansec slotted_name + for mansec in 1 3 7 ; do + local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}" + + mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir" + pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed" + + for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do + bn=$(basename "${f}") + slotted_name=${bn%.${mansec}}${SLOT}.${mansec} + case ${bn} in + TABLE.7|WITH.7) + echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name} + ;; + *) + echo ".so ${rel_manpath}/${bn}" > ${slotted_name} + ;; + esac + done + + popd > /dev/null + done + + insinto /etc/postgresql-${SLOT} + newins src/bin/psql/psqlrc.sample psqlrc + + # Don't delete libpg{port,common}.a (Bug #571046). They're always + # needed by extensions utilizing PGXS. + use static-libs || \ + find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \ + -delete + + # Make slot specific links to programs + local f bn + for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \ + -mindepth 1 -maxdepth 1) + do + bn=$(basename "${f}") + dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \ + "/usr/bin/${bn}${SLOT/.}" + done + + if use doc ; then + docinto html + dodoc doc/src/sgml/html/* + fi + + if use server; then + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} + + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT} + + if use systemd; then + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.service-9.6-r1" | \ + systemd_newunit - ${PN}-${SLOT}.service + newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir + newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf + fi + + use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session + + if use prefix ; then + keepdir /run/postgresql + fperms 1775 /run/postgresql + fi + fi +} + +pkg_postinst() { + use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf + 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 "https://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}" + + if [[ -n ${REPLACING_VERSIONS} ]] ; then + ewarn "If your system is using 'pg_stat_statements' and you are running a" + ewarn "version of PostgreSQL ${SLOT}, we advise that you execute" + ewarn "the following command after upgrading:" + ewarn + ewarn "ALTER EXTENSION pg_stat_statements UPDATE;" + fi + 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 " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html" + einfo " https://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 "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs" + mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR" + chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown" + 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 + if ! use systemd; then + einfo "The PostgreSQL server, by default, will log events to:" + einfo " ${DATA_DIR%/}/postmaster.log" + einfo + fi + 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}" + elif use systemd; then + einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL" + einfo "instead of 'pg_ctl'." + 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 +} diff --git a/dev-db/postgresql/postgresql-12.10.ebuild b/dev-db/postgresql/postgresql-12.10.ebuild deleted file mode 100644 index 852f5715923c..000000000000 --- a/dev-db/postgresql/postgresql-12.10.ebuild +++ /dev/null @@ -1,450 +0,0 @@ -# Copyright 1999-2022 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=7 - -PYTHON_COMPAT=( python3_{8,9,10} ) - -inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd tmpfiles - -KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" - -SLOT=$(ver_cut 1) - -MY_PV=${PV/_/} -S="${WORKDIR}/${PN}-${MY_PV}" - -SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2" - -LICENSE="POSTGRESQL GPL-2" -DESCRIPTION="PostgreSQL RDBMS" -HOMEPAGE="https://www.postgresql.org/" - -IUSE="debug doc icu kerberos ldap llvm nls pam - perl python +readline selinux +server systemd ssl static-libs tcl - threads uuid xml zlib" - -REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" - -CDEPEND=" ->=app-eselect/eselect-postgresql-2.0 -acct-group/postgres -acct-user/postgres -sys-apps/less -virtual/libintl -icu? ( dev-libs/icu:= ) -kerberos? ( virtual/krb5 ) -ldap? ( net-nds/openldap ) -llvm? ( - sys-devel/llvm:= - sys-devel/clang:= -) -pam? ( sys-libs/pam ) -perl? ( >=dev-lang/perl-5.8:= ) -python? ( ${PYTHON_DEPS} ) -readline? ( sys-libs/readline:0= ) -server? ( systemd? ( sys-apps/systemd ) ) -ssl? ( >=dev-libs/openssl-0.9.6-r1:0= ) -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,musl} ) - -nest_usedep() { - local front back - while [[ ${#} -gt 1 ]]; do - front+="${1}? ( " - back+=" )" - shift - done - echo "${front}${1}${back}" -} - -CDEPEND+=" -uuid? ( - ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )} - $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid) -)" - -DEPEND="${CDEPEND} -sys-devel/bison -sys-devel/flex -nls? ( sys-devel/gettext ) -xml? ( virtual/pkgconfig ) -" - -RDEPEND="${CDEPEND} -selinux? ( sec-policy/selinux-postgresql ) -" - -pkg_setup() { - use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup - - use python && python-single-r1_pkg_setup -} - -src_prepare() { - # Set proper run directory - sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \ - -i src/include/pg_config_manual.h || die - - # Rely on $PATH being in the proper order so that the correct - # install program is used for modules utilizing PGXS in both - # hardened and non-hardened environments. (Bug #528786) - sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die - - use server || eapply "${FILESDIR}/${PN}-12.1-no-server.patch" - - if use pam ; then - sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \ - -i src/backend/libpq/auth.c || \ - die 'PGSQL_PAM_SERVICE rename failed.' - fi - - eapply_user -} - -src_configure() { - case ${CHOST} in - *-darwin*|*-solaris*) - use nls && append-libs intl - ;; - esac - - export LDFLAGS_SL="${LDFLAGS}" - export LDFLAGS_EX="${LDFLAGS}" - - local PO="${EPREFIX}" - - local i uuid_config="" - if use uuid; then - for i in ${UTIL_LINUX_LIBC[@]}; do - use ${i} && uuid_config="--with-uuid=e2fs" - done - [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp" - fi - - econf \ - --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \ - --datadir="${PO}/usr/share/postgresql-${SLOT}" \ - --includedir="${PO}/usr/include/postgresql-${SLOT}" \ - --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \ - --sysconfdir="${PO}/etc/postgresql-${SLOT}" \ - --with-system-tzdata="${PO}/usr/share/zoneinfo" \ - $(use_enable !alpha spinlocks) \ - $(use_enable debug) \ - $(use_enable threads thread-safety) \ - $(use_with icu) \ - $(use_with kerberos gssapi) \ - $(use_with ldap) \ - $(use_with llvm) \ - $(use_with pam) \ - $(use_with perl) \ - $(use_with python) \ - $(use_with readline) \ - $(use_with ssl openssl) \ - $(usex server "$(use_with systemd)" '--without-systemd') \ - $(use_with tcl) \ - ${uuid_config} \ - $(use_with xml libxml) \ - $(use_with xml libxslt) \ - $(use_with zlib) \ - $(use_enable nls) -} - -src_compile() { - emake - emake -C contrib -} - -src_install() { - emake DESTDIR="${D}" install - emake DESTDIR="${D}" install -C contrib - - dodoc README HISTORY - - # man pages are already built, but if we have the target make them, - # they'll be generated from source before being installed so we - # manually install man pages. - # We use ${SLOT} instead of doman for postgresql.eselect - insinto /usr/share/postgresql-${SLOT}/man/ - doins -r doc/src/sgml/man{1,3,7} - if ! use server; then - # Remove man pages for non-existent binaries - serverman=( - initdb - pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby} - pg_{test_{fsync,timing},upgrade,waldump} - post{gres,master} - ) - for m in ${serverman[@]} ; do - rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1" - done - fi - docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7} - - # Create slot specific man pages - local bn f mansec slotted_name - for mansec in 1 3 7 ; do - local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}" - - mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir" - pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed" - - for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do - bn=$(basename "${f}") - slotted_name=${bn%.${mansec}}${SLOT}.${mansec} - case ${bn} in - TABLE.7|WITH.7) - echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name} - ;; - *) - echo ".so ${rel_manpath}/${bn}" > ${slotted_name} - ;; - esac - done - - popd > /dev/null - done - - insinto /etc/postgresql-${SLOT} - newins src/bin/psql/psqlrc.sample psqlrc - - # Don't delete libpg{port,common}.a (Bug #571046). They're always - # needed by extensions utilizing PGXS. - use static-libs || \ - find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \ - -delete - - # Make slot specific links to programs - local f bn - for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \ - -mindepth 1 -maxdepth 1) - do - bn=$(basename "${f}") - dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \ - "/usr/bin/${bn}${SLOT/.}" - done - - if use doc ; then - docinto html - dodoc doc/src/sgml/html/* - fi - - if use server; then - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} - - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT} - - if use systemd; then - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.service-9.6-r1" | \ - systemd_newunit - ${PN}-${SLOT}.service - newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir - newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf - fi - - use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session - - if use prefix ; then - keepdir /run/postgresql - fperms 1775 /run/postgresql - fi - fi -} - -pkg_postinst() { - use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf - 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 "https://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}" - - if [[ -n ${REPLACING_VERSIONS} ]] ; then - ewarn "If your system is using 'pg_stat_statements' and you are running a" - ewarn "version of PostgreSQL ${SLOT}, we advise that you execute" - ewarn "the following command after upgrading:" - ewarn - ewarn "ALTER EXTENSION pg_stat_statements UPDATE;" - fi - 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 " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html" - einfo " https://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 "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs" - mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR" - chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown" - 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 - if ! use systemd; then - einfo "The PostgreSQL server, by default, will log events to:" - einfo " ${DATA_DIR%/}/postmaster.log" - einfo - fi - 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}" - elif use systemd; then - einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL" - einfo "instead of 'pg_ctl'." - 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 -} diff --git a/dev-db/postgresql/postgresql-12.9-r1.ebuild b/dev-db/postgresql/postgresql-12.9-r1.ebuild new file mode 100644 index 000000000000..b7d45b34ed5f --- /dev/null +++ b/dev-db/postgresql/postgresql-12.9-r1.ebuild @@ -0,0 +1,454 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +PYTHON_COMPAT=( python3_{8,9,10} ) +LLVM_MAX_SLOT=14 + +inherit flag-o-matic linux-info llvm multilib pam prefix python-single-r1 systemd tmpfiles + +KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~mips ppc ppc64 ~s390 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" + +SLOT=$(ver_cut 1) + +MY_PV=${PV/_/} +S="${WORKDIR}/${PN}-${MY_PV}" + +SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2" + +LICENSE="POSTGRESQL GPL-2" +DESCRIPTION="PostgreSQL RDBMS" +HOMEPAGE="https://www.postgresql.org/" + +IUSE="debug doc icu kerberos ldap llvm nls pam + perl python +readline selinux +server systemd ssl static-libs tcl + threads uuid xml zlib" + +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" + +CDEPEND=" +>=app-eselect/eselect-postgresql-2.0 +acct-group/postgres +acct-user/postgres +sys-apps/less +virtual/libintl +icu? ( dev-libs/icu:= ) +kerberos? ( virtual/krb5 ) +ldap? ( net-nds/openldap:= ) +llvm? ( + =dev-lang/perl-5.8:= ) +python? ( ${PYTHON_DEPS} ) +readline? ( sys-libs/readline:0= ) +server? ( systemd? ( sys-apps/systemd ) ) +ssl? ( >=dev-libs/openssl-0.9.6-r1:0= ) +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,musl} ) + +nest_usedep() { + local front back + while [[ ${#} -gt 1 ]]; do + front+="${1}? ( " + back+=" )" + shift + done + echo "${front}${1}${back}" +} + +CDEPEND+=" +uuid? ( + ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )} + $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid) +)" + +DEPEND="${CDEPEND} +sys-devel/bison +sys-devel/flex +nls? ( sys-devel/gettext ) +xml? ( virtual/pkgconfig ) +" + +RDEPEND="${CDEPEND} +selinux? ( sec-policy/selinux-postgresql ) +" + +pkg_setup() { + llvm_pkg_setup + + use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup + + use python && python-single-r1_pkg_setup +} + +src_prepare() { + # Set proper run directory + sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \ + -i src/include/pg_config_manual.h || die + + # Rely on $PATH being in the proper order so that the correct + # install program is used for modules utilizing PGXS in both + # hardened and non-hardened environments. (Bug #528786) + sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die + + use server || eapply "${FILESDIR}/${PN}-12.1-no-server.patch" + use server && eapply "${FILESDIR}/postgres-llvm14.patch" + + if use pam ; then + sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \ + -i src/backend/libpq/auth.c || \ + die 'PGSQL_PAM_SERVICE rename failed.' + fi + + eapply_user +} + +src_configure() { + case ${CHOST} in + *-darwin*|*-solaris*) + use nls && append-libs intl + ;; + esac + + export LDFLAGS_SL="${LDFLAGS}" + export LDFLAGS_EX="${LDFLAGS}" + + local PO="${EPREFIX}" + + local i uuid_config="" + if use uuid; then + for i in ${UTIL_LINUX_LIBC[@]}; do + use ${i} && uuid_config="--with-uuid=e2fs" + done + [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp" + fi + + econf \ + --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \ + --datadir="${PO}/usr/share/postgresql-${SLOT}" \ + --includedir="${PO}/usr/include/postgresql-${SLOT}" \ + --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \ + --sysconfdir="${PO}/etc/postgresql-${SLOT}" \ + --with-system-tzdata="${PO}/usr/share/zoneinfo" \ + $(use_enable !alpha spinlocks) \ + $(use_enable debug) \ + $(use_enable threads thread-safety) \ + $(use_with icu) \ + $(use_with kerberos gssapi) \ + $(use_with ldap) \ + $(use_with llvm) \ + $(use_with pam) \ + $(use_with perl) \ + $(use_with python) \ + $(use_with readline) \ + $(use_with ssl openssl) \ + $(usex server "$(use_with systemd)" '--without-systemd') \ + $(use_with tcl) \ + ${uuid_config} \ + $(use_with xml libxml) \ + $(use_with xml libxslt) \ + $(use_with zlib) \ + $(use_enable nls) +} + +src_compile() { + emake + emake -C contrib +} + +src_install() { + emake DESTDIR="${D}" install + emake DESTDIR="${D}" install -C contrib + + dodoc README HISTORY + + # man pages are already built, but if we have the target make them, + # they'll be generated from source before being installed so we + # manually install man pages. + # We use ${SLOT} instead of doman for postgresql.eselect + insinto /usr/share/postgresql-${SLOT}/man/ + doins -r doc/src/sgml/man{1,3,7} + if ! use server; then + # Remove man pages for non-existent binaries + serverman=( + initdb + pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby} + pg_{test_{fsync,timing},upgrade,waldump} + post{gres,master} + ) + for m in ${serverman[@]} ; do + rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1" + done + fi + docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7} + + # Create slot specific man pages + local bn f mansec slotted_name + for mansec in 1 3 7 ; do + local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}" + + mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir" + pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed" + + for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do + bn=$(basename "${f}") + slotted_name=${bn%.${mansec}}${SLOT}.${mansec} + case ${bn} in + TABLE.7|WITH.7) + echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name} + ;; + *) + echo ".so ${rel_manpath}/${bn}" > ${slotted_name} + ;; + esac + done + + popd > /dev/null + done + + insinto /etc/postgresql-${SLOT} + newins src/bin/psql/psqlrc.sample psqlrc + + # Don't delete libpg{port,common}.a (Bug #571046). They're always + # needed by extensions utilizing PGXS. + use static-libs || \ + find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \ + -delete + + # Make slot specific links to programs + local f bn + for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \ + -mindepth 1 -maxdepth 1) + do + bn=$(basename "${f}") + dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \ + "/usr/bin/${bn}${SLOT/.}" + done + + if use doc ; then + docinto html + dodoc doc/src/sgml/html/* + fi + + if use server; then + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} + + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT} + + if use systemd; then + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.service-9.6-r1" | \ + systemd_newunit - ${PN}-${SLOT}.service + newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir + newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf + fi + + use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session + + if use prefix ; then + keepdir /run/postgresql + fperms 1775 /run/postgresql + fi + fi +} + +pkg_postinst() { + use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf + 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 "https://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}" + + if [[ -n ${REPLACING_VERSIONS} ]] ; then + ewarn "If your system is using 'pg_stat_statements' and you are running a" + ewarn "version of PostgreSQL ${SLOT}, we advise that you execute" + ewarn "the following command after upgrading:" + ewarn + ewarn "ALTER EXTENSION pg_stat_statements UPDATE;" + fi + 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 " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html" + einfo " https://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 "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs" + mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR" + chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown" + 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 + if ! use systemd; then + einfo "The PostgreSQL server, by default, will log events to:" + einfo " ${DATA_DIR%/}/postmaster.log" + einfo + fi + 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}" + elif use systemd; then + einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL" + einfo "instead of 'pg_ctl'." + 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 +} diff --git a/dev-db/postgresql/postgresql-12.9.ebuild b/dev-db/postgresql/postgresql-12.9.ebuild deleted file mode 100644 index f3837a3f0404..000000000000 --- a/dev-db/postgresql/postgresql-12.9.ebuild +++ /dev/null @@ -1,450 +0,0 @@ -# Copyright 1999-2022 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=7 - -PYTHON_COMPAT=( python3_{8,9,10} ) - -inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd tmpfiles - -KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~mips ppc ppc64 ~s390 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" - -SLOT=$(ver_cut 1) - -MY_PV=${PV/_/} -S="${WORKDIR}/${PN}-${MY_PV}" - -SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2" - -LICENSE="POSTGRESQL GPL-2" -DESCRIPTION="PostgreSQL RDBMS" -HOMEPAGE="https://www.postgresql.org/" - -IUSE="debug doc icu kerberos ldap llvm nls pam - perl python +readline selinux +server systemd ssl static-libs tcl - threads uuid xml zlib" - -REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" - -CDEPEND=" ->=app-eselect/eselect-postgresql-2.0 -acct-group/postgres -acct-user/postgres -sys-apps/less -virtual/libintl -icu? ( dev-libs/icu:= ) -kerberos? ( virtual/krb5 ) -ldap? ( net-nds/openldap ) -llvm? ( - sys-devel/llvm:= - sys-devel/clang:= -) -pam? ( sys-libs/pam ) -perl? ( >=dev-lang/perl-5.8:= ) -python? ( ${PYTHON_DEPS} ) -readline? ( sys-libs/readline:0= ) -server? ( systemd? ( sys-apps/systemd ) ) -ssl? ( >=dev-libs/openssl-0.9.6-r1:0= ) -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,musl} ) - -nest_usedep() { - local front back - while [[ ${#} -gt 1 ]]; do - front+="${1}? ( " - back+=" )" - shift - done - echo "${front}${1}${back}" -} - -CDEPEND+=" -uuid? ( - ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )} - $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid) -)" - -DEPEND="${CDEPEND} -sys-devel/bison -sys-devel/flex -nls? ( sys-devel/gettext ) -xml? ( virtual/pkgconfig ) -" - -RDEPEND="${CDEPEND} -selinux? ( sec-policy/selinux-postgresql ) -" - -pkg_setup() { - use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup - - use python && python-single-r1_pkg_setup -} - -src_prepare() { - # Set proper run directory - sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \ - -i src/include/pg_config_manual.h || die - - # Rely on $PATH being in the proper order so that the correct - # install program is used for modules utilizing PGXS in both - # hardened and non-hardened environments. (Bug #528786) - sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die - - use server || eapply "${FILESDIR}/${PN}-12.1-no-server.patch" - - if use pam ; then - sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \ - -i src/backend/libpq/auth.c || \ - die 'PGSQL_PAM_SERVICE rename failed.' - fi - - eapply_user -} - -src_configure() { - case ${CHOST} in - *-darwin*|*-solaris*) - use nls && append-libs intl - ;; - esac - - export LDFLAGS_SL="${LDFLAGS}" - export LDFLAGS_EX="${LDFLAGS}" - - local PO="${EPREFIX}" - - local i uuid_config="" - if use uuid; then - for i in ${UTIL_LINUX_LIBC[@]}; do - use ${i} && uuid_config="--with-uuid=e2fs" - done - [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp" - fi - - econf \ - --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \ - --datadir="${PO}/usr/share/postgresql-${SLOT}" \ - --includedir="${PO}/usr/include/postgresql-${SLOT}" \ - --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \ - --sysconfdir="${PO}/etc/postgresql-${SLOT}" \ - --with-system-tzdata="${PO}/usr/share/zoneinfo" \ - $(use_enable !alpha spinlocks) \ - $(use_enable debug) \ - $(use_enable threads thread-safety) \ - $(use_with icu) \ - $(use_with kerberos gssapi) \ - $(use_with ldap) \ - $(use_with llvm) \ - $(use_with pam) \ - $(use_with perl) \ - $(use_with python) \ - $(use_with readline) \ - $(use_with ssl openssl) \ - $(usex server "$(use_with systemd)" '--without-systemd') \ - $(use_with tcl) \ - ${uuid_config} \ - $(use_with xml libxml) \ - $(use_with xml libxslt) \ - $(use_with zlib) \ - $(use_enable nls) -} - -src_compile() { - emake - emake -C contrib -} - -src_install() { - emake DESTDIR="${D}" install - emake DESTDIR="${D}" install -C contrib - - dodoc README HISTORY - - # man pages are already built, but if we have the target make them, - # they'll be generated from source before being installed so we - # manually install man pages. - # We use ${SLOT} instead of doman for postgresql.eselect - insinto /usr/share/postgresql-${SLOT}/man/ - doins -r doc/src/sgml/man{1,3,7} - if ! use server; then - # Remove man pages for non-existent binaries - serverman=( - initdb - pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby} - pg_{test_{fsync,timing},upgrade,waldump} - post{gres,master} - ) - for m in ${serverman[@]} ; do - rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1" - done - fi - docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7} - - # Create slot specific man pages - local bn f mansec slotted_name - for mansec in 1 3 7 ; do - local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}" - - mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir" - pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed" - - for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do - bn=$(basename "${f}") - slotted_name=${bn%.${mansec}}${SLOT}.${mansec} - case ${bn} in - TABLE.7|WITH.7) - echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name} - ;; - *) - echo ".so ${rel_manpath}/${bn}" > ${slotted_name} - ;; - esac - done - - popd > /dev/null - done - - insinto /etc/postgresql-${SLOT} - newins src/bin/psql/psqlrc.sample psqlrc - - # Don't delete libpg{port,common}.a (Bug #571046). They're always - # needed by extensions utilizing PGXS. - use static-libs || \ - find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \ - -delete - - # Make slot specific links to programs - local f bn - for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \ - -mindepth 1 -maxdepth 1) - do - bn=$(basename "${f}") - dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \ - "/usr/bin/${bn}${SLOT/.}" - done - - if use doc ; then - docinto html - dodoc doc/src/sgml/html/* - fi - - if use server; then - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} - - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT} - - if use systemd; then - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.service-9.6-r1" | \ - systemd_newunit - ${PN}-${SLOT}.service - newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir - newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf - fi - - use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session - - if use prefix ; then - keepdir /run/postgresql - fperms 1775 /run/postgresql - fi - fi -} - -pkg_postinst() { - use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf - 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 "https://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}" - - if [[ -n ${REPLACING_VERSIONS} ]] ; then - ewarn "If your system is using 'pg_stat_statements' and you are running a" - ewarn "version of PostgreSQL ${SLOT}, we advise that you execute" - ewarn "the following command after upgrading:" - ewarn - ewarn "ALTER EXTENSION pg_stat_statements UPDATE;" - fi - 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 " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html" - einfo " https://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 "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs" - mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR" - chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown" - 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 - if ! use systemd; then - einfo "The PostgreSQL server, by default, will log events to:" - einfo " ${DATA_DIR%/}/postmaster.log" - einfo - fi - 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}" - elif use systemd; then - einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL" - einfo "instead of 'pg_ctl'." - 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 -} diff --git a/dev-db/postgresql/postgresql-13.5-r1.ebuild b/dev-db/postgresql/postgresql-13.5-r1.ebuild new file mode 100644 index 000000000000..d204a6930de0 --- /dev/null +++ b/dev-db/postgresql/postgresql-13.5-r1.ebuild @@ -0,0 +1,466 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +PYTHON_COMPAT=( python3_{8,9,10} ) +LLVM_MAX_SLOT=14 + +inherit flag-o-matic linux-info llvm multilib pam prefix python-single-r1 systemd tmpfiles + +KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" + +SLOT=$(ver_cut 1) + +MY_PV=${PV/_/} +S="${WORKDIR}/${PN}-${MY_PV}" + +SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2" + +LICENSE="POSTGRESQL GPL-2" +DESCRIPTION="PostgreSQL RDBMS" +HOMEPAGE="https://www.postgresql.org/" + +IUSE="debug doc icu kerberos ldap llvm nls pam + perl python +readline selinux +server systemd ssl static-libs tcl + threads uuid xml zlib" + +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" + +CDEPEND=" +>=app-eselect/eselect-postgresql-2.0 +acct-group/postgres +acct-user/postgres +sys-apps/less +virtual/libintl +icu? ( dev-libs/icu:= ) +kerberos? ( virtual/krb5 ) +ldap? ( net-nds/openldap:= ) +llvm? ( + =dev-lang/perl-5.8:= ) +python? ( ${PYTHON_DEPS} ) +readline? ( sys-libs/readline:0= ) +server? ( systemd? ( sys-apps/systemd ) ) +ssl? ( >=dev-libs/openssl-0.9.6-r1:0= ) +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,musl} ) + +nest_usedep() { + local front back + while [[ ${#} -gt 1 ]]; do + front+="${1}? ( " + back+=" )" + shift + done + echo "${front}${1}${back}" +} + +CDEPEND+=" +uuid? ( + ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )} + $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid) +)" + +DEPEND="${CDEPEND} +sys-devel/bison +sys-devel/flex +nls? ( sys-devel/gettext ) +xml? ( virtual/pkgconfig ) +" + +RDEPEND="${CDEPEND} +selinux? ( sec-policy/selinux-postgresql ) +" + +pkg_setup() { + llvm_pkg_setup + + use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup + + use python && python-single-r1_pkg_setup +} + +src_prepare() { + eapply "${FILESDIR}"/${PN}-13.3-riscv-spinlocks.patch + + # Set proper run directory + sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \ + -i src/include/pg_config_manual.h || die + + # Rely on $PATH being in the proper order so that the correct + # install program is used for modules utilizing PGXS in both + # hardened and non-hardened environments. (Bug #528786) + sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die + + use server || eapply "${FILESDIR}/${PN}-13_beta1-no-server.patch" + use server && eapply "${FILESDIR}/postgres-llvm14.patch" + + if use pam ; then + sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \ + -i src/backend/libpq/auth.c || \ + die 'PGSQL_PAM_SERVICE rename failed.' + fi + + eapply_user +} + +src_configure() { + case ${CHOST} in + *-darwin*|*-solaris*) + use nls && append-libs intl + ;; + esac + + export LDFLAGS_SL="${LDFLAGS}" + export LDFLAGS_EX="${LDFLAGS}" + + local PO="${EPREFIX}" + + local i uuid_config="" + if use uuid; then + for i in ${UTIL_LINUX_LIBC[@]}; do + use ${i} && uuid_config="--with-uuid=e2fs" + done + [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp" + fi + + local myconf="\ + --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \ + --datadir="${PO}/usr/share/postgresql-${SLOT}" \ + --includedir="${PO}/usr/include/postgresql-${SLOT}" \ + --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \ + --sysconfdir="${PO}/etc/postgresql-${SLOT}" \ + --with-system-tzdata="${PO}/usr/share/zoneinfo" \ + $(use_enable debug) \ + $(use_enable threads thread-safety) \ + $(use_with icu) \ + $(use_with kerberos gssapi) \ + $(use_with ldap) \ + $(use_with llvm) \ + $(use_with pam) \ + $(use_with perl) \ + $(use_with python) \ + $(use_with readline) \ + $(use_with ssl openssl) \ + $(usex server "$(use_with systemd)" '--without-systemd') \ + $(use_with tcl) \ + ${uuid_config} \ + $(use_with xml libxml) \ + $(use_with xml libxslt) \ + $(use_with zlib) \ + $(use_enable nls)" + if use alpha; then + myconf+=" --disable-spinlocks" + else + # Should be the default but just in case + myconf+=" --enable-spinlocks" + fi + econf ${myconf} +} + +src_compile() { + emake + emake -C contrib +} + +src_install() { + emake DESTDIR="${D}" install + emake DESTDIR="${D}" install -C contrib + + dodoc README HISTORY + + # man pages are already built, but if we have the target make them, + # they'll be generated from source before being installed so we + # manually install man pages. + # We use ${SLOT} instead of doman for postgresql.eselect + insinto /usr/share/postgresql-${SLOT}/man/ + doins -r doc/src/sgml/man{1,3,7} + if ! use server; then + # Remove man pages for non-existent binaries + serverman=( + initdb + pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby} + pg_{test_{fsync,timing},upgrade,waldump} + post{gres,master} + ) + for m in ${serverman[@]} ; do + rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1" + done + fi + docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7} + + # Create slot specific man pages + local bn f mansec slotted_name + for mansec in 1 3 7 ; do + local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}" + + mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir" + pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed" + + for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do + bn=$(basename "${f}") + slotted_name=${bn%.${mansec}}${SLOT}.${mansec} + case ${bn} in + TABLE.7|WITH.7) + echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name} + ;; + *) + echo ".so ${rel_manpath}/${bn}" > ${slotted_name} + ;; + esac + done + + popd > /dev/null + done + + insinto /etc/postgresql-${SLOT} + newins src/bin/psql/psqlrc.sample psqlrc + + # Don't delete libpg{port,common}.a (Bug #571046). They're always + # needed by extensions utilizing PGXS. + use static-libs || \ + find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \ + -delete + + # Make slot specific links to programs + local f bn + for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \ + -mindepth 1 -maxdepth 1) + do + bn=$(basename "${f}") + dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \ + "/usr/bin/${bn}${SLOT/.}" + done + + if use doc ; then + docinto html + dodoc doc/src/sgml/html/* + fi + + if use server; then + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} + + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT} + + if use systemd; then + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.service-9.6-r1" | \ + systemd_newunit - ${PN}-${SLOT}.service + newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir + newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf + fi + + use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session + + if use prefix ; then + keepdir /run/postgresql + fperms 1775 /run/postgresql + fi + fi +} + +pkg_postinst() { + use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf + 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 "https://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}" + + if [[ -n ${REPLACING_VERSIONS} ]] ; then + ewarn "If your system is using 'pg_stat_statements' and you are running a" + ewarn "version of PostgreSQL ${SLOT}, we advise that you execute" + ewarn "the following command after upgrading:" + ewarn + ewarn "ALTER EXTENSION pg_stat_statements UPDATE;" + fi + 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 " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html" + einfo " https://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 "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs" + mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR" + chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown" + 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 + if ! use systemd; then + einfo "The PostgreSQL server, by default, will log events to:" + einfo " ${DATA_DIR%/}/postmaster.log" + einfo + fi + 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}" + elif use systemd; then + einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL" + einfo "instead of 'pg_ctl'." + 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 + # Some ICU tests fail if LC_CTYPE and LC_COLLATE aren't the same. We set + # LC_CTYPE to be equal to LC_COLLATE since LC_COLLATE is set by Portage. + local old_ctype=${LC_CTYPE} + export LC_CTYPE=${LC_COLLATE} + emake check + export LC_CTYPE=${old_ctype} + 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 +} diff --git a/dev-db/postgresql/postgresql-13.5.ebuild b/dev-db/postgresql/postgresql-13.5.ebuild deleted file mode 100644 index 5f6ce9b239e3..000000000000 --- a/dev-db/postgresql/postgresql-13.5.ebuild +++ /dev/null @@ -1,462 +0,0 @@ -# Copyright 1999-2022 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=7 - -PYTHON_COMPAT=( python3_{8,9,10} ) - -inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd tmpfiles - -KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" - -SLOT=$(ver_cut 1) - -MY_PV=${PV/_/} -S="${WORKDIR}/${PN}-${MY_PV}" - -SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2" - -LICENSE="POSTGRESQL GPL-2" -DESCRIPTION="PostgreSQL RDBMS" -HOMEPAGE="https://www.postgresql.org/" - -IUSE="debug doc icu kerberos ldap llvm nls pam - perl python +readline selinux +server systemd ssl static-libs tcl - threads uuid xml zlib" - -REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" - -CDEPEND=" ->=app-eselect/eselect-postgresql-2.0 -acct-group/postgres -acct-user/postgres -sys-apps/less -virtual/libintl -icu? ( dev-libs/icu:= ) -kerberos? ( virtual/krb5 ) -ldap? ( net-nds/openldap ) -llvm? ( - sys-devel/llvm:= - sys-devel/clang:= -) -pam? ( sys-libs/pam ) -perl? ( >=dev-lang/perl-5.8:= ) -python? ( ${PYTHON_DEPS} ) -readline? ( sys-libs/readline:0= ) -server? ( systemd? ( sys-apps/systemd ) ) -ssl? ( >=dev-libs/openssl-0.9.6-r1:0= ) -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,musl} ) - -nest_usedep() { - local front back - while [[ ${#} -gt 1 ]]; do - front+="${1}? ( " - back+=" )" - shift - done - echo "${front}${1}${back}" -} - -CDEPEND+=" -uuid? ( - ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )} - $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid) -)" - -DEPEND="${CDEPEND} -sys-devel/bison -sys-devel/flex -nls? ( sys-devel/gettext ) -xml? ( virtual/pkgconfig ) -" - -RDEPEND="${CDEPEND} -selinux? ( sec-policy/selinux-postgresql ) -" - -pkg_setup() { - use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup - - use python && python-single-r1_pkg_setup -} - -src_prepare() { - eapply "${FILESDIR}"/${PN}-13.3-riscv-spinlocks.patch - - # Set proper run directory - sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \ - -i src/include/pg_config_manual.h || die - - # Rely on $PATH being in the proper order so that the correct - # install program is used for modules utilizing PGXS in both - # hardened and non-hardened environments. (Bug #528786) - sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die - - use server || eapply "${FILESDIR}/${PN}-13_beta1-no-server.patch" - - if use pam ; then - sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \ - -i src/backend/libpq/auth.c || \ - die 'PGSQL_PAM_SERVICE rename failed.' - fi - - eapply_user -} - -src_configure() { - case ${CHOST} in - *-darwin*|*-solaris*) - use nls && append-libs intl - ;; - esac - - export LDFLAGS_SL="${LDFLAGS}" - export LDFLAGS_EX="${LDFLAGS}" - - local PO="${EPREFIX}" - - local i uuid_config="" - if use uuid; then - for i in ${UTIL_LINUX_LIBC[@]}; do - use ${i} && uuid_config="--with-uuid=e2fs" - done - [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp" - fi - - local myconf="\ - --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \ - --datadir="${PO}/usr/share/postgresql-${SLOT}" \ - --includedir="${PO}/usr/include/postgresql-${SLOT}" \ - --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \ - --sysconfdir="${PO}/etc/postgresql-${SLOT}" \ - --with-system-tzdata="${PO}/usr/share/zoneinfo" \ - $(use_enable debug) \ - $(use_enable threads thread-safety) \ - $(use_with icu) \ - $(use_with kerberos gssapi) \ - $(use_with ldap) \ - $(use_with llvm) \ - $(use_with pam) \ - $(use_with perl) \ - $(use_with python) \ - $(use_with readline) \ - $(use_with ssl openssl) \ - $(usex server "$(use_with systemd)" '--without-systemd') \ - $(use_with tcl) \ - ${uuid_config} \ - $(use_with xml libxml) \ - $(use_with xml libxslt) \ - $(use_with zlib) \ - $(use_enable nls)" - if use alpha; then - myconf+=" --disable-spinlocks" - else - # Should be the default but just in case - myconf+=" --enable-spinlocks" - fi - econf ${myconf} -} - -src_compile() { - emake - emake -C contrib -} - -src_install() { - emake DESTDIR="${D}" install - emake DESTDIR="${D}" install -C contrib - - dodoc README HISTORY - - # man pages are already built, but if we have the target make them, - # they'll be generated from source before being installed so we - # manually install man pages. - # We use ${SLOT} instead of doman for postgresql.eselect - insinto /usr/share/postgresql-${SLOT}/man/ - doins -r doc/src/sgml/man{1,3,7} - if ! use server; then - # Remove man pages for non-existent binaries - serverman=( - initdb - pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby} - pg_{test_{fsync,timing},upgrade,waldump} - post{gres,master} - ) - for m in ${serverman[@]} ; do - rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1" - done - fi - docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7} - - # Create slot specific man pages - local bn f mansec slotted_name - for mansec in 1 3 7 ; do - local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}" - - mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir" - pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed" - - for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do - bn=$(basename "${f}") - slotted_name=${bn%.${mansec}}${SLOT}.${mansec} - case ${bn} in - TABLE.7|WITH.7) - echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name} - ;; - *) - echo ".so ${rel_manpath}/${bn}" > ${slotted_name} - ;; - esac - done - - popd > /dev/null - done - - insinto /etc/postgresql-${SLOT} - newins src/bin/psql/psqlrc.sample psqlrc - - # Don't delete libpg{port,common}.a (Bug #571046). They're always - # needed by extensions utilizing PGXS. - use static-libs || \ - find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \ - -delete - - # Make slot specific links to programs - local f bn - for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \ - -mindepth 1 -maxdepth 1) - do - bn=$(basename "${f}") - dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \ - "/usr/bin/${bn}${SLOT/.}" - done - - if use doc ; then - docinto html - dodoc doc/src/sgml/html/* - fi - - if use server; then - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} - - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT} - - if use systemd; then - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.service-9.6-r1" | \ - systemd_newunit - ${PN}-${SLOT}.service - newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir - newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf - fi - - use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session - - if use prefix ; then - keepdir /run/postgresql - fperms 1775 /run/postgresql - fi - fi -} - -pkg_postinst() { - use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf - 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 "https://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}" - - if [[ -n ${REPLACING_VERSIONS} ]] ; then - ewarn "If your system is using 'pg_stat_statements' and you are running a" - ewarn "version of PostgreSQL ${SLOT}, we advise that you execute" - ewarn "the following command after upgrading:" - ewarn - ewarn "ALTER EXTENSION pg_stat_statements UPDATE;" - fi - 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 " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html" - einfo " https://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 "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs" - mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR" - chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown" - 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 - if ! use systemd; then - einfo "The PostgreSQL server, by default, will log events to:" - einfo " ${DATA_DIR%/}/postmaster.log" - einfo - fi - 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}" - elif use systemd; then - einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL" - einfo "instead of 'pg_ctl'." - 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 - # Some ICU tests fail if LC_CTYPE and LC_COLLATE aren't the same. We set - # LC_CTYPE to be equal to LC_COLLATE since LC_COLLATE is set by Portage. - local old_ctype=${LC_CTYPE} - export LC_CTYPE=${LC_COLLATE} - emake check - export LC_CTYPE=${old_ctype} - 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 -} diff --git a/dev-db/postgresql/postgresql-13.6-r2.ebuild b/dev-db/postgresql/postgresql-13.6-r2.ebuild new file mode 100644 index 000000000000..7c89241ebf32 --- /dev/null +++ b/dev-db/postgresql/postgresql-13.6-r2.ebuild @@ -0,0 +1,466 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +PYTHON_COMPAT=( python3_{8,9,10} ) +LLVM_MAX_SLOT=14 + +inherit flag-o-matic linux-info llvm multilib pam prefix python-single-r1 systemd tmpfiles + +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" + +SLOT=$(ver_cut 1) + +MY_PV=${PV/_/} +S="${WORKDIR}/${PN}-${MY_PV}" + +SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2" + +LICENSE="POSTGRESQL GPL-2" +DESCRIPTION="PostgreSQL RDBMS" +HOMEPAGE="https://www.postgresql.org/" + +IUSE="debug doc icu kerberos ldap llvm nls pam + perl python +readline selinux +server systemd ssl static-libs tcl + threads uuid xml zlib" + +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" + +CDEPEND=" +>=app-eselect/eselect-postgresql-2.0 +acct-group/postgres +acct-user/postgres +sys-apps/less +virtual/libintl +icu? ( dev-libs/icu:= ) +kerberos? ( virtual/krb5 ) +ldap? ( net-nds/openldap:= ) +llvm? ( + =dev-lang/perl-5.8:= ) +python? ( ${PYTHON_DEPS} ) +readline? ( sys-libs/readline:0= ) +server? ( systemd? ( sys-apps/systemd ) ) +ssl? ( >=dev-libs/openssl-0.9.6-r1:0= ) +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,musl} ) + +nest_usedep() { + local front back + while [[ ${#} -gt 1 ]]; do + front+="${1}? ( " + back+=" )" + shift + done + echo "${front}${1}${back}" +} + +CDEPEND+=" +uuid? ( + ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )} + $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid) +)" + +DEPEND="${CDEPEND} +sys-devel/bison +sys-devel/flex +nls? ( sys-devel/gettext ) +xml? ( virtual/pkgconfig ) +" + +RDEPEND="${CDEPEND} +selinux? ( sec-policy/selinux-postgresql ) +" + +pkg_setup() { + llvm_pkg_setup + + use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup + + use python && python-single-r1_pkg_setup +} + +src_prepare() { + eapply "${FILESDIR}"/${PN}-13.3-riscv-spinlocks.patch + + # Set proper run directory + sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \ + -i src/include/pg_config_manual.h || die + + # Rely on $PATH being in the proper order so that the correct + # install program is used for modules utilizing PGXS in both + # hardened and non-hardened environments. (Bug #528786) + sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die + + use server || eapply "${FILESDIR}/${PN}-13_beta1-no-server.patch" + use server && eapply "${FILESDIR}/postgres-llvm14.patch" + + if use pam ; then + sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \ + -i src/backend/libpq/auth.c || \ + die 'PGSQL_PAM_SERVICE rename failed.' + fi + + eapply_user +} + +src_configure() { + case ${CHOST} in + *-darwin*|*-solaris*) + use nls && append-libs intl + ;; + esac + + export LDFLAGS_SL="${LDFLAGS}" + export LDFLAGS_EX="${LDFLAGS}" + + local PO="${EPREFIX}" + + local i uuid_config="" + if use uuid; then + for i in ${UTIL_LINUX_LIBC[@]}; do + use ${i} && uuid_config="--with-uuid=e2fs" + done + [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp" + fi + + local myconf="\ + --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \ + --datadir="${PO}/usr/share/postgresql-${SLOT}" \ + --includedir="${PO}/usr/include/postgresql-${SLOT}" \ + --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \ + --sysconfdir="${PO}/etc/postgresql-${SLOT}" \ + --with-system-tzdata="${PO}/usr/share/zoneinfo" \ + $(use_enable debug) \ + $(use_enable threads thread-safety) \ + $(use_with icu) \ + $(use_with kerberos gssapi) \ + $(use_with ldap) \ + $(use_with llvm) \ + $(use_with pam) \ + $(use_with perl) \ + $(use_with python) \ + $(use_with readline) \ + $(use_with ssl openssl) \ + $(usex server "$(use_with systemd)" '--without-systemd') \ + $(use_with tcl) \ + ${uuid_config} \ + $(use_with xml libxml) \ + $(use_with xml libxslt) \ + $(use_with zlib) \ + $(use_enable nls)" + if use alpha; then + myconf+=" --disable-spinlocks" + else + # Should be the default but just in case + myconf+=" --enable-spinlocks" + fi + econf ${myconf} +} + +src_compile() { + emake + emake -C contrib +} + +src_install() { + emake DESTDIR="${D}" install + emake DESTDIR="${D}" install -C contrib + + dodoc README HISTORY + + # man pages are already built, but if we have the target make them, + # they'll be generated from source before being installed so we + # manually install man pages. + # We use ${SLOT} instead of doman for postgresql.eselect + insinto /usr/share/postgresql-${SLOT}/man/ + doins -r doc/src/sgml/man{1,3,7} + if ! use server; then + # Remove man pages for non-existent binaries + serverman=( + initdb + pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby} + pg_{test_{fsync,timing},upgrade,waldump} + post{gres,master} + ) + for m in ${serverman[@]} ; do + rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1" + done + fi + docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7} + + # Create slot specific man pages + local bn f mansec slotted_name + for mansec in 1 3 7 ; do + local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}" + + mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir" + pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed" + + for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do + bn=$(basename "${f}") + slotted_name=${bn%.${mansec}}${SLOT}.${mansec} + case ${bn} in + TABLE.7|WITH.7) + echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name} + ;; + *) + echo ".so ${rel_manpath}/${bn}" > ${slotted_name} + ;; + esac + done + + popd > /dev/null + done + + insinto /etc/postgresql-${SLOT} + newins src/bin/psql/psqlrc.sample psqlrc + + # Don't delete libpg{port,common}.a (Bug #571046). They're always + # needed by extensions utilizing PGXS. + use static-libs || \ + find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \ + -delete + + # Make slot specific links to programs + local f bn + for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \ + -mindepth 1 -maxdepth 1) + do + bn=$(basename "${f}") + dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \ + "/usr/bin/${bn}${SLOT/.}" + done + + if use doc ; then + docinto html + dodoc doc/src/sgml/html/* + fi + + if use server; then + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} + + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT} + + if use systemd; then + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.service-9.6-r1" | \ + systemd_newunit - ${PN}-${SLOT}.service + newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir + newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf + fi + + use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session + + if use prefix ; then + keepdir /run/postgresql + fperms 1775 /run/postgresql + fi + fi +} + +pkg_postinst() { + use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf + 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 "https://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}" + + if [[ -n ${REPLACING_VERSIONS} ]] ; then + ewarn "If your system is using 'pg_stat_statements' and you are running a" + ewarn "version of PostgreSQL ${SLOT}, we advise that you execute" + ewarn "the following command after upgrading:" + ewarn + ewarn "ALTER EXTENSION pg_stat_statements UPDATE;" + fi + 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 " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html" + einfo " https://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 "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs" + mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR" + chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown" + 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 + if ! use systemd; then + einfo "The PostgreSQL server, by default, will log events to:" + einfo " ${DATA_DIR%/}/postmaster.log" + einfo + fi + 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}" + elif use systemd; then + einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL" + einfo "instead of 'pg_ctl'." + 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 + # Some ICU tests fail if LC_CTYPE and LC_COLLATE aren't the same. We set + # LC_CTYPE to be equal to LC_COLLATE since LC_COLLATE is set by Portage. + local old_ctype=${LC_CTYPE} + export LC_CTYPE=${LC_COLLATE} + emake check + export LC_CTYPE=${old_ctype} + 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 +} diff --git a/dev-db/postgresql/postgresql-13.6.ebuild b/dev-db/postgresql/postgresql-13.6.ebuild deleted file mode 100644 index 213350b0e72e..000000000000 --- a/dev-db/postgresql/postgresql-13.6.ebuild +++ /dev/null @@ -1,462 +0,0 @@ -# Copyright 1999-2022 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=7 - -PYTHON_COMPAT=( python3_{8,9,10} ) - -inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd tmpfiles - -KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" - -SLOT=$(ver_cut 1) - -MY_PV=${PV/_/} -S="${WORKDIR}/${PN}-${MY_PV}" - -SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2" - -LICENSE="POSTGRESQL GPL-2" -DESCRIPTION="PostgreSQL RDBMS" -HOMEPAGE="https://www.postgresql.org/" - -IUSE="debug doc icu kerberos ldap llvm nls pam - perl python +readline selinux +server systemd ssl static-libs tcl - threads uuid xml zlib" - -REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" - -CDEPEND=" ->=app-eselect/eselect-postgresql-2.0 -acct-group/postgres -acct-user/postgres -sys-apps/less -virtual/libintl -icu? ( dev-libs/icu:= ) -kerberos? ( virtual/krb5 ) -ldap? ( net-nds/openldap ) -llvm? ( - sys-devel/llvm:= - sys-devel/clang:= -) -pam? ( sys-libs/pam ) -perl? ( >=dev-lang/perl-5.8:= ) -python? ( ${PYTHON_DEPS} ) -readline? ( sys-libs/readline:0= ) -server? ( systemd? ( sys-apps/systemd ) ) -ssl? ( >=dev-libs/openssl-0.9.6-r1:0= ) -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,musl} ) - -nest_usedep() { - local front back - while [[ ${#} -gt 1 ]]; do - front+="${1}? ( " - back+=" )" - shift - done - echo "${front}${1}${back}" -} - -CDEPEND+=" -uuid? ( - ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )} - $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid) -)" - -DEPEND="${CDEPEND} -sys-devel/bison -sys-devel/flex -nls? ( sys-devel/gettext ) -xml? ( virtual/pkgconfig ) -" - -RDEPEND="${CDEPEND} -selinux? ( sec-policy/selinux-postgresql ) -" - -pkg_setup() { - use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup - - use python && python-single-r1_pkg_setup -} - -src_prepare() { - eapply "${FILESDIR}"/${PN}-13.3-riscv-spinlocks.patch - - # Set proper run directory - sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \ - -i src/include/pg_config_manual.h || die - - # Rely on $PATH being in the proper order so that the correct - # install program is used for modules utilizing PGXS in both - # hardened and non-hardened environments. (Bug #528786) - sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die - - use server || eapply "${FILESDIR}/${PN}-13_beta1-no-server.patch" - - if use pam ; then - sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \ - -i src/backend/libpq/auth.c || \ - die 'PGSQL_PAM_SERVICE rename failed.' - fi - - eapply_user -} - -src_configure() { - case ${CHOST} in - *-darwin*|*-solaris*) - use nls && append-libs intl - ;; - esac - - export LDFLAGS_SL="${LDFLAGS}" - export LDFLAGS_EX="${LDFLAGS}" - - local PO="${EPREFIX}" - - local i uuid_config="" - if use uuid; then - for i in ${UTIL_LINUX_LIBC[@]}; do - use ${i} && uuid_config="--with-uuid=e2fs" - done - [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp" - fi - - local myconf="\ - --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \ - --datadir="${PO}/usr/share/postgresql-${SLOT}" \ - --includedir="${PO}/usr/include/postgresql-${SLOT}" \ - --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \ - --sysconfdir="${PO}/etc/postgresql-${SLOT}" \ - --with-system-tzdata="${PO}/usr/share/zoneinfo" \ - $(use_enable debug) \ - $(use_enable threads thread-safety) \ - $(use_with icu) \ - $(use_with kerberos gssapi) \ - $(use_with ldap) \ - $(use_with llvm) \ - $(use_with pam) \ - $(use_with perl) \ - $(use_with python) \ - $(use_with readline) \ - $(use_with ssl openssl) \ - $(usex server "$(use_with systemd)" '--without-systemd') \ - $(use_with tcl) \ - ${uuid_config} \ - $(use_with xml libxml) \ - $(use_with xml libxslt) \ - $(use_with zlib) \ - $(use_enable nls)" - if use alpha; then - myconf+=" --disable-spinlocks" - else - # Should be the default but just in case - myconf+=" --enable-spinlocks" - fi - econf ${myconf} -} - -src_compile() { - emake - emake -C contrib -} - -src_install() { - emake DESTDIR="${D}" install - emake DESTDIR="${D}" install -C contrib - - dodoc README HISTORY - - # man pages are already built, but if we have the target make them, - # they'll be generated from source before being installed so we - # manually install man pages. - # We use ${SLOT} instead of doman for postgresql.eselect - insinto /usr/share/postgresql-${SLOT}/man/ - doins -r doc/src/sgml/man{1,3,7} - if ! use server; then - # Remove man pages for non-existent binaries - serverman=( - initdb - pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby} - pg_{test_{fsync,timing},upgrade,waldump} - post{gres,master} - ) - for m in ${serverman[@]} ; do - rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1" - done - fi - docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7} - - # Create slot specific man pages - local bn f mansec slotted_name - for mansec in 1 3 7 ; do - local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}" - - mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir" - pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed" - - for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do - bn=$(basename "${f}") - slotted_name=${bn%.${mansec}}${SLOT}.${mansec} - case ${bn} in - TABLE.7|WITH.7) - echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name} - ;; - *) - echo ".so ${rel_manpath}/${bn}" > ${slotted_name} - ;; - esac - done - - popd > /dev/null - done - - insinto /etc/postgresql-${SLOT} - newins src/bin/psql/psqlrc.sample psqlrc - - # Don't delete libpg{port,common}.a (Bug #571046). They're always - # needed by extensions utilizing PGXS. - use static-libs || \ - find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \ - -delete - - # Make slot specific links to programs - local f bn - for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \ - -mindepth 1 -maxdepth 1) - do - bn=$(basename "${f}") - dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \ - "/usr/bin/${bn}${SLOT/.}" - done - - if use doc ; then - docinto html - dodoc doc/src/sgml/html/* - fi - - if use server; then - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} - - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT} - - if use systemd; then - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.service-9.6-r1" | \ - systemd_newunit - ${PN}-${SLOT}.service - newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir - newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf - fi - - use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session - - if use prefix ; then - keepdir /run/postgresql - fperms 1775 /run/postgresql - fi - fi -} - -pkg_postinst() { - use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf - 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 "https://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}" - - if [[ -n ${REPLACING_VERSIONS} ]] ; then - ewarn "If your system is using 'pg_stat_statements' and you are running a" - ewarn "version of PostgreSQL ${SLOT}, we advise that you execute" - ewarn "the following command after upgrading:" - ewarn - ewarn "ALTER EXTENSION pg_stat_statements UPDATE;" - fi - 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 " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html" - einfo " https://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 "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs" - mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR" - chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown" - 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 - if ! use systemd; then - einfo "The PostgreSQL server, by default, will log events to:" - einfo " ${DATA_DIR%/}/postmaster.log" - einfo - fi - 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}" - elif use systemd; then - einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL" - einfo "instead of 'pg_ctl'." - 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 - # Some ICU tests fail if LC_CTYPE and LC_COLLATE aren't the same. We set - # LC_CTYPE to be equal to LC_COLLATE since LC_COLLATE is set by Portage. - local old_ctype=${LC_CTYPE} - export LC_CTYPE=${LC_COLLATE} - emake check - export LC_CTYPE=${old_ctype} - 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 -} diff --git a/dev-db/postgresql/postgresql-14.1-r1.ebuild b/dev-db/postgresql/postgresql-14.1-r1.ebuild new file mode 100644 index 000000000000..db0770f6cb90 --- /dev/null +++ b/dev-db/postgresql/postgresql-14.1-r1.ebuild @@ -0,0 +1,466 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +PYTHON_COMPAT=( python3_{8,9,10} ) +LLVM_MAX_SLOT=14 + +inherit flag-o-matic linux-info llvm multilib pam prefix python-single-r1 systemd tmpfiles + +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" + +SLOT=$(ver_cut 1) + +MY_PV=${PV/_/} +S="${WORKDIR}/${PN}-${MY_PV}" + +SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2" + +LICENSE="POSTGRESQL GPL-2" +DESCRIPTION="PostgreSQL RDBMS" +HOMEPAGE="https://www.postgresql.org/" + +IUSE="debug doc icu kerberos ldap llvm lz4 nls pam + perl python +readline selinux +server systemd ssl static-libs tcl + threads uuid xml zlib" + +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" + +CDEPEND=" +>=app-eselect/eselect-postgresql-2.0 +acct-group/postgres +acct-user/postgres +sys-apps/less +virtual/libintl +icu? ( dev-libs/icu:= ) +kerberos? ( virtual/krb5 ) +ldap? ( net-nds/openldap:= ) +llvm? ( + =dev-lang/perl-5.8:= ) +python? ( ${PYTHON_DEPS} ) +readline? ( sys-libs/readline:0= ) +server? ( systemd? ( sys-apps/systemd ) ) +ssl? ( >=dev-libs/openssl-0.9.6-r1:0= ) +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,musl} ) + +nest_usedep() { + local front back + while [[ ${#} -gt 1 ]]; do + front+="${1}? ( " + back+=" )" + shift + done + echo "${front}${1}${back}" +} + +CDEPEND+=" +uuid? ( + ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )} + $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid) +)" + +DEPEND="${CDEPEND} +sys-devel/bison +sys-devel/flex +nls? ( sys-devel/gettext ) +xml? ( virtual/pkgconfig ) +" + +RDEPEND="${CDEPEND} +selinux? ( sec-policy/selinux-postgresql ) +" + +pkg_setup() { + llvm_pkg_setup + + use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup + + use python && python-single-r1_pkg_setup +} + +src_prepare() { + # Set proper run directory + sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \ + -i src/include/pg_config_manual.h || die + + # Rely on $PATH being in the proper order so that the correct + # install program is used for modules utilizing PGXS in both + # hardened and non-hardened environments. (Bug #528786) + sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die + + use server || eapply "${FILESDIR}/${PN}-14_rc1-no-server.patch" + use server && eapply "${FILESDIR}/postgres-llvm14.patch" + + if use pam ; then + sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \ + -i src/backend/libpq/auth.c || \ + die 'PGSQL_PAM_SERVICE rename failed.' + fi + + eapply_user +} + +src_configure() { + case ${CHOST} in + *-darwin*|*-solaris*) + use nls && append-libs intl + ;; + esac + + export LDFLAGS_SL="${LDFLAGS}" + export LDFLAGS_EX="${LDFLAGS}" + + local PO="${EPREFIX}" + + local i uuid_config="" + if use uuid; then + for i in ${UTIL_LINUX_LIBC[@]}; do + use ${i} && uuid_config="--with-uuid=e2fs" + done + [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp" + fi + + local myconf="\ + --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \ + --datadir="${PO}/usr/share/postgresql-${SLOT}" \ + --includedir="${PO}/usr/include/postgresql-${SLOT}" \ + --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \ + --sysconfdir="${PO}/etc/postgresql-${SLOT}" \ + --with-system-tzdata="${PO}/usr/share/zoneinfo" \ + $(use_enable debug) \ + $(use_enable threads thread-safety) \ + $(use_with icu) \ + $(use_with kerberos gssapi) \ + $(use_with ldap) \ + $(use_with llvm) \ + $(use_with lz4) \ + $(use_with pam) \ + $(use_with perl) \ + $(use_with python) \ + $(use_with readline) \ + $(use_with ssl openssl) \ + $(usex server "$(use_with systemd)" '--without-systemd') \ + $(use_with tcl) \ + ${uuid_config} \ + $(use_with xml libxml) \ + $(use_with xml libxslt) \ + $(use_with zlib) \ + $(use_enable nls)" + if use alpha; then + myconf+=" --disable-spinlocks" + else + # Should be the default but just in case + myconf+=" --enable-spinlocks" + fi + econf ${myconf} +} + +src_compile() { + emake + emake -C contrib +} + +src_install() { + emake DESTDIR="${D}" install + emake DESTDIR="${D}" install -C contrib + + dodoc README HISTORY + + # man pages are already built, but if we have the target make them, + # they'll be generated from source before being installed so we + # manually install man pages. + # We use ${SLOT} instead of doman for postgresql.eselect + insinto /usr/share/postgresql-${SLOT}/man/ + doins -r doc/src/sgml/man{1,3,7} + if ! use server; then + # Remove man pages for non-existent binaries + serverman=( + initdb + pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby} + pg_{test_{fsync,timing},upgrade,waldump} + post{gres,master} + ) + for m in ${serverman[@]} ; do + rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1" + done + fi + docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7} + + # Create slot specific man pages + local bn f mansec slotted_name + for mansec in 1 3 7 ; do + local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}" + + mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir" + pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed" + + for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do + bn=$(basename "${f}") + slotted_name=${bn%.${mansec}}${SLOT}.${mansec} + case ${bn} in + TABLE.7|WITH.7) + echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name} + ;; + *) + echo ".so ${rel_manpath}/${bn}" > ${slotted_name} + ;; + esac + done + + popd > /dev/null + done + + insinto /etc/postgresql-${SLOT} + newins src/bin/psql/psqlrc.sample psqlrc + + # Don't delete libpg{port,common}.a (Bug #571046). They're always + # needed by extensions utilizing PGXS. + use static-libs || \ + find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \ + -delete + + # Make slot specific links to programs + local f bn + for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \ + -mindepth 1 -maxdepth 1) + do + bn=$(basename "${f}") + dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \ + "/usr/bin/${bn}${SLOT/.}" + done + + if use doc ; then + docinto html + dodoc doc/src/sgml/html/* + fi + + if use server; then + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} + + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT} + + if use systemd; then + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.service-9.6-r1" | \ + systemd_newunit - ${PN}-${SLOT}.service + newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir + newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf + fi + + use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session + + if use prefix ; then + keepdir /run/postgresql + fperms 1775 /run/postgresql + fi + fi +} + +pkg_postinst() { + use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf + 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 "https://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}" + + if [[ -n ${REPLACING_VERSIONS} ]] ; then + ewarn "If your system is using 'pg_stat_statements' and you are running a" + ewarn "version of PostgreSQL ${SLOT}, we advise that you execute" + ewarn "the following command after upgrading:" + ewarn + ewarn "ALTER EXTENSION pg_stat_statements UPDATE;" + fi + 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 " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html" + einfo " https://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 "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs" + mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR" + chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown" + 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 + if ! use systemd; then + einfo "The PostgreSQL server, by default, will log events to:" + einfo " ${DATA_DIR%/}/postmaster.log" + einfo + fi + 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}" + elif use systemd; then + einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL" + einfo "instead of 'pg_ctl'." + 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 + # Some ICU tests fail if LC_CTYPE and LC_COLLATE aren't the same. We set + # LC_CTYPE to be equal to LC_COLLATE since LC_COLLATE is set by Portage. + local old_ctype=${LC_CTYPE} + export LC_CTYPE=${LC_COLLATE} + emake check + export LC_CTYPE=${old_ctype} + 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 +} diff --git a/dev-db/postgresql/postgresql-14.1.ebuild b/dev-db/postgresql/postgresql-14.1.ebuild deleted file mode 100644 index 5dff65601bf4..000000000000 --- a/dev-db/postgresql/postgresql-14.1.ebuild +++ /dev/null @@ -1,462 +0,0 @@ -# Copyright 1999-2022 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=7 - -PYTHON_COMPAT=( python3_{8,9,10} ) - -inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd tmpfiles - -KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" - -SLOT=$(ver_cut 1) - -MY_PV=${PV/_/} -S="${WORKDIR}/${PN}-${MY_PV}" - -SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2" - -LICENSE="POSTGRESQL GPL-2" -DESCRIPTION="PostgreSQL RDBMS" -HOMEPAGE="https://www.postgresql.org/" - -IUSE="debug doc icu kerberos ldap llvm lz4 nls pam - perl python +readline selinux +server systemd ssl static-libs tcl - threads uuid xml zlib" - -REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" - -CDEPEND=" ->=app-eselect/eselect-postgresql-2.0 -acct-group/postgres -acct-user/postgres -sys-apps/less -virtual/libintl -icu? ( dev-libs/icu:= ) -kerberos? ( virtual/krb5 ) -ldap? ( net-nds/openldap ) -llvm? ( - sys-devel/llvm:= - sys-devel/clang:= -) -lz4? ( app-arch/lz4 ) -pam? ( sys-libs/pam ) -perl? ( >=dev-lang/perl-5.8:= ) -python? ( ${PYTHON_DEPS} ) -readline? ( sys-libs/readline:0= ) -server? ( systemd? ( sys-apps/systemd ) ) -ssl? ( >=dev-libs/openssl-0.9.6-r1:0= ) -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,musl} ) - -nest_usedep() { - local front back - while [[ ${#} -gt 1 ]]; do - front+="${1}? ( " - back+=" )" - shift - done - echo "${front}${1}${back}" -} - -CDEPEND+=" -uuid? ( - ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )} - $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid) -)" - -DEPEND="${CDEPEND} -sys-devel/bison -sys-devel/flex -nls? ( sys-devel/gettext ) -xml? ( virtual/pkgconfig ) -" - -RDEPEND="${CDEPEND} -selinux? ( sec-policy/selinux-postgresql ) -" - -pkg_setup() { - use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup - - use python && python-single-r1_pkg_setup -} - -src_prepare() { - # Set proper run directory - sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \ - -i src/include/pg_config_manual.h || die - - # Rely on $PATH being in the proper order so that the correct - # install program is used for modules utilizing PGXS in both - # hardened and non-hardened environments. (Bug #528786) - sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die - - use server || eapply "${FILESDIR}/${PN}-14_rc1-no-server.patch" - - if use pam ; then - sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \ - -i src/backend/libpq/auth.c || \ - die 'PGSQL_PAM_SERVICE rename failed.' - fi - - eapply_user -} - -src_configure() { - case ${CHOST} in - *-darwin*|*-solaris*) - use nls && append-libs intl - ;; - esac - - export LDFLAGS_SL="${LDFLAGS}" - export LDFLAGS_EX="${LDFLAGS}" - - local PO="${EPREFIX}" - - local i uuid_config="" - if use uuid; then - for i in ${UTIL_LINUX_LIBC[@]}; do - use ${i} && uuid_config="--with-uuid=e2fs" - done - [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp" - fi - - local myconf="\ - --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \ - --datadir="${PO}/usr/share/postgresql-${SLOT}" \ - --includedir="${PO}/usr/include/postgresql-${SLOT}" \ - --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \ - --sysconfdir="${PO}/etc/postgresql-${SLOT}" \ - --with-system-tzdata="${PO}/usr/share/zoneinfo" \ - $(use_enable debug) \ - $(use_enable threads thread-safety) \ - $(use_with icu) \ - $(use_with kerberos gssapi) \ - $(use_with ldap) \ - $(use_with llvm) \ - $(use_with lz4) \ - $(use_with pam) \ - $(use_with perl) \ - $(use_with python) \ - $(use_with readline) \ - $(use_with ssl openssl) \ - $(usex server "$(use_with systemd)" '--without-systemd') \ - $(use_with tcl) \ - ${uuid_config} \ - $(use_with xml libxml) \ - $(use_with xml libxslt) \ - $(use_with zlib) \ - $(use_enable nls)" - if use alpha; then - myconf+=" --disable-spinlocks" - else - # Should be the default but just in case - myconf+=" --enable-spinlocks" - fi - econf ${myconf} -} - -src_compile() { - emake - emake -C contrib -} - -src_install() { - emake DESTDIR="${D}" install - emake DESTDIR="${D}" install -C contrib - - dodoc README HISTORY - - # man pages are already built, but if we have the target make them, - # they'll be generated from source before being installed so we - # manually install man pages. - # We use ${SLOT} instead of doman for postgresql.eselect - insinto /usr/share/postgresql-${SLOT}/man/ - doins -r doc/src/sgml/man{1,3,7} - if ! use server; then - # Remove man pages for non-existent binaries - serverman=( - initdb - pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby} - pg_{test_{fsync,timing},upgrade,waldump} - post{gres,master} - ) - for m in ${serverman[@]} ; do - rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1" - done - fi - docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7} - - # Create slot specific man pages - local bn f mansec slotted_name - for mansec in 1 3 7 ; do - local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}" - - mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir" - pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed" - - for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do - bn=$(basename "${f}") - slotted_name=${bn%.${mansec}}${SLOT}.${mansec} - case ${bn} in - TABLE.7|WITH.7) - echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name} - ;; - *) - echo ".so ${rel_manpath}/${bn}" > ${slotted_name} - ;; - esac - done - - popd > /dev/null - done - - insinto /etc/postgresql-${SLOT} - newins src/bin/psql/psqlrc.sample psqlrc - - # Don't delete libpg{port,common}.a (Bug #571046). They're always - # needed by extensions utilizing PGXS. - use static-libs || \ - find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \ - -delete - - # Make slot specific links to programs - local f bn - for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \ - -mindepth 1 -maxdepth 1) - do - bn=$(basename "${f}") - dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \ - "/usr/bin/${bn}${SLOT/.}" - done - - if use doc ; then - docinto html - dodoc doc/src/sgml/html/* - fi - - if use server; then - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} - - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT} - - if use systemd; then - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.service-9.6-r1" | \ - systemd_newunit - ${PN}-${SLOT}.service - newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir - newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf - fi - - use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session - - if use prefix ; then - keepdir /run/postgresql - fperms 1775 /run/postgresql - fi - fi -} - -pkg_postinst() { - use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf - 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 "https://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}" - - if [[ -n ${REPLACING_VERSIONS} ]] ; then - ewarn "If your system is using 'pg_stat_statements' and you are running a" - ewarn "version of PostgreSQL ${SLOT}, we advise that you execute" - ewarn "the following command after upgrading:" - ewarn - ewarn "ALTER EXTENSION pg_stat_statements UPDATE;" - fi - 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 " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html" - einfo " https://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 "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs" - mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR" - chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown" - 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 - if ! use systemd; then - einfo "The PostgreSQL server, by default, will log events to:" - einfo " ${DATA_DIR%/}/postmaster.log" - einfo - fi - 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}" - elif use systemd; then - einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL" - einfo "instead of 'pg_ctl'." - 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 - # Some ICU tests fail if LC_CTYPE and LC_COLLATE aren't the same. We set - # LC_CTYPE to be equal to LC_COLLATE since LC_COLLATE is set by Portage. - local old_ctype=${LC_CTYPE} - export LC_CTYPE=${LC_COLLATE} - emake check - export LC_CTYPE=${old_ctype} - 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 -} diff --git a/dev-db/postgresql/postgresql-14.2-r1.ebuild b/dev-db/postgresql/postgresql-14.2-r1.ebuild new file mode 100644 index 000000000000..5d0ca44d23aa --- /dev/null +++ b/dev-db/postgresql/postgresql-14.2-r1.ebuild @@ -0,0 +1,463 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +PYTHON_COMPAT=( python3_{8,9,10} ) + +inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd tmpfiles + +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" + +SLOT=$(ver_cut 1) + +MY_PV=${PV/_/} +S="${WORKDIR}/${PN}-${MY_PV}" + +SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2" + +LICENSE="POSTGRESQL GPL-2" +DESCRIPTION="PostgreSQL RDBMS" +HOMEPAGE="https://www.postgresql.org/" + +IUSE="debug doc icu kerberos ldap llvm lz4 nls pam + perl python +readline selinux +server systemd ssl static-libs tcl + threads uuid xml zlib" + +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" + +CDEPEND=" +>=app-eselect/eselect-postgresql-2.0 +acct-group/postgres +acct-user/postgres +sys-apps/less +virtual/libintl +icu? ( dev-libs/icu:= ) +kerberos? ( virtual/krb5 ) +ldap? ( net-nds/openldap:= ) +llvm? ( + sys-devel/llvm:= + sys-devel/clang:= +) +lz4? ( app-arch/lz4 ) +pam? ( sys-libs/pam ) +perl? ( >=dev-lang/perl-5.8:= ) +python? ( ${PYTHON_DEPS} ) +readline? ( sys-libs/readline:0= ) +server? ( systemd? ( sys-apps/systemd ) ) +ssl? ( >=dev-libs/openssl-0.9.6-r1:0= ) +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,musl} ) + +nest_usedep() { + local front back + while [[ ${#} -gt 1 ]]; do + front+="${1}? ( " + back+=" )" + shift + done + echo "${front}${1}${back}" +} + +CDEPEND+=" +uuid? ( + ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )} + $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid) +)" + +DEPEND="${CDEPEND} +sys-devel/bison +sys-devel/flex +nls? ( sys-devel/gettext ) +xml? ( virtual/pkgconfig ) +" + +RDEPEND="${CDEPEND} +selinux? ( sec-policy/selinux-postgresql ) +" + +pkg_setup() { + use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup + + use python && python-single-r1_pkg_setup +} + +src_prepare() { + # Set proper run directory + sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \ + -i src/include/pg_config_manual.h || die + + # Rely on $PATH being in the proper order so that the correct + # install program is used for modules utilizing PGXS in both + # hardened and non-hardened environments. (Bug #528786) + sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die + + use server || eapply "${FILESDIR}/${PN}-14_rc1-no-server.patch" + use server && eapply "${FILESDIR}/postgres-llvm14.patch" + + if use pam ; then + sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \ + -i src/backend/libpq/auth.c || \ + die 'PGSQL_PAM_SERVICE rename failed.' + fi + + eapply_user +} + +src_configure() { + case ${CHOST} in + *-darwin*|*-solaris*) + use nls && append-libs intl + ;; + esac + + export LDFLAGS_SL="${LDFLAGS}" + export LDFLAGS_EX="${LDFLAGS}" + + local PO="${EPREFIX}" + + local i uuid_config="" + if use uuid; then + for i in ${UTIL_LINUX_LIBC[@]}; do + use ${i} && uuid_config="--with-uuid=e2fs" + done + [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp" + fi + + local myconf="\ + --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \ + --datadir="${PO}/usr/share/postgresql-${SLOT}" \ + --includedir="${PO}/usr/include/postgresql-${SLOT}" \ + --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \ + --sysconfdir="${PO}/etc/postgresql-${SLOT}" \ + --with-system-tzdata="${PO}/usr/share/zoneinfo" \ + $(use_enable debug) \ + $(use_enable threads thread-safety) \ + $(use_with icu) \ + $(use_with kerberos gssapi) \ + $(use_with ldap) \ + $(use_with llvm) \ + $(use_with lz4) \ + $(use_with pam) \ + $(use_with perl) \ + $(use_with python) \ + $(use_with readline) \ + $(use_with ssl openssl) \ + $(usex server "$(use_with systemd)" '--without-systemd') \ + $(use_with tcl) \ + ${uuid_config} \ + $(use_with xml libxml) \ + $(use_with xml libxslt) \ + $(use_with zlib) \ + $(use_enable nls)" + if use alpha; then + myconf+=" --disable-spinlocks" + else + # Should be the default but just in case + myconf+=" --enable-spinlocks" + fi + econf ${myconf} +} + +src_compile() { + emake + emake -C contrib +} + +src_install() { + emake DESTDIR="${D}" install + emake DESTDIR="${D}" install -C contrib + + dodoc README HISTORY + + # man pages are already built, but if we have the target make them, + # they'll be generated from source before being installed so we + # manually install man pages. + # We use ${SLOT} instead of doman for postgresql.eselect + insinto /usr/share/postgresql-${SLOT}/man/ + doins -r doc/src/sgml/man{1,3,7} + if ! use server; then + # Remove man pages for non-existent binaries + serverman=( + initdb + pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby} + pg_{test_{fsync,timing},upgrade,waldump} + post{gres,master} + ) + for m in ${serverman[@]} ; do + rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1" + done + fi + docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7} + + # Create slot specific man pages + local bn f mansec slotted_name + for mansec in 1 3 7 ; do + local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}" + + mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir" + pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed" + + for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do + bn=$(basename "${f}") + slotted_name=${bn%.${mansec}}${SLOT}.${mansec} + case ${bn} in + TABLE.7|WITH.7) + echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name} + ;; + *) + echo ".so ${rel_manpath}/${bn}" > ${slotted_name} + ;; + esac + done + + popd > /dev/null + done + + insinto /etc/postgresql-${SLOT} + newins src/bin/psql/psqlrc.sample psqlrc + + # Don't delete libpg{port,common}.a (Bug #571046). They're always + # needed by extensions utilizing PGXS. + use static-libs || \ + find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \ + -delete + + # Make slot specific links to programs + local f bn + for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \ + -mindepth 1 -maxdepth 1) + do + bn=$(basename "${f}") + dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \ + "/usr/bin/${bn}${SLOT/.}" + done + + if use doc ; then + docinto html + dodoc doc/src/sgml/html/* + fi + + if use server; then + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} + + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT} + + if use systemd; then + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.service-9.6-r1" | \ + systemd_newunit - ${PN}-${SLOT}.service + newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir + newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf + fi + + use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session + + if use prefix ; then + keepdir /run/postgresql + fperms 1775 /run/postgresql + fi + fi +} + +pkg_postinst() { + use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf + 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 "https://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}" + + if [[ -n ${REPLACING_VERSIONS} ]] ; then + ewarn "If your system is using 'pg_stat_statements' and you are running a" + ewarn "version of PostgreSQL ${SLOT}, we advise that you execute" + ewarn "the following command after upgrading:" + ewarn + ewarn "ALTER EXTENSION pg_stat_statements UPDATE;" + fi + 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 " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html" + einfo " https://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 "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs" + mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR" + chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown" + 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 + if ! use systemd; then + einfo "The PostgreSQL server, by default, will log events to:" + einfo " ${DATA_DIR%/}/postmaster.log" + einfo + fi + 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}" + elif use systemd; then + einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL" + einfo "instead of 'pg_ctl'." + 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 + # Some ICU tests fail if LC_CTYPE and LC_COLLATE aren't the same. We set + # LC_CTYPE to be equal to LC_COLLATE since LC_COLLATE is set by Portage. + local old_ctype=${LC_CTYPE} + export LC_CTYPE=${LC_COLLATE} + emake check + export LC_CTYPE=${old_ctype} + 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 +} diff --git a/dev-db/postgresql/postgresql-14.2.ebuild b/dev-db/postgresql/postgresql-14.2.ebuild deleted file mode 100644 index 5dff65601bf4..000000000000 --- a/dev-db/postgresql/postgresql-14.2.ebuild +++ /dev/null @@ -1,462 +0,0 @@ -# Copyright 1999-2022 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=7 - -PYTHON_COMPAT=( python3_{8,9,10} ) - -inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd tmpfiles - -KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" - -SLOT=$(ver_cut 1) - -MY_PV=${PV/_/} -S="${WORKDIR}/${PN}-${MY_PV}" - -SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2" - -LICENSE="POSTGRESQL GPL-2" -DESCRIPTION="PostgreSQL RDBMS" -HOMEPAGE="https://www.postgresql.org/" - -IUSE="debug doc icu kerberos ldap llvm lz4 nls pam - perl python +readline selinux +server systemd ssl static-libs tcl - threads uuid xml zlib" - -REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" - -CDEPEND=" ->=app-eselect/eselect-postgresql-2.0 -acct-group/postgres -acct-user/postgres -sys-apps/less -virtual/libintl -icu? ( dev-libs/icu:= ) -kerberos? ( virtual/krb5 ) -ldap? ( net-nds/openldap ) -llvm? ( - sys-devel/llvm:= - sys-devel/clang:= -) -lz4? ( app-arch/lz4 ) -pam? ( sys-libs/pam ) -perl? ( >=dev-lang/perl-5.8:= ) -python? ( ${PYTHON_DEPS} ) -readline? ( sys-libs/readline:0= ) -server? ( systemd? ( sys-apps/systemd ) ) -ssl? ( >=dev-libs/openssl-0.9.6-r1:0= ) -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,musl} ) - -nest_usedep() { - local front back - while [[ ${#} -gt 1 ]]; do - front+="${1}? ( " - back+=" )" - shift - done - echo "${front}${1}${back}" -} - -CDEPEND+=" -uuid? ( - ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )} - $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid) -)" - -DEPEND="${CDEPEND} -sys-devel/bison -sys-devel/flex -nls? ( sys-devel/gettext ) -xml? ( virtual/pkgconfig ) -" - -RDEPEND="${CDEPEND} -selinux? ( sec-policy/selinux-postgresql ) -" - -pkg_setup() { - use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup - - use python && python-single-r1_pkg_setup -} - -src_prepare() { - # Set proper run directory - sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \ - -i src/include/pg_config_manual.h || die - - # Rely on $PATH being in the proper order so that the correct - # install program is used for modules utilizing PGXS in both - # hardened and non-hardened environments. (Bug #528786) - sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die - - use server || eapply "${FILESDIR}/${PN}-14_rc1-no-server.patch" - - if use pam ; then - sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \ - -i src/backend/libpq/auth.c || \ - die 'PGSQL_PAM_SERVICE rename failed.' - fi - - eapply_user -} - -src_configure() { - case ${CHOST} in - *-darwin*|*-solaris*) - use nls && append-libs intl - ;; - esac - - export LDFLAGS_SL="${LDFLAGS}" - export LDFLAGS_EX="${LDFLAGS}" - - local PO="${EPREFIX}" - - local i uuid_config="" - if use uuid; then - for i in ${UTIL_LINUX_LIBC[@]}; do - use ${i} && uuid_config="--with-uuid=e2fs" - done - [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp" - fi - - local myconf="\ - --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \ - --datadir="${PO}/usr/share/postgresql-${SLOT}" \ - --includedir="${PO}/usr/include/postgresql-${SLOT}" \ - --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \ - --sysconfdir="${PO}/etc/postgresql-${SLOT}" \ - --with-system-tzdata="${PO}/usr/share/zoneinfo" \ - $(use_enable debug) \ - $(use_enable threads thread-safety) \ - $(use_with icu) \ - $(use_with kerberos gssapi) \ - $(use_with ldap) \ - $(use_with llvm) \ - $(use_with lz4) \ - $(use_with pam) \ - $(use_with perl) \ - $(use_with python) \ - $(use_with readline) \ - $(use_with ssl openssl) \ - $(usex server "$(use_with systemd)" '--without-systemd') \ - $(use_with tcl) \ - ${uuid_config} \ - $(use_with xml libxml) \ - $(use_with xml libxslt) \ - $(use_with zlib) \ - $(use_enable nls)" - if use alpha; then - myconf+=" --disable-spinlocks" - else - # Should be the default but just in case - myconf+=" --enable-spinlocks" - fi - econf ${myconf} -} - -src_compile() { - emake - emake -C contrib -} - -src_install() { - emake DESTDIR="${D}" install - emake DESTDIR="${D}" install -C contrib - - dodoc README HISTORY - - # man pages are already built, but if we have the target make them, - # they'll be generated from source before being installed so we - # manually install man pages. - # We use ${SLOT} instead of doman for postgresql.eselect - insinto /usr/share/postgresql-${SLOT}/man/ - doins -r doc/src/sgml/man{1,3,7} - if ! use server; then - # Remove man pages for non-existent binaries - serverman=( - initdb - pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby} - pg_{test_{fsync,timing},upgrade,waldump} - post{gres,master} - ) - for m in ${serverman[@]} ; do - rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1" - done - fi - docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7} - - # Create slot specific man pages - local bn f mansec slotted_name - for mansec in 1 3 7 ; do - local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}" - - mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir" - pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed" - - for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do - bn=$(basename "${f}") - slotted_name=${bn%.${mansec}}${SLOT}.${mansec} - case ${bn} in - TABLE.7|WITH.7) - echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name} - ;; - *) - echo ".so ${rel_manpath}/${bn}" > ${slotted_name} - ;; - esac - done - - popd > /dev/null - done - - insinto /etc/postgresql-${SLOT} - newins src/bin/psql/psqlrc.sample psqlrc - - # Don't delete libpg{port,common}.a (Bug #571046). They're always - # needed by extensions utilizing PGXS. - use static-libs || \ - find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \ - -delete - - # Make slot specific links to programs - local f bn - for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \ - -mindepth 1 -maxdepth 1) - do - bn=$(basename "${f}") - dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \ - "/usr/bin/${bn}${SLOT/.}" - done - - if use doc ; then - docinto html - dodoc doc/src/sgml/html/* - fi - - if use server; then - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} - - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT} - - if use systemd; then - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.service-9.6-r1" | \ - systemd_newunit - ${PN}-${SLOT}.service - newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir - newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf - fi - - use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session - - if use prefix ; then - keepdir /run/postgresql - fperms 1775 /run/postgresql - fi - fi -} - -pkg_postinst() { - use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf - 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 "https://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}" - - if [[ -n ${REPLACING_VERSIONS} ]] ; then - ewarn "If your system is using 'pg_stat_statements' and you are running a" - ewarn "version of PostgreSQL ${SLOT}, we advise that you execute" - ewarn "the following command after upgrading:" - ewarn - ewarn "ALTER EXTENSION pg_stat_statements UPDATE;" - fi - 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 " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html" - einfo " https://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 "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs" - mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR" - chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown" - 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 - if ! use systemd; then - einfo "The PostgreSQL server, by default, will log events to:" - einfo " ${DATA_DIR%/}/postmaster.log" - einfo - fi - 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}" - elif use systemd; then - einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL" - einfo "instead of 'pg_ctl'." - 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 - # Some ICU tests fail if LC_CTYPE and LC_COLLATE aren't the same. We set - # LC_CTYPE to be equal to LC_COLLATE since LC_COLLATE is set by Portage. - local old_ctype=${LC_CTYPE} - export LC_CTYPE=${LC_COLLATE} - emake check - export LC_CTYPE=${old_ctype} - 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 -} diff --git a/dev-db/postgresql/postgresql-9.6.24-r1.ebuild b/dev-db/postgresql/postgresql-9.6.24-r1.ebuild new file mode 100644 index 000000000000..bd5c27b6bf08 --- /dev/null +++ b/dev-db/postgresql/postgresql-9.6.24-r1.ebuild @@ -0,0 +1,474 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +PYTHON_COMPAT=( python3_{8,9} ) + +inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd tmpfiles + +KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~mips ppc ppc64 ~s390 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" + +SLOT=$(ver_cut 1-2) + +MY_PV=${PV/_/} +S="${WORKDIR}/${PN}-${MY_PV}" + +SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2" + +LICENSE="POSTGRESQL GPL-2" +DESCRIPTION="PostgreSQL RDBMS" +HOMEPAGE="https://www.postgresql.org/" + +IUSE="debug doc kerberos ldap nls pam perl + pg-legacytimestamp python +readline selinux +server systemd ssl + static-libs tcl threads uuid xml zlib" + +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" + +CDEPEND=" +>=app-eselect/eselect-postgresql-2.0 +acct-group/postgres +acct-user/postgres +sys-apps/less +virtual/libcrypt:= +virtual/libintl +kerberos? ( virtual/krb5 ) +ldap? ( net-nds/openldap:= ) +pam? ( sys-libs/pam ) +perl? ( >=dev-lang/perl-5.8:= ) +python? ( ${PYTHON_DEPS} ) +readline? ( sys-libs/readline:0= ) +ssl? ( >=dev-libs/openssl-0.9.6-r1:0= ) +server? ( systemd? ( sys-apps/systemd ) ) +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,musl} ) + +nest_usedep() { + local front back + while [[ ${#} -gt 1 ]]; do + front+="${1}? ( " + back+=" )" + shift + done + echo "${front}${1}${back}" +} + +CDEPEND+=" +uuid? ( + ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )} + $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid) +)" + +DEPEND="${CDEPEND} +sys-devel/bison +sys-devel/flex +nls? ( sys-devel/gettext ) +xml? ( virtual/pkgconfig ) +" + +RDEPEND="${CDEPEND} +selinux? ( sec-policy/selinux-postgresql ) +" + +pkg_setup() { + use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup + + use python && python-single-r1_pkg_setup +} + +src_prepare() { + # Work around PPC{,64} compilation bug where bool is already defined + sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die + + # Set proper run directory + sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \ + -i src/include/pg_config_manual.h || die + + # Rely on $PATH being in the proper order so that the correct + # install program is used for modules utilizing PGXS in both + # hardened and non-hardened environments. (Bug #528786) + sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die + + use server || eapply "${FILESDIR}/${PN}-${SLOT}.3-no-server.patch" + + if use pam ; then + sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \ + -i src/backend/libpq/auth.c || \ + die 'PGSQL_PAM_SERVICE rename failed.' + fi + + eapply_user +} + +src_configure() { + case ${CHOST} in + *-darwin*|*-solaris*) + use nls && append-libs intl + ;; + esac + + export LDFLAGS_SL="${LDFLAGS}" + export LDFLAGS_EX="${LDFLAGS}" + + local PO="${EPREFIX}" + + local i uuid_config="" + if use uuid; then + for i in ${UTIL_LINUX_LIBC[@]}; do + use ${i} && uuid_config="--with-uuid=e2fs" + done + [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp" + fi + + econf \ + --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \ + --datadir="${PO}/usr/share/postgresql-${SLOT}" \ + --includedir="${PO}/usr/include/postgresql-${SLOT}" \ + --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \ + --sysconfdir="${PO}/etc/postgresql-${SLOT}" \ + --with-system-tzdata="${PO}/usr/share/zoneinfo" \ + $(use_enable !alpha spinlocks) \ + $(use_enable !pg-legacytimestamp integer-datetimes) \ + $(use_enable debug) \ + $(use_enable threads thread-safety) \ + $(use_with kerberos gssapi) \ + $(use_with ldap) \ + $(use_with pam) \ + $(use_with perl) \ + $(use_with python) \ + $(use_with readline) \ + $(use_with ssl openssl) \ + $(usex server "$(use_with systemd)" '--without-systemd') \ + $(use_with tcl) \ + ${uuid_config} \ + $(use_with xml libxml) \ + $(use_with xml libxslt) \ + $(use_with zlib) \ + $(use_enable nls) +} + +src_compile() { + emake + emake -C contrib +} + +src_install() { + emake DESTDIR="${D}" install + emake DESTDIR="${D}" install -C contrib + + dodoc README HISTORY doc/{TODO,bug.template} + + # man pages are already built, but if we have the target make them, + # they'll be generated from source before being installed so we + # manually install man pages. + # We use ${SLOT} instead of doman for postgresql.eselect + insinto /usr/share/postgresql-${SLOT}/man/ + doins -r doc/src/sgml/man{1,3,7} + if ! use server; then + # Remove man pages for non-existent binaries + for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do + rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1" + done + fi + docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7} + + # Create slot specific man pages + local bn f mansec slotted_name + for mansec in 1 3 7 ; do + local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}" + + mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir" + pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed" + + for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do + bn=$(basename "${f}") + slotted_name=${bn%.${mansec}}${SLOT/.}.${mansec} + case ${bn} in + TABLE.7|WITH.7) + echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name} + ;; + *) + echo ".so ${rel_manpath}/${bn}" > ${slotted_name} + ;; + esac + done + + popd > /dev/null + done + + insinto /etc/postgresql-${SLOT} + newins src/bin/psql/psqlrc.sample psqlrc + + # Don't delete libpg{port,common}.a (Bug #571046). They're always + # needed by extensions utilizing PGXS. + use static-libs || \ + find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \ + -delete + + local f bn + for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \ + -mindepth 1 -maxdepth 1) + do + bn=$(basename "${f}") + # Temporarily tack on tmp to workaround a file collision + # issue. This is only necessary for 9.7 and earlier. 10 never + # had this issue. + dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \ + "/usr/bin/${bn}${SLOT/.}tmp" + done + + if use doc ; then + docinto html + dodoc doc/src/sgml/html/* + + docinto sgml + dodoc doc/src/sgml/*.{sgml,dsl} + fi + + if use server; then + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} + + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT} + + if use systemd; then + sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ + "${FILESDIR}/${PN}.service-9.6-r1" | \ + systemd_newunit - ${PN}-${SLOT}.service + newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf + fi + + newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir + + use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session + + if use prefix ; then + keepdir /run/postgresql + fperms 1775 /run/postgresql + fi + fi +} + +pkg_preinst() { + # Find all of the slot-specific symlinks, if any, in /usr/bin (e.g., + # /usr/bin/psql96). They may have been created by the + # postgresql.eselect module, but they're handled within this ebuild + # now. It's alright if we momentarily delete /usr/bin/psql as it + # will be recreated by the eselect module in pkg_ppostinst(). This + # is only necessary for 9.7 and earlier. 10 and later were never + # handled in this manner. + local canonicalise + if type -p realpath > /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() { + use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf + 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 "https://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 " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html" + einfo " https://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 + if ! use systemd; then + einfo "The PostgreSQL server, by default, will log events to:" + einfo " ${DATA_DIR%/}/postmaster.log" + einfo + fi + 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}" + elif use systemd; then + einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL" + einfo "instead of 'pg_ctl'." + 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 +} diff --git a/dev-db/postgresql/postgresql-9.6.24.ebuild b/dev-db/postgresql/postgresql-9.6.24.ebuild deleted file mode 100644 index 8310ab4b524f..000000000000 --- a/dev-db/postgresql/postgresql-9.6.24.ebuild +++ /dev/null @@ -1,474 +0,0 @@ -# Copyright 1999-2022 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=7 - -PYTHON_COMPAT=( python3_{8,9} ) - -inherit flag-o-matic linux-info multilib pam prefix python-single-r1 systemd tmpfiles - -KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~mips ppc ppc64 ~s390 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" - -SLOT=$(ver_cut 1-2) - -MY_PV=${PV/_/} -S="${WORKDIR}/${PN}-${MY_PV}" - -SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2" - -LICENSE="POSTGRESQL GPL-2" -DESCRIPTION="PostgreSQL RDBMS" -HOMEPAGE="https://www.postgresql.org/" - -IUSE="debug doc kerberos ldap nls pam perl - pg-legacytimestamp python +readline selinux +server systemd ssl - static-libs tcl threads uuid xml zlib" - -REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" - -CDEPEND=" ->=app-eselect/eselect-postgresql-2.0 -acct-group/postgres -acct-user/postgres -sys-apps/less -virtual/libcrypt:= -virtual/libintl -kerberos? ( virtual/krb5 ) -ldap? ( net-nds/openldap ) -pam? ( sys-libs/pam ) -perl? ( >=dev-lang/perl-5.8:= ) -python? ( ${PYTHON_DEPS} ) -readline? ( sys-libs/readline:0= ) -ssl? ( >=dev-libs/openssl-0.9.6-r1:0= ) -server? ( systemd? ( sys-apps/systemd ) ) -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,musl} ) - -nest_usedep() { - local front back - while [[ ${#} -gt 1 ]]; do - front+="${1}? ( " - back+=" )" - shift - done - echo "${front}${1}${back}" -} - -CDEPEND+=" -uuid? ( - ${UTIL_LINUX_LIBC[@]/%/? ( sys-apps/util-linux )} - $(nest_usedep ${UTIL_LINUX_LIBC[@]/#/!} dev-libs/ossp-uuid) -)" - -DEPEND="${CDEPEND} -sys-devel/bison -sys-devel/flex -nls? ( sys-devel/gettext ) -xml? ( virtual/pkgconfig ) -" - -RDEPEND="${CDEPEND} -selinux? ( sec-policy/selinux-postgresql ) -" - -pkg_setup() { - use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup - - use python && python-single-r1_pkg_setup -} - -src_prepare() { - # Work around PPC{,64} compilation bug where bool is already defined - sed '/#ifndef __cplusplus/a #undef bool' -i src/include/c.h || die - - # Set proper run directory - sed "s|\(PGSOCKET_DIR\s\+\)\"/tmp\"|\1\"${EPREFIX}/run/postgresql\"|" \ - -i src/include/pg_config_manual.h || die - - # Rely on $PATH being in the proper order so that the correct - # install program is used for modules utilizing PGXS in both - # hardened and non-hardened environments. (Bug #528786) - sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die - - use server || eapply "${FILESDIR}/${PN}-${SLOT}.3-no-server.patch" - - if use pam ; then - sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \ - -i src/backend/libpq/auth.c || \ - die 'PGSQL_PAM_SERVICE rename failed.' - fi - - eapply_user -} - -src_configure() { - case ${CHOST} in - *-darwin*|*-solaris*) - use nls && append-libs intl - ;; - esac - - export LDFLAGS_SL="${LDFLAGS}" - export LDFLAGS_EX="${LDFLAGS}" - - local PO="${EPREFIX}" - - local i uuid_config="" - if use uuid; then - for i in ${UTIL_LINUX_LIBC[@]}; do - use ${i} && uuid_config="--with-uuid=e2fs" - done - [[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp" - fi - - econf \ - --prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \ - --datadir="${PO}/usr/share/postgresql-${SLOT}" \ - --includedir="${PO}/usr/include/postgresql-${SLOT}" \ - --mandir="${PO}/usr/share/postgresql-${SLOT}/man" \ - --sysconfdir="${PO}/etc/postgresql-${SLOT}" \ - --with-system-tzdata="${PO}/usr/share/zoneinfo" \ - $(use_enable !alpha spinlocks) \ - $(use_enable !pg-legacytimestamp integer-datetimes) \ - $(use_enable debug) \ - $(use_enable threads thread-safety) \ - $(use_with kerberos gssapi) \ - $(use_with ldap) \ - $(use_with pam) \ - $(use_with perl) \ - $(use_with python) \ - $(use_with readline) \ - $(use_with ssl openssl) \ - $(usex server "$(use_with systemd)" '--without-systemd') \ - $(use_with tcl) \ - ${uuid_config} \ - $(use_with xml libxml) \ - $(use_with xml libxslt) \ - $(use_with zlib) \ - $(use_enable nls) -} - -src_compile() { - emake - emake -C contrib -} - -src_install() { - emake DESTDIR="${D}" install - emake DESTDIR="${D}" install -C contrib - - dodoc README HISTORY doc/{TODO,bug.template} - - # man pages are already built, but if we have the target make them, - # they'll be generated from source before being installed so we - # manually install man pages. - # We use ${SLOT} instead of doman for postgresql.eselect - insinto /usr/share/postgresql-${SLOT}/man/ - doins -r doc/src/sgml/man{1,3,7} - if ! use server; then - # Remove man pages for non-existent binaries - for m in {initdb,pg_{controldata,ctl,resetxlog},post{gres,master}}; do - rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1" - done - fi - docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7} - - # Create slot specific man pages - local bn f mansec slotted_name - for mansec in 1 3 7 ; do - local rel_manpath="../../postgresql-${SLOT}/man/man${mansec}" - - mkdir -p "${ED}"/usr/share/man/man${mansec} || die "making man dir" - pushd "${ED}"/usr/share/man/man${mansec} > /dev/null || die "pushd failed" - - for f in "${ED}/usr/share/postgresql-${SLOT}/man/man${mansec}"/* ; do - bn=$(basename "${f}") - slotted_name=${bn%.${mansec}}${SLOT/.}.${mansec} - case ${bn} in - TABLE.7|WITH.7) - echo ".so ${rel_manpath}/SELECT.7" > ${slotted_name} - ;; - *) - echo ".so ${rel_manpath}/${bn}" > ${slotted_name} - ;; - esac - done - - popd > /dev/null - done - - insinto /etc/postgresql-${SLOT} - newins src/bin/psql/psqlrc.sample psqlrc - - # Don't delete libpg{port,common}.a (Bug #571046). They're always - # needed by extensions utilizing PGXS. - use static-libs || \ - find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \ - -delete - - local f bn - for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \ - -mindepth 1 -maxdepth 1) - do - bn=$(basename "${f}") - # Temporarily tack on tmp to workaround a file collision - # issue. This is only necessary for 9.7 and earlier. 10 never - # had this issue. - dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \ - "/usr/bin/${bn}${SLOT/.}tmp" - done - - if use doc ; then - docinto html - dodoc doc/src/sgml/html/* - - docinto sgml - dodoc doc/src/sgml/*.{sgml,dsl} - fi - - if use server; then - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} - - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT} - - if use systemd; then - sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.service-9.6-r1" | \ - systemd_newunit - ${PN}-${SLOT}.service - newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf - fi - - newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir - - use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session - - if use prefix ; then - keepdir /run/postgresql - fperms 1775 /run/postgresql - fi - fi -} - -pkg_preinst() { - # Find all of the slot-specific symlinks, if any, in /usr/bin (e.g., - # /usr/bin/psql96). They may have been created by the - # postgresql.eselect module, but they're handled within this ebuild - # now. It's alright if we momentarily delete /usr/bin/psql as it - # will be recreated by the eselect module in pkg_ppostinst(). This - # is only necessary for 9.7 and earlier. 10 and later were never - # handled in this manner. - local canonicalise - if type -p realpath > /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() { - use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf - 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 "https://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 " https://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html" - einfo " https://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 - if ! use systemd; then - einfo "The PostgreSQL server, by default, will log events to:" - einfo " ${DATA_DIR%/}/postmaster.log" - einfo - fi - 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}" - elif use systemd; then - einfo "You should use the 'postgresql-${SLOT}.service' unit to run PostgreSQL" - einfo "instead of 'pg_ctl'." - 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 -} diff --git a/dev-db/postgresql/postgresql-9999.ebuild b/dev-db/postgresql/postgresql-9999.ebuild index f290a4330a72..cce0a2f8499a 100644 --- a/dev-db/postgresql/postgresql-9999.ebuild +++ b/dev-db/postgresql/postgresql-9999.ebuild @@ -32,7 +32,7 @@ sys-apps/less virtual/libintl icu? ( dev-libs/icu:= ) kerberos? ( virtual/krb5 ) -ldap? ( net-nds/openldap ) +ldap? ( net-nds/openldap:= ) llvm? ( sys-devel/llvm:= sys-devel/clang:= -- cgit v1.2.3