Skip to content

Commit

Permalink
build: add FENCETMPDIR for state files
Browse files Browse the repository at this point in the history
  • Loading branch information
oalbrigt committed Jul 8, 2022
1 parent bccac64 commit 1b7f3cc
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ TARFILES = $(PACKAGE_NAME)-$(VERSION).tar.bz2 \

ACLOCAL_AMFLAGS = -I m4

SUBDIRS = lib agents doc
SUBDIRS = lib agents doc systemd

.PHONY: $(SUBDIRS)

Expand All @@ -34,6 +34,7 @@ doc: agents
install-exec-local:
$(INSTALL) -d $(DESTDIR)/$(LOGDIR)
$(INSTALL) -d $(DESTDIR)/$(CLUSTERVARRUN)
$(INSTALL) -d -m 1755 $(DESTDIR)$(FENCETMPDIR)

uninstall-local:
rmdir $(DESTDIR)/$(LOGDIR) || :;
Expand Down
30 changes: 30 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,38 @@ AC_ARG_WITH([agents],
[ AGENTS_LIST="$withval" ],
[ AGENTS_LIST="all" ])

FENCETMPDIR=${localstatedir}/run/fence-agents
AC_ARG_WITH(fencetmpdir,
[ --with-fencetmpdir=DIR directory for fence agents state files [${FENCETMPDIR}]],
[ FENCETMPDIR="$withval" ])

# Expand $prefix
eval FENCETMPDIR="`eval echo ${FENCETMPDIR}`"
AC_DEFINE_UNQUOTED(FENCETMPDIR,"$FENCETMPDIR", Where Fence agents keep state files)
AC_SUBST(FENCETMPDIR)


if test "x$AGENTS_LIST" = x; then
AC_ERROR([No agents selected])
fi

# PKG_CHECK_MODULES will fail if systemd is not found by default, so make sure
# we set the proper vars and deal with it
PKG_CHECK_MODULES([systemd], [systemd], [HAS_SYSTEMD=yes], [HAS_SYSTEMD=no])
if test "x$HAS_SYSTEMD" == "xyes"; then
PKG_CHECK_VAR([SYSTEMD_TMPFILES_DIR], [systemd], [tmpfilesdir])
if test "x$SYSTEMD_TMPFILES_DIR" == "x"; then
AC_MSG_ERROR([Unable to detect systemd tmpfiles directory automatically])
fi

# sanitize systed vars when using non standard prefix
if test "$prefix" != "/usr"; then
SYSTEMD_TMPFILES_DIR="$prefix/$SYSTEMD_TMPFILES_DIR"
AC_SUBST([SYSTEMD_TMPFILES_DIR])
fi
fi
AM_CONDITIONAL(HAVE_SYSTEMD, [test "x$HAS_SYSTEMD" == xyes ])

FENCE_KDUMP=0
if echo "$AGENTS_LIST" | grep -q -E "all|kdump"; then
case "$host_os" in
Expand Down Expand Up @@ -552,6 +580,8 @@ AC_CONFIG_FILES([Makefile
agents/Makefile
lib/Makefile
doc/Makefile
systemd/Makefile
systemd/fence-agents.conf
agents/virt/Makefile
agents/virt/config/Makefile
agents/virt/common/Makefile
Expand Down
16 changes: 15 additions & 1 deletion fence-agents.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,13 @@ sed -i.orig 's|FENCE_ZVM=1|FENCE_ZVM=0|' configure.ac
%endif

./autogen.sh
%{configure} --disable-libvirt-qmf-plugin
%{configure} \
%if %{defined _tmpfilesdir}
SYSTEMD_TMPFILES_DIR=%{_tmpfilesdir} \
--with-fencetmpdir=/run/fence-agents \
%endif
--disable-libvirt-qmf-plugin

CFLAGS="$(echo '%{optflags}')" make %{_smp_mflags}

%install
Expand Down Expand Up @@ -277,6 +283,14 @@ This package contains support files including the Python fencing library.
%{_datadir}/pkgconfig/%{name}.pc
%exclude %{_sbindir}/*
%exclude %{_mandir}/man8/*
%if %{defined _tmpfilesdir}
%{_tmpfilesdir}/%{name}.conf
%endif
%if %{defined _tmpfilesdir}
%dir %attr (1755, root, root) /run/%{name}
%else
%dir %attr (1755, root, root) %{_var}/run/%{name}
%endif

%package all
License: GPLv2+ and LGPLv2+ and ASL 2.0
Expand Down
24 changes: 24 additions & 0 deletions m4/PKG_CHECK_VAR.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
dnl -------------------------------------------
dnl Since: 0.28
dnl
dnl Retrieves the value of the pkg-config variable for the given module.
dnl
dnl Origin (declared license: GPLv2+ with less restrictive exception):
dnl https://cgit.freedesktop.org/pkg-config/tree/pkg.m4.in?h=pkg-config-0.29.1#n261
dnl (AS_VAR_COPY replaced with backward-compatible equivalent and guard
dnl to prefer system-wide variant by Jan Pokorny <[email protected]>)

m4_ifndef([PKG_CHECK_VAR],[
AC_DEFUN([PKG_CHECK_VAR],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
_PKG_CONFIG([$1], [variable="][$3]["], [$2])
dnl AS_VAR_COPY([$1], [pkg_cv_][$1])
$1=AS_VAR_GET([pkg_cv_][$1])
AS_VAR_IF([$1], [""], [$5], [$4])dnl
])dnl PKG_CHECK_VAR
])dnl m4_ifndef
1 change: 1 addition & 0 deletions make/fencebuild.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ define gen_agent_from_py
-e 's#@''LOGDIR@#${LOGDIR}#g' \
-e 's#@''SBINDIR@#${sbindir}#g' \
-e 's#@''LIBEXECDIR@#${libexecdir}#g' \
-e 's#@''FENCETMPDIR@#${FENCETMPDIR}#g' \
-e 's#@''IPMITOOL_PATH@#${IPMITOOL_PATH}#g' \
-e 's#@''OPENSTACK_PATH@#${OPENSTACK_PATH}#g' \
-e 's#@''AMTTOOL_PATH@#${AMTTOOL_PATH}#g' \
Expand Down
24 changes: 24 additions & 0 deletions systemd/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Copyright (C) 2017 Oyvind Albrigtsen
#
# 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; either version 2
# of the License, or (at your option) any later version.
#
# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#

MAINTAINERCLEANFILES = Makefile.in

if HAVE_SYSTEMD
tmpfilesdir = $(SYSTEMD_TMPFILES_DIR)
tmpfiles_DATA = fence-agents.conf
endif
1 change: 1 addition & 0 deletions systemd/fence-agents.conf.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d @FENCETMPDIR@ 1755 root root

0 comments on commit 1b7f3cc

Please sign in to comment.