mirror of
https://abf.rosa.ru/djam/mariadb.git
synced 2025-02-24 07:02:47 +00:00

This package in ROSA was maintained quite poorly, had only a few users and lacked such important features as running multiple instances of MySQL server (mysqld@.service) and scripts for automatic upgrade to newer versions. Also upstream has renamed libraries, now there is mysql-connector-c with devel parts. /srv/mysql is also rather strange, /var/lib/mysql is more common. Let's rebase to a well-maintained package from openSUSE. It is being done in a not released platform without any compatibility for smooth upgrades fromt he old package. The new one has a lower epoch, automatic upgrades won't be done. High epoch is not needed anymore: mysql-community has not been merged from abf.io/rosaserver to abf.io/import, and now the library in mariadb is called libmariadbclient, not libmysqlclient (but compatibility symlinks do exist), so there are no duplicated provides and so there is no need in a high epoch. This commits just imports from openSUSE's SRPM without any changes, the following one will adapt it for ROSA. It will allow to easily see the diff against the openSUSE's package to easify further syncs and contibuting back to SUSE (https://bugzilla.opensuse.org/show_bug.cgi?id=1182218)
117 lines
3.5 KiB
Text
117 lines
3.5 KiB
Text
%__mysql_test_run_dir /tmp/mysql
|
|
%__mysql_test_user dbuser
|
|
%__mysql_test_pass dbuserpass
|
|
%__mysql_test_cconf abuild-myclient.cnf
|
|
%__mysql_test_port 63306
|
|
%__mysql_test_db testdb
|
|
|
|
#
|
|
# macro: mysql_testserver_start -- start a test mysqld instance
|
|
#
|
|
# usage: %mysql_test_start -u <db_user> -p <db_user_password> -t <port> -d <db_names>
|
|
#
|
|
# db_user: user of the database (not admin of the server)
|
|
# db_user_password: his password
|
|
# db_names: name or names separated by semicolon (e. g. testhat or test1:test2)
|
|
#
|
|
|
|
%mysql_testserver_start(u:p:t:d:) \
|
|
TEST_RUN_DIR=%{__mysql_test_run_dir} \
|
|
TEST_USER="%{-u:%{-u*}}" \
|
|
if [ -z "$TEST_USER" ]; then \
|
|
TEST_USER='%{__mysql_test_user}' \
|
|
fi \
|
|
TEST_PASS="%{-p:%{-p*}}" \
|
|
if [ -z "$TEST_PASS" ]; then \
|
|
TEST_PASS='%{__mysql_test_pass}' \
|
|
fi \
|
|
TEST_PORT="%{-t:%{-t*}}" \
|
|
if [ -z "$TEST_PORT" ]; then \
|
|
TEST_PORT='%{__mysql_test_port}' \
|
|
fi \
|
|
TEST_DB="%{-d:%{-d*}}" \
|
|
if [ -z "$TEST_DB" ]; then \
|
|
TEST_DB='%{__mysql_test_db}' \
|
|
fi \
|
|
\
|
|
[ -d $TEST_RUN_DIR ] && rm -r $TEST_RUN_DIR \
|
|
mkdir -p $TEST_RUN_DIR/datadir{,-private} \
|
|
\
|
|
cat << EOF > $TEST_RUN_DIR/my.cnf \
|
|
[client] \
|
|
socket = $TEST_RUN_DIR/mysql.sock \
|
|
port = $TEST_PORT \
|
|
[mysqld] \
|
|
user = abuild \
|
|
log-error = $TEST_RUN_DIR/mysqld.log \
|
|
secure_file_priv = $TEST_RUN_DIR/datadir-private \
|
|
datadir = $TEST_RUN_DIR/datadir \
|
|
server-id = 1 \
|
|
socket = $TEST_RUN_DIR/mysql.sock \
|
|
port = $TEST_PORT \
|
|
sql_mode = '' \
|
|
EOF\
|
|
\
|
|
echo '>>> Initializing databases' \
|
|
mysql_install_db --defaults-file=$TEST_RUN_DIR/my.cnf \
|
|
\
|
|
echo '>>> Invoking mysqld' \
|
|
/usr/sbin/mysqld --defaults-file=$TEST_RUN_DIR/my.cnf& \
|
|
sleep 2 \
|
|
\
|
|
echo ">>> Creating \'$TEST_DB\' database, (credentials: $TEST_USER, $TEST_PASS)" \
|
|
mysqladmin --defaults-file=$TEST_RUN_DIR/my.cnf --user=abuild password abuildpw \
|
|
for db in `echo $TEST_DB | tr ':' ' '`; do \
|
|
mysqladmin --defaults-file=$TEST_RUN_DIR/my.cnf --user=abuild --password=abuildpw create $db \
|
|
done \
|
|
cat << EOF > $TEST_RUN_DIR/create_auth.sql \
|
|
CREATE USER '$TEST_USER'@'localhost' IDENTIFIED BY '$TEST_PASS'; \
|
|
GRANT ALL PRIVILEGES ON * . * TO '$TEST_USER'@'localhost'; \
|
|
FLUSH PRIVILEGES; \
|
|
EOF\
|
|
mysql --defaults-file=$TEST_RUN_DIR/my.cnf --user=abuild --password=abuildpw < $TEST_RUN_DIR/create_auth.sql \
|
|
%nil
|
|
|
|
#
|
|
# macro: mysql_testserver_cconf -- generate client access conf
|
|
#
|
|
# usage: %mysql_testserver_cconf -n <filename> -d <dbname>
|
|
#
|
|
# filename: filename of the configuration
|
|
# dbname: database name (only one, not multiple as in %mysql_testserver_start)
|
|
|
|
%mysql_testserver_cconf(n:d:) \
|
|
TEST_RUN_DIR=%{__mysql_test_run_dir} \
|
|
TEST_CCONF="%{-n:%{-n*}}" \
|
|
if [ -z "$TEST_CCONF" ]; then \
|
|
TEST_CCONF='%{__mysql_test_cconf}' \
|
|
fi \
|
|
TEST_DB="%{-d:%{-d*}}" \
|
|
if [ -z "$TEST_DB" ]; then \
|
|
TEST_DB='%{__mysql_test_db}' \
|
|
fi \
|
|
cat << EOF > $TEST_CCONF \
|
|
[client] \
|
|
user = $TEST_USER \
|
|
password = $TEST_PASS \
|
|
database = $TEST_DB \
|
|
socket = $TEST_RUN_DIR/mysql.sock \
|
|
port = $TEST_PORT \
|
|
EOF\
|
|
%nil
|
|
|
|
#
|
|
# macro: mysql_testserver_stop -- start a test mysqld instance
|
|
#
|
|
# usage: %mysql_test_stop
|
|
#
|
|
|
|
%mysql_testserver_stop() \
|
|
TEST_RUN_DIR=%{__mysql_test_run_dir} \
|
|
echo '>>> Shutting the mysql server down' \
|
|
cat << EOF > $TEST_RUN_DIR/shutdown.sql \
|
|
SHUTDOWN; \
|
|
EOF\
|
|
mysql --defaults-file=$TEST_RUN_DIR/my.cnf --user=abuild --password=abuildpw < $TEST_RUN_DIR/shutdown.sql \
|
|
%nil
|
|
|