From e882bc390eb09ca60041b331dc124655e25946cc Mon Sep 17 00:00:00 2001 From: Terje Rosten Date: Fri, 1 Feb 2019 10:08:40 +0100 Subject: [PATCH] Add MySQL package --- main/mysql/APKBUILD | 303 +++++++++++++++++++++++++++++++++++++++++++ main/mysql/mysql.conf | 8 ++ main/mysql/mysql.initd | 38 ++++++ main/mysql/mysql.pre-install | 11 ++ main/mysql/mysql.skip-tests | 45 +++++++ 5 files changed, 405 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 0000000..c5e796a --- /dev/null +++ b/main/mysql/APKBUILD @@ -0,0 +1,303 @@ +pkgname=mysql +pkgver=8.0.14 +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 \ + "$pkgdir"/usr/share/mysql/magic +} + +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 mysqlxtest" + for i in $bins; do + mv "$pkgdir"/usr/bin/${i} "$subpkgdir"/usr/bin/ + done + mv "$pkgdir"/usr/share/mysql-test/lib/My/SafeProcess/my_safe_process \ + "$subpkgdir"/usr/bin/ + 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 + ln -s /usr/bin/my_safe_process \ + "$subpkgdir"/usr/share/mysql-test/lib/My/SafeProcess/my_safe_process +} + +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="b6f2897d9258fefc3f945d52b3f510fae41c23b4a572c7af91665cca5f1b46fdc0a07aaafd5646c32105a31ee7a7a85d755b9a8bdc377c4d8528eeb52fc25fe8 mysql-boost-8.0.14.tar.gz +4781e8e3c3e25271f3f06e45704c36f0851d948a0b5ecf9f8534a4c78d99ae70824572b158bc4183544f6961c0729baa3a7f9a5287c3f233c54cd38d67f3b23a mysql.pre-install +9130e2cbb5dd4e789e2fc1af77d9389d28f15b5530a42b3305412f02397715d04b766590c457a02d4814ecf4c5fe7392a8990fa074d97bb590c43f2dc2daf5a9 mysql.initd +b259cc1c0527937598464d00cc5856cb5321e557b074e6ef0f038f11d479c42df3a5f79bbb3145a4648500f498a2cc651c9ebf13501039be71572041dc34476f mysql.conf +949527e2e2a2a8a45589415f0eaa8209951b9b5d2ef367ea979faf039d49fb23be4ec59e2c3bdea658c36efa596d1e19afb9c6a433c4d998bfeb79e4c16beb19 mysql.skip-tests" diff --git a/main/mysql/mysql.conf b/main/mysql/mysql.conf new file mode 100644 index 0000000..e46cd49 --- /dev/null +++ b/main/mysql/mysql.conf @@ -0,0 +1,8 @@ +# For advice on how to change settings please see +# http://dev.mysql.com/doc/refman/en/server-configuration-defaults.html + +[mysqld] +pid-file=/run/mysqld/mysqld.pid +log-error=/var/lib/mysql/mysqld.log +user=mysql + diff --git a/main/mysql/mysql.initd b/main/mysql/mysql.initd new file mode 100644 index 0000000..a004630 --- /dev/null +++ b/main/mysql/mysql.initd @@ -0,0 +1,38 @@ +#!/sbin/openrc-run + +get_mysql_option() { + local option=$1 + local default=$2 + result=$(/usr/bin/my_print_defaults mysqld | sed -n "s/^--${option}=//p" | tail -n 1) + [ -z "$result" ] && result="${default}" + echo $result +} + +command="/usr/bin/mysqld" +command_args_background="-D" +pidfile=$(get_mysql_option pid-file "/run/mysqld/mysqld.pid") +extra_stopped_commands="init" +retry="60" + +depend() { + use net + need localmount +} + +init() { + ebegin "Initializing a new MySQL instance" + ${command} -I + eend $? +} + +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." + fi +} + +start_post() { + ewaitfile 60 $(get_mysql_option socket "/run/mysqld/mysqld.sock") +} diff --git a/main/mysql/mysql.pre-install b/main/mysql/mysql.pre-install new file mode 100644 index 0000000..5f6a476 --- /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 0000000..60baf5f --- /dev/null +++ b/main/mysql/mysql.skip-tests @@ -0,0 +1,45 @@ +innodb.innodb_bug84958 : fails on alpine linux +innodb.mysqld_core_dump_without_buffer_pool : fails on alpine linux +innodb.mysqld_core_dump_without_buffer_pool_dynamic : fails on alpine linux +innodb.mysqld_core_dump_without_buffer_pool_with_resizing : fails on alpine linux +innodb.log_file_system : fails on alpine linux +main.admin_interface : fails on alpine linux +main.file_contents : fails on alpine linux +main.multiaddress_bind : fails on alpine linux +main.mysqldump : fails on alpine linux +service_sys_var_registration.sys_var_service_3_comp_trans : fails on alpine linux +main.ssl_ca : fails on alpine linux +main.xa_prepared_binlog_off : fails on alpine linux +main.ssl_crl : fails on alpine linux +binlog.binlog_grant_alter_user : fails on alpine linux +auth_sec.cert_verify : OpenSSL 1.1.1 +auth_sec.mysql_ssl_connection : OpenSSL 1.1.1 +auth_sec.openssl_cert_generation : OpenSSL 1.1.1 +auth_sec.ssl_auto_detect : OpenSSL 1.1.1 +auth_sec.ssl_mode : OpenSSL 1.1.1 +auth_sec.tls : OpenSSL 1.1.1 +i_main.bug11761822 : OpenSSL 1.1.1 +i_main.bug13115401 : OpenSSL 1.1.1 +i_main.bug21025587 : OpenSSL 1.1.1 +i_main.plugin_auth_sha256_bug17675203 : OpenSSL 1.1.1 +i_main.ssl : OpenSSL 1.1.1 +i_main.verify_ca-bug24732452 : OpenSSL 1.1.1 +innodb.innodb_bug-13628249 : OpenSSL 1.1.1 +main.grant_alter_user_qa : OpenSSL 1.1.1 +main.grant_user_lock_qa : OpenSSL 1.1.1 +main.mysql_ssl_default : OpenSSL 1.1.1 +main.openssl_1 : OpenSSL 1.1.1 +main.plugin_auth_sha256_tls : OpenSSL 1.1.1 +main.ssl : OpenSSL 1.1.1 +main.ssl_8k_key : OpenSSL 1.1.1 +main.ssl_cipher : OpenSSL 1.1.1 +main.ssl_compress : OpenSSL 1.1.1 +main.ssl_verify_identity : OpenSSL 1.1.1 +test_service_sql_api.test_session_audit_null : OpenSSL 1.1.1 +test_service_sql_api.test_session_general_log : OpenSSL 1.1.1 +x.connection_expired_certs : OpenSSL 1.1.1 +x.connection_openssl : OpenSSL 1.1.1 +x.connection_openssl_unixsocket : OpenSSL 1.1.1 +x.connection_tls_version : OpenSSL 1.1.1 +x.mysqlxtest_mode_ssl : OpenSSL 1.1.1 +x.mysqlxtest_mode_ssl_unixsocket : OpenSSL 1.1.1 -- 2.7.3