sys-auth/libnss-mysql: fix building against MariaDB 10.2+ and MySQL 8
authorThomas Deutschmann <whissi@gentoo.org>
Thu, 26 Mar 2020 21:32:40 +0000 (22:32 +0100)
committerThomas Deutschmann <whissi@gentoo.org>
Thu, 26 Mar 2020 21:33:44 +0000 (22:33 +0100)
Closes: https://github.com/gentoo/gentoo/pull/15083
Closes: https://bugs.gentoo.org/693392
Package-Manager: Portage-2.3.96, Repoman-2.3.22
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
sys-auth/libnss-mysql/files/libnss-mysql-1.5_p20060915-mariadb10.2.patch [new file with mode: 0644]
sys-auth/libnss-mysql/files/libnss-mysql-1.5_p20060915-multiarch.patch [new file with mode: 0644]
sys-auth/libnss-mysql/libnss-mysql-1.5_p20060915-r5.ebuild [new file with mode: 0644]

diff --git a/sys-auth/libnss-mysql/files/libnss-mysql-1.5_p20060915-mariadb10.2.patch b/sys-auth/libnss-mysql/files/libnss-mysql-1.5_p20060915-mariadb10.2.patch
new file mode 100644 (file)
index 0000000..b669d01
--- /dev/null
@@ -0,0 +1,35 @@
+--- a/src/mysql.c
++++ b/src/mysql.c
+@@ -196,6 +196,7 @@
+   int retval;
+   sql_server_t *server = &conf.sql.server;
+   unsigned int port;
++  my_bool reconnect = 1;
+   DENTER
+@@ -238,8 +239,9 @@
+           DSRETURN (NSS_UNAVAIL)
+         }
+       ci.valid = ntrue;
+-      ci.link.reconnect = 0; /* Safety: We can't let MySQL assume socket is
+-                                still valid; see _nss_mysql_validate_socket */
++      /* Safety: We can't let MySQL assume socket is still valid;
++         see _nss_mysql_validate_socket */
++      mysql_options(&ci.link, MYSQL_OPT_RECONNECT, &reconnect); 
+       DSRETURN (NSS_SUCCESS)
+     }
+   _nss_mysql_log (LOG_ALERT, "Connection to server '%s' failed: %s",
+--- a/src/nss_mysql.h
++++ b/src/nss_mysql.h
+@@ -72,6 +72,10 @@ typedef nss_status_t NSS_STATUS;
+ /* Default initializers */
+ #define DEF_TIMEOUT         3
+
++#if !defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 80001
++#define my_bool bool
++#endif
++
+ #ifdef DEBUG
+ void _nss_mysql_debug (char *fmt, ...);
+ #define DEBUG_FILE "/tmp/libnss-mysql-debug.log"
diff --git a/sys-auth/libnss-mysql/files/libnss-mysql-1.5_p20060915-multiarch.patch b/sys-auth/libnss-mysql/files/libnss-mysql-1.5_p20060915-multiarch.patch
new file mode 100644 (file)
index 0000000..3a85b60
--- /dev/null
@@ -0,0 +1,21 @@
+--- libnss-mysql-1.5/acinclude.m4
++++ libnss-mysql-1.5.sal/acinclude.m4
+@@ -80,6 +80,18 @@
+     fi
+ done
++dnl Test also $libdir path
++if test -f "$libdir/libmysqlclient.so"
++then
++    MYSQL_LIB_DIR="$libdir"
++    break
++fi
++if test -f "$libdir/mysql/libmysqlclient.so"
++then
++    MYSQL_LIB_DIR="$libdir/mysql"
++    break
++fi
++
+ if test -n "$MYSQL_LIB_DIR"
+ then
+     AC_MSG_RESULT([$MYSQL_LIB_DIR])
diff --git a/sys-auth/libnss-mysql/libnss-mysql-1.5_p20060915-r5.ebuild b/sys-auth/libnss-mysql/libnss-mysql-1.5_p20060915-r5.ebuild
new file mode 100644 (file)
index 0000000..090feab
--- /dev/null
@@ -0,0 +1,62 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit autotools
+
+KEYWORDS="amd64 ppc ~sparc x86"
+
+DESCRIPTION="NSS MySQL Library"
+HOMEPAGE="http://libnss-mysql.sourceforge.net/"
+SRC_URI="http://libnss-mysql.sourceforge.net/snapshot/${PN}-${PV/1.5_p/}.tgz"
+LICENSE="GPL-2"
+SLOT="0"
+IUSE="debug"
+
+DEPEND="dev-db/mysql-connector-c:="
+RDEPEND="${DEPEND}"
+
+S="${WORKDIR}/${PN}"
+
+DOCS=( AUTHORS DEBUGGING FAQ INSTALL NEWS README THANKS
+       TODO UPGRADING ChangeLog
+)
+
+PATCHES=(
+       "${FILESDIR}"/${P}-no-automagic-debug.diff
+       "${FILESDIR}"/${PN}-1.5_p20060915-multiarch.patch
+       "${FILESDIR}"/${PN}-1.5_p20060915-mariadb10.2.patch
+)
+
+src_prepare() {
+       default
+
+       mv configure.{in,ac} || die
+
+       eautoreconf
+}
+
+src_configure() {
+       # Usually, authentication libraries don't belong into usr.
+       # But here, it's required that the lib is in the same dir
+       # as libmysql, because else failures may occur on boot if
+       # udev tries to access a user / group that doesn't exist
+       # on the system before /usr is mounted.
+       econf --libdir="/usr/$(get_libdir)" \
+               $(use_enable debug)
+}
+
+src_install() {
+       default
+
+       find "${ED}" -name '*.la' -delete || die
+
+       newdoc sample/README README.sample
+
+       local subdir
+       for subdir in sample/{linux,freebsd,complex,minimal} ; do
+               docinto "${subdir}"
+               dodoc "${subdir}/"{*.sql,*.cfg}
+       done
+}