Blame SOURCES/mysql-paths.patch

80384c
Some hard-coded paths make problems when package is built into chroot like
80384c
Software Collections. Removing these hard-coded paths should fix it.
80384c
80384c
Upstream report: https://mariadb.atlassian.net/browse/MDEV-6485
80384c
80384c
80384c
diff -up mysql-5.6.23/client/mysql_plugin.c.hardpaths mysql-5.6.23/client/mysql_plugin.c
80384c
--- mysql-5.6.23/client/mysql_plugin.c.hardpaths	2015-01-19 14:48:30.000000000 +0100
80384c
+++ mysql-5.6.23/client/mysql_plugin.c	2015-02-23 13:34:21.328484658 +0100
80384c
@@ -90,6 +90,7 @@ static int find_plugin(char *tp_path);
80384c
 static int build_bootstrap_file(char *operation, char *bootstrap);
80384c
 static int dump_bootstrap_file(char *bootstrap_file);
80384c
 static int bootstrap_server(char *server_path, char *bootstrap_file);
80384c
+static int find_file_in_path(const char *name, char *to);
80384c
 
80384c
 
80384c
 int main(int argc,char *argv[])
80384c
@@ -121,7 +122,7 @@ int main(int argc,char *argv[])
80384c
   */
80384c
   if ((error= process_options(argc, argv, operation)) ||
80384c
       (error= check_access()) ||
80384c
-      (error= find_tool("mysqld" FN_EXEEXT, server_path)) ||
80384c
+      (error= find_file_in_path("mysqld" FN_EXEEXT, server_path)) ||
80384c
       (error= find_plugin(tp_path)) ||
80384c
       (error= build_bootstrap_file(operation, bootstrap)))
80384c
     goto exit;
80384c
@@ -324,7 +325,7 @@ static int get_default_values()
80384c
   FILE *file= 0;
80384c
 
80384c
   memset(tool_path, 0, FN_REFLEN);
80384c
-  if ((error= find_tool("my_print_defaults" FN_EXEEXT, tool_path)))
80384c
+  if ((error= find_file_in_path("my_print_defaults" FN_EXEEXT, tool_path)))
80384c
     goto exit;
80384c
   else
80384c
   {
80384c
@@ -989,6 +990,55 @@ exit:
80384c
 }
80384c
 
80384c
 
