File syslog-ng.spec of Package syslog-ng

#
# spec file for package syslog-ng
#
# Copyright (c) 2011 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/
#

# norootforbuild


Name:           syslog-ng
%define         eventlog_version 0.2.7
%define         with_sql         %suse_version > 1130
Version:        3.2.2
Release:        2
License:        GPLv2
Group:          System/Daemons
Summary:        The new-generation syslog-daemon
Url:            http://www.balabit.com/products/syslog_ng/
Requires(pre):  %insserv_prereq %fillup_prereq /sbin/klogd /etc/init.d/syslog
Provides:       syslog
#Source0:        http://www.balabit.com/downloads/files/syslog-ng/sources/%%{version}/source/syslog-ng_%%{version}.tar.gz
Source0:        syslog-ng_%{version}.tar.bz2
Source1:        syslog-ng.rc-script
Source2:        syslog-ng.sysconfig
Source3:        syslog-ng.conf.default
Patch0:         syslog-ng-%{version}-less-static.dif
Patch1:         syslog-ng-%{version}-no-datetime.diff
Patch2:         syslog-ng-%{version}-systemd-integration.bnc656104.diff
%if 0%{?with_sql}
Patch3:         syslog-ng-%{version}-module-path.diff
%endif
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  bison flex gcc-c++ glib2-devel pkgconfig
BuildRequires:  klogd python tcpd-devel
%if %suse_version > 1130  
BuildRequires:  libnet-devel
# The systemd package provides
#   /usr/share/doc/packages/systemd/sd-daemon.[ch]
# (http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.[ch])
# files we need for socket activation, see bnc#656259.
BuildRequires:  systemd
%else  
BuildRequires:  libnet
%endif
%if 0%{?with_sql}
BuildRequires:  libdbi-devel
%endif
BuildRequires:  libevtlog-devel pcre-devel
BuildRequires:  libopenssl-devel

# only while preparing dist from git
# BuildRequires:	git

%description
syslog-ng is a "new-generation" syslogd (replacement) for Unix and
Unix-like systems. It tries to fill the gaps in the original syslogd:

* powerful configurability
* filtering based on message content
* portability
* better network forwarding

The official home page of syslog-ng is:
http://www.balabit.com/network-security/syslog-ng/

Authors:
--------
    Balázs Scheidler <bazsi@balabit.hu>
    BalaBit IT Ltd. <info@balabit.hu>


%if 0%{?with_sql}

%package sql
License:        GPLv2
Group:          System/Daemons
Summary:        SQL support using DBI
Requires:       %{name} = %{version}

%description sql
This package provides the libafsql module providing support for
logging into a SQL database using DBI. To enable it, comment
out the library in %_sysconfdir/syslog-ng/scl/modules.conf

Authors:
--------
    Balázs Scheidler <bazsi@balabit.hu>
    BalaBit IT Ltd. <info@balabit.hu>

%endif

%prep
%setup -q -n syslog-ng-%{version}
%if 0%{suse_version} <= 1130
%patch0 -p0
%endif
%patch1 -p0
%if %suse_version > 1130  
%patch2 -p1
%endif
%if 0%{?with_sql}
%patch3 -p1
# change module-path to be arch specific & enable it
sed -i -e 's|#@define module-path .*|@define module-path "/%_lib/syslog-ng:%_libdir/syslog-ng"|g' \
	scl/modules.conf
%endif
cp -a $RPM_SOURCE_DIR/syslog-ng.rc-script    .
cp -a $RPM_SOURCE_DIR/syslog-ng.conf.default .
%ifarch s390 s390x
    sed -i -e 's/tty10/console/g' syslog-ng.conf.default
%endif
%if %suse_version > 1130  
cp -a /usr/share/doc/packages/systemd/sd-daemon.[ch] modules/afsocket/
%endif

%build
##
## build ####################################################
##
export CFLAGS="$RPM_OPT_FLAGS"
# export SUSE_ASNEEDED=0
#
# - update configure scripts & tools:
#
%{?suse_update_config:%{suse_update_config -f}}
#aclocal --force
#libtoolize -f
#automake --foreign --add-missing --copy --force-missing
#autoheader
#
autoreconf -fiv
#
# - configure syslog-ng using static eventlog library (default)
#
%configure \
	--bindir=/usr/bin			\
	--sbindir=/sbin				\
	--enable-ipv6				\
	--enable-tcp-wrapper			\
	--enable-spoof-source			\
%if 0%{?sles_version}
	--disable-pcre				\
%else
%if 0%{?suse_version}
	--enable-pcre				\
