From 5eaeb51ae724ec750876f90bbf992e81c0f9141a Mon Sep 17 00:00:00 2001 From: Honza Horak Date: Mon, 21 Jul 2014 14:41:04 +0200 Subject: [PATCH] Expand paths in helper scripts using cmake --- ...db-check-socket => mariadb-check-socket.sh | 0 ...repare-db-dir => mariadb-prepare-db-dir.sh | 6 +-- ...cripts-common => mariadb-scripts-common.sh | 6 +-- mariadb-wait-ready => mariadb-wait-ready.sh | 4 +- mariadb.service => mariadb.service.in | 16 +++---- mariadb.spec | 46 +++++++++++-------- mariadb.tmpfiles.d | 2 - mariadb.tmpfiles.d.in | 2 + mysql_config.sh => mysql_config_multilib.sh | 8 ++-- mysqld.service | 12 ----- mysqld.service.in | 12 +++++ 11 files changed, 60 insertions(+), 54 deletions(-) rename mariadb-check-socket => mariadb-check-socket.sh (100%) rename mariadb-prepare-db-dir => mariadb-prepare-db-dir.sh (92%) rename mariadb-scripts-common => mariadb-scripts-common.sh (87%) rename mariadb-wait-ready => mariadb-wait-ready.sh (94%) rename mariadb.service => mariadb.service.in (80%) delete mode 100644 mariadb.tmpfiles.d create mode 100644 mariadb.tmpfiles.d.in rename mysql_config.sh => mysql_config_multilib.sh (69%) delete mode 100644 mysqld.service create mode 100644 mysqld.service.in diff --git a/mariadb-check-socket b/mariadb-check-socket.sh similarity index 100% rename from mariadb-check-socket rename to mariadb-check-socket.sh diff --git a/mariadb-prepare-db-dir b/mariadb-prepare-db-dir.sh similarity index 92% rename from mariadb-prepare-db-dir rename to mariadb-prepare-db-dir.sh index 3b464e9..0e574bc 100644 --- a/mariadb-prepare-db-dir +++ b/mariadb-prepare-db-dir.sh @@ -10,7 +10,7 @@ source "`dirname ${BASH_SOURCE[0]}`/mariadb-scripts-common" SERVICE_NAME="$1" if [ x"$SERVICE_NAME" = x ] then - SERVICE_NAME=mariadb.service + SERVICE_NAME=@RPM_PACKAGE_PREFIX@mariadb.service fi myuser=`systemctl show -p User "${SERVICE_NAME}" | @@ -61,11 +61,11 @@ if [ ! -d "$datadir/mysql" ] ; then # Now create the database echo "Initializing MySQL database" - /usr/bin/mysql_install_db --datadir="$datadir" --user="$myuser" + @bindir@/mysql_install_db --datadir="$datadir" --user="$myuser" ret=$? if [ $ret -ne 0 ] ; then echo "Initialization of MySQL database failed." >&2 - echo "Perhaps /etc/my.cnf is misconfigured." >&2 + echo "Perhaps @sysconfdir@/my.cnf is misconfigured." >&2 # Clean up any partially-created database files if [ ! -e "$datadir/mysql/user.frm" ] ; then rm -rf "$datadir"/* diff --git a/mariadb-scripts-common b/mariadb-scripts-common.sh similarity index 87% rename from mariadb-scripts-common rename to mariadb-scripts-common.sh index 7278350..7ce9a11 100755 --- a/mariadb-scripts-common +++ b/mariadb-scripts-common.sh @@ -38,9 +38,9 @@ get_mysql_option(){ # must correspond with values defined in mysqld_safe script and source # code itself. -server_sections="mysqld_safe mysqld server mariadb" +server_sections="mysqld_safe mysqld server mysqld-@MAJOR_VERSION@.@MINOR_VERSION@ mariadb mariadb-@MAJOR_VERSION@.@MINOR_VERSION@ client-server" -get_mysql_option "$server_sections" datadir "/var/lib/mysql" +get_mysql_option "$server_sections" datadir "@MYSQL_DATADIR@" datadir="$result" # if there is log_error in the my.cnf, my_print_defaults still @@ -50,7 +50,7 @@ datadir="$result" get_mysql_option "$server_sections" log-error "`hostname`.err" errlogfile="$result" -get_mysql_option "$server_sections" socket "/var/lib/mysql/mysql.sock" +get_mysql_option "$server_sections" socket "@MYSQL_UNIX_ADDR@" socketfile="$result" get_mysql_option "$server_sections" pid-file "`hostname`.pid" diff --git a/mariadb-wait-ready b/mariadb-wait-ready.sh similarity index 94% rename from mariadb-wait-ready rename to mariadb-wait-ready.sh index ad1392b..cf5409f 100644 --- a/mariadb-wait-ready +++ b/mariadb-wait-ready.sh @@ -11,7 +11,7 @@ source "`dirname ${BASH_SOURCE[0]}`/mariadb-scripts-common" if [ $# -ne 1 ] ; then echo "You need to pass daemon pid as an argument for this script." exit 20 -fi +fi # Service file passes us the daemon's PID (actually, mysqld_safe's PID) daemon_pid="$1" @@ -24,7 +24,7 @@ while /bin/true; do ret=1 break fi - RESPONSE=`/usr/bin/mysqladmin --no-defaults --socket="$socketfile" --user=UNKNOWN_MYSQL_USER ping 2>&1` + RESPONSE=`@bindir@/mysqladmin --no-defaults --socket="$socketfile" --user=UNKNOWN_MYSQL_USER ping 2>&1` mret=$? if [ $mret -eq 0 ] ; then break diff --git a/mariadb.service b/mariadb.service.in similarity index 80% rename from mariadb.service rename to mariadb.service.in index f938b05..82b87db 100644 --- a/mariadb.service +++ b/mariadb.service.in @@ -17,28 +17,28 @@ # [Service] # LimitNOFILE=10000 -# Note: /usr/lib/... is recommended in the .include line though /lib/... +# Note: /usr/lib/... is recommended in the .include line though /lib/... # still works. # Don't forget to reload systemd daemon after you change unit configuration: # root> systemctl --system daemon-reload [Unit] -Description=MariaDB database server +Description=MariaDB @MAJOR_VERSION@.@MINOR_VERSION@ database server After=syslog.target After=network.target -BindsTo=mysqld.service +BindsTo=@RPM_PACKAGE_PREFIX@mysqld.service [Service] Type=simple User=mysql Group=mysql -ExecStartPre=/usr/libexec/mariadb-check-socket -ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n +ExecStartPre=@libexecdir@/mariadb-check-socket +ExecStartPre=@libexecdir@/mariadb-prepare-db-dir %n # Note: we set --basedir to prevent probes that might trigger SELinux alarms, # per bug #547485 -ExecStart=/usr/bin/mysqld_safe --basedir=/usr -ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID +ExecStart=@bindir@/mysqld_safe --basedir=@prefix@ +ExecStartPost=@libexecdir@/mariadb-wait-ready $MAINPID # Give a reasonable amount of time for the server to start up/shut down TimeoutSec=300 @@ -48,4 +48,4 @@ PrivateTmp=true [Install] WantedBy=multi-user.target -Also=mysqld.service +Also=@RPM_PACKAGE_PREFIX@mysqld.service diff --git a/mariadb.spec b/mariadb.spec index 2d5f39b..1e836c2 100644 --- a/mariadb.spec +++ b/mariadb.spec @@ -68,20 +68,20 @@ URL: http://mariadb.org License: GPLv2 with exceptions and LGPLv2 and BSD Source0: http://mirrors.syringanetworks.net/mariadb/mariadb-%{version}/source/mariadb-%{version}.tar.gz -Source2: mysql_config.sh +Source2: mysql_config_multilib.sh Source3: my.cnf Source4: my_config.h Source5: README.mysql-cnf Source6: README.mysql-docs Source7: README.mysql-license Source9: mysql-embedded-check.c -Source10: mariadb.tmpfiles.d -Source11: mariadb.service -Source12: mariadb-prepare-db-dir -Source13: mariadb-wait-ready -Source14: mariadb-check-socket -Source15: mariadb-scripts-common -Source16: mysqld.service +Source10: mariadb.tmpfiles.d.in +Source11: mariadb.service.in +Source12: mariadb-prepare-db-dir.sh +Source13: mariadb-wait-ready.sh +Source14: mariadb-check-socket.sh +Source15: mariadb-scripts-common.sh +Source16: mysqld.service.in Source50: rh-skipped-tests-base.list Source51: rh-skipped-tests-intel.list Source52: rh-skipped-tests-arm.list @@ -104,6 +104,7 @@ Patch12: mariadb-covscan-stroverflow.patch Patch13: mariadb-config.patch Patch14: mariadb-ssltest.patch Patch15: mariadb-mysql_config.patch +Patch16: mariadb-scripts.patch BuildRequires: perl, readline-devel, openssl-devel BuildRequires: cmake, ncurses-devel, zlib-devel, libaio-devel @@ -335,6 +336,7 @@ MariaDB is a community developed branch of MySQL. %patch13 -p1 %patch14 -p1 %patch15 -p1 +%patch16 -p1 # workaround for upstream bug #56342 rm -f mysql-test/t/ssl_8k_key-master.opt @@ -359,6 +361,8 @@ cat %{SOURCE53} >> mysql-test/rh-skipped-tests.list cat %{SOURCE54} >> mysql-test/rh-skipped-tests.list %endif +cp %{SOURCE2} %{SOURCE10} %{SOURCE11} %{SOURCE12} %{SOURCE13} %{SOURCE14} \ + %{SOURCE15} %{SOURCE16} scripts %build @@ -401,6 +405,7 @@ export LDFLAGS cmake . -DBUILD_CONFIG=mysql_release \ -DFEATURE_SET="community" \ -DINSTALL_LAYOUT=RPM \ + -DRPM_PACKAGE_PREFIX="" \ -DRPM="%{?rhel:rhel%{rhel}}%{!?rhel:fedora%{fedora}}" \ -DCMAKE_INSTALL_PREFIX="%{_prefix}" \ %if 0%{?fedora} >= 20 @@ -510,7 +515,7 @@ mv %{buildroot}%{_includedir}/mysql/private/config.h %{buildroot}%{_includedir}/ install -p -m 644 %{SOURCE4} %{buildroot}%{_includedir}/mysql/ install -p -m 644 %{SOURCE4} %{buildroot}%{_includedir}/mysql/private/config.h mv %{buildroot}%{_bindir}/mysql_config %{buildroot}%{_bindir}/mysql_config-%{__isa_bits} -install -p -m 0755 %{SOURCE2} %{buildroot}%{_bindir}/mysql_config +install -p -m 0755 scripts/mysql_config_multilib %{buildroot}%{_bindir}/mysql_config %endif # install INFO_SRC, INFO_BIN into libdir (upstream thinks these are doc files, @@ -538,17 +543,17 @@ install -p -m 0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/ # install systemd unit files and scripts for handling server startup mkdir -p %{buildroot}%{_unitdir} -install -p -m 644 %{SOURCE11} %{buildroot}%{_unitdir}/%{name}.service +install -p -m 644 scripts/mariadb.service %{buildroot}%{_unitdir}/%{name}.service %if %{?with_mysqld_unit} -install -p -m 644 %{SOURCE16} %{buildroot}%{_unitdir}/ +install -p -m 644 scripts/mysqld.service %{buildroot}%{_unitdir}/mysqld.service %endif -install -p -m 755 %{SOURCE12} %{buildroot}%{_libexecdir}/ -install -p -m 755 %{SOURCE13} %{buildroot}%{_libexecdir}/ -install -p -m 755 %{SOURCE14} %{buildroot}%{_libexecdir}/ -install -p -m 644 %{SOURCE15} %{buildroot}%{_libexecdir}/ +install -p -m 755 scripts/mariadb-prepare-db-dir %{buildroot}%{_libexecdir}/mariadb-prepare-db-dir +install -p -m 755 scripts/mariadb-wait-ready %{buildroot}%{_libexecdir}/mariadb-wait-ready +install -p -m 755 scripts/mariadb-check-socket %{buildroot}%{_libexecdir}/mariadb-check-socket +install -p -m 644 scripts/mariadb-scripts-common %{buildroot}%{_libexecdir}/mariadb-scripts-common mkdir -p %{buildroot}%{_tmpfilesdir} -install -p -m 0644 %{SOURCE10} %{buildroot}%{_tmpfilesdir}/%{name}.conf +install -p -m 0644 scripts/mariadb.tmpfiles.d %{buildroot}%{_tmpfilesdir}/%{name}.conf # Remove libmysqld.a rm -f %{buildroot}%{_libdir}/mysql/libmysqld.a @@ -816,10 +821,10 @@ fi %{?with_mysqld_unit:%{_unitdir}/mysqld.service} %{_unitdir}/%{name}.service -%{_libexecdir}/%{basename:%{SOURCE12}} -%{_libexecdir}/%{basename:%{SOURCE13}} -%{_libexecdir}/%{basename:%{SOURCE14}} -%{_libexecdir}/%{basename:%{SOURCE15}} +%{_libexecdir}/mariadb-prepare-db-dir +%{_libexecdir}/mariadb-wait-ready +%{_libexecdir}/mariadb-check-socket +%{_libexecdir}/mariadb-scripts-common %{_tmpfilesdir}/%{name}.conf %attr(0755,mysql,mysql) %dir %{_localstatedir}/run/mysqld @@ -878,6 +883,7 @@ fi - Use modern symbol filtering with compatible backup - Add more groupnames for server's my.cnf - Error messages now provided by a separate package (thanks Alexander Barkov) +- Expand paths in helper scripts using cmake * Wed Jun 18 2014 Mikko Tiihonen - 1:10.0.12-2 - Use -fno-delete-null-pointer-checks to avoid segfaults with gcc 4.9 diff --git a/mariadb.tmpfiles.d b/mariadb.tmpfiles.d deleted file mode 100644 index fbfe4d9..0000000 --- a/mariadb.tmpfiles.d +++ /dev/null @@ -1,2 +0,0 @@ -d /var/run/mysqld 0755 mysql mysql - -d /var/run/mariadb 0755 mysql mysql - diff --git a/mariadb.tmpfiles.d.in b/mariadb.tmpfiles.d.in new file mode 100644 index 0000000..a1b20aa --- /dev/null +++ b/mariadb.tmpfiles.d.in @@ -0,0 +1,2 @@ +d /var/run/@RPM_PACKAGE_PREFIX@mysqld 0755 mysql mysql - +d /var/run/@RPM_PACKAGE_PREFIX@mariadb 0755 mysql mysql - diff --git a/mysql_config.sh b/mysql_config_multilib.sh similarity index 69% rename from mysql_config.sh rename to mysql_config_multilib.sh index 4849e95..06c2a2b 100644 --- a/mysql_config.sh +++ b/mysql_config_multilib.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # # Wrapper script for mysql_config to support multilib # @@ -17,10 +17,10 @@ if [ "$status" = "unknown" ] ; then fi -if [ -x /usr/bin/mysql_config-$bits ] ; then - /usr/bin/mysql_config-$bits "$@" +if [ -x @bindir@/mysql_config-$bits ] ; then + @bindir@/mysql_config-$bits "$@" else - echo "$0: error: needed binary: /usr/bin/mysql_config-$bits is missing" + echo "$0: error: needed binary: @bindir@/mysql_config-$bits is missing" exit 1 fi diff --git a/mysqld.service b/mysqld.service deleted file mode 100644 index fad58b7..0000000 --- a/mysqld.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=MySQL compatibility service (another name for mariadb.service; you should use mariadb.service instead) -BindsTo=mariadb.service - -[Service] -Type=oneshot -ExecStart=/bin/true -RemainAfterExit=yes - -[Install] -WantedBy=multi-user.target -Also=mariadb.service diff --git a/mysqld.service.in b/mysqld.service.in new file mode 100644 index 0000000..50f4b49 --- /dev/null +++ b/mysqld.service.in @@ -0,0 +1,12 @@ +[Unit] +Description=MySQL compatibility service (another name for @RPM_PACKAGE_PREFIX@mariadb.service; you should use @RPM_PACKAGE_PREFIX@mariadb.service instead) +BindsTo=@RPM_PACKAGE_PREFIX@mariadb.service + +[Service] +Type=oneshot +ExecStart=/bin/true +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target +Also=@RPM_PACKAGE_PREFIX@mariadb.service