Hardcoded paths removed to work fine in chroot

This commit is contained in:
Honza Horak 2014-07-25 16:51:11 +02:00
parent 75032c40af
commit c48a49a6ed
7 changed files with 237 additions and 27 deletions

View File

@ -6,20 +6,39 @@ to know about this.
Recommendation they change is at http://bugs.mysql.com/bug.php?id=61425
diff -up mysql-5.6.15/mysql-test/t/file_contents.test.p19 mysql-5.6.15/mysql-test/t/file_contents.test
--- mysql-5.6.15/mysql-test/t/file_contents.test.p19 2013-12-09 18:44:48.425892516 +0100
+++ mysql-5.6.15/mysql-test/t/file_contents.test 2013-12-09 18:48:02.247150032 +0100
@@ -39,6 +39,14 @@ if ($dir_bin =~ m|/usr/|) {
diff -up mysql-5.6.19/mysql-test/t/file_contents.test.file-contents mysql-5.6.19/mysql-test/t/file_contents.test
--- mysql-5.6.19/mysql-test/t/file_contents.test.file-contents 2014-07-25 11:56:12.442153944 +0200
+++ mysql-5.6.19/mysql-test/t/file_contents.test 2014-07-25 12:00:11.578581702 +0200
@@ -11,7 +11,7 @@
--perl
print "\nChecking 'INFO_SRC' and 'INFO_BIN'\n";
$dir_bin = $ENV{'MYSQL_BINDIR'};
-if ($dir_bin =~ m|/usr/|) {
+if ($dir_bin =~ m|.*/usr/$|) {
# RPM package
$dir_docs = $dir_bin;
$dir_docs =~ s|/lib|/share/doc|;
@@ -26,7 +26,7 @@ if ($dir_bin =~ m|/usr/|) {
$dir_docs = glob "$dir_bin/share/doc/mysql-community-server*";
}
}
-} elsif ($dir_bin =~ m|/usr$|) {
+} elsif ($dir_bin =~ m|.*/usr$|) {
# RPM build during development
$dir_docs = "$dir_bin/share/doc";
if(-d "$dir_docs/packages") {
@@ -39,6 +39,15 @@ if ($dir_bin =~ m|/usr/|) {
# If not it might be ULN so try that
$dir_docs = glob "$dir_bin/share/doc/mysql-community-server*";
}
+
+ # All the above is entirely wacko, because these files are not docs;
+ # they should be kept in libdir instead. mtr does not provide a nice
+ # way to find libdir though, so we have to kluge it like this:
+ if (-d "/usr/lib64/mysql") {
+ $dir_docs = "/usr/lib64/mysql";
+ if (-d "$dir_bin/lib64/mysql") {
+ $dir_docs = "$dir_bin/lib64/mysql";
+ } else {
+ $dir_docs = "/usr/lib/mysql";
+ $dir_docs = "$dir_bin/lib/mysql";
+ }
}
} else {

View File

@ -14,21 +14,40 @@ Adjust the mysql-log-rotate script in several ways:
See discussions at RH bugs 799735, 547007
diff -up mysql-5.6.10/support-files/mysql-log-rotate.sh.orig mysql-5.6.10/support-files/mysql-log-rotate.sh
--- mysql-5.6.10/support-files/mysql-log-rotate.sh.orig 2013-01-22 17:54:50.000000000 +0100
+++ mysql-5.6.10/support-files/mysql-log-rotate.sh 2013-02-19 15:27:28.448443077 +0100
@@ -4,7 +4,7 @@
# follows:
diff -up mysql-5.6.19/support-files/mysql-log-rotate.sh.logrotate mysql-5.6.19/support-files/mysql-log-rotate.sh
--- mysql-5.6.19/support-files/mysql-log-rotate.sh.logrotate 2014-07-25 11:49:37.237448291 +0200
+++ mysql-5.6.19/support-files/mysql-log-rotate.sh 2014-07-25 11:53:17.096840857 +0200
@@ -1,14 +1,13 @@
-# The log file name and location can be set in
-# /etc/my.cnf by setting the "log-error" option
-# in either [mysqld] or [mysqld_safe] section as
-# follows:
+# This logname can be set in /etc/my.cnf
+# by setting the variable "log-error"
+# in the [mysqld_safe] section as follows:
#
# [mysqld]
-# [mysqld]
-# log-error=@localstatedir@/mysqld.log
+# log-error=/var/log/mysqld.log
+# [mysqld_safe]
+# log-error=@LOG_LOCATION@
#
# In case the root user has a password, then you
# have to create a /root/.my.cnf configuration file
@@ -19,19 +19,21 @@
# ATTENTION: The /root/.my.cnf file should be readable
# _ONLY_ by root !
-# In case the root user has a password, then you
-# have to create a /root/.my.cnf configuration file
-# with the following content:
+# If the root user has a password you have to create a
+# /root/.my.cnf configuration file with the following
+# content:
#
# [mysqladmin]
# password = <secret>
@@ -16,22 +15,24 @@
#
# where "<secret>" is the password.
#
-# ATTENTION: The /root/.my.cnf file should be readable
-# _ONLY_ by root !
+# ATTENTION: This /root/.my.cnf should be readable ONLY
+# for root !
-@localstatedir@/mysqld.log {
- # create 600 mysql mysql
@ -48,7 +67,7 @@ diff -up mysql-5.6.10/support-files/mysql-log-rotate.sh.orig mysql-5.6.10/suppor
-}
+# Then, un-comment the following lines to enable rotation of mysql's log file:
+
+#/var/log/mysqld.log {
+#@LOG_LOCATION@ {
+# create 640 mysql mysql
+# notifempty
+# daily

164
community-mysql-paths.patch Normal file
View File

@ -0,0 +1,164 @@
Some hard-coded paths make problems when package is built into chroot like
Software Collections. Removing these hard-coded paths should fix it.
Upstream report: https://mariadb.atlassian.net/browse/MDEV-6485
diff -up mysql-5.6.19/client/mysql_plugin.c.cmakepaths mysql-5.6.19/client/mysql_plugin.c
--- mysql-5.6.19/client/mysql_plugin.c.cmakepaths 2014-05-06 12:45:57.000000000 +0200
+++ mysql-5.6.19/client/mysql_plugin.c 2014-07-25 13:12:36.991896193 +0200
@@ -90,6 +90,7 @@ static int find_plugin(char *tp_path);
static int build_bootstrap_file(char *operation, char *bootstrap);
static int dump_bootstrap_file(char *bootstrap_file);
static int bootstrap_server(char *server_path, char *bootstrap_file);
+static int find_file_in_path(char *to,const char *name);
int main(int argc,char *argv[])
@@ -121,7 +122,7 @@ int main(int argc,char *argv[])
*/
if ((error= process_options(argc, argv, operation)) ||
(error= check_access()) ||
- (error= find_tool("mysqld" FN_EXEEXT, server_path)) ||
+ (error= find_file_in_path("mysqld" FN_EXEEXT, server_path)) ||
(error= find_plugin(tp_path)) ||
(error= build_bootstrap_file(operation, bootstrap)))
goto exit;
@@ -324,7 +325,7 @@ static int get_default_values()
FILE *file= 0;
memset(tool_path, 0, FN_REFLEN);
- if ((error= find_tool("my_print_defaults" FN_EXEEXT, tool_path)))
+ if ((error= find_file_in_path("my_print_defaults" FN_EXEEXT, tool_path)))
goto exit;
else
{
@@ -989,6 +990,55 @@ exit:
}
+#if defined(__WIN__)
+#define F_OK 0
+#define PATH_SEP ';'
+#define PROGRAM_EXTENSION ".exe"
+#else
+#define PATH_SEP ':'
+#endif
+
+static int find_file_in_path(char *to, const char *name)
+{
+ char *path,*pos,dir[2];
+ const char *ext="";
+
+ if (!(path=getenv("PATH")))
+ goto notfound;
+ dir[0]=FN_LIBCHAR; dir[1]=0;
+#ifdef PROGRAM_EXTENSION
+ if (!fn_ext(name)[0])
+ ext=PROGRAM_EXTENSION;
+#endif
+
+ for (pos=path ; (pos=strchr(pos,PATH_SEP)) ; path= ++pos)
+ {
+ if (path != pos)
+ {
+ strxmov(strnmov(to,path,(uint) (pos-path)),dir,name,ext,NullS);
+ if (!access(to,F_OK))
+ {
+ if (opt_verbose)
+ printf("# Found tool '%s' as '%s'.\n", name, to);
+ return 0;
+ }
+ }
+ }
+#ifdef __WIN__
+ to[0]=FN_CURLIB;
+ strxmov(to+1,dir,name,ext,NullS);
+ if (!access(to,F_OK)) /* Test in current dir */
+ {
+ if (opt_verbose)
+ printf("# Found tool '%s' as '%s'.\n", name, to);
+ return 0;
+ }
+#endif
+notfound:
+ fprintf(stderr, "WARNING: Cannot find %s.\n", name);
+ return 1; /* File not found */
+}
+
/**
Locate the tool and form tool path.
diff -up mysql-5.6.19/mysys_ssl/my_default.cc.cmakepaths mysql-5.6.19/mysys_ssl/my_default.cc
--- mysql-5.6.19/mysys_ssl/my_default.cc.cmakepaths 2014-05-06 12:45:58.000000000 +0200
+++ mysql-5.6.19/mysys_ssl/my_default.cc 2014-07-25 13:19:12.587624249 +0200
@@ -1389,12 +1389,12 @@ static const char **init_default_directo
#else
- errors += add_directory(alloc, "/etc/", dirs);
- errors += add_directory(alloc, "/etc/mysql/", dirs);
-
#if defined(DEFAULT_SYSCONFDIR)
if (DEFAULT_SYSCONFDIR[0])
+ {
errors += add_directory(alloc, DEFAULT_SYSCONFDIR, dirs);
+ errors += add_directory(alloc, DEFAULT_SYSCONFDIR "/mysql", dirs);
+ }
#endif /* DEFAULT_SYSCONFDIR */
#endif
diff -up mysql-5.6.19/scripts/mysqlaccess.sh.cmakepaths mysql-5.6.19/scripts/mysqlaccess.sh
--- mysql-5.6.19/scripts/mysqlaccess.sh.cmakepaths 2014-05-06 12:45:58.000000000 +0200
+++ mysql-5.6.19/scripts/mysqlaccess.sh 2014-07-25 13:12:36.995896200 +0200
@@ -483,9 +483,6 @@ MySQLaccess::Report::Print_Header();
elsif (-f "@sysconfdir@/$script_conf") {
require "@sysconfdir@/$script_conf";
}
- elsif (-f "/etc/$script_conf") {
- require "/etc/$script_conf";
- }
# ****************************
# Read in all parameters
@@ -951,7 +948,6 @@ sub MergeConfigFile {
sub MergeConfigFiles {
my ($name,$pass,$uid,$gid,$quota,$comment,$gcos,$dir,$shell) = getpwuid $<;
MergeConfigFile("@sysconfdir@/my.cnf");
- MergeConfigFile("/etc/my.cnf");
MergeConfigFile("$dir/.my.cnf");
}
diff -up mysql-5.6.19/scripts/mysqld_multi.sh.cmakepaths mysql-5.6.19/scripts/mysqld_multi.sh
--- mysql-5.6.19/scripts/mysqld_multi.sh.cmakepaths 2014-05-06 12:45:58.000000000 +0200
+++ mysql-5.6.19/scripts/mysqld_multi.sh 2014-07-25 13:12:36.996896202 +0200
@@ -573,9 +573,7 @@ sub list_defaults_files
my %seen; # Don't list the same file more than once
return grep { defined $_ and not $seen{$_}++ and -f $_ and -r $_ }
- ('/etc/my.cnf',
- '/etc/mysql/my.cnf',
- '@sysconfdir@/my.cnf',
+ ('@sysconfdir@/my.cnf',
($ENV{MYSQL_HOME} ? "$ENV{MYSQL_HOME}/my.cnf" : undef),
$opt{'extra-file'},
($ENV{HOME} ? "$ENV{HOME}/.my.cnf" : undef));
--- mysql-5.6.19/cmake/install_layout.cmake.cmakepaths 2014-07-25 14:21:56.063132378 +0200
+++ mysql-5.6.19/cmake/install_layout.cmake 2014-07-25 14:25:46.894644591 +0200
@@ -94,7 +94,7 @@ IF(UNIX)
" Choose between ${VALID_INSTALL_LAYOUTS}" )
ENDIF()
- SET(SYSCONFDIR "${CMAKE_INSTALL_PREFIX}/etc"
+ SET(SYSCONFDIR "/etc"
CACHE PATH "config directory (for my.cnf)")
MARK_AS_ADVANCED(SYSCONFDIR)
ENDIF()
@@ -145,6 +145,7 @@ SET(INSTALL_PLUGINTESTDIR_STANDALONE
SET(INSTALL_BINDIR_RPM "bin")
SET(INSTALL_SBINDIR_RPM "sbin")
SET(INSTALL_SCRIPTDIR_RPM "bin")
+SET(INSTALL_SYSCONFDIR_RPM "/etc")
#
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
SET(INSTALL_LIBDIR_RPM "lib64")

View File

@ -1,7 +1,7 @@
diff -rup mysql-5.6.19-orig/scripts/CMakeLists.txt mysql-5.6.19/scripts/CMakeLists.txt
--- mysql-5.6.19-orig/scripts/CMakeLists.txt 2014-07-22 10:07:12.053410263 +0200
+++ mysql-5.6.19/scripts/CMakeLists.txt 2014-07-22 10:10:44.102502369 +0200
@@ -381,6 +381,30 @@ ELSE()
@@ -381,6 +381,31 @@ ELSE()
ENDIF()
INSTALL_SCRIPT(${CMAKE_CURRENT_BINARY_DIR}/${file} COMPONENT ${${file}_COMPONENT})
ENDFOREACH()
@ -16,6 +16,7 @@ diff -rup mysql-5.6.19-orig/scripts/CMakeLists.txt mysql-5.6.19/scripts/CMakeLis
+ mysql-scripts-common
+ mysql_config_multilib
+ mysql.init
+ my.cnf
+ )
+ FOREACH(file ${SYSTEMD_SCRIPTS})
+ IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh)

View File

@ -71,7 +71,7 @@ License: GPLv2 with exceptions and LGPLv2 and BSD
Source0: https://cdn.mysql.com/Downloads/MySQL-5.6/mysql-%{version}.tar.gz
Source2: mysql_config_multilib.sh
Source3: my.cnf
Source3: my.cnf.in
Source4: my_config.h
Source6: README.mysql-docs
Source7: README.mysql-license
@ -95,6 +95,7 @@ Patch5: %{pkgname}-cipherspec.patch
Patch6: %{pkgname}-file-contents.patch
Patch7: %{pkgname}-dh1024.patch
Patch8: %{pkgname}-scripts.patch
Patch9: %{pkgname}-paths.patch
# Patches specific for this mysql package
Patch50: %{pkgname}-expired-certs.patch
@ -343,6 +344,7 @@ the MySQL sources.
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch50 -p1
%patch51 -p1
%patch52 -p1
@ -391,8 +393,8 @@ add_test 'main.upgrade : unknown'
%endif
popd
cp %{SOURCE2} %{SOURCE10} %{SOURCE11} %{SOURCE12} %{SOURCE13} %{SOURCE14} \
%{SOURCE15} %{SOURCE17} scripts
cp %{SOURCE2} %{SOURCE3} %{SOURCE10} %{SOURCE11} %{SOURCE12} %{SOURCE13} \
%{SOURCE14} %{SOURCE15} %{SOURCE17} scripts
%build
# fail quickly and obviously if user tries to build as root
@ -428,8 +430,11 @@ cmake .. -DBUILD_CONFIG=mysql_release \
-DFEATURE_SET="community" \
-DINSTALL_LAYOUT=RPM \
-DDAEMON_NAME="%{daemon_name}" \
-DLOG_LOCATION="%{logfile}" \
-DPID_FILE_DIR="%{_localstatedir}/run/%{daemon_name}" \
-DNICE_PROJECT_NAME="MySQL" \
-DCMAKE_INSTALL_PREFIX="%{_prefix}" \
-DSYSCONFDIR="%{_sysconfdir}" \
%if 0%{?fedora} >= 20
-DINSTALL_DOCDIR="share/doc/%{name}" \
-DINSTALL_DOCREADMEDIR="share/doc/%{name}" \
@ -461,6 +466,7 @@ cmake .. -DBUILD_CONFIG=mysql_release \
-DWITH_ZLIB=system \
-DCMAKE_C_FLAGS="%{optflags}" \
-DCMAKE_CXX_FLAGS="%{optflags}" \
-DTMPDIR=/var/tmp \
%{?_hardened_build:-DWITH_MYSQLD_LDFLAGS="-pie -Wl,-z,relro,-z,now"}
make %{?_smp_mflags} VERBOSE=1
@ -901,6 +907,7 @@ fi
%changelog
* Tue Jul 22 2014 Honza Horak <hhorak@redhat.com> - 5.6.19-5
- Hardcoded paths removed to work fine in chroot
- Spec rewrite to be more similar to oterh MySQL implementations
- Include SysV init script if built on older system
- Add possibility to not ship some sub-packages

View File

@ -17,8 +17,8 @@ symbolic-links=0
# /etc/my.cnf.d/server.cnf (part of mariadb-server).
# It doesn't matter that we set these settings only for [mysqld] here,
# because they will be read and used in mysqld_safe as well.
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
log-error=@LOG_LOCATION@
pid-file=@PID_FILE_DIR@/@DAEMON_NAME@.pid
[mysqld_safe]

View File

@ -1 +1 @@
d /var/run/@DAEMON_NAME@ 0755 mysql mysql -
d @PID_FILE_DIR@ 0755 mysql mysql -