diff mbox

[7/7,v2] mysql: add mariadb galera cluster variant

Message ID 1436458921-4199-8-git-send-email-sylvain.raybaud@green-communications.fr
State Changes Requested
Headers show

Commit Message

Sylvain Raybaud July 9, 2015, 4:22 p.m. UTC
Signed-off-by: Sylvain Raybaud <sylvain.raybaud@green-communications.fr>
---
 .../mariadb-galera-01-fix_xtradb_cmakelist.patch   |  27 +++
 .../mariadb-galera-02-fix_innodb_cmakelist.patch   | 251 +++++++++++++++++++++
 package/mysql/Config.in                            |  43 +++-
 package/mysql/mariadb-galera-cluster.cnf           | 204 +++++++++++++++++
 package/mysql/mysql.hash                           |   2 +
 package/mysql/mysql.mk                             | 216 +++++++++++++++---
 6 files changed, 707 insertions(+), 36 deletions(-)
 create mode 100644 package/mysql/10.0.17/mariadb-galera-01-fix_xtradb_cmakelist.patch
 create mode 100644 package/mysql/10.0.17/mariadb-galera-02-fix_innodb_cmakelist.patch
 create mode 100644 package/mysql/mariadb-galera-cluster.cnf

Comments

Samuel Martin July 9, 2015, 9:56 p.m. UTC | #1
Hi Sylvain,

Here is a partial review (inlined).

But, overall, I feel like this implementation (essentially the *.mk
file) does not match the Buildroot way of doing things... :-/
Have you look at the virtual package infrastructure [1]?

On Thu, Jul 9, 2015 at 6:22 PM, Sylvain Raybaud
<sylvain.raybaud@green-communications.fr> wrote:
> Signed-off-by: Sylvain Raybaud <sylvain.raybaud@green-communications.fr>
> ---
>  .../mariadb-galera-01-fix_xtradb_cmakelist.patch   |  27 +++
>  .../mariadb-galera-02-fix_innodb_cmakelist.patch   | 251 +++++++++++++++++++++
>  package/mysql/Config.in                            |  43 +++-
>  package/mysql/mariadb-galera-cluster.cnf           | 204 +++++++++++++++++
>  package/mysql/mysql.hash                           |   2 +
>  package/mysql/mysql.mk                             | 216 +++++++++++++++---
>  6 files changed, 707 insertions(+), 36 deletions(-)
>  create mode 100644 package/mysql/10.0.17/mariadb-galera-01-fix_xtradb_cmakelist.patch
>  create mode 100644 package/mysql/10.0.17/mariadb-galera-02-fix_innodb_cmakelist.patch
>  create mode 100644 package/mysql/mariadb-galera-cluster.cnf
>
> diff --git a/package/mysql/10.0.17/mariadb-galera-01-fix_xtradb_cmakelist.patch b/package/mysql/10.0.17/mariadb-galera-01-fix_xtradb_cmakelist.patch
> new file mode 100644
> index 0000000..83eac77
> --- /dev/null
> +++ b/package/mysql/10.0.17/mariadb-galera-01-fix_xtradb_cmakelist.patch
> @@ -0,0 +1,27 @@
> +Do not perform test if the build is not requested anyway. The test may fail,
> +preventing building the whole package.
> +
The comment does not really reflect what is done in the patch:
- according to the comment: this change touch tests;
- AFAICS, this change disable a plugin.

Missing SoB line [2].

> +--- a/storage/xtradb/CMakeLists.txt    2014-10-30 16:24:33.160188627 +0100
> ++++ b/storage/xtradb/CMakeLists.txt    2014-10-30 16:25:09.060188829 +0100
> +@@ -470,12 +470,13 @@
> +   SET(WITH_INNOBASE_STORAGE_ENGINE TRUE)
> + ENDIF()
> +
> +-IF(XTRADB_OK)
> +-  MYSQL_ADD_PLUGIN(xtradb ${INNOBASE_SOURCES} STORAGE_ENGINE
> +-    DEFAULT
> +-    RECOMPILE_FOR_EMBEDDED
> +-    LINK_LIBRARIES ${ZLIB_LIBRARY} ${LINKER_SCRIPT})
> +-ELSE()
> +-  MESSAGE(FATAL_ERROR "Percona XtraDB is not supported on this platform")
> ++IF(NOT WITHOUT_XTRADB)
Does this boolean come from an option? it could.

> ++  IF(XTRADB_OK)
> ++    MYSQL_ADD_PLUGIN(xtradb ${INNOBASE_SOURCES} STORAGE_ENGINE
> ++      DEFAULT
> ++      RECOMPILE_FOR_EMBEDDED
> ++      LINK_LIBRARIES ${ZLIB_LIBRARY} ${LINKER_SCRIPT})
> ++  ELSE()
> ++    MESSAGE(FATAL_ERROR "Percona XtraDB is not supported on this platform")
> ++  ENDIF()
> + ENDIF()
> +-
> diff --git a/package/mysql/10.0.17/mariadb-galera-02-fix_innodb_cmakelist.patch b/package/mysql/10.0.17/mariadb-galera-02-fix_innodb_cmakelist.patch
> new file mode 100644
> index 0000000..1ddec5d
> --- /dev/null
> +++ b/package/mysql/10.0.17/mariadb-galera-02-fix_innodb_cmakelist.patch
> @@ -0,0 +1,251 @@
> +Use CHECK_C_SOURCE_COMPILES instead of CHECK_C_SOURCE_RUNS in order to be
> +cross-compile friendly.
> +In buildroot another solution (maybe better, maybe not) could be to use
> +BR2_ARCH_HAS_ATOMICS in order to determine the value of HAVE_IB_GCC_ATOMIC_BUILTINS_BYTE
> +and likes.
> +
Missing SoB line [2].

It makes sense to submit this patch upstream as well.

> +--- a/storage/innobase/CMakeLists.txt  2014-11-07 17:05:48.853208487 +0100
> ++++ b/storage/innobase/CMakeLists.txt  2014-11-07 17:11:38.061217839 +0100
> +@@ -58,100 +58,99 @@
> +
> + IF(NOT MSVC)
> + # either define HAVE_IB_GCC_ATOMIC_BUILTINS or not
> +-IF(NOT CMAKE_CROSSCOMPILING)
> +-  # workaround for gcc 4.1.2 RHEL5/x86, gcc atomic ops only work under -march=i686
> +-  IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "i686" AND CMAKE_COMPILER_IS_GNUCC AND
> +-     CMAKE_C_COMPILER_VERSION VERSION_LESS "4.1.3")
> +-    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=i686")
> +-    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=i686")
> +-  ENDIF()
> +-  CHECK_C_SOURCE_RUNS(
> +-  "
> +-  int main()
> +-  {
> +-    long      x;
> +-    long      y;
> +-    long      res;
> +-
> +-    x = 10;
> +-    y = 123;
> +-    res = __sync_bool_compare_and_swap(&x, x, y);
> +-    if (!res || x != y) {
> +-      return(1);
> +-    }
> +-
> +-    x = 10;
> +-    y = 123;
> +-    res = __sync_bool_compare_and_swap(&x, x + 1, y);
> +-    if (res || x != 10) {
> +-      return(1);
> +-    }
> +-    x = 10;
> +-    y = 123;
> +-    res = __sync_add_and_fetch(&x, y);
> +-    if (res != 123 + 10 || x != 123 + 10) {
> +-      return(1);
> +-    }
> +-    return(0);
> +-  }"
> +-  HAVE_IB_GCC_ATOMIC_BUILTINS
> +-  )
> +-  CHECK_C_SOURCE_RUNS(
> +-  "
> +-  int main()
> +-  {
> +-    long      res;
> +-    char      c;
> +-
> +-    c = 10;
> +-    res = __sync_lock_test_and_set(&c, 123);
> +-    if (res != 10 || c != 123) {
> +-      return(1);
> +-    }
> +-    return(0);
> +-  }"
> +-  HAVE_IB_GCC_ATOMIC_BUILTINS_BYTE
> +-  )
> +-  CHECK_C_SOURCE_RUNS(
> +-  "#include<stdint.h>
> +-  int main()
> +-  {
> +-    int64_t   x,y,res;
> +-
> +-    x = 10;
> +-    y = 123;
> +-    res = __sync_sub_and_fetch(&y, x);
> +-    if (res != y || y != 113) {
> +-      return(1);
> +-    }
> +-    res = __sync_add_and_fetch(&y, x);
> +-    if (res != y || y != 123) {
> +-      return(1);
> +-    }
> +-    return(0);
> +-  }"
> +-  HAVE_IB_GCC_ATOMIC_BUILTINS_64
> +-  )
> +-  CHECK_C_SOURCE_RUNS(
> +-  "#include<stdint.h>
> +-  int main()
> +-  {
> +-    __sync_synchronize();
> +-    return(0);
> +-  }"
> +-  HAVE_IB_GCC_SYNC_SYNCHRONISE
> +-  )
> +-  CHECK_C_SOURCE_RUNS(
> +-  "#include<stdint.h>
> +-  int main()
> +-  {
> +-    __atomic_thread_fence(__ATOMIC_ACQUIRE);
> +-    __atomic_thread_fence(__ATOMIC_RELEASE);
> +-    return(0);
> +-  }"
> +-  HAVE_IB_GCC_ATOMIC_THREAD_FENCE
> +-  )
> +-ENDIF()
> ++
> ++# workaround for gcc 4.1.2 RHEL5/x86, gcc atomic ops only work under -march=i686
> ++IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "i686" AND CMAKE_COMPILER_IS_GNUCC AND
> ++   CMAKE_C_COMPILER_VERSION VERSION_LESS "4.1.3")
> ++  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=i686")
> ++  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=i686")
> ++ENDIF()
> ++CHECK_C_SOURCE_COMPILES(
> ++"
> ++int main()
> ++{
> ++  long        x;
> ++  long        y;
> ++  long        res;
> ++
> ++  x = 10;
> ++  y = 123;
> ++  res = __sync_bool_compare_and_swap(&x, x, y);
> ++  if (!res || x != y) {
> ++    return(1);
> ++  }
> ++
> ++  x = 10;
> ++  y = 123;
> ++  res = __sync_bool_compare_and_swap(&x, x + 1, y);
> ++  if (res || x != 10) {
> ++    return(1);
> ++  }
> ++  x = 10;
> ++  y = 123;
> ++  res = __sync_add_and_fetch(&x, y);
> ++  if (res != 123 + 10 || x != 123 + 10) {
> ++    return(1);
> ++  }
> ++  return(0);
> ++}"
> ++HAVE_IB_GCC_ATOMIC_BUILTINS
> ++)
> ++CHECK_C_SOURCE_COMPILES(
> ++"
> ++int main()
> ++{
> ++  long        res;
> ++  char        c;
> ++
> ++  c = 10;
> ++  res = __sync_lock_test_and_set(&c, 123);
> ++  if (res != 10 || c != 123) {
> ++    return(1);
> ++  }
> ++  return(0);
> ++}"
> ++HAVE_IB_GCC_ATOMIC_BUILTINS_BYTE
> ++)
> ++CHECK_C_SOURCE_COMPILES(
> ++"#include<stdint.h>
> ++int main()
> ++{
> ++  int64_t     x,y,res;
> ++
> ++  x = 10;
> ++  y = 123;
> ++  res = __sync_sub_and_fetch(&y, x);
> ++  if (res != y || y != 113) {
> ++    return(1);
> ++  }
> ++  res = __sync_add_and_fetch(&y, x);
> ++  if (res != y || y != 123) {
> ++    return(1);
> ++  }
> ++  return(0);
> ++}"
> ++HAVE_IB_GCC_ATOMIC_BUILTINS_64
> ++)
> ++CHECK_C_SOURCE_COMPILES(
> ++"#include<stdint.h>
> ++int main()
> ++{
> ++  __sync_synchronize();
> ++  return(0);
> ++}"
> ++HAVE_IB_GCC_SYNC_SYNCHRONISE
> ++)
> ++CHECK_C_SOURCE_COMPILES(
> ++"#include<stdint.h>
> ++int main()
> ++{
> ++  __atomic_thread_fence(__ATOMIC_ACQUIRE);
> ++  __atomic_thread_fence(__ATOMIC_RELEASE);
> ++return(0);
> ++}"
> ++HAVE_IB_GCC_ATOMIC_THREAD_FENCE
> ++)
> +
> + IF(HAVE_IB_GCC_ATOMIC_BUILTINS)
> +  ADD_DEFINITIONS(-DHAVE_IB_GCC_ATOMIC_BUILTINS=1)
> +@@ -173,28 +172,26 @@
> +  ADD_DEFINITIONS(-DHAVE_IB_GCC_ATOMIC_THREAD_FENCE=1)
> + ENDIF()
> +
> +- # either define HAVE_IB_ATOMIC_PTHREAD_T_GCC or not
> +-IF(NOT CMAKE_CROSSCOMPILING)
> +-  CHECK_C_SOURCE_RUNS(
> +-  "
> +-  #include <pthread.h>
> +-  #include <string.h>
> +-
> +-  int main() {
> +-    pthread_t       x1;
> +-    pthread_t       x2;
> +-    pthread_t       x3;
> +-
> +-    memset(&x1, 0x0, sizeof(x1));
> +-    memset(&x2, 0x0, sizeof(x2));
> +-    memset(&x3, 0x0, sizeof(x3));
> +-
> +-    __sync_bool_compare_and_swap(&x1, x2, x3);
> +-
> +-    return(0);
> +-  }"
> +-  HAVE_IB_ATOMIC_PTHREAD_T_GCC)
> +-ENDIF()
> ++# either define HAVE_IB_ATOMIC_PTHREAD_T_GCC or not
> ++CHECK_C_SOURCE_COMPILES(
> ++"
> ++#include <pthread.h>
> ++#include <string.h>
> ++
> ++int main() {
> ++  pthread_t       x1;
> ++  pthread_t       x2;
> ++  pthread_t       x3;
> ++
> ++  memset(&x1, 0x0, sizeof(x1));
> ++  memset(&x2, 0x0, sizeof(x2));
> ++  memset(&x3, 0x0, sizeof(x3));
> ++  __sync_bool_compare_and_swap(&x1, x2, x3);
> ++
> ++  return(0);
> ++}"
> ++HAVE_IB_ATOMIC_PTHREAD_T_GCC)
> ++
> + IF(HAVE_IB_ATOMIC_PTHREAD_T_GCC)
> +   ADD_DEFINITIONS(-DHAVE_IB_ATOMIC_PTHREAD_T_GCC=1)
> + ENDIF()
> diff --git a/package/mysql/Config.in b/package/mysql/Config.in
> index 7133892..a1a2d23 100644
> --- a/package/mysql/Config.in
> +++ b/package/mysql/Config.in
> @@ -1,8 +1,17 @@
>  config BR2_PACKAGE_MYSQL
> +       bool "mysql"
> +
> +if BR2_PACKAGE_MYSQL
> +choice
> +       prompt "MySQL database system implementation"
> +       default MYSQL_MYSQL
> +
> +config MYSQL_MYSQL
>         bool "MySQL"
>         depends on BR2_INSTALL_LIBSTDCPP
>         depends on BR2_USE_MMU # fork()
>         depends on BR2_TOOLCHAIN_HAS_THREADS
> +       depends on BR2_USE_MMU
duplicate, to be removed

