Skip to content

Commit 616ced8

Browse files
committed
Merge 10.9 into 10.10
2 parents a089ebd + 2763f73 commit 616ced8

15 files changed

+343
-178
lines changed

debian/mariadb-common.postinst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ case "$1" in
3535
then
3636
update-alternatives --install /etc/mysql/my.cnf my.cnf "/etc/mysql/mariadb.cnf" 500 || true
3737
fi
38-
;;
38+
;;
3939
esac
4040

4141
#DEBHELPER#

debian/mariadb-common.postrm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ case "$1" in
1010
then
1111
/usr/share/mysql-common/configure-symlinks remove mariadb "/etc/mysql/mariadb.cnf"
1212
fi
13-
;;
13+
;;
1414
esac
1515

1616
#DEBHELPER#

debian/mariadb-server.postinst

Lines changed: 87 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
#!/bin/bash
22
set -e
33

4+
# shellcheck source=/dev/null
45
. /usr/share/debconf/confmodule
56

6-
if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi
7+
if [ -n "$DEBIAN_SCRIPT_DEBUG" ]
8+
then
9+
set -v -x
10+
DEBIAN_SCRIPT_TRACE=1
11+
fi
12+
713
${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
814

915
export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin
@@ -21,7 +27,9 @@ case "$1" in
2127
# and because changed configuration options should take effect immediately.
2228
# In case the server wasn't running at all it should be ok if the stop
2329
# script fails. I can't tell at this point because of the cleaned /run.
24-
set +e; invoke-rc.d mariadb stop; set -e
30+
set +e
31+
invoke-rc.d mariadb stop
32+
set -e
2533

2634
# An existing /etc/init.d/mysql might be on the system if there was a
2735
# previous MySQL or MariaDB installation, since /etc/init.d files are
@@ -61,21 +69,26 @@ case "$1" in
6169
# If the following symlink exists, it is a preserved copy the old data dir
6270
# created by the preinst script during a upgrade that would have otherwise
6371
# been replaced by an empty mysql dir. This should restore it.
64-
for dir in DATADIR LOGDIR; do
72+
for dir in DATADIR LOGDIR
73+
do
6574

66-
if [ "$dir" = "DATADIR" ]; then
75+
if [ "$dir" = "DATADIR" ]
76+
then
6777
targetdir=$mysql_datadir
6878
else
6979
targetdir=$mysql_logdir
7080
fi
7181

7282
savelink="$mysql_upgradedir/$dir.link"
73-
if [ -L "$savelink" ]; then
83+
if [ -L "$savelink" ]
84+
then
7485
# If the targetdir was a symlink before we upgraded it is supposed
7586
# to be either still be present or not existing anymore now.
76-
if [ -L "$targetdir" ]; then
87+
if [ -L "$targetdir" ]
88+
then
7789
rm "$savelink"
78-
elif [ ! -d "$targetdir" ]; then
90+
elif [ ! -d "$targetdir" ]
91+
then
7992
mv "$savelink" "$targetdir"
8093
else
8194
# this should never even happen, but just in case...
@@ -97,7 +110,7 @@ this all away.
97110
EOF
98111
fi
99112
fi
100-
rmdir $mysql_upgradedir 2>/dev/null || true
113+
rmdir $mysql_upgradedir 2>/dev/null || true
101114

102115
done
103116

@@ -109,17 +122,29 @@ EOF
109122
# This direct update is needed to enable an authentication mechanism to
110123
# perform mariadb-upgrade, (MDEV-22678). To keep the impact minimal, we
111124
# skip innodb and set key-buffer-size to 0 as it isn't reused.
112-
if [ -f "$mysql_datadir"/auto.cnf ] && [ -f "$mysql_datadir"/mysql/user.MYD ] &&
113-
[ ! lsof -nt "$mysql_datadir"/mysql/user.MYD > /dev/null ] && [ ! -f "$mysql_datadir"/undo_001 ]; then
114-
echo "UPDATE mysql.user SET plugin='unix_socket' WHERE plugin='auth_socket';" |
115-
mariadbd --skip-innodb --key_buffer_size=0 --default-storage-engine=MyISAM --bootstrap 2> /dev/null
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" ]
129+
then
130+
echo "UPDATE mysql.user SET plugin='unix_socket' WHERE plugin='auth_socket';" |
131+
mariadbd --skip-innodb --key_buffer_size=0 --default-storage-engine=MyISAM --bootstrap 2> /dev/null
116132
fi
117133

118134
# Ensure the existence and right permissions for the database and
119135
# log files. Use mkdir option 'Z' to create with correct SELinux context.
120-
if [ ! -d "$mysql_statedir" ] && [ ! -L "$mysql_statedir" ]; then mkdir -Z "$mysql_statedir"; fi
121-
if [ ! -d "$mysql_datadir" ] && [ ! -L "$mysql_datadir" ]; then mkdir -Z "$mysql_datadir" ; fi
122-
if [ ! -d "$mysql_logdir" ] && [ ! -L "$mysql_logdir" ]; then mkdir -Z "$mysql_logdir" ; fi
136+
if [ ! -d "$mysql_statedir" ] && [ ! -L "$mysql_statedir" ]
137+
then
138+
mkdir -Z "$mysql_statedir"
139+
fi
140+
if [ ! -d "$mysql_datadir" ] && [ ! -L "$mysql_datadir" ]
141+
then
142+
mkdir -Z "$mysql_datadir"
143+
fi
144+
if [ ! -d "$mysql_logdir" ] && [ ! -L "$mysql_logdir" ]
145+
then
146+
mkdir -Z "$mysql_logdir"
147+
fi
123148
# When creating an ext3 jounal on an already mounted filesystem like e.g.
124149
# /var/lib/mysql, you get a .journal file that is not modifiable by chown.
125150
# The mysql_statedir must not be writable by the mysql user under any
@@ -168,8 +193,8 @@ EOF
168193
# Debian: can safely run on upgrades with existing databases
169194
set +e
170195
bash /usr/bin/mariadb-install-db --rpm --cross-bootstrap --user=mysql \
171-
--disable-log-bin --skip-test-db 2>&1 | \
172-
$ERR_LOGGER
196+
--disable-log-bin --skip-test-db 2>&1 | \
197+
$ERR_LOGGER
173198
set -e
174199

175200
# On new installations root user can connect via unix_socket.
@@ -180,26 +205,30 @@ EOF
180205
# --defaults-file option for tools (for the sake of upgrades)
181206
# and thus need /etc/mysql/debian.cnf to exist, even if it's empty.
182207
# In the long run the goal is to obsolete this file.
183-
dc=$mysql_cfgdir/debian.cnf;
184-
if [ ! -d "$mysql_cfgdir" ]; then
208+
dc="$mysql_cfgdir/debian.cnf"
209+
if [ ! -d "$mysql_cfgdir" ]
210+
then
185211
install -o 0 -g 0 -m 0755 -d $mysql_cfgdir
186212
fi
187-
if [ ! -e "$dc" ]; then
188-
cat /dev/null > $dc
189-
echo "# THIS FILE IS OBSOLETE. STOP USING IT IF POSSIBLE." >>$dc
190-
echo "# This file exists only for backwards compatibility for" >>$dc
191-
echo "# tools that run '--defaults-file=/etc/mysql/debian.cnf'" >>$dc
192-
echo "# and have root level access to the local filesystem." >>$dc
193-
echo "# With those permissions one can run 'mariadb' directly" >>$dc
194-
echo "# anyway thanks to unix socket authentication and hence" >>$dc
195-
echo "# this file is useless. See package README for more info." >>$dc
196-
echo "[client]" >>$dc
197-
echo "host = localhost" >>$dc
198-
echo "user = root" >>$dc
199-
echo "[mysql_upgrade]" >>$dc
200-
echo "host = localhost" >>$dc
201-
echo "user = root" >>$dc
202-
echo "# THIS FILE WILL BE REMOVED IN A FUTURE DEBIAN RELEASE." >>$dc
213+
if [ ! -e "$dc" ]
214+
then
215+
cat /dev/null > $dc
216+
{
217+
echo "# THIS FILE IS OBSOLETE. STOP USING IT IF POSSIBLE.";
218+
echo "# This file exists only for backwards compatibility for";
219+
echo "# tools that run '--defaults-file=/etc/mysql/debian.cnf'";
220+
echo "# and have root level access to the local filesystem.";
221+
echo "# With those permissions one can run 'mariadb' directly";
222+
echo "# anyway thanks to unix socket authentication and hence";
223+
echo "# this file is useless. See package README for more info.";
224+
echo "[client]";
225+
echo "host = localhost";
226+
echo "user = root";
227+
echo "[mysql_upgrade]";
228+
echo "host = localhost";
229+
echo "user = root";
230+
echo "# THIS FILE WILL BE REMOVED IN A FUTURE DEBIAN RELEASE.";
231+
} >> $dc
203232
fi
204233
# Keep it only root-readable, as it always was
205234
chown 0:0 $dc
@@ -212,8 +241,10 @@ EOF
212241
# on by default) to work both to disable a default profile, and to keep
213242
# any profile installed and maintained by users themselves.
214243
profile="/etc/apparmor.d/usr.sbin.mariadbd"
215-
if [ -f "$profile" ] && aa-status --enabled 2>/dev/null; then
216-
if grep -q /usr/sbin/mariadbd "$profile" 2>/dev/null ; then
244+
if [ -f "$profile" ] && aa-status --enabled 2>/dev/null
245+
then
246+
if grep -q /usr/sbin/mariadbd "$profile" 2>/dev/null
247+
then
217248
apparmor_parser -r "$profile" || true
218249
else
219250
echo "/usr/sbin/mariadbd { }" | apparmor_parser --remove 2>/dev/null || true
@@ -225,24 +256,24 @@ EOF
225256
# Note that file cannot be empty, otherwise systemd version in Ubuntu Bionic
226257
# will think the service is masked
227258
echo "# empty placeholder" > /etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf
228-
229-
;;
259+
;;
230260

231261
abort-upgrade|abort-remove|abort-configure)
232-
;;
262+
;;
233263

