MDEV-33750: Rename mysql to mariadb in Debian directory

As this is MariaDB then also variable names in
mariadb-server.*inst should correlate when possible
this change variable and directory names
This commit is contained in:
Tuukka Pasanen 2024-05-27 09:04:34 +03:00 committed by Daniel Black
parent 75d354a23a
commit d83742622d
2 changed files with 58 additions and 58 deletions

View file

@ -60,11 +60,11 @@ case "$1" in
fi fi
fi fi
mysql_statedir=/usr/share/mariadb mariadb_statedir=/usr/share/mariadb
mysql_datadir=/var/lib/mysql mariadb_datadir=/var/lib/mysql
mysql_logdir=/var/log/mysql mariadb_logdir=/var/log/mysql
mysql_cfgdir=/etc/mysql mariadb_cfgdir=/etc/mysql
mysql_upgradedir=/var/lib/mysql-upgrade mariadb_upgradedir=/var/lib/mysql-upgrade
# If the following symlink exists, it is a preserved copy the old data dir # If the following symlink exists, it is a preserved copy the old data dir
# created by the preinst script during a upgrade that would have otherwise # created by the preinst script during a upgrade that would have otherwise
@ -74,12 +74,12 @@ case "$1" in
if [ "$dir" = "DATADIR" ] if [ "$dir" = "DATADIR" ]
then then
targetdir=$mysql_datadir targetdir=$mariadb_datadir
else else
targetdir=$mysql_logdir targetdir=$mariadb_logdir
fi fi
savelink="$mysql_upgradedir/$dir.link" savelink="$mariadb_upgradedir/$dir.link"
if [ -L "$savelink" ] if [ -L "$savelink" ]
then then
# If the targetdir was a symlink before we upgraded it is supposed # If the targetdir was a symlink before we upgraded it is supposed
@ -92,10 +92,10 @@ case "$1" in
mv "$savelink" "$targetdir" mv "$savelink" "$targetdir"
else else
# this should never even happen, but just in case... # this should never even happen, but just in case...
mysql_tmp=$(mktemp -d -t mysql-symlink-restore-XXXXXX) mariadb_tmp=$(mktemp -d -t mariadb-symlink-restore-XXXXXX)
echo "this is very strange! see $mysql_tmp/README..." >&2 echo "this is very strange! see $mariadb_tmp/README..." >&2
mv "$targetdir" "$mysql_tmp" mv "$targetdir" "$mariadb_tmp"
cat << EOF > "$mysql_tmp/README" cat << EOF > "$mariadb_tmp/README"
If you're reading this, it's most likely because you had replaced /var/lib/mysql If you're reading this, it's most likely because you had replaced /var/lib/mysql
with a symlink, then upgraded to a new version of mysql, and then dpkg with a symlink, then upgraded to a new version of mysql, and then dpkg
@ -110,7 +110,7 @@ this all away.
EOF EOF
fi fi
fi fi
rmdir $mysql_upgradedir 2>/dev/null || true rmdir $mariadb_upgradedir 2>/dev/null || true
done done
@ -122,10 +122,10 @@ EOF
# This direct update is needed to enable an authentication mechanism to # This direct update is needed to enable an authentication mechanism to
# perform mariadb-upgrade, (MDEV-22678). To keep the impact minimal, we # perform mariadb-upgrade, (MDEV-22678). To keep the impact minimal, we
# skip innodb and set key-buffer-size to 0 as it isn't reused. # skip innodb and set key-buffer-size to 0 as it isn't reused.
if [ -f "$mysql_datadir/auto.cnf" ] && if [ -f "$mariadb_datadir/auto.cnf" ] &&
[ -f "$mysql_datadir/mysql/user.MYD" ] && [ -f "$mariadb_datadir/mysql/user.MYD" ] &&
! lsof -nt "$mysql_datadir"/mysql/user.MYD > /dev/null && ! lsof -nt "$mariadb_datadir"/mysql/user.MYD > /dev/null &&
[ ! -f "$mysql_datadir/undo_001" ] [ ! -f "$mariadb_datadir/undo_001" ]
then 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 mariadbd --skip-innodb --key_buffer_size=0 --default-storage-engine=MyISAM --bootstrap 2> /dev/null
@ -133,27 +133,27 @@ EOF
# Ensure the existence and right permissions for the database and # Ensure the existence and right permissions for the database and
# log files. Use mkdir option 'Z' to create with correct SELinux context. # log files. Use mkdir option 'Z' to create with correct SELinux context.
if [ ! -d "$mysql_statedir" ] && [ ! -L "$mysql_statedir" ] if [ ! -d "$mariadb_statedir" ] && [ ! -L "$mariadb_statedir" ]
then then
mkdir -Z "$mysql_statedir" mkdir -Z "$mariadb_statedir"
fi fi
if [ ! -d "$mysql_datadir" ] && [ ! -L "$mysql_datadir" ] if [ ! -d "$mariadb_datadir" ] && [ ! -L "$mariadb_datadir" ]
then then
mkdir -Z "$mysql_datadir" mkdir -Z "$mariadb_datadir"
fi fi
if [ ! -d "$mysql_logdir" ] && [ ! -L "$mysql_logdir" ] if [ ! -d "$mariadb_logdir" ] && [ ! -L "$mariadb_logdir" ]
then then
mkdir -Z "$mysql_logdir" mkdir -Z "$mariadb_logdir"
fi fi
# When creating an ext3 jounal on an already mounted filesystem like e.g. # When creating an ext3 jounal on an already mounted filesystem like e.g.
# /var/lib/mysql, you get a .journal file that is not modifiable by chown. # /var/lib/mysql, you get a .journal file that is not modifiable by chown.
# The mysql_statedir must not be writable by the mysql user under any # The mariadb_statedir must not be writable by the mysql user under any
# circumstances as it contains scripts that are executed by root. # circumstances as it contains scripts that are executed by root.
set +e set +e
chown -R 0:0 $mysql_statedir chown -R 0:0 $mariadb_statedir
find $mysql_datadir ! -uid "$(id -u mysql)" -print0 | xargs -0 -r chown mysql find $mariadb_datadir ! -uid "$(id -u mysql)" -print0 | xargs -0 -r chown mysql
chown -R mysql:adm $mysql_logdir chown -R mysql:adm $mariadb_logdir
chmod 2750 $mysql_logdir chmod 2750 $mariadb_logdir
set -e set -e
## Set the correct filesystem ownership for the PAM v2 plugin ## Set the correct filesystem ownership for the PAM v2 plugin
@ -176,14 +176,14 @@ EOF
chown mysql /usr/lib/mysql/plugin/auth_pam_tool_dir chown mysql /usr/lib/mysql/plugin/auth_pam_tool_dir
# This is important to avoid dataloss when there is a removed # This is important to avoid dataloss when there is a removed
# mysql-server version from Woody lying around which used the same # mariadb-server version from Woody lying around which used the same
# data directory and then somehow gets purged by the admin. # data directory and then somehow gets purged by the admin.
db_set mariadb-server/postrm_remove_database false || true db_set mariadb-server/postrm_remove_database false || true
# Clean up old flags before setting new one # Clean up old flags before setting new one
rm -f $mysql_datadir/debian-*.flag rm -f $mariadb_datadir/debian-*.flag
# Flag data dir to avoid downgrades # Flag data dir to avoid downgrades
touch "$mysql_datadir/debian-__MARIADB_MAJOR_VER__.flag" touch "$mariadb_datadir/debian-__MARIADB_MAJOR_VER__.flag"
# initiate databases. Output is not allowed by debconf :-( # initiate databases. Output is not allowed by debconf :-(
# This will fail if we are upgrading an existing database; in this case # This will fail if we are upgrading an existing database; in this case
@ -205,10 +205,10 @@ EOF
# --defaults-file option for tools (for the sake of upgrades) # --defaults-file option for tools (for the sake of upgrades)
# and thus need /etc/mysql/debian.cnf to exist, even if it's empty. # and thus need /etc/mysql/debian.cnf to exist, even if it's empty.
# In the long run the goal is to obsolete this file. # In the long run the goal is to obsolete this file.
dc="$mysql_cfgdir/debian.cnf" dc="$mariadb_cfgdir/debian.cnf"
if [ ! -d "$mysql_cfgdir" ] if [ ! -d "$mariadb_cfgdir" ]
then then
install -o 0 -g 0 -m 0755 -d $mysql_cfgdir install -o 0 -g 0 -m 0755 -d $mariadb_cfgdir
fi fi
if [ ! -e "$dc" ] if [ ! -e "$dc" ]
then then
@ -224,7 +224,7 @@ EOF
echo "[client]"; echo "[client]";
echo "host = localhost"; echo "host = localhost";
echo "user = root"; echo "user = root";
echo "[mysql_upgrade]"; echo "[mariadb_upgrade]";
echo "host = localhost"; echo "host = localhost";
echo "user = root"; echo "user = root";
echo "# THIS FILE WILL BE REMOVED IN A FUTURE DEBIAN RELEASE."; echo "# THIS FILE WILL BE REMOVED IN A FUTURE DEBIAN RELEASE.";