>         select BR2_PACKAGE_NCURSES
>         select BR2_PACKAGE_READLINE
>         help
> @@ -10,7 +19,35 @@ config BR2_PACKAGE_MYSQL
>
>           http://www.mysql.com/
>
> -if BR2_PACKAGE_MYSQL
> +config MYSQL_MARIADB_GALERA
> +       bool "mariadb-galera"
> +       select BR2_PACKAGE_NCURSES
> +       select BR2_PACKAGE_OPENSSL
> +       select BR2_PACKAGE_ZLIB
> +       select BR2_PACKAGE_LIBAIO
> +       select BR2_PACKAGE_LIBTOOL
> +       select BR2_PACKAGE_GALERA
> +       select BR2_PACKAGE_BASH # runtime dependency only
> +       select BR2_PACKAGE_LSOF # runtime dependency only
> +       select BR2_PACKAGE_PROCPS_NG # runtime dependency only
> +       select BR2_PACKAGE_FINDUTILS # runtime dependency only
> +       select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
> +       depends on BR2_TOOLCHAIN_BUILDROOT_GLIBC || BR2_PACKAGE_EGLIBC # spawn()
Missing "depends on" for the selected packages [3].

> +       help
> +         MariaDB Galera Cluster.
> +         https://mariadb.com/kb/en/mariadb/what-is-mariadb-galera-cluster
> +
> +endchoice
> +
> +endif
> +
> +comment "MySQL needs a toolchain w/ C++, threads"
> +depends on !BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_HAS_THREADS
Indent is wrong.
Missing: depends on BR2_USE_MMU
Move this comment in the choice.

> +
> +comment "MariaDB needs an (e)glibc toolchain"
> +depends on !BR2_TOOLCHAIN_BUILDROOT_GLIBC && !BR2_PACKAGE_EGLIBC # spawn()
Indent is wrong.
Move this comment in the choice.

> +
> +if MYSQL_MYSQL
>
>  config BR2_PACKAGE_MYSQL_SERVER
>         bool "MySQL server"
> @@ -18,7 +55,3 @@ config BR2_PACKAGE_MYSQL_SERVER
>           Install the MySQL server on the target.
>
>  endif
> -
> -comment "MySQL needs a toolchain w/ C++, threads"
> -       depends on BR2_USE_MMU
> -       depends on !BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_HAS_THREADS

---- end of this review ----

