summaryrefslogtreecommitdiff
path: root/support-files
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2012-05-22 11:04:32 +0200
committerSergei Golubchik <sergii@pisem.net>2012-05-22 11:04:32 +0200
commitec586f529c871ec39556ded59206bdb813387130 (patch)
treef6121386b8b032c912bfdc30af858b3f04678f75 /support-files
parent329daad2d32730c1aade8134d1709383fe072309 (diff)
downloadmariadb-git-ec586f529c871ec39556ded59206bdb813387130.tar.gz
Building RPMs with CPack
configure with cmake -DRPM=distro
Diffstat (limited to 'support-files')
-rw-r--r--support-files/CMakeLists.txt20
-rw-r--r--support-files/rpm-ldconfig.sh1
-rw-r--r--support-files/rpm-postin.sh77
-rw-r--r--support-files/rpm-prein.sh73
-rw-r--r--support-files/rpm-preun.sh14
5 files changed, 184 insertions, 1 deletions
diff --git a/support-files/CMakeLists.txt b/support-files/CMakeLists.txt
index 3ad48520dfb..177980414ca 100644
--- a/support-files/CMakeLists.txt
+++ b/support-files/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2010, Oracle and/or its affiliates.
+# Copyright (c) 2012, Monty Program Ab
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -65,6 +66,7 @@ IF(UNIX)
ENDFOREACH()
IF(INSTALL_SUPPORTFILESDIR)
INSTALL(FILES magic DESTINATION ${inst_location} COMPONENT SupportFiles)
+ INSTALL(DIRECTORY RHEL4-SElinux/ DESTINATION ${inst_location}/SELinux/RHEL4 COMPONENT SupportFiles)
ENDIF()
INSTALL(FILES mysql.m4 DESTINATION ${INSTALL_SHAREDIR}/aclocal COMPONENT Development)
@@ -91,4 +93,20 @@ IF(UNIX)
DESTINATION ${inst_location} COMPONENT SupportFiles
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+
+ IF (INSTALL_SYSCONFDIR)
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mysql-log-rotate DESTINATION ${INSTALL_SYSCONFDIR}/logrotate.d
+ RENAME mysql COMPONENT SupportFiles)
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mysql.server
+ DESTINATION ${INSTALL_SYSCONFDIR}/init.d
+ RENAME mysql COMPONENT SupportFiles
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
+ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+ # This is for SuSE:
+ INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink
+ ${INSTALL_SYSCONFDIR}/init.d/mysql
+ ${INSTALL_SBINDIR}/rcmysql
+ WORKING_DIRECTORY \$ENV{DESTDIR}${prefix})"
+ COMPONENT SupportFiles)
+ ENDIF(INSTALL_SYSCONFDIR)
ENDIF()
diff --git a/support-files/rpm-ldconfig.sh b/support-files/rpm-ldconfig.sh
new file mode 100644
index 00000000000..8b0c822426a
--- /dev/null
+++ b/support-files/rpm-ldconfig.sh
@@ -0,0 +1 @@
+/sbin/ldconfig
diff --git a/support-files/rpm-postin.sh b/support-files/rpm-postin.sh
new file mode 100644
index 00000000000..49a8253ceef
--- /dev/null
+++ b/support-files/rpm-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-prein.sh b/support-files/rpm-prein.sh
new file mode 100644
index 00000000000..0a8ac0c5f97
--- /dev/null
+++ b/support-files/rpm-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-preun.sh b/support-files/rpm-preun.sh
new file mode 100644
index 00000000000..182be27f1ec
--- /dev/null
+++ b/support-files/rpm-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.
+