Skip to content
Permalink
Browse files

wip rpm posttrans

  • Loading branch information...
vuvova committed Jul 12, 2019
1 parent 306474e commit f6a53ebb69f66e22f283022a262a76fb4f2b4117
Showing with 45 additions and 25 deletions.
  1. +1 −0 cmake/cpack_rpm.cmake
  2. +28 −20 scripts/mysql_install_db.sh
  3. +16 −5 support-files/rpm/server-posttrans.sh
@@ -81,6 +81,7 @@ SET(CPACK_RPM_SPEC_MORE_DEFINE "
%define mysqld_group mysql
%define _bindir ${INSTALL_BINDIRABS}
%define _sbindir ${INSTALL_SBINDIRABS}
%define _mysharedir ${INSTALL_MYSQLSHAREDIRABS}
%define _sysconfdir ${INSTALL_SYSCONFDIR}
%define restart_flag_dir %{_localstatedir}/lib/rpm-state/mariadb
%define restart_flag %{restart_flag_dir}/need-restart
@@ -96,6 +96,8 @@ Usage: $0 [OPTIONS]
user. You must be root to use this option. By default
mysqld runs using your current login name and files and
directories that it creates will be owned by you.
--sql-script=file Execute this sql script instead of the default
server initialization
All other options are passed to the mysqld program
@@ -179,6 +181,7 @@ parse_arguments()
--auth-root-socket-user=*)
auth_root_socket_user="$(parse_arg "$arg")" ;;
--skip-test-db) skip_test_db=1 ;;
--sql-script) sql_script="$(parse_arg "$arg")" ;;

*)
if test -n "$pick_args"
@@ -377,7 +380,7 @@ fill_system_tables="$srcpkgdatadir/mysql_system_tables_data.sql"
maria_add_gis_sp="$buildpkgdatadir/maria_add_gis_sp_bootstrap.sql"
mysql_test_db="$srcpkgdatadir/mysql_test_db.sql"

for f in "$fill_help_tables" "$create_system_tables" "$create_system_tables2" "$fill_system_tables" "$maria_add_gis_sp" "$mysql_test_db"
for f in "$fill_help_tables" "$create_system_tables" "$create_system_tables2" "$fill_system_tables" "$maria_add_gis_sp" "$mysql_test_db" $sql_script
do
if test ! -f "$f"
then
@@ -489,7 +492,7 @@ then
args="$args --user=$user"
fi

if test -f "$ldata/mysql/user.frm"
if test -z "$sql_script" -a -f "$ldata/mysql/user.frm"
then
echo "mysql.user table already exists!"
echo "Run mysql_upgrade, not mysql_install_db"
@@ -524,26 +527,31 @@ auth_root_socket_user=${auth_root_socket_user:-${user:-${USER:-root}}}

cat_sql()
{
echo "create database if not exists mysql;"
echo "use mysql;"
if test -z "$sql_script"
then
echo "create database if not exists mysql;"
echo "use mysql;"

case "$auth_root_authentication_method" in
normal)
echo "SET @auth_root_socket=NULL;"
;;
socket)
echo "SET @auth_root_socket='$auth_root_socket_user';"
;;
esac
case "$auth_root_authentication_method" in
normal)
echo "SET @auth_root_socket=NULL;"
;;
socket)
echo "SET @auth_root_socket='$auth_root_socket_user';"
;;
esac

cat "$create_system_tables" "$create_system_tables2" "$fill_system_tables" "$fill_help_tables" "$maria_add_gis_sp"
if test "$skip_test_db" -eq 0
then
cat "$mysql_test_db"
cat "$create_system_tables" "$create_system_tables2" "$fill_system_tables" "$fill_help_tables" "$maria_add_gis_sp"
if test "$skip_test_db" -eq 0
then
cat "$mysql_test_db"
fi
for f in "$buildpkgdatadir"/*-postin.sql; do
test -f "$f" && cat "$f"
done
else
cat $sql_script
fi
for f in "$buildpkgdatadir"/*-postin.sql; do
test -f "$f" && cat "$f"
done
}

# Create the system and help tables by passing them to "mysqld --bootstrap"
@@ -591,7 +599,7 @@ fi
# Don't output verbose information if running inside bootstrap or using
# --srcdir for testing. In such cases, there's no end user looking at
# the screen.
if test "$cross_bootstrap" -eq 0 && test -z "$srcdir"
if test "$cross_bootstrap" -eq 0 -a -z "$srcdir" -a -z "$sql_script"
then
s_echo
s_echo "To start mysqld at boot time you have to copy"
@@ -1,10 +1,21 @@
if [ -r %{restart_flag} ] ; then
rm %{restart_flag}
# only restart the server if it was alredy running
# only restart the server if it was already running
if [ -x /usr/bin/systemctl ] ; then
/usr/bin/systemctl daemon-reload > /dev/null 2>&1
/usr/bin/systemctl try-restart mariadb.service > /dev/null 2>&1
/usr/bin/systemctl daemon-reload
/usr/bin/systemctl -q is-active mariadb.service && \
START='/usr/bin/systemctl start mariadb.service'
/usr/bin/systemctl stop mariadb.service
elif %{_sysconfdir}/init.d/mysql status > /dev/null 2>&1; then
%{_sysconfdir}/init.d/mysql restart
START='%{_sysconfdir}/init.d/mysql start'
%{_sysconfdir}/init.d/mysql stop
fi
for p in `cat %{restart_flag}`; do
# if %{restart_flag} includes a plugin name it can only mean
# that a new plugin was installed. At least for now.
if test -f %{_mysharedir}/$p-postin.sql; then
%{_bindir}/mysql_install_db --rpm --user=%{mysqld_user} --sql-script=%{_mysharedir}/$p-postin.sql
fi
done
rm %{restart_flag}
$START
fi

0 comments on commit f6a53eb

Please sign in to comment.
You can’t perform that action at this time.