> diff --git a/package/mysql/mariadb-galera-cluster.cnf b/package/mysql/mariadb-galera-cluster.cnf
> new file mode 100644
> index 0000000..c3eddaa
> --- /dev/null
> +++ b/package/mysql/mariadb-galera-cluster.cnf
> @@ -0,0 +1,204 @@
> +# MariaDB database server configuration file.
> +#
> +# You can copy this file to one of:
> +# - "/etc/mysql/my.cnf" to set global options,
> +# - "~/.my.cnf" to set user-specific options.
> +#
> +# One can use all long options that the program supports.
> +# Run program with --help to get a list of available options and with
> +# --print-defaults to see which it would actually understand and use.
> +#
> +# For explanations see
> +# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
> +
> +# This will be passed to all mysql clients
> +# It has been reported that passwords should be enclosed with ticks/quotes
> +# escpecially if they contain "#" chars...
> +# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
> +[client]
> +port           = 3306
> +socket         = /tmp/mysql.sock
> +
> +# Here is entries for some specific programs
> +# The following values assume you have at least 32M ram
> +
> +# This was formally known as [safe_mysqld]. Both versions are currently parsed.
> +[mysqld_safe]
> +socket         = /tmp/mysql.sock
> +nice           = 0
> +
> +[mysqld]
> +#
> +# * Basic Settings
> +#
> +user           = mysql
> +pid-file       = /tmp/mysql.pid
> +socket         = /tmp/mysql.sock
> +port           = 3306
> +basedir                = /usr
> +datadir                = /var/lib/mysql
> +tmpdir         = /tmp
> +lc_messages_dir        = /usr/share/
> +lc_messages    = en_US
> +skip-external-locking
> +
> +# Don't use DNS as it may not be available
> +skip-host-cache
> +skip-name-resolve
> +
> +#
> +# Instead of skip-networking the default is now to listen only on
> +# localhost which is more compatible and is not less secure.
> +#bind-address          = 127.0.0.1
> +#
> +# * Fine Tuning
> +#
> +max_connections                = 100
> +connect_timeout                = 5
> +wait_timeout           = 600
> +max_allowed_packet     = 16M
> +thread_cache_size       = 128
> +sort_buffer_size       = 4M
> +bulk_insert_buffer_size        = 16M
> +tmp_table_size         = 32M
> +max_heap_table_size    = 32M
> +#
> +# * MyISAM
> +#
> +# This replaces the startup script and checks MyISAM tables if needed
> +# the first time they are touched. On error, make copy and try a repair.
> +myisam_recover          = BACKUP
> +key_buffer_size                = 64M
> +#open-files-limit      = 2000
> +table_open_cache       = 400
> +myisam_sort_buffer_size        = 64M
> +concurrent_insert      = 2
> +read_buffer_size       = 2M
> +read_rnd_buffer_size   = 1M
> +#
> +# * Query Cache Configuration
> +#
> +# Cache only tiny result sets, so we can fit more in the query cache.
> +query_cache_limit              = 128K
> +query_cache_size               = 16M
> +# for more write intensive setups, set to DEMAND or OFF
> +#query_cache_type              = DEMAND
> +#
> +# * Logging and Replication
> +#
> +# Both location gets rotated by the cronjob.
> +# Be aware that this log type is a performance killer.
> +# As of 5.1 you can enable the log at runtime!
> +#general_log_file        = /var/lib/mysql/mysql.log
> +#general_log             = 1
> +#
> +# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
> +#
> +# we do want to know about network errors and such
> +log_warnings           = 2
> +#
> +# Enable the slow query log to see queries with especially long duration
> +#slow_query_log[={0|1}]
> +slow_query_log_file    = /var/lib/mysql/mariadb-slow.log
> +long_query_time = 10
> +#log_slow_rate_limit   = 1000
> +log_slow_verbosity     = query_plan
> +
> +#log-queries-not-using-indexes
> +#log_slow_admin_statements
> +#
> +# The following can be used as easy to replay backup logs or for replication.
> +# note: if you are setting up a replication slave, see README.Debian about
> +#       other settings you may need to change.
> +#server-id             = 1
> +#report_host           = master1
> +#auto_increment_increment = 2
> +#auto_increment_offset = 1
> +log_bin                        = /var/lib/mysql/mariadb-bin
> +log_bin_index          = /var/lib/mysql/mariadb-bin.index
> +# not fab for performance, but safer
> +#sync_binlog           = 1
> +expire_logs_days       = 10
> +max_binlog_size         = 100M
> +# slaves
> +#relay_log             = /var/lib/mysql/relay-bin
> +#relay_log_index       = /var/lib/mysql/relay-bin.index
> +#relay_log_info_file   = /var/lib/mysql/relay-bin.info
> +#log_slave_updates
> +#read_only
> +#
> +# If applications support it, this stricter sql_mode prevents some
> +# mistakes like inserting invalid dates etc.
> +#sql_mode              = NO_ENGINE_SUBSTITUTION,TRADITIONAL
> +#
> +# * InnoDB
> +#
> +# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
> +# Read the manual for more InnoDB related options. There are many!
> +default_storage_engine = InnoDB
> +# you can't just change log file size, requires special procedure
> +#innodb_log_file_size  = 50M
> +innodb_buffer_pool_size        = 64M
> +innodb_log_buffer_size = 8M
> +innodb_file_per_table  = 1
> +innodb_open_files      = 400
> +innodb_io_capacity     = 400
> +innodb_flush_method    = O_DIRECT
> +#
> +# * Security Features
> +#
> +# Read the manual, too, if you want chroot!
> +# chroot = /var/lib/mysql/
> +#
> +# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
> +#
> +# ssl-ca=/etc/mysql/cacert.pem
> +# ssl-cert=/etc/mysql/server-cert.pem
> +# ssl-key=/etc/mysql/server-key.pem
> +
> +#
> +# * Galera-related settings
> +#
> +
> +[galera]
> +# Mandatory settings
> +
> +# use InnoDB instead of XtraDB
> +ignore_builtin_innodb
> +innodb_autoinc_lock_mode=2
> +innodb_doublewrite=1
> +
> +plugin_load=innodb=ha_innodb.so
> +plugin_dir=/usr/lib/plugin
> +
> +wsrep_provider=/usr/lib/libgalera_smm.so
> +binlog_format=row
> +default_storage_engine=InnoDB
> +
> +query_cache_size=0 # mandatory only for versions prior to 5.5.40-galera, 10.0.14-galera and 10.1.2
> +wsrep_on=ON        # Enable wsrep replication
> +#wsrep_cluster_name=
> +#wsrep_cluster_address=
> +wsrep_sst_method=rsync
> +
> +#
> +# Optional setting
> +#wsrep_slave_threads=1
> +#innodb_flush_log_at_trx_commit=0
> +
> +[mysqldump]
> +quick
> +quote-names
> +max_allowed_packet     = 16M
> +
> +[mysql]
> +#no-auto-rehash        # faster start of mysql but no tab completition
> +
> +[isamchk]
> +key_buffer             = 16M
> +
> +#
> +# * IMPORTANT: Additional settings that can override those from this file!
> +#   The files must end with '.cnf', otherwise they'll be ignored.
> +#
> +!includedir /etc/mysql/conf.d/
> diff --git a/package/mysql/mysql.hash b/package/mysql/mysql.hash
> index 84f3361..d9f3574 100644
> --- a/package/mysql/mysql.hash
> +++ b/package/mysql/mysql.hash
> @@ -1,2 +1,4 @@
>  # From https://downloads.mariadb.com/archives/mysql-5.1/mysql-5.1.73.tar.gz.md5
>  md5    887f869bcc757957067b9198f707f32f        mysql-5.1.73.tar.gz
> +# From: https://downloads.mariadb.org/interstitial/mariadb-galera-10.0.17/source/mariadb-galera-10.0.17.tar.gz
> +sha1    91b70d19fb687a58f0e40f50608071489743e54e       mariadb-galera-10.0.17.tar.gz
> diff --git a/package/mysql/mysql.mk b/package/mysql/mysql.mk
> index 8718193..9abf50e 100644
> --- a/package/mysql/mysql.mk
> +++ b/package/mysql/mysql.mk
> @@ -4,17 +4,24 @@
>  #
>  ################################################################################
>
> -MYSQL_VERSION_MAJOR = 5.1
> -MYSQL_VERSION = $(MYSQL_VERSION_MAJOR).73
> -MYSQL_SOURCE = mysql-$(MYSQL_VERSION).tar.gz
> -MYSQL_SITE = http://downloads.skysql.com/archives/mysql-$(MYSQL_VERSION_MAJOR)
> -MYSQL_INSTALL_STAGING = YES
> -MYSQL_DEPENDENCIES = readline ncurses
> -MYSQL_AUTORECONF = YES
> -MYSQL_LICENSE = GPLv2
> -MYSQL_LICENSE_FILES = README COPYING
> -
> -MYSQL_CONF_ENV = \
> +################################################################################
> +#
> +# mysql implementation
> +#
> +################################################################################
> +
> +
> +MYSQL_MYSQL_VERSION_MAJOR = 5.1
> +MYSQL_MYSQL_VERSION = $(MYSQL_MYSQL_VERSION_MAJOR).73
> +MYSQL_MYSQL_SOURCE = mysql-$(MYSQL_MYSQL_VERSION).tar.gz
> +MYSQL_MYSQL_SITE = http://downloads.skysql.com/archives/mysql-$(MYSQL_MYSQL_VERSION_MAJOR)
> +MYSQL_MYSQL_INSTALL_STAGING = YES
> +MYSQL_MYSQL_DEPENDENCIES = readline ncurses
> +MYSQL_MYSQL_AUTORECONF = YES
> +MYSQL_MYSQL_LICENSE = GPLv2
> +MYSQL_MYSQL_LICENSE_FILES = README COPYING
> +
> +MYSQL_MYSQL_CONF_ENV = \
>         ac_cv_sys_restartable_syscalls=yes \
>         ac_cv_path_PS=/bin/ps \
>         ac_cv_FIND_PROC="/bin/ps p \$\$PID | grep -v grep | grep mysqld > /dev/null" \
> @@ -23,7 +30,7 @@ MYSQL_CONF_ENV = \
>         ac_cv_have_decl_HAVE_IB_GCC_ATOMIC_BUILTINS=yes \
>         mysql_cv_new_rl_interface=yes
>
> -MYSQL_CONF_OPTS = \
> +MYSQL_MYSQL_CONF_OPTS = \
>         --without-ndb-binlog \
>         --without-docs \
>         --without-man \
> @@ -34,22 +41,22 @@ MYSQL_CONF_OPTS = \
>         --disable-mysql-maintainer-mode
>
>  ifeq ($(BR2_PACKAGE_OPENSSL),y)
> -MYSQL_DEPENDENCIES += openssl
> +MYSQL_MYSQL_DEPENDENCIES += openssl
>  endif
>
>  ifeq ($(BR2_PACKAGE_ZLIB),y)
> -MYSQL_DEPENDENCIES += zlib
> +MYSQL_MYSQL_DEPENDENCIES += zlib
>  endif
>
>  ifeq ($(BR2_PACKAGE_MYSQL_SERVER),y)
> -MYSQL_DEPENDENCIES += host-mysql host-bison
> -HOST_MYSQL_DEPENDENCIES = host-zlib host-ncurses
> +MYSQL_MYSQL_DEPENDENCIES += host-mysql host-bison
> +HOST_MYSQL_MYSQL_DEPENDENCIES = host-zlib host-ncurses
>
> -HOST_MYSQL_CONF_OPTS = \
> +HOST_MYSQL_MYSQL_CONF_OPTS = \
>         --with-embedded-server \
>         --disable-mysql-maintainer-mode
>
> -MYSQL_CONF_OPTS += \
> +MYSQL_MYSQL_CONF_OPTS += \
>         --localstatedir=/var/mysql \
>         --with-atomic-ops=up \
>         --with-embedded-server \
> @@ -69,12 +76,12 @@ MYSQL_CONF_OPTS += \
>  # Debugging is only available for the server, so no need for
>  # this if-block outside of the server if-block
>  ifeq ($(BR2_ENABLE_DEBUG),y)
> -MYSQL_CONF_OPTS += --with-debug=full
> +MYSQL_MYSQL_CONF_OPTS += --with-debug=full
>  else
> -MYSQL_CONF_OPTS += --without-debug
> +MYSQL_MYSQL_CONF_OPTS += --without-debug
>  endif
>
> -define HOST_MYSQL_BUILD_CMDS
> +define HOST_MYSQL_MYSQL_BUILD_CMDS
>         $(MAKE) -C $(@D)/include my_config.h
>         $(MAKE) -C $(@D)/mysys libmysys.a
>         $(MAKE) -C $(@D)/strings libmystrings.a
> @@ -84,41 +91,188 @@ define HOST_MYSQL_BUILD_CMDS
>         $(MAKE) -C $(@D)/sql gen_lex_hash
>  endef
>
> -define HOST_MYSQL_INSTALL_CMDS
> +define HOST_MYSQL_MYSQL_INSTALL_CMDS
>         $(INSTALL) -m 0755  $(@D)/sql/gen_lex_hash  $(HOST_DIR)/usr/bin/
>  endef
>
> -define MYSQL_USERS
> +define MYSQL_MYSQL_USERS
>         mysql -1 nogroup -1 * /var/mysql - - MySQL daemon
>  endef
>
> -define MYSQL_ADD_FOLDER
> +define MYSQL_MYSQL_ADD_FOLDER
>         $(INSTALL) -d $(TARGET_DIR)/var/mysql
>  endef
>
> -MYSQL_POST_INSTALL_TARGET_HOOKS += MYSQL_ADD_FOLDER
> +MYSQL_MYSQL_POST_INSTALL_TARGET_HOOKS += MYSQL_ADD_FOLDER
>
> -define MYSQL_INSTALL_INIT_SYSV
> +define MYSQL_MYSQL_INSTALL_INIT_SYSV
>         $(INSTALL) -D -m 0755 package/mysql/S97mysqld \
>                 $(TARGET_DIR)/etc/init.d/S97mysqld
>  endef
>
>  else
> -MYSQL_CONF_OPTS += \
> +MYSQL_MYSQL_CONF_OPTS += \
>         --without-server
>  endif
>
>
> -define MYSQL_REMOVE_TEST_PROGS
> +define MYSQL_MYSQL_REMOVE_TEST_PROGS
>         rm -rf $(TARGET_DIR)/usr/mysql-test $(TARGET_DIR)/usr/sql-bench
>  endef
>
> -define MYSQL_ADD_MYSQL_LIB_PATH
> +define MYSQL_MYSQL_ADD_MYSQL_LIB_PATH
>         echo "/usr/lib/mysql" >> $(TARGET_DIR)/etc/ld.so.conf
>  endef
>
> -MYSQL_POST_INSTALL_TARGET_HOOKS += MYSQL_REMOVE_TEST_PROGS
> -MYSQL_POST_INSTALL_TARGET_HOOKS += MYSQL_ADD_MYSQL_LIB_PATH
> +MYSQL_MYSQL_POST_INSTALL_TARGET_HOOKS += MYSQL_MYSQL_REMOVE_TEST_PROGS
> +MYSQL_MYSQL_POST_INSTALL_TARGET_HOOKS += MYSQL_MYSQL_ADD_MYSQL_LIB_PATH
> +
> +################################################################################
> +#
> +# mariadb galera cluster implementation
> +#
> +################################################################################
> +
> +# According to MariaDB galera cluster documentation these options must be passed
> +# to CMake:
> +MYSQL_MARIADB_GALERA_CLUSTER_OPTS += "-DWITH_WSREP=1"
> +MYSQL_MARIADB_GALERA_CLUSTER_OPTS += "-DWITH_INNODB_DISALLOW_WRITES=1"
> +
> +# msgpack causes trouble when cross-compiling:
> +MYSQL_MARIADB_GALERA_EXTRA_OPTS += "-DGRN_WITH_MESSAGE_PACK=no"
> +
> +# Mroonga needs libstemmer. Some work still needs to be done before it can be
> +# included in buildroot. Disable it for now.
> +MYSQL_MARIADB_GALERA_EXTRA_OPTS += "-DWITHOUT_MROONGA=1"
> +
> +# This value is determined automatically during straight compile by compiling
> +# and running a test code. You cannot do that during cross-compile. However the
> +# stack grows downward in most if not all modern systems. The only exception I
> +# am aware of is PA-RISC which is not supported by buildroot. Therefore it makes
> +# sense to hardcode the value. If an arch is added the stack of which grows up
> +# one should expect unpredictable behavior at run time.
> +MYSQL_MARIADB_GALERA_EXTRA_OPTS += "-DSTACK_DIRECTION=-1"
> +
> +# XTRADB requires atomics intrinsic. MariaDB package tests for them by compiling
> +# and running C code which is not possible when cross-compiling. It is probably
> +# probably possible to use BR2_ARCH_HAS_ATOMIC_INTRINSICS instead of compiling
> +# and running some test code but for now we will just disable XTRADB.
> +MYSQL_MARIADB_GALERA_EXTRA_OPTS += "-DWITHOUT_XTRADB=1"
> +
> +# Jemalloc was added for TokuDB. Since its configure script seems somewhat broken
> +# when it comes to cross-compilation we shall disable it and also disable TokuDB.
> +MYSQL_MARIADB_GALERA_EXTRA_OPTS += "-DWITH_JEMALLOC=no -DWITHOUT_TOKUDB=1"
> +
> +MYSQL_MARIADB_GALERA_VERSION = 10.0.17
> +MYSQL_MARIADB_GALERA_SOURCE = mariadb-galera-$(MYSQL_MARIADB_GALERA_VERSION).tar.gz
> +MYSQL_MARIADB_GALERA_SITE = https://downloads.mariadb.org/interstitial/mariadb-galera-$(MYSQL_MARIADB_GALERA_VERSION)/source/
> +
> +# In order to cross-compile mariadb galera cluster one should first natively
> +# build in order to use some of the generated executables. They are then
> +# included by import_executables.cmake which is generated during the native
> +# build. Therefore host-mariadb-galera needs to be added to mariadb galera
> +# dependencies and
> +# -DIMPORT_EXECUTABLES=$(BUILD_DIR)/host-mariadb-galera/import_executables.cmake
> +# must be passed to cmake
> +MYSQL_MARIADB_GALERA_TARGET_BUILD_IMPORT += "-DIMPORT_EXECUTABLES=$(HOST_MYSQL_DIR)/import_executables.cmake"
> +
> +
> +MYSQL_MARIADB_GALERA_INSTALL_STAGING = NO
> +MYSQL_MARIADB_GALERA_INSTALL_TARGET = YES
> +
> +MYSQL_MARIADB_GALERA_DEPENDENCIES = \
> +       host-mysql \
> +       ncurses \
> +       openssl \
> +       zlib \
> +       libaio \
> +       libtool \
> +       galera
> +
> +MYSQL_MARIADB_GALERA_CONF_OPTS = $(MYSQL_MARIADB_GALERA_EXTRA_OPTS)
> +MYSQL_MARIADB_GALERA_CONF_OPTS += $(MYSQL_MARIADB_GALERA_TARGET_BUILD_IMPORT)
> +HOST_MYSQL_MARIADB_GALERA_CONF_OPTS = $(MYSQL_MARIADB_GALERA_EXTRA_OPTS)
> +
> +# Options specific to Galera cluster
> +MYSQL_MARIADB_GALERA_CONF_OPTS += $(MYSQL_MARIADB_GALERA_CLUSTER_OPTS)
> +HOST_MYSQL_MARIADB_GALERA_CONF_OPTS += $(MYSQL_MARIADB_GALERA_CLUSTER_OPTS)
> +
> +# Post install configuration
> +
> +define MYSQL_MARIADB_GALERA_USERS
> +       mysql 1000 mysql 1000 * /var/lib/mysql - - MySQL Server
> +endef
> +
> +define MYSQL_MARIADB_GALERA_INSTALL_CNF
> +       mkdir -p $(TARGET_DIR)/etc/mysql/conf.d
> +       install -m 644 package/mysql/mariadb-galera-cluster.cnf $(TARGET_DIR)/etc/mysql/my.cnf
> +endef
> +
> +MYSQL_MARIADB_GALERA_POST_INSTALL_TARGET_HOOKS += MYSQL_MARIADB_GALERA_INSTALL_CNF
>
> +define MYSQL_MARIADB_GALERA_INSTALL_INIT_SYSV
> +       $(INSTALL) -D -m 0755 $(@D)/support-files/mysql.server.sh \
> +               $(TARGET_DIR)/etc/init.d/mysqld
> +endef
> +
> +# generic options
> +
> +MYSQL_MARIADB_GALERA_AUTORECONF = NO
> +MYSQL_MARIADB_GALERA_LICENSE = GPLv2
> +MYSQL_MARIADB_GALERA_LICENSE_FILES = README COPYING COPYING.LESSER
> +
> +################################################################################
> +#
> +# meta package
> +#
> +################################################################################
> +
> +
> +ifeq ($(MYSQL_MYSQL),y)
> +       MYSQL_VERSION = $(MYSQL_MYSQL_VERSION)
> +       MYSQL_SOURCE = $(MYSQL_MYSQL_SOURCE)
> +       MYSQL_SITE = $(MYSQL_MYSQL_SITE)
> +       MYSQL_INSTALL_STAGING = $(MYSQL_MYSQL_INSTALL_STAGING)
> +       MYSQL_DEPENDENCIES = $(MYSQL_MYSQL_DEPENDENCIES)
> +       MYSQL_AUTORECONF = $(MYSQL_MYSQL_AUTORECONF)
> +       MYSQL_LICENSE = $(MYSQL_MYSQL_LICENSE)
> +       MYSQL_LICENSE_FILES = $(MYSQL_MYSQL_LICENSE_FILES)
> +       MYSQL_CONF_ENV = $(MYSQL_MYSQL_CONF_ENV)
> +       MYSQL_CONF_OPTS = $(MYSQL_MYSQL_CONF_OPTS)
> +
> +       MYSQL_USERS = $(MYSQL_MYSQL_USERS)
> +       MYSQL_POST_INSTALL_TARGET_HOOKS += $(MYSQL_MYSQL_POST_INSTALL_TARGET_HOOKS)
> +
> +       MYSQL_INSTALL_INIT_SYSV = $(MYSQL_MYSQL_INSTALL_INIT_SYSV)
> +
> +       HOST_MYSQL_DEPENDENCIES = $(HOST_MYSQL_MYSQL_DEPENDENCIES)
> +       HOST_MYSQL_CONF_OPTS = $(HOST_MYSQL_MYSQL_CONF_OPTS)
> +       HOST_MYSQL_BUILD_CMDS = $(HOST_MYSQL_MYSQL_BUILD_CMDS)
> +       HOST_MYSQL_INSTALL_CMDS = $(HOST_MYSQL_MYSQL_INSTALL_CMDS)
> +else ifeq ($(MYSQL_MARIADB_GALERA),y)
> +       MYSQL_VERSION = $(MYSQL_MARIADB_GALERA_VERSION)
> +       MYSQL_SOURCE = $(MYSQL_MARIADB_GALERA_SOURCE)
> +       MYSQL_SITE = $(MYSQL_MARIADB_GALERA_SITE)
> +       MYSQL_INSTALL_STAGING = $(MYSQL_MARIADB_GALERA_INSTALL_STAGING)
> +       MYSQL_DEPENDENCIES = $(MYSQL_MARIADB_GALERA_DEPENDENCIES)
> +       MYSQL_AUTORECONF = $(MYSQL_MARIADB_GALERA_AUTORECONF)
> +       MYSQL_LICENSE = $(MYSQL_MARIADB_GALERA_LICENSE)
> +       MYSQL_LICENSE_FILES = $(MYSQL_MARIADB_GALERA_LICENSE_FILES)
> +       MYSQL_CONF_OPTS = $(MYSQL_MARIADB_GALERA_CONF_OPTS)
> +
> +       MYSQL_USERS = $(MYSQL_MARIADB_GALERA_USERS)
> +       MYSQL_POST_INSTALL_TARGET_HOOKS += $(MYSQL_MARIADB_GALERA_POST_INSTALL_TARGET_HOOKS)
> +
> +       MYSQL_INSTALL_INIT_SYSV = $(MYSQL_MARIADB_GALERA_INSTALL_INIT_SYSV)
> +
> +       HOST_MYSQL_DEPENDENCIES = $(HOST_MYSQL_MARIADB_GALERA_DEPENDENCIES)
> +       HOST_MYSQL_CONF_OPTS = $(HOST_MYSQL_MARIADB_GALERA_CONF_OPTS)
> +endif
> +
> +ifeq ($(MYSQL_MYSQL),y)
>  $(eval $(autotools-package))
>  $(eval $(host-autotools-package))
> +else ifeq ($(MYSQL_MARIADB_GALERA),y)
> +$(eval $(host-cmake-package))
> +$(eval $(cmake-package))
> +endif
> --
> 1.9.1
>
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot


[1] http://nightly.buildroot.org/manual.html#_infrastructure_for_virtual_packages
[2] http://nightly.buildroot.org/manual.html#_format_and_licensing_of_the_package_patches
[3] http://nightly.buildroot.org/manual.html#depends-on-vs-select

Regards,
Thomas Petazzoni July 10, 2015, 7:54 a.m. UTC | #2
Dear Samuel Martin,

On Thu, 9 Jul 2015 23:56:25 +0200, Samuel Martin wrote:

> Here is a partial review (inlined).
> 
> But, overall, I feel like this implementation (essentially the *.mk
> file) does not match the Buildroot way of doing things... :-/
> Have you look at the virtual package infrastructure [1]?

Fully agreed. Using the same package for both MySQL and MariaDB would
make sense if their build system was similar. But it's completely
different, so it really needs to be two separate packages.

Then, if their client libraries are compatible, so that client
applications can use either MySQL or MariaDB with no change, then doing
a virtual package is indeed the right direction.

Best regards,

Thomas
Sylvain Raybaud Aug. 7, 2015, 1:44 p.m. UTC | #3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thomas, Samuel, all

Back working on this after some time off. I've made some of the fixes
you suggested. I've got a question about this one.

