-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
5,970 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
These files support the creation of a native macOS .pkg installer for MariaDB Server. | ||
|
||
This installer is intended to install a specially-built MariaDB distribution that runs independent of other things installed on the OS. See https://mariadb.com/kb/en/mariadb/installing-mariadb-server-pkg-packages-on-macos/ for more information about the behavior of the .pkg installer and the MariaDB distribution it installs. | ||
|
||
Build Instructions: | ||
|
||
The recommended build configuration is achieved by invoking cmake with these options: | ||
|
||
cmake . -DBUILD_CONFIG=mysql_release -DWITH_SSL=system -DOPENSSL_SSL_LIBRARY="/usr/local/opt/openssl/lib/libssl.a" -DOPENSSL_CRYPTO_LIBRARY="/usr/local/opt/openssl/lib/libcrypto.a" -DOPENSSL_INCLUDE_DIR="/usr/local/opt/openssl/include" -DTOKUDB_OK=0 -DWITH_JEMALLOC=no -DMYSQL_UNIX_ADDR=/usr/local/mariadb/data/mariadb.sock -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb/server -DINSTALL_MYSQLDATADIR=/usr/local/mariadb/data -DDEFAULT_SYSCONFDIR=/usr/local/mariadb/etc -DWITH_EMBEDDED_SERVER=OFF -DPLUGIN_AWS_KEY_MANAGEMENT=NO -DWITH_UNIT_TESTS=OFF -DWITH_WSREP=OFF | ||
|
||
Build the TGZ package using cmake && make package, and then point mkpkg to that archive. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<installer-gui-script minSpecVersion="1"> | ||
<title>MariaDB Server</title> | ||
<background file="MariaDB_background.png" mime-type="image/png" /> | ||
<allowed-os-versions> | ||
<os-version min="10.11.0"/> | ||
</allowed-os-versions> | ||
<domains enable_anywhere="false" enable_currentUserHome="false" enable_localSystem="true"/> | ||
<installation-check script="InstallationCheck()"/> | ||
<script> | ||
function InstallationCheck(prefix) { | ||
if (system.compareVersions(system.version.ProductVersion, '10.11.0') < 0) { | ||
my.result.message = 'Sorry, macOS Sierra (10.11) or higher is required to install this MariaDB Server package. Consider installing from Homebrew instead on earlier versions of OS X.'; | ||
my.result.type = 'Fatal'; | ||
return false; | ||
} | ||
var existing = system.run('check_for_existing_installation'); | ||
if (existing > 0) { | ||
// _err_existing_process=2 | ||
// _err_existing_tcp=4 | ||
// _err_existing_socket=8 | ||
// _err_existing_install=16 | ||
my.result.message = "Installation of MariaDB Server may interfere with, or be affected by, your existing installation. Proceed with caution."; | ||
my.result.type = 'Warning'; | ||
if (existing & 16) { my.result.message += "\n\n• There is an existing install of MariaDB Server running from /usr/local/mariadb/server. This instance will be stopped before installation proceeds." } | ||
if (existing & 2) { my.result.message += "\n\n• There is a mariadbd or mysqld process already running on this computer." } | ||
if (existing & 4) { my.result.message += "\n\n• There is a server already listening on TCP port 3306. This MariaDB Server installation will be started with networking disabled unless an existing MariaDB Server installation, stopped during the install process, is bound to that port." } | ||
if (existing & 8) { my.result.message += "\n\n• There is an existing socket file at /tmp/mysql.sock." } | ||
return false | ||
} | ||
return true; | ||
} | ||
</script> | ||
<welcome file="welcome.html" mime-type="text/html" /> | ||
<license file="license.html" mime-type="text/html" /> | ||
<conclusion file="conclusion.html" mime-type="text/html"/> | ||
<options customize="allow" require-scripts="false" allow-external-scripts="yes"/> | ||
<choices-outline> | ||
<line choice="com.mariadb.mariadb-server-files"/> | ||
<line choice="com.mariadb.mariadb-server-launchd"/> | ||
</choices-outline> | ||
<choice id="default"/> | ||
<choice id="com.mariadb.mariadb-server-files" visible="true" enabled="true" title="MariaDB Server" description="MariaDB Server and standard tools."> | ||
<pkg-ref id="com.mariadb.mariadb-server-files"/> | ||
</choice> | ||
<choice id="com.mariadb.mariadb-server-launchd" visible="true" enabled="true" title="launchd support" description="Automatically start MariaDB Server using launchd."> | ||
<pkg-ref id="com.mariadb.mariadb-server-launchd"/> | ||
</choice> | ||
<pkg-ref id="com.mariadb.mariadb-server-files" onConclusion="none">#mariadb-server-files.pkg</pkg-ref> | ||
<pkg-ref id="com.mariadb.mariadb-server-launchd" onConclusion="none">#mariadb-server-launchd.pkg</pkg-ref> | ||
</installer-gui-script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2016 MariaDB Corporation | ||
# | ||
# 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 | ||
# the Free Software Foundation; version 2 of the License. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ | ||
|
||
set -e | ||
set -x | ||
exec >>/var/log/mariadb_installer.log 2>&1 | ||
|
||
basedir=/usr/local/mariadb/server | ||
datadir=/usr/local/mariadb/data | ||
option_file=/usr/local/mariadb/etc/my.cnf | ||
|
||
# If the datadir does NOT exist, create it and bootstrap with some special sauce to remove | ||
# superfluous users and put some unix socket auth users in their place. | ||
if ! [[ -e $datadir ]] | ||
then | ||
cd "$basedir" | ||
mkdir -p "$datadir" | ||
./scripts/mysql_install_db --skip-networking --datadir="$datadir" | ||
# ./bin/mysqld --skip-networking --bootstrap --datadir="$datadir" --basedir=. <<EoSQL | ||
# delete from mysql.user; | ||
# delete from mysql.db; | ||
# flush privileges; | ||
# create user '$USER'@'localhost' identified with unix_socket; | ||
# -- grant all privileges on test.* to '$USER'@'localhost'; | ||
#EoSQL | ||
rm -f ./data/*.err | ||
fi | ||
|
||
chown -R _mysql "$datadir" | ||
|
||
|
||
# Is anything listening on port 3306 ? | ||
# If so, start MariaDB Server without networking. | ||
if nc localhost -G 2 3306 < /dev/null &>/dev/null | ||
then | ||
# | ||
if ! [[ -e $option_file ]] || | ||
! "$basedir"/bin/my_print_defaults --defaults-file="$option_file" --mysqld 2>/dev/null | | ||
grep -q skip.networking | ||
then | ||
printf '%s\n' '[server]' 'skip-networking' >> "$option_file" | ||
fi | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2016 MariaDB Corporation | ||
# | ||
# 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 | ||
# the Free Software Foundation; version 2 of the License. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ | ||
|
||
# Unload existing .plist, and stop running MariaDB Server | ||
launchctl unload /Library/LaunchDaemons/com.mariadb.server.plist | ||
|
||
mkdir -p /usr/local/mariadb | ||
|
||
symlinks=( /usr/local/mariadb/server ) | ||
|
||
# Go through the symlinks in the array and, for each one, move it to use an unused suffixed | ||
for dest in "${symlinks[@]}" | ||
do | ||
if [[ -L $dest ]] | ||
then | ||
rm "$dest" | ||
elif [[ -e $dest ]] | ||
then | ||
# look for an unused suffix to rename $dest | ||
suffix=0 | ||
while [[ -e $dest.$((++suffix)) ]]; do :; done | ||
|
||
mv "$dest" "$dest.$suffix" | ||
fi | ||
done | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
# Create a log file of the script's activities. | ||
exec >>/var/log/mariadb_installer.log 2>&1 | ||
|
||
# Load the .plist file into launchctl, which will also start MariaDB Server | ||
launchctl load /Library/LaunchDaemons/com.mariadb.server.plist | ||
|
||
# Wait 30 seconds for MariaDB Server to start | ||
i=0; while ((i++ < 30)); do pgrep mariadbd && [[ -e /usr/local/mariadb/data/mariadb.sock ]] && break; sleep 1; done | ||
|
||
/usr/local/mariadb/server/bin/mysql_upgrade | ||
|
||
# ln -sf /usr/local/mariadb/server/bin/* /usr/local/bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>Label</key> <string>com.mariadb.server</string> | ||
|
||
<key>KeepAlive</key> | ||
<dict> | ||
<key>SuccessfulExit</key> <false/> | ||
</dict> | ||
|
||
<key>ExitTimeOut</key> <integer>600</integer> | ||
<key>UserName</key> <string>_mysql</string> | ||
<key>GroupName</key> <string>_mysql</string> | ||
|
||
<key>WorkingDirectory</key> <string>/usr/local/mariadb/data</string> | ||
<key>Program</key> <string>/usr/local/mariadb/server/bin/mariadbd</string> | ||
<key>ProgramArguments</key> | ||
<array> | ||
<string>/usr/local/mariadb/server/bin/mariadbd</string> | ||
<string>--user=_mysql</string> | ||
<string>--basedir=/usr/local/mariadb/server</string> | ||
<string>--datadir=/usr/local/mariadb/data</string> | ||
<string>--log-basename=mariadb</string> | ||
<string>--plugin-dir=/usr/local/mariadb/server/lib/plugin</string> | ||
</array> | ||
<key>EnvironmentVariables</key> | ||
<dict> | ||
<key>MYSQL_HOME</key> <string>/usr/local/mariadb</string> | ||
</dict> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script takes an existing .tar.gz package of MariaDB Server and morphs it into | ||
# a macOS .pkg installer. The server should be built using some specific CMake options | ||
# outlined in the README file in this source tree for the package to work correctly! | ||
|
||
# This script builds two packages: mariadb-server-files and mariadb-server-launchd, | ||
# and then it combines them together into a single, installable .pkg file. | ||
# The script was originally developed by Kolbe Kegel (https://github.com/kolbe). | ||
|
||
set -ex | ||
|
||
if ! (($# == 1)) | ||
then | ||
echo "Must provide path to MariaDB Server .tar.gz package. Aborting." >&2 | ||
exit 1 | ||
fi | ||
|
||
file=$1 | ||
dir="${file%*.tar.gz}" | ||
dir="${dir##*/}" | ||
|
||
re='mariadb-([0-9]+\.[0-9]+\.[0-9]+)-' | ||
[[ $dir =~ $re ]] | ||
ver=${BASH_REMATCH[1]} | ||
|
||
mkdir -p mariadb-server-files tmp | ||
rm -rf mariadb-server-files/* tmp/* | ||
|
||
tar -xf "$file" -C mariadb-server-files/ | ||
|
||
pushd "mariadb-server-files" | ||
pushd "$dir" | ||
|
||
pushd bin | ||
|
||
# Create these symlinks, so that MariaDB Server is started using "mariadbd" instead | ||
# of "mysqld" and the client program is "mariadb" instead of "mysql". | ||
#ln -s mysql mariadb | ||
#ln -s mysqld mariadbd | ||
|
||
popd | ||
popd | ||
|
||
ln -s "$dir" server | ||
|
||
# Create the etc dir so that it's "installed" by the installer. | ||
mkdir etc | ||
|
||
popd | ||
|
||
pkgbuild --root ./mariadb-server-files --identifier com.mariadb.mariadb-server-files --scripts ./mariadb-server-files-scripts --version "${ver//./}0" --install-location /usr/local/mariadb mariadb-server-files.pkg | ||
|
||
pkgbuild --root ./mariadb-server-launchd --identifier com.mariadb.mariadb-server-launchd --scripts ./mariadb-server-launchd-scripts --install-location /Library/LaunchDaemons mariadb-server-launchd.pkg | ||
|
||
productbuild --distribution distribution.xml --resources ./resources --scripts ./resources/scripts "$dir.pkg" | ||
|
||
mv mariadb-server-files.pkg mariadb-server-launchd.pkg tmp/ |
Oops, something went wrong.