summaryrefslogtreecommitdiff
path: root/user/mariadb
diff options
context:
space:
mode:
Diffstat (limited to 'user/mariadb')
-rw-r--r--user/mariadb/APKBUILD271
-rw-r--r--user/mariadb/crc32-power.patch8
-rw-r--r--user/mariadb/gcc_builtins_ppc.h78
-rw-r--r--user/mariadb/libedit.patch57
-rw-r--r--user/mariadb/mariadb-server.limits3
-rw-r--r--user/mariadb/mariadb-server.pre-install7
-rw-r--r--user/mariadb/mariadb.initd47
-rw-r--r--user/mariadb/ppchax.patch26
8 files changed, 497 insertions, 0 deletions
diff --git a/user/mariadb/APKBUILD b/user/mariadb/APKBUILD
new file mode 100644
index 000000000..0b211f2ce
--- /dev/null
+++ b/user/mariadb/APKBUILD
@@ -0,0 +1,271 @@
+# Contributor: A. Wilcox <awilfox@adelielinux.org>
+# Contributor: Dan Theisen <djt@hxx.in>
+# Maintainer: Dan Theisen <djt@hxx.in>
+pkgname=mariadb
+pkgver=10.4.6
+pkgrel=0
+pkgdesc="Open source database server"
+url="https://mariadb.org/"
+arch="all"
+options="suid" # required for pam_auth plugin, which is needed for
+ # mysql_install_db to work
+options="$options !dbg" # abuild can't handle splitting -dbg with the way
+ # this build's package() function works.
+license="GPL-2.0-only"
+pkgusers="mysql"
+pkggroups="mysql"
+depends="$pkgname-common"
+depends_dev="openssl-dev zlib-dev"
+makedepends="$depends_dev bison cmake curl-dev libaio-dev libarchive-dev
+ libedit-dev libevent-dev libexecinfo-dev libxml2-dev ncurses-dev
+ linux-pam-dev pcre-dev xz-dev"
+_mytopdeps="perl perl-dbi perl-dbd-mysql perl-getopt-long perl-socket
+ perl-term-readkey"
+subpackages="$pkgname-client $pkgname-server $pkgname-libs $pkgname-embedded
+ $pkgname-common::noarch $pkgname-backup mytop::noarch $pkgname-openrc
+ $pkgname-doc $pkgname-dev"
+source="https://downloads.mariadb.org/interstitial/mariadb-$pkgver/source/mariadb-$pkgver.tar.gz
+ crc32-power.patch
+ gcc_builtins_ppc.h
+ libedit.patch
+ ppchax.patch
+ mariadb.initd
+ mariadb-server.limits
+ "
+
+build() {
+ if [ "$CBUILD" != "$CHOST" ]; then
+ CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
+ fi
+
+ case "$CTARGET_ARCH" in
+ ppc)
+ cp "$srcdir"/gcc_builtins_ppc.h "$builddir"/include/atomic/gcc_builtins.h
+ ;;
+ esac
+
+ local _release="\
+ -DBUILD_CONFIG=mysql_release \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_CXX_FLAGS=\"$CXXFLAGS -DNDEBUG\" \
+ -DCMAKE_C_FLAGS=\"$CFLAGS -DNDEBUG\" \
+ -DWITH_DEFAULT_COMPILER_OPTIONS=NO \
+ -DWITH_DEFAULT_FEATURE_SET=NO "
+
+ # NUMA is disabled because all arches do not support it
+ # SKIP_TESTS skips client unittests that require a server to be present
+ # JEMALLOC is reported to not work on musl, TODO: test this
+ # ASAN also doesn't work on musl iirc
+ local _deps="\
+ -DWITH_MARIABACKUP=ON \
+ -DWITH_NUMA=OFF \
+ -DWITH_LIBNUMA=OFF \
+ -DWITH_LIBWSREP=ON \
+ -DWITH_UNIT_TESTS=ON \
+ -DWITH_LIBEDIT=ON \
+ -DWITH_EMBEDDED_SERVER=ON \
+ -DWITH_UNITTEST=OFF \
+ -DWITH_ASAN=OFF \
+ -DWITH_JEMALLOC=OFF \
+ -DWITH_LIBWRAP=OFF \
+ -DWITH_SYSTEMD=no \
+ -DWITH_VALGRIND=OFF \
+ -DWITH_COMMENT=\"${DISTRO_NAME:-Adélie Linux}\" \
+ -DENABLED_LOCAL_INFILE=ON \
+ -DENABLED_PROFILING=OFF \
+ -DSKIP_TESTS=ON "
+
+ # AWS_KEY_MANAGEMENT makes this package non-redistributable, disable it
+ local _plugins="\
+ -DPLUGIN_ARCHIVE=YES \
+ -DPLUGIN_ARIA=YES \
+ -DPLUGIN_BLACKHOLE=YES \
+ -DPLUGIN_CSV=YES \
+ -DPLUGIN_MYISAM=YES \
+ -DAUTH_GSSAPI_PLUGIN_TYPE=NO \
+ -DPLUGIN_AUTH_GSSAPI=NO \
+ -DPLUGIN_AWS_KEY_MANAGEMENT=NO \
+ -DPLUGIN_CASSANDRA=NO \
+ -DPLUGIN_FEEDBACK=NO "
+
+ # Investigate turning more of these on
+ local _innodb="\
+ -DWITH_INNODB_LZMA=YES \
+ -DWITH_INNODB_BZIP2=NO \
+ -DWITH_INNODB_LZ4=NO \
+ -DWITH_INNODB_LZO=NO \
+ -DWITH_INNODB_SNAPPY=NO "
+
+ # MongoDB is not libre software, disable it
+ local _connect="\
+ -DCONNECT_WITH_MYSQL=YES \
+ -DCONNECT_WITH_MONGO=NO \
+ -DCONNECT_WITH_ODBC=NO \
+ -DCONNECT_WITH_JDBC=NO \
+ -DCONNECT_WITH_LIBXML2=system "
+
+ # non-portable things, things that don't work on musl, BE, 32-bit etc
+ local _evil="\
+ -DPLUGIN_MROONGA=NO \
+ -DPLUGIN_ROCKSDB=NO \
+ -DPLUGIN_TOKUDB=NO "
+
+ local _system_libs="\
+ -DWITH_LIBARCHIVE=system \
+ -DWITH_PCRE=system \
+ -DWITH_SSL=system \
+ -DWITH_ZLIB=system \
+ -DWITH_EXTERNAL_ZLIB=YES \
+ -DCONC_WITH_EXTERNAL_ZLIB=YES "
+
+ local _system_paths="\
+ -DCMAKE_INSTALL_PREFIX=/usr \
+ -DSYSCONFDIR=/etc/mysql \
+ -DMYSQL_DATADIR=/var/lib/mariadb \
+ -DMYSQL_UNIX_ADDR=/var/run/mariadb/mysqld.sock \
+ -DINSTALL_UNIX_ADDRDIR=/var/run/mariadb/mysqld.sock \
+ -DPKG_CONFIG_EXECUTABLE=/usr/bin/pkgconf \
+ -DINSTALL_BINDIR=bin \
+ -DINSTALL_SCRIPTDIR=bin \
+ -DINSTALL_SBINDIR=sbin \
+ -DINSTALL_INCLUDEDIR=include/mysql \
+ -DINSTALL_LIBDIR=lib \
+ -DINSTALL_PLUGINDIR=lib/mariadb/plugin \
+ -DINSTALL_DOCDIR=share/doc/$pkgname \
+ -DINSTALL_DOCREADMEDIR=share/doc/$pkgname \
+ -DINSTALL_MANDIR=share/man \
+ -DINSTALL_MYSQLSHAREDIR=share/mariadb \
+ -DINSTALL_SUPPORTFILESDIR=share/mariadb \
+ -DSUFFIX_INSTALL_DIR=\"\" "
+
+ _buildflags=$(echo "\
+ ${_release}\
+ ${_deps}\
+ ${_plugins}\
+ ${_innodb}\
+ ${_connect}\
+ ${_evil}\
+ ${_system_libs}\
+ ${_system_paths}\
+ ${CMAKE_CROSSOPTS}" | tr -d '\t')
+ echo "Build Flags are: $_buildflags"
+ eval "cmake $_buildflags ."
+ make
+}
+
+check() {
+ CTEST_OUTPUT_ON_FAILURE=TRUE ctest -E '^(test-connect)$'
+}
+
+package() {
+ depends="$pkgname-client $pkgname-server"
+ install -m755 -D ${srcdir}/mariadb.initd ${pkgdir}/etc/init.d/mariadb
+}
+
+openrc() {
+ default_openrc
+ depends="mariadb-server=$pkgver-r$pkgrel"
+}
+
+_install_component() {
+ cd "$builddir"
+ component=$1
+ prefix=$subpkgdir/usr
+ msg "Installing component \"$component\" into $prefix"
+ cmake -DCMAKE_INSTALL_PREFIX=${prefix} \
+ -DCOMPONENT=${component} \
+ -P cmake_install.cmake
+}
+
+libs() {
+ pkgdesc="Libraries for the MariaDB database"
+ _install_component SharedLibraries
+}
+
+client() {
+ pkgdesc="The MariaDB database client"
+ depends="mariadb-common=$pkgver-r$pkgrel"
+ for part in Client ClientPlugins; do
+ _install_component ${part}
+ done
+}
+
+server() {
+ pkgdesc="The MariaDB database server"
+ depends="mariadb-common=$pkgver-r$pkgrel"
+ install="$pkgname-server.pre-install"
+ for part in Server Server_Scripts IniFiles connect-engine; do
+ _install_component ${part}
+ done
+
+ install -m755 -D ${srcdir}/mariadb-server.limits \
+ ${subpkgdir}/etc/security/limits.d/mariadb.conf
+}
+
+
+common() {
+ pkgdesc="MariaDB common files for both server and client"
+ replaces="mysql-common"
+ depends=
+
+ SHARE_PATH=${pkgdir}-server/usr/share
+ mkdir -p ${subpkgdir}/usr
+ mv $SHARE_PATH ${subpkgdir}/usr
+
+ _install_component Common
+}
+
+embedded() {
+ pkgdesc="MariaDB embedded server and embeddable library"
+
+ # move mysql-embedded from client subpackage to embedded
+ mkdir -p ${subpkgdir}/usr/bin
+ BIN_PATH=${pkgdir}-client/usr/bin
+ mv $BIN_PATH/mysql_embedded ${subpkgdir}/usr/bin/
+
+ # move embedded mysqld libraries from server package to embedded
+ mkdir -p ${subpkgdir}/usr/lib
+ LIB_PATH=${pkgdir}-server/usr/lib
+ MYSQLD_ELIB=$(readlink $LIB_PATH/libmysqld.so)
+ mv $LIB_PATH/$MYSQLD_ELIB ${subpkgdir}/usr/lib/
+ mv $LIB_PATH/libmysqld.so ${subpkgdir}/usr/lib/
+ mv $LIB_PATH/libmariadbd.so ${subpkgdir}/usr/lib/
+}
+
+backup() {
+ pkgdesc="The mariabackup tool for physical online backups"
+ _install_component backup
+}
+
+mytop() {
+ pkgdesc="Command line tool used for monitoring MariaDB performance"
+ depends="$_mytopdeps"
+ _install_component Mytop
+}
+
+dev() {
+ replaces="libmysqlclient mysql-dev"
+ provides="mysql-dev=$pkgver-r$pkgrel"
+ depends="$pkgname-libs"
+ _install_component Development
+
+ # move symlinks for static libs from libs subpackage to dev
+ LIB_PATH=${pkgdir}-libs/usr/lib
+ mv $LIB_PATH/libmysqlclient.a ${subpkgdir}/usr/lib/
+ mv $LIB_PATH/libmysqlclient_r.a ${subpkgdir}/usr/lib/
+}
+
+doc() {
+ for part in ManPagesClient ManPagesServer ManPagesDevelopment; do
+ _install_component ${part}
+ done
+ default_doc
+}
+
+sha512sums="b04c47f72de2473d7b5edd04b4785a1d7179bb1f429f30ba53ae6cfbbb413200d9803eff1072949b2e81fd7d2164ea34c68620d621d4181b913daa2293ae140c mariadb-10.4.6.tar.gz
+03a4f60674cb45bcccb59971260c56f0f5f64eb79ad4078c485bc8112df2b9ee2b4eb08350530443b318440787b672b2947bc439783e813a32350f9179417cd0 crc32-power.patch
+15ae6d4564c5c8b8583502acd54bf0019e8a62ebcf87278015506e58848cb6996ff61ca055897f9192b8818808adeeac15b8f786065cfd071cc264ca1922f7e3 gcc_builtins_ppc.h
+41dc407cc16e7af5a8b9527489016a052a8bce85bd3d00f0d06b98b3fef16a693849d15a9a15136ee8148829fe4570d03df65dfb6fe9f0bccc447cab1bd666f4 libedit.patch
+0725c1c04ce01d6035d4fef5018709c8814228bf250503455c2aa7c972278fcb78b47e681a721cb42dc61508075e1485116d8c7ac924c584b4bf5ca6b27b6594 ppchax.patch
+1a2b058aad5fd6d6964db58b663591299a5bf82e7ad21a105d53a3e7ad1c3674c737caf3ee12799cce947cf8ead1f3e789dd8afcfc769891f08208b3006f9654 mariadb.initd
+d47324b34a87410eddb554f65199d145dfba9ae40407a62fb77df4e1ebf13087d15eb28e61e5e7cc9139eb42f093a0955136edae4020822652a1f0b4e219849e mariadb-server.limits"
diff --git a/user/mariadb/crc32-power.patch b/user/mariadb/crc32-power.patch
new file mode 100644
index 000000000..aa269a599
--- /dev/null
+++ b/user/mariadb/crc32-power.patch
@@ -0,0 +1,8 @@
+--- mariadb-10.4.6/cmake/crc32.cmake.old 2019-06-17 22:00:31.000000000 +0000
++++ mariadb-10.4.6/cmake/crc32.cmake 2019-07-06 22:02:39.704198796 +0000
+@@ -1,4 +1,4 @@
+-IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64")
++IF(FALSE)
+ SET(HAVE_CRC32_VPMSUM 1)
+ SET(CRC32_LIBRARY crc32-vpmsum)
+ ADD_SUBDIRECTORY(extra/crc32-vpmsum)
diff --git a/user/mariadb/gcc_builtins_ppc.h b/user/mariadb/gcc_builtins_ppc.h
new file mode 100644
index 000000000..8e492c58a
--- /dev/null
+++ b/user/mariadb/gcc_builtins_ppc.h
@@ -0,0 +1,78 @@
+#ifndef ATOMIC_GCC_BUILTINS_INCLUDED
+#define ATOMIC_GCC_BUILTINS_INCLUDED
+
+/* Copyright (c) 2017 MariaDB Foundation
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
+
+
+#define MY_MEMORY_ORDER_RELAXED __ATOMIC_RELAXED
+#define MY_MEMORY_ORDER_CONSUME __ATOMIC_CONSUME
+#define MY_MEMORY_ORDER_ACQUIRE __ATOMIC_ACQUIRE
+#define MY_MEMORY_ORDER_RELEASE __ATOMIC_RELEASE
+#define MY_MEMORY_ORDER_ACQ_REL __ATOMIC_ACQ_REL
+#define MY_MEMORY_ORDER_SEQ_CST __ATOMIC_SEQ_CST
+
+#define my_atomic_store32_explicit(P, D, O) __atomic_store_4((P), (D), (O))
+#define my_atomic_store64_explicit(P, D, O) __atomic_store_8((P), (D), (O))
+#define my_atomic_storeptr_explicit(P, D, O) __atomic_store_4((P), (unsigned int)(D), (O))
+
+#define my_atomic_load32_explicit(P, O) __atomic_load_4((P), (O))
+#define my_atomic_load64_explicit(P, O) __atomic_load_8((P), (O))
+#define my_atomic_loadptr_explicit(P, O) __atomic_load_4((P), (O))
+
+#define my_atomic_fas32_explicit(P, D, O) __atomic_exchange_4((P), (D), (O))
+#define my_atomic_fas64_explicit(P, D, O) __atomic_exchange_8((P), (D), (O))
+#define my_atomic_fasptr_explicit(P, D, O) __atomic_exchange_4((P), (D), (O))
+
+#define my_atomic_add32_explicit(P, A, O) __atomic_fetch_add_4((P), (A), (O))
+#define my_atomic_add64_explicit(P, A, O) __atomic_fetch_add_8((P), (A), (O))
+
+#define my_atomic_cas32_weak_explicit(P, E, D, S, F) \
+ __atomic_compare_exchange_4((P), (E), (D), 1, (S), (F))
+#define my_atomic_cas64_weak_explicit(P, E, D, S, F) \
+ __atomic_compare_exchange_8((P), (E), (D), 1, (S), (F))
+#define my_atomic_casptr_weak_explicit(P, E, D, S, F) \
+ __atomic_compare_exchange_4((P), (E), (D), 1, (S), (F))
+
+#define my_atomic_cas32_strong_explicit(P, E, D, S, F) \
+ __atomic_compare_exchange_4((P), (E), (D), 0, (S), (F))
+#define my_atomic_cas64_strong_explicit(P, E, D, S, F) \
+ __atomic_compare_exchange_8((P), (E), (D), 0, (S), (F))
+#define my_atomic_casptr_strong_explicit(P, E, D, S, F) \
+ __atomic_compare_exchange_4((P), (E), (D), 0, (S), (F))
+
+#define my_atomic_store32(P, D) __atomic_store_4((P), (D), __ATOMIC_SEQ_CST)
+#define my_atomic_store64(P, D) __atomic_store_8((P), (D), __ATOMIC_SEQ_CST)
+#define my_atomic_storeptr(P, D) __atomic_store_4((P), (D), __ATOMIC_SEQ_CST)
+
+#define my_atomic_load32(P) __atomic_load_4((P), __ATOMIC_SEQ_CST)
+#define my_atomic_load64(P) __atomic_load_8((P), __ATOMIC_SEQ_CST)
+#define my_atomic_loadptr(P) __atomic_load_4((P), __ATOMIC_SEQ_CST)
+
+#define my_atomic_fas32(P, D) __atomic_exchange_4((P), (D), __ATOMIC_SEQ_CST)
+#define my_atomic_fas64(P, D) __atomic_exchange_8((P), (D), __ATOMIC_SEQ_CST)
+#define my_atomic_fasptr(P, D) __atomic_exchange_4((P), (D), __ATOMIC_SEQ_CST)
+
+#define my_atomic_add32(P, A) __atomic_fetch_add_4((P), (A), __ATOMIC_SEQ_CST)
+#define my_atomic_add64(P, A) __atomic_fetch_add_8((P), (A), __ATOMIC_SEQ_CST)
+
+#define my_atomic_cas32(P, E, D) \
+ __atomic_compare_exchange_4((P), (E), (D), 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
+#define my_atomic_cas64(P, E, D) \
+ __atomic_compare_exchange_8((P), (E), (D), 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
+#define my_atomic_casptr(P, E, D) \
+ __atomic_compare_exchange_4((P), (E), (D), 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
+
+#endif /* ATOMIC_GCC_BUILTINS_INCLUDED */
diff --git a/user/mariadb/libedit.patch b/user/mariadb/libedit.patch
new file mode 100644
index 000000000..14dc9db49
--- /dev/null
+++ b/user/mariadb/libedit.patch
@@ -0,0 +1,57 @@
+From d9342e88289fa588ea2f1a094dbfc32f0693e23d Mon Sep 17 00:00:00 2001
+From: Sebastian Kemper <sebastian_ml@gmx.net>
+Date: Tue, 9 Apr 2019 22:28:10 +0200
+Subject: [PATCH] cmake: support new libedit interface
+
+libedit changed it's interface a while ago. MariaDB's cmake file doesn't
+recognize the new interface, the compile test fails:
+
+/mariadb-10.2.19/CMakeFiles/CMakeTmp/src.cxx: In function 'int main(int, char**)':
+/mariadb-10.2.19/CMakeFiles/CMakeTmp/src.cxx:6:47: error: invalid conversion from 'char*' to 'int' [-fpermissive]
+ int res= (*rl_completion_entry_function)(0,0);
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
+
+Fix this by adding a detection for the new interface as well.
+
+Run-tested on a MIPS machine.
+
+Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
+---
+ cmake/readline.cmake | 17 +++++++++++++++--
+ 1 file changed, 15 insertions(+), 2 deletions(-)
+
+diff --git a/cmake/readline.cmake b/cmake/readline.cmake
+index 12a8980b6a90..a2b2cc4c241f 100644
+--- a/cmake/readline.cmake
++++ b/cmake/readline.cmake
+@@ -160,8 +160,20 @@ MACRO (MYSQL_FIND_SYSTEM_LIBEDIT)
+ int res= (*rl_completion_entry_function)(0,0);
+ completion_matches(0,0);
+ }"
+- LIBEDIT_INTERFACE)
+- SET(USE_LIBEDIT_INTERFACE ${LIBEDIT_INTERFACE})
++ LIBEDIT_HAVE_COMPLETION_INT)
++
++ CHECK_CXX_SOURCE_COMPILES("
++ #include <stdio.h>
++ #include <readline.h>
++ int main(int argc, char **argv)
++ {
++ char res= *(*rl_completion_entry_function)(0,0);
++ completion_matches(0,0);
++ }"
++ LIBEDIT_HAVE_COMPLETION_CHAR)
++ IF(LIBEDIT_HAVE_COMPLETION_INT OR LIBEDIT_HAVE_COMPLETION_CHAR)
++ SET(USE_LIBEDIT_INTERFACE 1)
++ ENDIF()
+ ENDIF()
+ ENDMACRO()
+
+@@ -187,6 +199,7 @@ MACRO (MYSQL_CHECK_READLINE)
+ IF(USE_LIBEDIT_INTERFACE)
+ SET(MY_READLINE_INCLUDE_DIR ${LIBEDIT_INCLUDE_DIR})
+ SET(MY_READLINE_LIBRARY ${LIBEDIT_LIBRARY} ${CURSES_LIBRARY})
++ SET(USE_NEW_READLINE_INTERFACE ${LIBEDIT_HAVE_COMPLETION_CHAR})
+ ELSE()
+ MYSQL_USE_BUNDLED_READLINE()
+ ENDIF()
diff --git a/user/mariadb/mariadb-server.limits b/user/mariadb/mariadb-server.limits
new file mode 100644
index 000000000..520783992
--- /dev/null
+++ b/user/mariadb/mariadb-server.limits
@@ -0,0 +1,3 @@
+#<domain> <type> <item> <value>
+@mysql soft nofile 65535
+@mysql hard nofile 65535
diff --git a/user/mariadb/mariadb-server.pre-install b/user/mariadb/mariadb-server.pre-install
new file mode 100644
index 000000000..de2bcd795
--- /dev/null
+++ b/user/mariadb/mariadb-server.pre-install
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+groupadd -g 60 -r mysql
+useradd -M -N -r -u 60 -g 60 -c "MariaDB Database User" -d /var/lib/mysql -s /sbin/nologin mysql
+
+mkdir /var/lib/mysql
+chown mysql:mysql /var/lib/mysql
diff --git a/user/mariadb/mariadb.initd b/user/mariadb/mariadb.initd
new file mode 100644
index 000000000..4e1cf8d3e
--- /dev/null
+++ b/user/mariadb/mariadb.initd
@@ -0,0 +1,47 @@
+#!/sbin/openrc-run
+
+getconf() {
+ v=$(my_print_defaults --mysqld | grep ^--$1)
+ [ -z $v ] && echo $2 || echo ${v#*=}
+}
+
+retry="60"
+extra_stopped_commands="setup"
+
+user=${MYSQLD_USER:-mysql}
+group=${MYSQLD_GROUP:-mysql}
+default_datadir=$(getconf datadir "/var/lib/mariadb")
+datadir=${MYSQLD_DATADIR:-$default_datadir}
+
+command="/usr/bin/mysqld_safe"
+command_args="--syslog --nowatch --user=$user"
+
+depend() {
+ use net
+ need localmount
+}
+
+setup() {
+ checkpath -d -m 1775 -o $user:$group /run/mariadb
+ ebegin "Creating a new MySQL database in $datadir"
+ mysql_install_db --user=$user --datadir=$datadir
+ eend $?
+}
+
+start_pre() {
+ pidfile=$(getconf pid-file "/run/mariadb/mysqld.pid")
+ command_args="$command_args --pid-file=$pidfile"
+ if [ ! -d $datadir/mysql ]; then
+ eerror "Data directory '$datadir' is empty or invalid."
+ eerror "Run '/etc/init.d/mariadb setup' to create new database."
+ fi
+}
+
+start_post() {
+ ewaitfile 10 $(getconf socket "/run/mariadb/mysqld.sock")
+}
+
+stop_pre() {
+ pidfile=$(getconf pid-file "/run/mariadb/mysqld.pid")
+}
+
diff --git a/user/mariadb/ppchax.patch b/user/mariadb/ppchax.patch
new file mode 100644
index 000000000..26ffb5189
--- /dev/null
+++ b/user/mariadb/ppchax.patch
@@ -0,0 +1,26 @@
+--- mariadb-10.4.6/configure.cmake.old 2019-06-17 22:00:31.000000000 +0000
++++ mariadb-10.4.6/configure.cmake 2019-07-06 23:21:57.705655766 +0000
+@@ -922,6 +922,10 @@
+ return (int)__atomic_load_n(ptr, __ATOMIC_SEQ_CST);
+ }"
+ HAVE_GCC_C11_ATOMICS)
++IF(NOT HAVE_GCC_C11_ATOMICS AND CMAKE_SYSTEM_PROCESSOR MATCHES "ppc")
++ SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} atomic)
++ SET(HAVE_GCC_C11_ATOMICS 1)
++ENDIF()
+
+ IF(WITH_VALGRIND)
+ SET(HAVE_valgrind 1)
+--- mariadb-10.4.6/mysys/CMakeLists.txt.old 2019-06-17 22:00:32.000000000 +0000
++++ mariadb-10.4.6/mysys/CMakeLists.txt 2019-07-07 00:03:56.956394100 +0000
+@@ -91,6 +91,10 @@
+ TARGET_LINK_LIBRARIES(mysys pthread)
+ ENDIF()
+
++IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc")
++ TARGET_LINK_LIBRARIES(mysys atomic)
++ENDIF()
++
+ ADD_EXECUTABLE(thr_lock thr_lock.c)
+ TARGET_LINK_LIBRARIES(thr_lock mysys)
+ SET_TARGET_PROPERTIES(thr_lock PROPERTIES COMPILE_FLAGS "-DMAIN")