234264
triggered)
235-
if [ -d /run/systemd/system ]; then
265+
if [ -d /run/systemd/system ]
266+
then
236267
systemctl --system daemon-reload
237268
else
238269
invoke-rc.d mariadb restart
239270
fi
240-
;;
271+
;;
241272

242273
*)
243274
echo "postinst called with unknown argument '$1'" 1>&2
244275
exit 1
245-
;;
276+
;;
246277
esac
247278

248279
db_stop # in case invoke fails
@@ -252,19 +283,23 @@ db_stop # in case invoke fails
252283
# systemctl. If we upgrade from MySQL mysql.service may be masked, which also
253284
# means init.d script is disabled. Unmask mysql service explicitly.
254285
# Check first that the command exists, to avoid emitting any warning messages.
255-
if [ -x "$(command -v deb-systemd-helper)" ]; then
286+
if [ -x "$(command -v deb-systemd-helper)" ]
287+
then
256288
deb-systemd-helper unmask mysql.service > /dev/null
257289
fi
258290

259291
#DEBHELPER#
260292

261293
# Modified dh_systemd_start snippet that's not added automatically
262-
if [ -d /run/systemd/system ]; then
263-
systemctl --system daemon-reload >/dev/null || true
264-
deb-systemd-invoke start mariadb.service >/dev/null || true
265-
# Modified dh_installinit snippet to only run with sysvinit
266-
elif [ -x "/etc/init.d/mariadb" ]; then
267-
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
268-
invoke-rc.d mariadb start || exit $?
269-
fi
294+
if [ -d /run/systemd/system ]
295+
then
296+
systemctl --system daemon-reload >/dev/null || true
297+
deb-systemd-invoke start mariadb.service >/dev/null || true
298+
# Modified dh_installinit snippet to only run with sysvinit
299+
elif [ -x "/etc/init.d/mariadb" ]
300+
then
301+
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]
302+
then
303+
invoke-rc.d mariadb start || exit $?
304+
fi
270305
fi

