Ver código fonte

first cut at packaging rsyslog

Ralf S. Engelschall 18 anos atrás
pai
commit
1376a68e1e
4 arquivos alterados com 322 adições e 0 exclusões
  1. 56 0
      rsyslog/rc.rsyslog
  2. 16 0
      rsyslog/rsyslog.conf
  3. 70 0
      rsyslog/rsyslog.patch
  4. 180 0
      rsyslog/rsyslog.spec

+ 56 - 0
rsyslog/rc.rsyslog

@@ -0,0 +1,56 @@
+#!@l_prefix@/bin/openpkg rc
+##
+##  rc.rsyslog -- Run-Commands
+##
+
+%config
+    rsyslog_enable="$openpkg_rc_def"
+    rsyslog_flags="-o"
+    rsyslog_log_prolog="true"
+    rsyslog_log_epilog="true"
+    rsyslog_log_numfiles="10"
+    rsyslog_log_minsize="1M"
+    rsyslog_log_complevel="9"
+
+%common
+    rsyslog_pidfile="@l_prefix@/var/rsyslog/run/rsyslog.pid"
+    rsyslog_logfile="@l_prefix@/var/rsyslog/log/rsyslog.log"
+    rsyslog_signal () {
+        [ -f $rsyslog_pidfile ] && kill -$1 `cat $rsyslog_pidfile`
+    }
+
+%status -u @l_susr@ -o
+    rsyslog_usable="unknown"
+    rsyslog_active="no"
+    rcService rsyslog enable yes && \
+        rsyslog_signal 0 && rsyslog_active="yes"
+    echo "rsyslog_enable=\"$rsyslog_enable\""
+    echo "rsyslog_usable=\"$rsyslog_usable\""
+    echo "rsyslog_active=\"$rsyslog_active\""
+
+%start -u @l_susr@
+    rcService rsyslog enable yes || exit 0
+    rcService rsyslog active yes && exit 0
+    @l_prefix@/sbin/rsyslog ${rsyslog_flags}
+
+%stop -u @l_susr@
+    rcService rsyslog enable yes || exit 0
+    rcService rsyslog active no  && exit 0
+    rsyslog_signal TERM
+    sleep 2
+    rm -f $rsyslog_pidfile >/dev/null 2>&1 || true
+
+%restart -u @l_susr@
+    rcService rsyslog enable yes || exit 0
+    rcService rsyslog active no  && exit 0
+    rc rsyslog stop start
+
+%daily -u @l_susr@
+    rcService rsyslog enable yes || exit 0
+    shtool rotate -f \
+        -n $rsyslog_log_numfiles -s $rsyslog_log_minsize -d \
+        -z $rsyslog_log_complevel -m 664 -o @l_musr@ -g @l_mgrp@ \
+        -P "$rsyslog_log_prolog" \
+        -E "$rsyslog_log_epilog; rc rsyslog restart" \
+        $rsyslog_logfile
+

+ 16 - 0
rsyslog/rsyslog.conf

@@ -0,0 +1,16 @@
+##
+##  rsyslog.conf -- rsyslogd(8) configuration
+##
+
+#   templates
+$template  traditional,"%timegenerated% %HOSTNAME% %syslogtag%%msg:::drop-last-lf%\n"
+$template  precise,"%syslogpriority%,%syslogfacility%,%timegenerated::fulltime%,%HOSTNAME%,%syslogtag%,%msg%\n"
+$template  rfc3164fmt,"<%PRI%>%TIMESTAMP% %HOSTNAME% %syslogtag%%msg%"
+$template  wallmsg,"\r\n\7Message from syslogd@%HOSTNAME% at %timegenerated% ...\r\n %syslogtag%%msg%\n\r"
+$template  db,"insert into SystemEvents (Message, Facility,FromHost, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values ('%msg%', %syslogfacility%, '%HOSTNAME%',%syslogpriority%, '%timereported:::date-mysql%', '%timegenerated:::date-mysql%', %iut%, '%syslogtag%')",sql
+
+#   selectors
+*.*        @l_prefix@/var/rsyslog/log//var/log/rsyslog.log;traditional
+#*.*       @172.19.2.16;rfc3164fmt
+#*.*       >dbhost,dbname,dbuser,dbpasswd;db
+

+ 70 - 0
rsyslog/rsyslog.patch

