File csync2.spec of Package csync2

# spec file for package csync2
# Copyright (c) 2012 SUSE LINUX Products 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

Summary:        Cluster synchronization tool
License:        GPL-2.0+ ; LGPL-2.1+
Group:          Productivity/Clustering/HA

Name:           csync2
Version:        1.34
Release:        0
Source1:        csync2-README.quickstart
Source2:        csync2-rm-ssl-cert
Patch0:         csync2-fix-xinetd.patch
Patch1:         fix-missing-sentinels.diff
%if 0%{?suse_version} > 1120
Patch2:         csync2-1.34-pure-gnutls-r2.patch
BuildRequires:  pkg-config
Patch3:         force-debug-stderr-off-inetd.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Requires(post): openssl 
Requires:       gnutls
Requires:       sqlite2
Requires:       xinetd
BuildRequires:  bison
BuildRequires:  flex
BuildRequires:  libgnutls-devel
%if 0%{?sles_version} == 11
BuildRequires:  libgnutls-extra-devel
BuildRequires:  libtasn1-devel
BuildRequires:  sqlite2-devel
%if 0%{?suse_version} > 1210
BuildRequires:  librsync-devel
BuildRequires:  librsync

Csync2 is a cluster synchronization tool. It can be used to keep files
on multiple hosts in a cluster in sync. Csync2 can handle complex
setups with much more than just 2 hosts, handle file deletions and can
detect conflicts. It is expedient for HA-clusters, HPC-clusters, COWs
and server farms.

%setup -q
%patch0 -p1 -b .fix-xinetd
%patch1 -p1
%if 0%{?suse_version} > 1120
%patch2 -p1
%patch3 -p1
install -p -m 644 %{SOURCE1} README.quickstart

%configure --sysconfdir=%{_sysconfdir}/csync2
make %{?_smp_mflags}

make install DESTDIR=%{buildroot}
mkdir -p %{buildroot}%{_var}/lib/csync2
install -p -D -m 644 csync2.xinetd %{buildroot}%{_sysconfdir}/xinetd.d/csync2
install -p -m 755 %{SOURCE2} %{buildroot}%{_sbindir}/csync2-rm-ssl-cert
# We need these empty files to be able to %%ghost them
touch %{buildroot}%{_sysconfdir}/csync2/csync2_ssl_key.pem
touch %{buildroot}%{_sysconfdir}/csync2/csync2_ssl_cert.pem

umask 077
if [ ! -f %{_sysconfdir}/csync2/csync2_ssl_key.pem ]; then
/usr/bin/openssl genrsa -rand /proc/apm:/proc/cpuinfo:/proc/dma:/proc/filesystems:/proc/interrupts:/proc/ioports:/proc/pci:/proc/rtc:/proc/uptime 1024 > %{_sysconfdir}/csync2/csync2_ssl_key.pem 2>/dev/null
if [ "x${FQDN}" = "x" ]; then
if [ ! -f %{_sysconfdir}/csync2/csync2_ssl_cert.pem ]; then
cat << EOF | /usr/bin/openssl req -new -key %{_sysconfdir}/csync2/csync2_ssl_key.pem -x509 -days 3000 -out %{_sysconfdir}/csync2/csync2_ssl_cert.pem 2>/dev/null

# Cleanup all databases upon last removal
if [ $1 -eq 0 ]; then
  %{__rm} -f %{_var}/lib/csync2/*

%doc README README.quickstart AUTHORS COPYING paper.pdf
%dir %{_sysconfdir}/csync2/
%config(noreplace) %{_sysconfdir}/csync2/csync2.cfg
%config(noreplace) %{_sysconfdir}/xinetd.d/csync2
%ghost %config %{_sysconfdir}/csync2/csync2_ssl_key.pem
%ghost %config %{_sysconfdir}/csync2/csync2_ssl_cert.pem
%dir %{_var}/lib/csync2/