debian/mariadb-server.postrm

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
#!/bin/bash
22
set -e
33

4+
# shellcheck source=/dev/null
45
. /usr/share/debconf/confmodule
56

6-
if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi
7+
if [ -n "$DEBIAN_SCRIPT_DEBUG" ]
8+
then
9+
set -v -x
10+
DEBIAN_SCRIPT_TRACE=1
11+
fi
12+
713
${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
814

915
MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"
@@ -12,54 +18,61 @@ MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"
1218
# do it himself. No database directories should be removed while the server
1319
# is running! Another mariadbd in e.g. a different chroot is fine for us.
1420
stop_server() {
15-
# Return immediately if there are no mysqld processes running
16-
# as there is no point in trying to shutdown in that case.
17-
if ! pgrep -x --nslist pid --ns $$ "mysqld|mariadbd" > /dev/null; then return; fi
21+
# Return immediately if there are no mysqld processes running
22+
# as there is no point in trying to shutdown in that case.
23+
if ! pgrep -x --nslist pid --ns $$ "mysqld|mariadbd" > /dev/null
24+
then
25+
return
26+
fi
1827

19-
set +e
20-
invoke-rc.d mariadb stop
21-
invoke-rc.d mysql stop # Backwards compatibility
22-
errno=$?
23-
set -e
28+
set +e
29+
invoke-rc.d mariadb stop
30+
invoke-rc.d mysql stop # Backwards compatibility
31+
errno=$?
32+
set -e
2433

25-
# systemctl could emit exit code 100=no init script (fresh install)
26-
if [ "$errno" != 0 -a "$errno" != 100 ]; then
27-
echo "Attempt to stop MariaDB/MySQL server returned exitcode $errno" 1>&2
28-
echo "There is a MariaDB/MySQL server running, but we failed in our attempts to stop it." 1>&2
29-
echo "Stop it yourself and try again!" 1>&2
30-
db_stop
31-
exit 1
32-
fi
34+
# systemctl could emit exit code 100=no init script (fresh install)
35+
if [ "$errno" != 0 ] && [ "$errno" != 100 ]
36+
then
37+
echo "Attempt to stop MariaDB/MySQL server returned exitcode $errno" 1>&2
38+
echo "There is a MariaDB/MySQL server running, but we failed in our attempts to stop it." 1>&2
39+
echo "Stop it yourself and try again!" 1>&2
40+
db_stop
41+
exit 1
42+
fi
3343
}
3444

3545

3646
case "$1" in
3747
purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
38-
if [ -n "`$MYADMIN ping 2>/dev/null`" ]; then
48+
if [ -n "$($MYADMIN ping 2>/dev/null)" ]
49+
then
3950
stop_server
4051
sleep 2
4152
fi
42-
;;
53+
;;
4354
*)
4455
echo "postrm called with unknown argument '$1'" 1>&2
4556
exit 1
46-
;;
57+
;;
4758
esac
4859