On 10/07/2015 09:54, Thomas Petazzoni wrote:
> Dear Samuel Martin,
> 
> On Thu, 9 Jul 2015 23:56:25 +0200, Samuel Martin wrote:
> 
>> Here is a partial review (inlined).
>> 
>> But, overall, I feel like this implementation (essentially the
>> *.mk file) does not match the Buildroot way of doing things...
>> :-/ Have you look at the virtual package infrastructure [1]?
> 
> Fully agreed. Using the same package for both MySQL and MariaDB
> would make sense if their build system was similar. But it's
> completely different, so it really needs to be two separate
> packages.
> 
> Then, if their client libraries are compatible, so that client 
> applications can use either MySQL or MariaDB with no change, then
> doing a virtual package is indeed the right direction.
> 
> Best regards,
> 
> Thomas
> 

OK I can make a virtual package, that seems to make sense. However,
according to section 17.11.6, it seems that I'll have to patch all
packages that depend on mysql, because there is some special magic to
add in the depender's Config.in, am I right? Is this the way to go?

Cheers,

- -- 
Sylvain Raybaud
www.green-communications.fr
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBAgAGBQJVxLZaAAoJEEkkwl4JtJ9ylCEP/Am9kDIzaEj8fEC+q9pfjq5s
Bxo80/MJrg7jgWGK/82/aaXShAhA0q9MDDB1vwIFKz+jsDiuHcuqWWzrXl0RhNpb
Rlwk+pcJFvBKXBHX0b7p+8etVneAdvlr0avWfkdfNKqo1ARXrpfyp0kmbIaAfjPc
PqgxXK7DlV7inJ6dtvA4ziJ9KAb90P4dG07xmogOfJhFLRujRapaVhEobyeoMdl+
CXUJEJakulxShHTmi7F6JYZyLx2XWsB/O1580I0PszrUniuQjPT7bDWYqX8yABki
pSVpGA20g8k10q3Y3GIE6cY37/YtuazPNIQUZI1WvTzkIrv28qGM73BFJQ6eSrz9
2tHCW0zSYDOZTgxSfjODxhCZJOIYqHKV2X4ZlAiOIAAGXpcOogy+ctGJkNVJF98e
mQsBf0Mb95WZYfJt4DbIGCsSIwFnEuzs6TM7PZBtO6/z6sRFJ7/11zmD9lnezJjD
dhYpXkfMwLTYNkpqJWoIW+KLvi9JenuGKkFW+9e9sumwjFfXSkakEIDWY+mkjUgE
izgNoMB4CBrkwry5H+OsE5VJi+OBsfhEyG8CbV36JZphXgAqNmBde485aRnFHbeb
CgkHklSg1PRYpuILO6CrbP6zjXbpAh/73CMJoL0Ym12ttD/7QcElQW8kiAHIN2P7
4NQVPFV3eMZPmXXofhbu
=2TBq
-----END PGP SIGNATURE-----
Thomas Petazzoni Aug. 8, 2015, 8:43 a.m. UTC | #4
Dear Sylvain Raybaud,

On Fri, 07 Aug 2015 15:44:58 +0200, Sylvain Raybaud wrote:

> OK I can make a virtual package, that seems to make sense. However,
> according to section 17.11.6, it seems that I'll have to patch all
> packages that depend on mysql, because there is some special magic to
> add in the depender's Config.in, am I right? Is this the way to go?

We could do something like jpeg (virtual), libjpeg and jpeg-turbo. This
way, dependers can continue to do a "select BR2_PACKAGE_MYSQL", and
there is a "choice" in mysql/Config.in to choose between the original
MySQL or MariaDB. Of course the original MySQL package will have to be
renamed to some other name than mysql.

I think the mechanism where the package depending on the virtual
package do "depends on BR2_PACKAGE_HAS_<foo>" is very good for cases
like OpenGL and al. where we have potentially an arbitrary/unlimited
number of providers.

But for things like libjpeg/jpeg-turbo or mysql/mariadb, where we know
the choice will be limited to a few alternatives, it probably makes
sense to have something like libjpeg.

I've Cc'ed Yann, to get his opinion on the matter.

Thanks,

Thomas
Yann E. MORIN Aug. 8, 2015, 11:22 p.m. UTC | #5
Thomas, Sylvain, All,

On 2015-08-08 10:43 +0200, Thomas Petazzoni spake thusly:
> On Fri, 07 Aug 2015 15:44:58 +0200, Sylvain Raybaud wrote:
> > OK I can make a virtual package, that seems to make sense. However,
> > according to section 17.11.6, it seems that I'll have to patch all
> > packages that depend on mysql, because there is some special magic to
> > add in the depender's Config.in, am I right? Is this the way to go?
> 
> We could do something like jpeg (virtual), libjpeg and jpeg-turbo. This
> way, dependers can continue to do a "select BR2_PACKAGE_MYSQL", and
> there is a "choice" in mysql/Config.in to choose between the original
> MySQL or MariaDB. Of course the original MySQL package will have to be
> renamed to some other name than mysql.
> 
> I think the mechanism where the package depending on the virtual
> package do "depends on BR2_PACKAGE_HAS_<foo>" is very good for cases
> like OpenGL and al. where we have potentially an arbitrary/unlimited
> number of providers.
> 
> But for things like libjpeg/jpeg-turbo or mysql/mariadb, where we know
> the choice will be limited to a few alternatives, it probably makes
> sense to have something like libjpeg.
> 
> I've Cc'ed Yann, to get his opinion on the matter.

Well, I never much liked the way the jpeg package has been done.

I do understand that it makes it just work great for users. However,
that was not the way virtual packages were supposed to work; it's
just a (bad) hack (which in fact predates the actual virtual package
infra, IIRC).

And it's a hack that prevents a br2-external from providing its own
jpeg implementation (e.g. one optimised to make use of a specific SoC
hardware, for example).

Now, the mariadb vs. mysql case might not be so problematic. We don't
much expect a myriad of alternate implementations to just pop-up over
the night, and even less hardware-specific implementations. But who
knows? That's probably what we originally thought about the jpeg case,
and now I see at least one reason why we should not have done it that
way... Maybe some vendors have specially-crafted mysql /forks/ tailored
to specific use-cases (but do we care?)...

So, I'd rather that we just handle virtual packages like is done for the
GL case rather than the jpeg case (which I consider broken...)

Regards,
Yann E. MORIN.
Thomas Petazzoni Aug. 9, 2015, 8:46 a.m. UTC | #6
Hello,

On Sun, 9 Aug 2015 01:22:42 +0200, Yann E. MORIN wrote:

> Well, I never much liked the way the jpeg package has been done.
> 
> I do understand that it makes it just work great for users. However,
> that was not the way virtual packages were supposed to work; it's
> just a (bad) hack (which in fact predates the actual virtual package
> infra, IIRC).
> 
> And it's a hack that prevents a br2-external from providing its own
> jpeg implementation (e.g. one optimised to make use of a specific SoC
> hardware, for example).
> 
> Now, the mariadb vs. mysql case might not be so problematic. We don't
> much expect a myriad of alternate implementations to just pop-up over
> the night, and even less hardware-specific implementations. But who
> knows? That's probably what we originally thought about the jpeg case,
> and now I see at least one reason why we should not have done it that
> way... Maybe some vendors have specially-crafted mysql /forks/ tailored
> to specific use-cases (but do we care?)...

Well, if you take this as an argument, then *all* packages should be
virtual packages. I know a customer that has custom versions of dbus
and directfb, for example. Should they be virtual packages because of
that?

> So, I'd rather that we just handle virtual packages like is done for the
> GL case rather than the jpeg case (which I consider broken...)

Well, for MySQL, I'm still not sure. The main drawback of going all the
way to the standard virtual package mechanism is that you can no longer
"select" MySQL from any other package. You can only use a "depends on"
dependency.

Thomas
Yann E. MORIN Aug. 9, 2015, 12:59 p.m. UTC | #7
Thomas, All,

On 2015-08-09 10:46 +0200, Thomas Petazzoni spake thusly:
> On Sun, 9 Aug 2015 01:22:42 +0200, Yann E. MORIN wrote:
> > Well, I never much liked the way the jpeg package has been done.
> > 
> > I do understand that it makes it just work great for users. However,
> > that was not the way virtual packages were supposed to work; it's
> > just a (bad) hack (which in fact predates the actual virtual package
> > infra, IIRC).
> > 
> > And it's a hack that prevents a br2-external from providing its own
> > jpeg implementation (e.g. one optimised to make use of a specific SoC
> > hardware, for example).
> > 
> > Now, the mariadb vs. mysql case might not be so problematic. We don't
> > much expect a myriad of alternate implementations to just pop-up over
> > the night, and even less hardware-specific implementations. But who
> > knows? That's probably what we originally thought about the jpeg case,
> > and now I see at least one reason why we should not have done it that
> > way... Maybe some vendors have specially-crafted mysql /forks/ tailored
> > to specific use-cases (but do we care?)...
> 
> Well, if you take this as an argument, then *all* packages should be
> virtual packages.

Well, certainly not what I said.

> I know a customer that has custom versions of dbus
> and directfb, for example. Should they be virtual packages because of
> that?

"Custom versions" does not count (at least if I understand it has "with
local changes when compared to upstream", in which case they would just
have to use OVERRIDE_SRCDIR for those packages, and manage populating
those overrides externally to Buildroot).

What I am talking about is "alternate implementations", as clearly
illustrated by the GL case. GL is the most prominent example of such
alternate implementations; jpeg should also fall into this category.

Remember we had a case for adding an accelerated jpeg implementation,
specific to the freescale iMX CPUs a while back, for example.

> > So, I'd rather that we just handle virtual packages like is done for the
> > GL case rather than the jpeg case (which I consider broken...)
> 
> Well, for MySQL, I'm still not sure. The main drawback of going all the
> way to the standard virtual package mechanism is that you can no longer
> "select" MySQL from any other package. You can only use a "depends on"
> dependency.

Yes, I agree we have to draw a line somewhere.

I think the mysql vs. mariadb case would fall in the category "we do not
expect alternate implementations to pop up", and thus we can handle it
like is currently done for jpeg.

Regards,
Yann E. MORIN.
Sylvain Raybaud Aug. 20, 2015, 12:05 p.m. UTC | #8
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dear Thomas, Yann and all,

On 08/08/2015 10:43, Thomas Petazzoni wrote:
> Dear Sylvain Raybaud,
> 
> On Fri, 07 Aug 2015 15:44:58 +0200, Sylvain Raybaud wrote:
> 
>>> OK I can make a virtual package, that seems to make sense.
>>> However, according to section 17.11.6, it seems that I'll have
>>> to patch all packages that depend on mysql, because there is
>>> some special magic to add in the depender's Config.in, am I
>>> right? Is this the way to go?
> We could do something like jpeg (virtual), libjpeg and jpeg-turbo.
> This way, dependers can continue to do a "select
> BR2_PACKAGE_MYSQL", and there is a "choice" in mysql/Config.in to
> choose between the original MySQL or MariaDB.

Ok, I'm going that way.

Of course the original MySQL package will have to be
> renamed to some other name than mysql.

Does "original_mysql" sound good to you?

Cheers,

- -- 
Sylvain Raybaud
www.green-communications.fr
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBAgAGBQJV1cJuAAoJEEkkwl4JtJ9y/UIP/RPchCfWHqMmHhPGE3OwJ44K
4MVLtB3uVTCXOSPktU2dJh/UgUZ231NitQRp3VYXMyPace+2q+wU8ckJUIW5A4tm
BFwBsIEXI0axLUZJkwGFRRm15VGIcBKnYbEXwVay3hYAb2veBY9N2eSGs44CsDjF
Y1boB7mWSf9wJV7JYR3YkwFeNJMYr1G31bKeCCxEEXFRr9Yx7PDZdQZgn5C6osXE
pKJXnX8abrQz8TVRux+o4brUzGuVDYlOo1vdbdB2AMmV81WLqLSQy1c5u+4fwvxT
/LPnI6HcHbjHs6UN47NtorOxkp4qQT1l8G/WDTsopUwlTA5DQRXu9QcNH4dy5JtB
x0/80iV7t3LvrcuNv2y9Pb3BCRq0MRebzzQkz7AIYWzYtwWODzTa3Sxkavkg0yoZ
6ZygDWNNAwE0LYZkAuQZW1UGot63gwJsaGjhi1DdbrcWdbGMviScT2lu/PgEnlS2
QoqFfiU1LF7swrGxSCDQ7zYWif/aUzE+Tk7IjbgUyEJFOJNLHHursRCZkAo67F7F
vln2gpQhavWrCVtq2kqtjJTrqh2r6l3UXmrPXgVFI75YD87FC3P88IcDxYQNJVz9
aoIgXNwXWDI3RRDMOk1Kn01P8k4ymFjyBH3g76j7xPCAL87Zqop0W2+fSH9UYOID
d2IfI5N1VsBbyLfeBy2L
=hT7W
-----END PGP SIGNATURE-----
Thomas Petazzoni Aug. 20, 2015, 12:32 p.m. UTC | #9
Dear Sylvain Raybaud,

On Thu, 20 Aug 2015 14:05:02 +0200, Sylvain Raybaud wrote:

> Of course the original MySQL package will have to be
> > renamed to some other name than mysql.
> 
> Does "original_mysql" sound good to you?

I'd rather suggest 'oracle-mysql'.

Thanks,

Thomas
Sylvain Raybaud Aug. 21, 2015, 8:23 a.m. UTC | #10
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Samuel

Thanks for your review. Here are my replies to some points (also inlined).

On 09/07/2015 23:56, Samuel Martin wrote:
> Hi Sylvain,
> 
> Here is a partial review (inlined).
> 
> But, overall, I feel like this implementation (essentially the
> *.mk file) does not match the Buildroot way of doing things... :-/ 
> Have you look at the virtual package infrastructure [1]?

Considering your remark and the discussion that took place last week,
I repackaged the whole thing in the same way as jpeg.

> 
> On Thu, Jul 9, 2015 at 6:22 PM, Sylvain Raybaud

>> diff --git
>> a/package/mysql/10.0.17/mariadb-galera-01-fix_xtradb_cmakelist.patch
>> b/package/mysql/10.0.17/mariadb-galera-01-fix_xtradb_cmakelist.patch
>>
>> 
new file mode 100644
>> index 0000000..83eac77 --- /dev/null +++
>> b/package/mysql/10.0.17/mariadb-galera-01-fix_xtradb_cmakelist.patch
>>
>> 
@@ -0,0 +1,27 @@
>> +Do not perform test if the build is not requested anyway. The
>> test may fail, +preventing building the whole package. +
> The comment does not really reflect what is done in the patch: -
> according to the comment: this change touch tests; - AFAICS, this
> change disable a plugin.

No, I just enclose some commands in:

IF(NOT WITHOUT_XTRADB)
[..]
ENDIF()

Meaning: "if building XtraDB plugin was not requested, do not care
about the result of the test". This patch does not disable XtraDB.
This is done via an option passed in mariadb-galera.mk

