From a79abb6517f2fa68b48e61aa3354a0631e3a63f7 Mon Sep 17 00:00:00 2001 From: Tuukka Pasanen Date: Fri, 3 Mar 2023 14:27:30 +0200 Subject: [PATCH 1/3] MDEV-30778: Remove Awk from mysql_install_db Commit reduces need of AWK-command at least for Debian mariadb-server-compat package. Commit removes need of AWK-command from scripts/mysql_install_db.sh script. AWK command is replace by purely Posix sh compiliant version. --- scripts/mysql_install_db.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index eec985396c4..b28e533ecd8 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -476,7 +476,7 @@ fi if test "$ip_only" -eq 1 then - hostname=`echo "$resolved" | awk '/ /{print $6}'` + hostname=`echo "$resolved" | while read a; do echo ${a##* }; done` fi # Create database directories From fe32a4a5bb84afa0db4cf6fee5ce5f37dfa065ea Mon Sep 17 00:00:00 2001 From: Tuukka Pasanen Date: Mon, 13 Mar 2023 11:56:53 +0200 Subject: [PATCH 2/3] MDEV-30837: Remove usage of AWK from Debian init and postinst scripts AWK in used in Debian SysV-init and postinst scripts to determine is there enough space starting MariaDB database or create new database to target destination. These AWK scripts can be rewrited to use pure SH or help using Coreutils which is mandatory for usage of MariaDB currently. Reasoning behind this is to get rid of one very less used dependency --- debian/mariadb-server.mariadb.init | 5 ++++- debian/mariadb-server.preinst | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/debian/mariadb-server.mariadb.init b/debian/mariadb-server.mariadb.init index cc004179894..f4051d4b007 100644 --- a/debian/mariadb-server.mariadb.init +++ b/debian/mariadb-server.mariadb.init @@ -84,7 +84,10 @@ sanity_checks() { # check for diskspace shortage datadir=`mariadbd_get_param datadir` - if LC_ALL=C BLOCKSIZE= df --portability $datadir/. | tail -n 1 | awk '{ exit ($4>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 "$datadir" | tail -n 1` + 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 diff --git a/debian/mariadb-server.preinst b/debian/mariadb-server.preinst index 755815eaeed..e2d8e670bbf 100644 --- a/debian/mariadb-server.preinst +++ b/debian/mariadb-server.preinst @@ -196,8 +196,10 @@ if [ ! -d $mysql_datadir ] && [ ! -L $mysql_datadir ]; then mkdir -Z $mysql_datadir fi -# checking disc space -if LC_ALL=C BLOCKSIZE= df --portability $mysql_datadir/. | tail -n 1 | awk '{ exit ($4>1000) }'; 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 "$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 From 31487f4b2b6a3c038a39bb68ce96e9c400ca25d6 Mon Sep 17 00:00:00 2001 From: Tuukka Pasanen Date: Fri, 24 Mar 2023 11:42:15 +0200 Subject: [PATCH 3/3] MDEV-30837: Remove usage of AWK in autobake-debs.sh AWK is used in autobake-debs.sh for printing information about created DEB packages. This can be rewrite with bash inner commands read and echo. --- debian/autobake-deb.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/debian/autobake-deb.sh b/debian/autobake-deb.sh index 68a8ce34283..caef33b2b7d 100755 --- a/debian/autobake-deb.sh +++ b/debian/autobake-deb.sh @@ -201,7 +201,11 @@ then for package in *.deb do echo "$package" | cut -d '_' -f 1 - dpkg-deb -c "$package" | awk '{print $1 " " $2 " " $6 " " $7 " " $8}' | sort -k 3 + # shellcheck disable=SC2034 + dpkg-deb -c "$package" | while IFS=" " read -r col1 col2 col3 col4 col5 col6 col7 col8 + do + echo "$col1 $col2 $col6 $col7 $col8" | sort -k 3 + done echo "------------------------------------------------" done fi