[Feature]add MT2731_MP2_MR2_SVN388 baseline version

Change-Id: Ief04314834b31e27effab435d3ca8ba33b499059
diff --git a/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/0001-disable-ucontext-on-musl.patch b/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/0001-disable-ucontext-on-musl.patch
new file mode 100644
index 0000000..60e9199
--- /dev/null
+++ b/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/0001-disable-ucontext-on-musl.patch
@@ -0,0 +1,28 @@
+From 5bc3e7ef9700d12054e0125a126f1bb093f01ef9 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sun, 26 Mar 2017 14:30:33 -0700
+Subject: [PATCH] disable ucontext on musl
+
+musl does not have *contex() APIs even though it has ucontext.h header
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ include/my_context.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/include/my_context.h b/include/my_context.h
+index dd44103..9b28c17 100644
+--- a/include/my_context.h
++++ b/include/my_context.h
+@@ -31,7 +31,7 @@
+ #define MY_CONTEXT_USE_X86_64_GCC_ASM
+ #elif defined(__GNUC__) && __GNUC__ >= 3 && defined(__i386__)
+ #define MY_CONTEXT_USE_I386_GCC_ASM
+-#elif defined(HAVE_UCONTEXT_H)
++#elif defined(__GLIBC__) && defined(HAVE_UCONTEXT_H)
+ #define MY_CONTEXT_USE_UCONTEXT
+ #else
+ #define MY_CONTEXT_DISABLE
+-- 
+2.12.1
+
diff --git a/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/change-cc-to-cc-version.patch b/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/change-cc-to-cc-version.patch
new file mode 100644
index 0000000..02bda24
--- /dev/null
+++ b/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/change-cc-to-cc-version.patch
@@ -0,0 +1,26 @@
+mariadb: replace the CC with CC_VERSION and CXX with CXX_VERSION
+
+mysqlbug.sh is a bug report script. It makes a report with the build information,
+including gcc version. The CC is the local path of gcc, which is useless for bug
+report, and the path may expose private information, so change it to CC_VERSION.
+
+Upstream-Status: Pending
+
+Signed-off-by: Yue Tao <Yue.Tao@windriver.com>
+Signed-off-by: Wenzong Fan <wenzong.fan@windriver.com>
+================================
+diff --git a/scripts/mysqlbug.sh.old b/scripts/mysqlbug.sh
+index e9df210..d4b8d53 100644
+--- a/scripts/mysqlbug.sh.old
++++ b/scripts/mysqlbug.sh
+@@ -24,8 +24,8 @@ VERSION="@VERSION@@MYSQL_SERVER_SUFFIX@"
+ COMPILATION_COMMENT="@COMPILATION_COMMENT@"
+ BUGmysql="maria-developers@lists.launchpad.net"
+ # This is set by configure
+-COMP_CALL_INFO="CC='@SAVE_CC@'  CFLAGS='@SAVE_CFLAGS@'  CXX='@SAVE_CXX@'  CXXFLAGS='@SAVE_CXXFLAGS@'  LDFLAGS='@SAVE_LDFLAGS@'  ASFLAGS='@SAVE_ASFLAGS@'"
+-COMP_RUN_INFO="CC='@CC@'  CFLAGS='@CFLAGS@'  CXX='@CXX@'  CXXFLAGS='@CXXFLAGS@'  LDFLAGS='@LDFLAGS@'  ASFLAGS='@ASFLAGS@'"
++COMP_CALL_INFO="CC='@CC_VERSION@'  CFLAGS='@SAVE_CFLAGS@'  CXX='@CXX_VERSION@'  CXXFLAGS='@SAVE_CXXFLAGS@'  LDFLAGS='@SAVE_LDFLAGS@'  ASFLAGS='@SAVE_ASFLAGS@'"
++COMP_RUN_INFO="CC='@CC_VERSION@'  CFLAGS='@CFLAGS@'  CXX='@CXX_VERSION@'  CXXFLAGS='@CXXFLAGS@'  LDFLAGS='@LDFLAGS@'  ASFLAGS='@ASFLAGS@'"
+ CONFIGURE_LINE="@CONF_COMMAND@"
+ 
+ LIBC_INFO=""
diff --git a/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/configure.cmake-fix-valgrind.patch b/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/configure.cmake-fix-valgrind.patch
new file mode 100644
index 0000000..e97def6
--- /dev/null
+++ b/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/configure.cmake-fix-valgrind.patch
@@ -0,0 +1,41 @@
+From 5effba0d7d47071a3f1bca56823190d5a95bb1a6 Mon Sep 17 00:00:00 2001
+From: Jackie Huang <jackie.huang@windriver.com>
+Date: Wed, 12 Nov 2014 03:09:10 -0500
+Subject: [PATCH] configure.cmake: fix valgrind
+
+Check valgrind headers only if WITH_VALGRIND is set.
+
+mariadb uses two macros for valgrind compilations:
+HAVE_valgrind - valgrind is installed and can be set by configure option -DWITH_VALGRIND
+HAVE_VALGRIND - valgrind debug libraries is installed, set by auto check
+
+We would like to set them both by the configure option so that we can use
+PACKAGECONFIG to decide if valgrind is needed or not.
+
+Upstream-Status: Inappropriate [oe specific]
+
+Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
+---
+ configure.cmake | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.cmake b/configure.cmake
+index 0bd7bbe..51a098f 100644
+--- a/configure.cmake
++++ b/configure.cmake
+@@ -1047,10 +1047,10 @@ MARK_AS_ADVANCED(WITH_ATOMIC_LOCKS MY_ATOMIC_MODE_RWLOCK MY_ATOMIC_MODE_DUMMY)
+ 
+ IF(WITH_VALGRIND)
+   SET(HAVE_valgrind 1)
++  CHECK_INCLUDE_FILES("valgrind/memcheck.h;valgrind/valgrind.h"
++  HAVE_VALGRIND)
+ ENDIF()
+ 
+-CHECK_INCLUDE_FILES("valgrind/memcheck.h;valgrind/valgrind.h" 
+-  HAVE_VALGRIND)
+ 
+ #--------------------------------------------------------------------
+ # Check for IPv6 support
+-- 
+2.0.0
+
diff --git a/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/fix-a-building-failure.patch b/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/fix-a-building-failure.patch
new file mode 100644
index 0000000..0c4e102
--- /dev/null
+++ b/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/fix-a-building-failure.patch
@@ -0,0 +1,31 @@
+[PATCH] fix a building failure
+
+Upstream-Status: Inappropriate [configuration]
+
+building failed since native does not generate import_executables.cmake
+In fact, our building system will export the needed commands
+
+Signed-off-by: Roy Li <rongqing.li@windriver.com>
+---
+ CMakeLists.txt | 5 -----
+ 1 file changed, 5 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index c1ce1c5..83b3a7e 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -350,11 +350,6 @@ MYSQL_CHECK_READLINE()
+ 
+ CHECK_JEMALLOC()
+ 
+-IF(CMAKE_CROSSCOMPILING)
+-  SET(IMPORT_EXECUTABLES "IMPORTFILE-NOTFOUND" CACHE FILEPATH "Path to import_executables.cmake from a native build")
+-  INCLUDE(${IMPORT_EXECUTABLES})
+-ENDIF()
+-
+ #
+ # Setup maintainer mode options by the end. Platform checks are
+ # not run with the warning options as to not perturb fragile checks
+-- 
+1.9.1
+
diff --git a/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/fix-cmake-module-path.patch b/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/fix-cmake-module-path.patch
new file mode 100644
index 0000000..8d9f558
--- /dev/null
+++ b/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/fix-cmake-module-path.patch
@@ -0,0 +1,29 @@
+Avoid CMAKE_MODULE_PATH being overwritten
+
+OE-Core's setting of CMAKE_MODULE_PATH stomps on MariaDB's value unless
+we set it after setting the project name.
+
+Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
+
+Upstream-Status: Inappropriate [working around OE-Core bug]
+
+--- mariadb/CMakeLists.txt	2014-07-17 11:01:07.676353047 +0100
++++ mariadb/CMakeLists.txt	2014-07-17 11:01:31.299353107 +0100
+@@ -28,8 +28,6 @@
+ 
+ MESSAGE(STATUS "Running cmake version ${CMAKE_VERSION}")
+ 
+-SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
+-
+ # Distinguish between community and non-community builds, with the
+ # default being a community build. This does not impact the feature
+ # set that will be compiled in; it's merely provided as a hint to
+@@ -77,6 +75,8 @@
+ ENDIF()
+ PROJECT(${MYSQL_PROJECT_NAME})
+ 
++SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
++
+ IF(BUILD_CONFIG)
+   INCLUDE(
+   ${CMAKE_SOURCE_DIR}/cmake/build_configurations/${BUILD_CONFIG}.cmake)
diff --git a/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/fix-mysqlclient-r-version.patch b/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/fix-mysqlclient-r-version.patch
new file mode 100644
index 0000000..a519e42
--- /dev/null
+++ b/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/fix-mysqlclient-r-version.patch
@@ -0,0 +1,160 @@
+From 6db2a606196fb38a6d106dc409eee1cb9a40a440 Mon Sep 17 00:00:00 2001
+From: Tor Didriksen <tor.didriksen@oracle.com>
+Date: Mon, 24 Jun 2013 17:15:35 +0200
+Subject: [PATCH] Bug#16809055 MYSQL 5.6 AND 5.7 STILL USE LIBMYSQLCLIENT.SO.18
+
+With this patch, the libmysql/ directory contains:
+libmysqlclient.a
+libmysqlclient_r.a -> libmysqlclient.a
+libmysqlclient_r.so -> libmysqlclient.so*
+libmysqlclient_r.so.18 -> libmysqlclient.so.18*
+libmysqlclient_r.so.18.1.0 -> libmysqlclient.so.18.1.0*
+libmysqlclient.so -> libmysqlclient.so.18*
+libmysqlclient.so.18 -> libmysqlclient.so.18.1.0*
+libmysqlclient.so.18.1.0*
+
+This fixes libmysqlclient_r symlinks pointing to the unversioned
+libmysqlclient.so symlink (leading to package QA errors since the
+libmysqlclient-r package ends up depending on libmysqlclient-dev).
+
+Borrowed from MySQL 5.6 tree at https://github.com/percona/mysql/
+
+Upstream-Status: Pending
+
+Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
+
+---
+ cmake/install_macros.cmake | 25 +++++++++++++++----------
+ libmysql/CMakeLists.txt    | 34 +++++++++++++++++++++++++++-------
+ 2 files changed, 42 insertions(+), 17 deletions(-)
+
+diff --git a/cmake/install_macros.cmake b/cmake/install_macros.cmake
+index b8efdf8..a0d0e68 100644
+--- a/cmake/install_macros.cmake
++++ b/cmake/install_macros.cmake
+@@ -1,4 +1,4 @@
+-# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
++# Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
+ # 
+ # 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
+@@ -167,28 +167,33 @@ ENDFUNCTION()
+ 
+ 
+ # Install symbolic link to CMake target. 
+-# the link is created in the same directory as target
+-# and extension will be the same as for target file.
+-MACRO(INSTALL_SYMLINK linkname target destination component)
++# We do 'cd path; ln -s target_name link_name'
++# We also add an INSTALL target for "${path}/${link_name}"
++MACRO(INSTALL_SYMLINK target target_name link_name destination component)
+ IF(UNIX)
+   GET_TARGET_PROPERTY(location ${target} LOCATION)
+   GET_FILENAME_COMPONENT(path ${location} PATH)
+-  GET_FILENAME_COMPONENT(name ${location} NAME)
+-  SET(output ${path}/${linkname})
++  MESSAGE(STATUS "target ${target}")
++  MESSAGE(STATUS "link_name ${link_name}")
++  MESSAGE(STATUS "target_name ${target_name}")
++  MESSAGE(STATUS "path ${path}")
++  MESSAGE(STATUS "")
++
++  SET(output ${path}/${link_name})
+   ADD_CUSTOM_COMMAND(
+     OUTPUT ${output}
+     COMMAND ${CMAKE_COMMAND} ARGS -E remove -f ${output}
+     COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink 
+-      ${name} 
+-      ${linkname}
++      ${target_name} 
++      ${link_name}
+     WORKING_DIRECTORY ${path}
+     DEPENDS ${target}
+     )
+   
+-  ADD_CUSTOM_TARGET(symlink_${linkname}
++  ADD_CUSTOM_TARGET(symlink_${link_name}
+     ALL
+     DEPENDS ${output})
+-  SET_TARGET_PROPERTIES(symlink_${linkname} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
++  SET_TARGET_PROPERTIES(symlink_${link_name} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
+   IF(CMAKE_GENERATOR MATCHES "Xcode")
+     # For Xcode, replace project config with install config
+     STRING(REPLACE "${CMAKE_CFG_INTDIR}" 
+diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt
+index be5760f..96286ff 100644
+--- a/libmysql/CMakeLists.txt
++++ b/libmysql/CMakeLists.txt
+@@ -433,6 +433,12 @@ IF(MSVC)
+  INSTALL_DEBUG_TARGET(clientlib DESTINATION ${INSTALL_LIBDIR}/debug)
+ ENDIF()
+ 
++MACRO(GET_TARGET_NAME target out_name)
++  GET_TARGET_PROPERTY(location ${target} LOCATION)
++  GET_FILENAME_COMPONENT(name ${location} NAME)
++  SET(${out_name} ${name})
++ENDMACRO()
++
+ IF(UNIX)
+   MACRO(GET_VERSIONED_LIBNAME LIBNAME EXTENSION VERSION OUTNAME)
+     SET(DOT_VERSION ".${VERSION}")
+@@ -445,7 +451,13 @@ IF(UNIX)
+       SET(${OUTNAME} ${LIBNAME}${EXTENSION}${DOT_VERSION})
+     ENDIF() 
+   ENDMACRO()
+-  INSTALL_SYMLINK(${CMAKE_STATIC_LIBRARY_PREFIX}mysqlclient_r.a mysqlclient ${INSTALL_LIBDIR} Development)
++ENDIF()
++
++IF(UNIX)
++  GET_TARGET_NAME(mysqlclient lib_name)
++  INSTALL_SYMLINK(mysqlclient
++    ${lib_name} ${CMAKE_STATIC_LIBRARY_PREFIX}mysqlclient_r.a
++    ${INSTALL_LIBDIR} Development)
+ ENDIF()
+ 
+ IF(NOT DISABLE_SHARED)
+@@ -456,10 +468,9 @@ IF(NOT DISABLE_SHARED)
+     # libtool compatability
+     IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR APPLE)
+       SET(OS_SHARED_LIB_VERSION "${SHARED_LIB_MAJOR_VERSION}")
+-    ELSEIF(CMAKE_SYSTEM_NAME MATCHES "HP-UX")
+-      SET(OS_SHARED_LIB_VERSION "${SHARED_LIB_MAJOR_VERSION}.0")
+     ELSE()
+-      SET(OS_SHARED_LIB_VERSION "${SHARED_LIB_MAJOR_VERSION}.0.0")
++      SET(OS_SHARED_LIB_VERSION
++        "${SHARED_LIB_MAJOR_VERSION}.${SHARED_LIB_MINOR_VERSION}.0")
+     ENDIF()
+     # Name of shared library is mysqlclient on Unix
+     SET_TARGET_PROPERTIES(libmysql PROPERTIES 
+@@ -482,8 +493,13 @@ IF(NOT DISABLE_SHARED)
+       "${CMAKE_SHARED_LIBRARY_SUFFIX}"
+       ""
+       linkname)
+-    INSTALL_SYMLINK(${linkname} libmysql ${INSTALL_LIBDIR} SharedLibraries)
+-    SET(OS_SHARED_LIB_SYMLINKS "${SHARED_LIB_MAJOR_VERSION}" "${OS_SHARED_LIB_VERSION}")
++    GET_TARGET_NAME(libmysql lib_name)
++    GET_FILENAME_COMPONENT(lib_name_we ${lib_name} NAME_WE)
++    INSTALL_SYMLINK(libmysql
++      ${lib_name} ${linkname}
++      ${INSTALL_LIBDIR} SharedLibraries)
++    SET(OS_SHARED_LIB_SYMLINKS
++      "${SHARED_LIB_MAJOR_VERSION}" "${OS_SHARED_LIB_VERSION}")
+     LIST(REMOVE_DUPLICATES OS_SHARED_LIB_SYMLINKS)
+     FOREACH(ver ${OS_SHARED_LIB_SYMLINKS})
+       GET_VERSIONED_LIBNAME(
+@@ -491,7 +507,11 @@ IF(NOT DISABLE_SHARED)
+         "${CMAKE_SHARED_LIBRARY_SUFFIX}"
+         "${ver}"
+         linkname)
+-      INSTALL_SYMLINK(${linkname} libmysql ${INSTALL_LIBDIR} SharedLibraries)
++      GET_VERSIONED_LIBNAME(
++        ${lib_name_we} "${CMAKE_SHARED_LIBRARY_SUFFIX}" "${ver}" lib_name_ver)
++      INSTALL_SYMLINK(libmysql
++        ${lib_name_ver} ${linkname}
++        ${INSTALL_LIBDIR} SharedLibraries)
+     ENDFOREACH()
+   ENDIF()
+ ENDIF()
+-- 
+2.0.3
+
diff --git a/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/install_db b/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/install_db
new file mode 100755
index 0000000..512a7da
--- /dev/null
+++ b/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/install_db
@@ -0,0 +1,13 @@
+#! /bin/sh
+case "$1" in
+  start)
+	echo "Starting to install database for mariadb"
+	/usr/bin/mysql-systemd-start pre
+        echo "done."
+	;;
+  *)
+	echo "Usage: /etc/init.d/install_db start"
+	exit 1
+esac
+
+exit 0
diff --git a/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/install_db.service b/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/install_db.service
new file mode 100644
index 0000000..c8369f5
--- /dev/null
+++ b/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/install_db.service
@@ -0,0 +1,17 @@
+#
+# Simple install MySQL database service file
+# It shoulb be done before mysqld.service
+
+[Unit]
+Description=Install MySQL Community Server Database
+After=network.target
+After=syslog.target
+Before=mysqld.service
+
+[Install]
+WantedBy=multi-user.target
+
+[Service]
+Type=oneshot
+ExecStart=@BINDIR@/mysql-systemd-start pre
+
diff --git a/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/my.cnf b/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/my.cnf
new file mode 100644
index 0000000..dc4c172
--- /dev/null
+++ b/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/my.cnf
@@ -0,0 +1,25 @@
+[client]
+#password					= password
+port						= 3306
+socket						= /var/lib/mysql/mysql.sock
+
+[mysqld_safe]
+
+[mysqld]
+user 						= mysql
+port 						= 3306
+socket 						= /var/lib/mysql/mysql.sock
+pid-file 					= /var/lib/mysql/mysqld.pid
+log-error 					= /var/log/mysqld.err
+basedir 					= /usr
+datadir 					= /var/lib/mysql
+skip-external-locking
+skip-networking
+ignore-builtin-innodb
+default-storage-engine				= myisam
+bind-address					= localhost
+
+#
+# include all files from the config directory
+#
+!includedir /etc/my.cnf.d
diff --git a/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/mysql-systemd-start b/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/mysql-systemd-start
new file mode 100644
index 0000000..189c020
--- /dev/null
+++ b/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/mysql-systemd-start
@@ -0,0 +1,66 @@
+#! /bin/sh
+#
+# Needed argument: pre | post
+#
+# pre mode  :  try to run mysql_install_db and fix perms and SELinux contexts
+# post mode :  ping server until answer is received
+#
+
+get_option () {
+    local section=$1
+    local option=$2
+    local default=$3
+    ret=$(/usr/bin/my_print_defaults $section | grep '^--'${option}'=' | cut -d= -f2-)
+    [ -z $ret ] && ret=$default
+    echo $ret
+}
+
+install_db () {
+    # Note: something different than datadir=/var/lib/mysql requires SELinux policy changes (in enforcing mode)
+    datadir=$(get_option mysqld datadir "/var/lib/mysql")
+
+    # Restore log, dir, perms and SELinux contexts
+    [ -d "$datadir" ] || install -d -m 0755 -omysql -gmysql "$datadir" || exit 1
+    log=/var/log/mysqld.log
+    [ -e $log ] || touch $log
+    chmod 0640 $log
+    chown mysql:mysql $log || exit 1
+    if [ -x /usr/sbin/restorecon ]; then
+        /usr/sbin/restorecon "$datadir"
+        /usr/sbin/restorecon $log
+    fi
+
+    # If special mysql dir is in place, skip db install
+    [ -d "$datadir/mysql" ] && exit 0
+
+    # Create initial db
+    /usr/bin/mysql_install_db --rpm --datadir="$datadir" --user=mysql
+    exit 0
+}
+
+pinger () {
+    # Wait for ping to answer to signal startup completed,
+    # might take a while in case of e.g. crash recovery
+    # MySQL systemd service will timeout script if no answer
+    datadir=$(get_option mysqld datadir "/var/lib/mysql")
+    socket=$(get_option  mysqld socket "$datadir/mysql.sock")
+    case $socket in
+        /*) adminsocket="$socket" ;;
+        *) adminsocket="$datadir/$socket" ;;
+    esac
+
+    while /bin/true ; do
+        sleep 1
+        mysqladmin --no-defaults --socket="$adminsocket" --user=UNKNOWN_MYSQL_USER ping >/dev/null 2>&1 && break
+    done
+    exit 0
+}
+
+# main
+case $1 in
+    "pre") install_db ;;
+    "post") pinger ;;
+esac
+
+exit 0
+
diff --git a/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/mysqld.service b/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/mysqld.service
new file mode 100644
index 0000000..d883617
--- /dev/null
+++ b/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/mysqld.service
@@ -0,0 +1,25 @@
+[Unit]
+Description=MariaDB database server
+After=syslog.target
+After=network.target
+
+[Service]
+PIDFile=/var/lib/mysql/mysqld.pid
+Type=simple
+User=mysql
+Group=mysql
+
+# Execute post scripts as root
+PermissionsStartOnly=true
+
+# Start main service
+ExecStart=@BINDIR@/mysqld_safe --basedir=@PREFIX@
+
+# Don't signal startup success before a ping works
+ExecStartPost=@BINDIR@/mysql-systemd-start post
+
+TimeoutSec=300
+PrivateTmp=true
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/remove-bad-path.patch b/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/remove-bad-path.patch
new file mode 100644
index 0000000..ff26b0b
--- /dev/null
+++ b/meta/meta-openembedded/meta-oe/recipes-dbs/mysql/mariadb/remove-bad-path.patch
@@ -0,0 +1,18 @@
+Remove host path from include directories
+
+Naturally this breaks cross-compilation if present.
+
+Upstream-Status: Pending
+
+Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
+
+--- mariadb-5.5.38/storage/tokudb/ft-index/CMakeLists.txt	2014-07-17 14:37:04.529327998 +0100
++++ mariadb-5.5.38/storage/tokudb/ft-index/CMakeLists.txt	2014-07-17 14:43:56.991337895 +0100
+@@ -39,7 +39,6 @@
+ 
+ ## default includes and libraries
+ include_directories(SYSTEM
+-  /usr/local/include
+   ${ZLIB_INCLUDE_DIRS}
+   )
+