#!/bin/sh
# Copyright (c) 2000-2002, 2004, 2006, 2007 MySQL AB
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
# Create a bug report and mail it to the mysql mailing list
# Based on glibc bug reporting script.
echo "Finding system information for a MySQL bug report"
VERSION="5.1.73"
COMPILATION_COMMENT="Source distribution"
BUGmysql="mysql@lists.mysql.com"
# This is set by configure
COMP_CALL_INFO="CC='gcc'  CFLAGS='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC'  CXX=''  CXXFLAGS='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -felide-constructors -fno-rtti -fno-exceptions'  LDFLAGS=''  ASFLAGS=''"
COMP_RUN_INFO="CC='gcc'  CFLAGS=' -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC   -DUNIV_LINUX -DUNIV_LINUX'  CXX='g++'  CXXFLAGS=' -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -felide-constructors -fno-rtti -fno-exceptions   -fno-implicit-templates -fno-exceptions -fno-rtti'  LDFLAGS=' -rdynamic '  ASFLAGS=''"
CONFIGURE_LINE="./configure  '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '--target=x86_64-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--with-readline' '--with-ssl=/usr' '--without-debug' '--enable-shared' '--with-embedded-server' '--localstatedir=/var/lib/mysql' '--with-unix-socket-path=/var/lib/mysql/mysql.sock' '--with-mysqld-user=mysql' '--with-extra-charsets=all' '--with-big-tables' '--with-pic' '--with-plugin-innobase' '--with-plugin-innodb_plugin' '--with-plugin-partition' '--enable-local-infile' '--enable-largefile' '--enable-thread-safe-client' '--disable-dependency-tracking' 'build_alias=x86_64-redhat-linux-gnu' 'host_alias=x86_64-redhat-linux-gnu' 'target_alias=x86_64-redhat-linux-gnu' 'CFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC' 'CXXFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -felide-constructors -fno-rtti -fno-exceptions'"
LIBC_INFO=""
for pat in /lib/libc.* /lib/libc-* /usr/lib/libc.* /usr/lib/libc-*
do
    TMP=`ls -l $pat 2>/dev/null`
    if test $? = 0
    then
      LIBC_INFO="$LIBC_INFO
$TMP"
    fi
done
PATH=../client:$PATH:/bin:/usr/bin:/usr/local/bin
export PATH
BUGADDR=${1-$BUGmysql}
ENVIRONMENT=`uname -a`
: ${USER=${LOGNAME-`whoami`}}
COMMAND=`echo $0|sed 's%.*/\([^/]*\)%\1%'`
# Try to create a secure tmpfile
umask 077
TEMPDIR=/tmp/mysqlbug-$$
mkdir $TEMPDIR || (echo "can not create directory in /tmp, aborting"; exit 1;)
TEMP=${TEMPDIR}/mysqlbug
trap 'rm -f $TEMP $TEMP.x; rmdir $TEMPDIR; exit 1' 1 2 3 13 15
trap 'rm -f $TEMP $TEMP.x; rmdir $TEMPDIR' 0
# How to read the passwd database.
PASSWD="cat /etc/passwd"
if test -f /usr/lib/sendmail
then
  MAIL_AGENT="/usr/lib/sendmail -oi -t"
elif test -f /usr/sbin/sendmail
then
  MAIL_AGENT="/usr/sbin/sendmail -oi -t"
else
  MAIL_AGENT="rmail $BUGmysql"
fi
# Figure out how to echo a string without a trailing newline
N=`echo 'hi there\c'`
case "$N" in
  *c)	ECHON1='echo -n' ECHON2= ;;
  *)	ECHON1=echo ECHON2='\c' ;;
esac
# Find out the name of the originator of this PR.
if test -n "$NAME" 
then
  ORIGINATOR="$NAME"
elif test -f $HOME/.fullname
then
  ORIGINATOR="`sed -e '1q' $HOME/.fullname`"
else
  # Must use temp file due to incompatibilities in quoting behavior
  # and to protect shell metacharacters in the expansion of $LOGNAME
  $PASSWD | grep "^$LOGNAME:" | awk -F: '{print $5}' | sed -e 's/,.*//' > $TEMP
  ORIGINATOR="`cat $TEMP`"
  rm -f $TEMP
fi
if test -n "$ORGANIZATION"
then
  if test -f "$ORGANIZATION"
  then
    ORGANIZATION="`cat $ORGANIZATION`"
  fi
else
  if test -f $HOME/.organization
  then
    ORGANIZATION="`cat $HOME/.organization`"
  elif test -f $HOME/.signature
  then
    ORGANIZATION=`sed -e "s/^/  /" $HOME/.signature; echo ">"`
  fi
fi
PATH_DIRS=`echo $PATH | sed -e 's/^:/. /' -e 's/:$/ ./' -e 's/::/ . /g' -e 's/:/ /g' `
which_1 ()
{
  for cmd
  do
    # Absolute path ?. 
    if expr "x$cmd" : "x/" > /dev/null
    then
      echo "$cmd"
      exit 0
    else
      for d in $PATH_DIRS
      do
	file="$d/$cmd"
	if test -x "$file" -a ! -d "$file"
	then
	  echo "$file"
	  exit 0
	fi
      done
    fi
  done
  exit 1
}
change_editor ()
{
  echo "You can change editor by setting the environment variable VISUAL."
  echo "If your shell is a bourne shell (sh) do"
  echo "VISUAL=your_editors_name; export VISUAL"
  echo "If your shell is a C shell (csh) do"
  echo "setenv VISUAL your_editors_name"
}
# If they don't have a preferred editor set, then use emacs
if test -z "$VISUAL"
then
  if test -z "$EDITOR"
  then
    # Honor debian sensible-editor
    if test -x "/usr/bin/sensible-editor"
    then
      EDIT=/usr/bin/sensible-editor
    else
      EDIT=emacs
    fi
  else
    EDIT="$EDITOR"
  fi
else
  EDIT="$VISUAL"
fi
#which_1 $EDIT
used_editor=`which_1 $EDIT`
echo "test -x $used_editor"
if test -x "$used_editor"
then
  echo "Using editor $used_editor";
  change_editor
  sleep 2
else
  echo "Could not find a text editor. (tried $EDIT)"
  change_editor
  exit 1
fi
# Find out some information.
SYSTEM=`( test -f /bin/uname  && /bin/uname -a ) || \
        ( test -f /usr/bin/uname  && /usr/bin/uname -a ) || echo ""`
ARCH=`test -f /bin/arch  && /bin/arch`
MACHINE=`test -f /bin/machine  && /bin/machine`
FILE_PATHS=
for cmd in perl make gmake gcc cc
do
  file=`which_1 $cmd`
  if test $? = 0
  then
    if test $cmd = "gcc"
    then
      GCC_INFO=`$file -v 2>&1`
    elif test $cmd = "perl"
    then
      PERL_INFO=`$file -v | grep -i version 2>&1`
    fi
    FILE_PATHS="$FILE_PATHS $file"
  fi
done
admin=`which_1 mysqladmin`
MYSQL_SERVER=
if test -x "$admin"
then
  MYSQL_SERVER=`$admin version 2> /dev/null`
  if test "$?" = "1"
  then
    MYSQL_SERVER=""
  fi
fi
SUBJECT_C="[50 character or so descriptive subject here (for reference)]"
ORGANIZATION_C=''
FIX_C='