Commit 52516706 authored by Sergei Golubchik's avatar Sergei Golubchik

cleanup mysql_install_db

1. detect resolveip location, don' assume it's in $basedir/bin
2. don't guess $scriptdir to (incorrectly) construct the $0 path
3. rename find_in_basedir -> find_in_dirs, don't prepend $basedir
   automatically. This allows to use identical path lists in
   find_in_dirs and in cannot_find_file.
4. move search path lists to CMakeLists.txt to avoid specifying the
   same path list twice (in find_in_dirs and in cannot_find_file).
parent d76f5774
...@@ -205,6 +205,11 @@ ELSE() ...@@ -205,6 +205,11 @@ ELSE()
SET(localstatedir ${MYSQL_DATADIR}) SET(localstatedir ${MYSQL_DATADIR})
ENDIF() ENDIF()
SET(resolveip_locations "$basedir/bin")
SET(mysqld_locations "$basedir/libexec $basedir/sbin $basedir/bin")
SET(errmsg_locations "$basedir/share/english $basedir/share/mysql/english")
SET(pkgdata_locations "$basedir/share $basedir/share/mysql")
IF(UNIX) IF(UNIX)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysql_install_db.sh CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysql_install_db.sh
${CMAKE_CURRENT_BINARY_DIR}/mysql_install_db ESCAPE_QUOTES @ONLY) ${CMAKE_CURRENT_BINARY_DIR}/mysql_install_db ESCAPE_QUOTES @ONLY)
......
...@@ -159,7 +159,7 @@ parse_arguments() ...@@ -159,7 +159,7 @@ parse_arguments()
# Try to find a specific file within --basedir which can either be a binary # Try to find a specific file within --basedir which can either be a binary
# release or installed source directory and return the path. # release or installed source directory and return the path.
find_in_basedir() find_in_dirs()
{ {
case "$1" in case "$1" in
--dir) --dir)
...@@ -171,13 +171,13 @@ find_in_basedir() ...@@ -171,13 +171,13 @@ find_in_basedir()
for dir in "$@" for dir in "$@"
do do
if test -f "$basedir/$dir/$file" if test -f "$dir/$file"
then then
if test -n "$return_dir" if test -n "$return_dir"
then then
echo "$basedir/$dir" echo "$dir"
else else
echo "$basedir/$dir/$file" echo "$dir/$file"
fi fi
break break
fi fi
...@@ -239,7 +239,7 @@ then ...@@ -239,7 +239,7 @@ then
print_defaults="$builddir/extra/my_print_defaults" print_defaults="$builddir/extra/my_print_defaults"
elif test -n "$basedir" elif test -n "$basedir"
then then
print_defaults=`find_in_basedir my_print_defaults bin extra` print_defaults=`find_in_dirs my_print_defaults $basedir/bin $basedir/extra`
if test -z "$print_defaults" if test -z "$print_defaults"
then then
cannot_find_file my_print_defaults $basedir/bin $basedir/extra cannot_find_file my_print_defaults $basedir/bin $basedir/extra
...@@ -265,41 +265,43 @@ if test -n "$srcdir" ...@@ -265,41 +265,43 @@ if test -n "$srcdir"
then then
basedir="$builddir" basedir="$builddir"
bindir="$basedir/client" bindir="$basedir/client"
extra_bindir="$basedir/extra" resolveip="$basedir/extra/resolveip"
mysqld="$basedir/sql/mysqld" mysqld="$basedir/sql/mysqld"
langdir="$basedir/sql/share/english" langdir="$basedir/sql/share/english"
pkgdatadir="$srcdir/scripts" pkgdatadir="$srcdir/scripts"
scriptdir="$srcdir/scripts"
elif test -n "$basedir" elif test -n "$basedir"
then then
bindir="$basedir/bin" bindir="$basedir/bin" # only used in the help text
extra_bindir="$bindir" resolveip=`find_in_dirs resolveip @resolveip_locations@`
mysqld=`find_in_basedir mysqld libexec sbin bin` if test -z "$resolveip"
then
cannot_find_file resolveip @resolveip_locations@
exit 1
fi
mysqld=`find_in_dirs mysqld @mysqld_locations@`
if test -z "$mysqld" if test -z "$mysqld"
then then
cannot_find_file mysqld $basedir/libexec $basedir/sbin $basedir/bin cannot_find_file mysqld @mysqld_locations@
exit 1 exit 1
fi fi
langdir=`find_in_basedir --dir errmsg.sys share/english share/mysql/english` langdir=`find_in_dirs --dir errmsg.sys @errmsg_locations@`
if test -z "$langdir" if test -z "$langdir"
then then
cannot_find_file errmsg.sys $basedir/share/english $basedir/share/mysql/english cannot_find_file errmsg.sys @errmsg_locations@
exit 1 exit 1
fi fi
pkgdatadir=`find_in_basedir --dir fill_help_tables.sql share share/mysql` pkgdatadir=`find_in_dirs --dir fill_help_tables.sql @pkgdata_locations@`
if test -z "$pkgdatadir" if test -z "$pkgdatadir"
then then
cannot_find_file fill_help_tables.sql $basedir/share $basedir/share/mysql cannot_find_file fill_help_tables.sql @pkgdata_locations@
exit 1 exit 1
fi fi
scriptdir="$basedir/scripts"
else else
basedir="@prefix@" basedir="@prefix@"
bindir="@bindir@" bindir="@bindir@"
extra_bindir="$bindir" resolveip="$bindir/resolveip"
mysqld="@libexecdir@/mysqld" mysqld="@libexecdir@/mysqld"
pkgdatadir="@pkgdatadir@" pkgdatadir="@pkgdatadir@"
scriptdir="@scriptdir@"
fi fi
# Set up paths to SQL scripts required for bootstrap # Set up paths to SQL scripts required for bootstrap
...@@ -342,14 +344,14 @@ hostname=`@HOSTNAME@` ...@@ -342,14 +344,14 @@ hostname=`@HOSTNAME@`
# Check if hostname is valid # Check if hostname is valid
if test "$cross_bootstrap" -eq 0 -a "$in_rpm" -eq 0 -a "$force" -eq 0 if test "$cross_bootstrap" -eq 0 -a "$in_rpm" -eq 0 -a "$force" -eq 0
then then
resolved=`"$extra_bindir/resolveip" $hostname 2>&1` resolved=`"$resolveip" $hostname 2>&1`
if test $? -ne 0 if test $? -ne 0
then then
resolved=`"$extra_bindir/resolveip" localhost 2>&1` resolved=`"$resolveip" localhost 2>&1`
if test $? -ne 0 if test $? -ne 0
then then
echo "Neither host '$hostname' nor 'localhost' could be looked up with" echo "Neither host '$hostname' nor 'localhost' could be looked up with"
echo "'$extra_bindir/resolveip'" echo "'$resolveip'"
echo "Please configure the 'hostname' command to return a correct" echo "Please configure the 'hostname' command to return a correct"
echo "hostname." echo "hostname."
echo "If you want to solve this at a later stage, restart this script" echo "If you want to solve this at a later stage, restart this script"
...@@ -357,7 +359,7 @@ then ...@@ -357,7 +359,7 @@ then
link_to_help link_to_help
exit 1 exit 1
fi fi
echo "WARNING: The host '$hostname' could not be looked up with resolveip." echo "WARNING: The host '$hostname' could not be looked up with $resolveip."
echo "This probably means that your libc libraries are not 100 % compatible" echo "This probably means that your libc libraries are not 100 % compatible"
echo "with this binary MariaDB version. The MariaDB daemon, mysqld, should work" echo "with this binary MariaDB version. The MariaDB daemon, mysqld, should work"
echo "normally with the exception that host name resolving will not work." echo "normally with the exception that host name resolving will not work."
...@@ -436,7 +438,7 @@ else ...@@ -436,7 +438,7 @@ else
echo "The problem could be conflicting information in an external" echo "The problem could be conflicting information in an external"
echo "my.cnf files. You can ignore these by doing:" echo "my.cnf files. You can ignore these by doing:"
echo echo
echo " shell> $scriptdir/scripts/mysql_install_db --defaults-file=~/.my.cnf" echo " shell> $0 --defaults-file=~/.my.cnf"
echo echo
echo "You can also try to start the mysqld daemon with:" echo "You can also try to start the mysqld daemon with:"
echo echo
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment