mariadb: move libmariadb into its own package

This way when only wanting the library nobody needs to download and
compile the server package, saving space and time. Also this way we can
avoid sudden SONAME bumps during a server upgrade.

Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
This commit is contained in:
Sebastian Kemper
2019-11-17 16:05:26 +01:00
parent 88511f13d0
commit c1964dd8d2
5 changed files with 301 additions and 89 deletions

188
libs/libmariadb/Makefile Normal file
View File

@@ -0,0 +1,188 @@
#
# Copyright (C) 2019 Sebastian Kemper <sebastian_ml@gmx.net>
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=libmariadb
PKG_VERSION:=3.1.5
PKG_RELEASE:=1
PKG_SOURCE:=mariadb-connector-c-$(PKG_VERSION)-src.tar.gz
PKG_SOURCE_URL := \
https://mirror.netcologne.de/mariadb/connector-c-$(PKG_VERSION) \
https://mirror.lstn.net/mariadb/connector-c-$(PKG_VERSION) \
https://ftp.yz.yamagata-u.ac.jp/pub/dbms/mariadb/connector-c-$(PKG_VERSION) \
https://downloads.mariadb.org/interstitial/connector-c-$(PKG_VERSION)
PKG_HASH:=a9de5fedd1a7805c86e23be49b9ceb79a86b090ad560d51495d7ba5952a9d9d5
PKG_MAINTAINER:=Sebastian Kemper <sebastian_ml@gmx.net>
PKG_LICENSE:=LGPL-2.1
PKG_LICENSE_FILES:=COPYING.LIB
PKG_BUILD_DIR:=$(BUILD_DIR)/mariadb-connector-c-$(PKG_VERSION)-src
PKG_CPE_ID:=cpe:/a:mariadb:mariadb
PKG_BUILD_PARALLEL:=1
CMAKE_INSTALL:=1
MARIADB_CONF_DIR:=/etc/mysql
MARIADB_PLUGIN_DIR:=/usr/lib/mariadb/plugin
MARIADB_PORT=3306
MARIADB_SOCKET=/var/run/mysqld/mysqld.sock
MARIADB_CLIENT_PLUGINS := \
auth_gssapi_client \
remote_io
PKG_CONFIG_DEPENDS := \
$(patsubst %,CONFIG_PACKAGE_$(PKG_NAME)-plugin-%,$(subst _,-,$(MARIADB_CLIENT_PLUGINS)))
plugin-auth_gssapi_client := CLIENT_PLUGIN_AUTH_GSSAPI_CLIENT
plugin-remote_io := CLIENT_PLUGIN_REMOTE_IO
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
include $(INCLUDE_DIR)/nls.mk
# Pass CPPFLAGS in the CFLAGS as otherwise the build system will
# ignore them.
TARGET_CFLAGS+=$(TARGET_CPPFLAGS)
define Package/$(PKG_NAME)/install/plugin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)$(MARIADB_PLUGIN_DIR)/$(2).so $(1)$(MARIADB_PLUGIN_DIR)
endef
define Package/$(PKG_NAME)/Default
SECTION:=libs
CATEGORY:=Libraries
URL:=https://mariadb.org/
SUBMENU:=Database
endef
define Package/$(PKG_NAME)/description/Default
MariaDB is a very fast and robust SQL database server.
endef
define Package/$(PKG_NAME)
$(call Package/$(PKG_NAME)/Default)
DEPENDS:=+mariadb-common \
$(ICONV_DEPENDS) \
+libopenssl \
+zlib
TITLE:=MariaDB database client library
MENU:=1
PROVIDES:=libmariadbclient libmysqlclient libmysqlclient-r
ABI_VERSION:=3
endef
define Package/$(PKG_NAME)/conffiles
$(MARIADB_CONF_DIR)/conf.d/50-client.cnf
endef
define Package/$(PKG_NAME)/description
$(call Package/$(PKG_NAME)/description/Default)
This package includes the client library.
endef
# We won't need unit tests
CMAKE_OPTIONS += -DWITH_UNIT_TESTS=0
# Make it explicit that we are cross-compiling
CMAKE_OPTIONS += -DCMAKE_CROSSCOMPILING=1
CMAKE_OPTIONS += \
-DINSTALL_INCLUDEDIR=include/mysql \
-DINSTALL_LIBDIR=lib \
-DINSTALL_PLUGINDIR=lib/mariadb/plugin \
-DMARIADB_UNIX_ADDR=$(MARIADB_SOCKET) \
-DWITH_EXTERNAL_ZLIB=YES \
-DWITH_MYSQLCOMPAT=ON \
-DWITH_SSL=OPENSSL
# Help MariaDB find the correct libiconv.
# nls.mk sets it up so that with CONFIG_BUILD_NLS libiconv-full would be used,
# otherwise libiconv-stub (independent of the selected libc). MariaDB needs a
# leg up to find/pick the right lib.
CMAKE_OPTIONS += \
-DICONV_INCLUDE_DIR=$(ICONV_PREFIX)/include \
-DICONV_LIBRARIES=$(ICONV_PREFIX)/lib/libiconv.$(if $(CONFIG_BUILD_NLS),so,a)
CMAKE_OPTIONS += \
$(foreach p,$(MARIADB_CLIENT_PLUGINS),-D$(plugin-$(p))=$(if $(CONFIG_PACKAGE_$(PKG_NAME)-plugin-$(subst _,-,$(p))),DYNAMIC,OFF))
# LIBICONV_PLUG is used in GNU's libiconv for redefinition of exports [e.g.
# from libiconv_open() to iconv_open()]. But in OpenWrt this variable is not set
# when building libiconv-full. So when MariaDB sets LIBICONV_PLUG it expects
# iconv_open() to be available for example, which is not the case - only
# libiconv_open() is. To address this prevent the variable from being set.
# libiconv-stub does not use this variable, so there is no harm in always doing
# this.
define Build/Prepare
$(call Build/Prepare/Default)
$(SED) '/ADD_DEFINITIONS(-DLIBICONV_PLUG)/d' $(PKG_BUILD_DIR)/CMakeLists.txt
endef
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/bin $(1)/usr/include $(1)/usr/lib/mysql $(1)/usr/lib/pkgconfig $(2)/bin
$(CP) $(PKG_INSTALL_DIR)/usr/include/mysql $(1)/usr/include
cd $(1)/usr/include/mysql; $(LN) mariadb_version.h mysql_version.h
$(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{mariadb,mysqlclient}*.so* $(1)/usr/lib
cd $(1)/usr/lib/mysql; $(LN) ../lib{mariadb,mysqlclient}*.so* .
$(INSTALL_BIN) files/mysql_config $(1)/usr/bin
$(LN) $(STAGING_DIR)/usr/bin/mysql_config $(2)/bin
$(SED) 's/PORT/$(MARIADB_PORT)/' $(1)/usr/bin/mysql_config
$(SED) 's|PLUGIN_DIR|$(MARIADB_PLUGIN_DIR)|' $(1)/usr/bin/mysql_config
$(SED) 's|SOCKET|$(MARIADB_SOCKET)|' $(1)/usr/bin/mysql_config
cd "$(PKG_BUILD_DIR)/mariadb_config"; \
CLIENT_VERSION=`sed -n 's|^#define[[:blank:]]*VERSION[[:blank:]]*"\([0-9.]*\)"|\1|p' mariadb_config.c`; \
$(SED) "s/VERSION/$$$${CLIENT_VERSION}/" $(1)/usr/bin/mysql_config
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libmariadb.pc $(1)/usr/lib/pkgconfig
endef
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)$(MARIADB_CONF_DIR)/conf.d
$(INSTALL_DIR) $(1)$(MARIADB_PLUGIN_DIR)
$(INSTALL_BIN) \
$(PKG_INSTALL_DIR)$(MARIADB_PLUGIN_DIR)/caching_sha2_password.so \
$(PKG_INSTALL_DIR)$(MARIADB_PLUGIN_DIR)/client_ed25519.so \
$(PKG_INSTALL_DIR)$(MARIADB_PLUGIN_DIR)/dialog.so \
$(PKG_INSTALL_DIR)$(MARIADB_PLUGIN_DIR)/mysql_clear_password.so \
$(PKG_INSTALL_DIR)$(MARIADB_PLUGIN_DIR)/sha256_password.so \
$(1)$(MARIADB_PLUGIN_DIR)
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/libmariadb.so.$(ABI_VERSION) $(1)/usr/lib
$(INSTALL_CONF) conf/50-client.cnf $(1)$(MARIADB_CONF_DIR)/conf.d
endef
define BuildPlugin
define Package/$(PKG_NAME)-plugin-$(subst _,-,$(1))
$(call Package/$(PKG_NAME)/Default)
TITLE:=$(PKG_NAME) plugin
DEPENDS:=$(PKG_NAME) $(patsubst +%,+PACKAGE_$(PKG_NAME)-plugin-$(subst _,-,$(1)):%,$(2))
endef
define Package/$(PKG_NAME)-plugin-$(subst _,-,$(1))/description
$(call Package/$(PKG_NAME)/description/Default)
This package provides the $(1) plugin.
endef
define Package/$(PKG_NAME)-plugin-$(subst _,-,$(1))/install
$(INSTALL_DIR) $$(1)$(MARIADB_PLUGIN_DIR)
$(call Package/$(PKG_NAME)/install/plugin,$$(1),$(1))
endef
$$(eval $$(call BuildPackage,$(PKG_NAME)-plugin-$(subst _,-,$(1))))
endef
$(eval $(call BuildPackage,$(PKG_NAME)))
$(eval $(call BuildPlugin,auth_gssapi_client,+krb5-libs))
$(eval $(call BuildPlugin,remote_io,+libcurl))

