From 1e2d80ff8a14daad66940c4229efdbe3dbac9a3f Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 29 Mar 2007 22:47:48 +0000 Subject: [PATCH] initscript and packaging cleanups, per bugs 233771, 233731 --- my.cnf | 5 +---- mysql.init | 41 +++++++++++++++-------------------------- mysql.spec | 42 ++++++++++++++---------------------------- 3 files changed, 30 insertions(+), 58 deletions(-) diff --git a/my.cnf b/my.cnf index 2543388..2e035c8 100644 --- a/my.cnf +++ b/my.cnf @@ -1,13 +1,10 @@ [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock +user=mysql # Default to using old password format for compatibility with mysql 3.x # clients (those using the mysqlclient10 compatibility package). old_passwords=1 - -[mysql.server] -user=mysql -basedir=/var/lib [mysqld_safe] log-error=/var/log/mysqld.log diff --git a/mysql.init b/mysql.init index 4f37047..76c29f2 100644 --- a/mysql.init +++ b/mysql.init @@ -18,38 +18,26 @@ prog="MySQL" -# extract value of a MySQL option from /etc/my.cnf -# Usage: get_mysql_option FILE VARNAME DEFAULT +# extract value of a MySQL option from config files +# Usage: get_mysql_option SECTION VARNAME DEFAULT # result is returned in $result -# Ugly as this is, it knows nothing of option file sections ... +# 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=`sed -n "s/^[ \t]*$2[ \t]*=[ \t]*//p" "$1" 2>/dev/null | tail -n 1` + 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" - else - # found, still have to deal with quoting and end-of-line comments - dequoted=`echo "$result" | sed "s/^'\([^']*\)'.*$/\1/"` - if [ x"$dequoted" != x"$result" ]; then - result="$dequoted" - else - dequoted=`echo "$result" | sed 's/^"\([^"]*\)".*$/\1/'` - if [ x"$dequoted" != x"$result" ]; then - result="$dequoted" - else - result=`echo "$result" | sed 's/^\([^ \t#]*\).*$/\1/'` - fi - fi fi } -get_mysql_option /etc/my.cnf datadir "/var/lib/mysql" +get_mysql_option mysqld datadir "/var/lib/mysql" datadir="$result" -get_mysql_option /etc/my.cnf socket "$datadir/mysql.sock" +get_mysql_option mysqld socket "$datadir/mysql.sock" socketfile="$result" -get_mysql_option /etc/my.cnf log-error "/var/log/mysqld.log" +get_mysql_option mysqld_safe log-error "/var/log/mysqld.log" errlogfile="$result" -get_mysql_option /etc/my.cnf pid-file "/var/run/mysqld/mysqld.pid" +get_mysql_option mysqld_safe pid-file "/var/run/mysqld/mysqld.pid" mypidfile="$result" start(){ @@ -67,11 +55,12 @@ start(){ fi chown mysql:mysql "$datadir" chmod 0755 "$datadir" - # The reason for explicitly specifying --pid-file is that there may - # be no such entry in my.cnf, and the default behavior will be to not - # create it at all. Likewise, we specify --log-error in case there - # was not an entry in my.cnf. - /usr/bin/mysqld_safe --defaults-file=/etc/my.cnf --pid-file="$mypidfile" --log-error="$errlogfile" >/dev/null 2>&1 & + # 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. + /usr/bin/mysqld_safe --datadir="$datadir" --socket="$socketfile" \ + --log-error="$errlogfile" --pid-file="$mypidfile" \ + >/dev/null 2>&1 & ret=$? # Spin for a maximum of N seconds waiting for the server to come up. # Rather than assuming we know a valid username, accept an "access diff --git a/mysql.spec b/mysql.spec index a7c38e2..c20c2a4 100644 --- a/mysql.spec +++ b/mysql.spec @@ -1,6 +1,6 @@ Name: mysql Version: 5.0.37 -Release: 1%{?dist} +Release: 2%{?dist} Summary: MySQL client programs and shared libraries License: GPL Group: Applications/Databases @@ -70,7 +70,6 @@ License: GPL Group: Applications/Databases Prereq: /sbin/chkconfig, /usr/sbin/useradd Requires: %{name} = %{version}-%{release} -Requires: %{name}-libs = %{version}-%{release} Requires: sh-utils # mysqlhotcopy needs DBI/DBD support Requires: perl-DBI, perl-DBD-MySQL @@ -88,7 +87,6 @@ Summary: Files for development of MySQL applications License: GPL Group: Applications/Databases Requires: %{name} = %{version}-%{release} -Requires: %{name}-libs = %{version}-%{release} Requires: openssl-devel Conflicts: MySQL-devel @@ -257,6 +255,8 @@ rm -f ${RPM_BUILD_ROOT}%{_datadir}/mysql/preinstall rm -f ${RPM_BUILD_ROOT}%{_datadir}/mysql/postinstall rm -f ${RPM_BUILD_ROOT}%{_datadir}/mysql/mysql-*.spec rm -f ${RPM_BUILD_ROOT}%{_datadir}/mysql/mysql-log-rotate +rm -f ${RPM_BUILD_ROOT}%{_mandir}/man1/ndbd.1* +rm -f ${RPM_BUILD_ROOT}%{_mandir}/man1/ndb_*.1* mkdir -p $RPM_BUILD_ROOT/etc/ld.so.conf.d echo "%{_libdir}/mysql" > $RPM_BUILD_ROOT/etc/ld.so.conf.d/%{name}-%{_arch}.conf @@ -332,16 +332,16 @@ fi %{_mandir}/man1/mysqldump.1* %{_mandir}/man1/mysqlshow.1* -%dir %{_libdir}/mysql %{_libdir}/mysql/mysqlbug %{_libdir}/mysql/mysql_config -# perhaps my.cnf should be in the server package? -%config(noreplace) /etc/my.cnf - %files libs %defattr(-,root,root) +# although the default my.cnf contains only server settings, we put it in the +# libs package because it can be used for client settings too. +%config(noreplace) /etc/my.cnf + %dir %{_libdir}/mysql %{_libdir}/mysql/libmysqlclient*.so.* /etc/ld.so.conf.d/* @@ -434,29 +434,9 @@ fi %{_mandir}/man1/my_print_defaults.1* %{_mandir}/man1/mysql_tzinfo_to_sql.1* %{_mandir}/man1/mysql_install_db.1* -%{_mandir}/man1/ndb_config.1* -%{_mandir}/man1/ndb_cpcd.1* -%{_mandir}/man1/ndb_delete_all.1* -%{_mandir}/man1/ndb_desc.1* -%{_mandir}/man1/ndb_drop_index.1* -%{_mandir}/man1/ndb_drop_table.1* -%{_mandir}/man1/ndb_error_reporter.1* -%{_mandir}/man1/ndb_mgm.1* -%{_mandir}/man1/ndb_mgmd.1* -%{_mandir}/man1/ndb_print_backup_file.1* -%{_mandir}/man1/ndb_print_schema_file.1* -%{_mandir}/man1/ndb_print_sys_file.1* -%{_mandir}/man1/ndb_restore.1* -%{_mandir}/man1/ndb_select_all.1* -%{_mandir}/man1/ndb_select_count.1* -%{_mandir}/man1/ndb_show_tables.1* -%{_mandir}/man1/ndb_size.pl.1* -%{_mandir}/man1/ndb_waiter.1* -%{_mandir}/man1/ndbd.1* %{_mandir}/man8/mysqld.8* %{_mandir}/man8/mysqlmanager.8* -%dir %{_datadir}/mysql %{_datadir}/mysql/errmsg.txt %{_datadir}/mysql/fill_help_tables.sql %{_datadir}/mysql/mysql_fix_privilege_tables.sql @@ -468,7 +448,6 @@ fi %files devel %defattr(-,root,root) /usr/include/mysql -%dir %{_libdir}/mysql %{_libdir}/mysql/*.a %{_libdir}/mysql/libmysqlclient*.so @@ -482,6 +461,13 @@ fi %attr(-,mysql,mysql) %{_datadir}/mysql-test %changelog +* Thu Mar 29 2007 Tom Lane 5.0.37-2 +- Use a less hacky method of getting default values in initscript +Related: #233771, #194596 +- Improve packaging of mysql-libs per suggestions from Remi Collet +Resolves: #233731 +- Update default /etc/my.cnf ([mysql.server] has been bogus for a long time) + * Mon Mar 12 2007 Tom Lane 5.0.37-1 - Update to MySQL 5.0.37 Resolves: #231838