Spec rewrite to be more similar to oterh MySQL implementations

This commit is contained in:
Honza Horak 2014-07-24 10:00:55 +02:00
parent 99fd710fa5
commit 75032c40af
12 changed files with 656 additions and 174 deletions

View File

@ -1,7 +1,7 @@
diff -rup mysql-5.6.19-orig/scripts/CMakeLists.txt mysql-5.6.19/scripts/CMakeLists.txt diff -rup mysql-5.6.19-orig/scripts/CMakeLists.txt mysql-5.6.19/scripts/CMakeLists.txt
--- mysql-5.6.19-orig/scripts/CMakeLists.txt 2014-07-22 10:07:12.053410263 +0200 --- mysql-5.6.19-orig/scripts/CMakeLists.txt 2014-07-22 10:07:12.053410263 +0200
+++ mysql-5.6.19/scripts/CMakeLists.txt 2014-07-22 10:10:44.102502369 +0200 +++ mysql-5.6.19/scripts/CMakeLists.txt 2014-07-22 10:10:44.102502369 +0200
@@ -381,6 +381,28 @@ ELSE() @@ -381,6 +381,30 @@ ELSE()
ENDIF() ENDIF()
INSTALL_SCRIPT(${CMAKE_CURRENT_BINARY_DIR}/${file} COMPONENT ${${file}_COMPONENT}) INSTALL_SCRIPT(${CMAKE_CURRENT_BINARY_DIR}/${file} COMPONENT ${${file}_COMPONENT})
ENDFOREACH() ENDFOREACH()
@ -9,11 +9,13 @@ diff -rup mysql-5.6.19-orig/scripts/CMakeLists.txt mysql-5.6.19/scripts/CMakeLis
+ # files for systemd + # files for systemd
+ SET(SYSTEMD_SCRIPTS + SET(SYSTEMD_SCRIPTS
+ mysql.tmpfiles.d + mysql.tmpfiles.d
+ mysqld.service + mysql.service
+ mysqld-prepare-db-dir + mysql-prepare-db-dir
+ mysqld-wait-ready + mysql-wait-ready
+ mysqld-check-socket + mysql-check-socket
+ mysqld-scripts-common + mysql-scripts-common
+ mysql_config_multilib
+ mysql.init
+ ) + )
+ FOREACH(file ${SYSTEMD_SCRIPTS}) + FOREACH(file ${SYSTEMD_SCRIPTS})
+ IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh) + IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh)

View File