80384c
+#if defined(__WIN__)
80384c
+#define F_OK 0
80384c
+#define PATH_SEP ';'
80384c
+#define PROGRAM_EXTENSION ".exe"
80384c
+#else
80384c
+#define PATH_SEP ':'
80384c
+#endif
80384c
+
80384c
+static int find_file_in_path(const char *name, char *to)
80384c
+{
80384c
+  char *path,*pos,dir[2];
80384c
+  const char *ext="";
80384c
+
80384c
+  if (!(path=getenv("PATH")))
80384c
+    goto notfound;
80384c
+  dir[0]=FN_LIBCHAR; dir[1]=0;
80384c
+#ifdef PROGRAM_EXTENSION
80384c
+  if (!fn_ext(name)[0])
80384c
+    ext=PROGRAM_EXTENSION;
80384c
+#endif
80384c
+
80384c
+  for (pos=path ; (pos=strchr(pos,PATH_SEP)) ; path= ++pos)
80384c
+  {
80384c
+    if (path != pos)
80384c
+    {
80384c
+      strxmov(strnmov(to,path,(uint) (pos-path)),dir,name,ext,NullS);
80384c
+      if (!access(to,F_OK))
80384c
+      {
80384c
+        if (opt_verbose)
80384c
+          printf("# Found tool '%s' as '%s'.\n", name, to);
80384c
+	return 0;
80384c
+      }
80384c
+    }
80384c
+  }
80384c
+#ifdef __WIN__
80384c
+  to[0]=FN_CURLIB;
80384c
+  strxmov(to+1,dir,name,ext,NullS);
80384c
+  if (!access(to,F_OK))			/* Test in current dir */
80384c
+  {
80384c
+    if (opt_verbose)
80384c
+      printf("# Found tool '%s' as '%s'.\n", name, to);
80384c
+    return 0;
80384c
+  }
80384c
+#endif
80384c
+notfound:
80384c
+  fprintf(stderr, "WARNING: Cannot find %s.\n", name);
80384c
+  return 1;				/* File not found */
80384c
+}
80384c
+
80384c
 /**
80384c
   Locate the tool and form tool path.
80384c
 
80384c
diff -up mysql-5.6.23/cmake/install_layout.cmake.hardpaths mysql-5.6.23/cmake/install_layout.cmake
80384c
--- mysql-5.6.23/cmake/install_layout.cmake.hardpaths	2015-01-19 14:48:32.000000000 +0100
80384c
+++ mysql-5.6.23/cmake/install_layout.cmake	2015-02-23 13:34:21.330484657 +0100
80384c
@@ -94,7 +94,7 @@ IF(UNIX)
80384c
     " Choose between ${VALID_INSTALL_LAYOUTS}" )
80384c
   ENDIF()
80384c
 
80384c
-  SET(SYSCONFDIR "${CMAKE_INSTALL_PREFIX}/etc"
80384c
+  SET(SYSCONFDIR "/etc"
80384c
     CACHE PATH "config directory (for my.cnf)")
80384c
   MARK_AS_ADVANCED(SYSCONFDIR)
80384c
 ENDIF()
80384c
@@ -145,6 +145,7 @@ SET(INSTALL_PLUGINTESTDIR_STANDALONE
80384c
 SET(INSTALL_BINDIR_RPM                  "bin")
80384c
 SET(INSTALL_SBINDIR_RPM                 "sbin")
80384c
 SET(INSTALL_SCRIPTDIR_RPM               "bin")
80384c
+SET(INSTALL_SYSCONFDIR_RPM              "/etc")
80384c
 #
80384c
 IF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
80384c
   SET(INSTALL_LIBDIR_RPM                "lib64")
80384c
diff -up mysql-5.6.23/mysys_ssl/my_default.cc.hardpaths mysql-5.6.23/mysys_ssl/my_default.cc
80384c
--- mysql-5.6.23/mysys_ssl/my_default.cc.hardpaths	2015-01-19 14:48:32.000000000 +0100
80384c
+++ mysql-5.6.23/mysys_ssl/my_default.cc	2015-02-23 13:34:21.329484658 +0100
80384c
@@ -1389,12 +1389,12 @@ static const char **init_default_directo
80384c
 
80384c
 #else
80384c
 
80384c
-  errors += add_directory(alloc, "/etc/", dirs);
80384c
-  errors += add_directory(alloc, "/etc/mysql/", dirs);
80384c
-
80384c
 #if defined(DEFAULT_SYSCONFDIR)
80384c
   if (DEFAULT_SYSCONFDIR[0])
80384c
+  {
80384c
     errors += add_directory(alloc, DEFAULT_SYSCONFDIR, dirs);
80384c
+    errors += add_directory(alloc, DEFAULT_SYSCONFDIR "/mysql", dirs);
80384c
+  }
80384c
 #endif /* DEFAULT_SYSCONFDIR */
80384c
 
80384c
 #endif
80384c
diff -up mysql-5.6.23/scripts/CMakeLists.txt.hardpaths mysql-5.6.23/scripts/CMakeLists.txt
80384c
--- mysql-5.6.23/scripts/CMakeLists.txt.hardpaths	2015-02-23 13:34:21.325484657 +0100
80384c
+++ mysql-5.6.23/scripts/CMakeLists.txt	2015-02-23 13:34:21.330484657 +0100
80384c
@@ -219,7 +219,7 @@ INSTALL_SCRIPT(
80384c
   )
80384c
 
80384c
 SET(prefix "${CMAKE_INSTALL_PREFIX}")
