From 875ab2e43c7c3355e70deb0ec56ae3cfb015fba5 Mon Sep 17 00:00:00 2001 From: Juergen Borleis Date: Tue, 24 May 2016 12:54:32 +0200 Subject: mySQL: exhume a gone package by updating it to a new release After the remove of the old package from the staging area this change adds a new release of the mySQL package. Its intended and checked on a read-only root filesystem with write access in "/var/mysql" only. The database engine runs as a regular user and does not need root permissions. Due to its dependency to boost_1_59_0 it uses exactly this version and the already present boost lib in PTXdist isn't used. Be aware: its buildsystem uses a huge amount of memory. If your host is low on memory don't forget to build this package with the '-ji1' parameter. Signed-off-by: Juergen Borleis Signed-off-by: Michael Olbrich --- ...01-Fix_buildsystem-use-compile-only-tests.patch | 100 +++++++++++++ patches/mysql-5.7.11/series | 4 + projectroot/etc/group | 1 + projectroot/etc/mysql/my.cnf | 38 +++++ projectroot/etc/passwd | 1 + projectroot/lib/systemd/system/mysqld.service | 48 +++++++ projectroot/lib/systemd/system/mysqldinit.service | 36 +++++ projectroot/sbin/mysqlinit | 12 ++ rules/host-mysql.in | 10 ++ rules/host-mysql.make | 56 ++++++++ rules/mysql.in | 20 +++ rules/mysql.make | 158 +++++++++++++++++++++ 12 files changed, 484 insertions(+) create mode 100644 patches/mysql-5.7.11/0001-Fix_buildsystem-use-compile-only-tests.patch create mode 100644 patches/mysql-5.7.11/series create mode 100644 projectroot/etc/mysql/my.cnf create mode 100644 projectroot/lib/systemd/system/mysqld.service create mode 100644 projectroot/lib/systemd/system/mysqldinit.service create mode 100644 projectroot/sbin/mysqlinit create mode 100644 rules/host-mysql.in create mode 100644 rules/host-mysql.make create mode 100644 rules/mysql.in create mode 100644 rules/mysql.make diff --git a/patches/mysql-5.7.11/0001-Fix_buildsystem-use-compile-only-tests.patch b/patches/mysql-5.7.11/0001-Fix_buildsystem-use-compile-only-tests.patch new file mode 100644 index 000000000..106abc54a --- /dev/null +++ b/patches/mysql-5.7.11/0001-Fix_buildsystem-use-compile-only-tests.patch @@ -0,0 +1,100 @@ +From: Juergen Borleis +Date: Tue, 15 Mar 2016 15:02:02 +0100 +Subject: [PATCH] Fix_buildsystem: use compile only tests + +Testing compiler features need not to run to test them. +--- + storage/innobase/innodb.cmake | 36 ++++++++++++++++-------------------- + 1 file changed, 16 insertions(+), 20 deletions(-) + +diff --git a/storage/innobase/innodb.cmake b/storage/innobase/innodb.cmake +index 809e58941e95..944f4e10803b 100644 +--- a/storage/innobase/innodb.cmake ++++ b/storage/innobase/innodb.cmake +@@ -108,7 +108,7 @@ IF(HAVE_NANOSLEEP) + ENDIF() + + IF(NOT MSVC) +- CHECK_C_SOURCE_RUNS( ++ CHECK_CXX_SOURCE_COMPILES( + " + #define _GNU_SOURCE + #include +@@ -131,28 +131,27 @@ ENDIF() + + IF(NOT MSVC) + # either define HAVE_IB_GCC_ATOMIC_BUILTINS or not +-IF(NOT CMAKE_CROSSCOMPILING) +- CHECK_C_SOURCE_RUNS( +- "#include ++CHECK_CXX_SOURCE_COMPILES(" ++ #include + int main() + { + __sync_synchronize(); + return(0); + }" +- HAVE_IB_GCC_SYNC_SYNCHRONISE +- ) +- CHECK_C_SOURCE_RUNS( +- "#include ++ HAVE_IB_GCC_SYNC_SYNCHRONISE) ++ ++CHECK_CXX_SOURCE_COMPILES(" ++ #include + int main() + { + __atomic_thread_fence(__ATOMIC_ACQUIRE); + __atomic_thread_fence(__ATOMIC_RELEASE); + return(0); + }" +- HAVE_IB_GCC_ATOMIC_THREAD_FENCE +- ) +- CHECK_C_SOURCE_RUNS( +- "#include ++ HAVE_IB_GCC_ATOMIC_THREAD_FENCE) ++ ++CHECK_CXX_SOURCE_COMPILES(" ++ #include + int main() + { + unsigned char a = 0; +@@ -164,9 +163,7 @@ IF(NOT CMAKE_CROSSCOMPILING) + __ATOMIC_RELEASE, __ATOMIC_ACQUIRE); + return(0); + }" +- HAVE_IB_GCC_ATOMIC_COMPARE_EXCHANGE +- ) +-ENDIF() ++ HAVE_IB_GCC_ATOMIC_COMPARE_EXCHANGE) + + IF(HAVE_IB_GCC_SYNC_SYNCHRONISE) + ADD_DEFINITIONS(-DHAVE_IB_GCC_SYNC_SYNCHRONISE=1) +@@ -181,8 +178,7 @@ IF(HAVE_IB_GCC_ATOMIC_COMPARE_EXCHANGE) + ENDIF() + + # either define HAVE_IB_ATOMIC_PTHREAD_T_GCC or not +-IF(NOT CMAKE_CROSSCOMPILING) +- CHECK_C_SOURCE_RUNS( ++CHECK_CXX_SOURCE_COMPILES( + " + #include + #include +@@ -201,14 +197,14 @@ IF(NOT CMAKE_CROSSCOMPILING) + return(0); + }" + HAVE_IB_ATOMIC_PTHREAD_T_GCC) +-ENDIF() ++ + IF(HAVE_IB_ATOMIC_PTHREAD_T_GCC) + ADD_DEFINITIONS(-DHAVE_IB_ATOMIC_PTHREAD_T_GCC=1) + ENDIF() + + # Only use futexes on Linux if GCC atomics are available +-IF(NOT MSVC AND NOT CMAKE_CROSSCOMPILING) +- CHECK_C_SOURCE_RUNS( ++IF(NOT MSVC) ++ CHECK_CXX_SOURCE_COMPILES( + " + #include + #include diff --git a/patches/mysql-5.7.11/series b/patches/mysql-5.7.11/series new file mode 100644 index 000000000..2d5f3314f --- /dev/null +++ b/patches/mysql-5.7.11/series @@ -0,0 +1,4 @@ +# generated by git-ptx-patches +#tag:base --start-number 1 +0001-Fix_buildsystem-use-compile-only-tests.patch +# feb58169ae07f03fb795bfc9055f69a9 - git-ptx-patches magic diff --git a/projectroot/etc/group b/projectroot/etc/group index 5d491761d..9ff570261 100644 --- a/projectroot/etc/group +++ b/projectroot/etc/group @@ -19,6 +19,7 @@ video:x:113: lock:x:114: audio:x:115: input:x:116: +mysql:x:117: systemd-journal:x:201: systemd-network:x:202: systemd-journal-remote:x:203: diff --git a/projectroot/etc/mysql/my.cnf b/projectroot/etc/mysql/my.cnf new file mode 100644 index 000000000..909c0da8c --- /dev/null +++ b/projectroot/etc/mysql/my.cnf @@ -0,0 +1,38 @@ +# For advice on how to change settings please see +# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html + +[mysqld] +innodb_force_recovery = 0 + +# Remove leading # and set to the amount of RAM for the most important data +# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. +innodb_buffer_pool_size = 8M + +# Remove leading # to turn on a very important data integrity option: logging +# changes to the binary log between backups. +# log_bin + +# Remove leading # to turn on error logging. +# log_error= +# log_error_verbosity= + +# we have a read-only filesystem with one persistent writeable area only +# so point to this single writeable location +datadir = /var/lib/mysql/data + +# These are commonly set, remove the # and set as required. +# lc-messages-dir = ..... +# plugin-dir = ..... +# basedir = ..... +# port = ..... +# server_id = ..... +# socket = ..... + +# Remove leading # to set options mainly useful for reporting servers. +# The server defaults are faster for transactions and fast SELECTs. +# Adjust sizes as needed, experiment to find the optimal values. +join_buffer_size = 8M +sort_buffer_size = 2M +read_rnd_buffer_size = 2M + +sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES diff --git a/projectroot/etc/passwd b/projectroot/etc/passwd index d8ccb408d..b75ed9f45 100644 --- a/projectroot/etc/passwd +++ b/projectroot/etc/passwd @@ -3,6 +3,7 @@ daemon:x:1:1:daemon:/usr/sbin:/bin/sh ftp:x:11:101:ftp user:/home:/bin/false www:x:12:102:www user:/home:/bin/false sshd:x:100:65534:SSH Server:/var/run/sshd:/bin/false +mysql:x:101:117:mySQL Server:/var/run/mysql:/bin/false messagebus:x:103:104:messagebus:/dev/null:/bin/false systemd-network:x:202:202:systemd-network:/dev/null:/bin/false systemd-resolve:x:203:65534:systemd-resolve:/dev/null:/bin/false diff --git a/projectroot/lib/systemd/system/mysqld.service b/projectroot/lib/systemd/system/mysqld.service new file mode 100644 index 000000000..f92d49b90 --- /dev/null +++ b/projectroot/lib/systemd/system/mysqld.service @@ -0,0 +1,48 @@ +# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +# systemd service file for MySQL forking server +# + +[Unit] +Description=MySQL Server +Requires=mysqldinit.service +After=mysqldinit.service + +[Service] +User=mysql +Group=mysql +Type=forking + +PIDFile=/tmp/mysqld.pid + +# Disable service start and stop timeout logic of systemd for mysqld service. +TimeoutSec=0 + +# Start main service +ExecStart=/usr/bin/mysqld --defaults-file=/etc/mysql/my.cnf --skip-ssl --pid-file=/tmp/mysqld.pid $MYSQLD_OPTS + +# Sets open_files_limit +LimitNOFILE = 5000 + +Restart=on-failure + +RestartPreventExitStatus=1 + +PrivateTmp=false + +[Install] +WantedBy=multi-user.target + diff --git a/projectroot/lib/systemd/system/mysqldinit.service b/projectroot/lib/systemd/system/mysqldinit.service new file mode 100644 index 000000000..d7aefcc03 --- /dev/null +++ b/projectroot/lib/systemd/system/mysqldinit.service @@ -0,0 +1,36 @@ +# Copyright (c) 2016, Pengutronix +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# mySQL run-time preparation +# +# Preparation must be run once if the "data" (=working directory) does not +# exist yet. +# Since we expect a read-only root filesystem, we need one writeable filesystem +# part at "/var/mysql". +# +# Sinse we change some permissions, the script itself must run as user 'root' +# + +[Unit] +Description=MySQL Server Initialisation Service +RequiresMountsFor=/var/lib/mysql +ConditionPathExists=!/var/lib/mysql/data + +[Service] +User=root +Group=root +Type=oneshot +RemainAfterExit=yes + +ExecStart=/sbin/mysqlinit "/var/lib/mysql" + +[Install] +WantedBy=multi-user.target diff --git a/projectroot/sbin/mysqlinit b/projectroot/sbin/mysqlinit new file mode 100644 index 000000000..72b6d1f10 --- /dev/null +++ b/projectroot/sbin/mysqlinit @@ -0,0 +1,12 @@ +#!/bin/sh + +MYSQLD_OPTS= + +# since mySQL runs as a regular user, we need to give its working directory +# to it. + +chown mysql.mysql "$1" +chmod 0755 "$1" + +# now let mySQL do its initializing job +/usr/bin/mysqld --defaults-file=/etc/mysql/my.cnf --initialize --user=mysql --skip-ssl --pid-file=/tmp/mysqld.pid $MYSQLD_OPTS diff --git a/rules/host-mysql.in b/rules/host-mysql.in new file mode 100644 index 000000000..460064772 --- /dev/null +++ b/rules/host-mysql.in @@ -0,0 +1,10 @@ +## SECTION=hosttools_noprompt + +config HOST_MYSQL + tristate + select HOST_LIBAIO + select HOST_NCURSES + select HOST_CMAKE + select HOST_SYSTEMD + help + Required host part of the mySQL build system diff --git a/rules/host-mysql.make b/rules/host-mysql.make new file mode 100644 index 000000000..bcee0a3ba --- /dev/null +++ b/rules/host-mysql.make @@ -0,0 +1,56 @@ +# -*-makefile-*- +# +# Copyright (C) 2016 by Juergen Borleis +# +# See CREDITS for details about who has contributed to this project. +# +# For further information about the PTXdist project and license conditions +# see the README file. +# + +# +# We provide this package +# +HOST_PACKAGES-$(PTXCONF_HOST_MYSQL) += host-mysql + +# +# Paths and names +# +HOST_MYSQL_BOOST = $(MYSQL_BOOST) +HOST_MYSQL_BOOST_SOURCE = $(MYSQL_BOOST_SOURCE) +$(HOST_MYSQL_BOOST_SOURCE) = MYSQL_BOOST +HOST_MYSQL_BOOST_DIR = $(HOST_MYSQL_DIR) +HOST_BOOST_LICENSE := BSL-1.0 + +# ---------------------------------------------------------------------------- +# Extract +# ---------------------------------------------------------------------------- + +$(STATEDIR)/host-mysql.extract: + @$(call targetinfo) + @$(call clean, $(HOST_MYSQL_DIR)) + @$(call extract, HOST_MYSQL) + @$(call extract, HOST_MYSQL_BOOST) + @$(call patchin, HOST_MYSQL) + @$(call touch) + +# ---------------------------------------------------------------------------- +# Prepare + Compile +# ---------------------------------------------------------------------------- + +# +# cmake +# +HOST_MYSQL_CONF_TOOL := cmake +HOST_MYSQL_CONF_OPT := \ + $(HOST_CMAKE_OPT) \ + -DBUILD_CONFIG=mysql_release \ + -DCMAKE_INSTALL_PREFIX:PATH=/usr \ + -DSTACK_DIRECTION=1 \ + -DBOOST_INCLUDE_DIR=$(HOST_MYSQL_BOOST_DIR) \ + -DLOCAL_BOOST_DIR=$(HOST_MYSQL_BOOST_DIR) \ + -DHAVE_LLVM_LIBCPP_EXITCODE=no \ + -DHAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE_EXITCODE=no \ + -DWITH_ZLIB="bundled" + +# vim: syntax=make diff --git a/rules/mysql.in b/rules/mysql.in new file mode 100644 index 000000000..0aea6c2a4 --- /dev/null +++ b/rules/mysql.in @@ -0,0 +1,20 @@ +## SECTION=applications + +config MYSQL + tristate + select HOST_CMAKE + select HOST_MYSQL + select LIBAIO + select ZLIB + select LIBC_PTHREAD + select LIBC_RT + select LIBC_M + select LIBC_CRYPT + select LIBC_DL + select GCCLIBS_CXX + select GCCLIBS_GCC_S + select NCURSES + select SYSTEMD + prompt "mysql" + help + mySQL, an SQL database engine diff --git a/rules/mysql.make b/rules/mysql.make new file mode 100644 index 000000000..a20eaa39d --- /dev/null +++ b/rules/mysql.make @@ -0,0 +1,158 @@ +# -*-makefile-*- +# +# Copyright (C) 2016 by Juergen Borleis +# +# See CREDITS for details about who has contributed to this project. +# +# For further information about the PTXdist project and license conditions +# see the README file. +# + +# +# We provide this package +# +PACKAGES-$(PTXCONF_MYSQL) += mysql + +# +# Paths and names +# +MYSQL_VERSION := 5.7.11 +MYSQL_MD5 := f84d945a40ed876d10f8d5a7f4ccba32 +MYSQL := mysql-$(MYSQL_VERSION) +MYSQL_SUFFIX := tar.gz +MYSQL_URL := http://cdn.mysql.com//Downloads/MySQL-5.7/$(MYSQL).tar.gz +MYSQL_SOURCE := $(SRCDIR)/$(MYSQL).$(MYSQL_SUFFIX) +MYSQL_DIR := $(BUILDDIR)/$(MYSQL) +MYSQL_LICENSE := GPL-2.0 + +# mySQL has a hard dependency to boost_1_59_0. Deal with it + +MYSQL_BOOST_VERSION := 1_59_0 +MYSQL_BOOST_MD5 := 6aa9a5c6a4ca1016edd0ed1178e3cb87 +MYSQL_BOOST := boost_$(MYSQL_BOOST_VERSION) +MYSQL_BOOST_SUFFIX := tar.bz2 +MYSQL_BOOST_URL := $(call ptx/mirror, SF, boost/$(MYSQL_BOOST).$(MYSQL_BOOST_SUFFIX)) +MYSQL_BOOST_SOURCE := $(SRCDIR)/$(MYSQL_BOOST).$(MYSQL_BOOST_SUFFIX) +$(MYSQL_BOOST_SOURCE) := MYSQL_BOOST +MYSQL_BOOST_DIR := $(MYSQL_DIR) + +# we need more than one archive to download +MYSQL_SOURCES := $(MYSQL_SOURCE) $(MYSQL_BOOST_SOURCE) + +# ---------------------------------------------------------------------------- +# Extract +# ---------------------------------------------------------------------------- + +$(STATEDIR)/mysql.extract: + @$(call targetinfo) + @$(call clean, $(MYSQL_DIR)) + @$(call extract, MYSQL) + @$(call extract, MYSQL_BOOST) + @$(call patchin, MYSQL) + @$(call touch) + +# ---------------------------------------------------------------------------- +# Prepare +# ---------------------------------------------------------------------------- + +# +# cmake +# +MYSQL_CONF_TOOL := cmake +MYSQL_CONF_OPT := \ + $(CROSS_CMAKE_USR) \ + -DBUILD_CONFIG=mysql_release \ + -DSTACK_DIRECTION=1 \ + -DHAVE_LLVM_LIBCPP_EXITCODE=no \ + -DCMAKE_INSTALL_PREFIX:PATH=/usr \ + -DWITH_ZLIB=system \ + -DWITH_LZ4=bundled \ + -DWITH_SSL=bundled \ + -DCOMMUNITY_BUILD=ON \ + -DBOOST_INCLUDE_DIR=$(MYSQL_BOOST_DIR) \ + -DLOCAL_BOOST_DIR=$(MYSQL_BOOST_DIR) \ + -DMYSQL_DATADIR=/usr/local/mysql/data \ + -DMYSQL_KEYRINGDIR=/usr/local/mysql/keyring \ + -DSYSCONFDIR=/etc/mysql \ + -DSYSTEMD_PID_DIR=/run/mysql \ + -DTMPDIR=/tmp \ + -DWITH_EXTRA_CHARSETS=all \ + -DWITH_UNIT_TESTS=OFF \ + -DWITH_VALGRIND=OFF \ + -DWITH_SYSTEMD=ON \ + -DCOMPILATION_COMMENT=PTXdist \ + -DDEFAULT_CHARSET=latin1 + +# ---------------------------------------------------------------------------- +# Compile +# ---------------------------------------------------------------------------- + +$(STATEDIR)/mysql.compile: + @$(call targetinfo) + # we must copy it twice: once for the buildsystem, once for runtime + cp $(HOST_MYSQL_DIR)-build/sql/gen_lex_hash $(PTXDIST_SYSROOT_HOST)/bin + cp $(HOST_MYSQL_DIR)-build/sql/gen_lex_hash $(MYSQL_DIR)/sql + cp $(HOST_MYSQL_DIR)-build/sql/gen_lex_token $(PTXDIST_SYSROOT_HOST)/bin + cp $(HOST_MYSQL_DIR)-build/sql/gen_lex_token $(MYSQL_DIR)/sql + cp $(HOST_MYSQL_DIR)-build/extra/lz4_decompress $(PTXDIST_SYSROOT_HOST)/bin + cp $(HOST_MYSQL_DIR)-build/extra/lz4_decompress $(MYSQL_DIR)/extra + cp $(HOST_MYSQL_DIR)-build/extra/zlib_decompress $(PTXDIST_SYSROOT_HOST)/bin + cp $(HOST_MYSQL_DIR)-build/extra/zlib_decompress $(MYSQL_DIR)/extra + cp $(HOST_MYSQL_DIR)-build/extra/comp_err $(PTXDIST_SYSROOT_HOST)/bin + cp $(HOST_MYSQL_DIR)-build/extra/comp_err $(MYSQL_DIR)/extra + cp $(HOST_MYSQL_DIR)-build/scripts/comp_sql $(PTXDIST_SYSROOT_HOST)/bin + cp $(HOST_MYSQL_DIR)-build/scripts/comp_sql $(MYSQL_DIR)/scripts + + @$(call world/compile, MYSQL) + @$(call touch) + + +# ---------------------------------------------------------------------------- +# Target-Install +# ---------------------------------------------------------------------------- + +$(STATEDIR)/mysql.targetinstall: + @$(call targetinfo) + + @$(call install_init, mysql) + @$(call install_fixup, mysql,PRIORITY,optional) + @$(call install_fixup, mysql,SECTION,base) + @$(call install_fixup, mysql,AUTHOR,"Juergen Borleis ") + @$(call install_fixup, mysql,DESCRIPTION,"mySQL service") + +# # server stuff + @$(call install_copy, mysql, 0, 0, 0755, -, /usr/bin/mysqld) + + @$(call install_alternative, mysql, 0, 0, 0755, /sbin/mysqlinit) + @$(call install_alternative, mysql, 0, 0, 0644, /lib/systemd/system/mysqldinit.service) + @$(call install_link, mysql, ../mysqldinit.service, \ + /lib/systemd/system/multi-user.target.wants/mysqldinit.service) + @$(call install_alternative, mysql, 0, 0, 0644, /lib/systemd/system/mysqld.service) + @$(call install_link, mysql, ../mysqld.service, \ + /lib/systemd/system/multi-user.target.wants/mysqld.service) + @$(call install_alternative, mysql, 0, 0, 0644, /etc/mysql/my.cnf) + @$(call install_copy, mysql, 0, 0, 0644, -, /usr/lib/plugin/keyring_file.so) + +# # TODO: do we need more languages? + @$(call install_copy, mysql, 0, 0, 0755, -, /usr/share/english/errmsg.sys) + +# # TODO: do we need more charsets? + @$(call install_copy, mysql, 0, 0, 0755, -, /usr/share/charsets/latin1.xml) + +# # client stuff + @$(call install_copy, mysql, 0, 0, 0755, -, /usr/bin/mysql) + @$(call install_copy, mysql, 0, 0, 0755, -, /usr/bin/mysqladmin) + @$(call install_copy, mysql, 0, 0, 0755, -, /usr/bin/mysql_upgrade) + @$(call install_copy, mysql, 0, 0, 0755, -, /usr/bin/mysqlcheck) + @$(call install_copy, mysql, 0, 0, 0755, -, /usr/bin/mysqldump) + + @$(call install_lib, mysql, 0, 0, 0644, libmysqlclient) + +# # create a working directory which is writeable + @$(call install_copy, mysql, mysql, mysql, 0755, /var/lib/mysql) + + @$(call install_finish, mysql) + + @$(call touch) + +# vim: syntax=make -- cgit v1.2.3