summaryrefslogtreecommitdiff
blob: 792fb470f03f088bc87da4bf3f755223a1fd1550 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-analyzer/sancp/sancp-1.6.1-r3.ebuild,v 1.2 2012/06/12 02:59:01 zmedico Exp $

EAPI="2"

inherit eutils toolchain-funcs user

DESCRIPTION="SANCP is a network security tool designed to collect statistical \
	information regarding network traffic and collect the traffic itself in pcap format."
HOMEPAGE="http://www.metre.net/sancp.html"
SRC_URI="http://www.metre.net/files/${P}.tar.gz
	http://sancp.sourceforge.net/${PN}-1.6.1.fix200511.a.patch
	http://sancp.sourceforge.net/${PN}-1.6.1.fix200511.b.patch
	http://sancp.sourceforge.net/${PN}-1.6.1.fix200601.c.patch
	http://sancp.sourceforge.net/${PN}-1.6.1.fix200606.d.patch"

LICENSE="QPL"

SLOT="0"
KEYWORDS="~amd64 ~x86"

IUSE="sguil"

RDEPEND="net-libs/libpcap"
DEPEND="${RDEPEND}"

pkg_setup() {
	enewgroup sancp
	enewuser sancp -1 -1 /dev/null sancp
}

src_prepare() {
	epatch "${DISTDIR}"/${PN}-1.6.1.fix200511.a.patch
	epatch "${DISTDIR}"/${PN}-1.6.1.fix200511.b.patch
	# bug 138337
	epatch "${DISTDIR}"/${PN}-1.6.1.fix200601.c.patch
	epatch "${DISTDIR}"/${PN}-1.6.1.fix200606.d.patch
	epatch "${FILESDIR}"/${P}-compiler.patch
}

src_compile() {
	tc-export CXX CC
	emake || die "make failed"
}

src_install() {
	keepdir /var/log/sancp/
	dodoc docs/CHANGES docs/fields.LIST docs/README docs/SETUP \
		"${FILESDIR}"/sguil_sancp.conf etc/sancp/sancp.conf

	insinto /etc/sancp
	if use sguil ; then
		newins "${FILESDIR}"/sguil_sancp.conf sancp.conf
	else
		doins etc/sancp/sancp.conf
	fi

	dobin sancp

	newinitd "${FILESDIR}"/sancp.rc1 sancp
	newconfd "${FILESDIR}"/sancp.confd sancp
	if use sguil ; then
		sed -i -e /^SANCP_OPTS/s:'sancp':"sguil":g \
			-e s:'-d $LOGDIR/today':"-d /var/lib/sguil/$(hostname)/sancp": \
			"${D}/etc/conf.d/sancp"
	fi

	fowners sancp:sancp /var/log/sancp
	fperms 0770 /var/log/sancp
}

pkg_postinst() {
	elog
	elog "Please modify /etc/sancp/sancp.conf to suit your environment"
	elog
}