From 06c07ffa11d902b5b558afe2c65d0b7a0b147f17 Mon Sep 17 00:00:00 2001 From: Terje Rosten Date: Thu, 27 Jun 2019 13:56:41 +0200 Subject: [PATCH] Add MySQL 8.0 package --- main/mysql/APKBUILD | 298 +++++++++++++++++++++++++++++++++++ main/mysql/mysql.conf | 6 + main/mysql/mysql.initd | 58 +++++++ main/mysql/mysql.pre-install | 11 ++ main/mysql/mysql.skip-tests | 2 + 5 files changed, 375 insertions(+) create mode 100644 main/mysql/APKBUILD create mode 100644 main/mysql/mysql.conf create mode 100644 main/mysql/mysql.initd create mode 100644 main/mysql/mysql.pre-install create mode 100644 main/mysql/mysql.skip-tests diff --git a/main/mysql/APKBUILD b/main/mysql/APKBUILD new file mode 100644 index 0000000000..793d11be6d --- /dev/null +++ b/main/mysql/APKBUILD @@ -0,0 +1,298 @@ +pkgname=mysql +pkgver=8.0.16 +pkgrel=0 +pkgdesc="A very fast and reliable SQL database server" + +url="http://www.mysql.com" +pkgusers="mysql" +pkggroups="mysql" +arch="all" +license="GPL-2.0-only" +depends="$pkgname-common" +depends_dev="openssl-dev zlib-dev" +makedepends="bison cmake icu-dev libaio-dev libc-dev libedit-dev libevent-dev + lz4-dev libtirpc-dev linux-headers linux-pam-dev musl-dev ncurses-dev + protobuf-dev openssl-dev re2-dev rpcgen rapidjson-dev valgrind-dev + zlib-dev gzip lz4 perl perl-json perl-libwww" +install="$pkgname.pre-install" +source="https://cdn.mysql.com/Downloads/MySQL-8.0/mysql-boost-$pkgver.tar.gz + mysql.pre-install + mysql.initd + mysql.conf + mysql.skip-tests" +subpackages="$pkgname-doc + $pkgname-dev + $pkgname-test:mysql_test + $pkgname-common + $pkgname-client-libs:client_libs + $pkgname-client + $pkgname-binaries + $pkgname-plugins + $pkgname-router" +builddir="$srcdir/$pkgname-$pkgver/build" + +prepare() { + default_prepare + mkdir -p "$srcdir" + cd "$srcdir" + tar xf "$pkgname"-boost-"$pkgver".tar.gz + install -D -m0644 "$srcdir"/mysql.skip-tests \ + "$srcdir/$pkgname-$pkgver"/mysql-test/alpine-skip-tests + mkdir -p "$builddir" +} + +_check() { + cd "$builddir"/mysql-test + case $(nproc) in + 1|2) tests="main.1st" ;; + 3|4|5|6|7) tests="--suite=main" ;; + *) tests="" # default is to run all tests + esac + ./mtr --mem --parallel=auto --force --retry=1 \ + --mysqld=--binlog-format=row \ + --suite-timeout=720 --testcase-timeout=30 \ + --report-unstable-tests --clean-vardir \ + --skip-test-list=alpine-skip-tests ${tests} + rm -r var $(readlink var) +} + +build() { + cd "$builddir" + cmake .. \ + -DBUILD_CONFIG=mysql_release \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DINSTALL_LAYOUT=TARGZ \ + -DSYSCONFDIR=/etc \ + -DMYSQL_DATADIR="/var/lib/mysql" \ + -DINSTALL_SUPPORTFILESDIR=share/$pkgname \ + -DINSTALL_MYSQLSHAREDIR=share/$pkgname \ + -DINSTALL_MANDIR=share/man \ + -DINSTALL_INCLUDEDIR=include/mysql \ + -DINSTALL_DOCDIR=share/doc/$pkgname \ + -DINSTALL_MYSQLTESTDIR=share/mysql-test \ + -DINSTALL_SECURE_FILE_PRIVDIR=/var/lib/mysql-files \ + -DCMAKE_BUILD_TYPE=MinSizeRel \ + -DWITH_BOOST=../boost \ + -DWITH_INNODB_MEMCACHED=1 \ + -DINSTALL_LIBDIR="lib" \ + -DINSTALL_PLUGINDIR="lib/$pkgname/plugin" \ + -DROUTER_INSTALL_LIBDIR="lib" \ + -DROUTER_INSTALL_PLUGINDIR="lib/mysqlrouter" \ + -DROUTER_INSTALL_DATADIR="/var/lib/mysqlrouter" \ + -DMYSQL_UNIX_ADDR=/run/mysqld/mysqld.sock \ + -DMYSQLX_UNIX_ADDR=/run/mysqld/mysqlx.sock \ + -DWITH_NUMA=OFF \ + -DWITH_SYSTEM_LIBS=ON \ + -DTMPDIR=/var/tmp + make -j$(nproc) + # check() is running in fakeroot, test suite don't support that + _check +} + +check() { + msg "Running MySQL tests" + cd "$builddir" + # Unit tests + make test VERBOSE=1 + # MySQL Test Suite don't work in fakeroot + [ "$(id -u)" = "0" ] && + echo "Can't run MySQL Test Suite as super user" && return 0 + _check +} + +package() { + cd "$builddir" + make DESTDIR="$pkgdir/" install + install -D -m0644 ../LICENSE \ + "$pkgdir"/usr/share/licenses/$pkgname/LICENSE + install -D -m0644 ../router/LICENSE.router \ + "$pkgdir"/usr/share/licenses/$pkgname/LICENSE.router + install -D -m0644 "$srcdir"/mysql.conf "$pkgdir"/etc/my.cnf + install -D -m0755 "$srcdir"/mysql.initd "$pkgdir"/etc/init.d/mysql + # move files to avoid default_dev processing + for dir in $(find "$pkgdir"/usr/share/mysql-test -type d -name include); do + mv ${dir} ${dir}__ + done + # remove some unwanted files + rm "$pkgdir"/usr/lib/libmysqlharness.a \ + "$pkgdir"/usr/lib/libmysqlharness.so \ + "$pkgdir"/usr/lib/libmysqlrouter.so + rm "$pkgdir"/usr/LICENSE \ + "$pkgdir"/usr/LICENSE.router \ + "$pkgdir"/usr/LICENSE-test \ + "$pkgdir"/usr/README \ + "$pkgdir"/usr/README.router \ + "$pkgdir"/usr/README-test + rm -rf "$pkgdir"/usr/docs + rm "$pkgdir"/usr/share/mysql/mysql-log-rotate \ + "$pkgdir"/usr/share/mysql/mysql.server \ + "$pkgdir"/usr/share/mysql/mysqld_multi.server +} + +dev() { + default_dev + mkdir -p "$subpkgdir"/usr/bin + mv "$pkgdir"/usr/bin/mysql_config "$subpkgdir"/usr/bin/ +} + +common() { + pkgdesc="MySQL common" + mkdir -p "$subpkgdir"/usr/share/mysql + local langs="charsets bulgarian czech danish dutch english estonian + french german greek hungarian italian japanese korean + norwegian-ny norwegian polish portuguese romanian russian + serbian slovak spanish swedish ukrainian" + for l in $langs; do + mv "$pkgdir"/usr/share/mysql/${l} "$subpkgdir"/usr/share/mysql/ + done +} + +client_libs() { + pkgdesc="MySQL libs" + depends="mysql-common" + mkdir -p "$subpkgdir"/usr/lib + mv "$pkgdir"/usr/lib/libmysqlclient.so.* "$subpkgdir"/usr/lib/ +} + +client() { + pkgdesc="MySQL client" + depends="mysql-common" + local bins="mysql mysqladmin mysqldump mysqlpump mysqlimport + mysql_tzinfo_to_sql mysql_upgrade" + mkdir -p "$subpkgdir"/usr/bin/ + for i in $bins; do + mv "$pkgdir"/usr/bin/${i} "$subpkgdir"/usr/bin/ + done +} + +mysql_test() { + pkgdesc="MySQL test suite" + depends="mysql mysql-client mysql-binaries mysql-plugins + gzip lz4 perl perl-json perl-libwww" + mkdir -p "$subpkgdir"/usr/bin + local bins="mysql_client_test mysqltest mysqltest_safe_process mysqlxtest" + for i in $bins; do + mv "$pkgdir"/usr/bin/${i} "$subpkgdir"/usr/bin/ + done + mkdir -p "$subpkgdir"/usr/share + mv "$pkgdir"/usr/share/mysql-test "$subpkgdir"/usr/share/ + for dir in $(find "$subpkgdir"/usr/share/mysql-test -type d -name include__); do + mv ${dir} ${dir%__} + done +} + +binaries() { + pkgdesc="MySQL extra binaries" + depends="mysql-common" + mkdir -p "$subpkgdir"/usr/bin + local bins="innochecksum ibd2sdi myisamchk myisam_ftdump myisamlog + myisampack mysqlbinlog mysqlcheck mysql_config_editor + mysqld_multi mysqld_safe mysqldumpslow mysql_secure_installation + mysql_ssl_rsa_setup mysqlshow mysqlslap perror zlib_decompress" + for i in $bins; do + mv "$pkgdir"/usr/bin/"${i}" "$subpkgdir"/usr/bin/ + done +} + +plugins() { + pkgdesc="MySQL extra plugins" + depends="mysql" + mkdir -p "$subpkgdir"/usr/lib/mysql/plugin + local plugins="auth_test_plugin.so + component_example_component1.so + component_example_component2.so + component_example_component3.so + component_log_sink_test.so + component_mysqlx_global_reset.so + component_pfs_example.so + component_pfs_example_component_population.so + component_test_pfs_notification.so + component_test_pfs_resource_group.so + component_test_string_service_charset.so + component_test_string_service.so + component_test_string_service_long.so + component_udf_reg_3_func.so + component_udf_reg_int_same_func.so + component_udf_reg_avg_func.so + component_udf_reg_only_3_func.so + component_udf_reg_int_func.so + component_udf_reg_real_func.so + component_test_udf_registration.so + component_udf_unreg_3_func.so + component_udf_unreg_int_func.so + component_udf_unreg_real_func.so + component_test_audit_api_message.so + component_test_host_application_signal.so + component_test_sys_var_service_int.so + component_test_sys_var_service.so + component_test_sys_var_service_same.so + component_test_sys_var_service_str.so + component_test_status_var_service.so + component_test_status_var_service_int.so + component_test_status_var_service_reg_only.so + component_test_status_var_service_str.so + component_test_status_var_service_unreg_only.so + component_test_system_variable_source.so + component_test_backup_lock_service.so + daemon_example.ini + ha_example.so + ha_mock.so + libtest_sql_shutdown.so + libtest_sql_views_triggers.so + libtest_sql_lock.so + libtest_sql_stored_procedures_functions.so + libtest_x_sessions_init.so + libtest_services_threaded.so + libtest_session_in_thd.so + libtest_sql_all_col_types.so + libtest_sql_complex.so + libtest_session_detach.so + libtest_sql_commit.so + libtest_sql_cmds_1.so + libtest_sql_processlist.so + libtest_sql_replication.so + libtest_sql_2_sessions.so + libtest_session_attach.so + libtest_framework.so + libtest_sql_errors.so + libtest_session_info.so + libtest_sql_sqlmode.so + libtest_x_sessions_deinit.so + libtest_services.so + libtest_sql_stmt.so + libdaemon_example.so + pfs_example_plugin_employee.so + qa_auth_client.so + qa_auth_interface.so + qa_auth_server.so + replication_observers_example_plugin.so + rewrite_example.so + test_security_context.so + test_services_host_application_signal.so + test_services_plugin_registry.so + test_udf_services.so + udf_example.so" + for plugin in $plugins; do + mv "$pkgdir"/usr/lib/mysql/plugin/${plugin} "$subpkgdir"/usr/lib/mysql/plugin + done +} + +router() { + pkgdesc="MySQL Router" + mkdir -p "$subpkgdir"/usr/bin + mkdir -p "$subpkgdir"/usr/lib + local bins="mysqlrouter mysqlrouter_plugin_info" + for i in $bins; do + mv "$pkgdir"/usr/bin/${i} "$subpkgdir"/usr/bin/ + done + local libs="libmysqlharness.so.1 libmysqlrouter.so.1" + for i in $libs; do + mv "$pkgdir"/usr/lib/${i} "$subpkgdir"/usr/lib/ + done + mv "$pkgdir"/usr/lib/mysqlrouter "$subpkgdir"/usr/lib +} +sha512sums="4de08d74637d1fef4f570148e66c8ddf2b59d1c0a49d715ca632da7f572645b65ec5f7c115aaf0bd179b0a9f1ba2bc40357c371f170a674118159d99b2c49516 mysql-boost-8.0.16.tar.gz +4781e8e3c3e25271f3f06e45704c36f0851d948a0b5ecf9f8534a4c78d99ae70824572b158bc4183544f6961c0729baa3a7f9a5287c3f233c54cd38d67f3b23a mysql.pre-install +ea1bb63848ca1d6799769b1f55b24659141c8f6ee1ea5ee1ecbce4f7c39a992d6ef835df82838c385f8196bdd1de719b364c6f9636548f3c68d3e485ad1c9633 mysql.initd +2837b7417c272a9f3bcfd53e7283d82724f9b98fb5272aacdeb498663d4538f5be3f5e420fc51afcf9782d9fe32c423b8edef9f93a12926fb292288a20d4f6c7 mysql.conf +c9e69bc3e353fd714257a44c05ea57c9e00917032422932ef23a817a0bd8a4d3b69717eaa10118fd82f0cdc25eba1c4423399bbc9cdaf3e7a332f361209f4229 mysql.skip-tests" diff --git a/main/mysql/mysql.conf b/main/mysql/mysql.conf new file mode 100644 index 0000000000..ccdb3ef60e --- /dev/null +++ b/main/mysql/mysql.conf @@ -0,0 +1,6 @@ +# For advice on how to change settings please see +# http://dev.mysql.com/doc/refman/en/server-configuration-defaults.html + +[mysqld] +log-error=/var/lib/mysql/mysqld.log + diff --git a/main/mysql/mysql.initd b/main/mysql/mysql.initd new file mode 100644 index 0000000000..498369d0ae --- /dev/null +++ b/main/mysql/mysql.initd @@ -0,0 +1,58 @@ +#!/sbin/openrc-run + +extra_commands="checkconfig" +extra_stopped_commands="init" +command="/usr/bin/mysqld" +pidfile="/run/mysqld/mysqld.pid" +command_args="--pid-file=$pidfile --user=mysql" +command_args_background="-D" +retry="60" + +depend() { + use net + need localmount +} + +init() { + ebegin "Initializing a new MySQL instance" + ${command} -I --user=mysql + eend $? "Initializing of MySQL failed. See /var/lib/mysql/mysqld.log" +} + +start_pre() { + required_files="$(get_mysql_option datadir "/var/lib/mysql")/mysql.ibd" + if [ ! -e "${required_files}" ]; then + eerror "MySQL is not initialized." + eerror "Run '/etc/init.d/mysql init' to initialize new instance." + return 1 + fi + if [ "${RC_CMD}" != "restart" ] ; then + checkconfig || return $? + fi + # for sockets + checkpath --directory --mode 0755 --owner mysql:mysql "/run/mysqld" +} + +start_post() { + ewaitfile 60 $(get_mysql_option socket "/run/mysqld/mysqld.sock") +} + +stop_pre() { + if [ "${RC_CMD}" = "restart" ] ; then + checkconfig || return $? + fi +} + +checkconfig() { + ebegin "Checking MySQL configuration" + ${command} --validate-config + eend $? +} + +get_mysql_option() { + local option=$1 + local default=$2 + result="$(/usr/bin/my_print_defaults mysqld | grep '^--'${option}'=' | cut -d= -f2- | tail -n 1)" + [ -z "$result" ] && result="${default}" + echo $result +} diff --git a/main/mysql/mysql.pre-install b/main/mysql/mysql.pre-install new file mode 100644 index 0000000000..5f6a476eba --- /dev/null +++ b/main/mysql/mysql.pre-install @@ -0,0 +1,11 @@ +#! /bin/sh + +addgroup -S mysql 2>/dev/null +adduser -S -D -H -h /var/lib/mysql -s /sbin/nologin -G mysql -g mysql mysql 2>/dev/null + +# Extra dirs for secure file priv and keyring +install -d -m0750 -omysql -gmysql /var/lib/mysql-files 2>/dev/null +install -d -m0700 -omysql -gmysql /var/lib/mysql-keyring 2>/dev/null + +exit 0 + diff --git a/main/mysql/mysql.skip-tests b/main/mysql/mysql.skip-tests new file mode 100644 index 0000000000..9100b54f38 --- /dev/null +++ b/main/mysql/mysql.skip-tests @@ -0,0 +1,2 @@ +main.events_2 : BUG#1 Fails on alpine linux +service_sys_var_registration.sys_var_service_3_comp : BUG#2 Fails on alpine linux -- 2.22.0