@@ -0,0 +1,70 @@
+Index: config.h.in
+--- config.h.in.orig	2007-12-27 23:28:51 +0100
++++ config.h.in	2007-12-29 11:21:50 +0100
+@@ -1,7 +1,9 @@
+ /* config.h.in.  Generated from configure.ac by autoheader.  */
+ 
+ /* Description */
++#ifndef BSD
+ #undef BSD
++#endif
+ 
+ /* klogd functionality is integrated. */
+ #undef FEATURE_KLOGD
+Index: net.h
+--- net.h.orig	2007-12-26 10:56:07 +0100
++++ net.h	2007-12-29 11:21:50 +0100
+@@ -22,6 +22,9 @@
+ #ifndef INCLUDED_NET_H
+ #define INCLUDED_NET_H
+ 
++#include <sys/types.h>
++#include <sys/socket.h>
++
+ #ifdef SYSLOG_INET
+ #include <netinet/in.h>
+ 
+Index: syslogd.c
+--- syslogd.c.orig	2007-12-26 10:56:01 +0100
++++ syslogd.c	2007-12-29 11:57:58 +0100
+@@ -267,28 +267,9 @@
+ #define _PATH_MODDIR	"/lib/rsyslog/"
+ #endif
+ 
+-#if defined(SYSLOGD_PIDNAME)
+-#undef _PATH_LOGPID
+-#if defined(FSSTND)
+-#ifdef BSD
+-#define _PATH_VARRUN "/var/run/"
+-#endif
+-#ifdef __sun
+-#define _PATH_VARRUN "/var/run/"
+-#endif
+-#define _PATH_LOGPID _PATH_VARRUN SYSLOGD_PIDNAME
+-#else
+-#define _PATH_LOGPID "/etc/" SYSLOGD_PIDNAME
+-#endif
+-#else
+ #ifndef _PATH_LOGPID
+-#if defined(FSSTND)
+-#define _PATH_LOGPID _PATH_VARRUN "rsyslogd.pid"
+-#else
+ #define _PATH_LOGPID "/etc/rsyslogd.pid"
+ #endif
+-#endif
+-#endif
+ 
+ #ifndef _PATH_DEV
+ #define _PATH_DEV	"/dev/"
+@@ -303,11 +284,7 @@
+ #endif
+ 
+ #ifndef _PATH_LOG
+-#ifdef BSD
+ #define _PATH_LOG	"/var/run/log"
+-#else
+-#define _PATH_LOG	"/dev/log"
+-#endif
+ #endif
+ 
+ 

+ 180 - 0
rsyslog/rsyslog.spec

