diff --git a/0000-mysql-add-fstack-protector-strong.patch b/0000-mysql-add-fstack-protector-strong.patch
deleted file mode 100644
index d83f23493c29d9daf1a20c513b2b811e08345c76..0000000000000000000000000000000000000000
--- a/0000-mysql-add-fstack-protector-strong.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From cb5dfd6d62419ce6d84bed6600eca7d894fd683b Mon Sep 17 00:00:00 2001
-
----
- cmake/build_configurations/compiler_options.cmake | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/cmake/build_configurations/compiler_options.cmake b/cmake/build_configurations/compiler_options.cmake
-index a30eafe1..d93575bd 100644
---- a/cmake/build_configurations/compiler_options.cmake
-+++ b/cmake/build_configurations/compiler_options.cmake
-@@ -38,6 +38,7 @@ IF(UNIX)
- # Default GCC flags
- IF(MY_COMPILER_IS_GNU)
- SET(COMMON_C_FLAGS "-fno-omit-frame-pointer")
-+ SET(COMMON_C_FLAGS "-fstack-protector-strong")
- # Disable inline optimizations for valgrind testing to avoid false positives
- IF(WITH_VALGRIND)
- STRING_PREPEND(COMMON_C_FLAGS "-fno-inline ")
-@@ -47,7 +48,7 @@ IF(UNIX)
- STRING_APPEND(COMMON_C_FLAGS " -ffp-contract=off")
- ENDIF()
-
-- SET(COMMON_CXX_FLAGS "-std=c++17 -fno-omit-frame-pointer")
-+ SET(COMMON_CXX_FLAGS "-std=c++17 -fno-omit-frame-pointer -fstack-protector-strong")
- # Disable inline optimizations for valgrind testing to avoid false positives
- IF(WITH_VALGRIND)
- STRING_PREPEND(COMMON_CXX_FLAGS "-fno-inline ")
---
-2.27.0
-
diff --git a/README.mysql-docs b/README.mysql-docs
new file mode 100644
index 0000000000000000000000000000000000000000..dd894a7b9c01c5c905cf86bb7bb1c239298b3d7d
--- /dev/null
+++ b/README.mysql-docs
@@ -0,0 +1,4 @@
+The official MySQL documentation is not freely redistributable, so we cannot
+include it in RHEL or Fedora. You can find it on-line at
+
+http://dev.mysql.com/doc/
diff --git a/README.mysql-license b/README.mysql-license
new file mode 100644
index 0000000000000000000000000000000000000000..ceabbcfe26fa844000a0426ee203f69b9ea47036
--- /dev/null
+++ b/README.mysql-license
@@ -0,0 +1,9 @@
+MySQL is distributed under GPL v2, but there are some licensing exceptions
+that allow the client libraries to be linked with a non-GPL application,
+so long as the application is under a license approved by Oracle.
+For details see
+
+http://www.mysql.com/about/legal/licensing/foss-exception/
+
+Some innobase code from Percona and Google is under BSD license.
+Some code related to test-suite is under LGPLv2.
diff --git a/my.cnf.in b/my.cnf.in
new file mode 100644
index 0000000000000000000000000000000000000000..2bb9e886c441433cba9c2a5507e6a0e1c3310167
--- /dev/null
+++ b/my.cnf.in
@@ -0,0 +1,16 @@
+#
+# This group is read both both by the client and the server
+# use it for options that affect everything
+#
+[client-server]
+
+#
+# This group is read by the server
+#
+[mysqld]
+
+#
+# include all files from the config directory
+#
+!includedir @SYSCONF2DIR@
+
diff --git a/mysql-arm32-timer.patch b/mysql-arm32-timer.patch
new file mode 100644
index 0000000000000000000000000000000000000000..cdd51a72bc40c9c1bc75e5011ee72579fef19258
--- /dev/null
+++ b/mysql-arm32-timer.patch
@@ -0,0 +1,14 @@
+--- mysql-8.0.24-bak/mysql-test/include/mtr_warnings.sql 2021-03-22 16:44:50.000000000 +0800
++++ mysql-8.0.24/mysql-test/include/mtr_warnings.sql 2021-05-07 10:58:00.852352992 +0800
+@@ -304,6 +304,11 @@
+ ("Invalid systemd notify socket, cannot send: "),
+
+ /*
++ ARM32 don't support timers and get this warning in every test.
++ */
++ ("The CYCLE timer is not available. WAIT events in the performance_schema will not be timed."),
++
++ /*
+ Manifest file processing
+ */
+ ("Manifest file '.*' is not read-only. For better security, please make sure that the file is read-only."),
diff --git a/mysql-chain-certs.patch b/mysql-chain-certs.patch
index 0ce41c105b18df9b7bbd473a8051738453c61c90..5f26c48b97efb00a3c5c20dd6567ec9230d49d44 100644
--- a/mysql-chain-certs.patch
+++ b/mysql-chain-certs.patch
@@ -4,8 +4,8 @@ certificate files.
This only really works for OpenSSL-based builds, as yassl is unable to read
multiple certificates from a file. The patch below to yassl/src/ssl.cpp
doesn't fix that, but just arranges that the viosslfactories.c patch won't
-have any ill effects in a yassl build. Since we don't use yassl in R-H/
-Fe builds, I'm not feeling motivated to try to fix yassl for this.
+have any ill effects in a yassl build. Since we don't use yassl in Red Hat/
+Fedora builds, I'm not feeling motivated to try to fix yassl for this.
See RH bug #598656. Filed upstream at http://bugs.mysql.com/bug.php?id=54158
diff --git a/mysql-check-socket.sh b/mysql-check-socket.sh
new file mode 100644
index 0000000000000000000000000000000000000000..b15cd32fe0db96635864250926ff2609d1819212
--- /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-prepare-db-dir.sh b/mysql-prepare-db-dir.sh
new file mode 100644
index 0000000000000000000000000000000000000000..46cf636945a36896841e1092507f12777a8fc482
--- /dev/null
+++ b/mysql-prepare-db-dir.sh
@@ -0,0 +1,112 @@
+#!/bin/sh
+
+# This script creates the mysql data directory during first service start.
+# In subsequent starts, it does nothing much.
+#
+# This script is meant to be run as non-root user either during initscript
+# or systemd service execution, before starting the mysqld daemon.
+# Running it as root may have some security risks, because it touches files
+# that can be symlinks pointing to unexpected locations.
+#
+# On the other hand, when using non-standard locations for datadir and logfile,
+# this script might not be able to create the files and the daemon won't start
+# properly. A solution for that is to created the locations for datadir and
+# logfile with correct ownership before starting the daemon.
+
+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
+if [ ! -e "$errlogfile" -a ! -h "$errlogfile" -a x$(dirname "$errlogfile") = "x/var/log" ]; then
+ case $(basename "$errlogfile") in
+ mysql*.log|mariadb*.log) install /dev/null -m0640 -o$myuser -g$mygroup "$errlogfile" ;;
+ *) ;;
+ esac
+else
+ # Provide some advice if the log file cannot be created by this script
+ errlogdir=$(dirname "$errlogfile")
+ if ! [ -d "$errlogdir" ] ; then
+ echo "The directory $errlogdir does not exist."
+ exit 1
+ elif [ -e "$errlogfile" -a ! -w "$errlogfile" ] ; then
+ echo "The log file $errlogfile cannot be written, please, fix its permissions."
+ echo "The daemon will be run under $myuser:$mygroup"
+ exit 1
+ fi
+fi
+
+
+
+export LC_ALL=C
+
+# Returns content of the specified directory
+# If listing files fails, fake-file is returned so which means
+# we'll behave like there was some data initialized
+# Some files or directories are fine to be there, so those are
+# explicitly removed from the listing
+# @param
datadir
+list_datadir ()
+{
+ ( ls -1A "$1" 2>/dev/null || echo "fake-file" ) | grep -v \
+ -e '^lost+found$' \
+ -e '\.err$' \
+ -e '^\.bash_history$'
+}
+
+# Checks whether datadir should be initialized
+# @param datadir
+should_initialize ()
+{
+ test -z "$(list_datadir "$1")"
+}
+
+# Make the data directory if doesn't exist or empty
+if should_initialize "$datadir" ; then
+
+ # Now create the database
+ echo "Initializing @NICE_PROJECT_NAME@ database"
+ @libexecdir@/mysqld --initialize-insecure --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
+ # upgrade does not need to be run on a fresh datadir
+ echo "@VERSION@" >"$datadir/mysql_upgrade_info"
+fi
+
+exit 0
diff --git a/mysql-s390-tsc.patch b/mysql-s390-tsc.patch
new file mode 100644
index 0000000000000000000000000000000000000000..a4bd7f7e15552fe779d8fef7be842cd5ec6eca2b
--- /dev/null
+++ b/mysql-s390-tsc.patch
@@ -0,0 +1,48 @@
+Support s390/s390x in performance schema's cycle-counting functions.
+Filed upstream at http://bugs.mysql.com/bug.php?id=59953
+---
+ include/my_rdtsc.h | 1 +
+ mysys/my_rdtsc.cc | 9 +++++++++
+ 2 files changed, 10 insertions(+)
+
+diff --git a/include/my_rdtsc.h b/include/my_rdtsc.h
+index b411eda0..03fc9a58 100644
+--- a/include/my_rdtsc.h
++++ b/include/my_rdtsc.h
+@@ -128,5 +128,6 @@ void my_timer_init(MY_TIMER_INFO *mti);
+ #define MY_TIMER_ROUTINE_GETSYSTEMTIMEASFILETIME 26
+ /* #define MY_TIMER_ROUTINE_ASM_SUNPRO_X86_64 27 - No longer used */
+ #define MY_TIMER_ROUTINE_ASM_AARCH64 28
++#define MY_TIMER_ROUTINE_ASM_S390 29
+
+ #endif
+diff --git a/mysys/my_rdtsc.cc b/mysys/my_rdtsc.cc
+index d9756487..817aa9d6 100644
+--- a/mysys/my_rdtsc.cc
++++ b/mysys/my_rdtsc.cc
+@@ -168,6 +168,13 @@ ulonglong my_timer_cycles(void) {
+ __asm __volatile__("mrs %[rt],cntvct_el0" : [ rt ] "=r"(result));
+ return result;
+ }
++#elif defined(__GNUC__) && defined(__s390__)
++ /* covers both s390 and s390x */
++ {
++ ulonglong result;
++ __asm__ __volatile__ ("stck %0" : "=Q" (result) : : "cc");
++ return result;
++ }
+ #elif defined(HAVE_SYS_TIMES_H) && defined(HAVE_GETHRTIME)
+ /* gethrtime may appear as either cycle or nanosecond counter */
+ return (ulonglong)gethrtime();
+@@ -453,6 +460,8 @@ void my_timer_init(MY_TIMER_INFO *mti) {
+ mti->cycles.routine = MY_TIMER_ROUTINE_ASM_GCC_SPARC64;
+ #elif defined(__GNUC__) && defined(__aarch64__)
+ mti->cycles.routine = MY_TIMER_ROUTINE_ASM_AARCH64;
++#elif defined(__GNUC__) && defined(__s390__)
++ mti->cycles.routine = MY_TIMER_ROUTINE_ASM_S390;
+ #elif defined(HAVE_SYS_TIMES_H) && defined(HAVE_GETHRTIME)
+ mti->cycles.routine = MY_TIMER_ROUTINE_GETHRTIME;
+ #else
+--
+2.27.0
+
diff --git a/mysql-scripts-common.sh b/mysql-scripts-common.sh
new file mode 100644
index 0000000000000000000000000000000000000000..58f0437cff9d03c3f69d19e178aa0fc099dc79f8
--- /dev/null
+++ b/mysql-scripts-common.sh
@@ -0,0 +1,68 @@
+#!/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 $my_print_defaults_extra_args $sections | sed -n "s/^--${option_name}=//p" | tail -n 1`
+ if [ -z "$result" ]; then
+ # not found, use default
+ result="${default_value}"
+ fi
+}
+
+# For the case of running more instances via systemd, scrits that source
+# this file can get --default-group-suffix or similar option as the first
+# argument. The utility my_print_defaults needs to use it as well, so the
+# scripts sourcing this file work with the same options as the daemon.
+my_print_defaults_extra_args=''
+while echo "$1" | grep -q '^--defaults' ; do
+ my_print_defaults_extra_args="${my_print_defaults_extra_args} $1"
+ shift
+done
+
+# 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 "$datadir/`hostname`.err"
+errlogfile="$result"
+
+get_mysql_option "$server_sections" socket "@MYSQL_UNIX_ADDR@"
+socketfile="$result"
+
+get_mysql_option "$server_sections" pid-file "$datadir/`hostname`.pid"
+pidfile="$result"
+
diff --git a/mysql-scripts.patch b/mysql-scripts.patch
new file mode 100644
index 0000000000000000000000000000000000000000..322577b280183176dc5f95bd59a3ec222594d9a0
--- /dev/null
+++ b/mysql-scripts.patch
@@ -0,0 +1,33 @@
+--- mysql-8.0.22/scripts/CMakeLists.txt.old 2020-10-21 11:08:50.654252563 +0200
++++ mysql-8.0.22/scripts/CMakeLists.txt 2020-10-21 11:11:33.635935366 +0200
+@@ -507,4 +507,30 @@
+ )
+ ENDIF()
+ ENDIF()
++
++ # files for systemd
++ SET(SYSTEMD_SCRIPTS
++ mysql.tmpfiles.d
++ mysql.service
++ mysql@.service
++ mysql-prepare-db-dir
++ mysql-wait-stop
++ mysql-check-socket
++ mysql-scripts-common
++ mysql_config_multilib
++ my.cnf
++ server.cnf
++ )
++ FOREACH(file ${SYSTEMD_SCRIPTS})
++ IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh)
++ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh
++ ${CMAKE_CURRENT_BINARY_DIR}/${file} ESCAPE_QUOTES @ONLY)
++ ELSEIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.in)
++ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${file}.in
++ ${CMAKE_CURRENT_BINARY_DIR}/${file} ESCAPE_QUOTES @ONLY)
++ ELSE()
++ MESSAGE(FATAL_ERROR "Can not find ${file}.sh or ${file}.in in "
++ "${CMAKE_CURRENT_SOURCE_DIR}" )
++ ENDIF()
++ ENDFOREACH()
+ ENDIF()
diff --git a/mysql-wait-stop.sh b/mysql-wait-stop.sh
new file mode 100644
index 0000000000000000000000000000000000000000..62bde30eaecc93ff2cb3a6224cf3fda02461f98e
--- /dev/null
+++ b/mysql-wait-stop.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+source "`dirname ${BASH_SOURCE[0]}`/mysql-scripts-common"
+
+# This script waits for mysqld to be properly stopped
+# (which can be many seconds in some large load).
+# Running this as ExecStopPost is useful so that starting which is done
+# as part of restart doesn't see the former process still running.
+
+# Wait for the server to properly end the main server
+ret=0
+TIMEOUT=60
+SECONDS=0
+
+if ! [ -f "$pidfile" ]; then
+ exit 0
+fi
+
+MYSQLPID=`cat "$pidfile" 2>/dev/null`
+if [ -z "$MYSQLPID" ] ; then
+ exit 2
+fi
+
+while /bin/true; do
+ # Check process still exists
+ if ! [ -d "/proc/${MYSQLPID}" ] ; then
+ break
+ fi
+ if [ $SECONDS -gt $TIMEOUT ] ; then
+ ret=3
+ break
+ fi
+ sleep 1
+done
+
+exit $ret
diff --git a/mysql.service.in b/mysql.service.in
new file mode 100644
index 0000000000000000000000000000000000000000..0e96374bca751b9ae8babfc332047b6757a285bb
--- /dev/null
+++ b/mysql.service.in
@@ -0,0 +1,62 @@
+# 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 use systemctl edit:
+#
+# $ systemctl edit @DAEMON_NAME@.service
+#
+# this will create file
+#
+# /etc/systemd/system/@DAEMON_NAME@.service.d/override.conf
+#
+# which be parsed after the file @DAEMON_NAME@.service itself is parsed.
+#
+# For example, if you want to increase mysql's open-files-limit to 20000
+# add following when editing with command above:
+#
+# [Service]
+# LimitNOFILE=20000
+#
+# Or if you require to execute pre and post scripts in the unit file as root, set
+# PermissionsStartOnly=true
+#
+# 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
+#
+# 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=notify
+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=@libexecdir@/mysqld --basedir=@prefix@
+ExecStopPost=@libexecdir@/mysql-wait-stop
+
+# 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
+
+Restart=on-failure
+
+RestartPreventExitStatus=1
+
+# Sets open_files_limit
+LimitNOFILE = 10000
+
+# Set enviroment variable MYSQLD_PARENT_PID. This is required for SQL restart command.
+Environment=MYSQLD_PARENT_PID=1
+
+[Install]
+WantedBy=multi-user.target
diff --git a/mysql.spec b/mysql.spec
index e029005fd27443894718655ad12a42f7a9de63b7..39e6260fade65dcc6a4222ab89ccfe86717a18a7 100644
--- a/mysql.spec
+++ b/mysql.spec
@@ -1,58 +1,225 @@
-%define debug_package %{nil}
-%define __os_install_post %{nil}
-%define __debug_install_post \
-%{_rpmconfigdir}/find-debuginfo.sh %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
-%{nil}
+%undefine __cmake_in_source_build
+%global pkg_name %{name}
%global pkgnamepatch mysql
+%{!?runselftest:%global runselftest 0}
+%global check_testsuite 0
+%global require_mysql_selinux 0
+%global _pkgdocdirname %{pkg_name}%{!?_pkgdocdir:-%{version}}
+%{!?_pkgdocdir: %global _pkgdocdir %{_docdir}/%{pkg_name}-%{version}}
+%global _default_patch_flags --no-backup-if-mismatch
+%global skiplist platform-specific-tests.list
+%bcond_without clibrary
+%bcond_without devel
+%bcond_without client
+%bcond_without common
+%bcond_without errmsg
+%bcond_without test
+%bcond_with config
+%bcond_with debug
%global boost_bundled_version 1.73.0
-Name: mysql
-Version: 8.0.28
-Release: 2
-License: GPLv2 with exceptions and LGPLv2 and BSD
-Summary: The world's most popular open source database
-URL: http://www.mysql.com/
-Source0: https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-boost-%{version}.tar.gz
-Patch0:0000-mysql-add-fstack-protector-strong.patch
-Patch1:%{pkgnamepatch}-install-test.patch
-Patch3:%{pkgnamepatch}-file-contents.patch
-Patch5:%{pkgnamepatch}-paths.patch
-Patch6:%{pkgnamepatch}-chain-certs.patch
-Patch7:%{pkgnamepatch}-sharedir.patch
-Patch8:%{pkgnamepatch}-rpath.patch
-Patch10:boost-1.58.0-pool.patch
-Patch11:boost-1.57.0-mpl-print.patch
-Patch12:%{pkgnamepatch}-fix-includes-robin-hood.patch
-Patch13:disable-moutline-atomics-for-aarch64.patch
+%global daemon_name mysqld
+%global daemon_no_prefix mysqld
+%global pidfiledir %{_rundir}/%{daemon_name}
+%global logrotateddir %{_sysconfdir}/logrotate.d
+%global logfiledir %{_localstatedir}/log/mysql
+%global logfile %{logfiledir}/%{daemon_no_prefix}.log
+%global dbdatadir %{_localstatedir}/lib/mysql
+%global mysqluserhome /var/lib/mysql
+%bcond_without mysql_names
+%bcond_without conflicts
+%global sameevr %{?epoch:%{epoch}:}%{version}-%{release}
+Name: mysql
+Version: 8.0.28
+Release: 3
+Summary: MySQL client programs and shared libraries
+URL: http://www.mysql.com
+License: GPLv2 with exceptions and LGPLv2 and BSD
+Source0: https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-boost-%{version}.tar.gz
+Source2: mysql_config_multilib.sh
+Source3: my.cnf.in
+Source6: README.mysql-docs
+Source7: README.mysql-license
+Source10: mysql.tmpfiles.d.in
+Source11: mysql.service.in
+Source12: mysql-prepare-db-dir.sh
+Source14: mysql-check-socket.sh
+Source15: mysql-scripts-common.sh
+Source17: mysql-wait-stop.sh
+Source18: mysql@.service.in
+Source30: %{pkgnamepatch}.rpmlintrc
+Source31: server.cnf.in
+Patch1: %{pkgnamepatch}-install-test.patch
+Patch3: %{pkgnamepatch}-file-contents.patch
+Patch4: %{pkgnamepatch}-scripts.patch
+Patch5: %{pkgnamepatch}-paths.patch
+Patch6: %{pkgnamepatch}-chain-certs.patch
+Patch7: %{pkgnamepatch}-sharedir.patch
+Patch8: %{pkgnamepatch}-rpath.patch
+Patch9: %{pkgnamepatch}-arm32-timer.patch
+Patch10: boost-1.58.0-pool.patch
+Patch11: boost-1.57.0-mpl-print.patch
+Patch12: %{pkgnamepatch}-fix-includes-robin-hood.patch
+Patch13: disable-moutline-atomics-for-aarch64.patch
Patch14: CVE-2022-37434-1.patch
Patch15: CVE-2022-37434-2.patch
-BuildRequires: cmake openssl-devel ncurses-devel libtirpc-devel rpcgen libcurl-devel make
-
-Requires: libatomic >= 1.2.0 libstdc++ >= 7.3.0 ncurses libtirpc openssl ldconfig
-
+BuildRequires: cmake gcc-c++ libaio-devel libedit-devel libevent-devel libicu-devel lz4
+BuildRequires: lz4-devel mecab-devel bison libzstd-devel
+%ifnarch aarch64 %{arm} s390 s390x
+BuildRequires: numactl-devel
+%endif
+BuildRequires: openssl openssl-devel libcurl-devel make
+BuildRequires: perl-interpreter perl-generators
+BuildRequires: rpcgen libtirpc-devel
+BuildRequires: protobuf-lite-devel rapidjson-devel zlib zlib-devel multilib-rpm-config procps
+BuildRequires: time perl(base) perl(Carp) perl(Cwd) perl(Digest::file) perl(Digest::MD5)
+BuildRequires: perl(English) perl(Env) perl(Errno) perl(Exporter) perl(Fcntl)
+BuildRequires: perl(File::Basename) perl(File::Copy) perl(File::Find) perl(File::Spec)
+BuildRequires: perl(File::Spec::Functions) perl(File::Temp) perl(FindBin) perl(Data::Dumper)
+BuildRequires: perl(Getopt::Long) perl(if) perl(IO::File) perl(IO::Handle) perl(IO::Select)
+BuildRequires: perl(IO::Socket::INET) perl(IPC::Open3) perl(JSON) perl(lib) perl(LWP::Simple)
+BuildRequires: perl(Memoize) perl(Net::Ping) perl(POSIX) perl(Socket) perl(strict)
+BuildRequires: perl(Sys::Hostname) perl(Test::More) perl(Time::HiRes) perl(Time::localtime)
+BuildRequires: perl(warnings) systemd m4
+Requires: bash coreutils grep %{name}-common%{?_isa} = %{sameevr}
+Provides: bundled(boost) = %{boost_bundled_version}
+%if %{with mysql_names}
+Provides: mysql = %{sameevr}
+Provides: mysql%{?_isa} = %{sameevr}
+Provides: mysql-compat-client = %{sameevr}
+Provides: mysql-compat-client%{?_isa} = %{sameevr}
+%endif
+%{?with_conflicts:Conflicts: mariadb}
+%global __requires_exclude ^perl\\((hostnames|lib::mtr|lib::v1|mtr_|My::)
+%global __provides_exclude_from ^(%{_datadir}/(mysql|mysql-test)/.*|%{_libdir}/mysql/plugin/.*\\.so)$
%description
-The MySQL(TM) software delivers a very fast, multi-threaded, multi-user,
-and robust SQL (Structured Query Language) database server. MySQL Server
-is intended for mission-critical, heavy-load production systems as well
-as for embedding into mass-deployed software. MySQL is a trademark of
-Oracle and/or its affiliates
-
-The MySQL software has Dual Licensing, which means you can use the MySQL
-software free of charge under the GNU General Public License
-(http://www.gnu.org/licenses/). You can also purchase commercial MySQL
-licenses from Oracle and/or its affiliates if you do not wish to be bound by the terms of
-the GPL. See the chapter "Licensing and Support" in the manual for
-further info.
+MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
+client/server implementation consisting of a server daemon (mysqld)
+and many different client programs and libraries. The base package
+contains the standard MySQL client programs and generic MySQL files.
+%if %{with clibrary}
+
+%package libs
+Summary: The shared libraries required for MySQL clients
+Requires: %{name}-common%{?_isa} = %{sameevr}
+%if %{with mysql_names}
+Provides: mysql-libs = %{sameevr}
+Provides: mysql-libs%{?_isa} = %{sameevr}
+%endif
+%description libs
+The mysql-libs package provides the essential shared libraries for any
+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
+MySQL server.
+%endif
+
+
+%package config
+Summary: The config files required by server and client
+%description config
+The package provides the config file my.cnf and my.cnf.d directory used by any
+MariaDB or MySQL program. You will need to install this package to use any
+other MariaDB or MySQL package if the config files are not provided in the
+package itself.
+
+%if %{with common}
+
+%package common
+Summary: The shared files required for MySQL server and client
+Requires: %{_sysconfdir}/my.cnf
+%description common
+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 package.
+%endif
+%if %{with errmsg}
+
+%package errmsg
+Summary: The error messages files required by MySQL server
+Requires: %{name}-common%{?_isa} = %{sameevr}
+%description errmsg
+The package provides error messages files for the MySQL daemon
+%endif
+
+%package server
+Summary: The MySQL server and related files
+Suggests: %{name}%{?_isa} = %{sameevr}
+Requires: mysql%{?_isa}
+Requires: %{name}-common%{?_isa} = %{sameevr} %{_sysconfdir}/my.cnf
+Requires: %{_sysconfdir}/my.cnf.d %{name}-errmsg%{?_isa} = %{sameevr}
+%{?mecab:Requires: mecab-ipadic}
+Requires: coreutils
+Requires(pre): /usr/sbin/useradd
+Requires: systemd
+%{?systemd_requires: %systemd_requires}
+Recommends: libcap
+Requires(post): policycoreutils-python-utils
+%if %require_mysql_selinux
+Requires: (mysql-selinux if selinux-policy-targeted)
+%endif
+%if %{with mysql_names}
+Provides: mysql-server = %{sameevr}
+Provides: mysql-server%{?_isa} = %{sameevr}
+Provides: mysql-compat-server = %{sameevr}
+Provides: mysql-compat-server%{?_isa} = %{sameevr}
+%endif
+%{?with_conflicts:Conflicts: mariadb-server}
+%{?with_conflicts:Conflicts: mariadb-galera-server}
+%description server
+MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
+client/server implementation consisting of a server daemon (mysqld)
+and many different client programs and libraries. This package contains
+the MySQL server and some accompanying files and directories.
+%if %{with devel}
+
+%package devel
+Summary: Files for development of MySQL applications
+%{?with_clibrary:Requires: %{name}-libs%{?_isa} = %{sameevr}}
+Requires: openssl-devel zlib-devel libzstd-devel
+%{?with_conflicts:Conflicts: mariadb-devel}
+%description devel
+MySQL is a multi-user, multi-threaded SQL database server. This
+package contains the libraries and header files that are needed for
+developing MySQL client applications.
+%endif
+%if %{with test}
+
+%package test
+Summary: The test suite distributed with MySQL
+Requires: %{name}%{?_isa} = %{sameevr} %{name}-common%{?_isa} = %{sameevr}
+Requires: %{name}-server%{?_isa} = %{sameevr} gzip lz4 openssl perl(Digest::file)
+Requires: perl(Digest::MD5) perl(Env) perl(Exporter) perl(Fcntl) perl(File::Temp)
+Requires: perl(FindBin) perl(Data::Dumper) perl(Getopt::Long) perl(IPC::Open3) perl(JSON)
+Requires: perl(LWP::Simple) perl(Memoize) perl(Socket) perl(Sys::Hostname)
+Requires: perl(Test::More) perl(Time::HiRes)
+%{?with_conflicts:Conflicts: mariadb-test}
+%if %{with mysql_names}
+Provides: mysql-test = %{sameevr}
+Provides: mysql-test%{?_isa} = %{sameevr}
+%endif
+%description test
+MySQL is a multi-user, multi-threaded SQL database server. This
+package contains the regression test suite distributed with
+the MySQL sources.
+%endif
+
+%package help
+Summary: Docs for development of MySQL applications.
+Requires: mysql = %{version}-%{release}
+%description help
+The package provides Docs for development of MySQL applications.
+
%prep
%setup -q -n %{name}-%{version}
-%patch0 -p1
%patch1 -p1
%patch3 -p1
+%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
+%patch9 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
@@ -61,69 +228,328 @@ pushd boost/boost_$(echo %{boost_bundled_version}| tr . _)
%patch10 -p0
%patch11 -p1
popd
+pushd mysql-test
+add_test () {
+ echo "$1" : BUG#0 "${@:2}" >> %{skiplist}
+}
+touch %{skiplist}
+add_test innodb.redo_log_archive_04 failed since 8.0.17
+add_test clone.remote_dml_no_binlog failed since 8.0.17
+add_test auth_sec.keyring_file_data_qa sporadic since 8.0.19
+add_test collations.chinese sporadic since 8.0.19
+add_test main.mysql_load_data_local_dir local infile on
+add_test rpl.rpl_row_jsondiff_basic_pk failed since 8.0.22
+add_test rpl.rpl_row_jsondiff_basic_nokey failed since 8.0.22
+%ifarch %arm aarch64
+add_test gis.st_latitude
+add_test gis.st_longitude
+add_test perfschema.func_file_io missing hw on arm32
+add_test perfschema.func_mutex missing hw on arm32
+add_test perfschema.global_read_lock missing hw on arm32
+add_test perfschema.setup_objects missing hw on arm32
+add_test clone.remote_error_basic max_allowed_packet is 0
+add_test innodb.create_tablespace
+%endif
+%ifarch s390x
+add_test gis.geometry_class_attri_prop
+add_test gis.geometry_property_function_issimple
+add_test gis.gis_bugs_crashes
+add_test gis.spatial_analysis_functions_buffer
+add_test gis.spatial_analysis_functions_centroid
+add_test gis.spatial_analysis_functions_distance
+add_test gis.spatial_operators_intersection
+add_test gis.spatial_op_testingfunc_mix
+add_test gis.spatial_utility_function_distance_sphere
+add_test gis.spatial_utility_function_simplify
+add_test innodb.log_encrypt_kill main.with_recursive
+add_test innodb.mysqldump_max_recordsize
+add_test main.lock_multi_bug38499
+add_test main.window_std_var
+add_test main.window_std_var_optimized
+add_test main.with_recursive
+add_test x.resource_groups
+add_test gis.spatial_operators_symdifference
+add_test gis.spatial_operators_union
+add_test main.subquery_bugs
+%endif
+%ifarch %arm
+add_test perfschema.relaylog
+%endif
+popd
+cp %{SOURCE2} %{SOURCE3} %{SOURCE10} %{SOURCE11} %{SOURCE12} \
+ %{SOURCE14} %{SOURCE15} %{SOURCE17} %{SOURCE18} %{SOURCE31} scripts
%build
-cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql/data -DSYSCONFDIR=/etc \
- -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 \
- -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 \
- -DENABLED_LOCAL_INFILE=1 -DENABLE_DTRACE=0 -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci \
- -DWITH_EMBEDDED_SERVER=1 -DCMAKE_C_COMPILER=/usr/bin/gcc -DDOWNLOAD_BOOST=1 -DWITH_BOOST=./boost -DFORCE_INSOURCE_BUILD=1
+%ifarch %arm
+%define _lto_cflags %{nil}
+%endif
+%if %runselftest
+ if [ x"$(id -u)" = "x0" ]; then
+ echo "mysql's regression tests fail if run as root."
+ echo "If you really need to build the RPM as root, use"
+ echo "--nocheck to skip the regression tests."
+ exit 1
+ fi
+%endif
+mkdir -p build && chmod +w build && cd build
+cmake .. \
+ -DBUILD_CONFIG=mysql_release \
+ -DFEATURE_SET="community" \
+ -DINSTALL_LAYOUT=RPM \
+ -DDAEMON_NAME="%{daemon_name}" \
+ -DDAEMON_NO_PREFIX="%{daemon_no_prefix}" \
+ -DLOG_LOCATION="%{logfile}" \
+ -DPID_FILE_DIR="%{pidfiledir}" \
+ -DNICE_PROJECT_NAME="MySQL" \
+ -DCMAKE_INSTALL_PREFIX="%{_prefix}" \
+ -DSYSCONFDIR="%{_sysconfdir}" \
+ -DSYSCONF2DIR="%{_sysconfdir}/my.cnf.d" \
+ -DINSTALL_DOCDIR="share/doc/%{_pkgdocdirname}" \
+ -DINSTALL_DOCREADMEDIR="share/doc/%{_pkgdocdirname}" \
+ -DINSTALL_INCLUDEDIR=include/mysql \
+ -DINSTALL_INFODIR=share/info \
+ -DINSTALL_LIBEXECDIR=libexec \
+ -DINSTALL_LIBDIR="%{_lib}/mysql" \
+ -DRPATH_LIBDIR="%{_libdir}" \
+ -DINSTALL_MANDIR=share/man \
+ -DINSTALL_MYSQLSHAREDIR=share/%{pkg_name} \
+ -DINSTALL_MYSQLTESTDIR=share/mysql-test \
+ -DINSTALL_PLUGINDIR="%{_lib}/mysql/plugin" \
+ -DINSTALL_SBINDIR=bin \
+ -DINSTALL_SUPPORTFILESDIR=share/%{pkg_name} \
+ -DMYSQL_DATADIR="%{dbdatadir}" \
+ -DMYSQL_UNIX_ADDR="/var/lib/mysql/mysql.sock" \
+ -DENABLED_LOCAL_INFILE=ON \
+ -DWITH_SYSTEMD=1 \
+ -DSYSTEMD_SERVICE_NAME="%{daemon_name}" \
+ -DSYSTEMD_PID_DIR="%{pidfiledir}" \
+ -DWITH_INNODB_MEMCACHED=ON \
+ -DWITH_FIDO=bundled \
+%ifnarch aarch64 %{arm} s390 s390x
+ -DWITH_NUMA=ON \
+%endif
+%ifarch s390 s390x armv7hl
+ -DUSE_LD_GOLD=OFF \
+%endif
+ -DWITH_ROUTER=OFF \
+ -DWITH_SYSTEM_LIBS=ON \
+ -DWITH_MECAB=system \
+ -DWITH_BOOST=../boost \
+ -DREPRODUCIBLE_BUILD=OFF \
+ -DCMAKE_C_FLAGS="%{optflags}%{?with_debug: -fno-strict-overflow -Wno-unused-result -Wno-unused-function -Wno-unused-but-set-variable}" \
+ -DCMAKE_CXX_FLAGS="%{optflags}%{?with_debug: -fno-strict-overflow -Wno-unused-result -Wno-unused-function -Wno-unused-but-set-variable}" \
+ -DCMAKE_EXE_LINKER_FLAGS="-pie %{build_ldflags}" \
+%{?with_debug: -DWITH_DEBUG=1} \
+%{?with_debug: -DMYSQL_MAINTAINER_MODE=0} \
+ -DTMPDIR=/var/tmp \
+ -DWITH_MYSQLD_LDFLAGS="%{build_ldflags}" \
+ -DCMAKE_C_LINK_FLAGS="%{build_ldflags}" \
+ -DCMAKE_CXX_LINK_FLAGS="%{build_ldflags}"
+cmake .. -LAH
%make_build
+cd -
%install
-%make_install
+cd build
+make DESTDIR=%{buildroot} install
+if %multilib_capable; then
+mv %{buildroot}%{_bindir}/mysql_config %{buildroot}%{_bindir}/mysql_config-%{__isa_bits}
+install -p -m 0755 scripts/mysql_config_multilib %{buildroot}%{_bindir}/mysql_config
+fi
+install -p -m 0644 Docs/INFO_SRC %{buildroot}%{_libdir}/mysql/
+install -p -m 0644 Docs/INFO_BIN %{buildroot}%{_libdir}/mysql/
+mkdir -p %{buildroot}%{logfiledir}
+mkdir -p %{buildroot}%{pidfiledir}
+install -p -m 0755 -d %{buildroot}%{dbdatadir}
+install -p -m 0750 -d %{buildroot}%{_localstatedir}/lib/mysql-files
+install -p -m 0700 -d %{buildroot}%{_localstatedir}/lib/mysql-keyring
+
+install -D -p -m 0644 scripts/my.cnf %{buildroot}%{_sysconfdir}/my.cnf
+
+install -D -p -m 644 scripts/mysql.service %{buildroot}%{_unitdir}/%{daemon_name}.service
+install -D -p -m 644 scripts/mysql@.service %{buildroot}%{_unitdir}/%{daemon_name}@.service
+install -D -p -m 0644 scripts/mysql.tmpfiles.d %{buildroot}%{_tmpfilesdir}/%{daemon_name}.conf
+rm -r %{buildroot}%{_tmpfilesdir}/mysql.conf
+install -D -p -m 755 scripts/mysql-prepare-db-dir %{buildroot}%{_libexecdir}/mysql-prepare-db-dir
+install -p -m 755 scripts/mysql-wait-stop %{buildroot}%{_libexecdir}/mysql-wait-stop
+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
+install -D -p -m 0644 scripts/server.cnf %{buildroot}%{_sysconfdir}/my.cnf.d/%{pkg_name}-server.cnf
+rm %{buildroot}%{_libdir}/mysql/*.a
+rm %{buildroot}%{_mandir}/man1/comp_err.1*
+mkdir -p %{buildroot}%{logrotateddir}
+mv %{buildroot}%{_datadir}/%{pkg_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
+mv %{buildroot}%{_bindir}/mysqld %{buildroot}%{_libexecdir}/mysqld
+mkdir -p %{buildroot}%{_sbindir}
+ln -s %{_libexecdir}/mysqld %{buildroot}%{_sbindir}/mysqld
+
+%if %{with debug}
+mv %{buildroot}%{_bindir}/mysqld-debug %{buildroot}%{_libexecdir}/mysqld
+%endif
+
+cd -
+install -p -m 0644 %{SOURCE6} %{basename:%{SOURCE6}}
+install -p -m 0644 %{SOURCE7} %{basename:%{SOURCE7}}
+install -p -m 0644 mysql-test/%{skiplist} %{buildroot}%{_datadir}/mysql-test
+
+
+mkdir -p %{buildroot}%{_sysconfdir}/my.cnf.d
-%clean
-rm -rf %{buildroot}
-%pre
+
+
+%check
+%if %runselftest
+pushd build
+make test VERBOSE=1
+cd mysql-test
+cp ../../mysql-test/%{skiplist} .
+export MTR_BUILD_THREAD=%{__isa_bits}
+./mtr %{?with_debug:--debug-server} \
+ --mem --parallel=auto --force --retry=2 \
+ --mysqld=--binlog-format=mixed \
+ --suite-timeout=720 --testcase-timeout=30 \
+ --report-unstable-tests --clean-vardir \
+%if %{check_testsuite}
+ --max-test-fail=0 || :
+%else
+ --skip-test-list=%{skiplist}
+%endif
+rm -r var $(readlink var)
+cd -
+popd
+%endif
+
+%pre server
/usr/sbin/groupadd -g 27 -o -r mysql >/dev/null 2>&1 || :
-/usr/sbin/useradd -M -N -g mysql -o -r -d %{_sharedstatedir}/mysql -s /sbin/nologin \
- -c "MySQL Server" -u 27 mysql >/dev/null 2>&1 || :
-
-%post
-if [ -f %{_prefix}/local/%{name}/support-files/mysql.server > /dev/null 2>&1 ] && [ ! -f %{_initddir}/mysql > /dev/null 2>&1 ];then
- cp %{_prefix}/local/%{name}/support-files/mysql.server %{_initddir}/mysql
- chmod +x %{_initddir}/mysql
- chkconfig --level 2345 mysql on
-fi
+/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 [ -e %{_prefix}/local/%{name}/lib/private ];then
- echo "%{_prefix}/local/%{name}/lib/private" > %{_sysconfdir}/ld.so.conf.d/%{name}.conf
- ldconfig
+%post server
+%systemd_post %{daemon_name}.service
+if [ ! -e "%{logfile}" -a ! -h "%{logfile}" ] ; then
+ install /dev/null -m0640 -omysql -gmysql "%{logfile}"
fi
-%preun
-if [ -f %{_sysconfdir}/my.cnf ];then
- mv %{_sysconfdir}/my.cnf %{_sysconfdir}/my.cnf.rpmold
-fi
-if [ -f %{_initddir}/mysql ];then
- mv %{_initddir}/mysql %{_initddir}/mysql.rpmold
-fi
-if [ "$1" = 0 ];then
- if [ -f %{_sysconfdir}/ld.so.conf.d/%{name}.conf ];then
- rm -f %{_sysconfdir}/ld.so.conf.d/%{name}.conf
- ldconfig
- fi
-fi
+%preun server
+%systemd_preun %{daemon_name}.service
-%postun
+%postun server
+%systemd_postun_with_restart %{daemon_name}.service
%files
-%dir %{_prefix}/local/%{name}
-%attr(755, %{name}, %{name}) %{_prefix}/local/%{name}/*
-%exclude /usr/src/debug
-%exclude /usr/lib/debug
+%doc README README.mysql-license README.mysql-docs
+%{_bindir}/{mysql,mysql_config_editor,mysqladmin,mysqlcheck,mysqldump}
+%{_bindir}/{mysqlimport,mysqlpump,mysqlshow,mysqlslap,mysqlbinlog,zlib_decompress}
+%exclude %{_tmpfilesdir}/mysql.conf
+
+%files libs
+%{_libdir}/mysql/libmysqlclient*.so.*
+%config(noreplace) %{_sysconfdir}/ld.so.conf.d/*
+
+%files config
+%dir %{_sysconfdir}/my.cnf.d
+%config(noreplace) %{_sysconfdir}/my.cnf
+
+
+
+%files common
+%dir %{_libdir}/mysql
+%dir %{_datadir}/mysql
+%{_datadir}/mysql/charsets
+
+%files errmsg
+%{_datadir}/mysql/messages_to_error_log.txt
+%{_datadir}/mysql/messages_to_clients.txt
+%{_datadir}/mysql/{errmsg-utf8.txt,english}
+%lang(bg) %{_datadir}/mysql/bulgarian
+%lang(cs) %{_datadir}/mysql/czech
+%lang(da) %{_datadir}/mysql/danish
+%lang(nl) %{_datadir}/mysql/dutch
+%lang(et) %{_datadir}/mysql/estonian
+%lang(fr) %{_datadir}/mysql/french
+%lang(de) %{_datadir}/mysql/german
+%lang(el) %{_datadir}/mysql/greek
+%lang(hu) %{_datadir}/mysql/hungarian
+%lang(it) %{_datadir}/mysql/italian
+%lang(ja) %{_datadir}/mysql/japanese
+%lang(ko) %{_datadir}/mysql/korean
+%lang(no) %{_datadir}/mysql/norwegian
+%lang(no) %{_datadir}/mysql/norwegian-ny
+%lang(pl) %{_datadir}/mysql/polish
+%lang(pt) %{_datadir}/mysql/portuguese
+%lang(ro) %{_datadir}/mysql/romanian
+%lang(ru) %{_datadir}/mysql/russian
+%lang(sr) %{_datadir}/mysql/serbian
+%lang(sk) %{_datadir}/mysql/slovak
+%lang(es) %{_datadir}/mysql/spanish
+%lang(sv) %{_datadir}/mysql/swedish
+%lang(uk) %{_datadir}/mysql/ukrainian
+
+%files server
+%{_bindir}/{ibd2sdi,myisamchk,myisam_ftdump,myisamlog,myisampack,my_print_defaults}
+%{_bindir}/{mysql_secure_installation,mysql_ssl_rsa_setup,mysql_tzinfo_to_sql,perror}
+%{_bindir}/{mysql_upgrade,mysqld_pre_systemd,mysqldumpslow,innochecksum}
+%{_bindir}/{mysql_keyring_encryption_test,mysql_migrate_keyring}
+%config(noreplace) %{_sysconfdir}/my.cnf.d/mysql-server.cnf
+%{_sbindir}/mysqld
+%caps(cap_sys_nice=ep) %{_libexecdir}/mysqld
+%{_libdir}/mysql/{INFO_SRC,INFO_BIN,plugin}
+%dir %{_datadir}/mysql
+%{_datadir}/mysql/dictionary.txt
+%{_datadir}/mysql/*.sql
+%{_unitdir}/mysqld*
+%{_libexecdir}/{mysql-prepare-db-dir,mysql-wait-stop,mysql-check-socket,mysql-scripts-common}
+%{_tmpfilesdir}/mysqld.conf
+%attr(0755,mysql,mysql) %dir %{_localstatedir}/lib/mysql
+%attr(0750,mysql,mysql) %dir %{_localstatedir}/lib/mysql-files
+%attr(0700,mysql,mysql) %dir %{_localstatedir}/lib/mysql-keyring
+%attr(0750,mysql,mysql) %dir %{_localstatedir}/log/mysql
+%attr(0755,mysql,mysql) %dir %{_rundir}/mysqld
+%attr(0640,mysql,mysql) %config %ghost %verify(not md5 size mtime) %{_localstatedir}/log/mysql/mysqld.log
+%config(noreplace) %{_sysconfdir}/logrotate.d/mysqld
+
+%files devel
+%{_bindir}/mysql_config*
+%{_includedir}/mysql
+%{_datadir}/aclocal/mysql.m4
+%{_libdir}/mysql/libmysqlclient.so
+%{_libdir}/pkgconfig/mysqlclient.pc
+%exclude %{_bindir}/mysql_config_editor
+
+
+%files test
+%{_bindir}/{mysql_client_test,mysqltest,mysqltest_safe_process,mysqlxtest}
+%{_bindir}/{mysqld_safe,comp_err}
+%attr(-,mysql,mysql) %{_datadir}/mysql-test
+
+%files help
+%doc README.mysql-license README.mysql-docs LICENSE
+%doc storage/innobase/COPYING.Percona storage/innobase/COPYING.Google
+%{_mandir}/man1/{mysql.1*,mysql_config_editor.1*,mysqladmin.1*,mysqlbinlog.1*,mysqldump.1*}
+%{_mandir}/man1/{mysqlcheck.1*,mysqlimport.1*,mysqlpump.1*,mysqlshow.1*,mysqlslap.1*}
+%{_mandir}/man1/{ibd2sdi.1*,myisamchk.1*,myisamlog.1*,myisampack.1*,myisam_ftdump.1*,mysqlman.1*}
+%{_mandir}/man1/{my_print_defaults.1*,mysql_secure_installation.1*,mysql_ssl_rsa_setup.1*}
+%{_mandir}/man1/{mysql_tzinfo_to_sql.1*,mysql_upgrade.1*,mysqldumpslow.1*,perror.1*}
+%{_mandir}/man1/{lz4_decompress.1*,zlib_decompress.1*,innochecksum.1*,mysql.server.1*}
+%{_mandir}/man8/mysqld.8*
+%{_mandir}/man1/mysql_config.1*
%changelog
+* Fri Nov 10 2023 haomimi - 8.0.28-3
+- fix Failed to start mysqld.service
+
* Tue May 16 2023 yaoxin - 8.0.28-2
- Fix CVE-2022-37434
-* Tue Jan 25 yaoxin - 8.0.28-1
+* Tue Jan 25 2023 yaoxin - 8.0.28-1
- Upgrade mysql to 8.0.28 to fix cves.
-* Wed Nov 24 yaoxin - 8.0.27-1
+* Wed Nov 24 2022 - 8.0.27-1
- Upgrade mysql to 8.0.27,fix CVES:CVE-2021-2471 CVE-2021-2478 CVE-2021-2479
CVE-2021-2481 CVE-2021-35546 CVE-2021-35575 CVE-2021-35577 CVE-2021-35591
CVE-2021-35596 CVE-2021-35597 CVE-2021-35602 CVE-2021-35604 CVE-2021-35607
@@ -184,4 +610,4 @@ fi
- add fstack-protector-strong
* Fri Feb 28 2020 catastrowings 8.0.17-2
-- openEuler package init.
+- openEuler package init.
\ No newline at end of file
diff --git a/mysql.tmpfiles.d.in b/mysql.tmpfiles.d.in
new file mode 100644
index 0000000000000000000000000000000000000000..d2c4b3105d4e1142474c6391c7d645b83009bcad
--- /dev/null
+++ b/mysql.tmpfiles.d.in
@@ -0,0 +1 @@
+d @PID_FILE_DIR@ 0755 mysql mysql -
diff --git a/mysql.yaml b/mysql.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..e1e31058a4722597766385179e938f882f1c16a2
--- /dev/null
+++ b/mysql.yaml
@@ -0,0 +1,4 @@
+version_control: github
+src_repo: mysql/mysql-server
+tag_prefix: mysql-cluster-
+seperator: .
diff --git a/mysql@.service.in b/mysql@.service.in
new file mode 100644
index 0000000000000000000000000000000000000000..b7b2d48c1476943f1344495b7773fa39862015d0
--- /dev/null
+++ b/mysql@.service.in
@@ -0,0 +1,62 @@
+# 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 use systemctl edit:
+#
+# $ systemctl edit @DAEMON_NAME@.service
+#
+# this will create file
+#
+# /etc/systemd/system/@DAEMON_NAME@.service.d/override.conf
+#
+# which be parsed after the file @DAEMON_NAME@.service itself is parsed.
+#
+# For example, if you want to increase mysql's open-files-limit to 20000
+# add following when editing with command above:
+#
+# [Service]
+# LimitNOFILE=20000
+#
+# Or if you require to execute pre and post scripts in the unit file as root, set
+# PermissionsStartOnly=true
+#
+# 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
+#
+# 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=notify
+User=mysql
+Group=mysql
+
+ExecStartPre=@libexecdir@/mysql-check-socket --defaults-group-suffix=.%I
+ExecStartPre=@libexecdir@/mysql-prepare-db-dir --defaults-group-suffix=.%I %n
+# Note: we set --basedir to prevent probes that might trigger SELinux alarms,
+# per bug #547485
+ExecStart=@libexecdir@/mysqld --defaults-group-suffix=.%I --basedir=@prefix@
+ExecStopPost=@libexecdir@/mysql-wait-stop --defaults-group-suffix=.%I
+
+# 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
+
+Restart=on-failure
+
+RestartPreventExitStatus=1
+
+# Sets open_files_limit
+LimitNOFILE = 10000
+
+# Set enviroment variable MYSQLD_PARENT_PID. This is required for SQL restart command.
+Environment=MYSQLD_PARENT_PID=1
+
+[Install]
+WantedBy=multi-user.target
diff --git a/mysql_config_multilib.sh b/mysql_config_multilib.sh
new file mode 100644
index 0000000000000000000000000000000000000000..06c2a2b45dc2cd3ec4c58a5fad43543873954bfa
--- /dev/null
+++ b/mysql_config_multilib.sh
@@ -0,0 +1,26 @@
+#! /bin/sh
+#
+# Wrapper script for mysql_config to support multilib
+#
+# This command respects setarch
+
+bits=$(rpm --eval %__isa_bits)
+
+case $bits in
+ 32|64) status=known ;;
+ *) status=unknown ;;
+esac
+
+if [ "$status" = "unknown" ] ; then
+ echo "$0: error: command 'rpm --eval %__isa_bits' returned unknown value: $bits"
+ exit 1
+fi
+
+
+if [ -x @bindir@/mysql_config-$bits ] ; then
+ @bindir@/mysql_config-$bits "$@"
+else
+ echo "$0: error: needed binary: @bindir@/mysql_config-$bits is missing"
+ exit 1
+fi
+
diff --git a/server.cnf.in b/server.cnf.in
new file mode 100644
index 0000000000000000000000000000000000000000..ba3d47946ea4c10bb4079ef85abb80443a18b4c4
--- /dev/null
+++ b/server.cnf.in
@@ -0,0 +1,18 @@
+#
+# This group are read by MySQL server.
+# Use it for options that only the server (but not clients) should see
+#
+# For advice on how to change settings please see
+# http://dev.mysql.com/doc/refman/en/server-configuration-defaults.html
+
+# Settings user and group are ignored when systemd is used.
+# If you need to run mysqld under a different user or group,
+# customize your systemd unit file for mysqld according to the
+# instructions in http://fedoraproject.org/wiki/Systemd
+
+[mysqld]
+datadir=@MYSQL_DATADIR@
+socket=@MYSQL_UNIX_ADDR@
+log-error=@LOG_LOCATION@
+pid-file=@PID_FILE_DIR@/@DAEMON_NO_PREFIX@.pid
+