> [..]

>> ++IF(NOT WITHOUT_XTRADB)
> Does this boolean come from an option? it could.
> 

It does. There is the following line in mariadb-galera.mk:

MARIADB_GALERA_EXTRA_OPTS += "-DWITHOUT_XTRADB=1"


[..]

>> diff --git
>> a/package/mysql/10.0.17/mariadb-galera-02-fix_innodb_cmakelist.patch
>> b/package/mysql/10.0.17/mariadb-galera-02-fix_innodb_cmakelist.patch
>>
>> 
new file mode 100644
>> index 0000000..1ddec5d --- /dev/null +++
>> b/package/mysql/10.0.17/mariadb-galera-02-fix_innodb_cmakelist.patch
>>
>> 
@@ -0,0 +1,251 @@
>> +Use CHECK_C_SOURCE_COMPILES instead of CHECK_C_SOURCE_RUNS in
>> order to be +cross-compile friendly. +In buildroot another
>> solution (maybe better, maybe not) could be to use 
>> +BR2_ARCH_HAS_ATOMICS in order to determine the value of
>> HAVE_IB_GCC_ATOMIC_BUILTINS_BYTE +and likes. +
> Missing SoB line [2].
> 
> It makes sense to submit this patch upstream as well.

Right. Does this mean we should wait for them to review this patch
before considering including it in buildroot?

> [..]
>> +config MYSQL_MARIADB_GALERA +       bool "mariadb-galera" +
>> select BR2_PACKAGE_NCURSES +       select BR2_PACKAGE_OPENSSL +
>> select BR2_PACKAGE_ZLIB +       select BR2_PACKAGE_LIBAIO +
>> select BR2_PACKAGE_LIBTOOL +       select BR2_PACKAGE_GALERA +
>> select BR2_PACKAGE_BASH # runtime dependency only +       select
>> BR2_PACKAGE_LSOF # runtime dependency only +       select
>> BR2_PACKAGE_PROCPS_NG # runtime dependency only +       select
>> BR2_PACKAGE_FINDUTILS # runtime dependency only +       select
>> BR2_PACKAGE_BUSYBOX_SHOW_OTHERS +       depends on
>> BR2_TOOLCHAIN_BUILDROOT_GLIBC || BR2_PACKAGE_EGLIBC # spawn()
> Missing "depends on" for the selected packages [3].
> 
>> +       help +         MariaDB Galera Cluster. +
>> https://mariadb.com/kb/en/mariadb/what-is-mariadb-galera-cluster 
>> + +endchoice + +endif + +comment "MySQL needs a toolchain w/ C++,
>> threads" +depends on !BR2_INSTALL_LIBSTDCPP ||
>> !BR2_TOOLCHAIN_HAS_THREADS
> Indent is wrong. Missing: depends on BR2_USE_MMU Move this comment
> in the choice.

I don't understand how to properly move this in the choice section.
However I modified Config.in when I made mysql a virtual package. Does
this remark still apply?

> 
>> + +comment "MariaDB needs an (e)glibc toolchain" +depends on
>> !BR2_TOOLCHAIN_BUILDROOT_GLIBC && !BR2_PACKAGE_EGLIBC # spawn()
> Indent is wrong. Move this comment in the choice.

Same question about moving the comment.

Thanks again!

Cheers,

- -- 
Sylvain Raybaud
www.green-communications.fr
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBAgAGBQJV1uABAAoJEEkkwl4JtJ9yNCIP/ic8RsfhCdG56I3fH55KFDqi
ABnVSsYB3HP9vczjCfFzLQq3YbbTX1HMhB72L83OdyBoBmoUmEedXO9cOCcZw75q
Fer4OBgGhrl11uy3KvwH2E/nfGgVtjdiGSW0o+7mB041E/ix2E+SnlKwIQu9mTFS
4UZq7m7UpeWBQeMwRE3VpNnNCimpW+pcIXIjzMdbDMNfH5xAy6Da3OtJPay4vRBk
99PZ4Ly6wOcytRnTvuDOz2u8OMbb6GOshSTFyqDucenculWPada+fVa0QKWJlDMo
wFpLPv5HlcVKXcFZO8T+USK3GFnWgdjeJget1r8vXUUDzh/rEFD6VDCaYIC86dQN
pWHpqosPCUcd/d4q6hI1rutCO4w9djKmDDC8AFB2iPnwK7EuPV8AnWXE0RLMA+Rf
+CKoNG9D/yny3po37SouxajkIkg/3FOK/3cPVlTCEnMUiQtHh7Alcd6ll7CvTMEk
0gNA8Sia1vQ6B72O7ASJOfMCLQsOIiqXsODZhI9pFv2K5xGvap6E7LBShSuADE8o
qb7ig6wsTJnvdOBlDTyva7KPVQ4V/4nBQGT7njvsAtcwe46dNbYhIT2wRv7i7btW
5tBBy9HDZ8ex6AcM7pDaraU5gu6edEowRSTdZWLoM7SOBgNT8/USeRofVHBd4tgv
NMtaizcTJNxxjmiQSpwB
=UmBa
-----END PGP SIGNATURE-----
Arnout Vandecappelle Aug. 22, 2015, 10:21 p.m. UTC | #11
On 08/09/2015 01:22 AM, Yann E. MORIN wrote:
> Now, the mariadb vs. mysql case might not be so problematic. We don't
> much expect a myriad of alternate implementations to just pop-up over
> the night, 

 Well, actually... IIUC there are in fact two MariaDB implementations: the
cluster verion (Galera, added here) and the single-node version. Well, they
might actually be the same, but the download URLs are different.

 Sylvain, can you comment?


 That said, I don't see a big problem adding a third option to the choice
whenever the other mariadb is added.



> and even less hardware-specific implementations. But who
> knows? That's probably what we originally thought about the jpeg case,
> and now I see at least one reason why we should not have done it that
> way... Maybe some vendors have specially-crafted mysql /forks/ tailored
> to specific use-cases (but do we care?)...

 MariaDB already is a fork :-)


 BTW, regarding jpeg support in BR2_EXTERNAL, it could be supported but it gets
a bit complicated:

===== jpeg/Config.in =====
config BR2_PACKAGE_JPEG
	bool "jpeg support"

if BR2_PACKAGE_JPEG

choice
	prompt "jpeg variant"

config BR2_PACKAGE_LIBJPEG
	bool "jpeg"
	depends on !BR2_PACKAGE_EXTERNAL_JPEG_SELECTED
	select BR2_PACKAGE_HAS_JPEG

config BR2_PACKAGE_JPEG_TURBO
	bool "jpeg-turbo"
	depends on !BR2_PACKAGE_EXTERNAL_JPEG_SELECTED
	select BR2_PACKAGE_HAS_JPEG

# The following one will only be visible if we select an external JPEG library
# The other choices will vanish then.
config BR2_PACKAGE_EXTERNAL_JPEG
	bool "provided in BR2_EXTERNAL"
	depends on BR2_PACKAGE_EXTERNAL_JPEG_SELECTED
	select BR2_PACKAGE_HAS_JPEG

endchoice

config BR2_PACKAGE_HAS_JPEG
	bool

# This extra symbol is needed to be able to hide the internal ones
config BR2_PACKAGE_EXTERNAL_JPEG_SELECTED
	bool
	select BR2_PACKAGE_EXTERNAL_JPEG

config BR2_PACKAGE_PROVIDES_JPEG
	string
	default "libjpeg"    if BR2_PACKAGE_LIBJPEG
	default "jpeg-turbo" if BR2_PACKAGE_JPEG_TURBO

endif


==== BR2_EXTERNAL/try-this/Config.in ====
# This one actually looks like a normal virtual package
config BR2_PACKAGE_TRY_THIS
	bool "try this!"
	select BR2_PACKAGE_EXTERNAL_JPEG_SELECTED

config BR2_PACKAGE_PROVIDES_JPEG
	default "trythis" if BR2_PACKAGE_TRY_THIS

====


 Regards,
 Arnout
Sylvain Raybaud Aug. 24, 2015, 10:14 a.m. UTC | #12
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Arnout, Yann, all

On 23/08/2015 00:21, Arnout Vandecappelle wrote:
> On 08/09/2015 01:22 AM, Yann E. MORIN wrote:
>>> Now, the mariadb vs. mysql case might not be so problematic. We
>>> don't much expect a myriad of alternate implementations to just
>>> pop-up over the night,
> Well, actually... IIUC there are in fact two MariaDB
> implementations: the cluster verion (Galera, added here) and the
> single-node version. Well, they might actually be the same, but the
> download URLs are different.
> 
> Sylvain, can you comment?

That's right, there are two variants: MariaDB and MariaDB galera. The
later includes the capability of running as a cluster, when run with
the galera plugin. They are not the same but I haven't thoroughly
looked at the differences since it's the cluster I'm interested in. I
agree that ideally a third choice "mariadb" should be added. I've only
been focused on mariadb galera for now, but I don't think it's much
more work to add mariadb. Maybe I can do it after I'm done with
mariadb galera?

Cheers,

- -- 
Sylvain Raybaud
www.green-communications.fr
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBAgAGBQJV2u6EAAoJEEkkwl4JtJ9yrEMP/0G2yWR/AV8GJa+jW3p1Km3e
WuxJgvELUwgoL5gcPsjmqmBENBC19j0Z1StHDXefD3b91wv1NPxF/oJ/4yawNt0g
m22SWl3N0fMw4AAVM1m64wx/XdeJxU3usz3nDdQb1xC7675fOAFWmH4/PoSmFj/2
WsqB8IPh8GQWVOwJSTEOnTyXOCLSfTqsq643X3j88HwvSuHg52t3r7ObqbS8819E
H16eMFmD3qZbEr05hvRsHBEnXl0czrpFaEoc5zAui+CJgKS/oP+zkYNTRW/8gkgV
c0/LGHflQD+YsrmlamNWtqoC1p45/Zhy9shpMG4LEv9c9Us9UXiGwTFWmtyXzsta
wN+s6Po8JslkDRKYXB2M0AJ6aHWgbWDPe9kaOXI9maPIVlHTSKfGEUQHQaoz0kQn
04JvKlSjFlol7HUrvoA8Z08hefC90HkkGViEVy5csy01fN/WbkFwam0AvvpwIbOa
olFrwseslgnLba3OvnTY/4/GRKkq4m3ROycf/lTY/YhiZ8T9X3LflNm/tNYF7bYa
VOfIp7gEdQtp1/cJ/Srk/4F0VCMzB+2x40Evs+g2v/KNmSG2eNceem7bm2O+VKok
hSvZQRsMDkremwHb4KU5i14NFL/rkCnHLlmflvnWgV5JkGfD2Yoo/aQytHRzYXV/
BebcNtnMT7LYy7oOAYt0
=Y5rG
-----END PGP SIGNATURE-----
Sylvain Raybaud Aug. 26, 2015, 9:45 p.m. UTC | #13
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[sorry for the repost, but it looks like this email, originally sent
on 21st august, never made it to the list.]

Hi Samuel

Thanks for your review. Here are my replies to some points (also inlined).

On 09/07/2015 23:56, Samuel Martin wrote:
> Hi Sylvain,
> 
> Here is a partial review (inlined).
> 
> But, overall, I feel like this implementation (essentially the *.mk
> file) does not match the Buildroot way of doing things... :-/ Have
> you look at the virtual package infrastructure [1]?

Considering your remark and the discussion that took place last week,
I repackaged the whole thing in the same way as jpeg.

> 
> On Thu, Jul 9, 2015 at 6:22 PM, Sylvain Raybaud

>> diff --git 
>> a/package/mysql/10.0.17/mariadb-galera-01-fix_xtradb_cmakelist.patch
>>
>> 
b/package/mysql/10.0.17/mariadb-galera-01-fix_xtradb_cmakelist.patch
>> 
>> 
new file mode 100644
>> index 0000000..83eac77 --- /dev/null +++ 
>> b/package/mysql/10.0.17/mariadb-galera-01-fix_xtradb_cmakelist.patch
>>
>>
@@
>> 
- -0,0 +1,27 @@
>> +Do not perform test if the build is not requested anyway. The 
>> test may fail, +preventing building the whole package. +
> The comment does not really reflect what is done in the patch: - 
> according to the comment: this change touch tests; - AFAICS, this 
> change disable a plugin.

No, I just enclose some commands in:

IF(NOT WITHOUT_XTRADB)
[..]
ENDIF()

Meaning: "if building XtraDB plugin was not requested, do not care
about the result of the test". This patch does not disable XtraDB.
This is done via an option passed in mariadb-galera.mk

> [..]

>> ++IF(NOT WITHOUT_XTRADB)
> Does this boolean come from an option? it could.
> 

It does. There is the following line in mariadb-galera.mk:

MARIADB_GALERA_EXTRA_OPTS += "-DWITHOUT_XTRADB=1"


[..]

>> diff --git 
>> a/package/mysql/10.0.17/mariadb-galera-02-fix_innodb_cmakelist.patch
>>
>> 
b/package/mysql/10.0.17/mariadb-galera-02-fix_innodb_cmakelist.patch
>> 
>> 
new file mode 100644
>> index 0000000..1ddec5d --- /dev/null +++ 
>> b/package/mysql/10.0.17/mariadb-galera-02-fix_innodb_cmakelist.patch
>>
>>
@@
>> 
- -0,0 +1,251 @@
>> +Use CHECK_C_SOURCE_COMPILES instead of CHECK_C_SOURCE_RUNS in 
>> order to be +cross-compile friendly. +In buildroot another 
>> solution (maybe better, maybe not) could be to use 
>> +BR2_ARCH_HAS_ATOMICS in order to determine the value of 
>> HAVE_IB_GCC_ATOMIC_BUILTINS_BYTE +and likes. +
> Missing SoB line [2].
> 
> It makes sense to submit this patch upstream as well.

Right. Does this mean we should wait for them to review this patch
before considering including it in buildroot?

> [..]
>> +config MYSQL_MARIADB_GALERA +       bool "mariadb-galera" + 
>> select BR2_PACKAGE_NCURSES +       select BR2_PACKAGE_OPENSSL + 
>> select BR2_PACKAGE_ZLIB +       select BR2_PACKAGE_LIBAIO + 
>> select BR2_PACKAGE_LIBTOOL +       select BR2_PACKAGE_GALERA + 
>> select BR2_PACKAGE_BASH # runtime dependency only +       select 
>> BR2_PACKAGE_LSOF # runtime dependency only +       select 
>> BR2_PACKAGE_PROCPS_NG # runtime dependency only +       select 
>> BR2_PACKAGE_FINDUTILS # runtime dependency only +       select 
>> BR2_PACKAGE_BUSYBOX_SHOW_OTHERS +       depends on 
>> BR2_TOOLCHAIN_BUILDROOT_GLIBC || BR2_PACKAGE_EGLIBC # spawn()
> Missing "depends on" for the selected packages [3].
> 
>> +       help +         MariaDB Galera Cluster. + 
>> https://mariadb.com/kb/en/mariadb/what-is-mariadb-galera-cluster 
>> + +endchoice + +endif + +comment "MySQL needs a toolchain w/
>> C++, threads" +depends on !BR2_INSTALL_LIBSTDCPP || 
>> !BR2_TOOLCHAIN_HAS_THREADS
> Indent is wrong. Missing: depends on BR2_USE_MMU Move this comment 
> in the choice.

