diff --git a/configure.ac b/configure.ac index 58fe74f..ad723f8 100644 --- a/configure.ac +++ b/configure.ac @@ -30,6 +30,34 @@ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([no])]) AM_INIT_AUTOMAKE(1.11.1 foreign TESTS_OPTION) AM_PROG_CC_C_O +# expand_path_option $path_variable_name $default +expand_path_option() { + # The first argument is the variable *name* (not value) + ac_path_varname="$1" + + # Get the original value of the variable + ac_path_value=$(eval echo "\${${ac_path_varname}}") + + # Expand any literal variable expressions in the value so that we don't + # end up with something like '${prefix}' in #defines etc. + # + # Autoconf deliberately leaves values unexpanded to allow overriding + # the configure script choices in make commands (for example, + # "make exec_prefix=/foo install"). No longer being able to do this seems + # like no great loss. + eval ac_path_value=$(eval echo "${ac_path_value}") + + # Use (expanded) default if necessary + AS_IF([test x"${ac_path_value}" = x""], + [eval ac_path_value=$(eval echo "$2")]) + + # Require a full path + AS_CASE(["$ac_path_value"], + [/*], [eval ${ac_path_varname}="$ac_path_value"], + [*], [AC_MSG_ERROR([$ac_path_varname value "$ac_path_value" is not a full path])] + ) +} + PKG_CHECK_MODULES(glib, [glib-2.0]) PKG_CHECK_MODULES(libxml, [libxml-2.0]) @@ -164,6 +192,15 @@ AC_ARG_WITH(configdir, [ CONFIGDIR="$withval" ] ) +dnl --runstatedir is available as of autoconf 2.70 (2020-12-08). When users +dnl have an older version, they can use our --with-runstatedir. +sbd_runstatedir="" +AC_ARG_WITH([runstatedir], + [AS_HELP_STRING([--with-runstatedir=DIR], + [modifiable per-process data @<:@LOCALSTATEDIR/run@:>@ (ignored if --runstatedir is available)])], + [ sbd_runstatedir="$withval" ] +) + SBD_WATCHDOG_TIMEOUT_DEFAULT="" AC_ARG_WITH(watchdog-timeout-default, [ --with-watchdog-timeout-default=SECONDS @@ -289,32 +326,29 @@ case $exec_prefix in prefix) exec_prefix=$prefix;; esac -dnl Expand autoconf variables so that we dont end up with '${prefix}' -dnl in #defines and python scripts -dnl NOTE: Autoconf deliberately leaves them unexpanded to allow -dnl make exec_prefix=/foo install -dnl No longer being able to do this seems like no great loss to me... - -eval prefix="`eval echo ${prefix}`" -eval exec_prefix="`eval echo ${exec_prefix}`" -eval bindir="`eval echo ${bindir}`" -eval sbindir="`eval echo ${sbindir}`" -eval libexecdir="`eval echo ${libexecdir}`" -eval datadir="`eval echo ${datadir}`" -eval sysconfdir="`eval echo ${sysconfdir}`" -eval sharedstatedir="`eval echo ${sharedstatedir}`" -eval localstatedir="`eval echo ${localstatedir}`" -eval libdir="`eval echo ${libdir}`" -eval includedir="`eval echo ${includedir}`" -eval oldincludedir="`eval echo ${oldincludedir}`" -eval infodir="`eval echo ${infodir}`" -eval mandir="`eval echo ${mandir}`" +dnl Expand values of autoconf-provided directory options +expand_path_option prefix +expand_path_option exec_prefix +expand_path_option bindir +expand_path_option sbindir +expand_path_option libexecdir +expand_path_option datadir +expand_path_option sysconfdir +expand_path_option sharedstatedir +expand_path_option localstatedir +expand_path_option libdir +expand_path_option includedir +expand_path_option oldincludedir +expand_path_option infodir +expand_path_option mandir + +AS_IF([test x"${runstatedir}" = x""], [runstatedir="${sbd_runstatedir}"]) +expand_path_option runstatedir "${localstatedir}/run" +AC_SUBST(runstatedir) AC_SUBST(LIBADD_DL) dnl extra flags for dynamic linking libraries -if test x"${CONFIGDIR}" = x""; then - CONFIGDIR="${sysconfdir}/sysconfig" -fi +expand_path_option CONFIGDIR "${sysconfdir}/sysconfig" AC_SUBST(CONFIGDIR) if test x"${SBD_WATCHDOG_TIMEOUT_DEFAULT}" = x""; then diff --git a/man/Makefile.am b/man/Makefile.am index 995712d..ae4c14a 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -6,7 +6,7 @@ sbd.sysconfig.pod: ../src/sbd.sysconfig sed -r -n -e "s/^## Type: (.*)/Allows C<\1>/;t type;s/^## Default: (.*)/ defaulting to C<\1>/;t default;s/^#*(.*)=.*/=item B<\1>\n/;t variable;s/^#*//;s/^ *//;H;d;:type;h;d;:default;H;x;s/\n//;x;d;:variable;G;p" $< > $@ sbd.8.pod: sbd.8.pod.in sbd.sysconfig.pod - sed -e "s/@environment_section@//;t insert;p;d;:insert;rsbd.sysconfig.pod" $< > $@ + sed -e "s,\@runstatedir\@,$(runstatedir)," $< |sed -e "s/@environment_section@//;t insert;p;d;:insert;rsbd.sysconfig.pod" > $@ sbd.8: sbd.8.pod @POD2MAN@ -s 8 -c "STONITH Block Device" -r "SBD" -n "SBD" $< $@ diff --git a/man/sbd.8.pod.in b/man/sbd.8.pod.in index e4ad5f8..21b3834 100644 --- a/man/sbd.8.pod.in +++ b/man/sbd.8.pod.in @@ -242,7 +242,7 @@ Defaults to I. This can be used to override the default watchdog device used and should not usually be necessary. -=item B<-p> F +=item B<-p> F<@runstatedir@/sbd.pid> This option can be used to specify a pidfile for the main sbd process. diff --git a/sbd.spec b/sbd.spec index 0498db1..7a0d1fb 100644 --- a/sbd.spec +++ b/sbd.spec @@ -109,7 +109,8 @@ regression-testing sbd. export CFLAGS="$RPM_OPT_FLAGS -Wall -Werror" %configure --with-watchdog-timeout-default=%{watchdog_timeout_default} \ --with-sync-resource-startup-default=%{?with_sync_resource_startup_default:yes}%{!?with_sync_resource_startup_default:no} \ - --with-sync-resource-startup-sysconfig=%{sync_resource_startup_sysconfig} + --with-sync-resource-startup-sysconfig=%{sync_resource_startup_sysconfig} \ + --with-runstatedir=%{_rundir} make %{?_smp_mflags} ########################################################### diff --git a/src/sbd.service.in b/src/sbd.service.in index 94b0f99..a558a67 100644 --- a/src/sbd.service.in +++ b/src/sbd.service.in @@ -10,9 +10,9 @@ RefuseManualStart=true [Service] Type=forking -PIDFile=@localstatedir@/run/sbd.pid +PIDFile=@runstatedir@/sbd.pid EnvironmentFile=-@CONFIGDIR@/sbd -ExecStart=@sbindir@/sbd $SBD_OPTS -p @localstatedir@/run/sbd.pid watch +ExecStart=@sbindir@/sbd $SBD_OPTS -p @runstatedir@/sbd.pid watch ExecStop=@bindir@/kill -TERM $MAINPID # Could this benefit from exit codes for restart? diff --git a/src/sbd.sh.in b/src/sbd.sh.in index cb867f1..f6ed9a8 100644 --- a/src/sbd.sh.in +++ b/src/sbd.sh.in @@ -60,7 +60,7 @@ fi SBD_DEVS=${SBD_DEVICE%;} SBD_DEVICE_ARGS="-d ${SBD_DEVS//;/ -d }" -: ${SBD_PIDFILE:=/var/run/sbd.pid} +: ${SBD_PIDFILE:=@runstatedir@/sbd.pid} SBD_OPTS+=" -p $SBD_PIDFILE" : ${SBD_PACEMAKER:="true"} if ocf_is_true "$SBD_PACEMAKER" ; then diff --git a/src/sbd_remote.service.in b/src/sbd_remote.service.in index cfcafb5..56675b1 100644 --- a/src/sbd_remote.service.in +++ b/src/sbd_remote.service.in @@ -8,9 +8,9 @@ RefuseManualStart=true [Service] Type=forking -PIDFile=@localstatedir@/run/sbd.pid +PIDFile=@runstatedir@/sbd.pid EnvironmentFile=-@CONFIGDIR@/sbd -ExecStart=@sbindir@/sbd $SBD_OPTS -p @localstatedir@/run/sbd.pid watch +ExecStart=@sbindir@/sbd $SBD_OPTS -p @runstatedir@/sbd.pid watch ExecStop=@bindir@/kill -TERM $MAINPID # Could this benefit from exit codes for restart?