app-admin/ulogd: minor ebuild updates
[gentoo.git] / app-admin / ulogd / ulogd-2.0.5-r2.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6
7 AUTOTOOLS_AUTORECONF=1
8 AUTOTOOLS_IN_SOURCE_BUILD=1
9
10 inherit autotools-utils eutils flag-o-matic linux-info readme.gentoo systemd user
11
12 DESCRIPTION="A userspace logging daemon for netfilter/iptables related logging"
13 HOMEPAGE="https://netfilter.org/projects/ulogd/index.html"
14 SRC_URI="
15         https://www.netfilter.org/projects/${PN}/files/${P}.tar.bz2
16         ftp://ftp.netfilter.org/pub/${PN}/${P}.tar.bz2
17 "
18
19 LICENSE="GPL-2"
20 SLOT="0"
21 KEYWORDS="amd64 ~ia64 ppc x86"
22 IUSE="dbi doc json mysql nfacct +nfct +nflog pcap postgres sqlite -ulog"
23
24 RDEPEND="
25         || ( net-firewall/iptables net-firewall/nftables )
26         >=net-libs/libnfnetlink-1.0.1
27         dbi? ( dev-db/libdbi )
28         json? ( dev-libs/jansson )
29         nfacct? (
30                 >=net-libs/libmnl-1.0.3
31                 >=net-libs/libnetfilter_acct-1.0.1
32         )
33         nfct? ( >=net-libs/libnetfilter_conntrack-1.0.2 )
34         nflog? ( >=net-libs/libnetfilter_log-1.0.0 )
35         mysql? ( virtual/mysql )
36         pcap? ( net-libs/libpcap )
37         postgres? ( dev-db/postgresql:= )
38         sqlite? ( dev-db/sqlite:3 )
39 "
40 DEPEND="${RDEPEND}
41         doc? (
42                 app-text/linuxdoc-tools
43                 app-text/texlive-core
44                 virtual/latex-base
45         )
46 "
47
48 PATCHES=( "${FILESDIR}/${P}-remove-db-automagic.patch" )
49
50 DOCS=( AUTHORS README TODO )
51 DOC_CONTENTS="
52         You must have at least one logging stack enabled to make ulogd work.
53         Please edit example configuration located at /etc/ulogd.conf
54 "
55
56 pkg_setup() {
57         enewgroup ulogd
58         enewuser ulogd -1 -1 /var/log/ulogd ulogd
59
60         linux-info_pkg_setup
61
62         if kernel_is lt 2 6 14; then
63                 die "ulogd requires kernel newer than 2.6.14"
64         fi
65
66         if kernel_is lt 2 6 18; then
67                 ewarn "You are using kernel older than 2.6.18"
68                 ewarn "Some ulogd features may be unavailable"
69         fi
70
71         if use nfacct && kernel_is lt 3 3 0; then
72                 ewarn "NFACCT input plugin requires kernel newer than 3.3.0"
73         fi
74
75         if use ulog && kernel_is gt 3 17 0; then
76                 ewarn "ULOG target was removed since 3.17.0 kernel release"
77                 ewarn "Consider enabling NFACCT, NFCT or NFLOG support"
78         fi
79 }
80
81 src_prepare() {
82         # - make all logs to be kept in a single dir /var/log/ulogd
83         # - place sockets in /run instead of /tmp
84         sed -i \
85                 -e 's:var/log:var/log/ulogd:g' \
86                 -e 's:tmp:run:g' \
87                 ulogd.conf.in || die 'sed on ulogd.conf.in failed'
88
89         append-lfs-flags
90         autotools-utils_src_prepare
91 }
92
93 src_configure() {
94         local myeconfargs=(
95                 $(use_with dbi)
96                 $(use_with json jansson)
97                 $(use_enable nfacct)
98                 $(use_enable nfct)
99                 $(use_enable nflog)
100                 $(use_with mysql)
101                 $(use_with pcap)
102                 $(use_with postgres pgsql)
103                 $(use_with sqlite)
104                 $(use_enable ulog)
105         )
106         autotools-utils_src_configure
107 }
108
109 src_compile() {
110         autotools-utils_src_compile
111
112         if use doc; then
113                 # Prevent access violations from bitmap font files generation
114                 export VARTEXFONTS="${T}"/fonts
115                 emake -C doc
116         fi
117 }
118
119 src_install() {
120         autotools-utils_src_install
121         readme.gentoo_create_doc
122         prune_libtool_files --modules
123
124         if use doc; then
125                 dohtml doc/${PN}.html
126                 dodoc doc/${PN}.dvi doc/${PN}.txt doc/${PN}.ps
127         fi
128
129         use sqlite && dodoc doc/sqlite3.table
130         use mysql && dodoc doc/mysql-*.sql
131         use postgres && dodoc doc/pgsql-*.sql
132         doman ${PN}.8
133
134         insinto /etc
135         doins ${PN}.conf
136         fowners root:ulogd /etc/ulogd.conf
137         fperms 640 /etc/ulogd.conf
138
139         newinitd "${FILESDIR}/${PN}.init-r1" ${PN}
140         systemd_newunit "${FILESDIR}/${PN}.service-r1" ${PN}.service
141
142         insinto /etc/logrotate.d
143         newins "${FILESDIR}/${PN}.logrotate" ${PN}
144
145         diropts -o ulogd -g ulogd
146         keepdir /var/log/ulogd
147 }