summaryrefslogtreecommitdiffstats
path: root/debian/patches
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 18:07:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 18:07:29 +0000
commit82a6365993a3c6650c39a1bca3ec3ccba827b763 (patch)
tree5c5987626fe4696f54de9cdedfa95e0251e4e7b4 /debian/patches
parentAdding upstream version 1:10.5.12. (diff)
downloadmariadb-10.5-82a6365993a3c6650c39a1bca3ec3ccba827b763.tar.xz
mariadb-10.5-82a6365993a3c6650c39a1bca3ec3ccba827b763.zip
Adding debian version 1:10.5.12-1.debian/1%10.5.12-1debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--debian/patches/0025-Change-the-default-optimization-from-O3-to-O2-in-mys.patch54
-rw-r--r--debian/patches/1556.patch200
-rw-r--r--debian/patches/c11_atomics.patch75
-rw-r--r--debian/patches/env-perl-usr-bin-perl.patch97
-rw-r--r--debian/patches/fix-reproducible-builds-rocksdb.patch24
-rw-r--r--debian/patches/fix-spelling.patch36
-rw-r--r--debian/patches/mips-compilation-failure-__bss_start-symbol-miss.patch65
-rw-r--r--debian/patches/mips-connect-unaligned.patch269
-rw-r--r--debian/patches/mips-groonga-atomic.patch34
-rw-r--r--debian/patches/mroonga-path-reproducible-build.patch15
-rw-r--r--debian/patches/rocksdb-kfreebsd.patch148
-rw-r--r--debian/patches/series11
12 files changed, 1028 insertions, 0 deletions
diff --git a/debian/patches/0025-Change-the-default-optimization-from-O3-to-O2-in-mys.patch b/debian/patches/0025-Change-the-default-optimization-from-O3-to-O2-in-mys.patch
new file mode 100644
index 00000000..167e68cb
--- /dev/null
+++ b/debian/patches/0025-Change-the-default-optimization-from-O3-to-O2-in-mys.patch
@@ -0,0 +1,54 @@
+From: =?utf-8?q?Ond=C5=99ej_Sur=C3=BD?= <ondrej@debian.org>
+Date: Wed, 22 Nov 2017 20:32:51 +0000
+Subject: Change the default optimization from -O3 to -O2 in
+ mysql_release.cmake BUILD_CONFIG profile
+Forwarded: https://jira.mariadb.org/browse/MDEV-19734?focusedCommentId=156606&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-156606
+
+---
+ cmake/build_configurations/mysql_release.cmake | 12 ++++++------
+ .../PerconaFT/cmake_modules/TokuSetupCompiler.cmake | 16 ++++++++--------
+ 2 files changed, 14 insertions(+), 14 deletions(-)
+
+--- a/cmake/build_configurations/mysql_release.cmake
++++ b/cmake/build_configurations/mysql_release.cmake
+@@ -176,12 +176,12 @@ IF(UNIX)
+ IF(CMAKE_COMPILER_IS_GNUCC)
+ SET(COMMON_C_FLAGS "-g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -Wno-uninitialized")
+ SET(CMAKE_C_FLAGS_DEBUG "-O ${COMMON_C_FLAGS}")
+- SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_C_FLAGS}")
++ SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 ${COMMON_C_FLAGS}")
+ ENDIF()
+ IF(CMAKE_COMPILER_IS_GNUCXX)
+ SET(COMMON_CXX_FLAGS "-g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -Wno-uninitialized")
+ SET(CMAKE_CXX_FLAGS_DEBUG "-O ${COMMON_CXX_FLAGS}")
+- SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_CXX_FLAGS}")
++ SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 ${COMMON_CXX_FLAGS}")
+ ENDIF()
+
+ # IBM Z flags
+@@ -230,8 +230,8 @@ IF(UNIX)
+ ENDIF()
+ SET(CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS}")
+ SET(CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS}")
+- SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -unroll2 -ip ${COMMON_C_FLAGS}")
+- SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -unroll2 -ip ${COMMON_CXX_FLAGS}")
++ SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -unroll2 -ip ${COMMON_C_FLAGS}")
++ SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -unroll2 -ip ${COMMON_CXX_FLAGS}")
+ SET(WITH_SSL no)
+ ENDIF()
+ ENDIF()
+@@ -240,12 +240,12 @@ IF(UNIX)
+ IF(CMAKE_C_COMPILER_ID MATCHES "Clang")
+ SET(COMMON_C_FLAGS "-g -fno-omit-frame-pointer -fno-strict-aliasing -Wno-parentheses-equality -Wno-string-plus-int")
+ SET(CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS}")
+- SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_C_FLAGS}")
++ SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 ${COMMON_C_FLAGS}")
+ ENDIF()
+ IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ SET(COMMON_CXX_FLAGS "-g -fno-omit-frame-pointer -fno-strict-aliasing -Wno-parentheses-equality -Wno-string-plus-int")
+ SET(CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS}")
+- SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_CXX_FLAGS}")
++ SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 ${COMMON_CXX_FLAGS}")
+ ENDIF()
+
+ # Solaris flags
diff --git a/debian/patches/1556.patch b/debian/patches/1556.patch
new file mode 100644
index 00000000..adc7a6b0
--- /dev/null
+++ b/debian/patches/1556.patch
@@ -0,0 +1,200 @@
+Forwarded: https://github.com/MariaDB/server/pull/1556
+From 3cf95de573a6b10e68df2efc1f8cf2f42fdd2d68 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= <otto@kekalainen.net>
+Date: Wed, 30 Sep 2020 20:01:35 +0300
+Subject: [PATCH] MDEV-22659: Create one single unified and optimal logrotate
+ config
+
+Replace mysql-log-rotate.sh and debian/...mysql-server.logrotate with one
+new unified and well documented version.
+
+Name is mariadb.logrotate.in as in 10.5 branch we use now the 'mariadb'
+name, and use 'logrotate' to match the actual name of the utility, and
+use '.in' instead of '.sh' as this is not a shell script but a template
+file.
+
+--- a/.gitignore
++++ b/.gitignore
+@@ -275,7 +275,7 @@ support-files/my-innodb-heavy-4G.cnf
+ support-files/my-large.cnf
+ support-files/my-medium.cnf
+ support-files/my-small.cnf
+-support-files/mysql-log-rotate
++support-files/mariadb.logrotate
+ support-files/mysql.10.0.11.spec
+ support-files/mysql.server
+ support-files/mysql.service
+--- a/support-files/CMakeLists.txt
++++ b/support-files/CMakeLists.txt
+@@ -1,15 +1,15 @@
+ # Copyright (c) 2006, 2016, Oracle and/or its affiliates.
+ # Copyright (c) 2012, 2017, MariaDB
+-#
++#
+ # This program is free software; you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License as published by
+ # the Free Software Foundation; version 2 of the License.
+-#
++#
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ # GNU General Public License for more details.
+-#
++#
+ # You should have received a copy of the GNU General Public License
+ # along with this program; if not, write to the Free Software
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA
+@@ -31,6 +31,9 @@ ELSE()
+ SET(MYSQLD_USER "mysql")
+ SET(ini_file_extension "cnf")
+ SET(HOSTNAME "uname -n")
++
++ # Define directly here, as cmake/install_layout.cmake has no LOGDIR to be inherited
++ SET(logdir "/var/log/mysql")
+ ENDIF()
+
+ # XXX: shouldn't we just have variables for all this stuff and centralise
+@@ -50,9 +53,11 @@ ENDIF()
+
+ IF(UNIX)
+ SET(prefix ${CMAKE_INSTALL_PREFIX})
+- FOREACH(script mysqld_multi.server mysql-log-rotate binary-configure wsrep_notify)
+- CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${script}.sh
++ FOREACH(script mysqld_multi.server binary-configure wsrep_notify)
++ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${script}.sh
+ ${CMAKE_CURRENT_BINARY_DIR}/${script} @ONLY )
++ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mariadb.logrotate.in
++ ${CMAKE_CURRENT_BINARY_DIR}/mariadb.logrotate @ONLY )
+ INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${script}
+ DESTINATION ${inst_location} COMPONENT Server_Scripts)
+ ENDFOREACH()
+@@ -94,7 +99,7 @@ IF(UNIX)
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mariadb.pc DESTINATION ${INSTALL_LIBDIR}/pkgconfig COMPONENT Development)
+
+ INSTALL(FILES mysql.m4 DESTINATION ${INSTALL_SHAREDIR}/aclocal COMPONENT Development)
+-
++
+ SET(bindir ${INSTALL_BINDIRABS})
+ SET(sbindir ${INSTALL_SBINDIRABS})
+ SET(scriptdir ${INSTALL_SCRIPTDIRABS})
+@@ -112,7 +117,7 @@ IF(UNIX)
+ ELSE()
+ SET(sysconf2dir "${sysconfdir}/mysql")
+ ENDIF()
+- CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysql.server.sh
++ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysql.server.sh
+ ${CMAKE_CURRENT_BINARY_DIR}/mysql.server @ONLY)
+ INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/mysql.server
+ DESTINATION ${inst_location} COMPONENT SupportFiles)
+@@ -181,8 +186,9 @@ IF(UNIX)
+ ENDIF()
+
+ IF (INSTALL_SYSCONFDIR)
+- INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mysql-log-rotate DESTINATION ${INSTALL_SYSCONFDIR}/logrotate.d
+- RENAME mysql COMPONENT SupportFiles)
++ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mariadb.logrotate
++ DESTINATION ${INSTALL_SYSCONFDIR}/logrotate.d
++ RENAME mariadb COMPONENT SupportFiles)
+ IF(NOT HAVE_SYSTEMD)
+ INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/mysql.server
+ DESTINATION ${INSTALL_SYSCONFDIR}/init.d
+--- /dev/null
++++ b/support-files/mariadb.logrotate.in
+@@ -0,0 +1,56 @@
++# This is the MariaDB configuration for the logrotate utility
++#
++# Note that on most Linux systems logs are written to journald, which has its
++# own rotation scheme.
++#
++# Read https://mariadb.com/kb/en/error-log/ to learn more about logging and
++# https://mariadb.com/kb/en/rotating-logs-on-unix-and-linux/ about rotating logs.
++
++@localstatedir@/mysqld.log @logdir@/mysql.log @localstatedir@/mariadb.log @logdir@/mysql-slow.log @logdir@/mariadb-slow.log @logdir@/error.log {
++
++ # If any of the files listed above is missing, skip them silently without
++ # emitting any errors
++ missingok
++
++ # If file exists but is empty, don't rotate it
++ notifempty
++
++ # Run monthly
++ monthly
++
++ # Keep 6 months of logs
++ rotate 6
++
++ # If file is growing too big, rotate immediately
++ maxsize 500M
++
++ # If file size is too small, don't rotate at all
++ minsize 50M
++
++ # Compress logs, as they are text and compression will save a lot of disk space
++ compress
++
++ # Don't compress the log immediately to avoid errors about "file size changed while zipping"
++ delaycompress
++
++ # Don't run the postrotate script for each file configured in this file, but
++ # run it only once if one or more files were rotated
++ sharedscripts
++
++ # After each rotation, run this custom script to flush the logs. Note that
++ # this assumes that the mariadb-admin command has database access, which it
++ # has thanks to the default use of Unix socket authentication for the 'root'
++ # account used everywhere since MariaDB 10.4.
++ postrotate
++ if test -x /etc/mysql/debian.cnf
++ then
++ EXTRAPARAM='--defaults-file=/etc/mysql/debian.cnf'
++ fi
++
++ if test -x @bindir@/mariadb-admin
++ then
++ @bindir@/mariadb-admin $EXTRAPARAM --local flush-error-log \
++ flush-engine-log flush-general-log flush-slow-log
++ fi
++ endscript
++}
+--- a/support-files/mysql-log-rotate.sh
++++ /dev/null
+@@ -1,37 +0,0 @@
+-# This logname can be set in /etc/my.cnf
+-# by setting the variable "log-error"
+-# in the [mysqld] section as follows:
+-#
+-# [mysqld]
+-# log-error=@localstatedir@/mysqld.log
+-#
+-# If the root user has a password you have to create a
+-# /root/.my.cnf configuration file with the following
+-# content:
+-#
+-# [mysqladmin]
+-# password = <secret>
+-# user= root
+-#
+-# where "<secret>" is the password.
+-#
+-# ATTENTION: This /root/.my.cnf should be readable ONLY
+-# for root !
+-
+-@localstatedir@/mysqld.log {
+- # create 600 mysql mysql
+- notifempty
+- daily
+- rotate 3
+- missingok
+- compress
+- postrotate
+- # just if mariadbd is really running
+- if test -x @bindir@/mysqladmin && \
+- @bindir@/mysqladmin ping &>/dev/null
+- then
+- @bindir@/mysqladmin --local flush-error-log \
+- flush-engine-log flush-general-log flush-slow-log
+- fi
+- endscript
+-}
diff --git a/debian/patches/c11_atomics.patch b/debian/patches/c11_atomics.patch
new file mode 100644
index 00000000..00768729
--- /dev/null
+++ b/debian/patches/c11_atomics.patch
@@ -0,0 +1,75 @@
+Forwarded: https://github.com/MariaDB/server/pull/1716
+Author: Vicențiu Ciorbaru <vicentiu@mariadb.org>
+Date: Fri Dec 21 19:14:04 2018 +0200
+
+ Link with libatomic to enable C11 atomics support
+
+ Some architectures (mips) require libatomic to support proper
+ atomic operations. Check first if support is available without
+ linking, otherwise use the library.
+
+ Original commit:
+ Detect whether libatomic is needed rather than hard-coding for mips
+
+ Fixes FTBFS on powerpc, since it needs libatomic too for C11 atomics,
+ and possibly m68k.
+
+ Contributors:
+ James Cowgill <jcowgill@debian.org>
+ Jessica Clarke <jrtc27@debian.org>
+
+--- a/configure.cmake
++++ b/configure.cmake
+@@ -866,7 +866,25 @@ int main()
+ long long int *ptr= &var;
+ return (int)__atomic_load_n(ptr, __ATOMIC_SEQ_CST);
+ }"
+-HAVE_GCC_C11_ATOMICS)
++HAVE_GCC_C11_ATOMICS_WITHOUT_LIBATOMIC)
++IF (HAVE_GCC_C11_ATOMICS_WITHOUT_LIBATOMIC)
++ SET(HAVE_GCC_C11_ATOMICS True)
++ELSE()
++ SET(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
++ LIST(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
++ CHECK_CXX_SOURCE_COMPILES("
++ int main()
++ {
++ long long int var= 1;
++ long long int *ptr= &var;
++ return (int)__atomic_load_n(ptr, __ATOMIC_SEQ_CST);
++ }"
++ HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC)
++ IF(HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC)
++ SET(HAVE_GCC_C11_ATOMICS True)
++ ENDIF()
++ SET(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
++ENDIF()
+
+ IF(WITH_VALGRIND)
+ SET(HAVE_valgrind 1)
+--- a/mysys/CMakeLists.txt
++++ b/mysys/CMakeLists.txt
+@@ -168,6 +168,10 @@ TARGET_LINK_LIBRARIES(mysys dbug strings
+ ${LIBNSL} ${LIBM} ${LIBRT} ${CMAKE_DL_LIBS} ${LIBSOCKET} ${LIBEXECINFO})
+ DTRACE_INSTRUMENT(mysys)
+
++IF (HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC)
++ TARGET_LINK_LIBRARIES(mysys atomic)
++ENDIF()
++
+ IF(HAVE_BFD_H)
+ TARGET_LINK_LIBRARIES(mysys bfd)
+ ENDIF(HAVE_BFD_H)
+--- a/sql/CMakeLists.txt
++++ b/sql/CMakeLists.txt
+@@ -320,6 +320,10 @@ IF(WITH_MYSQLD_LDFLAGS)
+ "${MYSQLD_LINK_FLAGS} ${WITH_MYSQLD_LDFLAGS}")
+ ENDIF()
+
++IF (HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC)
++ TARGET_LINK_LIBRARIES(sql atomic)
++ENDIF()
++
+
+ FIND_PACKAGE(BISON 2.0)
+
diff --git a/debian/patches/env-perl-usr-bin-perl.patch b/debian/patches/env-perl-usr-bin-perl.patch
new file mode 100644
index 00000000..9ec127a0
--- /dev/null
+++ b/debian/patches/env-perl-usr-bin-perl.patch
@@ -0,0 +1,97 @@
+Forwarded: https://github.com/MariaDB/server/pull/1718
+Author: Otto Kekäläinen <otto@debian.org>
+Subject: Fix perl path in scripts
+ Fix Lintian issue
+ https://lintian.debian.org/tags/incorrect-path-for-interpreter.html
+ .
+ Upstream will never accept this patch, see
+ https://github.com/MariaDB/server/pull/1718
+
+--- a/mysql-test/lib/process-purecov-annotations.pl
++++ b/mysql-test/lib/process-purecov-annotations.pl
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env perl
++#!/usr/bin/perl
+ # -*- cperl -*-
+
+ # This script processes a .gcov coverage report to honor purecov
+--- a/mysql-test/lib/v1/mysql-test-run.pl
++++ b/mysql-test/lib/v1/mysql-test-run.pl
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env perl
++#!/usr/bin/perl
+ # -*- cperl -*-
+
+ # Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+--- a/mysql-test/mysql-stress-test.pl
++++ b/mysql-test/mysql-stress-test.pl
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env perl
++#!/usr/bin/perl
+
+ # Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ #
+--- a/mysql-test/mysql-test-run.pl
++++ b/mysql-test/mysql-test-run.pl
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env perl
++#!/usr/bin/perl
+ # -*- cperl -*-
+
+ # Copyright (c) 2004, 2014, Oracle and/or its affiliates.
+--- a/mysql-test/std_data/checkDBI_DBD-MariaDB.pl
++++ b/mysql-test/std_data/checkDBI_DBD-MariaDB.pl
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env perl
++#!/usr/bin/perl
+
+ # Copyright (c) 2011, Oracle and/or its affiliates
+ #
+--- a/mysql-test/suite/engines/rr_trx/run_stress_tx_rr.pl
++++ b/mysql-test/suite/engines/rr_trx/run_stress_tx_rr.pl
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env perl
++#!/usr/bin/perl
+ ################################################################################
+ #
+ # This script runs the transactional stress test "stress_tx_rr" against the
+--- a/mysql-test/suite/funcs_1/lib/DataGen_local.pl
++++ b/mysql-test/suite/funcs_1/lib/DataGen_local.pl
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env perl
++#!/usr/bin/perl
+
+
+ if ( (scalar(@ARGV) != 1 ) || ($ARGV[0] =~ /[^0-9]/i ) )
+--- a/mysql-test/suite/funcs_1/lib/DataGen_modify.pl
++++ b/mysql-test/suite/funcs_1/lib/DataGen_modify.pl
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env perl
++#!/usr/bin/perl
+
+
+ if ( (scalar(@ARGV) != 2 ) || ($ARGV[0] =~ /[^0-9]/i ) )
+--- a/mysql-test/suite/funcs_2/lib/gen_charset_utf8.pl
++++ b/mysql-test/suite/funcs_2/lib/gen_charset_utf8.pl
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env perl
++#!/usr/bin/perl
+
+ #################################################################################
+ # Author: Serge Kozlov #
+--- a/mysql-test/suite/rpl/extension/checksum.pl
++++ b/mysql-test/suite/rpl/extension/checksum.pl
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env perl
++#!/usr/bin/perl
+
+ # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ #
+--- a/scripts/mytop.sh
++++ b/scripts/mytop.sh
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env perl
++#!/usr/bin/perl
+ #
+ # $Id: mytop,v 1.99-maria6 2019/10/22 14:53:51 jweisbuch Exp $
+
diff --git a/debian/patches/fix-reproducible-builds-rocksdb.patch b/debian/patches/fix-reproducible-builds-rocksdb.patch
new file mode 100644
index 00000000..10182d5e
--- /dev/null
+++ b/debian/patches/fix-reproducible-builds-rocksdb.patch
@@ -0,0 +1,24 @@
+From: https://github.com/SafetyCulture/rocksdb/storage/rocksdb/commit/22aa678dac1bb4c01662a414498f9a1ef2a5a4c7
+Author: Otto Kekäläinen <otto@kekalainen.net>
+Subject: Make RocksDB build reproducible
+
+The RocksDB binary included a string with the build timestamp:
+> rocksdb_build_git_date:@2021-05-23·16:04:38@
+
+As this changes from build to build, it makes the builds unreproducible.
+Simply removing it solves the issue.
+
+This temporary fix can be removed when a proper fix already done in upstream
+lands in MariaDB when the RocksDB submodule is updated to a newer release.
+
+--- a/storage/rocksdb/rocksdb/util/build_version.cc.in
++++ b/storage/rocksdb/rocksdb/util/build_version.cc.in
+@@ -1,5 +1,5 @@
+ // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
+ #include "build_version.h"
+-const char* rocksdb_build_git_sha = "rocksdb_build_git_sha:@@GIT_SHA@@";
+-const char* rocksdb_build_git_date = "rocksdb_build_git_date:@@GIT_DATE_TIME@@";
+-const char* rocksdb_build_compile_date = __DATE__;
++const char* rocksdb_build_git_sha = "rocksdb_build_git_sha:REDACTED";
++const char* rocksdb_build_git_date = "rocksdb_build_git_date:REDACTED";
++const char* rocksdb_build_compile_date = "REDACTED";
diff --git a/debian/patches/fix-spelling.patch b/debian/patches/fix-spelling.patch
new file mode 100644
index 00000000..47d4c632
--- /dev/null
+++ b/debian/patches/fix-spelling.patch
@@ -0,0 +1,36 @@
+Forwarded: https://github.com/facebook/rocksdb/pull/7785
+Author: Otto Kekäläinen <otto@debian.org>
+Subject: Fix various spelling errors still found in code
+ Two upstream PRs remain that have been merged, but not imported on MariaDB 10.5.
+
+--- a/storage/rocksdb/rocksdb/db/external_sst_file_ingestion_job.cc
++++ b/storage/rocksdb/rocksdb/db/external_sst_file_ingestion_job.cc
+@@ -46,7 +46,7 @@ Status ExternalSstFileIngestionJob::Prep
+ TablePropertiesCollectorFactory::Context::kUnknownColumnFamily &&
+ f.cf_id != cfd_->GetID()) {
+ return Status::InvalidArgument(
+- "External file column family id dont match");
++ "External file column family id don't match");
+ }
+ }
+
+@@ -646,7 +646,7 @@ Status ExternalSstFileIngestionJob::Assi
+ return Status::InvalidArgument("Global seqno is required, but disabled");
+ } else if (file_to_ingest->global_seqno_offset == 0) {
+ return Status::InvalidArgument(
+- "Trying to set global seqno for a file that dont have a global seqno "
++ "Trying to set global seqno for a file that don't have a global seqno "
+ "field");
+ }
+
+--- a/storage/rocksdb/rocksdb/include/rocksdb/cache.h
++++ b/storage/rocksdb/rocksdb/include/rocksdb/cache.h
+@@ -60,7 +60,7 @@ struct LRUCacheOptions {
+ // If greater than zero, the LRU list will be split into a high-pri
+ // list and a low-pri list. High-pri entries will be insert to the
+ // tail of high-pri list, while low-pri entries will be first inserted to
+- // the low-pri list (the midpoint). This is refered to as
++ // the low-pri list (the midpoint). This is referred to as
+ // midpoint insertion strategy to make entries never get hit in cache
+ // age out faster.
+ //
diff --git a/debian/patches/mips-compilation-failure-__bss_start-symbol-miss.patch b/debian/patches/mips-compilation-failure-__bss_start-symbol-miss.patch
new file mode 100644
index 00000000..8bbb837f
--- /dev/null
+++ b/debian/patches/mips-compilation-failure-__bss_start-symbol-miss.patch
@@ -0,0 +1,65 @@
+Forwarded: https://github.com/MariaDB/server/pull/1716
+From 8c1608a68c57c98cdd695996d44663faca01ddd3 Mon Sep 17 00:00:00 2001
+From: Vicentiu Ciorbaru <vicentiu@debian>
+Date: Wed, 28 Nov 2018 18:01:04 +0200
+Subject: [PATCH] Fix mips compilation failure (__bss_start symbol missing)
+
+__bss_start symbol fails to link if -lsystemd is used. There is no
+obvious reason why this happens but the code using it is only relevant
+when doing a crash report and it is covered through a separate print
+statement anyway (used to print THD->query()).
+
+To fix the compilation problem, just check if we will link with systemd
+before checking __bss_start symbol, and add -lsystemd as a required library.
+This will reproduce the compilation environment used for the final binary
+and will correctly detect if __bss_start will be available or not.
+---
+ CMakeLists.txt | 4 ++--
+ cmake/systemd.cmake | 2 ++
+ configure.cmake | 3 +++
+ 3 files changed, 7 insertions(+), 2 deletions(-)
+
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -363,6 +363,8 @@ ELSE()
+ SET(DEFAULT_TMPDIR "\"${TMPDIR}\"")
+ ENDIF()
+
++CHECK_SYSTEMD()
++
+ # Run platform tests
+ INCLUDE(configure.cmake)
+
+@@ -394,8 +396,6 @@ SET(MALLOC_LIBRARY "system")
+
+ CHECK_PCRE()
+
+-CHECK_SYSTEMD()
+-
+ IF(CMAKE_CROSSCOMPILING AND NOT DEFINED CMAKE_CROSSCOMPILING_EMULATOR)
+ SET(IMPORT_EXECUTABLES "IMPORTFILE-NOTFOUND" CACHE FILEPATH "Path to import_executables.cmake from a native build")
+ INCLUDE(${IMPORT_EXECUTABLES})
+--- a/cmake/systemd.cmake
++++ b/cmake/systemd.cmake
+@@ -17,6 +17,9 @@ MACRO(CHECK_SYSTEMD)
+ IF(UNIX)
+ INCLUDE(FindPkgConfig)
+ # http://www.cmake.org/cmake/help/v3.0/module/FindPkgConfig.html
++ INCLUDE(CheckFunctionExists)
++ INCLUDE(CheckIncludeFiles)
++
+ SET(WITH_SYSTEMD "auto" CACHE STRING "Enable systemd scripts and notification support")
+ IF(WITH_SYSTEMD STREQUAL "yes" OR WITH_SYSTEMD STREQUAL "auto")
+ IF(PKG_CONFIG_FOUND)
+--- a/configure.cmake
++++ b/configure.cmake
+@@ -139,6 +139,9 @@ IF(UNIX)
+
+ SET(CMAKE_REQUIRED_LIBRARIES
+ ${LIBM} ${LIBNSL} ${LIBBIND} ${LIBCRYPT} ${LIBSOCKET} ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT} ${LIBRT} ${LIBEXECINFO})
++ IF (HAVE_SYSTEMD)
++ LIST(APPEND CMAKE_REQUIRED_LIBRARIES -lsystemd)
++ ENDIF()
+ # Need explicit pthread for gcc -fsanitize=address
+ IF(CMAKE_USE_PTHREADS_INIT AND CMAKE_C_FLAGS MATCHES "-fsanitize=")
+ SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} pthread)
diff --git a/debian/patches/mips-connect-unaligned.patch b/debian/patches/mips-connect-unaligned.patch
new file mode 100644
index 00000000..15ff8adc
--- /dev/null
+++ b/debian/patches/mips-connect-unaligned.patch
@@ -0,0 +1,269 @@
+Forwarded: https://github.com/MariaDB/server/pull/1716
+From: Debian MySQL Maintainers <pkg-mysql-maint@lists.alioth.debian.org>
+Date: Thu, 10 Aug 2017 20:40:28 +0200
+Subject: mips-connect-unaligned
+Description: Handle unaligned buffers in connect's TYPBLK class
+ On MIPS platforms (and probably others) unaligned memory access results in a
+ bus error. In the connect storage engine, block data for some data formats is
+ stored packed in memory and the TYPBLK class is used to read values from it.
+ Since TYPBLK does not have special handling for this packed memory, it can
+ quite easily result in unaligned memory accesses.
+ .
+ The simple way to fix this is to perform all accesses to the main buffer
+ through memcpy. With GCC and optimizations turned on, this call to memcpy is
+ completely optimized away on architectures where unaligned accesses are ok
+ (like x86).
+Author: James Cowgill <jcowgill@debian.org>
+---
+ storage/connect/valblk.cpp | 41 ++++++++++++++++++-------------------
+ storage/connect/valblk.h | 51 +++++++++++++++++++++++++++++-----------------
+ 2 files changed, 52 insertions(+), 40 deletions(-)
+
+--- a/storage/connect/valblk.cpp
++++ b/storage/connect/valblk.cpp
+@@ -268,14 +268,14 @@ bool TYPBLK<TYPE>::Init(PGLOBAL g, bool
+ template <class TYPE>
+ char *TYPBLK<TYPE>::GetCharString(char *p, int n)
+ {
+- sprintf(p, Fmt, Typp[n]);
++ sprintf(p, Fmt, UnalignedRead(n));
+ return p;
+ } // end of GetCharString
+
+ template <>
+ char *TYPBLK<double>::GetCharString(char *p, int n)
+ {
+- sprintf(p, Fmt, Prec, Typp[n]);
++ sprintf(p, Fmt, Prec, UnalignedRead(n));
+ return p;
+ } // end of GetCharString
+
+@@ -291,7 +291,7 @@ void TYPBLK<TYPE>::SetValue(PVAL valp, i
+ ChkTyp(valp);
+
+ if (!(b = valp->IsNull()))
+- Typp[n] = GetTypedValue(valp);
++ UnalignedWrite(n, GetTypedValue(valp));
+ else
+ Reset(n);
+
+@@ -353,9 +353,9 @@ void TYPBLK<TYPE>::SetValue(PCSZ p, int
+ ulonglong val = CharToNumber(p, strlen(p), maxval, Unsigned, &minus);
+
+ if (minus && val < maxval)
+- Typp[n] = (TYPE)(-(signed)val);
++ UnalignedWrite(n, (TYPE)(-(signed)val));
+ else
+- Typp[n] = (TYPE)val;
++ UnalignedWrite(n, (TYPE)val);
+
+ SetNull(n, false);
+ } // end of SetValue
+@@ -398,7 +398,7 @@ void TYPBLK<double>::SetValue(PCSZ p, in
+ throw Type;
+ } // endif Check
+
+- Typp[n] = atof(p);
++ UnalignedWrite(n, atof(p));
+ SetNull(n, false);
+ } // end of SetValue
+
+@@ -430,7 +430,7 @@ void TYPBLK<TYPE>::SetValue(PVBLK pv, in
+ ChkTyp(pv);
+
+ if (!(b = pv->IsNull(n2) && Nullable))
+- Typp[n1] = GetTypedValue(pv, n2);
++ UnalignedWrite(n1, GetTypedValue(pv, n2));
+ else
+ Reset(n1);
+
+@@ -481,10 +481,10 @@ void TYPBLK<TYPE>::SetMin(PVAL valp, int
+ {
+ CheckParms(valp, n)
+ TYPE tval = GetTypedValue(valp);
+- TYPE& tmin = Typp[n];
++ TYPE tmin = UnalignedRead(n);
+
+ if (tval < tmin)
+- tmin = tval;
++ UnalignedWrite(n, tval);
+
+ } // end of SetMin
+
+@@ -496,10 +496,10 @@ void TYPBLK<TYPE>::SetMax(PVAL valp, int
+ {
+ CheckParms(valp, n)
+ TYPE tval = GetTypedValue(valp);
+- TYPE& tmin = Typp[n];
++ TYPE tmin = UnalignedRead(n);
+
+ if (tval > tmin)
+- tmin = tval;
++ UnalignedWrite(n, tval);
+
+ } // end of SetMax
+
+@@ -513,8 +513,7 @@ void TYPBLK<TYPE>::SetValues(PVBLK pv, i
+ CheckType(pv)
+ TYPE *lp = ((TYPBLK*)pv)->Typp;
+
+- for (int i = k; i < n; i++) // TODO
+- Typp[i] = lp[i];
++ memcpy(Typp + k, lp + k, sizeof(TYPE) * n);
+
+ } // end of SetValues
+ #endif // 0
+@@ -525,7 +524,7 @@ void TYPBLK<TYPE>::SetValues(PVBLK pv, i
+ template <class TYPE>
+ void TYPBLK<TYPE>::Move(int i, int j)
+ {
+- Typp[j] = Typp[i];
++ UnalignedWrite(j, UnalignedRead(i));
+ MoveNull(i, j);
+ } // end of Move
+
+@@ -539,7 +538,7 @@ int TYPBLK<TYPE>::CompVal(PVAL vp, int n
+ ChkIndx(n);
+ ChkTyp(vp);
+ #endif // _DEBUG
+- TYPE mlv = Typp[n];
++ TYPE mlv = UnalignedRead(n);
+ TYPE vlv = GetTypedValue(vp);
+
+ return (vlv > mlv) ? 1 : (vlv < mlv) ? (-1) : 0;
+@@ -551,8 +550,8 @@ int TYPBLK<TYPE>::CompVal(PVAL vp, int n
+ template <class TYPE>
+ int TYPBLK<TYPE>::CompVal(int i1, int i2)
+ {
+- TYPE lv1 = Typp[i1];
+- TYPE lv2 = Typp[i2];
++ TYPE lv1 = UnalignedRead(i1);
++ TYPE lv2 = UnalignedRead(i2);
+
+ return (lv1 > lv2) ? 1 : (lv1 < lv2) ? (-1) : 0;
+ } // end of CompVal
+@@ -589,7 +588,7 @@ int TYPBLK<TYPE>::Find(PVAL vp)
+ TYPE n = GetTypedValue(vp);
+
+ for (i = 0; i < Nval; i++)
+- if (n == Typp[i])
++ if (n == UnalignedRead(i))
+ break;
+
+ return (i < Nval) ? i : (-1);
+@@ -605,7 +604,7 @@ int TYPBLK<TYPE>::GetMaxLength(void)
+ int i, n, m;
+
+ for (i = n = 0; i < Nval; i++) {
+- m = sprintf(buf, Fmt, Typp[i]);
++ m = sprintf(buf, Fmt, UnalignedRead(i));
+ n = MY_MAX(n, m);
+ } // endfor i
+
+@@ -1335,7 +1334,7 @@ char *DATBLK::GetCharString(char *p, int
+ char *vp;
+
+ if (Dvalp) {
+- Dvalp->SetValue(Typp[n]);
++ Dvalp->SetValue(UnalignedRead(n));
+ vp = Dvalp->GetCharString(p);
+ } else
+ vp = TYPBLK<int>::GetCharString(p, n);
+@@ -1351,7 +1350,7 @@ void DATBLK::SetValue(PCSZ p, int n)
+ if (Dvalp) {
+ // Decode the string according to format
+ Dvalp->SetValue_psz(p);
+- Typp[n] = Dvalp->GetIntValue();
++ UnalignedWrite(n, Dvalp->GetIntValue());
+ } else
+ TYPBLK<int>::SetValue(p, n);
+
+--- a/storage/connect/valblk.h
++++ b/storage/connect/valblk.h
+@@ -139,6 +139,7 @@ class VALBLK : public BLOCK {
+ int Prec; // Precision of float values
+ }; // end of class VALBLK
+
++
+ /***********************************************************************/
+ /* Class TYPBLK: represents a block of typed values. */
+ /***********************************************************************/
+@@ -151,40 +152,41 @@ class TYPBLK : public VALBLK {
+ // Implementation
+ virtual bool Init(PGLOBAL g, bool check);
+ virtual int GetVlen(void) {return sizeof(TYPE);}
+- virtual char GetTinyValue(int n) {return (char)Typp[n];}
+- virtual uchar GetUTinyValue(int n) {return (uchar)Typp[n];}
+- virtual short GetShortValue(int n) {return (short)Typp[n];}
+- virtual ushort GetUShortValue(int n) {return (ushort)Typp[n];}
+- virtual int GetIntValue(int n) {return (int)Typp[n];}
+- virtual uint GetUIntValue(int n) {return (uint)Typp[n];}
+- virtual longlong GetBigintValue(int n) {return (longlong)Typp[n];}
+- virtual ulonglong GetUBigintValue(int n) {return (ulonglong)Typp[n];}
+- virtual double GetFloatValue(int n) {return (double)Typp[n];}
++
++ virtual char GetTinyValue(int n) {return (char)UnalignedRead(n);}
++ virtual uchar GetUTinyValue(int n) {return (uchar)UnalignedRead(n);}
++ virtual short GetShortValue(int n) {return (short)UnalignedRead(n);}
++ virtual ushort GetUShortValue(int n) {return (ushort)UnalignedRead(n);}
++ virtual int GetIntValue(int n) {return (int)UnalignedRead(n);}
++ virtual uint GetUIntValue(int n) {return (uint)UnalignedRead(n);}
++ virtual longlong GetBigintValue(int n) {return (longlong)UnalignedRead(n);}
++ virtual ulonglong GetUBigintValue(int n) {return (ulonglong)UnalignedRead(n);}
++ virtual double GetFloatValue(int n) {return (double)UnalignedRead(n);}
+ virtual char *GetCharString(char *p, int n);
+- virtual void Reset(int n) {Typp[n] = 0;}
++ virtual void Reset(int n) {UnalignedWrite(n, 0);}
+
+ // Methods
+ using VALBLK::SetValue;
+ virtual void SetValue(PCSZ sp, int n);
+ virtual void SetValue(const char *sp, uint len, int n);
+ virtual void SetValue(short sval, int n)
+- {Typp[n] = (TYPE)sval; SetNull(n, false);}
++ {UnalignedWrite(n, (TYPE)sval); SetNull(n, false);}
+ virtual void SetValue(ushort sval, int n)
+- {Typp[n] = (TYPE)sval; SetNull(n, false);}
++ {UnalignedWrite(n, (TYPE)sval); SetNull(n, false);}
+ virtual void SetValue(int lval, int n)
+- {Typp[n] = (TYPE)lval; SetNull(n, false);}
++ {UnalignedWrite(n, (TYPE)lval); SetNull(n, false);}
+ virtual void SetValue(uint lval, int n)
+- {Typp[n] = (TYPE)lval; SetNull(n, false);}
++ {UnalignedWrite(n, (TYPE)lval); SetNull(n, false);}
+ virtual void SetValue(longlong lval, int n)
+- {Typp[n] = (TYPE)lval; SetNull(n, false);}
++ {UnalignedWrite(n, (TYPE)lval); SetNull(n, false);}
+ virtual void SetValue(ulonglong lval, int n)
+- {Typp[n] = (TYPE)lval; SetNull(n, false);}
++ {UnalignedWrite(n, (TYPE)lval); SetNull(n, false);}
+ virtual void SetValue(double fval, int n)
+- {Typp[n] = (TYPE)fval; SetNull(n, false);}
++ {UnalignedWrite(n, (TYPE)fval); SetNull(n, false);}
+ virtual void SetValue(char cval, int n)
+- {Typp[n] = (TYPE)cval; SetNull(n, false);}
++ {UnalignedWrite(n, (TYPE)cval); SetNull(n, false);}
+ virtual void SetValue(uchar cval, int n)
+- {Typp[n] = (TYPE)cval; SetNull(n, false);}
++ {UnalignedWrite(n, (TYPE)cval); SetNull(n, false);}
+ virtual void SetValue(PVAL valp, int n);
+ virtual void SetValue(PVBLK pv, int n1, int n2);
+ virtual void SetMin(PVAL valp, int n);
+@@ -206,6 +208,17 @@ class TYPBLK : public VALBLK {
+ // Members
+ TYPE* const &Typp;
+ const char *Fmt;
++
++ // Unaligned access
++ TYPE UnalignedRead(int n) const {
++ TYPE result;
++ memcpy(&result, Typp + n, sizeof(TYPE));
++ return result;
++ }
++
++ void UnalignedWrite(int n, TYPE value) {
++ memcpy(Typp + n, &value, sizeof(TYPE));
++ }
+ }; // end of class TYPBLK
+
+ /***********************************************************************/
diff --git a/debian/patches/mips-groonga-atomic.patch b/debian/patches/mips-groonga-atomic.patch
new file mode 100644
index 00000000..765ce47b
--- /dev/null
+++ b/debian/patches/mips-groonga-atomic.patch
@@ -0,0 +1,34 @@
+Forwarded: https://github.com/MariaDB/server/pull/1716
+From: Debian MySQL Maintainers <pkg-mysql-maint@lists.alioth.debian.org>
+Date: Thu, 10 Aug 2017 20:40:28 +0200
+Subject: mips-groonga-atomic
+ MIPS (and possibly other) platforms require linking against libatomic to
+ support 64-bit atomic integers. Groonga was failing to do so and all related
+ tests were failing with an atomics relocation error on MIPS.
+Author: James Cowgill <jcowgill@debian.org>
+---
+ storage/mroonga/vendor/groonga/CMakeLists.txt | 2 ++
+ storage/mroonga/vendor/groonga/lib/CMakeLists.txt | 1 +
+ 2 files changed, 3 insertions(+)
+
+--- a/storage/mroonga/vendor/groonga/CMakeLists.txt
++++ b/storage/mroonga/vendor/groonga/CMakeLists.txt
+@@ -237,6 +237,8 @@ endmacro()
+ include(build/ac_macros/check_headers.m4)
+ include(build/ac_macros/check_functions.m4)
+
++ac_check_lib(atomic __atomic_store_8)
++
+ ac_check_symbols(fpclassify math.h)
+ ac_check_lib(m fpclassify)
+
+--- a/storage/mroonga/vendor/groonga/lib/CMakeLists.txt
++++ b/storage/mroonga/vendor/groonga/lib/CMakeLists.txt
+@@ -90,6 +90,7 @@ endif()
+ set_target_properties(libgroonga PROPERTIES OUTPUT_NAME "groonga")
+
+ set(GRN_ALL_LIBRARIES
++ ${ATOMIC_LIBS}
+ ${EXECINFO_LIBS}
+ ${RT_LIBS}
+ ${PTHREAD_LIBS}
diff --git a/debian/patches/mroonga-path-reproducible-build.patch b/debian/patches/mroonga-path-reproducible-build.patch
new file mode 100644
index 00000000..963ac466
--- /dev/null
+++ b/debian/patches/mroonga-path-reproducible-build.patch
@@ -0,0 +1,15 @@
+Forwarded: https://github.com/mroonga/mroonga/issues/298
+Subject: Mroonga plugin build in MariaDB is not reproducible (Closes: #976984)
+ This did not make Mroonga reproducible, so we might as well remove this later on.
+
+--- a/storage/mroonga/vendor/groonga/configure.ac
++++ b/storage/mroonga/vendor/groonga/configure.ac
+@@ -1505,7 +1505,7 @@ GRN_DEFS="$GRN_DEFS -DGRN_DEFAULT_RELATI
+ AC_SUBST(GRN_DEFS)
+ CFLAGS="$CFLAGS $OPT_CFLAGS "
+ LIBS="$LIBS $WINDOWS_LIBS"
+-AC_DEFINE_UNQUOTED(CONFIGURE_OPTIONS, "$ac_configure_args", "specified configure options")
++AC_DEFINE_UNQUOTED(CONFIGURE_OPTIONS, "$(echo $ac_configure_args | sed -e "s@$(pwd)@<builddir>@g")", "specified configure options")
+
+ # For groonga.org
+ AC_ARG_WITH(groonga-org-path,
diff --git a/debian/patches/rocksdb-kfreebsd.patch b/debian/patches/rocksdb-kfreebsd.patch
new file mode 100644
index 00000000..8a6e1d91
--- /dev/null
+++ b/debian/patches/rocksdb-kfreebsd.patch
@@ -0,0 +1,148 @@
+Forwarded: https://github.com/facebook/rocksdb/pull/6992
+# Merged in RocksDB 6.13.fb, but not updated into MariaDB 10.5
+Forwarded: https://jira.mariadb.org/browse/MDEV-19251
+Description:
+ Upstream has merged this but we still need to wait for it to be included
+ in a RocksDB release and imported into MariaDB and then into Debian.
+--- a/storage/rocksdb/build_rocksdb.cmake
++++ b/storage/rocksdb/build_rocksdb.cmake
+@@ -90,6 +90,8 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Linux"
+ add_definitions(-DOS_LINUX)
+ elseif(CMAKE_SYSTEM_NAME MATCHES "SunOS")
+ add_definitions(-DOS_SOLARIS)
++elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD")
++ add_definitions(-DOS_GNU_KFREEBSD)
+ elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+ add_definitions(-DOS_FREEBSD)
+ elseif(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
+--- a/storage/rocksdb/rocksdb/CMakeLists.txt
++++ b/storage/rocksdb/rocksdb/CMakeLists.txt
+@@ -91,7 +91,7 @@ if(MSVC)
+ option(WITH_XPRESS "build with windows built in compression" OFF)
+ include(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty.inc)
+ else()
+- if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
++ if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD" AND NOT CMAKE_SYSTEM_NAME MATCHES "kFreeBSD")
+ # FreeBSD has jemalloc as default malloc
+ # but it does not have all the jemalloc files in include/...
+ set(WITH_JEMALLOC ON)
+@@ -413,6 +413,8 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Linux"
+ add_definitions(-DOS_LINUX)
+ elseif(CMAKE_SYSTEM_NAME MATCHES "SunOS")
+ add_definitions(-DOS_SOLARIS)
++elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD")
++ add_definitions(-DOS_GNU_KFREEBSD)
+ elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+ add_definitions(-DOS_FREEBSD)
+ elseif(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
+--- a/storage/rocksdb/rocksdb/build_tools/build_detect_platform
++++ b/storage/rocksdb/rocksdb/build_tools/build_detect_platform
+@@ -190,6 +190,17 @@ EOF
+ PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lpthread"
+ # PORT_FILES=port/freebsd/freebsd_specific.cc
+ ;;
++ GNU/kFreeBSD)
++ PLATFORM=OS_GNU_KFREEBSD
++ COMMON_FLAGS="$COMMON_FLAGS -DOS_GNU_KFREEBSD"
++ if [ -z "$USE_CLANG" ]; then
++ COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp"
++ else
++ PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -latomic"
++ fi
++ PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lpthread -lrt"
++ # PORT_FILES=port/gnu_kfreebsd/gnu_kfreebsd_specific.cc
++ ;;
+ NetBSD)
+ PLATFORM=OS_NETBSD
+ COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp -D_REENTRANT -DOS_NETBSD"
+--- a/storage/rocksdb/rocksdb/env/env_posix.cc
++++ b/storage/rocksdb/rocksdb/env/env_posix.cc
+@@ -41,7 +41,7 @@
+ #include <time.h>
+ #include <algorithm>
+ // Get nano time includes
+-#if defined(OS_LINUX) || defined(OS_FREEBSD)
++#if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_GNU_KFREEBSD)
+ #elif defined(__MACH__)
+ #include <Availability.h>
+ #include <mach/clock.h>
+@@ -287,7 +287,8 @@ class PosixEnv : public CompositeEnvWrap
+ }
+
+ uint64_t NowNanos() override {
+-#if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_AIX)
++#if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_GNU_KFREEBSD) || \
++ defined(OS_AIX)
+ struct timespec ts;
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ return static_cast<uint64_t>(ts.tv_sec) * 1000000000 + ts.tv_nsec;
+@@ -307,8 +308,8 @@ class PosixEnv : public CompositeEnvWrap
+ }
+
+ uint64_t NowCPUNanos() override {
+-#if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_AIX) || \
+- (defined(__MACH__) && defined(__MAC_10_12))
++#if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_GNU_KFREEBSD) || \
++ defined(OS_AIX) || (defined(__MACH__) && defined(__MAC_10_12))
+ struct timespec ts;
+ clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts);
+ return static_cast<uint64_t>(ts.tv_sec) * 1000000000 + ts.tv_nsec;
+--- a/storage/rocksdb/rocksdb/port/stack_trace.cc
++++ b/storage/rocksdb/rocksdb/port/stack_trace.cc
+@@ -32,7 +32,7 @@ namespace port {
+
+ namespace {
+
+-#if defined(OS_LINUX) || defined(OS_FREEBSD)
++#if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_GNU_KFREEBSD)
+ const char* GetExecutableName() {
+ static char name[1024];
+
+--- a/storage/rocksdb/rdb_io_watchdog.h
++++ b/storage/rocksdb/rdb_io_watchdog.h
+@@ -56,19 +56,19 @@ class Rdb_io_watchdog {
+ int stop_timers() {
+ int ret = 0;
+
+- if (m_io_check_watchdog_timer) {
++ if (m_io_check_watchdog_timer != reinterpret_cast<timer_t>(-1)) {
+ ret = timer_delete(m_io_check_watchdog_timer);
+
+ if (!ret) {
+- m_io_check_watchdog_timer = nullptr;
++ m_io_check_watchdog_timer = reinterpret_cast<timer_t>(-1);
+ }
+ }
+
+- if (m_io_check_timer && !ret) {
++ if (m_io_check_timer != reinterpret_cast<timer_t>(-1) && !ret) {
+ ret = timer_delete(m_io_check_timer);
+
+ if (!ret) {
+- m_io_check_timer = nullptr;
++ m_io_check_timer = reinterpret_cast<timer_t>(-1);
+ }
+ }
+
+@@ -93,8 +93,8 @@ class Rdb_io_watchdog {
+
+ public:
+ explicit Rdb_io_watchdog(std::vector<std::string> &&directories)
+- : m_io_check_timer(nullptr),
+- m_io_check_watchdog_timer(nullptr),
++ : m_io_check_timer(reinterpret_cast<timer_t>(-1)),
++ m_io_check_watchdog_timer(reinterpret_cast<timer_t>(-1)),
+ m_io_in_progress(false),
+ m_dirs_to_check(std::move(directories)),
+ m_buf(nullptr) {
+--- a/storage/rocksdb/rdb_io_watchdog.cc
++++ b/storage/rocksdb/rdb_io_watchdog.cc
+@@ -111,7 +111,7 @@ void Rdb_io_watchdog::io_check_callback(
+ sql_print_warning("Deleting the watchdog I/O timer failed with %d.", errno);
+ }
+
+- m_io_check_watchdog_timer = nullptr;
++ m_io_check_watchdog_timer = reinterpret_cast<timer_t>(-1);
+
+ RDB_MUTEX_UNLOCK_CHECK(m_reset_mutex);
+ }
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 00000000..d9211475
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1,11 @@
+mips-groonga-atomic.patch
+mips-connect-unaligned.patch
+c11_atomics.patch
+0025-Change-the-default-optimization-from-O3-to-O2-in-mys.patch
+mips-compilation-failure-__bss_start-symbol-miss.patch
+rocksdb-kfreebsd.patch
+mroonga-path-reproducible-build.patch
+env-perl-usr-bin-perl.patch
+fix-spelling.patch
+1556.patch
+fix-reproducible-builds-rocksdb.patch