%endif
%endif
	--with-pidfile-dir=/var/run		\
	--sysconfdir=/etc/syslog-ng		\
	--localstatedir=/var/lib/syslog-ng	\
	--with-module-dir="/%_lib/syslog-ng"	\
	--datadir=/usr/share/syslog-ng		\
	--prefix=/				\
	--exec-prefix=/				\
	--enable-ssl				\
%if 0%{?with_sql}
	--enable-sql				\
%endif
	%if 0%{suse_version} > 1130  
	   --enable-dynamic-linking  
	%else  
	   --enable-mixed-linking  
	%endif

#
# - build syslog-ng
#
make %_smp_mflags

#%check
##
## check ####################################################
##
#make check

%install
##
## install ##################################################
##
export RPM_BUILD_ROOT
for dir in sbin/conf.d \
           etc/syslog-ng \
           var/lib/syslog-ng \
           var/adm/fillup-templates ;
do
	test -d $RPM_BUILD_ROOT/$dir || \
	install -d -m755 $RPM_BUILD_ROOT/$dir
done
#
install -m644 syslog-ng.conf.default \
              $RPM_BUILD_ROOT/etc/syslog-ng/syslog-ng.conf
install -m644 $RPM_SOURCE_DIR/syslog-ng.sysconfig \
              $RPM_BUILD_ROOT/var/adm/fillup-templates/sysconfig.syslog-ng
#
make DESTDIR=${RPM_BUILD_ROOT} install
#
#tar -C doc/reference -xf doc/reference/syslog-ng.html.tar.gz
#mv doc/reference/syslog-ng.html  doc/reference/html
#mv doc/reference/html/index.html doc/reference/syslog-ng.html
mkdir %{buildroot}/usr/sbin/
%{__mv} -v %{buildroot}/sbin/syslog-ng-ctl %{buildroot}/usr/sbin/

mkdir -p %{buildroot}/var/run/syslog-ng/

# don't package update-patterndb now
rm %{buildroot}/usr/bin/update-patterndb

# move libsyslogng by hand, until a fix is found
mkdir -p %{buildroot}/%_lib
%{__mv} -v %{buildroot}/usr/%_lib/* %{buildroot}/%_lib

%if 0%{?with_sql}
# move libafsql to /usr, as it has dependencies there
mkdir -p %{buildroot}/usr/%_lib/syslog-ng
mv %{buildroot}/%_lib/syslog-ng/libafsql.so %{buildroot}/usr/%_lib/syslog-ng
%endif

# remove devel files
rm %{buildroot}/%_lib/syslog-ng/*.la
rm %{buildroot}/%_lib/*.la
rm %{buildroot}/%_lib/*.so

%clean
##
## clean build root #########################################
##
rm -rf $RPM_BUILD_ROOT

%post
##
## post install #############################################
##
#
# remove old SYSLOG_NG_* variables from etc/sysconfig/syslog-ng
# and the file itself as well.
# this may cause, that syslog-ng will be disabled, but because
# it is IMHO not possible to check if the syslog-ng init script
# was active _and_ SYSLOG_NG_REPLACE was "yes" _before_ the old
# syslog-ng package was uninstalled... it's IMHO acceptable.
#
%{remove_and_set -n syslog-ng SYSLOG_NG_REPLACE SYSLOG_NG_PARAMS}
if [ -f etc/sysconfig/syslog-ng ] ; then
  # be sure it' away now :-)
  rm -f etc/sysconfig/syslog-ng
fi
#
# add syslog variables provided by klogd if needed
#
%{remove_and_set -n syslog SYSLOG_NG_CREATE_CONFIG}
if test "$SYSLOG_NG_CREATE_CONFIG" == "yes" ; then
cat <<EOF
     Note: SuSEconfig script and its syslog-ng.conf.in template are
           not used any more. Please read README.SUSE for details.
EOF
fi
%{fillup_and_insserv -ny syslog syslog}
%{fillup_and_insserv -nY syslog earlysyslog}
#
# add SYSLOG_NG_* variables if needed
#
%{fillup_only -ans syslog ng}
#
# check if daemon configured in SYSLOG_DAEMON is installed
# and switch to ourself if it's missed
#
source etc/sysconfig/syslog
replace_syslog=no
if test "$SYSLOG_DAEMON" != "syslog-ng" ; then
    if test -z "$SYSLOG_DAEMON" || \
       test ! -x sbin/${SYSLOG_DAEMON} ; then
        replace_syslog=yes
    fi
fi
if test "$replace_syslog" = "yes" ; then
    sed -i -e 's/^SYSLOG_DAEMON=.*/SYSLOG_DAEMON="syslog-ng"/g' \
              etc/sysconfig/syslog
