File keepalived.spec of Package keepalived

# spec file for package keepalived
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

%if 0%{?suse_version} > 1210
%bcond_without systemd
%bcond_with    systemd
%bcond_with dbus

Name:           keepalived
Version:        1.3.3
Release:        0
Summary:        A strong & robust keepalive facility for linux
License:        GPL-2.0+
Group:          Productivity/Networking/Routing
# TODO: revert to old source line with 1.3.4 update
# Source:{version}.tar.gz
Source1:        keepalived.service
Source2:        keepalive-rpmlintrc
Patch1:         keepalive-init.patch
BuildRequires:  libnfnetlink-devel
BuildRequires:  net-snmp-devel
BuildRequires:  openssl-devel
BuildRequires:  pkgconfig
BuildRequires:  snmp-mibs
%if 0%{?suse_version} > 1110
BuildRequires:  pkgconfig(dbus-1)
BuildRequires:  pkgconfig(gio-2.0)
BuildRequires:  pkgconfig(libipset)
BuildRequires:  pkgconfig(libiptc)
BuildRequires:  pkgconfig(libnl-3.0)
BuildRequires:  pkgconfig(xtables)
BuildRequires:  dbus-1-devel
BuildRequires:  glib2-devel
BuildRequires:  ipset-devel
BuildRequires:  libiptc-devel
BuildRequires:  libnl-devel
BuildRequires:  libxtables-devel
BuildRequires:  libnfnetlink-devel
BuildRequires:  net-snmp-devel
BuildRequires:  popt-devel
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
BuildRequires:  cyrus-sasl-devel
Requires(pre):  pwdutils
Requires(pre):  %insserv_prereq
Requires(pre):  %fillup_prereq
%if %{with systemd}
BuildRequires:  systemd
Requires:       systemd

BuildRoot:      %{_tmppath}/%{name}-%{version}-build

The main goal of this project is to provide simple and robust facilities for
loadbalancing and high-availability to Linux system and Linux based
infrastructures. Loadbalancing framework relies on well-known and widely used
Linux Virtual Server (IPVS) kernel module providing Layer4 loadbalancing.
Keepalived implements a set of checkers to dynamically and adaptively maintain
and manage loadbalanced server pool according their health. On the other hand
high-availability is achieved by VRRP protocol. VRRP is a fundamental brick for
router failover. In addition, Keepalived implements a set of hooks to the VRRP
finite state machine providing low-level and high-speed protocol interactions.
Keepalived frameworks can be used independently or all together to provide
resilient infrastructures.

%setup -q
%patch1 -p0

export STRIP=true
export CPPFLAGS="$(pkg-config --cflags libnfnetlink libiptc libipset xtables)"
%configure \
  --disable-silent-rules \
  --enable-snmp \
  --enable-snmp-vrrp \
  %if %{with dbus}
  --enable-dbus \
  --enable-dbus-create-instance \
  --enable-snmp-checker \
  --enable-snmp-rfc \
  --enable-snmp-rfcv2 \
  --enable-snmp-rfcv3 \
  --enable-sha1 \
  --enable-routes \
  --enable-libiptc \
make %{?_smp_mflags}

make install DESTDIR="%{buildroot}"
install -dD -m 0750 %{buildroot}%{_var}/lib/%{name}
install -D  -m 0644 %{buildroot}/etc/sysconfig/keepalived %{buildroot}/var/adm/fillup-templates/sysconfig.%{name}

%if %{with systemd}
install -D -m0644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
ln -s /sbin/service %{buildroot}%{_sbindir}/rckeepalived
install -D -m 0750 keepalived/etc/init.d/keepalived.suse.init %{buildroot}/etc/init.d/keepalived
ln -s /etc/init.d/keepalived %{buildroot}%{_sbindir}/rckeepalived

chmod -R o= %{buildroot}/etc/keepalived
rm -rv %{buildroot}/etc/keepalived/samples/ %{buildroot}/etc/sysconfig/keepalived

/usr/sbin/groupadd -r %{name} >/dev/null 2>&1 || :
/usr/sbin/useradd -g %{name} -s /bin/false -r -c "Keepalived" -d %{_var}/lib/%{name} %{name} >/dev/null 2>&1 || :
%if %{with systemd}
%service_add_pre %{name}.service %{name}.socket

%stop_on_removal %{name}
%if %{with systemd}
%service_del_preun %{name}.service %{name}.socket

%fillup_only %{name}
%if %{with systemd}
%service_add_post %{name}.service %{name}.socket

%restart_on_update %{name}
%if %{with systemd}
%service_del_postun %{name}.service %{name}.socket

%config(noreplace) %attr(-,root,keepalived) /etc/keepalived/
%if %{with dbus}
%config /etc/dbus-1/system.d/org.keepalived.Vrrp1.conf
%if %{with systemd}
%dir %attr(-,keepalived,keepalived) %{_var}/lib/%{name}
%doc doc/samples/
%doc doc/keepalived.conf.SYNOPSIS doc/NOTE_vrrp_vmac.txt