I don't understand how to properly move this in the choice section.
However I modified Config.in when I made mysql a virtual package. Does
this remark still apply?

> 
>> + +comment "MariaDB needs an (e)glibc toolchain" +depends on 
>> !BR2_TOOLCHAIN_BUILDROOT_GLIBC && !BR2_PACKAGE_EGLIBC # spawn()
> Indent is wrong. Move this comment in the choice.

Same question about moving the comment.

Thanks again!

Cheers,

- -- 
Sylvain Raybaud
www.green-communications.fr
Sylvain Raybaud Oct. 8, 2015, 3:15 p.m. UTC | #14
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Samuel

On 09/07/2015 23:56, Samuel Martin wrote:
>>> +--- a/storage/xtradb/CMakeLists.txt    2014-10-30
>>> 16:24:33.160188627 +0100 ++++ b/storage/xtradb/CMakeLists.txt
>>> 2014-10-30 16:25:09.060188829 +0100 +@@ -470,12 +470,13 @@ +
>>> SET(WITH_INNOBASE_STORAGE_ENGINE TRUE) + ENDIF() + 
>>> +-IF(XTRADB_OK) +-  MYSQL_ADD_PLUGIN(xtradb ${INNOBASE_SOURCES}
>>> STORAGE_ENGINE +-    DEFAULT +-    RECOMPILE_FOR_EMBEDDED +-
>>> LINK_LIBRARIES ${ZLIB_LIBRARY} ${LINKER_SCRIPT}) +-ELSE() +-
>>> MESSAGE(FATAL_ERROR "Percona XtraDB is not supported on this
>>> platform") ++IF(NOT WITHOUT_XTRADB)
> Does this boolean come from an option? it could.

It does. I've sent this patch upstream. MariaDB people acknowledged
the bug. I think they'll fix it but I don't know when.

> 
>>> ++  IF(XTRADB_OK) ++    MYSQL_ADD_PLUGIN(xtradb
>>> ${INNOBASE_SOURCES} STORAGE_ENGINE ++      DEFAULT ++
>>> RECOMPILE_FOR_EMBEDDED ++      LINK_LIBRARIES ${ZLIB_LIBRARY}
>>> ${LINKER_SCRIPT}) ++  ELSE() ++    MESSAGE(FATAL_ERROR "Percona
>>> XtraDB is not supported on this platform") ++  ENDIF() +
>>> ENDIF() +- diff --git
>>> a/package/mysql/10.0.17/mariadb-galera-02-fix_innodb_cmakelist.patch
>>> b/package/mysql/10.0.17/mariadb-galera-02-fix_innodb_cmakelist.patch
>>
>>> 
> new file mode 100644
>>> index 0000000..1ddec5d --- /dev/null +++
>>> b/package/mysql/10.0.17/mariadb-galera-02-fix_innodb_cmakelist.patch
>>
>>> 
> @@ -0,0 +1,251 @@
>>> +Use CHECK_C_SOURCE_COMPILES instead of CHECK_C_SOURCE_RUNS in
>>> order to be +cross-compile friendly. +In buildroot another
>>> solution (maybe better, maybe not) could be to use 
>>> +BR2_ARCH_HAS_ATOMICS in order to determine the value of
>>> HAVE_IB_GCC_ATOMIC_BUILTINS_BYTE +and likes. +
> Missing SoB line [2].
> 
> It makes sense to submit this patch upstream as well.
> 

I've sent this upstream. I've been told that CHECK_C_SOURCE_COMPILES
was used before but was not enough in some corner cases. They propose
to use it when cross-compiling and stick with SOURCE_RUN otherwise. It
means that "corner cases" won't be covered in cross-compilation but
this solution is no worse than my patch. However, this script checks
the availability and usability of:
__sync_bool_compare_and_swap
__sync_add_and_fetch
__sync_lock_test_and_set
__sync_sub_and_fetch
__sync_add_and_fetch
__atomic_thread_fence
__sync_bool_compare_and_swap
__sync_synchronize
maybe I could use BR2_ARCH_HAS_ATOMICS and/or other buildroot
variables to determine the value of HAVE_IB_GCC_ATOMIC_BUILTINS_BYTE,
HAVE_IB_ATOMIC_PTHREAD_T_GCC and HAVE_IB_ATOMIC_PTHREAD_T_GCC?

Cheers,

- -- 
Sylvain Raybaud
www.green-communications.fr
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)

iQIcBAEBAgAGBQJWFoiFAAoJEEkkwl4JtJ9ys6oQAKqi6EMMLc7THs6WotDuNF72
Lcg+2ZHlaWdICu58ELSEJD8eqPQeHpKV+UFV+Zm02PT1UZ/nqnSCM59lTjsmzHOo
D+XJz9w/otGTYjYhKRYuz4f8CyX7VAd6snNxw2TeesRQgShsU8h/A2LE74BPN3nn
k5f6DZhmDd0ZDBxHFYhOVxQXLK7i8u0zSDemwrLQbdj4ngh7d9P+5LbXNYVKNZiU
6lNJwNR7xwvEB2ZFtpRkqC2gTjIxD2n71ultwbRoFybnG/drt8dfLWoAg3ZoxrAQ
sGcbHY0gqhch7ioF/nwdtPqO648jQwY5WGbpLv5FP8GA2XxyWz7JYhyxwIZtyroO
6dDUJEvpYbVGHYGeR0B/sFJYNtW4gaM4zsoi7NVA740hvX56vhIOQflF+DxxU6ae
Ma0y1If14U/d5KG8cb4RkC6BSBNRLZAuRAibUIvlQ4pHj6Zw2O3nLJ8o+/hzDEDi
y2HlCtq1OS2kxsRj81DgmCQMHswO2lLITYmrH3W25dh8guF1cfE9t+a79ZmjeaQA
im7m6tAhokkTN4m8XcPyaHfBuWBVViZrPmGJLFlLeqGTjJB3+Xm5/48lvhg96L/3
54dZ9kNJeyIcmXgkJv1tEKtfHyy33NZPYnyRbMBzP+Jk+n/S288WSfkxpBn9j9ur
YmoAYbVCYiQlaJWydCQp
=CJ/5
-----END PGP SIGNATURE-----
diff mbox

Patch

diff --git a/package/mysql/10.0.17/mariadb-galera-01-fix_xtradb_cmakelist.patch b/package/mysql/10.0.17/mariadb-galera-01-fix_xtradb_cmakelist.patch
new file mode 100644
index 0000000..83eac77
--- /dev/null
+++ b/package/mysql/10.0.17/mariadb-galera-01-fix_xtradb_cmakelist.patch
@@ -0,0 +1,27 @@ 
+Do not perform test if the build is not requested anyway. The test may fail,
+preventing building the whole package.
+
+--- a/storage/xtradb/CMakeLists.txt	2014-10-30 16:24:33.160188627 +0100
++++ b/storage/xtradb/CMakeLists.txt	2014-10-30 16:25:09.060188829 +0100
+@@ -470,12 +470,13 @@
+   SET(WITH_INNOBASE_STORAGE_ENGINE TRUE)
+ ENDIF()
+ 
+-IF(XTRADB_OK)
+-  MYSQL_ADD_PLUGIN(xtradb ${INNOBASE_SOURCES} STORAGE_ENGINE
+-    DEFAULT
+-    RECOMPILE_FOR_EMBEDDED
+-    LINK_LIBRARIES ${ZLIB_LIBRARY} ${LINKER_SCRIPT})
+-ELSE()
+-  MESSAGE(FATAL_ERROR "Percona XtraDB is not supported on this platform")
++IF(NOT WITHOUT_XTRADB)
++  IF(XTRADB_OK)
++    MYSQL_ADD_PLUGIN(xtradb ${INNOBASE_SOURCES} STORAGE_ENGINE
++      DEFAULT
++      RECOMPILE_FOR_EMBEDDED
++      LINK_LIBRARIES ${ZLIB_LIBRARY} ${LINKER_SCRIPT})
++  ELSE()
++    MESSAGE(FATAL_ERROR "Percona XtraDB is not supported on this platform")
++  ENDIF()
+ ENDIF()
+-
diff --git a/package/mysql/10.0.17/mariadb-galera-02-fix_innodb_cmakelist.patch b/package/mysql/10.0.17/mariadb-galera-02-fix_innodb_cmakelist.patch
new file mode 100644
index 0000000..1ddec5d
--- /dev/null
+++ b/package/mysql/10.0.17/mariadb-galera-02-fix_innodb_cmakelist.patch
@@ -0,0 +1,251 @@ 
+Use CHECK_C_SOURCE_COMPILES instead of CHECK_C_SOURCE_RUNS in order to be
+cross-compile friendly.
+In buildroot another solution (maybe better, maybe not) could be to use
+BR2_ARCH_HAS_ATOMICS in order to determine the value of HAVE_IB_GCC_ATOMIC_BUILTINS_BYTE
+and likes.
+
+--- a/storage/innobase/CMakeLists.txt	2014-11-07 17:05:48.853208487 +0100
++++ b/storage/innobase/CMakeLists.txt	2014-11-07 17:11:38.061217839 +0100
+@@ -58,100 +58,99 @@
+ 
+ IF(NOT MSVC)
+ # either define HAVE_IB_GCC_ATOMIC_BUILTINS or not
+-IF(NOT CMAKE_CROSSCOMPILING)
+-  # workaround for gcc 4.1.2 RHEL5/x86, gcc atomic ops only work under -march=i686
+-  IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "i686" AND CMAKE_COMPILER_IS_GNUCC AND
+-     CMAKE_C_COMPILER_VERSION VERSION_LESS "4.1.3")
+-    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=i686")
+-    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=i686")
+-  ENDIF()
+-  CHECK_C_SOURCE_RUNS(
+-  "
+-  int main()
+-  {
+-    long	x;
+-    long	y;
+-    long	res;
+-
+-    x = 10;
+-    y = 123;
+-    res = __sync_bool_compare_and_swap(&x, x, y);
+-    if (!res || x != y) {
+-      return(1);
+-    }
+-
+-    x = 10;
+-    y = 123;
+-    res = __sync_bool_compare_and_swap(&x, x + 1, y);
+-    if (res || x != 10) {
+-      return(1);
+-    }
+-    x = 10;
+-    y = 123;
+-    res = __sync_add_and_fetch(&x, y);
+-    if (res != 123 + 10 || x != 123 + 10) {
+-      return(1);
+-    }
+-    return(0);
+-  }"
+-  HAVE_IB_GCC_ATOMIC_BUILTINS
+-  )
+-  CHECK_C_SOURCE_RUNS(
+-  "
+-  int main()
+-  {
+-    long	res;
+-    char	c;
+-
+-    c = 10;
+-    res = __sync_lock_test_and_set(&c, 123);
+-    if (res != 10 || c != 123) {
+-      return(1);
+-    }
+-    return(0);
+-  }"
+-  HAVE_IB_GCC_ATOMIC_BUILTINS_BYTE
+-  )
+-  CHECK_C_SOURCE_RUNS(
+-  "#include<stdint.h>
+-  int main()
+-  {
+-    int64_t	x,y,res;
+-
+-    x = 10;
+-    y = 123;
+-    res = __sync_sub_and_fetch(&y, x);
+-    if (res != y || y != 113) {
+-      return(1);
+-    }
+-    res = __sync_add_and_fetch(&y, x);
+-    if (res != y || y != 123) {
+-      return(1);
+-    }
+-    return(0);
+-  }"
+-  HAVE_IB_GCC_ATOMIC_BUILTINS_64
+-  )
+-  CHECK_C_SOURCE_RUNS(
+-  "#include<stdint.h>
+-  int main()
+-  {
+-    __sync_synchronize();
+-    return(0);
+-  }"
+-  HAVE_IB_GCC_SYNC_SYNCHRONISE
+-  )
+-  CHECK_C_SOURCE_RUNS(
+-  "#include<stdint.h>
+-  int main()
+-  {
+-    __atomic_thread_fence(__ATOMIC_ACQUIRE);
+-    __atomic_thread_fence(__ATOMIC_RELEASE);
+-    return(0);
+-  }"
+-  HAVE_IB_GCC_ATOMIC_THREAD_FENCE
+-  )
+-ENDIF()
++
++# workaround for gcc 4.1.2 RHEL5/x86, gcc atomic ops only work under -march=i686
++IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "i686" AND CMAKE_COMPILER_IS_GNUCC AND
++   CMAKE_C_COMPILER_VERSION VERSION_LESS "4.1.3")
++  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=i686")
++  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=i686")
++ENDIF()
++CHECK_C_SOURCE_COMPILES(
++"
++int main()
++{
++  long	x;
++  long	y;
++  long	res;
++
++  x = 10;
++  y = 123;
++  res = __sync_bool_compare_and_swap(&x, x, y);
++  if (!res || x != y) {
++    return(1);
++  }
++
++  x = 10;
++  y = 123;
++  res = __sync_bool_compare_and_swap(&x, x + 1, y);
++  if (res || x != 10) {
++    return(1);
++  }
++  x = 10;
++  y = 123;
++  res = __sync_add_and_fetch(&x, y);
++  if (res != 123 + 10 || x != 123 + 10) {
++    return(1);
++  }
++  return(0);
++}"
++HAVE_IB_GCC_ATOMIC_BUILTINS
++)
++CHECK_C_SOURCE_COMPILES(
++"
++int main()
++{
++  long	res;
++  char	c;
++
++  c = 10;
++  res = __sync_lock_test_and_set(&c, 123);
++  if (res != 10 || c != 123) {
++    return(1);
++  }
++  return(0);
++}"
++HAVE_IB_GCC_ATOMIC_BUILTINS_BYTE
++)
++CHECK_C_SOURCE_COMPILES(
++"#include<stdint.h>
++int main()
++{
++  int64_t	x,y,res;
++
++  x = 10;
++  y = 123;
++  res = __sync_sub_and_fetch(&y, x);
++  if (res != y || y != 113) {
++    return(1);
++  }
++  res = __sync_add_and_fetch(&y, x);
++  if (res != y || y != 123) {
++    return(1);
++  }
++  return(0);
++}"
++HAVE_IB_GCC_ATOMIC_BUILTINS_64
++)
++CHECK_C_SOURCE_COMPILES(
++"#include<stdint.h>
++int main()
++{
++  __sync_synchronize();
++  return(0);
++}"
++HAVE_IB_GCC_SYNC_SYNCHRONISE
++)
++CHECK_C_SOURCE_COMPILES(
++"#include<stdint.h>
++int main()
++{
++  __atomic_thread_fence(__ATOMIC_ACQUIRE);
++  __atomic_thread_fence(__ATOMIC_RELEASE);
++return(0);
++}"
++HAVE_IB_GCC_ATOMIC_THREAD_FENCE
++)
+ 
+ IF(HAVE_IB_GCC_ATOMIC_BUILTINS)
+  ADD_DEFINITIONS(-DHAVE_IB_GCC_ATOMIC_BUILTINS=1)
+@@ -173,28 +172,26 @@
+  ADD_DEFINITIONS(-DHAVE_IB_GCC_ATOMIC_THREAD_FENCE=1)
+ ENDIF()
+ 
+- # either define HAVE_IB_ATOMIC_PTHREAD_T_GCC or not
+-IF(NOT CMAKE_CROSSCOMPILING)
+-  CHECK_C_SOURCE_RUNS(
+-  "
+-  #include <pthread.h>
+-  #include <string.h>
+-
+-  int main() {
+-    pthread_t       x1;
+-    pthread_t       x2;
+-    pthread_t       x3;
+-
+-    memset(&x1, 0x0, sizeof(x1));
+-    memset(&x2, 0x0, sizeof(x2));
+-    memset(&x3, 0x0, sizeof(x3));
+-
+-    __sync_bool_compare_and_swap(&x1, x2, x3);
+-
+-    return(0);
+-  }"
+-  HAVE_IB_ATOMIC_PTHREAD_T_GCC)
+-ENDIF()
++# either define HAVE_IB_ATOMIC_PTHREAD_T_GCC or not
++CHECK_C_SOURCE_COMPILES(
++"
++#include <pthread.h>
++#include <string.h>
++
++int main() {
++  pthread_t       x1;
++  pthread_t       x2;
++  pthread_t       x3;
++
++  memset(&x1, 0x0, sizeof(x1));
++  memset(&x2, 0x0, sizeof(x2));
++  memset(&x3, 0x0, sizeof(x3));
++  __sync_bool_compare_and_swap(&x1, x2, x3);
++
++  return(0);
++}"
++HAVE_IB_ATOMIC_PTHREAD_T_GCC)
++
+ IF(HAVE_IB_ATOMIC_PTHREAD_T_GCC)
+   ADD_DEFINITIONS(-DHAVE_IB_ATOMIC_PTHREAD_T_GCC=1)
+ ENDIF()
diff --git a/package/mysql/Config.in b/package/mysql/Config.in
index 7133892..a1a2d23 100644
--- a/package/mysql/Config.in
+++ b/package/mysql/Config.in
@@ -1,8 +1,17 @@ 
 config BR2_PACKAGE_MYSQL