@@ -0,0 +1,180 @@
+##
+##  rsyslog.spec -- OpenPKG RPM Package Specification
+##  Copyright (c) 2000-2007 OpenPKG Foundation e.V. <http://openpkg.net/>
+##  Copyright (c) 2000-2007 Ralf S. Engelschall <http://engelschall.com/>
+##
+##  Permission to use, copy, modify, and distribute this software for
+##  any purpose with or without fee is hereby granted, provided that
+##  the above copyright notice and this permission notice appear in all
+##  copies.
+##
+##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+##  SUCH DAMAGE.
+##
+
+#   package information
+Name:         rsyslog
+Summary:      Enhanced Logging Server
+URL:          http://www.rsyslog.com/
+Vendor:       R. Gerhards, M. Meckelein
+Packager:     OpenPKG Foundation e.V.
+Distribution: OpenPKG Community
+Class:        EVAL
+Group:        Logfile
+License:      GPL
+Version:      1.21.2
+Release:      20071229
+
+#   package options
+%option       with_kerberos no
+%option       with_mysql    no
+%option       with_pgsql    no
+
+#   list of sources
+Source0:      http://download.rsyslog.com/rsyslog/rsyslog-%{version}.tar.gz
+Source1:      rsyslog.conf
+Source2:      rc.rsyslog
+Patch0:       rsyslog.patch
+
+#   build information
+Prefix:       %{l_prefix}
+BuildRoot:    %{l_buildroot}
+BuildPreReq:  OpenPKG, openpkg >= 20060823
+PreReq:       OpenPKG, openpkg >= 20060823
+BuildPreReq:  zlib
+PreReq:       zlib
+%if "%{with_kerberos}" == "yes"
+BuildPreReq:  KERBEROS
+PreReq:       KERBEROS
+%endif
+%if "%{with_mysql}" == "yes"
+BuildPreReq:  mysql
+PreReq:       mysql
+%endif
+%if "%{with_pgsql}" == "yes"
+BuildPreReq:  postgresql, openssl
+PreReq:       postgresql, openssl
+%endif
+AutoReq:      no
+AutoReqProv:  no
+
+%description
+    Rsyslog is an enhanced multi-threaded syslogd(8) supporting, among
+    others, RDBMS, syslog/tcp, RFC 3195, permitted sender lists,
+    filtering on any message part, and fine grain output format control.
+    It is quite compatible to stock syslogd(8) and can be used as a
+    drop-in replacement. Its advanced features make it suitable for
+    enterprise-class, encryption protected syslog relay chains while at
+    the same time being very easy to setup for the novice user.
+
+%track
+    prog rsyslog = {
+        version   = %{version}
+        url       = http://download.rsyslog.com/rsyslog/
+        regex     = rsyslog-(__VER__)\.tar\.gz
+    }
+
+%prep
+    %setup -q
+    %patch -p0
+
+%build
+    #   configure program
+    %{l_shtool} subst \
+        -e 's;/etc/rsyslog.conf;%{l_prefix}/etc/rsyslog.conf;' \
+        -e 's;/etc/rsyslogd.pid;%{l_prefix}/var/rsyslog/run/rsyslog.pid;' \
+        -e 's;/lib/rsyslog/;%{l_prefix}/lib/rsyslog/;' \
+        -e 's;/var/run/log;%{l_prefix}/var/rsyslog/log;' \
+        syslogd.c
+    CC="%{l_cc}" \
+    CFLAGS="%{l_cflags -O}" \
+    CPPFLAGS="%{l_cppflags}" \
+    LDFLAGS="%{l_ldflags}" \
+%if "%{with_pgsql}" == "yes"
+    LIBS="`pg_config --libs`" \
+%endif
+    ./configure \
+        --prefix=%{l_prefix} \
+        --mandir=%{l_prefix}/man \
+        --enable-regexp \
+        --enable-zlib \
+%if "%{with_kerberos}" == "yes"
+        --enable-gssapi-krb5 \
+%endif
+%if "%{with_mysql}" == "yes"
+        --enable-mysql \
+%endif
+%if "%{with_pgsql}" == "yes"
+        --enable-pgsql \
+%endif
+        --disable-klogd
+
+    #   build program
+    %{l_make} %{l_mflags -O}
+
+%install
+    rm -rf $RPM_BUILD_ROOT
+
+    #   install program
+    %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
+
+    #   strip down installation
+    strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
+    rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/rsyslog/*.la >/dev/null 2>&1 || true
+    rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/rfc3195d
+    rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/rklogd
+    rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man8/rfc3195d.8
+    rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man8/rklogd.8
+
+    #   install default configuration
+    %{l_shtool} mkdir -f -p -m 755 \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/rsyslog
+    %{l_shtool} install -c -m 644 %{l_value -s -a} \
+        %{SOURCE rsyslog.conf} $RPM_BUILD_ROOT%{l_prefix}/etc/rsyslog/
+
+    #   install run-command script
+    %{l_shtool} mkdir -f -p -m 755 \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
+    %{l_shtool} install -c -m 644 %{l_value -s -a} \
+        %{SOURCE rc.rsyslog} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
+
+    #   create run-time directories
+    %{l_shtool} mkdir -f -p -m 755 \
+        $RPM_BUILD_ROOT%{l_prefix}/var/rsyslog/run \
+        $RPM_BUILD_ROOT%{l_prefix}/var/rsyslog/log
+
+    #   determine installation files
+    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
+        %{l_files_std} \
+        '%config %{l_prefix}/etc/rsyslog/*'
+
+%files -f files
+
+%clean
+    rm -rf $RPM_BUILD_ROOT
+
+%post
+    #   after upgrade, restart service
+    [ $1 -eq 2 ] || exit 0
+    eval `%{l_rc} rsyslog status 2>/dev/null`
+    [ ".$rsyslog_active" = .yes ] && %{l_rc} rsyslog restart
+    exit 0
+
+%preun
+    #   before erase, stop service and remove run-time files
+    [ $1 -eq 0 ] || exit 0
+    %{l_rc} rsyslog stop 2>/dev/null
+    rm -f $RPM_INSTALL_PREFIX/var/rsyslog/log/* >/dev/null 2>&1 || true
+    rm -f $RPM_INSTALL_PREFIX/var/rsyslog/run/* >/dev/null 2>&1 || true
+    exit 0
+