fi
#
# create dirs, touch log default files
#
mkdir -p var/log
touch var/log/messages;  chmod 640 var/log/messages
touch var/log/boot.log;  chmod 640 var/log/boot.log
touch var/log/mail;      chmod 640 var/log/mail
touch var/log/mail.info; chmod 640 var/log/mail.info
touch var/log/mail.warn; chmod 640 var/log/mail.warn
touch var/log/mail.err;  chmod 640 var/log/mail.err
test -f var/log/news && mv -f var/log/news var/log/news.bak
mkdir -p -m 0750 var/log/news
chown news:news  var/log/news
touch var/log/news/news.crit;   chmod 640 var/log/news/news.crit
chown news:news var/log/news/news.crit
touch var/log/news/news.err;    chmod 640 var/log/news/news.err
chown news:news var/log/news/news.err
touch var/log/news/news.notice; chmod 640 var/log/news/news.notice
chown news:news var/log/news/news.notice
#
# touch the additional log files we are using
#
touch var/log/acpid;            chmod 640 var/log/acpid
touch var/log/firewall;         chmod 640 var/log/firewall
touch var/log/NetworkManager;   chmod 640 var/log/NetworkManager

# run ldconfig
ldconfig

%preun
##
## pre uninstall ############################################
##
%stop_on_removal syslog

%postun
##
## post uninstall ###########################################
##
%restart_on_update syslog
%{insserv_cleanup}
# reset SYSLOG_DAEMON variable
if test -f etc/sysconfig/syslog ; then
  source etc/sysconfig/syslog
  if test "$SYSLOG_DAEMON" == "syslog-ng" ; then
    sed -i -e 's/^SYSLOG_DAEMON=.*/SYSLOG_DAEMON=""/g' \
              etc/sysconfig/syslog
  fi
fi

#run ldconfig
ldconfig

%files
##
## file list ################################################
##
%defattr(-,root,root)
%doc COPYING AUTHORS README ChangeLog INSTALL NEWS
%doc syslog-ng.rc-script syslog-ng.conf.default
%doc doc/examples
# doc/reference/syslog-ng.txt doc/reference/syslog-ng.html
%attr(755,root,root) /usr/bin/loggen
%attr(755,root,root) /sbin/syslog-ng
%attr(755,root,root) /usr/bin/pdbtool
%attr(755,root,root) /usr/sbin/syslog-ng-ctl
%{_mandir}/man5/syslog-ng.conf.5*
%{_mandir}/man8/syslog-ng.8*
%{_mandir}/man1/pdbtool.1*
%{_mandir}/man1/loggen.1*
%{_mandir}/man1/syslog-ng-ctl.1*
%dir /etc/syslog-ng
%dir /%_lib/syslog-ng
%if 0%{?with_sql}
%dir %_libdir/syslog-ng
%endif
%dir /usr/share/syslog-ng
%dir /usr/share/syslog-ng/include
%dir /usr/share/syslog-ng/include/scl
%dir /usr/share/syslog-ng/include/scl/pacct
%dir /usr/share/syslog-ng/include/scl/syslogconf
%dir /usr/share/syslog-ng/include/scl/system
%dir /usr/share/syslog-ng/xsd
%config(noreplace) /etc/syslog-ng/syslog-ng.conf
%config(noreplace) /etc/syslog-ng/modules.conf
%config(noreplace) /etc/syslog-ng/scl.conf
%dir /var/lib/syslog-ng
%attr(755,root,root) %ghost %dir /var/run/syslog-ng
/var/adm/fillup-templates/sysconfig.syslog-ng
%attr(755,root,root) /%_lib/libsyslog-ng.so.*
%attr(755,root,root) /%_lib/syslog-ng/*
%attr(755,root,root) /%_lib/libsyslog-ng-patterndb.so.*
%attr(644,root,root) /usr/share/syslog-ng/include/scl/pacct/plugin.conf
%attr(755,root,root) /usr/share/syslog-ng/include/scl/system/generate-system-source.sh
%attr(644,root,root) /usr/share/syslog-ng/include/scl/system/plugin.conf
%attr(644,root,root) /usr/share/syslog-ng/include/scl/syslogconf/README
%attr(755,root,root) /usr/share/syslog-ng/include/scl/syslogconf/convert-syslogconf.awk
%attr(644,root,root) /usr/share/syslog-ng/include/scl/syslogconf/plugin.conf
%attr(644,root,root) /usr/share/syslog-ng/xsd/patterndb-1.xsd
%attr(644,root,root) /usr/share/syslog-ng/xsd/patterndb-2.xsd
%attr(644,root,root) /usr/share/syslog-ng/xsd/patterndb-3.xsd

%if 0%{?with_sql}

%files sql
%defattr(-,root,root)
%dir %_libdir/syslog-ng
%attr(755,root,root) %_libdir/syslog-ng/libafsql.so
%endif

%changelog
openSUSE Build Service is sponsored by