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 with_sql %suse_version > 1130
%define with_systemd %suse_version > 1130
%define with_syslogservice %suse_version > 1140
%define with_json %suse_version > 1130
Version: 3.3.1
Release: 6
License: GPLv2
Group: System/Daemons
Summary: The new-generation syslog-daemon
Url: http://www.balabit.com/products/syslog_ng/
%if 0%{?with_syslogservice}
Requires(pre): %insserv_prereq %fillup_prereq syslog-service
%else
Requires(pre): %insserv_prereq %fillup_prereq /sbin/klogd /etc/init.d/syslog
%endif
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.diff
Patch1: syslog-ng-%{version}-filters.diff
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: bison flex gcc-c++ glib2-devel pkgconfig
BuildRequires: python tcpd-devel
%if %suse_version > 1140
BuildRequires: libcap-devel
%endif
%if 0%{?with_syslogservice}
BuildRequires: syslog-service
%else
BuildRequires: klogd
%endif
%if %suse_version > 1130
BuildRequires: libnet-devel
%else
BuildRequires: libnet
%endif
%if 0%{?with_systemd}
# 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.
#
# Note: On 11.4 we do not ship any systemd service file.
# On 12.x, the syslog.service file is provided by
# the syslog-service package.
#
BuildRequires: systemd
%endif
%if 0%{?with_sql}
BuildRequires: libdbi-devel
%endif
%if 0%{?with_json}
BuildRequires: json-glib-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
%if 0%{?with_json}
%package json
License: GPLv2
Group: System/Daemons
Summary: JSON output support
Requires: %{name} = %{version}
%description json
This package provides the tfjson module providing support for
logging in JSON format. 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 -p1
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 0%{?with_syslogservice}
%else
sed -i -e 's/\([ \t]*\)\(file.*kmsg.*\)/\1#\2/g' syslog-ng.conf.default
%endif
%if 0%{?with_systemd}
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 \
--with-pidfile-dir=/var/run \
--sysconfdir=/etc/syslog-ng \
--localstatedir=/var/lib/syslog-ng \
--with-module-dir="/%_lib/syslog-ng" \
--with-module-path="/%_lib/syslog-ng:/usr/%_lib/syslog-ng" \
--datadir=/usr/share/syslog-ng \
--prefix=/ \
--exec-prefix=/ \
--without-compile-date \
%if 0%{suse_version} < 1130
--disable-ssl \
--disable-pcre \
%else
--enable-ssl \
--enable-pcre \
%endif
%if 0%{?with_systemd}
--enable-systemd \
%endif
%if 0%{?with_sql}
--enable-sql \
%endif
%if 0%{?with_json}
--enable-json \
%endif
%if %suse_version > 1140
--enable-capabilities \
%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
mkdir -p %{buildroot}/usr/%_lib/syslog-ng
%if 0%{?with_sql}
# move libafsql to /usr, as it has dependencies there
mv %{buildroot}/%_lib/syslog-ng/libafsql.so %{buildroot}/usr/%_lib/syslog-ng
%endif
# move libtfjson to /usr, as it has dependencies there
%if 0%{?with_json}
mv %{buildroot}/%_lib/syslog-ng/libtfjson.so %{buildroot}/usr/%_lib/syslog-ng
%endif
# move libafmongodb to /usr, as it has dependencies there (on <11.4)
mv %{buildroot}/%_lib/syslog-ng/libafmongodb.so %{buildroot}/usr/%_lib/syslog-ng
# remove devel files
rm %{buildroot}/%_lib/syslog-ng/*.la
rm %{buildroot}/%_lib/*.la
rm %{buildroot}/%_lib/pkgconfig/syslog-ng.pc
rm -fr %{buildroot}/usr/include/syslog-ng
rm -fr %{buildroot}/usr/share/syslog-ng/tools
# keep only libafsocket-tsl.so
rm %{buildroot}/%_lib/syslog-ng/libafsocket.so
rm %{buildroot}/%_lib/syslog-ng/libafsocket-notls.so
mv %{buildroot}/%_lib/syslog-ng/libafsocket-tls.so %{buildroot}/%_lib/syslog-ng/libafsocket.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/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
# generate empty additional-log-sockets.conf file
# see also syslog-ng.conf.default in pkg src dir.
additional_sockets="/var/run/syslog-ng/additional-log-sockets.conf"
install -d -m750 ${additional_sockets%/*}
cat >$additional_sockets <<EOF
source chroots { };
EOF
chmod 640 "${additional_sockets#/}"
%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 ChangeLog NEWS
%doc syslog-ng.rc-script syslog-ng.conf.default
%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
%dir %_libdir/syslog-ng
%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*
%attr(755,root,root) /%_lib/syslog-ng/*
%attr(755,root,root) /usr/%_lib/syslog-ng/libafmongodb.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 /usr/%_lib/syslog-ng
%attr(755,root,root) /usr/%_lib/syslog-ng/libafsql.so
%endif
%if 0%{?with_json}
%files json
%defattr(-,root,root)
%dir /usr/%_lib/syslog-ng
%attr(755,root,root) /usr/%_lib/syslog-ng/libtfjson.so
%endif
%changelog