Skip to content

Commit d837426

Browse files
illuusiogrooverdan
authored andcommitted
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
1 parent 75d354a commit d837426

File tree

2 files changed

+58
-58
lines changed

2 files changed

+58
-58
lines changed

debian/mariadb-server.postinst

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ case "$1" in
6060
fi
6161
fi
6262

63-
mysql_statedir=/usr/share/mariadb
64-
mysql_datadir=/var/lib/mysql
65-
mysql_logdir=/var/log/mysql
66-
mysql_cfgdir=/etc/mysql
67-
mysql_upgradedir=/var/lib/mysql-upgrade
63+
mariadb_statedir=/usr/share/mariadb
64+
mariadb_datadir=/var/lib/mysql
65+
mariadb_logdir=/var/log/mysql
66+
mariadb_cfgdir=/etc/mysql
67+
mariadb_upgradedir=/var/lib/mysql-upgrade
6868

6969
# If the following symlink exists, it is a preserved copy the old data dir
7070
# created by the preinst script during a upgrade that would have otherwise
@@ -74,12 +74,12 @@ case "$1" in
7474

7575
if [ "$dir" = "DATADIR" ]
7676
then
77-
targetdir=$mysql_datadir
77+
targetdir=$mariadb_datadir
7878
else
79-
targetdir=$mysql_logdir
79+
targetdir=$mariadb_logdir
8080
fi
8181

82-
savelink="$mysql_upgradedir/$dir.link"
82+
savelink="$mariadb_upgradedir/$dir.link"
8383
if [ -L "$savelink" ]
8484
then
8585
# If the targetdir was a symlink before we upgraded it is supposed
@@ -92,10 +92,10 @@ case "$1" in
9292
mv "$savelink" "$targetdir"
9393
else
9494
# this should never even happen, but just in case...
95-
mysql_tmp=$(mktemp -d -t mysql-symlink-restore-XXXXXX)
96-
echo "this is very strange! see $mysql_tmp/README..." >&2
97-
mv "$targetdir" "$mysql_tmp"
98-
cat << EOF > "$mysql_tmp/README"
95+
mariadb_tmp=$(mktemp -d -t mariadb-symlink-restore-XXXXXX)
96+
echo "this is very strange! see $mariadb_tmp/README..." >&2
97+
mv "$targetdir" "$mariadb_tmp"
98+
cat << EOF > "$mariadb_tmp/README"
9999
100100
If you're reading this, it's most likely because you had replaced /var/lib/mysql
101101
with a symlink, then upgraded to a new version of mysql, and then dpkg
@@ -110,7 +110,7 @@ this all away.
110110
EOF
111111
fi
112112
fi
113-
rmdir $mysql_upgradedir 2>/dev/null || true
113+
rmdir $mariadb_upgradedir 2>/dev/null || true
114114

115115
done
116116

@@ -122,38 +122,38 @@ EOF
122122
# This direct update is needed to enable an authentication mechanism to
123123
# perform mariadb-upgrade, (MDEV-22678). To keep the impact minimal, we
124124
# skip innodb and set key-buffer-size to 0 as it isn't reused.
125-
if [ -f "$mysql_datadir/auto.cnf" ] &&
126-
[ -f "$mysql_datadir/mysql/user.MYD" ] &&
127-
! lsof -nt "$mysql_datadir"/mysql/user.MYD > /dev/null &&
128-
[ ! -f "$mysql_datadir/undo_001" ]
125+
if [ -f "$mariadb_datadir/auto.cnf" ] &&
126+
[ -f "$mariadb_datadir/mysql/user.MYD" ] &&
127+
! lsof -nt "$mariadb_datadir"/mysql/user.MYD > /dev/null &&
128+
[ ! -f "$mariadb_datadir/undo_001" ]
129129
then
130130
echo "UPDATE mysql.user SET plugin='unix_socket' WHERE plugin='auth_socket';" |
131131
mariadbd --skip-innodb --key_buffer_size=0 --default-storage-engine=MyISAM --bootstrap 2> /dev/null
132132
fi
133133

