mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
MDEV-33750: Sync maintainer scripts etc with latest downstream 10.11.5 in Debian
Fix a large amount of minor fixes to maintainer scripts and other done downstream in the official Debian packaging. Changes include:38198d0b9e
> Limit check of running mysqld/mariadbd to system users (Closes: #1032047) > > If a random user has their own copy of mysqld/mariadbd running, the > dpkg maintainer script should not care about it.8116354d22
> Make error more helpful in case server restart fails (Related: #1033234) > > Bugs such as https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1033234 > and https://bugs.launchpad.net/ubuntu/+source/mariadb-10.6/+bug/2011293 > show that currently dpkg stopping on service stop/start does not have > a very helpful error message.8675e97202
> Complement upstream commits with more complete mysql->mariadb conversion > > The upstream commit952af4a1
missed some places where 'mysql' or > 'MySQL' can and should be converted to use 'mariadb' or 'MariaDB'.c983613300
> Fix indentation in Debian post and pre scripts > > There is several misindentation inside Debian post and pre > installation scripts. False indentation with space as indent space > should be 2 and indentation with tabs. > > Adopt upstream commit7cbb45d1
in Debian by conserving customizations > in: > - debian/mariadb-server.postinst > - debian/mariadb-server.postrm > - debian/mariadb-server.preinstd0bcab443f
> Ensure spaces are used everywhere instead of tabs for indentation0300a9157c
> Complement previous upstream commits to fix Shellcheck issues > > - Unify if/then and while/do on separate lines > - Fix indentation to be consistent > - Use "$()" instead of backticks for subshells > - Exit code cannot be -1, must be 0-255 > - Remove unused variables MYCHECK and MYCHECK_PARAMS > - Rewrite messy command-line database calls to an easier to read form > that does exactly the same > - Use 'command -v' test instead of 'which' > > With this commit, all of debian/* is Shellcheck clean. Also * Update mariadb.conf.d template to tell users where to create logdir if they are not using journald * Remove use of work 'slave' * Add minor workaround for Debian Bug #1022994 if TMPDIR is empty * Make start/stop in maintainer scripts correctly check mariadbd ownership and only start/stop processes owned by root or 'mysql' * Remove obsolete 'NO_UPDATE_BUILD_VERSION=1' as it did not affect the RocksDB build reproducibility as previously assumed * Run 'wrap-and-sort -av'
This commit is contained in:
parent
5000d1ba6e
commit
2adaf5c261
16 changed files with 215 additions and 128 deletions
11
debian/additions/debian-start
vendored
11
debian/additions/debian-start
vendored
|
@ -6,14 +6,19 @@
|
|||
# Changes to this file will be preserved when updating the Debian package.
|
||||
#
|
||||
|
||||
# shellcheck source=debian/additions/debian-start.inc.sh
|
||||
source /usr/share/mysql/debian-start.inc.sh
|
||||
|
||||
# Read default/mysql first and then default/mariadb just like the init.d file does
|
||||
if [ -f /etc/default/mysql ]; then
|
||||
if [ -f /etc/default/mysql ]
|
||||
then
|
||||
# shellcheck source=/dev/null
|
||||
. /etc/default/mysql
|
||||
fi
|
||||
|
||||
if [ -f /etc/default/mariadb ]; then
|
||||
if [ -f /etc/default/mariadb ]
|
||||
then
|
||||
# shellcheck source=/dev/null
|
||||
. /etc/default/mariadb
|
||||
fi
|
||||
|
||||
|
@ -21,9 +26,7 @@ MARIADB="/usr/bin/mariadb --defaults-file=/etc/mysql/debian.cnf"
|
|||
MYADMIN="/usr/bin/mariadb-admin --defaults-file=/etc/mysql/debian.cnf"
|
||||
# Don't run full mariadb-upgrade on every server restart, use --version-check to do it only once
|
||||
MYUPGRADE="/usr/bin/mariadb-upgrade --defaults-extra-file=/etc/mysql/debian.cnf --version-check --silent"
|
||||
MYCHECK="/usr/bin/mariadb-check --defaults-file=/etc/mysql/debian.cnf"
|
||||
MYCHECK_SUBJECT="WARNING: mariadb-check has found corrupt tables"
|
||||
MYCHECK_PARAMS="--all-databases --fast --silent"
|
||||
MYCHECK_RCPT="${MYCHECK_RCPT:-root}"
|
||||
|
||||
## Checking for corrupt, not cleanly closed (only for MyISAM and Aria engines) and upgrade needing tables.
|
||||
|
|
41
debian/additions/debian-start.inc.sh
vendored
41
debian/additions/debian-start.inc.sh
vendored
|
@ -21,17 +21,28 @@ function check_for_crashed_tables() {
|
|||
# spaces in the thing to be looped over.
|
||||
|
||||
# If a crashed table is encountered, the "mariadb" command will return with a status different from 0
|
||||
#
|
||||
# The first query will generate lines like.
|
||||
# select count(*) into @discard from 'mysql'.'db'
|
||||
# The second line will load all tables without printing any actual results,
|
||||
# but may show warnings and definitely is expected to have some error and
|
||||
# exit code if crashed tables are encountered.
|
||||
#
|
||||
# Note that inside single quotes must be quoted with '\'' (to be outside of single quotes).
|
||||
set +e
|
||||
|
||||
LC_ALL=C $MARIADB --skip-column-names --batch -e '
|
||||
select concat('\''select count(*) into @discard from `'\'',
|
||||
TABLE_SCHEMA, '\''`.`'\'', TABLE_NAME, '\''`'\'')
|
||||
from information_schema.TABLES where TABLE_SCHEMA<>'\''INFORMATION_SCHEMA'\'' and TABLE_SCHEMA<>'\''PERFORMANCE_SCHEMA'\'' and ( ENGINE='\''MyISAM'\'' or ENGINE='\''Aria'\'' )' | \
|
||||
xargs -i ${MARIADB} --skip-column-names --silent --batch \
|
||||
--force -e "{}" &>"${tempfile}"
|
||||
# The $MARIADB is intentionally used to expand into a command and arguments
|
||||
# shellcheck disable=SC2086
|
||||
LC_ALL=C echo '
|
||||
SELECT CONCAT("select count(*) into @discard from '\''", TABLE_SCHEMA, "'\''.'\''", TABLE_NAME, "'\''")
|
||||
FROM information_schema.TABLES WHERE TABLE_SCHEMA<>"INFORMATION_SCHEMA" AND TABLE_SCHEMA<>"PERFORMANCE_SCHEMA"
|
||||
AND (ENGINE="MyISAM" OR ENGINE="Aria")
|
||||
' | \
|
||||
$MARIADB --skip-column-names --batch | \
|
||||
xargs -i $MARIADB --skip-column-names --silent --batch --force -e "{}" &> "${tempfile}"
|
||||
set -e
|
||||
|
||||
if [ -s "$tempfile" ]; then
|
||||
if [ -s "$tempfile" ]
|
||||
then
|
||||
(
|
||||
/bin/echo -e "\n" \
|
||||
"Improperly closed tables are also reported if clients are accessing\n" \
|
||||
|
@ -39,8 +50,9 @@ function check_for_crashed_tables() {
|
|||
$MYADMIN processlist status
|
||||
) >> "${tempfile}"
|
||||
# Check for presence as a dependency on mailx would require an MTA.
|
||||
if [ -x /usr/bin/mailx ]; then
|
||||
mailx -e -s"$MYCHECK_SUBJECT" $MYCHECK_RCPT < "$tempfile"
|
||||
if [ -x /usr/bin/mailx ]
|
||||
then
|
||||
mailx -e -s"$MYCHECK_SUBJECT" "$MYCHECK_RCPT" < "$tempfile"
|
||||
fi
|
||||
(echo "$MYCHECK_SUBJECT"; cat "${tempfile}") | logger -p daemon.warn -i -t"$0"
|
||||
fi
|
||||
|
@ -54,13 +66,13 @@ function upgrade_system_tables_if_necessary() {
|
|||
set -e
|
||||
set -u
|
||||
|
||||
logger -p daemon.info -i -t"$0" "Upgrading MySQL tables if necessary."
|
||||
logger -p daemon.info -i -t"$0" "Upgrading MariaDB tables if necessary."
|
||||
|
||||
# Filter all "duplicate column", "duplicate key" and "unknown column"
|
||||
# errors as the script is designed to be idempotent.
|
||||
LC_ALL=C $MYUPGRADE \
|
||||
2>&1 \
|
||||
| egrep -v '^(1|@had|ERROR (1051|1054|1060|1061|1146|1347|1348))' \
|
||||
| grep -E -v '^(1|@had|ERROR (1051|1054|1060|1061|1146|1347|1348))' \
|
||||
| logger -p daemon.warn -i -t"$0"
|
||||
}
|
||||
|
||||
|
@ -72,8 +84,9 @@ function check_root_accounts() {
|
|||
|
||||
logger -p daemon.info -i -t"$0" "Checking for insecure root accounts."
|
||||
|
||||
ret=$( echo "SELECT count(*) FROM mysql.user WHERE user='root' and password='' and plugin in ('', 'mysql_native_password', 'mysql_old_password');" | $MARIADB --skip-column-names )
|
||||
if [ "$ret" -ne "0" ]; then
|
||||
ret=$(echo "SELECT count(*) FROM mysql.user WHERE user='root' and password='' and password_expired='N' and plugin in ('', 'mysql_native_password', 'mysql_old_password');" | $MARIADB --skip-column-names)
|
||||
if [ "$ret" -ne "0" ]
|
||||
then
|
||||
logger -p daemon.warn -i -t"$0" "WARNING: mysql.user contains $ret root accounts without password!"
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -44,6 +44,11 @@ bind-address = 127.0.0.1
|
|||
# * Logging and Replication
|
||||
#
|
||||
|
||||
# Note: The configured log file or its directory need to be created
|
||||
# and be writable by the mysql user, e.g.:
|
||||
# $ sudo mkdir -m 2750 /var/log/mysql
|
||||
# $ sudo chown mysql /var/log/mysql
|
||||
|
||||
# Both location gets rotated by the cronjob.
|
||||
# Be aware that this log type is a performance killer.
|
||||
# Recommend only changing this at runtime for short testing periods if needed!
|
||||
|
@ -63,8 +68,8 @@ bind-address = 127.0.0.1
|
|||
#log_slow_min_examined_row_limit = 1000
|
||||
|
||||
# The following can be used as easy to replay backup logs or for replication.
|
||||
# note: if you are setting up a replication slave, see README.Debian about
|
||||
# other settings you may need to change.
|
||||
# note: if you are setting up a replica, see README.Debian about other
|
||||
# settings you may need to change.
|
||||
#server-id = 1
|
||||
#log_bin = /var/log/mysql/mysql-bin.log
|
||||
expire_logs_days = 10
|
||||
|
|
2
debian/autobake-deb.sh
vendored
2
debian/autobake-deb.sh
vendored
|
@ -183,7 +183,7 @@ fi
|
|||
|
||||
# Use eatmydata is available to build faster with less I/O, skipping fsync()
|
||||
# during the entire build process (safe because a build can always be restarted)
|
||||
if which eatmydata > /dev/null
|
||||
if command -v eatmydata > /dev/null
|
||||
then
|
||||
BUILDPACKAGE_DPKGCMD+=("eatmydata")
|
||||
fi
|
||||
|
|
1
debian/copyright
vendored
1
debian/copyright
vendored
|
@ -1,4 +1,3 @@
|
|||
|
||||
== MariaDB ==
|
||||
|
||||
The Debian package of MySQL was first debianzed on 1997-04-12 by Christian
|
||||
|
|
2
debian/mariadb-plugin-mroonga.postinst
vendored
2
debian/mariadb-plugin-mroonga.postinst
vendored
|
@ -3,7 +3,7 @@
|
|||
set -e
|
||||
|
||||
# Install Mroonga
|
||||
mysql --defaults-file=/etc/mysql/debian.cnf < /usr/share/mysql/mroonga/install.sql || true
|
||||
mariadb --defaults-file=/etc/mysql/debian.cnf < /usr/share/mysql/mroonga/install.sql || true
|
||||
# Always exit with success instead of leaving dpkg in a broken state
|
||||
|
||||
|
||||
|
|
2
debian/mariadb-plugin-mroonga.prerm
vendored
2
debian/mariadb-plugin-mroonga.prerm
vendored
|
@ -3,7 +3,7 @@
|
|||
set -e
|
||||
|
||||
# Uninstall Mroonga
|
||||
mysql --defaults-file=/etc/mysql/debian.cnf < /usr/share/mysql/mroonga/uninstall.sql || true
|
||||
mariadb --defaults-file=/etc/mysql/debian.cnf < /usr/share/mysql/mroonga/uninstall.sql || true
|
||||
# Always exit with success instead of leaving dpkg in a broken state
|
||||
|
||||
|
||||
|
|
2
debian/mariadb-server-core.install
vendored
2
debian/mariadb-server-core.install
vendored
|
@ -24,8 +24,8 @@ usr/share/mysql/english
|
|||
usr/share/mysql/estonian
|
||||
usr/share/mysql/fill_help_tables.sql
|
||||
usr/share/mysql/french
|
||||
usr/share/mysql/german
|
||||
usr/share/mysql/georgian
|
||||
usr/share/mysql/german
|
||||
usr/share/mysql/greek
|
||||
usr/share/mysql/hindi
|
||||
usr/share/mysql/hungarian
|
||||
|
|
12
debian/mariadb-server.config
vendored
12
debian/mariadb-server.config
vendored
|
@ -2,13 +2,19 @@
|
|||
|
||||
set -e
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
. /usr/share/debconf/confmodule
|
||||
|
||||
if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi
|
||||
${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
|
||||
if [ -n "$DEBIAN_SCRIPT_DEBUG" ]
|
||||
then
|
||||
set -v -x; DEBIAN_SCRIPT_TRACE=1
|
||||
fi
|
||||
|
||||
${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2}
|
||||
|
||||
# Beware that there are two ypwhich one of them needs the 2>/dev/null!
|
||||
if test -n "`which ypwhich 2>/dev/null`" && ypwhich >/dev/null 2>&1; then
|
||||
if test -n "$(command -v ypwhich 2>/dev/null)" && ypwhich > /dev/null 2>&1
|
||||
then
|
||||
db_input high mariadb-server/nis_warning || true
|
||||
db_go
|
||||
fi
|
||||
|
|
96
debian/mariadb-server.mariadb.init
vendored
96
debian/mariadb-server.mariadb.init
vendored
|
@ -8,7 +8,7 @@
|
|||
# Should-Stop: $network $named $time
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Start and stop the mysql database server daemon
|
||||
# Short-Description: Start and stop the MariaDB database server daemon
|
||||
# Description: Controls the main MariaDB database server daemon "mariadbd"
|
||||
# and its wrapper script "mysqld_safe".
|
||||
### END INIT INFO
|
||||
|
@ -19,9 +19,10 @@ ${DEBIAN_SCRIPT_DEBUG:+ set -v -x}
|
|||
|
||||
test -x /usr/sbin/mariadbd || exit 0
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
SELF=$(cd "$(dirname $0)"; pwd -P)/$(basename $0)
|
||||
SELF="$(cd "$(dirname "$0")"; pwd -P)/$(basename "$0")"
|
||||
|
||||
if [ -f /usr/bin/mariadb-admin ]
|
||||
then
|
||||
|
@ -31,26 +32,30 @@ then
|
|||
MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"
|
||||
else
|
||||
log_failure_msg "Command mariadb-admin/mysqladmin not found! This SysV init script depends on it."
|
||||
exit -1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -x /usr/bin/mariadbd-safe ]
|
||||
then
|
||||
log_failure_msg "/usr/bin/mariadbd-safe not found or executable! This SysV init script depends on it."
|
||||
exit -1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# priority can be overridden and "-s" adds output to stderr
|
||||
ERR_LOGGER="logger -p daemon.err -t /etc/init.d/mariadb -i"
|
||||
|
||||
if [ -f /etc/default/mysql ]; then
|
||||
if [ -f /etc/default/mysql ]
|
||||
then
|
||||
# shellcheck source=/dev/null
|
||||
. /etc/default/mysql
|
||||
fi
|
||||
|
||||
# Also source default/mariadb in case the installation was upgraded from
|
||||
# packages originally installed from MariaDB.org repositories, which have
|
||||
# had support for reading /etc/default/mariadb since March 2016.
|
||||
if [ -f /etc/default/mariadb ]; then
|
||||
if [ -f /etc/default/mariadb ]
|
||||
then
|
||||
# shellcheck source=/dev/null
|
||||
. /etc/default/mariadb
|
||||
fi
|
||||
|
||||
|
@ -77,13 +82,14 @@ mariadbd_get_param() {
|
|||
## Do some sanity checks before even trying to start mariadbd.
|
||||
sanity_checks() {
|
||||
# check for config file
|
||||
if [ ! -r /etc/mysql/my.cnf ]; then
|
||||
if [ ! -r /etc/mysql/my.cnf ]
|
||||
then
|
||||
log_warning_msg "$0: WARNING: /etc/mysql/my.cnf cannot be read. See README.Debian.gz"
|
||||
echo "WARNING: /etc/mysql/my.cnf cannot be read. See README.Debian.gz" | $ERR_LOGGER
|
||||
fi
|
||||
|
||||
# check for diskspace shortage
|
||||
datadir=`mariadbd_get_param datadir`
|
||||
datadir="$(mariadbd_get_param datadir)"
|
||||
|
||||
# If datadir location is not changed int configuration
|
||||
# then it's not printed with /usr/sbin/mariadbd --print-defaults
|
||||
|
@ -105,7 +111,8 @@ sanity_checks() {
|
|||
# As preset blocksize of GNU df is 1024 then available bytes is $df_available_blocks * 1024
|
||||
# 4096 blocks is then lower than 4 MB
|
||||
df_available_blocks="$(LC_ALL=C BLOCKSIZE='' df --output=avail "$datadir" | tail -n 1)"
|
||||
if [ "$df_available_blocks" -lt "4096" ]; then
|
||||
if [ "$df_available_blocks" -lt "4096" ]
|
||||
then
|
||||
log_failure_msg "$0: ERROR: The partition with $datadir is too full!"
|
||||
echo "ERROR: The partition with $datadir is too full!" | $ERR_LOGGER
|
||||
exit 1
|
||||
|
@ -119,17 +126,30 @@ sanity_checks() {
|
|||
#
|
||||
# Usage: boolean mariadbd_status [check_alive|check_dead] [warn|nowarn]
|
||||
mariadbd_status () {
|
||||
ping_output=`$MYADMIN ping 2>&1`; ping_alive=$(( ! $? ))
|
||||
ping_output="$($MYADMIN ping 2>&1)"
|
||||
# The whole mariadbd_status function should be rewritten in clean shell script,
|
||||
# so ignore minor Shellcheck nag for now as fixing it would be half of the
|
||||
# rewrite
|
||||
# shellcheck disable=SC2181
|
||||
ping_alive="$(( ! $? ))"
|
||||
|
||||
ps_alive=0
|
||||
pidfile=`mariadbd_get_param pid-file`
|
||||
if [ -f "$pidfile" ] && ps `cat $pidfile` >/dev/null 2>&1; then ps_alive=1; fi
|
||||
pidfile="$(mariadbd_get_param pid-file)"
|
||||
if [ -f "$pidfile" ] && ps "$(cat "$pidfile")" >/dev/null 2>&1
|
||||
then
|
||||
ps_alive=1
|
||||
fi
|
||||
|
||||
# Using '-a' is unstandard, but it works and might be needed for the grouping
|
||||
# of the if-else, so keep it and just ignore in Shellcheck
|
||||
# shellcheck disable=SC2166
|
||||
if [ "$1" = "check_alive" -a $ping_alive = 1 ] ||
|
||||
[ "$1" = "check_dead" -a $ping_alive = 0 -a $ps_alive = 0 ]; then
|
||||
[ "$1" = "check_dead" -a $ping_alive = 0 -a $ps_alive = 0 ]
|
||||
then
|
||||
return 0 # EXIT_SUCCESS
|
||||
else
|
||||
if [ "$2" = "warn" ]; then
|
||||
if [ "$2" = "warn" ]
|
||||
then
|
||||
echo -e "$ps_alive processes alive and '$MYADMIN ping' resulted in\n$ping_output\n" | $ERR_LOGGER -p daemon.debug
|
||||
fi
|
||||
return 1 # EXIT_FAILURE
|
||||
|
@ -146,7 +166,8 @@ case "${1:-''}" in
|
|||
sanity_checks;
|
||||
# Start daemon
|
||||
log_daemon_msg "Starting MariaDB database server" "mariadbd"
|
||||
if mariadbd_status check_alive nowarn; then
|
||||
if mariadbd_status check_alive nowarn
|
||||
then
|
||||
log_progress_msg "already running"
|
||||
log_end_msg 0
|
||||
else
|
||||
|
@ -156,16 +177,22 @@ case "${1:-''}" in
|
|||
# Start MariaDB!
|
||||
/usr/bin/mariadbd-safe "${@:2}" 2>&1 >/dev/null | $ERR_LOGGER &
|
||||
|
||||
for i in $(seq 1 "${MYSQLD_STARTUP_TIMEOUT:-30}"); do
|
||||
for _ in $(seq 1 "${MYSQLD_STARTUP_TIMEOUT:-30}")
|
||||
do
|
||||
sleep 1
|
||||
if mariadbd_status check_alive nowarn ; then break; fi
|
||||
if mariadbd_status check_alive nowarn
|
||||
then
|
||||
break
|
||||
fi
|
||||
log_progress_msg "."
|
||||
done
|
||||
if mariadbd_status check_alive warn; then
|
||||
if mariadbd_status check_alive warn
|
||||
then
|
||||
log_end_msg 0
|
||||
# Now start mysqlcheck or whatever the admin wants.
|
||||
output=$(/etc/mysql/debian-start)
|
||||
if [ -n "$output" ]; then
|
||||
if [ -n "$output" ]
|
||||
then
|
||||
log_action_msg "$output"
|
||||
fi
|
||||
else
|
||||
|
@ -181,28 +208,40 @@ case "${1:-''}" in
|
|||
# to specify it explicit as e.g. sudo environments points to the normal
|
||||
# users home and not /root)
|
||||
log_daemon_msg "Stopping MariaDB database server" "mariadbd"
|
||||
if ! mariadbd_status check_dead nowarn; then
|
||||
if ! mariadbd_status check_dead nowarn
|
||||
then
|
||||
set +e
|
||||
shutdown_out=`$MYADMIN shutdown 2>&1`; r=$?
|
||||
shutdown_out="$($MYADMIN shutdown 2>&1)"
|
||||
r=$?
|
||||
set -e
|
||||
if [ "$r" -ne 0 ]; then
|
||||
if [ "$r" -ne 0 ]
|
||||
then
|
||||
log_end_msg 1
|
||||
[ "$VERBOSE" != "no" ] && log_failure_msg "Error: $shutdown_out"
|
||||
log_daemon_msg "Killing MariaDB database server by signal" "mariadbd"
|
||||
killall -15 mariadbd
|
||||
server_down=
|
||||
for i in `seq 1 600`; do
|
||||
for _ in {1..600}
|
||||
do
|
||||
sleep 1
|
||||
if mariadbd_status check_dead nowarn; then server_down=1; break; fi
|
||||
if mariadbd_status check_dead nowarn
|
||||
then
|
||||
server_down=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test -z "$server_down"; then killall -9 mariadbd; fi
|
||||
if test -z "$server_down"
|
||||
then
|
||||
killall -9 mariadbd
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! mariadbd_status check_dead warn; then
|
||||
if ! mariadbd_status check_dead warn
|
||||
then
|
||||
log_end_msg 1
|
||||
log_failure_msg "Please stop MariaDB manually and read /usr/share/doc/mariadb-server/README.Debian.gz!"
|
||||
exit -1
|
||||
exit 1
|
||||
else
|
||||
log_end_msg 0
|
||||
fi
|
||||
|
@ -221,7 +260,8 @@ case "${1:-''}" in
|
|||
;;
|
||||
|
||||
'status')
|
||||
if mariadbd_status check_alive nowarn; then
|
||||
if mariadbd_status check_alive nowarn
|
||||
then
|
||||
log_action_msg "$($MYADMIN version)"
|
||||
else
|
||||
log_action_msg "MariaDB is stopped."
|
||||
|
|
26
debian/mariadb-server.postinst
vendored
26
debian/mariadb-server.postinst
vendored
|
@ -10,7 +10,7 @@ then
|
|||
DEBIAN_SCRIPT_TRACE=1
|
||||
fi
|
||||
|
||||
${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
|
||||
${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2}
|
||||
|
||||
export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin
|
||||
|
||||
|
@ -112,7 +112,7 @@ EOF
|
|||
fi
|
||||
rmdir $mysql_upgradedir 2>/dev/null || true
|
||||
|
||||
done
|
||||
done # end 'for dir' loop
|
||||
|
||||
# Upgrading from mysql.com needs might have the root user as auth_socket.
|
||||
# auto.cnf is a sign of a mysql install, that doesn't exist in mariadb.
|
||||
|
@ -127,7 +127,7 @@ EOF
|
|||
! lsof -nt "$mysql_datadir"/mysql/user.MYD > /dev/null &&
|
||||
[ ! -f "$mysql_datadir/undo_001" ]
|
||||
then
|
||||
echo "UPDATE mysql.user SET plugin='unix_socket' WHERE plugin='auth_socket';" |
|
||||
echo "UPDATE mysql.user SET plugin='unix_socket' WHERE plugin='auth_socket';" | \
|
||||
mariadbd --skip-innodb --key_buffer_size=0 --default-storage-engine=MyISAM --bootstrap 2> /dev/null
|
||||
fi
|
||||
|
||||
|
@ -183,6 +183,8 @@ EOF
|
|||
# Clean up old flags before setting new one
|
||||
rm -f $mysql_datadir/debian-*.flag
|
||||
# Flag data dir to avoid downgrades
|
||||
# @TODO: Rewrite this to use the new upstream /var/lib/mysql_upgrade_info file
|
||||
# instead of the legacy /var/lib/debian-XX.X.flag file
|
||||
touch "$mysql_datadir/debian-__MARIADB_MAJOR_VER__.flag"
|
||||
|
||||
# initiate databases. Output is not allowed by debconf :-(
|
||||
|
@ -191,9 +193,13 @@ EOF
|
|||
# handle things.
|
||||
# Debian: beware of the bashisms...
|
||||
# Debian: can safely run on upgrades with existing databases
|
||||
# Workaround for Debian Bug #1022994: failure to create database when
|
||||
# working with libpam-tmpdir (by setting TMPDIR to empty value).
|
||||
set +e
|
||||
bash /usr/bin/mariadb-install-db --rpm --cross-bootstrap --user=mysql \
|
||||
--disable-log-bin --skip-test-db 2>&1 | \
|
||||
TMPDIR='' bash /usr/bin/mariadb-install-db \
|
||||
--rpm --cross-bootstrap \
|
||||
--user=mysql --disable-log-bin \
|
||||
--skip-test-db 2>&1 | \
|
||||
$ERR_LOGGER
|
||||
set -e
|
||||
|
||||
|
@ -210,6 +216,7 @@ EOF
|
|||
then
|
||||
install -o 0 -g 0 -m 0755 -d $mysql_cfgdir
|
||||
fi
|
||||
|
||||
if [ ! -e "$dc" ]
|
||||
then
|
||||
cat /dev/null > $dc
|
||||
|
@ -241,13 +248,13 @@ EOF
|
|||
# on by default) to work both to disable a default profile, and to keep
|
||||
# any profile installed and maintained by users themselves.
|
||||
profile="/etc/apparmor.d/usr.sbin.mariadbd"
|
||||
if [ -f "$profile" ] && aa-status --enabled 2>/dev/null
|
||||
if [ -f "$profile" ] && aa-status --enabled 2> /dev/null
|
||||
then
|
||||
if grep -q /usr/sbin/mariadbd "$profile" 2>/dev/null
|
||||
if grep -q /usr/sbin/mariadbd "$profile" 2> /dev/null
|
||||
then
|
||||
apparmor_parser -r "$profile" || true
|
||||
else
|
||||
echo "/usr/sbin/mariadbd { }" | apparmor_parser --remove 2>/dev/null || true
|
||||
echo "/usr/sbin/mariadbd { }" | apparmor_parser --remove 2> /dev/null || true
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -272,7 +279,8 @@ EOF
|
|||
if [ -d /run/systemd/system ]
|
||||
then
|
||||
systemctl --system daemon-reload
|
||||
else
|
||||
elif [ -x /etc/init.d/mariadb ]
|
||||
then
|
||||
invoke-rc.d mariadb restart
|
||||
fi
|
||||
;;
|
||||
|
|
42
debian/mariadb-server.preinst
vendored
42
debian/mariadb-server.preinst
vendored
|
@ -27,6 +27,15 @@ export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin
|
|||
mysql_datadir=/var/lib/mysql
|
||||
mysql_upgradedir=/var/lib/mysql-upgrade
|
||||
|
||||
MARIADBD_USERS="root"
|
||||
|
||||
# Check if user 'mysql' exists before referring to it in pgrep
|
||||
# to avoid pgrep erroring on 'invalid user name'
|
||||
if id mysql >/dev/null 2>&1
|
||||
then
|
||||
MARIADBD_USERS="$MARIADBD_USERS,mysql"
|
||||
fi
|
||||
|
||||
# Try to stop the server in a sane way. If it does not success let the admin
|
||||
# do it himself. No database directories should be removed while the server
|
||||
# is running! Another mariadbd in e.g. a different chroot is fine for us.
|
||||
|
@ -34,7 +43,7 @@ stop_server() {
|
|||
# Return immediately if there are no mysqld processes running on a host
|
||||
# (leave containerized processes with the same name in other namespaces)
|
||||
# as there is no point in trying to shutdown in that case.
|
||||
if ! pgrep -x --nslist pid --ns $$ "mysqld|mariadbd" > /dev/null
|
||||
if ! pgrep -x -u "$MARIADBD_USERS" --nslist pid --ns $$ "mysqld|mariadbd" > /dev/null
|
||||
then
|
||||
return
|
||||
fi
|
||||
|
@ -77,6 +86,9 @@ do
|
|||
break
|
||||
fi
|
||||
|
||||
# The whole flag_version thing should be rewritten, so ignore minor Shellcheck
|
||||
# nag for now
|
||||
# shellcheck disable=SC2001
|
||||
flag_version=$(echo "$flag" | sed 's/.*debian-\([0-9\.]\+\).flag/\1/')
|
||||
|
||||
# Initialize value if empty
|
||||
|
@ -164,14 +176,14 @@ stop_server
|
|||
# If we use NIS then errors should be tolerated. It's up to the
|
||||
# user to ensure that the mysql user is correctly setup.
|
||||
# Beware that there are two ypwhich one of them needs the 2>/dev/null!
|
||||
if test -n "$(which ypwhich 2>/dev/null)" && ypwhich >/dev/null 2>&1
|
||||
if test -n "$(command -v ypwhich 2>/dev/null)" && ypwhich > /dev/null 2>&1
|
||||
then
|
||||
set +e
|
||||
fi
|
||||
|
||||
#
|
||||
# Now we have to ensure the following state:
|
||||
# /etc/passwd: mysql:x:100:101:MySQL Server:/nonexistent:/bin/false
|
||||
# /etc/passwd: mysql:x:100:101:MariaDB Server:/nonexistent:/bin/false
|
||||
# /etc/group: mysql:x:101:
|
||||
#
|
||||
# Sadly there could any state be present on the system so we have to
|
||||
|
@ -196,9 +208,9 @@ then
|
|||
--ingroup mysql \
|
||||
--no-create-home \
|
||||
--home /nonexistent \
|
||||
--gecos "MySQL Server" \
|
||||
--gecos "MariaDB Server" \
|
||||
--shell /bin/false \
|
||||
mysql >/dev/null
|
||||
mysql >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
# end of NIS tolerance zone
|
||||
|
@ -209,7 +221,8 @@ set -e
|
|||
for dir in DATADIR LOGDIR
|
||||
do
|
||||
checkdir=$(eval echo "$"$dir)
|
||||
if [ -L "$checkdir" ]; then
|
||||
if [ -L "$checkdir" ]
|
||||
then
|
||||
# Use mkdir option 'Z' to create with correct SELinux context.
|
||||
mkdir -pZ "$mysql_upgradedir"
|
||||
cp -dT "$checkdir" "$mysql_upgradedir/$dir.link"
|
||||
|
@ -223,23 +236,14 @@ then
|
|||
mkdir -Z $mysql_datadir
|
||||
fi
|
||||
|
||||
# Check if MariaDB datadir is available if not fails.
|
||||
# There should be symlink or directory available or something will fail.
|
||||
if [ -d "$mysql_datadir" ] || [ -L "$mysql_datadir" ]
|
||||
# As preset blocksize of GNU df is 1024 then available bytes is $df_available_blocks * 1024
|
||||
# 4096 blocks is then lower than 4 MB
|
||||
df_available_blocks="$(LC_ALL=C BLOCKSIZE='' df --output=avail "$mysql_datadir" | tail -n 1)"
|
||||
if [ "$df_available_blocks" -lt "4096" ]
|
||||
then
|
||||
# As preset blocksize of GNU df is 1024 then available bytes is $df_available_blocks * 1024
|
||||
# 4096 blocks is then lower than 4 MB
|
||||
df_available_blocks="$(LC_ALL=C BLOCKSIZE='' df --output=avail "$mysql_datadir" | tail -n 1)"
|
||||
if [ "$df_available_blocks" -lt "4096" ]
|
||||
then
|
||||
echo "ERROR: There's not enough space in $mysql_datadir/" 1>&2
|
||||
db_stop
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "ERROR: There's no directory or symlink available: $mysql_datadir/" 1>&2
|
||||
db_stop
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Since the home directory was created before putting the user into
|
||||
|
|
15
debian/rules
vendored
15
debian/rules
vendored
|
@ -30,7 +30,8 @@ DEB_VERSION_REVISION := $(shell echo $(DEB_VERSION) | sed -e 's/.*[~-]\(.*\)/\1/
|
|||
DEB_VERSION_VERSION := $(shell echo $(DEB_VERSION) | sed -e 's/^.*:\(.*\)\(-\|+\).*/\1/')
|
||||
DEB_VERSION_MAJOR := $(shell echo $(DEB_VERSION_VERSION) | sed -e 's/^\(.*\)\..*$$/\1/')
|
||||
RELEASE := $(shell lsb_release -r -s) # Use changelog based DEB_DISTRIBUTION instead?
|
||||
TMP:=$(CURDIR)/debian/tmp
|
||||
TMP := $(CURDIR)/debian/tmp
|
||||
MTR_SKIP_TEST_LIST := $(shell mktemp)
|
||||
|
||||
# According to Debian Policy version 4.2.0 builds should be as verbose as
|
||||
# possible unless 'terse' is specifically passed.
|
||||
|
@ -68,14 +69,17 @@ override_dh_auto_configure:
|
|||
dh_testdir
|
||||
|
||||
ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
|
||||
dpkg-architecture -a$(DEB_BUILD_ARCH) -f -c dh_auto_configure --builddirectory=builddir-native
|
||||
dpkg-architecture -a$(DEB_BUILD_ARCH) -f -c dh_auto_configure --builddirectory=builddir-native --reload-all-buildenv-variables
|
||||
dh_auto_build --builddirectory=builddir-native -- import_executables
|
||||
endif
|
||||
|
||||
echo "server:Version=$(DEB_VERSION)" >> debian/substvars
|
||||
|
||||
# As packages does not have major version any more on package name there is no way as it not set by dpkg
|
||||
# to use this on postinst script. Use sed to determine major version
|
||||
# As packages does not have major version any more in package name there is no
|
||||
# way as it not set by dpkg to use this on postinst script. Use sed to
|
||||
# determine major version instead.
|
||||
# @TODO: Rewrite this to use the new upstream /var/lib/mysql_upgrade_info file
|
||||
# instead of the legacy /var/lib/debian-XX.X.flag file
|
||||
sed -i 's/__MARIADB_MAJOR_VER__/$(DEB_VERSION_MAJOR)/g' debian/mariadb-server.post* debian/mariadb-server.preinst
|
||||
|
||||
# Don't build ColumnStore as part of the native build as it does not meet the
|
||||
|
@ -86,7 +90,6 @@ endif
|
|||
# Note: Don't use '-DWITH_URING=ON' as some Buildbot builders are missing it
|
||||
# and would fail permanently.
|
||||
PATH=$${MYSQL_BUILD_PATH:-"/usr/lib/ccache:/usr/local/bin:/usr/bin:/bin"} \
|
||||
NO_UPDATE_BUILD_VERSION=1 \
|
||||
dh_auto_configure --builddirectory=$(BUILDDIR) -- \
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
$(CMAKEFLAGS) \
|
||||
|
@ -180,7 +183,7 @@ override_dh_auto_install:
|
|||
override_dh_installsystemd:
|
||||
dh_installsystemd -pmariadb-server mariadb.service
|
||||
|
||||
# Start MariaDB at sequence number 19 before 20 where apache, proftpd etc gets
|
||||
# Start mariadbd at sequence number 19 before 20 where apache, proftpd etc gets
|
||||
# started which might depend on a running database server.
|
||||
override_dh_installinit-arch:
|
||||
dh_installinit --name=mariadb -- defaults 19 21
|
||||
|
|
3
debian/tests/control
vendored
3
debian/tests/control
vendored
|
@ -12,5 +12,6 @@ Depends: mariadb-plugin-rocksdb | mariadb-server,
|
|||
Restrictions: allow-stderr needs-root isolation-container
|
||||
|
||||
Tests: upstream
|
||||
Depends: mariadb-test, eatmydata
|
||||
Depends: eatmydata,
|
||||
mariadb-test
|
||||
Restrictions: allow-stderr breaks-testbed
|
||||
|
|
24
debian/tests/smoke
vendored
24
debian/tests/smoke
vendored
|
@ -8,9 +8,9 @@
|
|||
#
|
||||
# This test should be declared in debian/tests/control with the
|
||||
# following restrictions:
|
||||
#
|
||||
# needs-root (to be able to log into the database)
|
||||
# allow-stderr
|
||||
# - allow-stderr (set -x always outputs to stderr)
|
||||
# - needs-root (to be able to log into the database)
|
||||
# - isolation-container (to be able to start service)
|
||||
#
|
||||
# This test:
|
||||
#
|
||||
|
@ -27,7 +27,7 @@ set -ex
|
|||
# Start the daemon if it was not running. For example in Docker testing
|
||||
# environments there might not be any systemd et al and the service needs to
|
||||
# be started manually.
|
||||
if ! which systemctl
|
||||
if ! command -v systemctl
|
||||
then
|
||||
if ! /etc/init.d/mariadb status
|
||||
then
|
||||
|
@ -71,9 +71,12 @@ DROP DATABASE testdatabase;
|
|||
DROP USER 'testuser'@'localhost';
|
||||
EOT
|
||||
|
||||
# List based on what is advertised at
|
||||
# https://mariadb.com/kb/en/innodb-page-compression/#configuring-the-innodb-page-compression-algorithm
|
||||
# but disabled with '#' the options that are not available in this binary build
|
||||
# This will never fail but exists purely for debugging purposes in case a later
|
||||
# step would fail
|
||||
mariadb <<EOT
|
||||
SHOW GLOBAL STATUS WHERE Variable_name LIKE 'Innodb_have_%';
|
||||
EOT
|
||||
|
||||
mariadb <<EOT
|
||||
SET GLOBAL innodb_compression_algorithm=lz4;
|
||||
SET GLOBAL innodb_compression_algorithm=lzo;
|
||||
|
@ -88,7 +91,7 @@ EOT
|
|||
plugin=mariadb-plugin-rocksdb
|
||||
if [ "$(dpkg-architecture -qDEB_HOST_ARCH_BITS)" != 32 ] &&
|
||||
[ "$(dpkg-architecture -qDEB_HOST_ARCH_ENDIAN)" = little ]
|
||||
then
|
||||
then
|
||||
dpkg-query -W $plugin
|
||||
|
||||
LOG=/var/lib/mysql/#rocksdb/LOG
|
||||
|
@ -101,7 +104,8 @@ if [ "$(dpkg-architecture -qDEB_HOST_ARCH_BITS)" != 32 ] &&
|
|||
grep -F " supported:" $LOG
|
||||
|
||||
# Check that the expected compression methods are supported
|
||||
for a in LZ4 Snappy Zlib ZSTD; do
|
||||
for a in LZ4 Snappy Zlib ZSTD
|
||||
do
|
||||
if ! grep -qE "k$a(Compression)? supported: 1" $LOG
|
||||
then
|
||||
# Fail with explicit error message
|
||||
|
@ -110,5 +114,5 @@ if [ "$(dpkg-architecture -qDEB_HOST_ARCH_BITS)" != 32 ] &&
|
|||
fi
|
||||
done
|
||||
else
|
||||
! dpkg-query -W $plugin
|
||||
dpkg-query -W $plugin && exit 1
|
||||
fi
|
||||
|
|
21
debian/tests/upstream
vendored
21
debian/tests/upstream
vendored
|
@ -25,37 +25,37 @@ echo "using tmpdir: $WORKDIR/tmp"
|
|||
echo "Setting up skip-tests-list"
|
||||
|
||||
# Use the arch specific skiplists if exist, otherwise list is empty
|
||||
if [ -f /usr/share/mysql/mysql-test/unstable-tests.$ARCH ]
|
||||
if [ -f "/usr/share/mysql/mysql-test/unstable-tests.$ARCH" ]
|
||||
then
|
||||
cat /usr/share/mysql/mysql-test/unstable-tests.$ARCH >> $MTR_SKIP_TEST_LIST
|
||||
cat "/usr/share/mysql/mysql-test/unstable-tests.$ARCH" >> "$MTR_SKIP_TEST_LIST"
|
||||
fi
|
||||
|
||||
# Skip tests that cannot run properly on ci.debian.net / autopkgtests.ubuntu.com
|
||||
cat >> $MTR_SKIP_TEST_LIST << EOF
|
||||
cat >> "$MTR_SKIP_TEST_LIST" << EOF
|
||||
binlog.binlog_server_start_options : Requires writable /usr
|
||||
main.ctype_uca : Requires writable /usr
|
||||
rpl.rpl_gtid_mode : Requires starting server as root ref http://bugs.mysql.com/bug.php?id=70517
|
||||
EOF
|
||||
|
||||
# Skip tests that cannot run properly on Gitlab-CI
|
||||
if [ ! -z "$GITLAB_CI" ]
|
||||
if [ -n "$GITLAB_CI" ]
|
||||
then
|
||||
cat >> $MTR_SKIP_TEST_LIST << EOF
|
||||
cat >> "$MTR_SKIP_TEST_LIST" << EOF
|
||||
main.mysqld--help : For unknown reason table-cache is 4000 instead of default 421
|
||||
EOF
|
||||
fi
|
||||
|
||||
if [ "$ARCH" = "s390x" ]
|
||||
then
|
||||
echo "main.func_regexp_pcre : recursion fails on s390x https://bugs.launchpad.net/ubuntu/+source/mariadb-10.1/+bug/1723947" >> $MTR_SKIP_TEST_LIST
|
||||
echo "main.func_regexp_pcre : recursion fails on s390x https://bugs.launchpad.net/ubuntu/+source/mariadb-10.1/+bug/1723947" >> "$MTR_SKIP_TEST_LIST"
|
||||
elif [ "$ARCH" = "armhf" ] || [ "$ARCH" = "i386" ]
|
||||
then
|
||||
echo "main.failed_auth_unixsocket : Test returns wrong exit code on armhf and i386 (but only in debci) https://jira.mariadb.org/browse/MDEV-23933" >> $MTR_SKIP_TEST_LIST
|
||||
echo "main.failed_auth_unixsocket : Test returns wrong exit code on armhf and i386 (but only in debci) https://jira.mariadb.org/browse/MDEV-23933" >> "$MTR_SKIP_TEST_LIST"
|
||||
fi
|
||||
|
||||
# Store skipped test list in artifacts so it can be viewed while debugging
|
||||
# failed autopkgtest runs
|
||||
cp -v $MTR_SKIP_TEST_LIST $AUTOPKGTEST_ARTIFACTS
|
||||
cp -v "$MTR_SKIP_TEST_LIST" "$AUTOPKGTEST_ARTIFACTS"
|
||||
|
||||
cd /usr/share/mysql/mysql-test
|
||||
echo "starting mysql-test-tun.pl..."
|
||||
|
@ -64,7 +64,8 @@ eatmydata perl -I. ./mysql-test-run.pl \
|
|||
--force --testcase-timeout=120 --suite-timeout=540 --retry=3 \
|
||||
--verbose-restart --max-save-core=1 --max-save-datadir=1 \
|
||||
--parallel=auto --skip-rpl --suite=main \
|
||||
--skip-test-list=$MTR_SKIP_TEST_LIST \
|
||||
--skip-test-list="$MTR_SKIP_TEST_LIST" \
|
||||
--vardir="$WORKDIR/var" --tmpdir="$WORKDIR/tmp" \
|
||||
--xml-report=$AUTOPKGTEST_ARTIFACTS/mysql-test-run-junit.xml $@ 2>&1
|
||||
--xml-report="$AUTOPKGTEST_ARTIFACTS/mysql-test-run-junit.xml"
|
||||
"$@" 2>&1
|
||||
echo "run: OK"
|
||||
|
|
Loading…
Reference in a new issue