@ -1,3 +1,6 @@
# Name of the package without any prefixes
%global pkgname community-mysql
# Regression tests may take a long time (many cores recommended), skip them by # 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 # passing --nocheck to rpmbuild or by setting runselftest to 0 if defining
# --nocheck is not possible (e.g. in koji build) # --nocheck is not possible (e.g. in koji build)
@ -22,10 +25,40 @@
# my.cnf and my.cnf.d # my.cnf and my.cnf.d
%global ship_my_cnf 0 %global ship_my_cnf 0
# Name for the systemd unit file # For some use cases we do not need some parts of the package
%global daemon_name mysqld.service %bcond_without clibrary
%bcond_without embedded
%bcond_without devel
%bcond_without client
%bcond_without common
%bcond_without errmsg
%bcond_without bench
%bcond_without test
Name: community-mysql # Include files for SysV init or systemd
%if 0%{?fedora} >= 15
%bcond_without init_systemd
%bcond_with init_sysv
%global daemon_name mysqld
%else
%bcond_with init_systemd
%bcond_without init_sysv
%global daemon_name mysqld
%endif
# We define some system's well known locations here so we can use them easily
# later when building to another location (like SCL)
%global logrotateddir %{_sysconfdir}/logrotate.d
%global logfiledir %{_localstatedir}/log
%global logfile %{_localstatedir}/log/%{name}.log
# Home directory of mysql user should be same for all packages that create it
%global mysqluserhome /var/lib/mysql
# Make long macros shorter
%global sameevp %{?epoch:%{epoch}:}%{version}-%{release}
Name: %{pkgname}
Version: 5.6.19 Version: 5.6.19
Release: 5%{?dist} Release: 5%{?dist}
Summary: MySQL client programs and shared libraries Summary: MySQL client programs and shared libraries
@ -37,38 +70,42 @@ URL: http://www.mysql.com
License: GPLv2 with exceptions and LGPLv2 and BSD License: GPLv2 with exceptions and LGPLv2 and BSD
Source0: https://cdn.mysql.com/Downloads/MySQL-5.6/mysql-%{version}.tar.gz Source0: https://cdn.mysql.com/Downloads/MySQL-5.6/mysql-%{version}.tar.gz
Source2: mysql_config_multilib.sh
Source3: my.cnf Source3: my.cnf
Source4: mysql_config_multilib.sh Source4: my_config.h
Source5: my_config.h
Source6: README.mysql-docs Source6: README.mysql-docs
Source7: README.mysql-license Source7: README.mysql-license
Source10: mysql.tmpfiles.d.in Source10: mysql.tmpfiles.d.in
Source11: mysqld.service.in Source11: mysql.service.in
Source12: mysqld-prepare-db-dir.sh Source12: mysql-prepare-db-dir.sh
Source13: mysqld-wait-ready.sh Source13: mysql-wait-ready.sh
Source14: mysqld-check-socket.sh Source14: mysql-check-socket.sh
Source15: mysqld-scripts-common.sh Source15: mysql-scripts-common.sh
Source17: mysql.init.in
# To track rpmlint warnings # To track rpmlint warnings
Source17: mysql-5.6.10-rpmlintrc Source30: mysql-5.6.10-rpmlintrc
# Comments for these patches are in the patch files # Comments for these patches are in the patch files
Patch2: community-mysql-strmov.patch # Patches common for more mysql-like packages
Patch3: community-mysql-install-test.patch Patch1: %{pkgname}-strmov.patch
Patch4: community-mysql-expired-certs.patch Patch2: %{pkgname}-install-test.patch
Patch6: community-mysql-chain-certs.patch Patch3: %{pkgname}-s390-tsc.patch
Patch11: community-mysql-s390-tsc.patch Patch4: %{pkgname}-logrotate.patch
Patch16: community-mysql-logrotate.patch Patch5: %{pkgname}-cipherspec.patch
Patch18: community-mysql-5.6.11-cipherspec.patch Patch6: %{pkgname}-file-contents.patch
Patch19: community-mysql-file-contents.patch Patch7: %{pkgname}-dh1024.patch
Patch21: community-mysql-dh1024.patch Patch8: %{pkgname}-scripts.patch
Patch22: community-mysql-sharedir.patch
Patch23: community-mysql-5.6.16-libmysql-version.patch # Patches specific for this mysql package
Patch24: community-mysql-man-pages.patch Patch50: %{pkgname}-expired-certs.patch
Patch25: community-mysql-5.6.16-mysql-install.patch Patch51: %{pkgname}-chain-certs.patch
Patch26: community-mysql-5.6.13-major.patch Patch52: %{pkgname}-sharedir.patch
Patch34: community-mysql-pluginerrmsg.patch Patch53: %{pkgname}-5.6.16-libmysql-version.patch
Patch35: community-mysql-5.6.19-gcc49-aarch64-opt.patch Patch54: %{pkgname}-man-pages.patch
Patch37: community-mysql-scripts.patch Patch55: %{pkgname}-5.6.16-mysql-install.patch
Patch56: %{pkgname}-pluginerrmsg.patch
Patch57: %{pkgname}-5.6.19-gcc49-aarch64-opt.patch
Patch70: %{pkgname}-5.6.13-major.patch
BuildRequires: cmake BuildRequires: cmake
BuildRequires: dos2unix BuildRequires: dos2unix
@ -86,21 +123,25 @@ BuildRequires: perl(Env)
BuildRequires: perl(Exporter) BuildRequires: perl(Exporter)
BuildRequires: perl(Fcntl) BuildRequires: perl(Fcntl)
BuildRequires: perl(File::Temp) BuildRequires: perl(File::Temp)
BuildRequires: perl(Data::Dumper)
BuildRequires: perl(Getopt::Long) BuildRequires: perl(Getopt::Long)
BuildRequires: perl(IPC::Open3) BuildRequires: perl(IPC::Open3)
BuildRequires: perl(Socket) BuildRequires: perl(Socket)
BuildRequires: perl(Sys::Hostname) BuildRequires: perl(Sys::Hostname)
BuildRequires: perl(Test::More)
BuildRequires: perl(Time::HiRes) BuildRequires: perl(Time::HiRes)
BuildRequires: systemd %{?with_init_systemd:BuildRequires: systemd}
Requires: bash Requires: bash
Requires: fileutils Requires: fileutils
Requires: grep Requires: grep
Requires: %{name}-common%{?_isa} = %{version}-%{release} Requires: %{name}-common%{?_isa} = %{sameevp}
Provides: mysql = %{version}-%{release}
Provides: mysql%{?_isa} = %{version}-%{release} Provides: mysql = %{sameevp}
Provides: mysql-compat-client = %{version}-%{release} Provides: mysql%{?_isa} = %{sameevp}
Provides: mysql-compat-client%{?_isa} = %{version}-%{release} Provides: mysql-compat-client = %{sameevp}
Provides: mysql-compat-client%{?_isa} = %{sameevp}
Conflicts: mariadb Conflicts: mariadb
# mysql-cluster used to be built from this SRPM, but no more # mysql-cluster used to be built from this SRPM, but no more
Obsoletes: mysql-cluster < 5.1.44 Obsoletes: mysql-cluster < 5.1.44
@ -122,20 +163,23 @@ and many different client programs and libraries. The base package
contains the standard MySQL client programs and generic MySQL files. contains the standard MySQL client programs and generic MySQL files.
%if %{with clibrary}
%package libs %package libs
Summary: The shared libraries required for MySQL clients Summary: The shared libraries required for MySQL clients
Group: Applications/Databases Group: Applications/Databases
Requires: %{name}-common%{?_isa} = %{version}-%{release} Requires: %{name}-common%{?_isa} = %{sameevp}
Provides: mysql-libs = %{version}-%{release} Provides: mysql-libs = %{sameevp}
Provides: mysql-libs%{?_isa} = %{version}-%{release} Provides: mysql-libs%{?_isa} = %{sameevp}
%description libs %description libs
The mysql-libs package provides the essential shared libraries for any The mysql-libs package provides the essential shared libraries for any
MySQL client program or interface. You will need to install this package MySQL client program or interface. You will need to install this package
to use any other MySQL package or any clients that need to connect to a to use any other MySQL package or any clients that need to connect to a
MySQL server. MySQL server.
%endif
%if %{with common}
%package common %package common
Summary: The shared files required for MySQL server and client Summary: The shared files required for MySQL server and client
Group: Applications/Databases Group: Applications/Databases
@ -147,40 +191,49 @@ Requires: %{_sysconfdir}/my.cnf
The mysql-common package provides the essential shared files for any The mysql-common package provides the essential shared files for any
MySQL program. You will need to install this package to use any other MySQL program. You will need to install this package to use any other
MySQL package. MySQL package.
%endif
%if %{with errmsg}
%package errmsg %package errmsg
Summary: The error messages files required by server and embedded Summary: The error messages files required by server and embedded
Group: Applications/Databases Group: Applications/Databases
Requires: %{name}-common%{?_isa} = %{version}-%{release} Requires: %{name}-common%{?_isa} = %{sameevp}
%description errmsg %description errmsg
The package provides error messages files for the MySQL daemon and the The package provides error messages files for the MySQL daemon and the
embedded server. You will need to install this package to use any of those embedded server. You will need to install this package to use any of those
MySQL packages. MySQL packages.
%endif
%package server %package server
Summary: The MySQL server and related files Summary: The MySQL server and related files
Group: Applications/Databases Group: Applications/Databases
# note: no version here = %{version}-%{release} # note: no version here = %{sameevp}
Requires: mysql-compat-client%{?_isa} Requires: mysql-compat-client%{?_isa}
Requires: %{name}-common%{?_isa} = %{version}-%{release} Requires: %{name}-common%{?_isa} = %{sameevp}
Requires: %{name}-errmsg%{?_isa} = %{version}-%{release} %if %{without common}
Requires: %{_sysconfdir}/my.cnf
Requires: %{_sysconfdir}/my.cnf.d
%endif
Requires: %{name}-errmsg%{?_isa} = %{sameevp}
Requires: sh-utils Requires: sh-utils
Requires(pre): /usr/sbin/useradd Requires(pre): /usr/sbin/useradd
# We require this to be present for %%{_prefix}/lib/tmpfiles.d %if %{with init_systemd}
# We require this to be present for %%{_tmpfilesdir}
Requires: systemd Requires: systemd
# Make sure it's there when scriptlets run, too # Make sure it's there when scriptlets run, too
%{?systemd_requires: %systemd_requires} %{?systemd_requires: %systemd_requires}
%endif
# mysqlhotcopy needs DBI/DBD support # mysqlhotcopy needs DBI/DBD support
Requires: perl(DBI) Requires: perl(DBI)
Requires: perl(DBD::mysql) Requires: perl(DBD::mysql)
Provides: mysql-server = %{version}-%{release} Provides: mysql-server = %{sameevp}
Provides: mysql-server%{?_isa} = %{version}-%{release} Provides: mysql-server%{?_isa} = %{sameevp}
Provides: mysql-compat-server = %{version}-%{release} Provides: mysql-compat-server = %{sameevp}
Provides: mysql-compat-server%{?_isa} = %{version}-%{release} Provides: mysql-compat-server%{?_isa} = %{sameevp}
Conflicts: mariadb-server Conflicts: mariadb-server
Conflicts: mariadb-galera-server Conflicts: mariadb-galera-server
@ -191,11 +244,11 @@ and many different client programs and libraries. This package contains
the MySQL server and some accompanying files and directories. the MySQL server and some accompanying files and directories.
%if %{with devel}
%package devel %package devel
Summary: Files for development of MySQL applications Summary: Files for development of MySQL applications
Group: Applications/Databases Group: Applications/Databases
Requires: %{name}%{?_isa} = %{version}-%{release} Requires: %{name}-libs%{?_isa} = %{sameevp}
Requires: %{name}-libs%{?_isa} = %{version}-%{release}
Requires: openssl-devel%{?_isa} Requires: openssl-devel%{?_isa}
Conflicts: mariadb-devel Conflicts: mariadb-devel
@ -203,15 +256,17 @@ Conflicts: mariadb-devel
MySQL is a multi-user, multi-threaded SQL database server. This MySQL is a multi-user, multi-threaded SQL database server. This
package contains the libraries and header files that are needed for package contains the libraries and header files that are needed for
developing MySQL client applications. developing MySQL client applications.
%endif
%if %{with embedded}
%package embedded %package embedded
Summary: MySQL as an embeddable library Summary: MySQL as an embeddable library
Group: Applications/Databases Group: Applications/Databases
Requires: %{name}-common%{?_isa} = %{version}-%{release} Requires: %{name}-common%{?_isa} = %{sameevp}
Requires: %{name}-errmsg%{?_isa} = %{version}-%{release} Requires: %{name}-errmsg%{?_isa} = %{sameevp}
Provides: mysql-embedded = %{version}-%{release} Provides: mysql-embedded = %{sameevp}
Provides: mysql-embedded%{?_isa} = %{version}-%{release} Provides: mysql-embedded%{?_isa} = %{sameevp}
%description embedded %description embedded
MySQL is a multi-user, multi-threaded SQL database server. This MySQL is a multi-user, multi-threaded SQL database server. This
@ -222,67 +277,83 @@ into a client application instead of running as a separate process.
%package embedded-devel %package embedded-devel
Summary: Development files for MySQL as an embeddable library Summary: Development files for MySQL as an embeddable library
Group: Applications/Databases Group: Applications/Databases
Requires: %{name}-embedded%{?_isa} = %{version}-%{release} Requires: %{name}-embedded%{?_isa} = %{sameevp}
Requires: %{name}-devel%{?_isa} = %{version}-%{release} Requires: %{name}-devel%{?_isa} = %{sameevp}
Conflicts: mariadb-embedded-devel Conflicts: mariadb-embedded-devel
%description embedded-devel %description embedded-devel
MySQL is a multi-user, multi-threaded SQL database server. This MySQL is a multi-user, multi-threaded SQL database server. This
package contains files needed for developing and testing with package contains files needed for developing and testing with
the embedded version of the MySQL server. the embedded version of the MySQL server.
%endif
%if %{with bench}
%package bench %package bench
Summary: MySQL benchmark scripts and data Summary: MySQL benchmark scripts and data
Group: Applications/Databases Group: Applications/Databases
Requires: %{name}%{?_isa} = %{version}-%{release} Requires: %{name}%{?_isa} = %{sameevp}
Conflicts: mariadb-bench Conflicts: mariadb-bench
Provides: mysql-bench = %{version}-%{release} Provides: mysql-bench = %{sameevp}
Provides: mysql-bench%{?_isa} = %{version}-%{release} Provides: mysql-bench%{?_isa} = %{sameevp}
%description bench %description bench
MySQL is a multi-user, multi-threaded SQL database server. This MySQL is a multi-user, multi-threaded SQL database server. This
package contains benchmark scripts and data for use when benchmarking package contains benchmark scripts and data for use when benchmarking
MySQL. MySQL.
%endif
%if %{with test}
%package test %package test
Summary: The test suite distributed with MySQL Summary: The test suite distributed with MySQL
Group: Applications/Databases Group: Applications/Databases
Requires: %{name}%{?_isa} = %{version}-%{release} Requires: %{name}%{?_isa} = %{sameevp}
Requires: %{name}-common%{?_isa} = %{version}-%{release} Requires: %{name}-common%{?_isa} = %{sameevp}
Requires: %{name}-server%{?_isa} = %{version}-%{release} 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: mariadb-test Conflicts: mariadb-test
Provides: mysql-test = %{version}-%{release} Provides: mysql-test = %{sameevp}
Provides: mysql-test%{?_isa} = %{version}-%{release} Provides: mysql-test%{?_isa} = %{sameevp}
%description test %description test
MySQL is a multi-user, multi-threaded SQL database server. This MySQL is a multi-user, multi-threaded SQL database server. This
package contains the regression test suite distributed with package contains the regression test suite distributed with
the MySQL sources. the MySQL sources.
%endif
%prep %prep
%setup -q -n mysql-%{version} %setup -q -n mysql-%{version}
%patch1 -p1
%patch2 -p1 %patch2 -p1
%patch3 -p1 %patch3 -p1
%patch4 -p1 %patch4 -p1
%patch5 -p1
%patch6 -p1 %patch6 -p1
%patch11 -p1 %patch7 -p1
%patch16 -p1 %patch8 -p1
%patch18 -p1 %patch50 -p1
%patch19 -p1 %patch51 -p1
%patch21 -p1 %patch52 -p1
%patch22 -p1 %patch53 -p1
%patch23 -p1 %patch54 -p1
%patch24 -p1 %patch55 -p1
%patch25 -p1 %patch56 -p1
%patch57 -p1
%if %{with_shared_lib_major_hack} %if %{with_shared_lib_major_hack}
%patch26 -p1 %patch70 -p1
%endif %endif
%patch34 -p1
%patch35 -p1
%patch37 -p1
# Modify tests to pass on all archs # Modify tests to pass on all archs
pushd mysql-test pushd mysql-test
@ -320,8 +391,8 @@ add_test 'main.upgrade : unknown'
%endif %endif
popd popd
cp %{SOURCE10} %{SOURCE11} %{SOURCE12} %{SOURCE13} %{SOURCE14} \ cp %{SOURCE2} %{SOURCE10} %{SOURCE11} %{SOURCE12} %{SOURCE13} %{SOURCE14} \
%{SOURCE15} scripts %{SOURCE15} %{SOURCE17} scripts
%build %build
# fail quickly and obviously if user tries to build as root # fail quickly and obviously if user tries to build as root
@ -337,12 +408,27 @@ cp %{SOURCE10} %{SOURCE11} %{SOURCE12} %{SOURCE13} %{SOURCE14} \
# build out of source # build out of source
mkdir build && pushd build mkdir build && pushd build
# significant performance gains can be achieved by compiling with -O3 optimization
# rhbz#1051069
%ifarch ppc64
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"
export LDFLAGS
%endif
# The INSTALL_xxx macros have to be specified relative to CMAKE_INSTALL_PREFIX # The INSTALL_xxx macros have to be specified relative to CMAKE_INSTALL_PREFIX
# so we can't use %%{_datadir} and so forth here. # so we can't use %%{_datadir} and so forth here.
cmake .. -DBUILD_CONFIG=mysql_release \ cmake .. -DBUILD_CONFIG=mysql_release \
-DFEATURE_SET="community" \ -DFEATURE_SET="community" \
-DINSTALL_LAYOUT=RPM \ -DINSTALL_LAYOUT=RPM \
-DDAEMON_NAME="%{daemon_name}" \ -DDAEMON_NAME="%{daemon_name}" \
-DNICE_PROJECT_NAME="MySQL" \
-DCMAKE_INSTALL_PREFIX="%{_prefix}" \ -DCMAKE_INSTALL_PREFIX="%{_prefix}" \
%if 0%{?fedora} >= 20 %if 0%{?fedora} >= 20
-DINSTALL_DOCDIR="share/doc/%{name}" \ -DINSTALL_DOCDIR="share/doc/%{name}" \
@ -379,6 +465,8 @@ cmake .. -DBUILD_CONFIG=mysql_release \
make %{?_smp_mflags} VERBOSE=1 make %{?_smp_mflags} VERBOSE=1
popd
%install %install
pushd build pushd build
make DESTDIR=%{buildroot} install make DESTDIR=%{buildroot} install
@ -390,19 +478,19 @@ unamei=$(uname -i)
unamei=arm unamei=arm
%endif %endif
%ifarch %{arm} aarch64 %{ix86} x86_64 ppc %{power64} %{sparc} s390 s390x %ifarch %{arm} aarch64 %{ix86} x86_64 ppc %{power64} %{sparc} s390 s390x
mv %{buildroot}%{_includedir}/mysql/my_config.h %{buildroot}%{_includedir}/mysql/my_config_$unamei.h mv %{buildroot}%{_includedir}/mysql/my_config.h %{buildroot}%{_includedir}/mysql/my_config_${unamei}.h
install -p -m 644 %{SOURCE5} %{buildroot}%{_includedir}/mysql/ install -p -m 644 %{SOURCE4} %{buildroot}%{_includedir}/mysql/
mv %{buildroot}%{_bindir}/mysql_config %{buildroot}%{_bindir}/mysql_config-%{__isa_bits} mv %{buildroot}%{_bindir}/mysql_config %{buildroot}%{_bindir}/mysql_config-%{__isa_bits}
install -p -m 0755 %{SOURCE4} %{buildroot}%{_bindir}/mysql_config install -p -m 0755 scripts/mysql_config_multilib %{buildroot}%{_bindir}/mysql_config
%endif %endif
# install INFO_SRC, INFO_BIN into libdir (upstream thinks these are doc files, # install INFO_SRC, INFO_BIN into libdir (upstream thinks these are doc files,
# but that's pretty wacko --- see also mysql-file-contents.patch) # but that's pretty wacko --- see also %%{name}-file-contents.patch)
install -p -m 0644 Docs/INFO_SRC %{buildroot}%{_libdir}/mysql/ install -p -m 0644 Docs/INFO_SRC %{buildroot}%{_libdir}/mysql/
install -p -m 0644 Docs/INFO_BIN %{buildroot}%{_libdir}/mysql/ install -p -m 0644 Docs/INFO_BIN %{buildroot}%{_libdir}/mysql/
mkdir -p %{buildroot}%{_localstatedir}/log mkdir -p %{buildroot}%{logfiledir}
touch %{buildroot}%{_localstatedir}/log/mysqld.log touch %{buildroot}%{logfile}
mkdir -p %{buildroot}%{_localstatedir}/run/mysqld mkdir -p %{buildroot}%{_localstatedir}/run/mysqld
install -p -m 0755 -d %{buildroot}%{_localstatedir}/lib/mysql install -p -m 0755 -d %{buildroot}%{_localstatedir}/lib/mysql
@ -412,13 +500,21 @@ install -D -p -m 0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/my.cnf
%endif %endif
# install systemd unit files and scripts for handling server startup # install systemd unit files and scripts for handling server startup
install -D -p -m 644 scripts/mysqld.service %{buildroot}%{_unitdir}/%{daemon_name} %if %{with init_systemd}
install -p -m 755 scripts/mysqld-prepare-db-dir %{buildroot}%{_libexecdir}/mysqld-prepare-db-dir install -D -p -m 644 scripts/mysql.service %{buildroot}%{_unitdir}/%{daemon_name}.service
install -p -m 755 scripts/mysqld-wait-ready %{buildroot}%{_libexecdir}/mysqld-wait-ready
install -p -m 755 scripts/mysqld-check-socket %{buildroot}%{_libexecdir}/mysqld-check-socket
install -p -m 644 scripts/mysqld-scripts-common %{buildroot}%{_libexecdir}/mysqld-scripts-common
install -D -p -m 0644 scripts/mysql.tmpfiles.d %{buildroot}%{_tmpfilesdir}/%{name}.conf install -D -p -m 0644 scripts/mysql.tmpfiles.d %{buildroot}%{_tmpfilesdir}/%{name}.conf
%endif
# install SysV init script
%if %{with init_sysv}
install -D -p -m 755 scripts/mysql.init %{buildroot}%{_initddir}/%{daemon_name}
%endif
# helper scripts for service starting
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
# mysql-test includes one executable that doesn't belong under /usr/share, # mysql-test includes one executable that doesn't belong under /usr/share,
# so move it and provide a symlink # so move it and provide a symlink
@ -438,19 +534,19 @@ rm -f %{buildroot}%{_mandir}/man1/mysql-stress-test.pl.1*
rm -f %{buildroot}%{_mandir}/man1/mysql-test-run.pl.1* rm -f %{buildroot}%{_mandir}/man1/mysql-test-run.pl.1*
# put logrotate script where it needs to be # put logrotate script where it needs to be
mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d mkdir -p %{buildroot}%{logrotateddir}
mv %{buildroot}%{_datadir}/%{name}/mysql-log-rotate %{buildroot}%{_sysconfdir}/logrotate.d/mysqld mv %{buildroot}%{_datadir}/%{name}/mysql-log-rotate %{buildroot}%{logrotateddir}/%{daemon_name}
chmod 644 %{buildroot}%{_sysconfdir}/logrotate.d/mysqld chmod 644 %{buildroot}%{logrotateddir}/%{daemon_name}
mkdir -p %{buildroot}/etc/ld.so.conf.d mkdir -p %{buildroot}%{_sysconfdir}/ld.so.conf.d
echo "%{_libdir}/mysql" > %{buildroot}/etc/ld.so.conf.d/%{name}-%{_arch}.conf echo "%{_libdir}/mysql" > %{buildroot}%{_sysconfdir}/ld.so.conf.d/%{name}-%{_arch}.conf
# Back to src dir # Back to src dir
popd popd
# copy additional docs into build tree so %%doc will find them # copy additional docs into build tree so %%doc will find them
install -p -m 0644 %{SOURCE6} README.mysql-docs install -p -m 0644 %{SOURCE6} %{basename:%{SOURCE6}}
install -p -m 0644 %{SOURCE7} README.mysql-license install -p -m 0644 %{SOURCE7} %{basename:%{SOURCE7}}
# Install the list of skipped tests to be available for user runs # Install the list of skipped tests to be available for user runs
install -p -m 0644 mysql-test/%{skiplist} %{buildroot}%{_datadir}/mysql-test install -p -m 0644 mysql-test/%{skiplist} %{buildroot}%{_datadir}/mysql-test
@ -473,7 +569,57 @@ rm %{buildroot}%{_mandir}/man1/{mysqltest,mysql_client_test}_embedded.1
cp -p %{buildroot}%{_mandir}/man1/mysqltest.1 %{buildroot}%{_mandir}/man1/mysqltest_embedded.1 cp -p %{buildroot}%{_mandir}/man1/mysqltest.1 %{buildroot}%{_mandir}/man1/mysqltest_embedded.1
cp -p %{buildroot}%{_mandir}/man1/mysql_client_test.1 %{buildroot}%{_mandir}/man1/mysql_client_test_embedded.1 cp -p %{buildroot}%{_mandir}/man1/mysql_client_test.1 %{buildroot}%{_mandir}/man1/mysql_client_test_embedded.1
%if %{without clibrary}
rm -rf %{buildroot}%{_libdir}/mysql/libmysqlclient*.so.*
rm -rf %{buildroot}%{_sysconfdir}/ld.so.conf.d
%endif
%if %{without embedded}
rm -f %{buildroot}%{_libdir}/mysql/libmysqld.so*
rm -f %{buildroot}%{_bindir}/{mysql_client_test_embedded,mysqltest_embedded}
rm -f %{buildroot}%{_mandir}/man1/{mysql_client_test_embedded,mysqltest_embedded}.1*
%endif
%if %{without devel}
rm -f %{buildroot}%{_bindir}/mysql_config*
rm -rf %{buildroot}%{_includedir}/mysql
rm -f %{buildroot}%{_datadir}/aclocal/mysql.m4
rm -f %{buildroot}%{_libdir}/mysql/libmysqlclient*.so
rm -f %{buildroot}%{_mandir}/man1/mysql_config.1*
%endif
%if %{without client}
rm -f %{buildroot}%{_bindir}/{msql2mysql,mysql,mysql_config_editor,\
mysql_find_rows,mysql_waitpid,mysqlaccess,mysqladmin,mysqlbinlog,mysqlcheck,\
mysqldump,mysqlimport,mysqlshow,mysqlslap,my_print_defaults}
rm -f %{buildroot}%{_mandir}/man1/{msql2mysql,mysql,mysql_config_editor,\
mysql_find_rows,mysql_waitpid,mysqlaccess,mysqladmin,mysqlbinlog,mysqlcheck,\
mysqldump,mysqlimport,mysqlshow,mysqlslap,my_print_defaults}.1*
%endif
%if %{without common}
rm -f %{buildroot}%{_sysconfdir}/my.cnf
rm -rf %{buildroot}%{_datadir}/%{name}/charsets
%endif
%if %{without errmsg}
rm -rf %{buildroot}%{_datadir}/%{name}/{english,bulgarian,czech,danish,dutch,estonian,\
french,german,greek,hungarian,italian,japanese,korean,norwegian,norwegian-ny,\
polish,portuguese,romanian,russian,serbian,slovak,spanish,swedish,ukrainian}
%endif
%if %{without bench}
rm -rf %{buildroot}%{_datadir}/sql-bench
%endif
%if %{without test}
rm -f %{buildroot}%{_bindir}/{mysql_client_test,my_safe_process}
rm -rf %{buildroot}%{_datadir}/mysql-test
rm -f %{buildroot}%{_mandir}/man1/mysql_client_test.1*
%endif
%check %check
%if %{with test}
%if %runselftest %if %runselftest
pushd build pushd build
make test VERBOSE=1 make test VERBOSE=1
@ -491,33 +637,65 @@ export MTR_BUILD_THREAD=%{__isa_bits}
popd popd
popd popd
%endif %endif
%endif
%pre server %pre server
/usr/sbin/groupadd -g 27 -o -r mysql >/dev/null 2>&1 || : /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 /bin/bash \ /usr/sbin/useradd -M -N -g mysql -o -r -d %{mysqluserhome} -s /sbin/nologin \
-c "MySQL Server" -u 27 mysql >/dev/null 2>&1 || : -c "MySQL Server" -u 27 mysql >/dev/null 2>&1 || :
%if %{with clibrary}
%post libs -p /sbin/ldconfig %post libs -p /sbin/ldconfig
%endif
%if %{with embedded}
%post embedded -p /sbin/ldconfig %post embedded -p /sbin/ldconfig
%endif
%post server %post server
%systemd_post %{daemon_name} %if %{with init_systemd}
/bin/touch %{_localstatedir}/log/mysqld.log %systemd_post %{daemon_name}.service
%endif
%if %{with init_sysv}
if [ $1 = 1 ]; then
/sbin/chkconfig --add %{daemon_name}
fi
%endif
/bin/touch %{logfile}
%preun server %preun server
%systemd_preun %{daemon_name} %if %{with init_systemd}
%systemd_preun %{daemon_name}.service
%endif
%if %{with init_sysv}
if [ $1 = 0 ]; then
/sbin/service %{daemon_name} stop >/dev/null 2>&1
/sbin/chkconfig --del %{daemon_name}
fi
%endif
%if %{with clibrary}
%postun libs -p /sbin/ldconfig %postun libs -p /sbin/ldconfig
%endif
%if %{with embedded}
%postun embedded -p /sbin/ldconfig %postun embedded -p /sbin/ldconfig
%endif
%postun server %postun server
%systemd_postun_with_restart %{daemon_name} %if %{with init_systemd}
%systemd_postun_with_restart %{daemon_name}.service
%endif
%if %{with init_sysv}
if [ $1 -ge 1 ]; then
/sbin/service %{daemon_name} condrestart >/dev/null 2>&1 || :
fi
%endif
%files %files
%doc README.mysql-docs %doc README.mysql-docs
%if %{with client}
%{_bindir}/msql2mysql %{_bindir}/msql2mysql
%{_bindir}/mysql %{_bindir}/mysql
%{_bindir}/mysql_config_editor %{_bindir}/mysql_config_editor
@ -547,24 +725,30 @@ popd
%{_mandir}/man1/mysqlshow.1* %{_mandir}/man1/mysqlshow.1*
%{_mandir}/man1/mysqlslap.1* %{_mandir}/man1/mysqlslap.1*
%{_mandir}/man1/my_print_defaults.1* %{_mandir}/man1/my_print_defaults.1*
%endif
%if %{with clibrary}
%files libs %files libs
%dir %{_libdir}/mysql %dir %{_libdir}/mysql
%{_libdir}/mysql/libmysqlclient*.so.* %{_libdir}/mysql/libmysqlclient*.so.*
%config(noreplace) %{_sysconfdir}/ld.so.conf.d/* %config(noreplace) %{_sysconfdir}/ld.so.conf.d/*
%endif
%if %{with common}
%files common %files common
%doc README COPYING README.mysql-license %doc README COPYING README.mysql-license
%doc storage/innobase/COPYING.Percona storage/innobase/COPYING.Google %doc storage/innobase/COPYING.Percona storage/innobase/COPYING.Google
# although the default my.cnf contains only server settings, we put it in the # although the default my.cnf contains only server settings, we put it in the
# libs package because it can be used for client settings too. # common package because it can be used for client settings too.
%if %{ship_my_cnf} %if %{ship_my_cnf}
%config(noreplace) %{_sysconfdir}/my.cnf %config(noreplace) %{_sysconfdir}/my.cnf
%dir %{_sysconfdir}/my.cnf.d %dir %{_sysconfdir}/my.cnf.d
%endif %endif
%dir %{_datadir}/%{name} %dir %{_datadir}/%{name}
%{_datadir}/%{name}/charsets %{_datadir}/%{name}/charsets
%endif
%if %{with errmsg}
%files errmsg %files errmsg
%{_datadir}/%{name}/english %{_datadir}/%{name}/english
%lang(bg) %{_datadir}/%{name}/bulgarian %lang(bg) %{_datadir}/%{name}/bulgarian
@ -590,9 +774,10 @@ popd
%lang(es) %{_datadir}/%{name}/spanish %lang(es) %{_datadir}/%{name}/spanish
%lang(sv) %{_datadir}/%{name}/swedish %lang(sv) %{_datadir}/%{name}/swedish
%lang(uk) %{_datadir}/%{name}/ukrainian %lang(uk) %{_datadir}/%{name}/ukrainian
%endif
%files server %files server
%{_bindir}/myisamchk %{_bindir}/myisamchk
%{_bindir}/myisam_ftdump %{_bindir}/myisam_ftdump
%{_bindir}/myisamlog %{_bindir}/myisamlog
%{_bindir}/myisampack %{_bindir}/myisampack
@ -621,6 +806,10 @@ popd
%{_libdir}/mysql/INFO_SRC %{_libdir}/mysql/INFO_SRC
%{_libdir}/mysql/INFO_BIN %{_libdir}/mysql/INFO_BIN
%if %{without common}
%dir %{_datadir}/%{name}
%endif
%{_libdir}/mysql/plugin %{_libdir}/mysql/plugin
%{_mandir}/man1/myisamchk.1* %{_mandir}/man1/myisamchk.1*
@ -661,18 +850,20 @@ popd
%{_datadir}/%{name}/mysql_test_data_timezone.sql %{_datadir}/%{name}/mysql_test_data_timezone.sql
%{_datadir}/%{name}/my-*.cnf %{_datadir}/%{name}/my-*.cnf
%{_unitdir}/%{daemon_name} %{?with_init_systemd:%{_unitdir}/%{daemon_name}.service}
%{_libexecdir}/mysqld-prepare-db-dir %{?with_init_sysv:%{_initddir}/%{daemon_name}}
%{_libexecdir}/mysqld-wait-ready %{_libexecdir}/mysql-prepare-db-dir
%{_libexecdir}/mysqld-check-socket %{_libexecdir}/mysql-wait-ready
%{_libexecdir}/mysqld-scripts-common %{_libexecdir}/mysql-check-socket
%{_libexecdir}/mysql-scripts-common
%{_tmpfilesdir}/%{name}.conf %{?with_init_systemd:%{_tmpfilesdir}/%{name}.conf}
%attr(0755,mysql,mysql) %dir %{_localstatedir}/run/mysqld %attr(0755,mysql,mysql) %dir %{_localstatedir}/run/%{daemon_name}
%attr(0755,mysql,mysql) %dir %{_localstatedir}/lib/mysql %attr(0755,mysql,mysql) %dir %{_localstatedir}/lib/mysql
%attr(0640,mysql,mysql) %config %ghost %verify(not md5 size mtime) %{_localstatedir}/log/mysqld.log %attr(0640,mysql,mysql) %config %ghost %verify(not md5 size mtime) %{logfile}
%config(noreplace) %{_sysconfdir}/logrotate.d/mysqld %config(noreplace) %{logrotateddir}/%{daemon_name}
%if %{with devel}
%files devel %files devel
%{_bindir}/mysql_config %{_bindir}/mysql_config
%{_bindir}/mysql_config-%{__isa_bits} %{_bindir}/mysql_config-%{__isa_bits}
@ -681,7 +872,9 @@ popd
%{_libdir}/mysql/libmysqlclient.so %{_libdir}/mysql/libmysqlclient.so
%{_libdir}/mysql/libmysqlclient_r.so %{_libdir}/mysql/libmysqlclient_r.so
%{_mandir}/man1/mysql_config.1* %{_mandir}/man1/mysql_config.1*
%endif
%if %{with embedded}
%files embedded %files embedded
%{_libdir}/mysql/libmysqld.so.* %{_libdir}/mysql/libmysqld.so.*
@ -691,18 +884,26 @@ popd
%{_bindir}/mysqltest_embedded %{_bindir}/mysqltest_embedded
%{_mandir}/man1/mysql_client_test_embedded.1* %{_mandir}/man1/mysql_client_test_embedded.1*
%{_mandir}/man1/mysqltest_embedded.1* %{_mandir}/man1/mysqltest_embedded.1*
%endif
%if %{with bench}
%files bench %files bench
%{_datadir}/sql-bench %{_datadir}/sql-bench
%endif
%if %{with test}
%files test %files test
%{_bindir}/mysql_client_test %{_bindir}/mysql_client_test
%{_bindir}/my_safe_process %{_bindir}/my_safe_process
%attr(-,mysql,mysql) %{_datadir}/mysql-test %attr(-,mysql,mysql) %{_datadir}/mysql-test
%{_mandir}/man1/mysql_client_test.1* %{_mandir}/man1/mysql_client_test.1*
%endif
%changelog %changelog
* Tue Jul 22 2014 Honza Horak <hhorak@redhat.com> - 5.6.19-5 * Tue Jul 22 2014 Honza Horak <hhorak@redhat.com> - 5.6.19-5
- Spec rewrite to be more similar to oterh MySQL implementations
- Include SysV init script if built on older system
- Add possibility to not ship some sub-packages
- Port scripts for systemd unit from MariaDB - Port scripts for systemd unit from MariaDB
* Mon Jul 21 2014 Honza Horak <hhorak@redhat.com> - 5.6.19-4 * Mon Jul 21 2014 Honza Horak <hhorak@redhat.com> - 5.6.19-4

39
mysql-check-socket.sh Normal file
View File

@ -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

View File

@ -3,7 +3,7 @@
# This script creates the mysql data directory during first service start. # This script creates the mysql data directory during first service start.
# In subsequent starts, it does nothing much. # In subsequent starts, it does nothing much.
source "`dirname ${BASH_SOURCE[0]}`/mariadb-scripts-common" source "`dirname ${BASH_SOURCE[0]}`/mysql-scripts-common"
# If two args given first is user, second is group # If two args given first is user, second is group
# otherwise the arg is the systemd service file # otherwise the arg is the systemd service file
@ -13,7 +13,7 @@ then
mygroup="$2" mygroup="$2"
else else
# Absorb configuration settings from the specified systemd service file, # Absorb configuration settings from the specified systemd service file,
# or the default "mariadb" service if not specified # or the default service if not specified
SERVICE_NAME="$1" SERVICE_NAME="$1"
if [ x"$SERVICE_NAME" = x ] if [ x"$SERVICE_NAME" = x ]
then then
@ -68,11 +68,11 @@ if [ ! -d "$datadir/mysql" ] ; then
[ -x /sbin/restorecon ] && /sbin/restorecon "$datadir" [ -x /sbin/restorecon ] && /sbin/restorecon "$datadir"
# Now create the database # Now create the database
echo "Initializing MySQL database" echo "Initializing @NICE_PROJECT_NAME@ database"
@bindir@/mysql_install_db --datadir="$datadir" --user="$myuser" @bindir@/mysql_install_db --datadir="$datadir" --user="$myuser"
ret=$? ret=$?
if [ $ret -ne 0 ] ; then if [ $ret -ne 0 ] ; then
echo "Initialization of MySQL database failed." >&2 echo "Initialization of @NICE_PROJECT_NAME@ database failed." >&2
echo "Perhaps @sysconfdir@/my.cnf is misconfigured." >&2 echo "Perhaps @sysconfdir@/my.cnf is misconfigured." >&2
# Clean up any partially-created database files # Clean up any partially-created database files
if [ ! -e "$datadir/mysql/user.frm" ] ; then if [ ! -e "$datadir/mysql/user.frm" ] ; then

58
mysql-scripts-common.sh Executable file
View File

@ -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=`@bindir@/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 @sysconfdir@/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@ 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"

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
source "`dirname ${BASH_SOURCE[0]}`/mariadb-scripts-common" source "`dirname ${BASH_SOURCE[0]}`/mysql-scripts-common"
# This script waits for mysqld to be ready to accept connections # This script waits for mysqld to be ready to accept connections
# (which can be many seconds or even minutes after launch, if there's # (which can be many seconds or even minutes after launch, if there's
@ -32,7 +32,7 @@ while /bin/true; do
# exit codes 1, 11 (EXIT_CANNOT_CONNECT_TO_SERVICE) are expected, # exit codes 1, 11 (EXIT_CANNOT_CONNECT_TO_SERVICE) are expected,
# anything else suggests a configuration error # anything else suggests a configuration error
if [ $mret -ne 1 -a $mret -ne 11 ]; then if [ $mret -ne 1 -a $mret -ne 11 ]; then
echo "Cannot check for MySQL Daemon startup because of mysqladmin failure." >&2 echo "Cannot check for @NICE_PROJECT_NAME@ Daemon startup because of mysqladmin failure." >&2
ret=$mret ret=$mret
break break
fi fi

177
mysql.init.in Normal file
View File

@ -0,0 +1,177 @@
#!/bin/sh
#
# @DAEMON_NAME@ This shell script takes care of starting and stopping
# the MySQL subsystem (mysqld).
#
# chkconfig: - 64 36
# description: MySQL database server.
# processname: mysqld
# config: @sysconfdir@/my.cnf
# pidfile: /var/run/@DAEMON_NAME@/@DAEMON_NAME@.pid
### BEGIN INIT INFO
# Provides: mysqld
# Required-Start: $local_fs $remote_fs $network $named $syslog $time
# Required-Stop: $local_fs $remote_fs $network $named $syslog $time
# Short-Description: start and stop MySQL server
# Description: MySQL database server
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
exec="@bindir@/mysqld_safe"
prog="@DAEMON_NAME@"
# Set timeouts here so they can be overridden from /etc/sysconfig/@DAEMON_NAME@
STARTTIMEOUT=300
STOPTIMEOUT=60
# User and group the daemon will run under
MYUSER=mysql
MYGROUP=mysql
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
lockfile=/var/lock/subsys/$prog
# get options from my.cnf
source "@libexecdir@/mariadb-scripts-common"
start(){
[ -x $exec ] || exit 5
# check to see if it's already running
MYSQLDRUNNING=0
if [ -f "$pidfile" ]; then
MYSQLPID=`cat "$pidfile" 2>/dev/null`
if [ -n "$MYSQLPID" ] && [ -d "/proc/$MYSQLPID" ] ; then
MYSQLDRUNNING=1
fi
fi
RESPONSE=`@bindir@/mysqladmin --socket="$socketfile" --user=UNKNOWN_MYSQL_USER ping 2>&1`
if [ $MYSQLDRUNNING = 1 ] && [ $? = 0 ]; then
# already running, do nothing
action $"Starting $prog: " /bin/true
ret=0
elif [ $MYSQLDRUNNING = 1 ] && echo "$RESPONSE" | grep -q "Access denied for user"
then
# already running, do nothing
action $"Starting $prog: " /bin/true
ret=0
else
@libexecdir@/mariadb-prepare-db-dir $MYUSER $MYGROUP || return 4
@libexecdir@/mariadb-check-socket || return 1
# Pass all the options determined above, to ensure consistent behavior.
# In many cases mysqld_safe would arrive at the same conclusions anyway
# but we need to be sure. (An exception is that we don't force the
# log-error setting, since this script doesn't really depend on that,
# and some users might prefer to configure logging to syslog.)
# Note: set --basedir to prevent probes that might trigger SELinux
# alarms, per bug #547485
$exec --datadir="$datadir" --socket="$socketfile" \
--pid-file="$pidfile" \
--basedir=@prefix@ --user=$MYUSER >/dev/null 2>&1 &
safe_pid=$!
# Wait until the daemon is up
@libexecdir@/mariadb-wait-ready "$safe_pid"
ret=$?
if [ $ret -eq 0 ]; then
action $"Starting $prog: " /bin/true
chmod o+r $pidfile >/dev/null 2>&1
touch $lockfile
else
action $"Starting $prog: " /bin/false
fi
fi
return $ret
}
stop(){
if [ ! -f "$pidfile" ]; then
# not running; per LSB standards this is "ok"
action $"Stopping $prog: " /bin/true
return 0
fi
MYSQLPID=`cat "$pidfile" 2>/dev/null`
if [ -n "$MYSQLPID" ]; then
if ! [ -d "/proc/$MYSQLPID" ] ; then
# process doesn't run anymore
action $"Stopping $prog: " /bin/true
return 0
fi
/bin/kill "$MYSQLPID" >/dev/null 2>&1
ret=$?
if [ $ret -eq 0 ]; then
TIMEOUT="$STOPTIMEOUT"
while [ $TIMEOUT -gt 0 ]; do
/bin/kill -0 "$MYSQLPID" >/dev/null 2>&1 || break
sleep 1
let TIMEOUT=${TIMEOUT}-1
done
if [ $TIMEOUT -eq 0 ]; then
echo "Timeout error occurred trying to stop MySQL Daemon."
ret=1
action $"Stopping $prog: " /bin/false
else
rm -f $lockfile
rm -f "$socketfile"
action $"Stopping $prog: " /bin/true
fi
else
# kill command failed, probably insufficient permissions
action $"Stopping $prog: " /bin/false
ret=4
fi
else
# failed to read pidfile, probably insufficient permissions
action $"Stopping $prog: " /bin/false
ret=4
fi
return $ret
}
restart(){
stop
start
}
condrestart(){
[ -e $lockfile ] && restart || :
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p "$pidfile" $prog
;;
restart)
restart
;;
condrestart|try-restart)
condrestart
;;
reload)
exit 3
;;
force-reload)
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
exit $?

49
mysql.service.in Normal file
View File

@ -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

View File

@ -1 +1 @@
d /var/run/@RPM_PACKAGE_PREFIX@mysqld 0755 mysql mysql - d /var/run/@DAEMON_NAME@ 0755 mysql mysql -

View File

@ -1,4 +1,4 @@
#! /bin/bash #! /bin/sh
# #
# Wrapper script for mysql_config to support multilib # Wrapper script for mysql_config to support multilib
# #
@ -17,10 +17,10 @@ if [ "$status" = "unknown" ] ; then
fi fi
if [ -x /usr/bin/mysql_config-$bits ] ; then if [ -x @bindir@/mysql_config-$bits ] ; then
/usr/bin/mysql_config-$bits "$@" @bindir@/mysql_config-$bits "$@"
else else
echo "$0: error: needed binary: /usr/bin/mysql_config-$bits is missing" echo "$0: error: needed binary: @bindir@/mysql_config-$bits is missing"
exit 1 exit 1
fi fi

View File

@ -1,44 +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/mysqld.service",
# containing
# .include /lib/systemd/system/mysqld.service
# ...make your changes here...
# For more info about custom unit files, see
# 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/mysqld.service" containing:
# .include /lib/systemd/system/mysqld.service
# [Service]
# LimitNOFILE=10000
# Note: in F-17 and beyond, /usr/lib/... is recommended in the .include line
# though /lib/... will still work.
[Unit]
Description=MySQL @MAJOR_VERSION@.@MINOR_VERSION@ database server
After=syslog.target
After=network.target
[Service]
Type=simple
User=mysql
Group=mysql
ExecStartPre=@libexecdir@/mariadb-check-socket
ExecStartPre=@libexecdir@/mysqld-prepare-db-dir %n
# Note: we set --basedir to prevent probes that might trigger SELinux alarms,
# per bug #547485
ExecStart=@bindir@/mysqld_safe --basedir=/usr
ExecStartPost=@libexecdir@/mysqld-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