80384c
-SET(sysconfdir ${prefix})
80384c
+SET(sysconfdir ${SYSCONFDIR})
80384c
 SET(bindir ${prefix}/${INSTALL_BINDIR})
80384c
 SET(libexecdir ${prefix}/${INSTALL_SBINDIR})
80384c
 SET(scriptdir ${prefix}/${INSTALL_BINDIR})
80384c
diff -up mysql-5.6.23/scripts/mysqlaccess.sh.hardpaths mysql-5.6.23/scripts/mysqlaccess.sh
80384c
--- mysql-5.6.23/scripts/mysqlaccess.sh.hardpaths	2015-01-19 14:48:32.000000000 +0100
80384c
+++ mysql-5.6.23/scripts/mysqlaccess.sh	2015-02-23 13:34:21.329484658 +0100
80384c
@@ -483,9 +483,6 @@ MySQLaccess::Report::Print_Header();
80384c
   elsif (-f "@sysconfdir@/$script_conf") {
80384c
      require "@sysconfdir@/$script_conf";
80384c
   }
80384c
-  elsif (-f "/etc/$script_conf") {
80384c
-     require "/etc/$script_conf";
80384c
-  }
80384c
 
80384c
 # ****************************
80384c
 # Read in all parameters
80384c
@@ -951,7 +948,6 @@ sub MergeConfigFile {
80384c
 sub MergeConfigFiles {
80384c
     my ($name,$pass,$uid,$gid,$quota,$comment,$gcos,$dir,$shell) = getpwuid $<;
80384c
     MergeConfigFile("@sysconfdir@/my.cnf");
80384c
-    MergeConfigFile("/etc/my.cnf");
80384c
     MergeConfigFile("$dir/.my.cnf");
80384c
 }
80384c
 
80384c
diff -up mysql-5.6.23/scripts/mysqld_multi.sh.hardpaths mysql-5.6.23/scripts/mysqld_multi.sh
80384c
--- mysql-5.6.23/scripts/mysqld_multi.sh.hardpaths	2015-01-19 14:48:32.000000000 +0100
80384c
+++ mysql-5.6.23/scripts/mysqld_multi.sh	2015-02-23 13:34:21.329484658 +0100
80384c
@@ -573,9 +573,7 @@ sub list_defaults_files
80384c
 
80384c
   my %seen;  # Don't list the same file more than once
80384c
   return grep { defined $_ and not $seen{$_}++ and -f $_ and -r $_ }
80384c
-              ('/etc/my.cnf',
80384c
-               '/etc/mysql/my.cnf',
80384c
-               '@sysconfdir@/my.cnf',
80384c
+              ('@sysconfdir@/my.cnf',
80384c
                ($ENV{MYSQL_HOME} ? "$ENV{MYSQL_HOME}/my.cnf" : undef),
80384c
                $opt{'extra-file'},
80384c
                ($ENV{HOME} ? "$ENV{HOME}/.my.cnf" : undef));
80384c
diff -up mysql-5.6.23/scripts/mysql_install_db.pl.in.hardpaths mysql-5.6.23/scripts/mysql_install_db.pl.in
80384c
--- mysql-5.6.23/scripts/mysql_install_db.pl.in.hardpaths	2015-02-23 13:34:37.995485386 +0100
80384c
+++ mysql-5.6.23/scripts/mysql_install_db.pl.in	2015-02-23 13:35:15.505487028 +0100
80384c
@@ -922,7 +922,7 @@ if ( open(PIPE, "| $mysqld_install_cmd_l
80384c
 	      "The new default config file was created as $copy_cfg_file,",
80384c
 	      "please compare it with your file and take the changes you need.");
80384c
     }
80384c
-    foreach my $cfg ( "/etc/my.$cnfext", "/etc/mysql/my.$cnfext" )
80384c
+    foreach my $cfg ( "@SYSCONFDIR@/my.$cnfext", "@SYSCONFDIR@/mysql/my.$cnfext" )
80384c
     {
80384c
       check_sys_cfg_file ($opt, $cfg);
80384c
     }