From 85af24c338ec4c9bb2ad62c08ee34469a1e52ebf Mon Sep 17 00:00:00 2001 From: Honza Horak Date: Jul 24 2014 11:59:25 +0000 Subject: Spec rewrite to be more similar to oterh MySQL implementations --- diff --git a/mariadb-check-socket.sh b/mariadb-check-socket.sh deleted file mode 100644 index 955dc4f..0000000 --- a/mariadb-check-socket.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh - -# We check if there is already a process using the socket file, -# since otherwise the systemd service file could report false -# positive result when starting and mysqld_safe could remove -# a socket file, which is actually being used by a different daemon. - -source "`dirname ${BASH_SOURCE[0]}`/mariadb-scripts-common" - -if test -e "$socketfile" ; then - echo "Socket file $socketfile exists." >&2 - - # no write permissions - if ! test -w "$socketfile" ; then - echo "Not enough permission to write to the socket file $socketfile, which is suspicious." >&2 - echo "Please, remove $socketfile manually to start the service." >&2 - exit 1 - fi - - # not a socket file - if ! test -S "$socketfile" ; then - echo "The file $socketfile is not a socket file, which is suspicious." >&2 - echo "Please, remove $socketfile manually to start the service." >&2 - exit 1 - fi - - # some process uses the socket file - if fuser "$socketfile" &>/dev/null ; then - socketpid=$(fuser "$socketfile" 2>/dev/null) - echo "Is another MySQL daemon already running with the same unix socket?" >&2 - echo "Please, stop the process $socketpid or remove $socketfile manually to start the service." >&2 - exit 1 - fi - - # socket file is a garbage - echo "No process is using $socketfile, which means it is a garbage, so it will be removed automatically." >&2 -fi - -exit 0 diff --git a/mariadb-prepare-db-dir.sh b/mariadb-prepare-db-dir.sh deleted file mode 100644 index 8581a5f..0000000 --- a/mariadb-prepare-db-dir.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/sh - -# This script creates the mysql data directory during first service start. -# In subsequent starts, it does nothing much. - -source "`dirname ${BASH_SOURCE[0]}`/mariadb-scripts-common" - -# If two args given first is user, second is group -# otherwise the arg is the systemd service file -if [ "$#" -eq 2 ] -then - myuser="$1" - mygroup="$2" -else - # Absorb configuration settings from the specified systemd service file, - # or the default "mariadb" service if not specified - SERVICE_NAME="$1" - if [ x"$SERVICE_NAME" = x ] - then - SERVICE_NAME=@DAEMON_NAME@.service - fi - - myuser=`systemctl show -p User "${SERVICE_NAME}" | - sed 's/^User=//'` - if [ x"$myuser" = x ] - then - myuser=mysql - fi - - mygroup=`systemctl show -p Group "${SERVICE_NAME}" | - sed 's/^Group=//'` - if [ x"$mygroup" = x ] - then - mygroup=mysql - fi -fi - -# Set up the errlogfile with appropriate permissions -touch "$errlogfile" -ret=$? -# Provide some advice if the log file cannot be touched -if [ $ret -ne 0 ] ; then - errlogdir=$(dirname $errlogfile) - if ! [ -d "$errlogdir" ] ; then - echo "The directory $errlogdir does not exist." - elif [ -f "$errlogfile" ] ; then - echo "The log file $errlogfile cannot be touched, please, fix its permissions." - else - echo "The log file $errlogfile could not be created." - fi - echo "The daemon will be run under $myuser:$mygroup" - exit 1 -fi -chown "$myuser:$mygroup" "$errlogfile" -chmod 0640 "$errlogfile" -[ -x /sbin/restorecon ] && /sbin/restorecon "$errlogfile" - -# Make the data directory -if [ ! -d "$datadir/mysql" ] ; then - # First, make sure $datadir is there with correct permissions - # (note: if it's not, and we're not root, this'll fail ...) - if [ ! -e "$datadir" -a ! -h "$datadir" ] - then - mkdir -p "$datadir" || exit 1 - fi - chown "$myuser:$mygroup" "$datadir" - chmod 0755 "$datadir" - [ -x /sbin/restorecon ] && /sbin/restorecon "$datadir" - - # Now create the database - echo "Initializing MySQL database" - @bindir@/mysql_install_db --datadir="$datadir" --user="$myuser" - ret=$? - if [ $ret -ne 0 ] ; then - echo "Initialization of MySQL database failed." >&2 - echo "Perhaps @sysconfdir@/my.cnf is misconfigured." >&2 - # Clean up any partially-created database files - if [ ! -e "$datadir/mysql/user.frm" ] ; then - rm -rf "$datadir"/* - fi - exit $ret - fi - # In case we're running as root, make sure files are owned properly - chown -R "$myuser:$mygroup" "$datadir" -fi - -exit 0 diff --git a/mariadb-scripts-common.sh b/mariadb-scripts-common.sh deleted file mode 100755 index 7ce9a11..0000000 --- a/mariadb-scripts-common.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh - -# Some useful functions used in other MySQL helper scripts -# This scripts defines variables datadir, errlogfile, socketfile - -export LC_ALL=C - -# extract value of a MySQL option from config files -# Usage: get_mysql_option VARNAME DEFAULT SECTION [ SECTION, ... ] -# result is returned in $result -# We use my_print_defaults which prints all options from multiple files, -# with the more specific ones later; hence take the last match. -get_mysql_option(){ - if [ $# -ne 3 ] ; then - echo "get_mysql_option requires 3 arguments: section option default_value" - return - fi - sections="$1" - option_name="$2" - default_value="$3" - result=`/usr/bin/my_print_defaults $sections | sed -n "s/^--${option_name}=//p" | tail -n 1` - if [ -z "$result" ]; then - # not found, use default - result="${default_value}" - fi -} - -# Defaults here had better match what mysqld_safe will default to -# The option values are generally defined on three important places -# on the default installation: -# 1) default values are hardcoded in the code of mysqld daemon or -# mysqld_safe script -# 2) configurable values are defined in /etc/my.cnf -# 3) default values for helper scripts are specified bellow -# So, in case values are defined in my.cnf, we need to get that value. -# In case they are not defined in my.cnf, we need to get the same value -# in the daemon, as in the helper scripts. Thus, default values here -# must correspond with values defined in mysqld_safe script and source -# code itself. - -server_sections="mysqld_safe mysqld server mysqld-@MAJOR_VERSION@.@MINOR_VERSION@ mariadb mariadb-@MAJOR_VERSION@.@MINOR_VERSION@ client-server" - -get_mysql_option "$server_sections" datadir "@MYSQL_DATADIR@" -datadir="$result" - -# if there is log_error in the my.cnf, my_print_defaults still -# returns log-error -# log-error might be defined in mysqld_safe and mysqld sections, -# the former has bigger priority -get_mysql_option "$server_sections" log-error "`hostname`.err" -errlogfile="$result" - -get_mysql_option "$server_sections" socket "@MYSQL_UNIX_ADDR@" -socketfile="$result" - -get_mysql_option "$server_sections" pid-file "`hostname`.pid" -pidfile="$result" - diff --git a/mariadb-scripts.patch b/mariadb-scripts.patch index c79c134..650bbad 100644 --- a/mariadb-scripts.patch +++ b/mariadb-scripts.patch @@ -1,22 +1,23 @@ diff -up mariadb-10.0.12/scripts/CMakeLists.txt.systemd mariadb-10.0.12/scripts/CMakeLists.txt --- mariadb-10.0.12/scripts/CMakeLists.txt.systemd 2014-07-21 10:49:58.491470586 +0200 +++ mariadb-10.0.12/scripts/CMakeLists.txt 2014-07-21 14:21:22.673329708 +0200 -@@ -368,6 +368,31 @@ ELSE() +@@ -368,6 +368,32 @@ ELSE() COMPONENT ${${file}_COMPONENT} ) ENDFOREACH() + + # files for systemd + SET(SYSTEMD_SCRIPTS -+ mariadb-wait-ready -+ mariadb-scripts-common -+ mariadb-prepare-db-dir -+ mariadb-check-socket ++ mysql.tmpfiles.d ++ mysql.service ++ mysql-prepare-db-dir ++ mysql-wait-ready ++ mysql-check-socket ++ mysql-scripts-common + mysql_config_multilib -+ mariadb.service -+ mysqld.service -+ mariadb.tmpfiles.d + mysql.init ++ mysql-compat.service ++ mysql-compat.conf + ) + FOREACH(file ${SYSTEMD_SCRIPTS}) + IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh) diff --git a/mariadb-wait-ready.sh b/mariadb-wait-ready.sh deleted file mode 100644 index a5356c2..0000000 --- a/mariadb-wait-ready.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh - -source "`dirname ${BASH_SOURCE[0]}`/mariadb-scripts-common" - -# This script waits for mysqld to be ready to accept connections -# (which can be many seconds or even minutes after launch, if there's -# a lot of crash-recovery work to do). -# Running this as ExecStartPost is useful so that services declared as -# "After mysqld" won't be started until the database is really ready. - -if [ $# -ne 1 ] ; then - echo "You need to pass daemon pid as an argument for this script." - exit 20 -fi - -# Service file passes us the daemon's PID (actually, mysqld_safe's PID) -daemon_pid="$1" - -# Wait for the server to come up or for the mysqld process to disappear -ret=0 -while /bin/true; do - # Check process still exists - if ! [ -d "/proc/${daemon_pid}" ] ; then - ret=1 - break - fi - RESPONSE=`@bindir@/mysqladmin --no-defaults --socket="$socketfile" --user=UNKNOWN_MYSQL_USER ping 2>&1` - mret=$? - if [ $mret -eq 0 ] ; then - break - fi - # exit codes 1, 11 (EXIT_CANNOT_CONNECT_TO_SERVICE) are expected, - # anything else suggests a configuration error - if [ $mret -ne 1 -a $mret -ne 11 ]; then - echo "Cannot check for MySQL Daemon startup because of mysqladmin failure." >&2 - ret=$mret - break - fi - # "Access denied" also means the server is alive - echo "$RESPONSE" | grep -q "Access denied for user" && break - - sleep 1 -done - -exit $ret diff --git a/mariadb.service.in b/mariadb.service.in deleted file mode 100644 index b8c2f49..0000000 --- a/mariadb.service.in +++ /dev/null @@ -1,51 +0,0 @@ -# It's not recommended to modify this file in-place, because it will be -# overwritten during package upgrades. If you want to customize, the -# best way is to create a file "/etc/systemd/system/mariadb.service", -# containing -# .include /lib/systemd/system/mariadb.service -# ...make your changes here... -# or create a file "/etc/systemd/system/mariadb.service.d/foo.conf", -# which doesn't need to include ".include" call and which will be parsed -# after the file mariadb.service itself is parsed. -# -# For more info about custom unit files, see systemd.unit(5) or -# http://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F - -# For example, if you want to increase mysql's open-files-limit to 10000, -# you need to increase systemd's LimitNOFILE setting, so create a file named -# "/etc/systemd/system/mariadb.service.d/limits.conf" containing: -# [Service] -# LimitNOFILE=10000 - -# Note: /usr/lib/... is recommended in the .include line though /lib/... -# still works. -# Don't forget to reload systemd daemon after you change unit configuration: -# root> systemctl --system daemon-reload - -[Unit] -Description=MariaDB @MAJOR_VERSION@.@MINOR_VERSION@ database server -After=syslog.target -After=network.target -BindsTo=@DAEMON_NAME2@.service - -[Service] -Type=simple -User=mysql -Group=mysql - -ExecStartPre=@libexecdir@/mariadb-check-socket -ExecStartPre=@libexecdir@/mariadb-prepare-db-dir %n -# Note: we set --basedir to prevent probes that might trigger SELinux alarms, -# per bug #547485 -ExecStart=@bindir@/mysqld_safe --basedir=@prefix@ -ExecStartPost=@libexecdir@/mariadb-wait-ready $MAINPID - -# Give a reasonable amount of time for the server to start up/shut down -TimeoutSec=300 - -# Place temp files in a secure directory, not /tmp -PrivateTmp=true - -[Install] -WantedBy=multi-user.target -Also=@DAEMON_NAME2@.service diff --git a/mariadb.spec b/mariadb.spec index 716a173..c99d293 100644 --- a/mariadb.spec +++ b/mariadb.spec @@ -1,3 +1,6 @@ +# Name of the package without any prefixes +%global pkgname mariadb + # Regression tests may take a long time (many cores recommended), skip them by # passing --nocheck to rpmbuild or by setting runselftest to 0 if defining # --nocheck is not possible (e.g. in koji build) @@ -9,6 +12,10 @@ # use Full RELRO for all binaries (RHBZ#1092548) %global _hardened_build 1 +# By default, patch(1) creates backup files when chunks apply with offsets. +# Turn that off to ensure such files don't get included in RPMs (cf bz#884755). +%global _default_patch_flags --no-backup-if-mismatch + # When there is already another package that ships /etc/my.cnf, # rather include it than ship the file again, since conflicts between # those files may create issues @@ -45,7 +52,7 @@ %bcond_without test # Include files for SysV init or systemd -%if 0%{?systemd_requires:1} +%if 0%{?fedora} >= 15 %bcond_without init_systemd %bcond_with init_sysv %global daemon_name %{name} @@ -75,6 +82,9 @@ %global old_logfile %{_localstatedir}/log/mysqld.log %endif +# Home directory of mysql user should be same for all packages that create it +%global mysqluserhome /var/lib/mysql + # The evr of mysql we want to obsolete %global obsoleted_mysql_evr 5.6-0 %global obsoleted_mysql_case_evr 5.5.30-5 @@ -88,7 +98,10 @@ %global mysqld_enabled_flag_file %{_localstatedir}/lib/rpm-state/mysqld_enabled %global mysqld_running_flag_file %{_localstatedir}/lib/rpm-state/mysqld_running -Name: mariadb +# Make long macros shorter +%global sameevp %{epoch}:%{version}-%{release} + +Name: %{pkgname} Version: 10.0.12 Release: 5%{?dist} Epoch: 1 @@ -110,44 +123,48 @@ Source5: README.mysql-cnf Source6: README.mysql-docs Source7: README.mysql-license Source9: mysql-embedded-check.c -Source10: mariadb.tmpfiles.d.in -Source11: mariadb.service.in -Source12: mariadb-prepare-db-dir.sh -Source13: mariadb-wait-ready.sh -Source14: mariadb-check-socket.sh -Source15: mariadb-scripts-common.sh -Source16: mysqld.service.in -Source17: mysql.init.in +Source10: mysql.tmpfiles.d.in +Source11: mysql.service.in +Source12: mysql-prepare-db-dir.sh +Source13: mysql-wait-ready.sh +Source14: mysql-check-socket.sh +Source15: mysql-scripts-common.sh +Source16: mysql-compat.service.in +Source17: mysql-compat.conf.in +Source18: mysql.init.in Source50: rh-skipped-tests-base.list Source51: rh-skipped-tests-intel.list Source52: rh-skipped-tests-arm.list Source53: rh-skipped-tests-ppc-s390.list Source54: rh-skipped-tests-ppc64le.list -# Comments for these patches are in the patch files. -Patch1: mariadb-errno.patch -Patch2: mariadb-strmov.patch -Patch3: mariadb-install-test.patch -Patch4: mariadb-s390-tsc.patch -Patch5: mariadb-logrotate.patch -Patch6: mariadb-cipherspec.patch -Patch7: mariadb-file-contents.patch -Patch8: mariadb-string-overflow.patch -Patch9: mariadb-dh1024.patch -Patch10: mariadb-basedir.patch -Patch11: mariadb-covscan-signexpr.patch -Patch12: mariadb-covscan-stroverflow.patch -Patch13: mariadb-config.patch -Patch14: mariadb-ssltest.patch -Patch15: mariadb-mysql_config.patch -Patch16: mariadb-scripts.patch +# Comments for these patches are in the patch files +# Patches common for more mysql-like packages +Patch1: %{pkgname}-strmov.patch +Patch2: %{pkgname}-install-test.patch +Patch3: %{pkgname}-s390-tsc.patch +Patch4: %{pkgname}-logrotate.patch +Patch5: %{pkgname}-cipherspec.patch +Patch6: %{pkgname}-file-contents.patch +Patch7: %{pkgname}-dh1024.patch +Patch8: %{pkgname}-scripts.patch + +# Patches specific for this mysql package +Patch30: %{pkgname}-errno.patch +Patch31: %{pkgname}-string-overflow.patch +Patch32: %{pkgname}-basedir.patch +Patch33: %{pkgname}-covscan-signexpr.patch +Patch34: %{pkgname}-covscan-stroverflow.patch +Patch35: %{pkgname}-config.patch +Patch36: %{pkgname}-ssltest.patch +Patch37: %{pkgname}-mysql_config.patch BuildRequires: cmake BuildRequires: libaio-devel -BuildRequires: readline-devel BuildRequires: openssl-devel BuildRequires: ncurses-devel BuildRequires: perl +BuildRequires: readline-devel BuildRequires: systemtap-sdt-devel BuildRequires: zlib-devel # auth_pam.so plugin will be build if pam-devel is installed @@ -157,8 +174,14 @@ BuildRequires: pam-devel BuildRequires: procps BuildRequires: time BuildRequires: perl(Env) +BuildRequires: perl(Exporter) +BuildRequires: perl(Fcntl) +BuildRequires: perl(File::Temp) BuildRequires: perl(Data::Dumper) +BuildRequires: perl(Getopt::Long) +BuildRequires: perl(IPC::Open3) BuildRequires: perl(Socket) +BuildRequires: perl(Sys::Hostname) BuildRequires: perl(Test::More) BuildRequires: perl(Time::HiRes) %{?with_init_systemd:BuildRequires: systemd} @@ -166,18 +189,17 @@ BuildRequires: perl(Time::HiRes) Requires: bash Requires: fileutils Requires: grep -Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release} +Requires: %{name}-common%{?_isa} = %{sameevp} +Provides: mysql = %{sameevp} +Provides: mysql%{?_isa} = %{sameevp} +Provides: mysql-compat-client = %{sameevp} +Provides: mysql-compat-client%{?_isa} = %{sameevp} # MySQL (with caps) is upstream's spelling of their own RPMs for mysql %{?obsoleted_mysql_case_evr:Obsoletes: MySQL < %{obsoleted_mysql_case_evr}} -Conflicts: community-mysql -# MariaDB replaces mysql packages -Provides: mysql = %{epoch}:%{version}-%{release} -Provides: mysql%{?_isa} = %{epoch}:%{version}-%{release} -Provides: mysql-compat-client = %{epoch}:%{version}-%{release} -Provides: mysql-compat-client%{?_isa} = %{epoch}:%{version}-%{release} %{?obsoleted_mysql_evr:Obsoletes: mysql < %{obsoleted_mysql_evr}} +Conflicts: community-mysql # Filtering: https://fedoraproject.org/wiki/Packaging:AutoProvidesAndRequiresFiltering %if 0%{?__requires_exclude:1} @@ -186,13 +208,9 @@ Provides: mysql-compat-client%{?_isa} = %{epoch}:%{version}-%{release} %else %filter_from_requires /perl(\(hostnames\|lib::mtr\|lib::v1\|mtr_\|My::\)/d %filter_provides_in -P (%{_datadir}/(mysql|mysql-test)/.*|%{_libdir}/mysql/plugin/.*\\.so)$ -%filter_setup +%filter_setup %endif -# By default, patch(1) creates backup files when chunks apply with offsets. -# Turn that off to ensure such files don't get included in RPMs (cf bz#884755). -%global _default_patch_flags --no-backup-if-mismatch - %description MariaDB is a community developed branch of MySQL. MariaDB is a multi-user, multi-threaded SQL database server. @@ -203,12 +221,11 @@ contains the standard MariaDB/MySQL client programs and generic MySQL files. %if %{with clibrary} %package libs - Summary: The shared libraries required for MariaDB/MySQL clients Group: Applications/Databases -Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release} -Provides: mysql-libs = %{epoch}:%{version}-%{release} -Provides: mysql-libs%{?_isa} = %{epoch}:%{version}-%{release} +Requires: %{name}-common%{?_isa} = %{sameevp} +Provides: mysql-libs = %{sameevp} +Provides: mysql-libs%{?_isa} = %{sameevp} %{?obsoleted_mysql_case_evr:Obsoletes: MySQL-libs < %{obsoleted_mysql_case_evr}} %{?obsoleted_mysql_evr:Obsoletes: mysql-libs < %{obsoleted_mysql_evr}} @@ -219,9 +236,9 @@ package to use any other MariaDB package or any clients that need to connect to a MariaDB/MySQL server. MariaDB is a community developed branch of MySQL. %endif + %if %{with common} %package common - Summary: The shared files required by server and client Group: Applications/Databases %if ! %{ship_my_cnf} @@ -236,10 +253,9 @@ You will need to install this package to use any other MariaDB package. %if %{with errmsg} %package errmsg - Summary: The error messages files required by server and embedded Group: Applications/Databases -Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release} +Requires: %{name}-common%{?_isa} = %{sameevp} %description errmsg The package provides error messages files for the MariaDB daemon and the @@ -249,18 +265,17 @@ MariaDB packages. %package server - Summary: The MariaDB server and related files Group: Applications/Databases # note: no version here = %{version}-%{release} Requires: mysql-compat-client%{?_isa} -Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release} +Requires: %{name}-common%{?_isa} = %{sameevp} %if %{without common} Requires: %{_sysconfdir}/my.cnf Requires: %{_sysconfdir}/my.cnf.d %endif -Requires: %{name}-errmsg%{?_isa} = %{epoch}:%{version}-%{release} +Requires: %{name}-errmsg%{?_isa} = %{sameevp} Requires: sh-utils Requires(pre): /usr/sbin/useradd %if %{with init_systemd} @@ -272,12 +287,12 @@ Requires(posttrans): systemd %{?systemd_requires: %systemd_requires} %endif # mysqlhotcopy needs DBI/DBD support -Requires: perl-DBI -Requires: perl-DBD-MySQL -Provides: mysql-server = %{epoch}:%{version}-%{release} -Provides: mysql-server%{?_isa} = %{epoch}:%{version}-%{release} -Provides: mysql-compat-server = %{epoch}:%{version}-%{release} -Provides: mysql-compat-server%{?_isa} = %{epoch}:%{version}-%{release} +Requires: perl(DBI) +Requires: perl(DBD::mysql) +Provides: mysql-server = %{sameevp} +Provides: mysql-server%{?_isa} = %{sameevp} +Provides: mysql-compat-server = %{sameevp} +Provides: mysql-compat-server%{?_isa} = %{sameevp} %{?obsoleted_mysql_case_evr:Obsoletes: MySQL-server < %{obsoleted_mysql_case_evr}} Conflicts: community-mysql-server Conflicts: mariadb-galera-server @@ -293,10 +308,9 @@ MariaDB is a community developed branch of MySQL. %if %{with oqgraph} %package oqgraph - Summary: The Open Query GRAPH engine for MariaDB Group: Applications/Databases -Requires: %{name}-server%{?_isa} = %{epoch}:%{version}-%{release} +Requires: %{name}-server%{?_isa} = %{sameevp} # boost and Judy required for oograph BuildRequires: boost-devel BuildRequires: Judy-devel @@ -312,13 +326,12 @@ standard SQL syntax, and results joined onto other tables. %if %{with devel} %package devel - Summary: Files for development of MariaDB/MySQL applications Group: Applications/Databases -Requires: %{name}-libs%{?_isa} = %{epoch}:%{version}-%{release} +Requires: %{name}-libs%{?_isa} = %{sameevp} Requires: openssl-devel%{?_isa} -Provides: mysql-devel = %{epoch}:%{version}-%{release} -Provides: mysql-devel%{?_isa} = %{epoch}:%{version}-%{release} +Provides: mysql-devel = %{sameevp} +Provides: mysql-devel%{?_isa} = %{sameevp} %{?obsoleted_mysql_case_evr:Obsoletes: MySQL-devel < %{obsoleted_mysql_case_evr}} %{?obsoleted_mysql_evr:Obsoletes: mysql-devel < %{obsoleted_mysql_evr}} Conflicts: community-mysql-devel @@ -333,13 +346,12 @@ MariaDB is a community developed branch of MySQL. %if %{with embedded} %package embedded - Summary: MariaDB as an embeddable library Group: Applications/Databases -Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release} -Requires: %{name}-errmsg%{?_isa} = %{epoch}:%{version}-%{release} -Provides: mysql-embedded = %{epoch}:%{version}-%{release} -Provides: mysql-embedded%{?_isa} = %{epoch}:%{version}-%{release} +Requires: %{name}-common%{?_isa} = %{sameevp} +Requires: %{name}-errmsg%{?_isa} = %{sameevp} +Provides: mysql-embedded = %{sameevp} +Provides: mysql-embedded%{?_isa} = %{sameevp} %{?obsoleted_mysql_case_evr:Obsoletes: MySQL-embedded < %{obsoleted_mysql_case_evr}} %{?obsoleted_mysql_evr:Obsoletes: mysql-embedded < %{obsoleted_mysql_evr}} @@ -351,13 +363,12 @@ MariaDB is a community developed branch of MySQL. %package embedded-devel - Summary: Development files for MariaDB as an embeddable library Group: Applications/Databases -Requires: %{name}-embedded%{?_isa} = %{epoch}:%{version}-%{release} -Requires: %{name}-devel%{?_isa} = %{epoch}:%{version}-%{release} -Provides: mysql-embedded-devel = %{epoch}:%{version}-%{release} -Provides: mysql-embedded-devel%{?_isa} = %{epoch}:%{version}-%{release} +Requires: %{name}-embedded%{?_isa} = %{sameevp} +Requires: %{name}-devel%{?_isa} = %{sameevp} +Provides: mysql-embedded-devel = %{sameevp} +Provides: mysql-embedded-devel%{?_isa} = %{sameevp} Conflicts: community-mysql-embedded-devel %{?obsoleted_mysql_case_evr:Obsoletes: MySQL-embedded-devel < %{obsoleted_mysql_case_evr}} %{?obsoleted_mysql_evr:Obsoletes: mysql-embedded-devel < %{obsoleted_mysql_evr}} @@ -372,12 +383,11 @@ MariaDB is a community developed branch of MySQL. %if %{with bench} %package bench - Summary: MariaDB benchmark scripts and data Group: Applications/Databases -Requires: %{name}%{?_isa} = %{epoch}:%{version}-%{release} -Provides: mysql-bench = %{epoch}:%{version}-%{release} -Provides: mysql-bench%{?_isa} = %{epoch}:%{version}-%{release} +Requires: %{name}%{?_isa} = %{sameevp} +Provides: mysql-bench = %{sameevp} +Provides: mysql-bench%{?_isa} = %{sameevp} Conflicts: community-mysql-bench %{?obsoleted_mysql_case_evr:Obsoletes: MySQL-bench < %{obsoleted_mysql_case_evr}} %{?obsoleted_mysql_evr:Obsoletes: mysql-bench < %{obsoleted_mysql_evr}} @@ -392,22 +402,27 @@ MariaDB is a community developed branch of MySQL. %if %{with test} %package test - Summary: The test suite distributed with MariaD Group: Applications/Databases -Requires: %{name}%{?_isa} = %{epoch}:%{version}-%{release} -Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release} -Requires: %{name}-server%{?_isa} = %{epoch}:%{version}-%{release} -Provides: mysql-test = %{epoch}:%{version}-%{release} -Provides: mysql-test%{?_isa} = %{epoch}:%{version}-%{release} -Conflicts: community-mysql-test -%{?obsoleted_mysql_case_evr:Obsoletes: MySQL-test < %{obsoleted_mysql_case_evr}} -%{?obsoleted_mysql_evr:Obsoletes: mysql-test < %{obsoleted_mysql_evr}} +Requires: %{name}%{?_isa} = %{sameevp} +Requires: %{name}-common%{?_isa} = %{sameevp} +Requires: %{name}-server%{?_isa} = %{sameevp} Requires: perl(Env) +Requires: perl(Exporter) +Requires: perl(Fcntl) +Requires: perl(File::Temp) Requires: perl(Data::Dumper) +Requires: perl(Getopt::Long) +Requires: perl(IPC::Open3) Requires: perl(Socket) +Requires: perl(Sys::Hostname) Requires: perl(Test::More) Requires: perl(Time::HiRes) +Conflicts: community-mysql-test +Provides: mysql-test = %{sameevp} +Provides: mysql-test%{?_isa} = %{sameevp} +%{?obsoleted_mysql_case_evr:Obsoletes: MySQL-test < %{obsoleted_mysql_case_evr}} +%{?obsoleted_mysql_evr:Obsoletes: mysql-test < %{obsoleted_mysql_evr}} %description test MariaDB is a multi-user, multi-threaded SQL database server. This @@ -427,14 +442,14 @@ MariaDB is a community developed branch of MySQL. %patch6 -p1 %patch7 -p1 %patch8 -p1 -%patch9 -p1 -%patch10 -p1 -%patch11 -p1 -%patch12 -p1 -%patch13 -p1 -%patch14 -p1 -%patch15 -p1 -%patch16 -p1 +%patch30 -p1 +%patch31 -p1 +%patch32 -p1 +%patch33 -p1 +%patch34 -p1 +%patch35 -p1 +%patch36 -p1 +%patch37 -p1 sed -i -e 's/2.8.7/2.6.4/g' cmake/cpack_rpm.cmake @@ -462,7 +477,7 @@ cat %{SOURCE54} >> mysql-test/rh-skipped-tests.list %endif cp %{SOURCE2} %{SOURCE10} %{SOURCE11} %{SOURCE12} %{SOURCE13} %{SOURCE14} \ - %{SOURCE15} %{SOURCE16} %{SOURCE17} scripts + %{SOURCE15} %{SOURCE16} %{SOURCE17} %{SOURCE18} scripts %build @@ -493,6 +508,7 @@ CFLAGS=`echo $CFLAGS| sed -e "s|-O2|-O3|g" ` %endif CXXFLAGS="$CFLAGS" export CFLAGS CXXFLAGS + %if 0%{?_hardened_build} # building with PIE LDFLAGS="$LDFLAGS -pie -Wl,-z,relro,-z,now" @@ -508,6 +524,7 @@ cmake . -DBUILD_CONFIG=mysql_release \ %if 0%{?mysqld_unit:1} -DDAEMON_NAME2="%{mysqld_unit}" \ %endif + -DNICE_PROJECT_NAME="MariaDB" \ -DRPM="%{?rhel:rhel%{rhel}}%{!?rhel:fedora%{fedora}}" \ -DCMAKE_INSTALL_PREFIX="%{_prefix}" \ %if 0%{?fedora} >= 20 @@ -581,7 +598,7 @@ install -p -m 0755 scripts/mysql_config_multilib %{buildroot}%{_bindir}/mysql_co %endif # install INFO_SRC, INFO_BIN into libdir (upstream thinks these are doc files, -# but that's pretty wacko --- see also mariadb-file-contents.patch) +# but that's pretty wacko --- see also %%{name}-file-contents.patch) mv %{buildroot}%{_pkgdocdir}/MariaDB-server-%{version}/INFO_SRC %{buildroot}%{_libdir}/mysql/ mv %{buildroot}%{_pkgdocdir}/MariaDB-server-%{version}/INFO_BIN %{buildroot}%{_libdir}/mysql/ rm -rf %{buildroot}%{_pkgdocdir}/MariaDB-server-%{version}/ @@ -609,13 +626,15 @@ rm -f %{buildroot}%{_sysconfdir}/my.cnf # install systemd unit files and scripts for handling server startup %if %{with init_systemd} -install -D -p -m 644 scripts/mariadb.service %{buildroot}%{_unitdir}/%{daemon_name}.service -install -D -p -m 0644 scripts/mariadb.tmpfiles.d %{buildroot}%{_tmpfilesdir}/%{name}.conf +install -D -p -m 644 scripts/mysql.service %{buildroot}%{_unitdir}/%{daemon_name}.service +install -D -p -m 0644 scripts/mysql.tmpfiles.d %{buildroot}%{_tmpfilesdir}/%{name}.conf %endif # install alternative systemd unit file for compatibility reasons %if 0%{?mysqld_unit:1} -install -p -m 644 scripts/mysqld.service %{buildroot}%{_unitdir}/%{mysqld_unit}.service +install -p -m 644 scripts/mysql-compat.service %{buildroot}%{_unitdir}/%{mysqld_unit}.service +mkdir -p %{buildroot}%{_unitdir}/%{daemon_name}.service.d +install -p -m 644 scripts/mysql-compat.conf %{buildroot}%{_unitdir}/%{daemon_name}.service.d/mysql-compat.conf %endif # install SysV init script @@ -624,10 +643,10 @@ install -D -p -m 755 scripts/mysql.init %{buildroot}%{_initddir}/%{daemon_name} %endif # helper scripts for service starting -install -p -m 755 scripts/mariadb-prepare-db-dir %{buildroot}%{_libexecdir}/mariadb-prepare-db-dir -install -p -m 755 scripts/mariadb-wait-ready %{buildroot}%{_libexecdir}/mariadb-wait-ready -install -p -m 755 scripts/mariadb-check-socket %{buildroot}%{_libexecdir}/mariadb-check-socket -install -p -m 644 scripts/mariadb-scripts-common %{buildroot}%{_libexecdir}/mariadb-scripts-common +install -p -m 755 scripts/mysql-prepare-db-dir %{buildroot}%{_libexecdir}/mysql-prepare-db-dir +install -p -m 755 scripts/mysql-wait-ready %{buildroot}%{_libexecdir}/mysql-wait-ready +install -p -m 755 scripts/mysql-check-socket %{buildroot}%{_libexecdir}/mysql-check-socket +install -p -m 644 scripts/mysql-scripts-common %{buildroot}%{_libexecdir}/mysql-scripts-common # Remove libmysqld.a rm -f %{buildroot}%{_libdir}/mysql/libmysqld.a @@ -658,17 +677,17 @@ rm -f %{buildroot}%{_bindir}/mytop # put logrotate script where it needs to be mkdir -p %{buildroot}%{logrotateddir} -mv %{buildroot}%{_datadir}/%{name}/mysql-log-rotate %{buildroot}%{logrotateddir}/%{name} -chmod 644 %{buildroot}%{logrotateddir}/%{name} +mv %{buildroot}%{_datadir}/%{name}/mysql-log-rotate %{buildroot}%{logrotateddir}/%{daemon_name} +chmod 644 %{buildroot}%{logrotateddir}/%{daemon_name} mkdir -p %{buildroot}%{_sysconfdir}/ld.so.conf.d echo "%{_libdir}/mysql" > %{buildroot}%{_sysconfdir}/ld.so.conf.d/%{name}-%{_arch}.conf # copy additional docs into build tree so %%doc will find them -cp -p %{SOURCE5} . -cp -p %{SOURCE6} . -cp -p %{SOURCE7} . -cp -p %{SOURCE16} . +install -p -m 0644 %{SOURCE5} %{basename:%{SOURCE5}} +install -p -m 0644 %{SOURCE6} %{basename:%{SOURCE6}} +install -p -m 0644 %{SOURCE7} %{basename:%{SOURCE7}} +install -p -m 0644 %{SOURCE16} %{basename:%{SOURCE16}} # install the list of skipped tests to be available for user runs install -p -m 0644 mysql-test/rh-skipped-tests.list %{buildroot}%{_datadir}/mysql-test @@ -770,8 +789,8 @@ export MTR_BUILD_THREAD=%{__isa_bits} %pre server /usr/sbin/groupadd -g 27 -o -r mysql >/dev/null 2>&1 || : -/usr/sbin/useradd -M -N -g mysql -o -r -d %{_localstatedir}/lib/mysql -s /sbin/nologin \ - -c "MariaDB Server" -u 27 mysql >/dev/null 2>&1 || : +/usr/sbin/useradd -M -N -g mysql -o -r -d %{mysqluserhome} -s /sbin/nologin \ + -c "MySQL Server" -u 27 mysql >/dev/null 2>&1 || : %if %{with init_systemd} # Explicitly enable mysqld if it was enabled in the beginning @@ -805,6 +824,10 @@ fi %post libs -p /sbin/ldconfig %endif +%if %{with embedded} +%post embedded -p /sbin/ldconfig +%endif + %post server %if %{with init_systemd} %systemd_post %{daemon_name}.service @@ -816,10 +839,6 @@ fi %endif /bin/chmod 0755 %{_localstatedir}/lib/mysql -%if %{with embedded} -%post embedded -p /sbin/ldconfig -%endif - %preun server %if %{with init_systemd} %systemd_preun %{daemon_name}.service @@ -835,6 +854,10 @@ fi %postun libs -p /sbin/ldconfig %endif +%if %{with embedded} +%postun embedded -p /sbin/ldconfig +%endif + %postun server %if %{with init_systemd} %systemd_postun_with_restart %{daemon_name}.service @@ -845,10 +868,6 @@ if [ $1 -ge 1 ]; then fi %endif -%if %{with embedded} -%postun embedded -p /sbin/ldconfig -%endif - %files %doc README.mysql-docs @@ -900,9 +919,9 @@ fi %doc storage/innobase/COPYING.Percona storage/innobase/COPYING.Google # although the default my.cnf contains only server settings, we put it in the # common package because it can be used for client settings too. -%dir %{_sysconfdir}/my.cnf.d %if %{ship_my_cnf} %config(noreplace) %{_sysconfdir}/my.cnf +%dir %{_sysconfdir}/my.cnf.d %config(noreplace) %{_sysconfdir}/my.cnf.d/mysql-clients.cnf %endif %dir %{_datadir}/%{name} @@ -1019,23 +1038,24 @@ fi %{_datadir}/%{name}/my-*.cnf %{?mysqld_unit:%{_unitdir}/%{mysqld_unit}.service} +%{?mysqld_unit:%{_unitdir}/%{daemon_name}.service.d/mysql-compat.conf} %{?with_init_systemd:%{_unitdir}/%{daemon_name}.service} %{?with_init_sysv:%{_initddir}/%{daemon_name}} -%{_libexecdir}/mariadb-prepare-db-dir -%{_libexecdir}/mariadb-wait-ready -%{_libexecdir}/mariadb-check-socket -%{_libexecdir}/mariadb-scripts-common +%{_libexecdir}/mysql-prepare-db-dir +%{_libexecdir}/mysql-wait-ready +%{_libexecdir}/mysql-check-socket +%{_libexecdir}/mysql-scripts-common %{?with_init_systemd:%{_tmpfilesdir}/%{name}.conf} %attr(0755,mysql,mysql) %dir %{_localstatedir}/run/mysqld -%attr(0755,mysql,mysql) %dir %{_localstatedir}/run/%{name} +%attr(0755,mysql,mysql) %dir %{_localstatedir}/run/%{daemon_name} %attr(0755,mysql,mysql) %dir %{_localstatedir}/lib/mysql %attr(0750,mysql,mysql) %dir %{logfiledir} %attr(0640,mysql,mysql) %config %ghost %verify(not md5 size mtime) %{logfile} %if 0%{?old_logfile:1} %config %ghost %verify(not md5 size mtime) %{old_logfile} %endif -%config(noreplace) %{logrotateddir}/%{name} +%config(noreplace) %{logrotateddir}/%{daemon_name} %if %{with oqgraph} %files oqgraph @@ -1081,6 +1101,7 @@ fi %changelog * Tue Jul 22 2014 Honza Horak - 1:10.0.12-5 +- Spec rewrite to be more similar to oterh MySQL implementations - Use variable for daemon unit name - Include SysV init script if built on older system - Add possibility to not ship some sub-packages diff --git a/mariadb.tmpfiles.d.in b/mariadb.tmpfiles.d.in deleted file mode 100644 index 3799c46..0000000 --- a/mariadb.tmpfiles.d.in +++ /dev/null @@ -1,2 +0,0 @@ -d /var/run/@DAEMON_NAME2@ 0755 mysql mysql - -d /var/run/@DAEMON_NAME@ 0755 mysql mysql - diff --git a/mysql-check-socket.sh b/mysql-check-socket.sh new file mode 100644 index 0000000..b15cd32 --- /dev/null +++ b/mysql-check-socket.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# We check if there is already a process using the socket file, +# since otherwise the systemd service file could report false +# positive result when starting and mysqld_safe could remove +# a socket file, which is actually being used by a different daemon. + +source "`dirname ${BASH_SOURCE[0]}`/mysql-scripts-common" + +if test -e "$socketfile" ; then + echo "Socket file $socketfile exists." >&2 + + # no write permissions + if ! test -w "$socketfile" ; then + echo "Not enough permission to write to the socket file $socketfile, which is suspicious." >&2 + echo "Please, remove $socketfile manually to start the service." >&2 + exit 1 + fi + + # not a socket file + if ! test -S "$socketfile" ; then + echo "The file $socketfile is not a socket file, which is suspicious." >&2 + echo "Please, remove $socketfile manually to start the service." >&2 + exit 1 + fi + + # some process uses the socket file + if fuser "$socketfile" &>/dev/null ; then + socketpid=$(fuser "$socketfile" 2>/dev/null) + echo "Is another MySQL daemon already running with the same unix socket?" >&2 + echo "Please, stop the process $socketpid or remove $socketfile manually to start the service." >&2 + exit 1 + fi + + # socket file is a garbage + echo "No process is using $socketfile, which means it is a garbage, so it will be removed automatically." >&2 +fi + +exit 0 diff --git a/mysql-compat.service.in b/mysql-compat.service.in new file mode 100644 index 0000000..acd6c44 --- /dev/null +++ b/mysql-compat.service.in @@ -0,0 +1,12 @@ +[Unit] +Description=MySQL compatibility service (another name for @DAEMON_NAME@.service; you should use @DAEMON_NAME@.service instead) +BindsTo=@DAEMON_NAME@.service + +[Service] +Type=oneshot +ExecStart=/bin/true +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target +Also=@DAEMON_NAME@.service diff --git a/mysql-prepare-db-dir.sh b/mysql-prepare-db-dir.sh new file mode 100644 index 0000000..0507f52 --- /dev/null +++ b/mysql-prepare-db-dir.sh @@ -0,0 +1,87 @@ +#!/bin/sh + +# This script creates the mysql data directory during first service start. +# In subsequent starts, it does nothing much. + +source "`dirname ${BASH_SOURCE[0]}`/mysql-scripts-common" + +# If two args given first is user, second is group +# otherwise the arg is the systemd service file +if [ "$#" -eq 2 ] +then + myuser="$1" + mygroup="$2" +else + # Absorb configuration settings from the specified systemd service file, + # or the default service if not specified + SERVICE_NAME="$1" + if [ x"$SERVICE_NAME" = x ] + then + SERVICE_NAME=@DAEMON_NAME@.service + fi + + myuser=`systemctl show -p User "${SERVICE_NAME}" | + sed 's/^User=//'` + if [ x"$myuser" = x ] + then + myuser=mysql + fi + + mygroup=`systemctl show -p Group "${SERVICE_NAME}" | + sed 's/^Group=//'` + if [ x"$mygroup" = x ] + then + mygroup=mysql + fi +fi + +# Set up the errlogfile with appropriate permissions +touch "$errlogfile" +ret=$? +# Provide some advice if the log file cannot be touched +if [ $ret -ne 0 ] ; then + errlogdir=$(dirname $errlogfile) + if ! [ -d "$errlogdir" ] ; then + echo "The directory $errlogdir does not exist." + elif [ -f "$errlogfile" ] ; then + echo "The log file $errlogfile cannot be touched, please, fix its permissions." + else + echo "The log file $errlogfile could not be created." + fi + echo "The daemon will be run under $myuser:$mygroup" + exit 1 +fi +chown "$myuser:$mygroup" "$errlogfile" +chmod 0640 "$errlogfile" +[ -x /sbin/restorecon ] && /sbin/restorecon "$errlogfile" + +# Make the data directory +if [ ! -d "$datadir/mysql" ] ; then + # First, make sure $datadir is there with correct permissions + # (note: if it's not, and we're not root, this'll fail ...) + if [ ! -e "$datadir" -a ! -h "$datadir" ] + then + mkdir -p "$datadir" || exit 1 + fi + chown "$myuser:$mygroup" "$datadir" + chmod 0755 "$datadir" + [ -x /sbin/restorecon ] && /sbin/restorecon "$datadir" + + # Now create the database + echo "Initializing @NICE_PROJECT_NAME@ database" + @bindir@/mysql_install_db --datadir="$datadir" --user="$myuser" + ret=$? + if [ $ret -ne 0 ] ; then + echo "Initialization of @NICE_PROJECT_NAME@ database failed." >&2 + echo "Perhaps @sysconfdir@/my.cnf is misconfigured." >&2 + # Clean up any partially-created database files + if [ ! -e "$datadir/mysql/user.frm" ] ; then + rm -rf "$datadir"/* + fi + exit $ret + fi + # In case we're running as root, make sure files are owned properly + chown -R "$myuser:$mygroup" "$datadir" +fi + +exit 0 diff --git a/mysql-scripts-common.sh b/mysql-scripts-common.sh new file mode 100755 index 0000000..7ce9a11 --- /dev/null +++ b/mysql-scripts-common.sh @@ -0,0 +1,58 @@ +#!/bin/sh + +# Some useful functions used in other MySQL helper scripts +# This scripts defines variables datadir, errlogfile, socketfile + +export LC_ALL=C + +# extract value of a MySQL option from config files +# Usage: get_mysql_option VARNAME DEFAULT SECTION [ SECTION, ... ] +# result is returned in $result +# We use my_print_defaults which prints all options from multiple files, +# with the more specific ones later; hence take the last match. +get_mysql_option(){ + if [ $# -ne 3 ] ; then + echo "get_mysql_option requires 3 arguments: section option default_value" + return + fi + sections="$1" + option_name="$2" + default_value="$3" + result=`/usr/bin/my_print_defaults $sections | sed -n "s/^--${option_name}=//p" | tail -n 1` + if [ -z "$result" ]; then + # not found, use default + result="${default_value}" + fi +} + +# Defaults here had better match what mysqld_safe will default to +# The option values are generally defined on three important places +# on the default installation: +# 1) default values are hardcoded in the code of mysqld daemon or +# mysqld_safe script +# 2) configurable values are defined in /etc/my.cnf +# 3) default values for helper scripts are specified bellow +# So, in case values are defined in my.cnf, we need to get that value. +# In case they are not defined in my.cnf, we need to get the same value +# in the daemon, as in the helper scripts. Thus, default values here +# must correspond with values defined in mysqld_safe script and source +# code itself. + +server_sections="mysqld_safe mysqld server mysqld-@MAJOR_VERSION@.@MINOR_VERSION@ mariadb mariadb-@MAJOR_VERSION@.@MINOR_VERSION@ client-server" + +get_mysql_option "$server_sections" datadir "@MYSQL_DATADIR@" +datadir="$result" + +# if there is log_error in the my.cnf, my_print_defaults still +# returns log-error +# log-error might be defined in mysqld_safe and mysqld sections, +# the former has bigger priority +get_mysql_option "$server_sections" log-error "`hostname`.err" +errlogfile="$result" + +get_mysql_option "$server_sections" socket "@MYSQL_UNIX_ADDR@" +socketfile="$result" + +get_mysql_option "$server_sections" pid-file "`hostname`.pid" +pidfile="$result" + diff --git a/mysql-wait-ready.sh b/mysql-wait-ready.sh new file mode 100644 index 0000000..2ed5fe1 --- /dev/null +++ b/mysql-wait-ready.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +source "`dirname ${BASH_SOURCE[0]}`/mysql-scripts-common" + +# This script waits for mysqld to be ready to accept connections +# (which can be many seconds or even minutes after launch, if there's +# a lot of crash-recovery work to do). +# Running this as ExecStartPost is useful so that services declared as +# "After mysqld" won't be started until the database is really ready. + +if [ $# -ne 1 ] ; then + echo "You need to pass daemon pid as an argument for this script." + exit 20 +fi + +# Service file passes us the daemon's PID (actually, mysqld_safe's PID) +daemon_pid="$1" + +# Wait for the server to come up or for the mysqld process to disappear +ret=0 +while /bin/true; do + # Check process still exists + if ! [ -d "/proc/${daemon_pid}" ] ; then + ret=1 + break + fi + RESPONSE=`@bindir@/mysqladmin --no-defaults --socket="$socketfile" --user=UNKNOWN_MYSQL_USER ping 2>&1` + mret=$? + if [ $mret -eq 0 ] ; then + break + fi + # exit codes 1, 11 (EXIT_CANNOT_CONNECT_TO_SERVICE) are expected, + # anything else suggests a configuration error + if [ $mret -ne 1 -a $mret -ne 11 ]; then + echo "Cannot check for @NICE_PROJECT_NAME@ Daemon startup because of mysqladmin failure." >&2 + ret=$mret + break + fi + # "Access denied" also means the server is alive + echo "$RESPONSE" | grep -q "Access denied for user" && break + + sleep 1 +done + +exit $ret diff --git a/mysql.service.in b/mysql.service.in new file mode 100644 index 0000000..4c2b60a --- /dev/null +++ b/mysql.service.in @@ -0,0 +1,49 @@ +# It's not recommended to modify this file in-place, because it will be +# overwritten during package upgrades. If you want to customize, the +# best way is to create a file "/etc/systemd/system/@DAEMON_NAME@.service", +# containing +# .include /usr/lib/systemd/system/@DAEMON_NAME@.service +# ...make your changes here... +# or create a file "/etc/systemd/system/@DAEMON_NAME@.service.d/foo.conf", +# which doesn't need to include ".include" call and which will be parsed +# after the file @DAEMON_NAME@.service itself is parsed. +# +# For more info about custom unit files, see systemd.unit(5) or +# http://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F + +# For example, if you want to increase mysql's open-files-limit to 10000, +# you need to increase systemd's LimitNOFILE setting, so create a file named +# "/etc/systemd/system/@DAEMON_NAME@.service.d/limits.conf" containing: +# [Service] +# LimitNOFILE=10000 + +# Note: /usr/lib/... is recommended in the .include line though /lib/... +# still works. +# Don't forget to reload systemd daemon after you change unit configuration: +# root> systemctl --system daemon-reload + +[Unit] +Description=@NICE_PROJECT_NAME@ @MAJOR_VERSION@.@MINOR_VERSION@ database server +After=syslog.target +After=network.target + +[Service] +Type=simple +User=mysql +Group=mysql + +ExecStartPre=@libexecdir@/mysql-check-socket +ExecStartPre=@libexecdir@/mysql-prepare-db-dir %n +# Note: we set --basedir to prevent probes that might trigger SELinux alarms, +# per bug #547485 +ExecStart=@bindir@/mysqld_safe --basedir=@prefix@ +ExecStartPost=@libexecdir@/mysql-wait-ready $MAINPID + +# Give a reasonable amount of time for the server to start up/shut down +TimeoutSec=300 + +# Place temp files in a secure directory, not /tmp +PrivateTmp=true + +[Install] +WantedBy=multi-user.target diff --git a/mysql.tmpfiles.d.in b/mysql.tmpfiles.d.in new file mode 100644 index 0000000..3799c46 --- /dev/null +++ b/mysql.tmpfiles.d.in @@ -0,0 +1,2 @@ +d /var/run/@DAEMON_NAME2@ 0755 mysql mysql - +d /var/run/@DAEMON_NAME@ 0755 mysql mysql - diff --git a/mysqld.service.in b/mysqld.service.in deleted file mode 100644 index acd6c44..0000000 --- a/mysqld.service.in +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=MySQL compatibility service (another name for @DAEMON_NAME@.service; you should use @DAEMON_NAME@.service instead) -BindsTo=@DAEMON_NAME@.service - -[Service] -Type=oneshot -ExecStart=/bin/true -RemainAfterExit=yes - -[Install] -WantedBy=multi-user.target -Also=@DAEMON_NAME@.service