Bug#18972488 Remove packaging/rpm-uln directory from source

parent c0129a35
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
#
# 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
IF(UNIX)
SET(prefix ${CMAKE_INSTALL_PREFIX})
SET(SPECFILENAME "mysql.${VERSION}.spec")
IF("${VERSION}" MATCHES "-ndb-")
STRING(REGEX REPLACE "^.*-ndb-" "" NDBVERSION "${VERSION}")
SET(SPECFILENAME "mysql-cluster-${NDBVERSION}.spec")
ENDIF()
# Left in current directory, to be taken during build
CONFIGURE_FILE(mysql.spec.sh ${CMAKE_CURRENT_BINARY_DIR}/${SPECFILENAME} @ONLY)
FOREACH(ulnfile filter-requires-mysql.sh generate-tarball.sh my.cnf my_config.h
mysql-5.5-errno.patch mysql-5.5-fix-tests.patch mysql-5.5-libdir.patch
mysql-5.5-mtr1.patch mysql-5.5-stack-guard.patch mysql-5.5-testing.patch
mysql-chain-certs.patch mysql-embedded-check.c mysql-expired-certs.patch
mysql.init mysql-install-test.patch mysql-strmov.patch scriptstub.c
README.mysql-docs)
CONFIGURE_FILE(${ulnfile} ${CMAKE_CURRENT_BINARY_DIR}/${ulnfile} COPYONLY)
ENDFOREACH()
ENDIF()
In order to have RPMs of MySQL which are distributed via ULN for Oracle Linux
to be as closely compatible to such RPMs built and distributed by RedHat,
this directory contains additional files which originated at RedHat
and are used only for such RPMs intended for distribution via ULN.
Especially, this directory contains the spec file used to build these RPMs,
named "mysql.spec". Please regard the following note:
You are receiving a copy of the Red Hat spec file.
The terms of the Oracle license do NOT apply to the Red Hat spec file;
it is licensed under the
GNU GENERAL PUBLIC LICENSE Version 2, June 1991
separately from the Oracle programs you receive.
The official MySQL documentation is not freely redistributable, so we cannot
include it in RHEL or Fedora. You can find it on-line at
http://dev.mysql.com/doc/
#!/bin/sh
/usr/lib/rpm/perl.req $* | grep -v -e "perl(th" -e "perl(lib::mtr" -e "perl(mtr"
#!/bin/sh
VERSION=$1
rm -rf mysql-$VERSION
tar xfz mysql-$VERSION.tar.gz || exit 1
rm mysql-$VERSION/Docs/mysql.info
tar cfz mysql-$VERSION-nodocs.tar.gz mysql-$VERSION || exit 1
rm -rf mysql-$VERSION
exit 0
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
/*
* Kluge to support multilib installation of both 32- and 64-bit RPMS:
* we need to arrange that header files that appear in both RPMs are
* identical. Hence, this file is architecture-independent and calls
* in an arch-dependent file that will appear in just one RPM.
*
* To avoid breaking arches not explicitly supported by Red Hat, we
* use this indirection file *only* on known multilib arches.
*
* Note: this may well fail if user tries to use gcc's -I- option.
* But that option is deprecated anyway.
*/
#if defined(__x86_64__)
#include "my_config_x86_64.h"
#elif defined(__i386__)
#include "my_config_i386.h"
#elif defined(__ppc64__) || defined(__powerpc64__)
#include "my_config_ppc64.h"
#elif defined(__ppc__) || defined(__powerpc__)
#include "my_config_ppc.h"
#elif defined(__s390x__)
#include "my_config_s390x.h"
#elif defined(__s390__)
#include "my_config_s390.h"
#elif defined(__sparc__) && defined(__arch64__)
#include "my_config_sparc64.h"
#elif defined(__sparc__)
#include "my_config_sparc.h"
#endif
"extern int errno" is just a really bad idea.
diff -Naur mysql-5.1.32.orig/include/my_sys.h mysql-5.1.32/include/my_sys.h
--- mysql-5.1.32.orig/include/my_sys.h 2009-02-13 19:52:19.000000000 -0500
+++ mysql-5.1.32/include/my_sys.h 2009-03-04 18:08:40.000000000 -0500
@@ -199,13 +199,8 @@
#define my_afree(PTR) my_free(PTR)
#endif /* HAVE_ALLOCA */
-#ifndef errno /* did we already get it? */
-#ifdef HAVE_ERRNO_AS_DEFINE
#include <errno.h> /* errno is a define */
-#else
-extern int errno; /* declare errno */
-#endif
-#endif /* #ifndef errno */
+
extern char *home_dir; /* Home directory for user */
extern const char *my_progname; /* program-name (printed in errors) */
extern char curr_dir[]; /* Current directory for user */
Adapt tests (where needed) to RedHat conventions.
1) The RedHat convention uses the package name "mysql*" whereas upstream uses "MySQL*".
Test "file_contents" constructs path names and needs to be adapted.
=== modified file 'mysql-test/t/file_contents.test'
--- mysql-5.5.17-orig/mysql-test/t/file_contents.test 2011-10-10 12:03:29 +0000
+++ mysql-5.5.17/mysql-test/t/file_contents.test 2011-11-16 18:07:55 +0000
@@ -17,20 +17,20 @@ if ($dir_bin =~ m|/usr/|) {
$dir_docs =~ s|/lib|/share/doc|;
if(-d "$dir_docs/packages") {
# SuSE: "packages/" in the documentation path
- $dir_docs = glob "$dir_docs/packages/MySQL-server*";
+ $dir_docs = glob "$dir_docs/packages/mysql-server*";
} else {
# RedHat: version number in directory name
- $dir_docs = glob "$dir_docs/MySQL-server*";
+ $dir_docs = glob "$dir_docs/mysql-server*";
}
} elsif ($dir_bin =~ m|/usr$|) {
# RPM build during development
$dir_docs = "$dir_bin/share/doc";
if(-d "$dir_docs/packages") {
# SuSE: "packages/" in the documentation path
- $dir_docs = glob "$dir_docs/packages/MySQL-server*";
+ $dir_docs = glob "$dir_docs/packages/mysql-server*";
} else {
# RedHat: version number in directory name
- $dir_docs = glob "$dir_docs/MySQL-server*";
+ $dir_docs = glob "$dir_docs/mysql-server*";
}
} else {
# tar.gz package, Windows, or developer work (in BZR)
The RPMs built by MySQL AB (-> Sun -> Oracle) put the libraries into "/usr/lib".
Those built by RedHat put them into "/usr/lib/mysql".
This patch is to modify the cmake files to follow the RedHat convention.
Similar, the server is now in "/usr/libexec" (formerly "/usr/sbin").
diff -Naur mysql-5.5.17.orig/cmake/install_layout.cmake mysql-5.5.17/cmake/install_layout.cmake
--- mysql-5.5.17.orig/cmake/install_layout.cmake 2011-06-30 15:46:53 +0000
+++ mysql-5.5.17/cmake/install_layout.cmake 2011-10-27 16:40:10 +0000
@@ -140,14 +140,14 @@ SET(INSTALL_SBINDIR_RPM
# be applied at build time via "rpmbuild".
#
SET(INSTALL_BINDIR_RPM "bin")
-SET(INSTALL_SBINDIR_RPM "sbin")
+SET(INSTALL_SBINDIR_RPM "libexec")
SET(INSTALL_SCRIPTDIR_RPM "bin")
#
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
- SET(INSTALL_LIBDIR_RPM "lib64")
+ SET(INSTALL_LIBDIR_RPM "lib64/mysql")
SET(INSTALL_PLUGINDIR_RPM "lib64/mysql/plugin")
ELSE()
- SET(INSTALL_LIBDIR_RPM "lib")
+ SET(INSTALL_LIBDIR_RPM "lib/mysql")
SET(INSTALL_PLUGINDIR_RPM "lib/mysql/plugin")
ENDIF()
#
Drop support for version 1 of "mysql-test-run.pl" from the RPMs:
1) The auto-generation of Perl dependencies will mishandle that code,
probably because its run directory differs from its storage location.
2) It does not provide several variables which are used in tests of MySQL 5.5
If you really need it, take it from the source tarball.
=== modified file 'mysql-test/mysql-test-run.pl'
--- mysql-5.5.17-orig/mysql-test/mysql-test-run.pl 2011-10-03 11:16:40 +0000
+++ mysql-5.5.17/mysql-test/mysql-test-run.pl 2011-11-16 19:06:38 +0000
@@ -58,10 +58,9 @@ BEGIN {
if ( $version == 1 )
{
print "=======================================================\n";
- print " WARNING: Using mysql-test-run.pl version 1! \n";
+ print " ERROR: Support for version 1 is dropped in this distribution! \n";
print "=======================================================\n";
- # Should use exec() here on *nix but this appears not to work on Windows
- exit(system($^X, "lib/v1/mysql-test-run.pl", @ARGV) >> 8);
+ exit(1);
}
elsif ( $version == 2 )
{
mysql is not accounting for the "guard page" when setting thread stack size
requests. This is fatal on PPC systems, which may use guard pages as large
as 64K. This patch also documents the IA64 situation a bit better.
Note: there are quite a few other setstacksize calls besides the two in
mysqld.cc; is it important to fix any of the others?
Filed upstream at http://bugs.mysql.com/bug.php?id=35019
diff -Naur mysql-5.1.30.orig/sql/mysqld.cc mysql-5.1.30/sql/mysqld.cc
--- mysql-5.1.30.orig/sql/mysqld.cc 2008-11-14 11:37:13.000000000 -0500
+++ mysql-5.1.30/sql/mysqld.cc 2009-01-13 12:08:35.000000000 -0500
@@ -2653,6 +2653,70 @@
}
+/* pthread_attr_setstacksize without so much platform-dependency */
+/* returns the actual stack size if possible */
+static size_t my_setstacksize(pthread_attr_t *attr, size_t stacksize)
+{
+ size_t guard_size = 0;
+
+#if defined(__ia64__) || defined(__ia64)
+ /*
+ On IA64, half of the requested stack size is used for "normal stack"
+ and half for "register stack". The space measured by check_stack_overrun
+ is the "normal stack", so double the request to make sure we have the
+ caller-expected amount of normal stack.
+
+ NOTE: there is no guarantee that the register stack can't grow faster
+ than normal stack, so it's very unclear that we won't dump core due to
+ stack overrun despite check_stack_overrun's efforts. Experimentation
+ shows that in the execution_constants test, the register stack grows
+ less than half as fast as normal stack, but perhaps other scenarios are
+ less forgiving. If it turns out that more space is needed for the
+ register stack, that could be forced (rather inefficiently) by using a
+ multiplier higher than 2 here.
+ */
+ stacksize *= 2;
+#endif
+
+ /*
+ On many machines, the "guard space" is subtracted from the requested
+ stack size, and that space is quite large on some platforms. So add
+ it to our request, if we can find out what it is.
+
+ FIXME: autoconfiscate use of pthread_attr_getguardsize
+ */
+ if (pthread_attr_getguardsize(attr, &guard_size))
+ guard_size = 0; /* if can't find it out, treat as 0 */
+
+ pthread_attr_setstacksize(attr, stacksize + guard_size);
+
+ /* Retrieve actual stack size if possible */
+#ifdef HAVE_PTHREAD_ATTR_GETSTACKSIZE
+ {
+ size_t real_stack_size= 0;
+ /* We must ignore real_stack_size = 0 as Solaris 2.9 can return 0 here */
+ if (pthread_attr_getstacksize(attr, &real_stack_size) == 0 &&
+ real_stack_size > guard_size)
+ {
+ real_stack_size -= guard_size;
+ if (real_stack_size < stacksize)
+ {
+ if (global_system_variables.log_warnings)
+ sql_print_warning("Asked for %ld thread stack, but got %ld",
+ (long) stacksize, (long) real_stack_size);
+ stacksize= real_stack_size;
+ }
+ }
+ }
+#endif
+
+#if defined(__ia64__) || defined(__ia64)
+ stacksize /= 2;
+#endif
+ return stacksize;
+}
+
+
static void start_signal_handler(void)
{
int error;
@@ -2663,15 +2727,7 @@
#if !defined(HAVE_DEC_3_2_THREADS)
pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_SYSTEM);
(void) pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED);
-#if defined(__ia64__) || defined(__ia64)
- /*
- Peculiar things with ia64 platforms - it seems we only have half the
- stack size in reality, so we have to double it here
- */
- pthread_attr_setstacksize(&thr_attr,my_thread_stack_size*2);
-#else
- pthread_attr_setstacksize(&thr_attr,my_thread_stack_size);
-#endif
+ (void) my_setstacksize(&thr_attr,my_thread_stack_size);
#endif
mysql_mutex_lock(&LOCK_thread_count);
@@ -4445,37 +4501,7 @@
unireg_abort(1); // Will do exit
init_signals();
-#if defined(__ia64__) || defined(__ia64)
- /*
- Peculiar things with ia64 platforms - it seems we only have half the
- stack size in reality, so we have to double it here
- */
- pthread_attr_setstacksize(&connection_attrib,my_thread_stack_size*2);
-#else
- pthread_attr_setstacksize(&connection_attrib,my_thread_stack_size);
-#endif
-#ifdef HAVE_PTHREAD_ATTR_GETSTACKSIZE
- {
- /* Retrieve used stack size; Needed for checking stack overflows */
- size_t stack_size= 0;
- pthread_attr_getstacksize(&connection_attrib, &stack_size);
-#if defined(__ia64__) || defined(__ia64)
- stack_size/= 2;
-#endif
- /* We must check if stack_size = 0 as Solaris 2.9 can return 0 here */
- if (stack_size && stack_size < my_thread_stack_size)
- {
- if (global_system_variables.log_warnings)
- sql_print_warning("Asked for %lu thread stack, but got %ld",
- my_thread_stack_size, (long) stack_size);
-#if defined(__ia64__) || defined(__ia64)
- my_thread_stack_size= stack_size*2;
-#else
- my_thread_stack_size= stack_size;
-#endif
- }
- }
-#endif
+ my_thread_stack_size = my_setstacksize(&connection_attrib,my_thread_stack_size);
(void) thr_setconcurrency(concurrency); // 10 by default
Hack the top-level Makefile to enable the openssl regression tests.
(Why doesn't this happen automatically given the configure option??)
Also, increase the overall timeout for the regression tests to 12 hours,
because on a slow or heavily-loaded build machine sometimes the default of
5 hours isn't enough. (This has been demonstrated to fail in mass-rebuild
scenarios, which aren't that uncommon for Fedora.) Similarly increase the
per-testcase timeout to 30 minutes, since the default of 15 hasn't got a
great deal of headroom either.
diff -Naur mysql-5.1.32.orig/Makefile.am mysql-5.1.32/Makefile.am
--- mysql-5.1.32.orig/Makefile.am 2009-02-13 19:51:56.000000000 -0500
+++ mysql-5.1.32/Makefile.am 2009-03-04 18:12:36.000000000 -0500
@@ -98,7 +98,7 @@
test-ns:
cd mysql-test ; \
- @PERL@ ./mysql-test-run.pl $(force) $(mem) --mysqld=--binlog-format=mixed
+ @PERL@ ./mysql-test-run.pl $(force) $(mem) --ssl --mysqld=--binlog-format=mixed --suite-timeout=720 --testcase-timeout=30
test-binlog-statement:
cd mysql-test ; \
Fix things so that chains of certificates work in the server and client
certificate files.
This only really works for OpenSSL-based builds, as yassl is unable to read
multiple certificates from a file. The patch below to yassl/src/ssl.cpp
doesn't fix that, but just arranges that the viosslfactories.c patch won't
have any ill effects in a yassl build. Since we don't use yassl in Red Hat/
Fedora builds, I'm not feeling motivated to try to fix yassl for this.
See RH bug #598656. Filed upstream at http://bugs.mysql.com/bug.php?id=54158
===
Joerg Bruehe, MySQL Build Team at Oracle: First patch adapted to code changes in MySQL 5.5
diff -Naur mysql-5.5.29.orig/vio/viosslfactories.c mysql-5.5.29/vio/viosslfactories.c
--- mysql-5.5.29.orig/vio/viosslfactories.c 2010-05-06 11:28:07.000000000 -0400
+++ mysql-5.5.29/vio/viosslfactories.c 2010-05-26 23:23:46.000000000 -0400
@@ -106,7 +106,7 @@
key_file= cert_file;
if (cert_file &&
- SSL_CTX_use_certificate_file(ctx, cert_file, SSL_FILETYPE_PEM) <= 0)
+ SSL_CTX_use_certificate_chain_file(ctx, cert_file) <= 0)
{
*error= SSL_INITERR_CERT;
DBUG_PRINT("error",("%s from file '%s'", sslGetErrString(*error), cert_file));
diff -Naur mysql-5.1.47.orig/extra/yassl/src/ssl.cpp mysql-5.1.47/extra/yassl/src/ssl.cpp
--- mysql-5.1.47.orig/extra/yassl/src/ssl.cpp 2010-05-06 11:24:26.000000000 -0400
+++ mysql-5.1.47/extra/yassl/src/ssl.cpp 2010-05-26 23:29:13.000000000 -0400
@@ -1606,10 +1606,10 @@
}
- int SSL_CTX_use_certificate_chain_file(SSL_CTX*, const char*)
+ int SSL_CTX_use_certificate_chain_file(SSL_CTX* ctx, const char* file)
{
- // TDOD:
- return SSL_SUCCESS;
+ // For the moment, treat like use_certificate_file
+ return read_file(ctx, file, SSL_FILETYPE_PEM, Cert);
}
/* simple test program to see if we can link the embedded server library */
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include "mysql.h"
MYSQL *mysql;
static char *server_options[] = \
{ "mysql_test", "--defaults-file=my.cnf", NULL };
int num_elements = (sizeof(server_options) / sizeof(char *)) - 1;
static char *server_groups[] = { "libmysqld_server",
"libmysqld_client", NULL };
int main(int argc, char **argv)
{
mysql_library_init(num_elements, server_options, server_groups);
mysql = mysql_init(NULL);
mysql_close(mysql);
mysql_library_end();
return 0;
}
This diff is collapsed.
Improve the documentation that will be installed in the mysql-test RPM.
diff -Naur mysql-5.1.43.orig/mysql-test/README mysql-5.1.43/mysql-test/README
--- mysql-5.1.43.orig/mysql-test/README 2010-01-15 12:14:43.000000000 -0500
+++ mysql-5.1.43/mysql-test/README 2010-02-13 21:18:06.000000000 -0500
@@ -6,6 +6,16 @@
actually have a co-existing MySQL installation. The tests will not
conflict with it.
+For use in Red Hat distributions, you should run the script as user mysql,
+so the best bet is something like
+ cd /usr/share/mysql-test
+ sudo -u mysql ./mysql-test-run
+This will use the installed mysql executables, but will run a private copy
+of the server process (using data files within /usr/share/mysql-test),
+so you need not start the mysqld service beforehand.
+To clean up afterwards, remove the created "var" subdirectory, eg
+ sudo -u mysql rm -rf /usr/share/mysql-test/var
+
All tests must pass. If one or more of them fail on your system, please
read the following manual section for instructions on how to report the
problem:
@@ -25,7 +35,8 @@
With no test cases named on the command line, mysql-test-run falls back
to the normal "non-extern" behavior. The reason for this is that some
-tests cannot run with an external server.
+tests cannot run with an external server (because they need to control the
+options with which the server is started).
You can create your own test cases. To create a test case, create a new
Remove overly optimistic definition of strmov() as stpcpy().
mysql uses this macro with overlapping source and destination strings,
which is verboten per spec, and fails on some Red Hat platforms.
Deleting the definition is sufficient to make it fall back to a
byte-at-a-time copy loop, which should consistently give the
expected behavior.
Note: the particular case that prompted this patch is reported and fixed
at http://bugs.mysql.com/bug.php?id=48864. However, my faith in upstream's
ability to detect this type of error is low, and I also see little evidence
of any real performance gain from optimizing these calls. So I'm keeping
this patch.
diff -Naur mysql-5.1.37.orig/include/m_string.h mysql-5.1.37/include/m_string.h
--- mysql-5.1.37.orig/include/m_string.h 2009-07-13 19:08:50.000000000 -0400
+++ mysql-5.1.37/include/m_string.h 2009-08-31 21:49:49.000000000 -0400
@@ -81,13 +81,6 @@
extern void *(*my_str_malloc)(size_t);
extern void (*my_str_free)(void *);
-#if defined(HAVE_STPCPY)
-#define strmov(A,B) stpcpy((A),(B))
-#ifndef stpcpy
-extern char *stpcpy(char *, const char *); /* For AIX with gcc 2.95.3 */
-#endif
-#endif
-
/* Declared in int2str() */
extern char NEAR _dig_vec_upper[];
extern char NEAR _dig_vec_lower[];
#!/bin/sh
#
# mysqld This shell script takes care of starting and stopping
# the MySQL subsystem (mysqld).
#
# chkconfig: - 64 36
# description: MySQL database server.
# processname: mysqld
# config: /etc/my.cnf
# pidfile: /var/run/mysqld/mysqld.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
exec="/usr/bin/mysqld_safe"
prog="mysqld"
# Set timeouts here so they can be overridden from /etc/sysconfig/mysqld
STARTTIMEOUT=120
STOPTIMEOUT=60
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
lockfile=/var/lock/subsys/$prog
# extract value of a MySQL option from config files
# Usage: get_mysql_option SECTION VARNAME DEFAULT
# result is returned in $result
# We use my_print_defaults which prints all options from multiple files,
# with the more specific ones later; hence take the last match.
get_mysql_option(){
result=`/usr/bin/my_print_defaults "$1" | sed -n "s/^--$2=//p" | tail -n 1`
if [ -z "$result" ]; then
# not found, use default
result="$3"
fi
}
get_mysql_option mysqld datadir "/var/lib/mysql"
datadir="$result"
get_mysql_option mysqld socket "$datadir/mysql.sock"
socketfile="$result"
get_mysql_option mysqld_safe log-error "/var/log/mysqld.log"
errlogfile="$result"
get_mysql_option mysqld_safe pid-file "/var/run/mysqld/mysqld.pid"
mypidfile="$result"
start(){
[ -x $exec ] || exit 5
# check to see if it's already running
RESPONSE=`/usr/bin/mysqladmin --socket="$socketfile" --user=UNKNOWN_MYSQL_USER ping 2>&1`
if [ $? = 0 ]; then
# already running, do nothing
action $"Starting $prog: " /bin/true
ret=0
elif echo "$RESPONSE" | grep -q "Access denied for user"
then
# already running, do nothing
action $"Starting $prog: " /bin/true
ret=0
else
# prepare for start
touch "$errlogfile"
chown mysql:mysql "$errlogfile"
chmod 0640 "$errlogfile"
[ -x /sbin/restorecon ] && /sbin/restorecon "$errlogfile"
if [ ! -d "$datadir/mysql" ] ; then
# First, make sure $datadir is there with correct permissions
if [ ! -e "$datadir" -a ! -h "$datadir" ]
then
mkdir -p "$datadir" || exit 1
fi
chown mysql:mysql "$datadir"
chmod 0755 "$datadir"
[ -x /sbin/restorecon ] && /sbin/restorecon "$datadir"
# Now create the database
action $"Initializing MySQL database: " /usr/bin/mysql_install_db --datadir="$datadir" --user=mysql
ret=$?
chown -R mysql:mysql "$datadir"
if [ $ret -ne 0 ] ; then
return $ret
fi
fi
chown mysql:mysql "$datadir"
chmod 0755 "$datadir"
# Pass all the options determined above, to ensure consistent behavior.
# In many cases mysqld_safe would arrive at the same conclusions anyway
# but we need to be sure. (An exception is that we don't force the
# log-error setting, since this script doesn't really depend on that,
# and some users might prefer to configure logging to syslog.)
# Note: set --basedir to prevent probes that might trigger SELinux
# alarms, per bug #547485
$exec --datadir="$datadir" --socket="$socketfile" \
--pid-file="$mypidfile" \
--basedir=/usr --user=mysql >/dev/null 2>&1 &
safe_pid=$!
# Spin for a maximum of N seconds waiting for the server to come up;
# exit the loop immediately if mysqld_safe process disappears.
# Rather than assuming we know a valid username, accept an "access
# denied" response as meaning the server is functioning.
ret=0
TIMEOUT="$STARTTIMEOUT"
while [ $TIMEOUT -gt 0 ]; do
RESPONSE=`/usr/bin/mysqladmin --socket="$socketfile" --user=UNKNOWN_MYSQL_USER ping 2>&1` && break
echo "$RESPONSE" | grep -q "Access denied for user" && break
if ! /bin/kill -0 $safe_pid 2>/dev/null; then
echo "MySQL Daemon failed to start."
ret=1
break
fi
sleep 1
let TIMEOUT=${TIMEOUT}-1
done
if [ $TIMEOUT -eq 0 ]; then
echo "Timeout error occurred trying to start MySQL Daemon."
ret=1
fi
if [ $ret -eq 0 ]; then
action $"Starting $prog: " /bin/true
touch $lockfile
else
action $"Starting $prog: " /bin/false
fi
fi
return $ret
}
stop(){
if [ ! -f "$mypidfile" ]; then
# not running; per LSB standards this is "ok"
action $"Stopping $prog: " /bin/true
return 0
fi
MYSQLPID=`cat "$mypidfile"`
if [ -n "$MYSQLPID" ]; then
/bin/kill "$MYSQLPID" >/dev/null 2>&1
ret=$?
if [ $ret -eq 0 ]; then
TIMEOUT="$STOPTIMEOUT"
while [ $TIMEOUT -gt 0 ]; do
/bin/kill -0 "$MYSQLPID" >/dev/null 2>&1 || break
sleep 1
let TIMEOUT=${TIMEOUT}-1
done
if [ $TIMEOUT -eq 0 ]; then
echo "Timeout error occurred trying to stop MySQL Daemon."
ret=1
action $"Stopping $prog: " /bin/false
else
rm -f $lockfile
rm -f "$socketfile"
action $"Stopping $prog: " /bin/true
fi
else
action $"Stopping $prog: " /bin/false
fi
else
# failed to read pidfile, probably insufficient permissions
action $"Stopping $prog: " /bin/false
ret=4
fi
return $ret
}
restart(){
stop
start
}
condrestart(){
[ -e $lockfile ] && restart || :
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p "$mypidfile" $prog
;;
restart)
restart
;;
condrestart|try-restart)
condrestart
;;
reload)
exit 3
;;
force-reload)
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
exit $?
This diff is collapsed.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
/* Translate call of myself into call of same-named script in LIBDIR */
/* The macro LIBDIR must be defined as a double-quoted string */
int main (int argc, char **argv)
{
char *basename;
char *fullname;
char **newargs;
int i;
basename = strrchr(argv[0], '/');
if (basename)
basename++;
else
basename = argv[0];
fullname = malloc(strlen(LIBDIR) + strlen(basename) + 2);
sprintf(fullname, "%s/%s", LIBDIR, basename);
newargs = malloc((argc+1) * sizeof(char *));
newargs[0] = fullname;
for (i = 1; i < argc; i++)
newargs[i] = argv[i];
newargs[argc] = NULL;
execvp(fullname, newargs);
return 1;
}
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