diff options
author | Sergei Golubchik <sergii@pisem.net> | 2012-05-25 19:18:29 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2012-05-25 19:18:29 +0200 |
commit | be0d1179a87298a6ffc02e55a12e8e3a38d1e3c8 (patch) | |
tree | e7adb09daa8cd8309833643491694d6e99499bf5 /support-files/rpm | |
parent | 01a364a0ca31e80a5946597b6fccd96ff2fa723a (diff) | |
download | mariadb-git-be0d1179a87298a6ffc02e55a12e8e3a38d1e3c8.tar.gz |
create a new MariaDB-common.rpm that contains files needed both by the client and the server.
use my.cnf includes to split one big my.cnf file in server and client parts.
remove "Provides: mysql-libs" (doesn't help on CentOS 6)
Diffstat (limited to 'support-files/rpm')
-rw-r--r-- | support-files/rpm/client.cnf | 13 | ||||
-rw-r--r-- | support-files/rpm/my.cnf | 11 | ||||
-rw-r--r-- | support-files/rpm/mysql-clients.cnf | 23 | ||||
-rw-r--r-- | support-files/rpm/server-postin.sh | 77 | ||||
-rw-r--r-- | support-files/rpm/server-prein.sh | 73 | ||||
-rw-r--r-- | support-files/rpm/server-preun.sh | 14 | ||||
-rw-r--r-- | support-files/rpm/server.cnf | 25 | ||||
-rw-r--r-- | support-files/rpm/shared-post.sh | 1 |
8 files changed, 237 insertions, 0 deletions
diff --git a/support-files/rpm/client.cnf b/support-files/rpm/client.cnf new file mode 100644 index 00000000000..9028505a98a --- /dev/null +++ b/support-files/rpm/client.cnf @@ -0,0 +1,13 @@ +# +# These two groups are read by the client library +# Use it for options that affect all clients, but not the server +# + + +[client] + +# This group is not read by mysql client library, +# If you use the same .cnf file for MySQL and MariaDB, +# use it for MariaDB-only client options +[client-mariadb] + diff --git a/support-files/rpm/my.cnf b/support-files/rpm/my.cnf new file mode 100644 index 00000000000..913b88f8328 --- /dev/null +++ b/support-files/rpm/my.cnf @@ -0,0 +1,11 @@ +# +# This group is read both both by the client and the server +# use it for options that affect everything +# +[client-server] + +# +# include all files from the config directory +# +!includedir /etc/my.cnf.d + diff --git a/support-files/rpm/mysql-clients.cnf b/support-files/rpm/mysql-clients.cnf new file mode 100644 index 00000000000..3df9b7b955f --- /dev/null +++ b/support-files/rpm/mysql-clients.cnf @@ -0,0 +1,23 @@ +# +# These groups are read by MariaDB command-line tools +# Use it for options that affect only one utility +# + +[mysql] + +[mysql_upgrade] + +[mysqladmin] + +[mysqlbinlog] + +[mysqlcheck] + +[mysqldump] + +[mysqlimport] + +[mysqlshow] + +[mysqlslap] + diff --git a/support-files/rpm/server-postin.sh b/support-files/rpm/server-postin.sh new file mode 100644 index 00000000000..49a8253ceef --- /dev/null +++ b/support-files/rpm/server-postin.sh @@ -0,0 +1,77 @@ +mysql_datadir=%{mysqldatadir} + +# Create data directory +mkdir -p $mysql_datadir/{mysql,test} + +# Make MySQL start/shutdown automatically when the machine does it. +if [ -x /sbin/chkconfig ] ; then + /sbin/chkconfig --add mysql +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 +SETARGETDIR=/etc/selinux/targeted/src/policy +SEDOMPROG=$SETARGETDIR/domains/program +SECONPROG=$SETARGETDIR/file_contexts/program +if [ -f /etc/redhat-release ] \ + && grep -q "Red Hat Enterprise Linux .. release 4" /etc/redhat-release \ + || grep -q "CentOS release 4" /etc/redhat-release ; then + echo + echo + echo 'Notes regarding SELinux on this platform:' + echo '=========================================' + echo + echo 'The default policy might cause server startup to fail because it is ' + echo 'not allowed to access critical files. In this case, please update ' + echo 'your installation. ' + echo + echo 'The default policy might also cause inavailability of SSL related ' + echo 'features because the server is not allowed to access /dev/random ' + echo 'and /dev/urandom. If this is a problem, please do the following: ' + echo + echo ' 1) install selinux-policy-targeted-sources from your OS vendor' + echo ' 2) add the following two lines to '$SEDOMPROG/mysqld.te':' + echo ' allow mysqld_t random_device_t:chr_file read;' + echo ' allow mysqld_t urandom_device_t:chr_file read;' + echo ' 3) cd to '$SETARGETDIR' and issue the following command:' + echo ' make load' + echo + echo +fi + +if [ -x sbin/restorecon ] ; then + sbin/restorecon -R var/lib/mysql +fi + +# Restart in the same way that mysqld will be started normally. +if [ -x %{_sysconfdir}/init.d/mysql ] ; then + %{_sysconfdir}/init.d/mysql start + echo "Giving mysqld 2 seconds to start" + sleep 2 +fi + +# Allow safe_mysqld to start mysqld and print a message before we exit +sleep 2 + diff --git a/support-files/rpm/server-prein.sh b/support-files/rpm/server-prein.sh new file mode 100644 index 00000000000..0a8ac0c5f97 --- /dev/null +++ b/support-files/rpm/server-prein.sh @@ -0,0 +1,73 @@ +# Check if we can safely upgrade. An upgrade is only safe if it's from one +# of our RPMs in the same version family. + +installed=`rpm -q --whatprovides mysql-server 2> /dev/null` +if [ $? -eq 0 -a -n "$installed" ]; then + vendor=`rpm -q --queryformat='%{VENDOR}' "$installed" 2>&1` + version=`rpm -q --queryformat='%{VERSION}' "$installed" 2>&1` + myvendor='%{mysql_vendor}' + myversion='%{mysqlversion}' + + old_family=`echo $version | sed -n -e 's,^\([1-9][0-9]*\.[0-9][0-9]*\)\..*$,\1,p'` + new_family=`echo $myversion | sed -n -e 's,^\([1-9][0-9]*\.[0-9][0-9]*\)\..*$,\1,p'` + + [ -z "$vendor" ] && vendor='<unknown>' + [ -z "$old_family" ] && old_family="<unrecognized version $version>" + [ -z "$new_family" ] && new_family="<bad package specification: version $myversion>" + + error_text= + if [ "$vendor" != "$myvendor" ]; then + error_text="$error_text +The current MariaDB server package is provided by a different +vendor ($vendor) than $myvendor. Some files may be installed +to different locations, including log files and the service +startup script in %{_sysconfdir}/init.d/. +" + fi + + if [ "$old_family" != "$new_family" ]; then + error_text="$error_text +Upgrading directly from MySQL $old_family to MariaDB $new_family may not +be safe in all cases. A manual dump and restore using mysqldump is +recommended. It is important to review the MariaDB manual's Upgrading +section for version-specific incompatibilities. +" + fi + + if [ -n "$error_text" ]; then + cat <<HERE >&2 + +****************************************************************** +A MySQL or MariaDB server package ($installed) is installed. +$error_text +A manual upgrade is required. + +- Ensure that you have a complete, working backup of your data and my.cnf + files +- Shut down the MySQL server cleanly +- Remove the existing MySQL packages. Usually this command will + list the packages you should remove: + rpm -qa | grep -i '^mysql-' + + You may choose to use 'rpm --nodeps -ev <package-name>' to remove + the package which contains the mysqlclient shared library. The + library will be reinstalled by the MariaDB-shared package. +- Install the new MariaDB packages supplied by $myvendor +- Ensure that the MariaDB server is started +- Run the 'mysql_upgrade' program + +This is a brief description of the upgrade process. Important details +can be found in the MariaDB manual, in the Upgrading section. +****************************************************************** +HERE + exit 1 + fi +fi + +# Shut down a previously installed server first +if [ -x %{_sysconfdir}/init.d/mysql ] ; then + %{_sysconfdir}/init.d/mysql stop > /dev/null 2>&1 + echo "Giving mysqld 5 seconds to exit nicely" + sleep 5 +fi + diff --git a/support-files/rpm/server-preun.sh b/support-files/rpm/server-preun.sh new file mode 100644 index 00000000000..182be27f1ec --- /dev/null +++ b/support-files/rpm/server-preun.sh @@ -0,0 +1,14 @@ +if [ $1 = 0 ] ; then + # Stop MySQL before uninstalling it + if [ -x %{_sysconfdir}/init.d/mysql ] ; then + %{_sysconfdir}/init.d/mysql stop > /dev/null + # Don't start it automatically anymore + if [ -x /sbin/chkconfig ] ; then + /sbin/chkconfig --del mysql + fi + fi +fi + +# We do not remove the mysql user since it may still own a lot of +# database files. + diff --git a/support-files/rpm/server.cnf b/support-files/rpm/server.cnf new file mode 100644 index 00000000000..8cf2c74dbe4 --- /dev/null +++ b/support-files/rpm/server.cnf @@ -0,0 +1,25 @@ +# +# These groups are read by MariaDB server +# Use it for options that only the server (but not clients) should see +# +# See the examples of server my.cnf files in /usr/share/mysql/ +# + +[mysqld] + +[server] + +[embedded] + +# This group is only read by MariaDB-5.5 servers. +# If you use the same .cnf file for MariaDB of different versions, +# use this group for options that older servers don't understand +[mysqld-5.5] + +# These two groups are only read by MariaDB servers, not by MySQL. +# If you use the same .cnf file for MySQL and MariaDB, +# you can put MariaDB-only options here +[mariadb] + +[mariadb-5.5] + diff --git a/support-files/rpm/shared-post.sh b/support-files/rpm/shared-post.sh new file mode 100644 index 00000000000..8b0c822426a --- /dev/null +++ b/support-files/rpm/shared-post.sh @@ -0,0 +1 @@ +/sbin/ldconfig |