View File

@@ -0,0 +1,21 @@
#
# This group is read by the client library
# Use it for options that affect all clients, but not the server
#
[client]
# Default is Latin1, if you need UTF-8 set this (also in server section)
default-character-set = utf8mb4
# Example of client certificate usage
# ssl-cert=/etc/mysql/client-cert.pem
# ssl-key=/etc/mysql/client-key.pem
#
# Allow only TLS encrypted connections
# ssl-verify-server-cert=on
# This group is *never* read by mysql client library
# If you use the same .cnf file for MySQL and MariaDB, use it for
# MariaDB-only client options
[client-mariadb]

View File

@@ -0,0 +1,61 @@
#!/bin/sh
PCFILE=libmariadb
command -v pkg-config > /dev/null 2>&1
ret="$?"
if [ "$ret" -ne 0 ]; then
echo pkg-config not found >&2
exit 1
fi
pkg-config $PCFILE > /dev/null 2>&1
ret="$?"
if [ "$ret" -ne 0 ]; then
echo $PCFILE pkg-config file missing >&2
exit 1
fi
cflags=$(pkg-config $PCFILE --cflags)
include=$(pkg-config $PCFILE --cflags)
libs=$(pkg-config $PCFILE --libs)
plugindir=PLUGIN_DIR
socket=SOCKET
port=PORT
version=VERSION
usage () {
cat <<EOF
Usage: $0 [OPTIONS]
Options:
--cflags [$cflags]
--include [$include]
--libs [$libs]
--libs_r [$libs]
--plugindir [$plugindir]
--socket [$socket]
--port [$port]
--version [$version]
EOF
exit "$1"
}
if test $# -le 0; then usage 0 ; fi
while test $# -gt 0; do
case $1 in
--cflags) echo "$cflags" ;;
--include) echo "$include" ;;
--libs) echo "$libs" ;;
--libs_r) echo "$libs" ;;
--plugindir) echo "$plugindir" ;;
--socket) echo "$socket" ;;
--port) echo "$port" ;;
--version) echo "$version" ;;
*) usage 1 >&2 ;;
esac
shift
done
exit 0

View File

@@ -0,0 +1,11 @@
--- a/cmake/CheckIncludeFiles.cmake
+++ b/cmake/CheckIncludeFiles.cmake
@@ -46,4 +46,7 @@
CHECK_INCLUDE_FILES (sys/un.h HAVE_SYS_UN_H)
CHECK_INCLUDE_FILES (unistd.h HAVE_UNISTD_H)
CHECK_INCLUDE_FILES (utime.h HAVE_UTIME_H)
-CHECK_INCLUDE_FILES (ucontext.h HAVE_UCONTEXT_H)
+CHECK_INCLUDE_FILES (ucontext.h HAVE_UCONTEXT_HEADER)
+IF(HAVE_UCONTEXT_HEADER)
+ CHECK_FUNCTION_EXISTS(makecontext HAVE_UCONTEXT_H)
+ENDIF(HAVE_UCONTEXT_HEADER)