Skip to content

Commit

Permalink
mysql: update to 8.0.24
Browse files Browse the repository at this point in the history
Resolve nextcloud-snap#1626

Signed-off-by: Kyle Fazzari <kyrofa@ubuntu.com>
  • Loading branch information
kyrofa committed Apr 28, 2021
1 parent e32850e commit 6b4f03c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 77 deletions.
68 changes: 7 additions & 61 deletions snap/snapcraft.yaml
Expand Up @@ -325,35 +325,13 @@ parts:
# The collabora appimage requires this
- libfontconfig1

# Download the boost headers for MySQL. Note that the version used may need to
# be updated if the version of MySQL changes.
boost:
plugin: dump
source: https://github.com/kyrofa/boost_tarball/raw/master/boost_1_59_0.tar.gz
source-checksum: sha1/5123209db194d66d69a9cfa5af8ff473d5941d97
# When building MySQL, the headers in the source directory 'boost/' are
# required. Previously, using the 'copy' plugin, the whole archive was put
# under 'boost/', making the headers reside in 'boost/boost/'. Due to a bug,
# we now only stage the 'boost/' directory without moving it.
#
# Bug: https://bugs.launchpad.net/snapcraft/+bug/1757093
stage:
- boost/
prime:
- -*

mysql:
plugin: cmake
source: https://github.com/mysql/mysql-server.git
source-tag: mysql-5.7.34
source-depth: 1
override-pull: |
snapcraftctl pull
git apply $SNAPCRAFT_STAGE/mysql-support-compile-time-disabling-of-setpriority.patch
after: [boost, patches]

# Get from https://dev.mysql.com/downloads/mysql/
source: https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-boost-8.0.24.tar.gz
source-checksum: md5/e8cb8eafe07e22d5da123ffc5ca79e56
configflags:
- -DWITH_BOOST=$SNAPCRAFT_STAGE
- -DWITH_INNODB_PAGE_CLEANER_PRIORITY=OFF
- -DCMAKE_INSTALL_PREFIX=/
- -DBUILD_CONFIG=mysql_release
- -DWITH_UNIT_TESTS=OFF
Expand All @@ -363,47 +341,15 @@ parts:
- -DWITH_FEDERATED_STORAGE_ENGINE=OFF
- -DWITH_PARTITION_STORAGE_ENGINE=OFF
- -DINSTALL_MYSQLTESTDIR=
- -DDOWNLOAD_BOOST=1
- -DWITH_BOOST="$SNAPCRAFT_PART_SRC/downloaded-boost"

build-packages:
- wget
- g++
- cmake
- bison
- libncurses5-dev
- libaio-dev
stage-packages:
- libaio1
stage:
# Remove scripts that we'll be replacing with our own
- -support-files/mysql.server
- -COPYING
prime:
# Remove scripts that we'll be replacing with our own
- -support-files/mysql.server

# Remove unused binaries that waste space
- -bin/innochecksum
- -bin/lz4_decompress
- -bin/myisam*
- -bin/mysqladmin
- -bin/mysqlbinlog
- -bin/mysql_client_test
- -bin/mysql_config*
- -bin/mysqld_multi
- -bin/mysqlimport
- -bin/mysql_install_db
- -bin/mysql_plugin
- -bin/mysqlpump
- -bin/mysql_secure_installation
- -bin/mysqlshow
- -bin/mysqlslap
- -bin/mysql_ssl_rsa_setup
- -bin/mysqltest
- -bin/mysql_tzinfo_to_sql
- -bin/perror
- -bin/replace
- -bin/resolveip
- -bin/resolve_stack_dump
- -bin/zlib_decompress

# Copy over our MySQL scripts
mysql-customizations:
Expand Down
16 changes: 3 additions & 13 deletions src/mysql/bin/start_mysql
Expand Up @@ -56,7 +56,7 @@ if [ $new_install = true ]; then
ALTER USER 'root'@'localhost' IDENTIFIED BY '$root_password';
CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY '$nextcloud_password';
CREATE DATABASE nextcloud;
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost' IDENTIFIED BY '$nextcloud_password';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost';
SQL
then
# Now the root mysql user has a password. Save that as well.
Expand All @@ -75,20 +75,10 @@ else
sed -ri "s|(socket\s*=\s*)/var/snap/.*mysql.sock|\1$MYSQL_SOCKET|" "$MYSQL_ROOT_OPTION_FILE"
fi

# Wait here until mysql is running
# Wait here until mysql is running. MySQL 8 runs the upgrade automatically,
# so no need to do that, anymore.
wait_for_mysql -f

# Check and upgrade mysql tables if necessary. This will return 0 if the upgrade
# succeeded, in which case we need to restart mysql.
echo "Checking/upgrading mysql tables if necessary..."
if mysql_upgrade --defaults-file="$MYSQL_ROOT_OPTION_FILE"; then
echo "Restarting mysql server after upgrade..."
"$SNAP/support-files/mysql.server" restart

# Wait for server to come back after upgrade
wait_for_mysql -f
fi

# If this was a new installation, wait until the server is all up and running
# before saving off the nextcloud user's password. This way the presence of the
# file can be used as a signal that mysql is ready to be used.
Expand Down
6 changes: 3 additions & 3 deletions src/mysql/support-files/mysql.server
Expand Up @@ -115,7 +115,7 @@ other_args="$*" # uncommon, but needed when called from an RPM upgrade action
# Upstream mysql stuff, no need to fix this
# shellcheck disable=SC2116,SC2039
case "$(echo "testing\c")","$(echo -n testing)" in
*c*,-n*) echo_n="" echo_c="" ;;
*c*,-n*) echo_n="" echo_c="" ;;
*c*,*) echo_n=-n echo_c="" ;;
*) echo_n="" echo_c='\c' ;;
esac
Expand Down Expand Up @@ -202,7 +202,7 @@ case "$mode" in
then
# Give extra arguments to mysqld with the my.cnf file. This script
# may be overwritten at next upgrade.
"$bindir/mysqld_safe" --defaults-file="$SNAP/my.cnf" --datadir="$datadir" --pid-file="$mysqld_pid_file_path" --lc-messages-dir="$SNAP/share" --socket="$MYSQL_SOCKET" "$other_args" >/dev/null 2>&1 &
"$bindir/mysqld_safe" --defaults-file="$SNAP/my.cnf" --datadir="$datadir" --pid-file="$mysqld_pid_file_path" --lc-messages-dir="$SNAP/share" --socket="$MYSQL_SOCKET" "$other_args" >/dev/null &
wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$?

# Make lock for RedHat / SuSE
Expand Down Expand Up @@ -253,7 +253,7 @@ case "$mode" in
'restart')
# Stop the service and regardless of whether it was
# running or not, start it again.
if $0 stop "$other_args"; then
if $0 stop "$other_args"; then
$0 start "$other_args"
else
log_failure_msg "Failed to stop running server, so refusing to try to start."
Expand Down

0 comments on commit 6b4f03c

Please sign in to comment.