134134
# Ensure the existence and right permissions for the database and
135135
# log files. Use mkdir option 'Z' to create with correct SELinux context.
136-
if [ ! -d "$mysql_statedir" ] && [ ! -L "$mysql_statedir" ]
136+
if [ ! -d "$mariadb_statedir" ] && [ ! -L "$mariadb_statedir" ]
137137
then
138-
mkdir -Z "$mysql_statedir"
138+
mkdir -Z "$mariadb_statedir"
139139
fi
140-
if [ ! -d "$mysql_datadir" ] && [ ! -L "$mysql_datadir" ]
140+
if [ ! -d "$mariadb_datadir" ] && [ ! -L "$mariadb_datadir" ]
141141
then
142-
mkdir -Z "$mysql_datadir"
142+
mkdir -Z "$mariadb_datadir"
143143
fi
144-
if [ ! -d "$mysql_logdir" ] && [ ! -L "$mysql_logdir" ]
144+
if [ ! -d "$mariadb_logdir" ] && [ ! -L "$mariadb_logdir" ]
145145
then
146-
mkdir -Z "$mysql_logdir"
146+
mkdir -Z "$mariadb_logdir"
147147
fi
148148
# When creating an ext3 jounal on an already mounted filesystem like e.g.
149149
# /var/lib/mysql, you get a .journal file that is not modifiable by chown.
150-
# The mysql_statedir must not be writable by the mysql user under any
150+
# The mariadb_statedir must not be writable by the mysql user under any
151151
# circumstances as it contains scripts that are executed by root.
152152
set +e
153-
chown -R 0:0 $mysql_statedir
154-
find $mysql_datadir ! -uid "$(id -u mysql)" -print0 | xargs -0 -r chown mysql
155-
chown -R mysql:adm $mysql_logdir
156-
chmod 2750 $mysql_logdir
153+
chown -R 0:0 $mariadb_statedir
154+
find $mariadb_datadir ! -uid "$(id -u mysql)" -print0 | xargs -0 -r chown mysql
155+
chown -R mysql:adm $mariadb_logdir
156+
chmod 2750 $mariadb_logdir
157157
set -e
158158

159159
## Set the correct filesystem ownership for the PAM v2 plugin
@@ -176,14 +176,14 @@ EOF
176176
chown mysql /usr/lib/mysql/plugin/auth_pam_tool_dir
177177

178178
# This is important to avoid dataloss when there is a removed
179-
# mysql-server version from Woody lying around which used the same
179+
# mariadb-server version from Woody lying around which used the same
180180
# data directory and then somehow gets purged by the admin.
181181
db_set mariadb-server/postrm_remove_database false || true
182182

183183
# Clean up old flags before setting new one
184-
rm -f $mysql_datadir/debian-*.flag
184+
rm -f $mariadb_datadir/debian-*.flag
185185
# Flag data dir to avoid downgrades
186-
touch "$mysql_datadir/debian-__MARIADB_MAJOR_VER__.flag"
186+
touch "$mariadb_datadir/debian-__MARIADB_MAJOR_VER__.flag"
187187

188188
# initiate databases. Output is not allowed by debconf :-(
189189
# This will fail if we are upgrading an existing database; in this case
@@ -205,10 +205,10 @@ EOF
205205
# --defaults-file option for tools (for the sake of upgrades)
206206
# and thus need /etc/mysql/debian.cnf to exist, even if it's empty.
207207
# In the long run the goal is to obsolete this file.
208-
dc="$mysql_cfgdir/debian.cnf"
209-
if [ ! -d "$mysql_cfgdir" ]
208+
dc="$mariadb_cfgdir/debian.cnf"
209+
if [ ! -d "$mariadb_cfgdir" ]
210210
then
211-
install -o 0 -g 0 -m 0755 -d $mysql_cfgdir
211+
install -o 0 -g 0 -m 0755 -d $mariadb_cfgdir
212212
fi
213213
if [ ! -e "$dc" ]
214214
then
@@ -224,7 +224,7 @@ EOF
224224
echo "[client]";
225225
echo "host = localhost";
226226
echo "user = root";
227-
echo "[mysql_upgrade]";
227+
echo "[mariadb_upgrade]";
228228
echo "host = localhost";
229229
echo "user = root";
230230
echo "# THIS FILE WILL BE REMOVED IN A FUTURE DEBIAN RELEASE.";

