More fixes and cleanups for bug#28585:

  - make the 'dist-hook' from top-level Makefile work again.
  - we can find my_print_defaults from --basedir by parsing command
    line arguments prior to running my_print_defaults.
  - take advantage of additional command line parsing and allow the
    --no-defaults etc arguments to work anywhere rather than having
    to be the first argument.
  - find SQL files either from binary archive or source install.
  - consolidate and tidy code and error messages.
parent d2936fad
...@@ -32,12 +32,6 @@ in_rpm=0 ...@@ -32,12 +32,6 @@ in_rpm=0
ip_only=0 ip_only=0
windows=0 windows=0
case "$1" in
--no-defaults|--defaults-file=*|--defaults-extra-file=*)
defaults="$1"; shift
;;
esac
usage() usage()
{ {
cat <<EOF cat <<EOF
...@@ -112,6 +106,8 @@ parse_arguments() ...@@ -112,6 +106,8 @@ parse_arguments()
--verbose) verbose=1 ;; # Obsolete --verbose) verbose=1 ;; # Obsolete
--rpm) in_rpm=1 ;; --rpm) in_rpm=1 ;;
--help) usage ;; --help) usage ;;
--no-defaults|--defaults-file=*|--defaults-extra-file=*)
defaults="$arg" ;;
--windows) --windows)
# This is actually a "cross bootstrap" argument used when # This is actually a "cross bootstrap" argument used when
...@@ -139,20 +135,71 @@ parse_arguments() ...@@ -139,20 +135,71 @@ parse_arguments()
done done
} }
# Sanity check - make sure we can find my_print_defaults either in the binary # Try to find a specific file within --basedir which can either be a binary
# distribution or within the installed source compile. # release or installed source directory and return the path.
print_defaults="@bindir@/my_print_defaults" find_in_basedir()
if ! test -x $print_defaults {
then case "$1" in
echo "FATAL ERROR: Could not find $print_defaults" --dir)
return_dir=1; shift
;;
esac
file=$1; shift
for dir in "$@"
do
if test -f "$basedir/$dir/$file"
then
if test -n "$return_dir"
then
echo "$basedir/$dir"
else
echo "$basedir/$dir/$file"
fi
break
fi
done
}
missing_in_basedir()
{
echo "FATAL ERROR: Could not find $* inside --basedir"
echo echo
echo "If you are using a binary release, you must run this script from" echo "When using --basedir you must point either into a MySQL binary"
echo "within the directory the archive extracted into. If you compiled" echo "distribution directory or a compiled tree previously populated"
echo "MySQL yourself you must run 'make install' first." echo "by 'make install'"
exit 1 }
# Ok, let's go. We first need to parse arguments which are required by
# my_print_defaults so that we can execute it first, then later re-parse
# the command line to add any extra bits that we need.
parse_arguments PICK-ARGS-FROM-ARGV "$@"
# We can now find my_print_defaults, either in the supplied --basedir
# location or in the installed area.
if test -n "$basedir"
then
print_defaults=`find_in_basedir my_print_defaults bin extra`
if ! test -x "$print_defaults"
then
missing_in_basedir my_print_defaults
exit 1
fi
else
print_defaults="@bindir@/my_print_defaults"
if ! test -x "$print_defaults"
then
echo "FATAL ERROR: Could not find $print_defaults"
echo
echo "If you are using a binary release, you must run this script from"
echo "within the directory the archive extracted into. If you compiled"
echo "MySQL yourself you must run 'make install' first."
exit 1
fi
fi fi
# Firstly, get arguments from the groups [mysqld] and [mysql_install_db] # Now we can get arguments from the groups [mysqld] and [mysql_install_db]
# in the my.cfg file, then re-run to merge with command line arguments. # in the my.cfg file, then re-run to merge with command line arguments.
parse_arguments `$print_defaults $defaults mysqld mysql_install_db` parse_arguments `$print_defaults $defaults mysqld mysql_install_db`
parse_arguments PICK-ARGS-FROM-ARGV "$@" parse_arguments PICK-ARGS-FROM-ARGV "$@"
...@@ -163,20 +210,24 @@ then ...@@ -163,20 +210,24 @@ then
basedir="@prefix@" basedir="@prefix@"
bindir="@bindir@" bindir="@bindir@"
mysqld="@libexecdir@/mysqld" mysqld="@libexecdir@/mysqld"
pkgdatadir="@pkgdatadir@"
else else
bindir="$basedir/bin" bindir="$basedir/bin"
for dir in libexec sbin bin # We set up bootstrap-specific paths later, so skip this for --windows
do if test "$windows" -eq 0
if test -x "$basedir/$dir/mysqld" then
pkgdatadir=`find_in_basedir --dir fill_help_tables.sql share share/mysql`
if test -z "$pkgdatadir"
then then
mysqld="$basedir/$dir/mysqld" missing_in_basedir fill_help_tables.sql
break exit 1
fi
mysqld=`find_in_basedir mysqld libexec sbin bin`
if ! test -x "$mysqld"
then
missing_in_basedir mysqld
exit 1
fi fi
done
if test -z "$mysqld"
then
echo "FATAL ERROR: Could not find mysqld inside supplied --basedir"
exit 1
fi fi
fi fi
...@@ -190,8 +241,6 @@ fi ...@@ -190,8 +241,6 @@ fi
if test -n "$srcdir" if test -n "$srcdir"
then then
pkgdatadir="$srcdir/scripts" pkgdatadir="$srcdir/scripts"
else
pkgdatadir="@pkgdatadir@"
fi fi
fill_help_tables="$pkgdatadir/fill_help_tables.sql" fill_help_tables="$pkgdatadir/fill_help_tables.sql"
......
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