+	bool "mysql"
+
+if BR2_PACKAGE_MYSQL
+choice
+	prompt "MySQL database system implementation"
+	default MYSQL_MYSQL
+
+config MYSQL_MYSQL
 	bool "MySQL"
 	depends on BR2_INSTALL_LIBSTDCPP
 	depends on BR2_USE_MMU # fork()
 	depends on BR2_TOOLCHAIN_HAS_THREADS
+	depends on BR2_USE_MMU
 	select BR2_PACKAGE_NCURSES
 	select BR2_PACKAGE_READLINE
 	help
@@ -10,7 +19,35 @@  config BR2_PACKAGE_MYSQL
 
 	  http://www.mysql.com/
 
-if BR2_PACKAGE_MYSQL
+config MYSQL_MARIADB_GALERA
+	bool "mariadb-galera"
+	select BR2_PACKAGE_NCURSES
+	select BR2_PACKAGE_OPENSSL
+	select BR2_PACKAGE_ZLIB
+	select BR2_PACKAGE_LIBAIO
+	select BR2_PACKAGE_LIBTOOL
+	select BR2_PACKAGE_GALERA
+	select BR2_PACKAGE_BASH # runtime dependency only
+	select BR2_PACKAGE_LSOF # runtime dependency only
+	select BR2_PACKAGE_PROCPS_NG # runtime dependency only
+	select BR2_PACKAGE_FINDUTILS # runtime dependency only
+	select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
+	depends on BR2_TOOLCHAIN_BUILDROOT_GLIBC || BR2_PACKAGE_EGLIBC # spawn()
+	help
+	  MariaDB Galera Cluster.
+	  https://mariadb.com/kb/en/mariadb/what-is-mariadb-galera-cluster
+
+endchoice
+
+endif
+
+comment "MySQL needs a toolchain w/ C++, threads"
+depends on !BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_HAS_THREADS
+
+comment "MariaDB needs an (e)glibc toolchain"
+depends on !BR2_TOOLCHAIN_BUILDROOT_GLIBC && !BR2_PACKAGE_EGLIBC # spawn()
+
+if MYSQL_MYSQL
 
 config BR2_PACKAGE_MYSQL_SERVER
 	bool "MySQL server"
@@ -18,7 +55,3 @@  config BR2_PACKAGE_MYSQL_SERVER
 	  Install the MySQL server on the target.
 
 endif
-
-comment "MySQL needs a toolchain w/ C++, threads"
-	depends on BR2_USE_MMU
-	depends on !BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_HAS_THREADS
diff --git a/package/mysql/mariadb-galera-cluster.cnf b/package/mysql/mariadb-galera-cluster.cnf
new file mode 100644
index 0000000..c3eddaa
--- /dev/null
+++ b/package/mysql/mariadb-galera-cluster.cnf
@@ -0,0 +1,204 @@ 
+# MariaDB database server configuration file.
+#
+# You can copy this file to one of:
+# - "/etc/mysql/my.cnf" to set global options,
+# - "~/.my.cnf" to set user-specific options.
+# 
+# One can use all long options that the program supports.
+# Run program with --help to get a list of available options and with
+# --print-defaults to see which it would actually understand and use.
+#
+# For explanations see
+# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
+
+# This will be passed to all mysql clients
+# It has been reported that passwords should be enclosed with ticks/quotes
+# escpecially if they contain "#" chars...
+# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
+[client]
+port		= 3306
+socket		= /tmp/mysql.sock
+
+# Here is entries for some specific programs
+# The following values assume you have at least 32M ram
+
+# This was formally known as [safe_mysqld]. Both versions are currently parsed.
+[mysqld_safe]
+socket		= /tmp/mysql.sock
+nice		= 0
+
+[mysqld]
+#
+# * Basic Settings
+#
+user		= mysql
+pid-file	= /tmp/mysql.pid
+socket		= /tmp/mysql.sock
+port		= 3306
+basedir		= /usr
+datadir		= /var/lib/mysql
+tmpdir		= /tmp
+lc_messages_dir	= /usr/share/
+lc_messages	= en_US
+skip-external-locking
+
+# Don't use DNS as it may not be available
+skip-host-cache
+skip-name-resolve
+
+#
+# Instead of skip-networking the default is now to listen only on
+# localhost which is more compatible and is not less secure.
+#bind-address		= 127.0.0.1
+#
+# * Fine Tuning
+#
+max_connections		= 100
+connect_timeout		= 5
+wait_timeout		= 600
+max_allowed_packet	= 16M
+thread_cache_size       = 128
+sort_buffer_size	= 4M
+bulk_insert_buffer_size	= 16M
+tmp_table_size		= 32M
+max_heap_table_size	= 32M
+#
+# * MyISAM
+#
+# This replaces the startup script and checks MyISAM tables if needed
+# the first time they are touched. On error, make copy and try a repair.
+myisam_recover          = BACKUP
+key_buffer_size		= 64M
+#open-files-limit	= 2000
+table_open_cache	= 400
+myisam_sort_buffer_size	= 64M
+concurrent_insert	= 2
+read_buffer_size	= 2M
+read_rnd_buffer_size	= 1M
+#
+# * Query Cache Configuration
+#
+# Cache only tiny result sets, so we can fit more in the query cache.
+query_cache_limit		= 128K
+query_cache_size		= 16M
+# for more write intensive setups, set to DEMAND or OFF
+#query_cache_type		= DEMAND
+#
+# * Logging and Replication
+#
+# Both location gets rotated by the cronjob.
+# Be aware that this log type is a performance killer.
+# As of 5.1 you can enable the log at runtime!
+#general_log_file        = /var/lib/mysql/mysql.log
+#general_log             = 1
+#
+# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
+#
+# we do want to know about network errors and such
+log_warnings		= 2
+#
+# Enable the slow query log to see queries with especially long duration
+#slow_query_log[={0|1}]
+slow_query_log_file	= /var/lib/mysql/mariadb-slow.log
+long_query_time = 10
+#log_slow_rate_limit	= 1000
+log_slow_verbosity	= query_plan
+
+#log-queries-not-using-indexes
+#log_slow_admin_statements
+#
+# The following can be used as easy to replay backup logs or for replication.
+# note: if you are setting up a replication slave, see README.Debian about
+#       other settings you may need to change.
+#server-id		= 1
+#report_host		= master1
+#auto_increment_increment = 2
+#auto_increment_offset	= 1
+log_bin			= /var/lib/mysql/mariadb-bin
+log_bin_index		= /var/lib/mysql/mariadb-bin.index
+# not fab for performance, but safer
+#sync_binlog		= 1
+expire_logs_days	= 10
+max_binlog_size         = 100M
+# slaves
+#relay_log		= /var/lib/mysql/relay-bin
+#relay_log_index	= /var/lib/mysql/relay-bin.index
+#relay_log_info_file	= /var/lib/mysql/relay-bin.info
+#log_slave_updates
+#read_only
+#
+# If applications support it, this stricter sql_mode prevents some
+# mistakes like inserting invalid dates etc.
+#sql_mode		= NO_ENGINE_SUBSTITUTION,TRADITIONAL
+#
+# * InnoDB
+#
+# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
+# Read the manual for more InnoDB related options. There are many!
+default_storage_engine	= InnoDB
+# you can't just change log file size, requires special procedure
+#innodb_log_file_size	= 50M
+innodb_buffer_pool_size	= 64M
+innodb_log_buffer_size	= 8M
+innodb_file_per_table	= 1
+innodb_open_files	= 400
+innodb_io_capacity	= 400
+innodb_flush_method	= O_DIRECT
+#
+# * Security Features
+#
+# Read the manual, too, if you want chroot!
+# chroot = /var/lib/mysql/
+#
+# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
+#
+# ssl-ca=/etc/mysql/cacert.pem
+# ssl-cert=/etc/mysql/server-cert.pem
+# ssl-key=/etc/mysql/server-key.pem
+
+#
+# * Galera-related settings
+#
+
+[galera]
+# Mandatory settings
+
+# use InnoDB instead of XtraDB
+ignore_builtin_innodb
+innodb_autoinc_lock_mode=2
+innodb_doublewrite=1
+
+plugin_load=innodb=ha_innodb.so
+plugin_dir=/usr/lib/plugin
+
+wsrep_provider=/usr/lib/libgalera_smm.so
+binlog_format=row
+default_storage_engine=InnoDB
+
+query_cache_size=0 # mandatory only for versions prior to 5.5.40-galera, 10.0.14-galera and 10.1.2
+wsrep_on=ON        # Enable wsrep replication
+#wsrep_cluster_name=
+#wsrep_cluster_address=
+wsrep_sst_method=rsync
+
+#
+# Optional setting
+#wsrep_slave_threads=1
+#innodb_flush_log_at_trx_commit=0
+
+[mysqldump]
+quick
+quote-names
+max_allowed_packet	= 16M
+
+[mysql]
+#no-auto-rehash	# faster start of mysql but no tab completition
+
+[isamchk]
+key_buffer		= 16M
+
+#
+# * IMPORTANT: Additional settings that can override those from this file!
+#   The files must end with '.cnf', otherwise they'll be ignored.
+#
+!includedir /etc/mysql/conf.d/
diff --git a/package/mysql/mysql.hash b/package/mysql/mysql.hash
index 84f3361..d9f3574 100644
--- a/package/mysql/mysql.hash
+++ b/package/mysql/mysql.hash
@@ -1,2 +1,4 @@ 
 # From https://downloads.mariadb.com/archives/mysql-5.1/mysql-5.1.73.tar.gz.md5
 md5	887f869bcc757957067b9198f707f32f	mysql-5.1.73.tar.gz
+# From: https://downloads.mariadb.org/interstitial/mariadb-galera-10.0.17/source/mariadb-galera-10.0.17.tar.gz
+sha1	 91b70d19fb687a58f0e40f50608071489743e54e	mariadb-galera-10.0.17.tar.gz
diff --git a/package/mysql/mysql.mk b/package/mysql/mysql.mk
index 8718193..9abf50e 100644
--- a/package/mysql/mysql.mk
+++ b/package/mysql/mysql.mk
@@ -4,17 +4,24 @@ 
 #
 ################################################################################
 
-MYSQL_VERSION_MAJOR = 5.1
-MYSQL_VERSION = $(MYSQL_VERSION_MAJOR).73
-MYSQL_SOURCE = mysql-$(MYSQL_VERSION).tar.gz
-MYSQL_SITE = http://downloads.skysql.com/archives/mysql-$(MYSQL_VERSION_MAJOR)
-MYSQL_INSTALL_STAGING = YES
-MYSQL_DEPENDENCIES = readline ncurses
-MYSQL_AUTORECONF = YES
-MYSQL_LICENSE = GPLv2
-MYSQL_LICENSE_FILES = README COPYING
-
-MYSQL_CONF_ENV = \
+################################################################################
+#
+# mysql implementation
+#
+################################################################################
+
+
+MYSQL_MYSQL_VERSION_MAJOR = 5.1
+MYSQL_MYSQL_VERSION = $(MYSQL_MYSQL_VERSION_MAJOR).73
+MYSQL_MYSQL_SOURCE = mysql-$(MYSQL_MYSQL_VERSION).tar.gz
+MYSQL_MYSQL_SITE = http://downloads.skysql.com/archives/mysql-$(MYSQL_MYSQL_VERSION_MAJOR)
+MYSQL_MYSQL_INSTALL_STAGING = YES
+MYSQL_MYSQL_DEPENDENCIES = readline ncurses
+MYSQL_MYSQL_AUTORECONF = YES
+MYSQL_MYSQL_LICENSE = GPLv2
+MYSQL_MYSQL_LICENSE_FILES = README COPYING
+
+MYSQL_MYSQL_CONF_ENV = \
 	ac_cv_sys_restartable_syscalls=yes \
 	ac_cv_path_PS=/bin/ps \
 	ac_cv_FIND_PROC="/bin/ps p \$\$PID | grep -v grep | grep mysqld > /dev/null" \
@@ -23,7 +30,7 @@  MYSQL_CONF_ENV = \
 	ac_cv_have_decl_HAVE_IB_GCC_ATOMIC_BUILTINS=yes \
 	mysql_cv_new_rl_interface=yes
 
-MYSQL_CONF_OPTS = \
+MYSQL_MYSQL_CONF_OPTS = \
 	--without-ndb-binlog \
 	--without-docs \
 	--without-man \
@@ -34,22 +41,22 @@  MYSQL_CONF_OPTS = \
 	--disable-mysql-maintainer-mode
 
 ifeq ($(BR2_PACKAGE_OPENSSL),y)
-MYSQL_DEPENDENCIES += openssl
+MYSQL_MYSQL_DEPENDENCIES += openssl
 endif
 
 ifeq ($(BR2_PACKAGE_ZLIB),y)
-MYSQL_DEPENDENCIES += zlib
+MYSQL_MYSQL_DEPENDENCIES += zlib
 endif
 
 ifeq ($(BR2_PACKAGE_MYSQL_SERVER),y)
-MYSQL_DEPENDENCIES += host-mysql host-bison
-HOST_MYSQL_DEPENDENCIES = host-zlib host-ncurses
+MYSQL_MYSQL_DEPENDENCIES += host-mysql host-bison
+HOST_MYSQL_MYSQL_DEPENDENCIES = host-zlib host-ncurses
 
-HOST_MYSQL_CONF_OPTS = \
+HOST_MYSQL_MYSQL_CONF_OPTS = \
 	--with-embedded-server \
 	--disable-mysql-maintainer-mode
 
-MYSQL_CONF_OPTS += \
+MYSQL_MYSQL_CONF_OPTS += \
 	--localstatedir=/var/mysql \
 	--with-atomic-ops=up \
 	--with-embedded-server \
@@ -69,12 +76,12 @@  MYSQL_CONF_OPTS += \
 # Debugging is only available for the server, so no need for
 # this if-block outside of the server if-block
 ifeq ($(BR2_ENABLE_DEBUG),y)
-MYSQL_CONF_OPTS += --with-debug=full
+MYSQL_MYSQL_CONF_OPTS += --with-debug=full
 else
-MYSQL_CONF_OPTS += --without-debug
+MYSQL_MYSQL_CONF_OPTS += --without-debug
 endif
 
-define HOST_MYSQL_BUILD_CMDS
+define HOST_MYSQL_MYSQL_BUILD_CMDS
 	$(MAKE) -C $(@D)/include my_config.h
 	$(MAKE) -C $(@D)/mysys libmysys.a
 	$(MAKE) -C $(@D)/strings libmystrings.a
@@ -84,41 +91,188 @@  define HOST_MYSQL_BUILD_CMDS
 	$(MAKE) -C $(@D)/sql gen_lex_hash
 endef
 
-define HOST_MYSQL_INSTALL_CMDS
+define HOST_MYSQL_MYSQL_INSTALL_CMDS
 	$(INSTALL) -m 0755  $(@D)/sql/gen_lex_hash  $(HOST_DIR)/usr/bin/
 endef
 
-define MYSQL_USERS
+define MYSQL_MYSQL_USERS
 	mysql -1 nogroup -1 * /var/mysql - - MySQL daemon
 endef
 
-define MYSQL_ADD_FOLDER
+define MYSQL_MYSQL_ADD_FOLDER
 	$(INSTALL) -d $(TARGET_DIR)/var/mysql
 endef
 
-MYSQL_POST_INSTALL_TARGET_HOOKS += MYSQL_ADD_FOLDER
+MYSQL_MYSQL_POST_INSTALL_TARGET_HOOKS += MYSQL_ADD_FOLDER
 
-define MYSQL_INSTALL_INIT_SYSV
+define MYSQL_MYSQL_INSTALL_INIT_SYSV
 	$(INSTALL) -D -m 0755 package/mysql/S97mysqld \
 		$(TARGET_DIR)/etc/init.d/S97mysqld
 endef
 
 else
-MYSQL_CONF_OPTS += \
+MYSQL_MYSQL_CONF_OPTS += \
 	--without-server
 endif
 
 
-define MYSQL_REMOVE_TEST_PROGS
+define MYSQL_MYSQL_REMOVE_TEST_PROGS
 	rm -rf $(TARGET_DIR)/usr/mysql-test $(TARGET_DIR)/usr/sql-bench
 endef
 
-define MYSQL_ADD_MYSQL_LIB_PATH
+define MYSQL_MYSQL_ADD_MYSQL_LIB_PATH
 	echo "/usr/lib/mysql" >> $(TARGET_DIR)/etc/ld.so.conf
 endef
 
-MYSQL_POST_INSTALL_TARGET_HOOKS += MYSQL_REMOVE_TEST_PROGS
-MYSQL_POST_INSTALL_TARGET_HOOKS += MYSQL_ADD_MYSQL_LIB_PATH
+MYSQL_MYSQL_POST_INSTALL_TARGET_HOOKS += MYSQL_MYSQL_REMOVE_TEST_PROGS
+MYSQL_MYSQL_POST_INSTALL_TARGET_HOOKS += MYSQL_MYSQL_ADD_MYSQL_LIB_PATH
+
+################################################################################
+#
+# mariadb galera cluster implementation
+#
+################################################################################
+
+# According to MariaDB galera cluster documentation these options must be passed
+# to CMake:
+MYSQL_MARIADB_GALERA_CLUSTER_OPTS += "-DWITH_WSREP=1"
+MYSQL_MARIADB_GALERA_CLUSTER_OPTS += "-DWITH_INNODB_DISALLOW_WRITES=1"
+
+# msgpack causes trouble when cross-compiling:
+MYSQL_MARIADB_GALERA_EXTRA_OPTS += "-DGRN_WITH_MESSAGE_PACK=no"
+
+# Mroonga needs libstemmer. Some work still needs to be done before it can be
+# included in buildroot. Disable it for now.
+MYSQL_MARIADB_GALERA_EXTRA_OPTS += "-DWITHOUT_MROONGA=1"
+
+# This value is determined automatically during straight compile by compiling
+# and running a test code. You cannot do that during cross-compile. However the 
+# stack grows downward in most if not all modern systems. The only exception I
+# am aware of is PA-RISC which is not supported by buildroot. Therefore it makes
+# sense to hardcode the value. If an arch is added the stack of which grows up
+# one should expect unpredictable behavior at run time.
+MYSQL_MARIADB_GALERA_EXTRA_OPTS += "-DSTACK_DIRECTION=-1"
+
+# XTRADB requires atomics intrinsic. MariaDB package tests for them by compiling
+# and running C code which is not possible when cross-compiling. It is probably
+# probably possible to use BR2_ARCH_HAS_ATOMIC_INTRINSICS instead of compiling
+# and running some test code but for now we will just disable XTRADB.
+MYSQL_MARIADB_GALERA_EXTRA_OPTS += "-DWITHOUT_XTRADB=1"
+
+# Jemalloc was added for TokuDB. Since its configure script seems somewhat broken
+# when it comes to cross-compilation we shall disable it and also disable TokuDB.
+MYSQL_MARIADB_GALERA_EXTRA_OPTS += "-DWITH_JEMALLOC=no -DWITHOUT_TOKUDB=1"
+
+MYSQL_MARIADB_GALERA_VERSION = 10.0.17
+MYSQL_MARIADB_GALERA_SOURCE = mariadb-galera-$(MYSQL_MARIADB_GALERA_VERSION).tar.gz
+MYSQL_MARIADB_GALERA_SITE = https://downloads.mariadb.org/interstitial/mariadb-galera-$(MYSQL_MARIADB_GALERA_VERSION)/source/
+
+# In order to cross-compile mariadb galera cluster one should first natively
+# build in order to use some of the generated executables. They are then
+# included by import_executables.cmake which is generated during the native
+# build. Therefore host-mariadb-galera needs to be added to mariadb galera
+# dependencies and
+# -DIMPORT_EXECUTABLES=$(BUILD_DIR)/host-mariadb-galera/import_executables.cmake
+# must be passed to cmake
+MYSQL_MARIADB_GALERA_TARGET_BUILD_IMPORT += "-DIMPORT_EXECUTABLES=$(HOST_MYSQL_DIR)/import_executables.cmake"
+
+
+MYSQL_MARIADB_GALERA_INSTALL_STAGING = NO
+MYSQL_MARIADB_GALERA_INSTALL_TARGET = YES
+
+MYSQL_MARIADB_GALERA_DEPENDENCIES = \
+	host-mysql \
+	ncurses \
+	openssl \
+	zlib \
+	libaio \
+	libtool \
+	galera
+
+MYSQL_MARIADB_GALERA_CONF_OPTS = $(MYSQL_MARIADB_GALERA_EXTRA_OPTS)
+MYSQL_MARIADB_GALERA_CONF_OPTS += $(MYSQL_MARIADB_GALERA_TARGET_BUILD_IMPORT)
+HOST_MYSQL_MARIADB_GALERA_CONF_OPTS = $(MYSQL_MARIADB_GALERA_EXTRA_OPTS)
+
+# Options specific to Galera cluster
+MYSQL_MARIADB_GALERA_CONF_OPTS += $(MYSQL_MARIADB_GALERA_CLUSTER_OPTS)
+HOST_MYSQL_MARIADB_GALERA_CONF_OPTS += $(MYSQL_MARIADB_GALERA_CLUSTER_OPTS)
+
+# Post install configuration
+
+define MYSQL_MARIADB_GALERA_USERS
+	mysql 1000 mysql 1000 * /var/lib/mysql - - MySQL Server
+endef
+
+define MYSQL_MARIADB_GALERA_INSTALL_CNF
+	mkdir -p $(TARGET_DIR)/etc/mysql/conf.d
+	install -m 644 package/mysql/mariadb-galera-cluster.cnf $(TARGET_DIR)/etc/mysql/my.cnf
+endef
+
+MYSQL_MARIADB_GALERA_POST_INSTALL_TARGET_HOOKS += MYSQL_MARIADB_GALERA_INSTALL_CNF
 
+define MYSQL_MARIADB_GALERA_INSTALL_INIT_SYSV
+	$(INSTALL) -D -m 0755 $(@D)/support-files/mysql.server.sh \
+		$(TARGET_DIR)/etc/init.d/mysqld
+endef
+
+# generic options
+
+MYSQL_MARIADB_GALERA_AUTORECONF = NO
+MYSQL_MARIADB_GALERA_LICENSE = GPLv2
+MYSQL_MARIADB_GALERA_LICENSE_FILES = README COPYING COPYING.LESSER
+
+################################################################################
+#
+# meta package
+#
+################################################################################
+
+
+ifeq ($(MYSQL_MYSQL),y)
+	MYSQL_VERSION = $(MYSQL_MYSQL_VERSION)
+	MYSQL_SOURCE = $(MYSQL_MYSQL_SOURCE)
+	MYSQL_SITE = $(MYSQL_MYSQL_SITE)
+	MYSQL_INSTALL_STAGING = $(MYSQL_MYSQL_INSTALL_STAGING)
+	MYSQL_DEPENDENCIES = $(MYSQL_MYSQL_DEPENDENCIES)
+	MYSQL_AUTORECONF = $(MYSQL_MYSQL_AUTORECONF)
+	MYSQL_LICENSE = $(MYSQL_MYSQL_LICENSE)
+	MYSQL_LICENSE_FILES = $(MYSQL_MYSQL_LICENSE_FILES)
+	MYSQL_CONF_ENV = $(MYSQL_MYSQL_CONF_ENV)
+	MYSQL_CONF_OPTS = $(MYSQL_MYSQL_CONF_OPTS)
+
+	MYSQL_USERS = $(MYSQL_MYSQL_USERS)
+	MYSQL_POST_INSTALL_TARGET_HOOKS += $(MYSQL_MYSQL_POST_INSTALL_TARGET_HOOKS)
+
+	MYSQL_INSTALL_INIT_SYSV = $(MYSQL_MYSQL_INSTALL_INIT_SYSV)
+
+	HOST_MYSQL_DEPENDENCIES = $(HOST_MYSQL_MYSQL_DEPENDENCIES)
+	HOST_MYSQL_CONF_OPTS = $(HOST_MYSQL_MYSQL_CONF_OPTS)
+	HOST_MYSQL_BUILD_CMDS = $(HOST_MYSQL_MYSQL_BUILD_CMDS)
+	HOST_MYSQL_INSTALL_CMDS = $(HOST_MYSQL_MYSQL_INSTALL_CMDS)
+else ifeq ($(MYSQL_MARIADB_GALERA),y)
+	MYSQL_VERSION = $(MYSQL_MARIADB_GALERA_VERSION)
+	MYSQL_SOURCE = $(MYSQL_MARIADB_GALERA_SOURCE)
+	MYSQL_SITE = $(MYSQL_MARIADB_GALERA_SITE)
+	MYSQL_INSTALL_STAGING = $(MYSQL_MARIADB_GALERA_INSTALL_STAGING)
+	MYSQL_DEPENDENCIES = $(MYSQL_MARIADB_GALERA_DEPENDENCIES)
+	MYSQL_AUTORECONF = $(MYSQL_MARIADB_GALERA_AUTORECONF)
+	MYSQL_LICENSE = $(MYSQL_MARIADB_GALERA_LICENSE)
+	MYSQL_LICENSE_FILES = $(MYSQL_MARIADB_GALERA_LICENSE_FILES)
+	MYSQL_CONF_OPTS = $(MYSQL_MARIADB_GALERA_CONF_OPTS)
+
+	MYSQL_USERS = $(MYSQL_MARIADB_GALERA_USERS)
+	MYSQL_POST_INSTALL_TARGET_HOOKS += $(MYSQL_MARIADB_GALERA_POST_INSTALL_TARGET_HOOKS)
+
+	MYSQL_INSTALL_INIT_SYSV = $(MYSQL_MARIADB_GALERA_INSTALL_INIT_SYSV)
+
+	HOST_MYSQL_DEPENDENCIES = $(HOST_MYSQL_MARIADB_GALERA_DEPENDENCIES)
+	HOST_MYSQL_CONF_OPTS = $(HOST_MYSQL_MARIADB_GALERA_CONF_OPTS)
+endif
+
+ifeq ($(MYSQL_MYSQL),y)
 $(eval $(autotools-package))
 $(eval $(host-autotools-package))
+else ifeq ($(MYSQL_MARIADB_GALERA),y)
+$(eval $(host-cmake-package))
+$(eval $(cmake-package))
+endif