debian/mariadb-server.preinst

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ fi
2626
${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
2727

2828
export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin
29-
mysql_datadir=/var/lib/mysql
30-
mysql_upgradedir=/var/lib/mysql-upgrade
29+
mariadb_datadir=/var/lib/mysql
30+
mariadb_upgradedir=/var/lib/mysql-upgrade
3131

3232
# Try to stop the server in a sane way. If it does not success let the admin
3333
# do it himself. No database directories should be removed while the server
@@ -68,13 +68,13 @@ max_upgradeable_version=5.7
6868
# Check if a flag file is found that indicates a previous MariaDB or MySQL
6969
# version was installed. If multiple flags are found, check which one was
7070
# the biggest version number.
71-
for flag in "$mysql_datadir"/debian-*.flag
71+
for flag in "$mariadb_datadir"/debian-*.flag
7272
do
7373

7474
# The for loop leaves $flag as the query string if there are no results,
7575
# so the check below is needed to stop further processing when there are
7676
# no real results.
77-
if [ "$flag" = "$mysql_datadir/debian-*.flag" ]
77+
if [ "$flag" = "$mariadb_datadir/debian-*.flag" ]
7878
then
7979
break
8080
fi
@@ -109,13 +109,13 @@ then
109109
# MySQL 8.0 in Ubuntu has a bug in packaging and the file is name wrongly
110110
# 'debian-5.7.flag', so in case '5.7' was encountered an extra check needs to
111111
# be done to see is there is a file called undo_001, which is a sign of 8.0.
112-
if [ "$found_version" == "5.7" ] && [ -f "$mysql_datadir/undo_001" ]
112+
if [ "$found_version" == "5.7" ] && [ -f "$mariadb_datadir/undo_001" ]
113113
then
114114
# Seems to be a 8.0, flag has wrongly 5.7 (know bug)
115115
found_version=8.0
116116
fi
117117

118-
echo "$mysql_datadir: found previous version $found_version"
118+
echo "$mariadb_datadir: found previous version $found_version"
119119

120120
if dpkg --compare-versions "$found_version" '>>' "$this_version"
121121
then
@@ -135,10 +135,10 @@ fi
135135
# installs), then that file is enough of additional indication to trigger the
136136
# move of the data directory.
137137
if [ -z "$found_version" ] &&
138-
[ -z "$(find $mysql_datadir/debian-*.flag 2> /dev/null)" ] &&
139-
[ -f "$mysql_datadir/undo_001" ]
138+
[ -z "$(find $mariadb_datadir/debian-*.flag 2> /dev/null)" ] &&
139+
[ -f "$mariadb_datadir/undo_001" ]
140140
then
141-
echo "$mysql_datadir: no server version flag found, assuming MySQL 8.0 data encountered"
141+
echo "$mariadb_datadir: no server version flag found, assuming MySQL 8.0 data encountered"
142142
downgrade_detected=true
143143
found_version="previous" # Just use dummy name as we don't know real version
144144
fi
@@ -149,12 +149,12 @@ if [ -n "$downgrade_detected" ]
149149
then
150150
db_input critical "mariadb-server/old_data_directory_saved" || true
151151
db_go
152-
echo "The file $mysql_datadir/debian-$found_version.flag indicates a" 1>&2
152+
echo "The file $mariadb_datadir/debian-$found_version.flag indicates a" 1>&2
153153
echo "version that cannot automatically be upgraded. Therefore the" 1>&2
154-
echo "previous data directory will be renamed to $mysql_datadir-$found_version and" 1>&2
155-
echo "a new data directory will be initialized at $mysql_datadir." 1>&2
154+
echo "previous data directory will be renamed to $mariadb_datadir-$found_version and" 1>&2
155+
echo "a new data directory will be initialized at $mariadb_datadir." 1>&2
156156
echo "Please manually export/import your data (e.g. with mysqldump) if needed." 1>&2
157-
mv -f "$mysql_datadir" "$mysql_datadir-$found_version"
157+
mv -f "$mariadb_datadir" "$mariadb_datadir-$found_version"
158158
# Also move away the old debian.cnf file that included credentials that are
159159
# no longer valid. If none existed, ignore error and let dpkg continue.
160160
mv -f /etc/mysql/debian.cnf "/etc/mysql/debian.cnf-$found_version" || true
@@ -213,33 +213,33 @@ do
213213
checkdir=$(eval echo "$"$dir)
214214
if [ -L "$checkdir" ]; then
215215
# Use mkdir option 'Z' to create with correct SELinux context.
216-
mkdir -pZ "$mysql_upgradedir"
217-
cp -dT "$checkdir" "$mysql_upgradedir/$dir.link"
216+
mkdir -pZ "$mariadb_upgradedir"
217+
cp -dT "$checkdir" "$mariadb_upgradedir/$dir.link"
218218
fi
219219
done
220220

221221
# creating mysql home directory
222-
if [ ! -d $mysql_datadir ] && [ ! -L $mysql_datadir ]
222+
if [ ! -d $mariadb_datadir ] && [ ! -L $mariadb_datadir ]
223223
then
224224
# Use mkdir option 'Z' to create with correct SELinux context.
225-
mkdir -Z $mysql_datadir
225+
mkdir -Z $mariadb_datadir
226226
fi
227227

228228
# Check if MariaDB datadir is available if not fails.
229229
# There should be symlink or directory available or something will fail.
230-
if [ -d "$mysql_datadir" ] || [ -L "$mysql_datadir" ]
230+
if [ -d "$mariadb_datadir" ] || [ -L "$mariadb_datadir" ]
231231
then
232232
# As preset blocksize of GNU df is 1024 then available bytes is $df_available_blocks * 1024
233233
# 4096 blocks is then lower than 4 MB
234-
df_available_blocks="$(LC_ALL=C BLOCKSIZE='' df --output=avail "$mysql_datadir" | tail -n 1)"
234+
df_available_blocks="$(LC_ALL=C BLOCKSIZE='' df --output=avail "$mariadb_datadir" | tail -n 1)"
235235
if [ "$df_available_blocks" -lt "4096" ]
236236
then
237-
echo "ERROR: There's not enough space in $mysql_datadir/" 1>&2
237+
echo "ERROR: There's not enough space in $mariadb_datadir/" 1>&2
238238
db_stop
239239
exit 1
240240
fi
241241
else
242-
echo "ERROR: There's no directory or symlink available: $mysql_datadir/" 1>&2
242+
echo "ERROR: There's no directory or symlink available: $mariadb_datadir/" 1>&2
243243
db_stop
244244
exit 1
245245
fi
@@ -252,8 +252,8 @@ fi
252252
# The "set +e" is necessary as e.g. a ".journal" of a ext3 partition is
253253
# not chgrp'able (#318435).
254254
set +e
255-
find $mysql_datadir ! -uid "$(id -u mysql)" -print0 | xargs -0 -r chown mysql
256-
find $mysql_datadir -follow -not -group mysql -print0 2>/dev/null \
255+
find $mariadb_datadir ! -uid "$(id -u mysql)" -print0 | xargs -0 -r chown mysql
256+
find $mariadb_datadir -follow -not -group mysql -print0 2>/dev/null \
257257
| xargs -0 --no-run-if-empty chgrp mysql
258258
set -e
259259

0 commit comments

Comments
 (0)