Commit 3012a5d5 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-3796 various RPM problems

cmake/cpack_rpm.cmake:
  * mark all cnf files with %config(noreplace)
  * add the forgotten postun script
sql/sys_vars.cc:
  0 for a string variable means "no default. But datadir has the default value.
support-files/rpm/server-postin.sh:
  * use mysqld --help to determine the correct datadir in the presence of my.cnf files
    (better than my_print_defaults, because it considers the correct group set).
  * Only create users, and chown/chmod if it's a fresh install, not an upgrade.
  * only run mysql_install_db if datadir does not exist
parent 9ced8f2a
...@@ -64,8 +64,10 @@ SET(CPACK_RPM_SPEC_MORE_DEFINE "${CPACK_RPM_SPEC_MORE_DEFINE} ...@@ -64,8 +64,10 @@ SET(CPACK_RPM_SPEC_MORE_DEFINE "${CPACK_RPM_SPEC_MORE_DEFINE}
SET(CPACK_RPM_PACKAGE_REQUIRES "MariaDB-common") SET(CPACK_RPM_PACKAGE_REQUIRES "MariaDB-common")
SET(CPACK_RPM_server_USER_FILELIST "%ignore /etc" "%ignore /etc/init.d") SET(CPACK_RPM_server_USER_FILELIST "%ignore /etc" "%ignore /etc/init.d" "%config(noreplace) /etc/my.cnf.d/*")
SET(CPACK_RPM_common_USER_FILELIST "%config(noreplace) /etc/my.cnf") SET(CPACK_RPM_common_USER_FILELIST "%config(noreplace) /etc/my.cnf")
SET(CPACK_RPM_shared_USER_FILELIST "%config(noreplace) /etc/my.cnf.d/*")
SET(CPACK_RPM_client_USER_FILELIST "%config(noreplace) /etc/my.cnf.d/*")
SET(CPACK_RPM_client_PACKAGE_OBSOLETES "mysql-client MySQL-client MySQL-OurDelta-client") SET(CPACK_RPM_client_PACKAGE_OBSOLETES "mysql-client MySQL-client MySQL-OurDelta-client")
SET(CPACK_RPM_client_PACKAGE_PROVIDES "MariaDB-client MySQL-client mysql-client") SET(CPACK_RPM_client_PACKAGE_PROVIDES "MariaDB-client MySQL-client mysql-client")
...@@ -84,6 +86,7 @@ SET(CPACK_RPM_server_PACKAGE_PROVIDES "MariaDB MariaDB-server MySQL-server confi ...@@ -84,6 +86,7 @@ SET(CPACK_RPM_server_PACKAGE_PROVIDES "MariaDB MariaDB-server MySQL-server confi
SET(CPACK_RPM_server_PRE_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-prein.sh) SET(CPACK_RPM_server_PRE_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-prein.sh)
SET(CPACK_RPM_server_PRE_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-preun.sh) SET(CPACK_RPM_server_PRE_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-preun.sh)
SET(CPACK_RPM_server_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-postin.sh) SET(CPACK_RPM_server_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-postin.sh)
SET(CPACK_RPM_server_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-postun.sh)
SET(CPACK_RPM_shared_PACKAGE_OBSOLETES "mysql-shared MySQL-shared-standard MySQL-shared-pro MySQL-shared-pro-cert MySQL-shared-pro-gpl MySQL-shared-pro-gpl-cert MySQL-shared MySQL-OurDelta-shared") SET(CPACK_RPM_shared_PACKAGE_OBSOLETES "mysql-shared MySQL-shared-standard MySQL-shared-pro MySQL-shared-pro-cert MySQL-shared-pro-gpl MySQL-shared-pro-gpl-cert MySQL-shared MySQL-OurDelta-shared")
SET(CPACK_RPM_shared_PACKAGE_PROVIDES "MariaDB-shared MySQL-shared mysql-shared libmysqlclient.so.${SHARED_LIB_MAJOR_VERSION} libmysqlclient.so.${SHARED_LIB_MAJOR_VERSION}(libmysqlclient_${SHARED_LIB_MAJOR_VERSION}) libmysqlclient_r.so.${SHARED_LIB_MAJOR_VERSION} libmysqlclient_r.so.${SHARED_LIB_MAJOR_VERSION}(libmysqlclient_${SHARED_LIB_MAJOR_VERSION})") SET(CPACK_RPM_shared_PACKAGE_PROVIDES "MariaDB-shared MySQL-shared mysql-shared libmysqlclient.so.${SHARED_LIB_MAJOR_VERSION} libmysqlclient.so.${SHARED_LIB_MAJOR_VERSION}(libmysqlclient_${SHARED_LIB_MAJOR_VERSION}) libmysqlclient_r.so.${SHARED_LIB_MAJOR_VERSION} libmysqlclient_r.so.${SHARED_LIB_MAJOR_VERSION}(libmysqlclient_${SHARED_LIB_MAJOR_VERSION})")
......
...@@ -568,7 +568,7 @@ static Sys_var_ulong Sys_connect_timeout( ...@@ -568,7 +568,7 @@ static Sys_var_ulong Sys_connect_timeout(
static Sys_var_charptr Sys_datadir( static Sys_var_charptr Sys_datadir(
"datadir", "Path to the database root directory", "datadir", "Path to the database root directory",
READ_ONLY GLOBAL_VAR(mysql_real_data_home_ptr), READ_ONLY GLOBAL_VAR(mysql_real_data_home_ptr),
CMD_LINE(REQUIRED_ARG, 'h'), IN_FS_CHARSET, DEFAULT(0)); CMD_LINE(REQUIRED_ARG, 'h'), IN_FS_CHARSET, DEFAULT(mysql_real_data_home));
#ifndef DBUG_OFF #ifndef DBUG_OFF
static Sys_var_dbug Sys_dbug( static Sys_var_dbug Sys_dbug(
......
mysql_datadir=%{mysqldatadir}
# Create data directory
mkdir -p $mysql_datadir/{mysql,test}
# Make MySQL start/shutdown automatically when the machine does it. # Make MySQL start/shutdown automatically when the machine does it.
if [ $1 = 1 ] ; then if [ $1 = 1 ] ; then
if [ -x /sbin/chkconfig ] ; then if [ -x /sbin/chkconfig ] ; then
/sbin/chkconfig --add mysql /sbin/chkconfig --add mysql
fi fi
fi
# Create a MySQL user and group. Do not report any problems if it already mysql_dirs=(`%{_sbindir}/mysqld --verbose --help 2>/dev/null|sed -ne 's/^\(basedir\|datadir\)[[:space:]]*\(.*\)$/\2/p'`)
# exists. basedir="${mysql_dirs[0]}"
groupadd -r %{mysqld_group} 2> /dev/null || true datadir="${mysql_dirs[1]}"
useradd -M -r -d $mysql_datadir -s /bin/bash -c "MySQL server" -g %{mysqld_group} %{mysqld_user} 2> /dev/null || true # datadir may be relative to a basedir!
# The user may already exist, make sure it has the proper group nevertheless (BUG#12823) if expr $datadir : / > /dev/null; then
usermod -g %{mysqld_group} %{mysqld_user} 2> /dev/null || true mysql_datadir=$datadir
else
mysql_datadir=$basedir/$datadir
fi
# Create a MySQL user and group. Do not report any problems if it already
# exists.
groupadd -r %{mysqld_group} 2> /dev/null || true
useradd -M -r -d $mysql_datadir -s /bin/bash -c "MySQL server" -g %{mysqld_group} %{mysqld_user} 2> /dev/null || true
# The user may already exist, make sure it has the proper group nevertheless (BUG#12823)
usermod -g %{mysqld_group} %{mysqld_user} 2> /dev/null || true
# Change permissions so that the user that will run the MySQL daemon # Change permissions so that the user that will run the MySQL daemon
# owns all database files. # owns all database files.
chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir
# Initiate databases if [ ! -e $mysql_datadir ]; then
%{_bindir}/mysql_install_db --rpm --user=%{mysqld_user} # Create data directory
mkdir -p $mysql_datadir/{mysql,test}
# Upgrade databases if needed would go here - but it cannot be automated yet # Initiate databases
%{_bindir}/mysql_install_db --rpm --user=%{mysqld_user}
fi
# Change permissions again to fix any new files. # Change permissions again to fix any new files.
chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir
# Fix permissions for the permission database so that only the user # Fix permissions for the permission database so that only the user
# can read them. # can read them.
chmod -R og-rw $mysql_datadir/mysql chmod -R og-rw $mysql_datadir/mysql
fi
# install SELinux files - but don't override existing ones # install SELinux files - but don't override existing ones
SETARGETDIR=/etc/selinux/targeted/src/policy SETARGETDIR=/etc/selinux/targeted/src/policy
......
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