File keepalived.spec of Package keepalived

#
# spec file for package keepalived
#
# Copyright (c) 2015 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 http://bugs.opensuse.org/
#


%if 0%{?suse_version} > 1210
%define has_systemd 1
%endif

Name:           keepalived
Version:        1.2.15
Release:        0
Summary:        A strong & robust keepalive facility for linux
License:        GPL-2.0+
Group:          Productivity/Networking/Routing
Url:            http://www.keepalived.org/
Source:         http://www.keepalived.org/software/keepalived-%{version}.tar.gz
Source1:        keepalived.service
Source2:        keepalive-rpmlintrc
Patch1:         keepalive-init.patch
BuildRequires:  openssl-devel
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(libnl-3.0)
# BuildRequires:  netsnmp-devel
BuildRequires:  popt-devel
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
BuildRequires:  cyrus-sasl-devel
%endif
Requires(pre):  pwdutils
Requires(pre):  %insserv_prereq
Requires(pre):  %fillup_prereq
%if 0%{?has_systemd}
BuildRequires:  systemd
Requires:       systemd
%endif

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

%description
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.

%prep
%setup -q
%patch1

%build
export STRIP=true
export CFLAGS="%optflags -DOPENSSL_NO_SSL_INTERN"
%configure
make %{?_smp_mflags}

%install
make install DESTDIR="%{buildroot}"
install -dD -m 0750 %{buildroot}%{_var}/lib/%{name}
install -D -m 0750 keepalived/etc/init.d/keepalived.suse.init %{buildroot}/etc/init.d/keepalived
install -D -m 0644 %{buildroot}/etc/sysconfig/keepalived %{buildroot}/var/adm/fillup-templates/sysconfig.%{name}
%if 0%{?has_systemd}
install -D -m0644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
%endif

rm %{buildroot}/etc/rc.d/init.d/keepalived %{buildroot}/etc/sysconfig/keepalived
ln -s /etc/init.d/keepalived %{buildroot}%{_sbindir}/rckeepalived
chmod -R o= %{buildroot}/etc/keepalived
rm -rv %{buildroot}/etc/keepalived/samples/

%pre
/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 0%{?has_systemd}
%service_add_pre %{name}.service %{name}.socket
%endif

%preun
%stop_on_removal %{name}
%if 0%{?has_systemd}
%service_del_preun %{name}.service %{name}.socket
%endif

%post
%fillup_only %{name}
%if 0%{?has_systemd}
%service_add_post %{name}.service %{name}.socket
%endif

%postun
%insserv_cleanup
%restart_on_update %{name}
%if 0%{?has_systemd}
%service_del_postun %{name}.service %{name}.socket
%endif

%files
%defattr(-,root,root)
%doc README COPYING
%config(noreplace) %attr(-,root,keepalived) /etc/keepalived/
/etc/init.d/keepalived
%{_bindir}/genhash
%{_sbindir}/rckeepalived
%{_sbindir}/keepalived
%{_mandir}/man1/genhash.1.gz
%{_mandir}/man5/keepalived.conf.5.gz
%{_mandir}/man8/keepalived.8.gz
%if 0%{?has_systemd}
%{_unitdir}/%name.service
%endif
%dir %attr(-,keepalived,keepalived) %{_var}/lib/%{name}
/var/adm/fillup-templates/sysconfig.%{name}
%doc AUTHOR ChangeLog CONTRIBUTORS COPYING README
%doc doc/samples/
%doc doc/keepalived.conf.SYNOPSIS doc/KEEPALIVED-MIB doc/NOTE_vrrp_vmac.txt

%changelog
openSUSE Build Service is sponsored by