ASR_BASE
Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
diff --git a/external/subpack/utils/mariadb/patches/100-fix_hostname.patch b/external/subpack/utils/mariadb/patches/100-fix_hostname.patch
new file mode 100644
index 0000000..408651d
--- /dev/null
+++ b/external/subpack/utils/mariadb/patches/100-fix_hostname.patch
@@ -0,0 +1,11 @@
+--- a/scripts/mysql_install_db.sh
++++ b/scripts/mysql_install_db.sh
+@@ -424,7 +424,7 @@ fi
+
+
+ # Try to determine the hostname
+-hostname=`@HOSTNAME@`
++hostname=`cat /proc/sys/kernel/hostname`
+
+ # Check if hostname is valid
+ if test "$cross_bootstrap" -eq 0 -a "$in_rpm" -eq 0 -a "$force" -eq 0
diff --git a/external/subpack/utils/mariadb/patches/110-pcre.cmake.patch b/external/subpack/utils/mariadb/patches/110-pcre.cmake.patch
new file mode 100644
index 0000000..2d370a3
--- /dev/null
+++ b/external/subpack/utils/mariadb/patches/110-pcre.cmake.patch
@@ -0,0 +1,36 @@
+From: =?utf-8?q?Ond=C5=99ej_Sur=C3=BD?= <ondrej@debian.org>
+Date: Wed, 22 Nov 2017 06:05:45 +0000
+Subject: Revert to using system pcre library
+
+---
+ cmake/pcre.cmake | 16 ++--------------
+ 1 file changed, 2 insertions(+), 14 deletions(-)
+
+--- a/cmake/pcre.cmake
++++ b/cmake/pcre.cmake
+@@ -1,23 +1,11 @@
+-INCLUDE (CheckCSourceRuns)
+-
+ SET(WITH_PCRE "auto" CACHE STRING
+ "Which pcre to use (possible values are 'bundled', 'system', or 'auto')")
+
+ MACRO (CHECK_PCRE)
+ IF(WITH_PCRE STREQUAL "system" OR WITH_PCRE STREQUAL "auto")
+- CHECK_LIBRARY_EXISTS(pcre pcre_stack_guard "" HAVE_PCRE_STACK_GUARD)
+- IF(NOT CMAKE_CROSSCOMPILING)
+- SET(CMAKE_REQUIRED_LIBRARIES "pcre")
+- CHECK_C_SOURCE_RUNS("
+- #include <pcre.h>
+- int main() {
+- return -pcre_exec(NULL, NULL, NULL, -999, -999, 0, NULL, 0) < 256;
+- }" PCRE_STACK_SIZE_OK)
+- SET(CMAKE_REQUIRED_LIBRARIES)
+- ENDIF()
++ CHECK_LIBRARY_EXISTS(pcre pcre_stack_guard "" HAVE_PCRE)
+ ENDIF()
+- IF(NOT HAVE_PCRE_STACK_GUARD OR NOT PCRE_STACK_SIZE_OK OR
+- WITH_PCRE STREQUAL "bundled")
++ IF(NOT HAVE_PCRE OR WITH_PCRE STREQUAL "bundled")
+ IF (WITH_PCRE STREQUAL "system")
+ MESSAGE(FATAL_ERROR "system pcre is not found or unusable")
+ ENDIF()
diff --git a/external/subpack/utils/mariadb/patches/160-mips-machine.patch b/external/subpack/utils/mariadb/patches/160-mips-machine.patch
new file mode 100644
index 0000000..06d6dd5
--- /dev/null
+++ b/external/subpack/utils/mariadb/patches/160-mips-machine.patch
@@ -0,0 +1,21 @@
+From: Debian MySQL Maintainers <pkg-mysql-maint@lists.alioth.debian.org>
+Date: Thu, 10 Aug 2017 20:40:29 +0200
+Subject: mips-machine
+
+---
+ cmake/package_name.cmake | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/cmake/package_name.cmake
++++ b/cmake/package_name.cmake
+@@ -34,6 +34,10 @@ IF(NOT VERSION)
+ SET(DEFAULT_MACHINE "mips")
+ ENDIF()
+
++ IF(NOT 64BIT AND CMAKE_SYSTEM_PROCESSOR MATCHES "^mips64")
++ SET(DEFAULT_MACHINE "mips")
++ ENDIF()
++
+ IF(CMAKE_SYSTEM_NAME MATCHES "Windows")
+ SET(NEED_DASH_BETWEEN_PLATFORM_AND_MACHINE 0)
+ SET(DEFAULT_PLATFORM "win")
diff --git a/external/subpack/utils/mariadb/patches/170-ppc-remove-glibc-dep.patch b/external/subpack/utils/mariadb/patches/170-ppc-remove-glibc-dep.patch
new file mode 100644
index 0000000..46431d3
--- /dev/null
+++ b/external/subpack/utils/mariadb/patches/170-ppc-remove-glibc-dep.patch
@@ -0,0 +1,45 @@
+--- a/include/my_cpu.h
++++ b/include/my_cpu.h
+@@ -24,17 +24,16 @@
+ */
+
+ #ifdef _ARCH_PWR8
+-#include <sys/platform/ppc.h>
+ /* Very low priority */
+-#define HMT_very_low() __ppc_set_ppr_very_low()
++#define HMT_very_low() asm volatile("or 31,31,31")
+ /* Low priority */
+-#define HMT_low() __ppc_set_ppr_low()
++#define HMT_low() asm volatile ("or 1,1,1")
+ /* Medium low priority */
+-#define HMT_medium_low() __ppc_set_ppr_med_low()
++#define HMT_medium_low() asm volatile ("or 6,6,6")
+ /* Medium priority */
+-#define HMT_medium() __ppc_set_ppr_med()
++#define HMT_medium() asm volatile ("or 2,2,2")
+ /* Medium high priority */
+-#define HMT_medium_high() __ppc_set_ppr_med_high()
++#define HMT_medium_high() asm volatile("or 5,5,5")
+ /* High priority */
+ #define HMT_high() asm volatile("or 3,3,3")
+ #else
+@@ -80,7 +79,7 @@ static inline void MY_RELAX_CPU(void)
+ __asm__ __volatile__ ("pause");
+ #endif
+ #elif defined(_ARCH_PWR8)
+- __ppc_get_timebase();
++ __builtin_ppc_get_timebase();
+ #elif defined __GNUC__ && (defined __arm__ || defined __aarch64__)
+ /* Mainly, prevent the compiler from optimizing away delay loops */
+ __asm__ __volatile__ ("":::"memory");
+--- a/storage/tokudb/PerconaFT/portability/toku_time.h
++++ b/storage/tokudb/PerconaFT/portability/toku_time.h
+@@ -124,7 +124,7 @@ static inline tokutime_t toku_time_now(v
+ __asm __volatile__ ("mrs %[rt], cntvct_el0" : [rt] "=r" (result));
+ return result;
+ #elif defined(__powerpc__)
+- return __ppc_get_timebase();
++ return __builtin_ppc_get_timebase();
+ #else
+ #error No timer implementation for this platform
+ #endif
diff --git a/external/subpack/utils/mariadb/patches/180-relax-mysql_install-db-wrt-pam-tool.patch b/external/subpack/utils/mariadb/patches/180-relax-mysql_install-db-wrt-pam-tool.patch
new file mode 100644
index 0000000..fe9adbd
--- /dev/null
+++ b/external/subpack/utils/mariadb/patches/180-relax-mysql_install-db-wrt-pam-tool.patch
@@ -0,0 +1,39 @@
+--- a/scripts/mysql_install_db.sh
++++ b/scripts/mysql_install_db.sh
+@@ -364,6 +364,14 @@ then
+ exit 1
+ fi
+ plugindir=`find_in_dirs --dir auth_pam.so $basedir/lib*/plugin $basedir/lib*/mysql/plugin $basedir/lib/*/mariadb19/plugin`
++ # Upstream assumes all plugins will be always installed, but in OpenWrt we can
++ # install a server without plugins if we want to.
++ if test -z "$plugindir"
++ then
++ echo "Could not find plugin directory." >&2
++ echo "Will continue with \"/usr/lib/mariadb/plugin\"." >&2
++ plugindir=/usr/lib/mariadb/plugin
++ fi
+ pamtooldir=$plugindir
+ # relative from where the script was run for a relocatable install
+ elif test -n "$dirname0" -a -x "$rel_mysqld" -a ! "$rel_mysqld" -ef "@sbindir@/mysqld"
+@@ -488,7 +496,9 @@ do
+ fi
+ done
+
+-if test -n "$user"
++# There should be no need for this on OpenWrt. If this turns out to be a wrong guess then
++# we can revisit.
++if test -n ""
+ then
+ if test -z "$srcdir" -a "$in_rpm" -eq 0
+ then
+@@ -509,6 +519,10 @@ then
+ echo
+ fi
+ fi
++fi
++
++if test -n "$user"
++then
+ args="$args --user=$user"
+ fi
+
diff --git a/external/subpack/utils/mariadb/patches/190-replace-hostname-in-mysqld_safe.patch b/external/subpack/utils/mariadb/patches/190-replace-hostname-in-mysqld_safe.patch
new file mode 100644
index 0000000..3532a79
--- /dev/null
+++ b/external/subpack/utils/mariadb/patches/190-replace-hostname-in-mysqld_safe.patch
@@ -0,0 +1,29 @@
+--- a/scripts/mysqld_safe.sh
++++ b/scripts/mysqld_safe.sh
+@@ -247,7 +247,7 @@ wsrep_recover_position() {
+ return 1
+ fi
+
+- local wr_pidfile="$DATADIR/"`@HOSTNAME@`"-recover.pid"
++ local wr_pidfile="$DATADIR/"$(uci get 'system.@system[0].hostname')"-recover.pid"
+
+ local wr_options="--disable-log-error --pid-file='$wr_pidfile'"
+
+@@ -668,7 +668,7 @@ then
+ * ) err_log="$DATADIR/$err_log" ;;
+ esac
+ else
+- err_log=$DATADIR/`@HOSTNAME@`.err
++ err_log=$DATADIR/$(uci get 'system.@system[0].hostname').err
+ fi
+ fi
+
+@@ -754,7 +754,7 @@ fi
+
+ if test -z "$pid_file"
+ then
+- pid_file="`@HOSTNAME@`.pid"
++ pid_file="$(uci get 'system.@system[0].hostname').pid"
+ fi
+ # MariaDB wants pid file without datadir
+ append_arg_to_args "--pid-file=$pid_file"
diff --git a/external/subpack/utils/mariadb/patches/200-no-selinux.patch b/external/subpack/utils/mariadb/patches/200-no-selinux.patch
new file mode 100644
index 0000000..e984000
--- /dev/null
+++ b/external/subpack/utils/mariadb/patches/200-no-selinux.patch
@@ -0,0 +1,11 @@
+--- a/support-files/CMakeLists.txt
++++ b/support-files/CMakeLists.txt
+@@ -62,7 +62,7 @@ IF(UNIX)
+ INSTALL(FILES magic DESTINATION ${inst_location} COMPONENT SupportFiles)
+ INSTALL(DIRECTORY policy DESTINATION ${inst_location} COMPONENT SupportFiles)
+ FIND_PROGRAM(CHECKMODULE checkmodule)
+- FIND_PROGRAM(SEMODULE_PACKAGE semodule_package)
++# FIND_PROGRAM(SEMODULE_PACKAGE semodule_package)
+ MARK_AS_ADVANCED(CHECKMODULE SEMODULE_PACKAGE)
+
+ # Build pp files in policy/selinux