File nxlog-ce.spec of Package nxlog-ce

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

# backport...
%{!?_initddir: %{expand: %%global _initddir %{_initrddir}}}
%{!?_rundir: %{expand: %%global _rundir %{_localstatedir}/run}}

Name:           nxlog-ce
Version:        2.10.2150
Release:        0
Summary:        A universal log collector and forwarder supporting different platforms
License:        NXLOG
Group:          System/Daemons
Url:            http://nxlog-ce.sourceforge.net/
Source0:        https://nxlog.co/system/files/products/files/348/nxlog-ce-%{version}.tar.gz
Source1:        nxlog-ce.init
Source2:        nxlog-ce.service.in
Patch0:         nxlog-ce-2.10.2150_inet_pton.patch
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  libapr1-devel
BuildRequires:  libexpat-devel
BuildRequires:  libstomp-devel
BuildRequires:  libtool
BuildRequires:  libressl-devel
BuildRequires:  subversion
BuildRequires:  pcre-devel
BuildRequires:  xmlto
%if 0%{?suse_version} > 1110 && 0%{?suse_version} != 1315
BuildRequires:  dblatex
%endif
BuildRequires:  w3m
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} >= 1230
BuildRequires:  shadow
Requires(pre):  shadow
%else
BuildRequires:  pwdutils
Requires(pre):  pwdutils
%endif


%description
The nxlog community edition is an open source, high-performance,
multi-platform log management solution aimed at
solving these tasks and doing it all in one place.

In concept nxlog is similar to syslog-ng or rsyslog
but it is not limited to unix and syslog only.
It supports different platforms, log sources and formats
so nxlog can be an ideal choice to implement a centralized logging system.

%package -n perl-%{name}
Summary:        Perl module for nxlog-ce
Group:          Development/Libraries/Perl
# this is required for perl modules but SLE11 is a bit dated ...
%if 0%{?suse_version} > 1110
%{perl_requires}
%else
Requires:       perl
%endif

%description -n perl-%{name}
Perl module for nxlog-ce enabling perl applications to
directly log to nxlog-ce

%prep
%setup -qn nxlog-ce-2.10.7
%patch0

%build
touch NEWS README AUTHORS ChangeLog
# sle autoreconf and autoconf are braindead  a bit...
autoreconf -I. -fi
%configure --disable-static \
	--docdir=%{_defaultdocdir}/%{name} \
	--with-cachedir=%{_localstatedir}/spool/nxlog \
	--with-configfile=%{_sysconfdir}/nxlog/nxlog.conf \
	--with-pidfile=%{_rundir}/nxlog.pid

make %{?_smp_mflags}
# Prepare service file and initial configuration
sed -e 's!@sbindir@!%{_sbindir}!g' %{SOURCE2} > nxlog-ce.service
sed -re 's@(^LogFile).*@\1 %{_localstatedir}/log/nxlog-ce.log@g' ./packaging/redhat/nxlog.conf > nxlog.conf
sed -ri 's@/var/log/logmsg.txt@%{_localstatedir}/log/messages@g' nxlog.conf
sed -ri 's@/var/log/logmsg2.txt@%{_localstatedir}/log/remote@g' nxlog.conf


%install
make DESTDIR=%{buildroot} install %{?_smp_mflags}

install -Dm0644 nxlog.conf %{buildroot}/%{_sysconfdir}/nxlog/nxlog.conf
mkdir -p %{buildroot}/%{_sbindir}
%if 0%{?suse_version} >= 1210
install -Dm0644 nxlog-ce.service %{buildroot}/%{_unitdir}/nxlog-ce.service
ln -s %{_sbindir}/service %{buildroot}/%{_sbindir}/rc%{name}
%else
install -Dm0755 %{SOURCE1} %{buildroot}/%{_initddir}/%{name}
ln -s %{_initddir}/%{name} %{buildroot}/%{_sbindir}/rc%{name}
%endif

#remove libtool library helper files
find %{buildroot} -type f -name "*.la" -delete -print

%pre
%if 0%{?suse_version} >= 1210
%service_add_pre nxlog-ce.service
%endif
%{_bindir}/getent group nxlog >/dev/null || %{_sbindir}/groupadd -r nxlog || :
%{_bindir}/getent passwd nxlog >/dev/null || %{_sbindir}/useradd -r -d %{_localstatedir}/lib/nxlog -s /bin/false -c "nxlog Daemon" -g nxlog nxlog || :

%preun
%if 0%{?suse_version} >= 1210
%service_del_preun nxlog-ce.service
%else
%stop_on_removal nxlog-ce
%endif

%post
%if 0%{?suse_version} >= 1210
%{fillup_only nxlog-ce}
%else
%fillup_and_insserv -f nxlog-ce
# set us to be syslog implementation
if test -f etc/sysconfig/syslog ; then
	sed -i \
		-e 's/^SYSLOG_DAEMON=.*/SYSLOG_DAEMON="nxlog-ce"/g' \
		etc/sysconfig/syslog
fi
%endif

%postun
%if 0%{?suse_version} >= 1210
%service_del_postun nxlog-ce.service
%else
%restart_on_update nxlog-ce
%insserv_cleanup
%endif

%files
%defattr(-,root,root)
%doc ChangeLog.txt
%dir %{_docdir}/%{name}/figures
%doc %{_docdir}/%{name}/figures/*
%doc %{_docdir}/%{name}/nxlog-reference-manual.*
%dir %{_sysconfdir}/nxlog
%dir %{_datadir}/nxlog-ce
%dir %{_libexecdir}/nxlog
%dir %{_libexecdir}/nxlog/modules
%dir %{_libexecdir}/nxlog/modules/extension
%dir %{_libexecdir}/nxlog/modules/input
%dir %{_libexecdir}/nxlog/modules/output
%dir %{_libexecdir}/nxlog/modules/processor
# default config file
%config(noreplace) %{_sysconfdir}/nxlog/nxlog.conf
%{_bindir}/nxlog
%{_bindir}/nxlog-processor
%{_bindir}/nxlog-stmnt-verifier
%{_libexecdir}/nxlog/modules/extension/xm_*.so
%{_libexecdir}/nxlog/modules/input/im_*.so
%{_libexecdir}/nxlog/modules/output/om_*.so
%{_libexecdir}/nxlog/modules/processor/pm_*.so
%{_datadir}/nxlog-ce/core-fields.xml
%{_datadir}/nxlog-ce/im_*-fields.xml
%{_datadir}/nxlog-ce/pm_*-fields.xml
%{_datadir}/nxlog-ce/xm_*-fields.xml
%if 0%{?suse_version} >= 1210
%{_unitdir}/nxlog-ce.service
%else
%{_initddir}/%{name}
%endif
%{_sbindir}/rc%{name}

%files -n perl-%{name}
%defattr(-,root,root)
%dir %{perl_vendorlib}/Log
%{perl_vendorlib}/Log/Nxlog.pm

%changelog
openSUSE Build Service is sponsored by