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
This commit is contained in:
parent
9ced8f2a17
commit
3012a5d5ce
@ -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
|
|||||||
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(
|
|||||||
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(
|
||||||
|
@ -1,38 +1,47 @@
|
|||||||
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
|
||||||
|
|
||||||
|
mysql_dirs=(`%{_sbindir}/mysqld --verbose --help 2>/dev/null|sed -ne 's/^\(basedir\|datadir\)[[:space:]]*\(.*\)$/\2/p'`)
|
||||||
|
basedir="${mysql_dirs[0]}"
|
||||||
|
datadir="${mysql_dirs[1]}"
|
||||||
|
# datadir may be relative to a basedir!
|
||||||
|
if expr $datadir : / > /dev/null; then
|
||||||
|
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
|
||||||
|
# owns all database files.
|
||||||
|
chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir
|
||||||
|
|
||||||
|
if [ ! -e $mysql_datadir ]; then
|
||||||
|
# Create data directory
|
||||||
|
mkdir -p $mysql_datadir/{mysql,test}
|
||||||
|
|
||||||
|
# Initiate databases
|
||||||
|
%{_bindir}/mysql_install_db --rpm --user=%{mysqld_user}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Change permissions again to fix any new files.
|
||||||
|
chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir
|
||||||
|
|
||||||
|
# Fix permissions for the permission database so that only the user
|
||||||
|
# can read them.
|
||||||
|
chmod -R og-rw $mysql_datadir/mysql
|
||||||
fi
|
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
|
|
||||||
# owns all database files.
|
|
||||||
chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir
|
|
||||||
|
|
||||||
# Initiate databases
|
|
||||||
%{_bindir}/mysql_install_db --rpm --user=%{mysqld_user}
|
|
||||||
|
|
||||||
# Upgrade databases if needed would go here - but it cannot be automated yet
|
|
||||||
|
|
||||||
# Change permissions again to fix any new files.
|
|
||||||
chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir
|
|
||||||
|
|
||||||
# Fix permissions for the permission database so that only the user
|
|
||||||
# can read them.
|
|
||||||
chmod -R og-rw $mysql_datadir/mysql
|
|
||||||
|
|
||||||
# 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
|
||||||
SEDOMPROG=$SETARGETDIR/domains/program
|
SEDOMPROG=$SETARGETDIR/domains/program
|
||||||
|
Loading…
x
Reference in New Issue
Block a user