View file

@ -26,8 +26,8 @@ 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 export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin
mysql_datadir=/var/lib/mysql mariadb_datadir=/var/lib/mysql
mysql_upgradedir=/var/lib/mysql-upgrade mariadb_upgradedir=/var/lib/mysql-upgrade
# Try to stop the server in a sane way. If it does not success let the admin # 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 # do it himself. No database directories should be removed while the server
@ -68,13 +68,13 @@ max_upgradeable_version=5.7
# Check if a flag file is found that indicates a previous MariaDB or MySQL # Check if a flag file is found that indicates a previous MariaDB or MySQL
# version was installed. If multiple flags are found, check which one was # version was installed. If multiple flags are found, check which one was
# the biggest version number. # the biggest version number.
for flag in "$mysql_datadir"/debian-*.flag for flag in "$mariadb_datadir"/debian-*.flag
do do
# The for loop leaves $flag as the query string if there are no results, # The for loop leaves $flag as the query string if there are no results,
# so the check below is needed to stop further processing when there are # so the check below is needed to stop further processing when there are
# no real results. # no real results.
if [ "$flag" = "$mysql_datadir/debian-*.flag" ] if [ "$flag" = "$mariadb_datadir/debian-*.flag" ]
then then
break break
fi fi
@ -109,13 +109,13 @@ then
# MySQL 8.0 in Ubuntu has a bug in packaging and the file is name wrongly # MySQL 8.0 in Ubuntu has a bug in packaging and the file is name wrongly
# 'debian-5.7.flag', so in case '5.7' was encountered an extra check needs to # 'debian-5.7.flag', so in case '5.7' was encountered an extra check needs to
# be done to see is there is a file called undo_001, which is a sign of 8.0. # be done to see is there is a file called undo_001, which is a sign of 8.0.
if [ "$found_version" == "5.7" ] && [ -f "$mysql_datadir/undo_001" ] if [ "$found_version" == "5.7" ] && [ -f "$mariadb_datadir/undo_001" ]
then then
# Seems to be a 8.0, flag has wrongly 5.7 (know bug) # Seems to be a 8.0, flag has wrongly 5.7 (know bug)
found_version=8.0 found_version=8.0
fi fi
echo "$mysql_datadir: found previous version $found_version" echo "$mariadb_datadir: found previous version $found_version"
if dpkg --compare-versions "$found_version" '>>' "$this_version" if dpkg --compare-versions "$found_version" '>>' "$this_version"
then then
@ -135,10 +135,10 @@ fi
# installs), then that file is enough of additional indication to trigger the # installs), then that file is enough of additional indication to trigger the
# move of the data directory. # move of the data directory.
if [ -z "$found_version" ] && if [ -z "$found_version" ] &&
[ -z "$(find $mysql_datadir/debian-*.flag 2> /dev/null)" ] && [ -z "$(find $mariadb_datadir/debian-*.flag 2> /dev/null)" ] &&
[ -f "$mysql_datadir/undo_001" ] [ -f "$mariadb_datadir/undo_001" ]
then then
echo "$mysql_datadir: no server version flag found, assuming MySQL 8.0 data encountered" echo "$mariadb_datadir: no server version flag found, assuming MySQL 8.0 data encountered"
downgrade_detected=true downgrade_detected=true
found_version="previous" # Just use dummy name as we don't know real version found_version="previous" # Just use dummy name as we don't know real version
fi fi
@ -149,12 +149,12 @@ if [ -n "$downgrade_detected" ]
then then
db_input critical "mariadb-server/old_data_directory_saved" || true db_input critical "mariadb-server/old_data_directory_saved" || true
db_go db_go
echo "The file $mysql_datadir/debian-$found_version.flag indicates a" 1>&2 echo "The file $mariadb_datadir/debian-$found_version.flag indicates a" 1>&2
echo "version that cannot automatically be upgraded. Therefore the" 1>&2 echo "version that cannot automatically be upgraded. Therefore the" 1>&2
echo "previous data directory will be renamed to $mysql_datadir-$found_version and" 1>&2 echo "previous data directory will be renamed to $mariadb_datadir-$found_version and" 1>&2
echo "a new data directory will be initialized at $mysql_datadir." 1>&2 echo "a new data directory will be initialized at $mariadb_datadir." 1>&2
echo "Please manually export/import your data (e.g. with mysqldump) if needed." 1>&2 echo "Please manually export/import your data (e.g. with mysqldump) if needed." 1>&2
mv -f "$mysql_datadir" "$mysql_datadir-$found_version" mv -f "$mariadb_datadir" "$mariadb_datadir-$found_version"
# Also move away the old debian.cnf file that included credentials that are # Also move away the old debian.cnf file that included credentials that are
# no longer valid. If none existed, ignore error and let dpkg continue. # no longer valid. If none existed, ignore error and let dpkg continue.
mv -f /etc/mysql/debian.cnf "/etc/mysql/debian.cnf-$found_version" || true mv -f /etc/mysql/debian.cnf "/etc/mysql/debian.cnf-$found_version" || true
@ -213,33 +213,33 @@ do
checkdir=$(eval echo "$"$dir) checkdir=$(eval echo "$"$dir)
if [ -L "$checkdir" ]; then if [ -L "$checkdir" ]; then
# Use mkdir option 'Z' to create with correct SELinux context. # Use mkdir option 'Z' to create with correct SELinux context.
mkdir -pZ "$mysql_upgradedir" mkdir -pZ "$mariadb_upgradedir"
cp -dT "$checkdir" "$mysql_upgradedir/$dir.link" cp -dT "$checkdir" "$mariadb_upgradedir/$dir.link"
fi fi
done done
# creating mysql home directory # creating mysql home directory
if [ ! -d $mysql_datadir ] && [ ! -L $mysql_datadir ] if [ ! -d $mariadb_datadir ] && [ ! -L $mariadb_datadir ]
then then
# Use mkdir option 'Z' to create with correct SELinux context. # Use mkdir option 'Z' to create with correct SELinux context.
mkdir -Z $mysql_datadir mkdir -Z $mariadb_datadir
fi fi
# Check if MariaDB datadir is available if not fails. # Check if MariaDB datadir is available if not fails.
# There should be symlink or directory available or something will fail. # There should be symlink or directory available or something will fail.
if [ -d "$mysql_datadir" ] || [ -L "$mysql_datadir" ] if [ -d "$mariadb_datadir" ] || [ -L "$mariadb_datadir" ]
then then
# As preset blocksize of GNU df is 1024 then available bytes is $df_available_blocks * 1024 # As preset blocksize of GNU df is 1024 then available bytes is $df_available_blocks * 1024
# 4096 blocks is then lower than 4 MB # 4096 blocks is then lower than 4 MB
df_available_blocks="$(LC_ALL=C BLOCKSIZE='' df --output=avail "$mysql_datadir" | tail -n 1)" df_available_blocks="$(LC_ALL=C BLOCKSIZE='' df --output=avail "$mariadb_datadir" | tail -n 1)"
if [ "$df_available_blocks" -lt "4096" ] if [ "$df_available_blocks" -lt "4096" ]
then then
echo "ERROR: There's not enough space in $mysql_datadir/" 1>&2 echo "ERROR: There's not enough space in $mariadb_datadir/" 1>&2
db_stop db_stop
exit 1 exit 1
fi fi
else else
echo "ERROR: There's no directory or symlink available: $mysql_datadir/" 1>&2 echo "ERROR: There's no directory or symlink available: $mariadb_datadir/" 1>&2
db_stop db_stop
exit 1 exit 1
fi fi
@ -252,8 +252,8 @@ fi
# The "set +e" is necessary as e.g. a ".journal" of a ext3 partition is # The "set +e" is necessary as e.g. a ".journal" of a ext3 partition is
# not chgrp'able (#318435). # not chgrp'able (#318435).
set +e set +e
find $mysql_datadir ! -uid "$(id -u mysql)" -print0 | xargs -0 -r chown mysql find $mariadb_datadir ! -uid "$(id -u mysql)" -print0 | xargs -0 -r chown mysql
find $mysql_datadir -follow -not -group mysql -print0 2>/dev/null \ find $mariadb_datadir -follow -not -group mysql -print0 2>/dev/null \
| xargs -0 --no-run-if-empty chgrp mysql | xargs -0 --no-run-if-empty chgrp mysql
set -e set -e