4960
#
5061
# - Purge logs and data only if they are ours (#307473)
5162
# - Remove the mysql user only after all his owned files are purged.
5263
# - Cleanup the initscripts only if this was the last provider of them
5364
#
54-
if [ "$1" = "purge" ] && [ -f "/var/lib/mysql/debian-__MARIADB_MAJOR_VER__.flag" ]; then
65+
if [ "$1" = "purge" ] && [ -f "/var/lib/mysql/debian-__MARIADB_MAJOR_VER__.flag" ]
66+
then
5567
# we remove the mysql user only after all his owned files are purged
5668
rm -f /var/log/mysql.{log,err}{,.0,.[1234567].gz}
5769
rm -rf /var/log/mysql
5870

5971
db_input high "mariadb-server/postrm_remove_databases" || true
6072
db_go || true
6173
db_get "mariadb-server/postrm_remove_databases" || true
62-
if [ "$RET" = "true" ]; then
74+
if [ "$RET" = "true" ]
75+
then
6376
# never remove the debian.cnf when the databases are still existing
6477
# else we ran into big trouble on the next install!
6578
rm -f /etc/mysql/debian.cnf
@@ -72,9 +85,9 @@ if [ "$1" = "purge" ] && [ -f "/var/lib/mysql/debian-__MARIADB_MAJOR_VER__.flag"
7285
if [ -d /var/lib/mysql ]
7386
then
7487
find /var/lib/mysql -mindepth 1 \
75-
-not -path '*/lost+found/*' -not -name 'lost+found' \
76-
-not -path '*/lost@002bfound/*' -not -name 'lost@002bfound' \
77-
-delete
88+
-not -path '*/lost+found/*' -not -name 'lost+found' \
89+
-not -path '*/lost@002bfound/*' -not -name 'lost@002bfound' \
90+
-delete
7891

7992
# "|| true" still needed as rmdir still exits with non-zero if
8093
# /var/lib/mysql is a mount point
@@ -89,6 +102,7 @@ fi
89102
#DEBHELPER#
90103

91104
# Modified dh_systemd_start snippet that's not added automatically
92-
if [ -d /run/systemd/system ]; then
93-
systemctl --system daemon-reload >/dev/null || true
105+
if [ -d /run/systemd/system ]
106+
then
107+
systemctl --system daemon-reload >/dev/null || true
94108
fi

0 commit comments

Comments
 (0)