summaryrefslogtreecommitdiff
blob: 5d304156a91f8c2eee23c24a622f3aa60bc47677 (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-misc/quagga/quagga-0.96.5-r1.ebuild,v 1.5 2005/09/14 11:11:08 mrness Exp $

inherit eutils

MD5_PATCH="ht-20040525-0.96.5-bgp-md5.patch"

DESCRIPTION="A free routing daemon replacing Zebra supporting RIP, OSPF and BGP. Includes OSPFAPI, NET-SNMP and IPV6 support."
HOMEPAGE="http://quagga.net/"
KEYWORDS="x86 ~ppc ~sparc ~alpha ~amd64"
SLOT="0"
LICENSE="GPL-2"
SRC_URI="http://www.quagga.net/download/${P}.tar.gz
	tcpmd5? ( http://hasso.linux.ee/quagga/$MD5_PATCH )"

IUSE="ipv6 snmp pam tcpmd5 ospfapi"

DEPEND="virtual/libc
	sys-devel/binutils
	sys-apps/iproute2
	>=sys-libs/libcap-1.10-r3"

[ -z "${QUAGGA_USER_NAME}" ] && QUAGGA_USER_NAME="quagga"
[ -z "${QUAGGA_USER_UID}" ] && QUAGGA_USER_UID=441
[ -z "${QUAGGA_GROUP_NAME}" ] && QUAGGA_GROUP_NAME="quagga"
[ -z "${QUAGGA_GROUP_GID}" ] && QUAGGA_GROUP_GID=441
[ -z "${QUAGGA_VTYGROUP}" ] && QUAGGA_VTYGROUP="quagga"
[ -z "${QUAGGA_USER_SH}" ] && QUAGGA_USER_SH="/bin/false"
[ -z "${QUAGGA_USER_HOMEDIR}" ] && QUAGGA_USER_HOMEDIR=/var/empty
[ -z "${QUAGGA_USER_GROUPS}" ] && QUAGGA_USER_GROUPS=${QUAGGA_GROUP_NAME}
[ -z "${QUAGGA_STATEDIR}" ] && QUAGGA_STATEDIR=/var/run/quagga

pkg_preinst() {
	enewgroup ${QUAGGA_GROUP_NAME} ${QUAGGA_GROUP_GID}
	enewuser ${QUAGGA_USER_NAME} ${QUAGGA_USER_UID} ${QUAGGA_USER_SH} ${QUAGGA_USER_HOMEDIR} ${QUAGGA_USER_GROUPS}
}

src_unpack() {
	unpack ${A} || die
	cd ${S} || die
	[ -d ${FILESDIR}/patches-${PV} ] && epatch ${FILESDIR}/patches-${PV}
}

src_compile() {
	local ipv
	local snmp
	local pam
	local tcpmd5
	local ospfapi

	use ipv6 && ipv="--enable-ipv6 --enable-ripng --enable-ospf6d --enable-rtadv" || ipv="--disable-ipv6 --disable-ripngd --disable-ospf6d"
	use snmp && snmp="--enable-snmp"
	use pam && pam="--with-libpam"

	use tcpmd5 && tcpmd5="--enable-tcp-md5"
	use tcpmd5 && epatch ${DISTDIR}/$MD5_PATCH

	use ospfapi && ospfapi="--enable-opaque-lsa --enable-ospf-te --enable-ospfclient"

	# update makefiles

	export WANT_AUTOMAKE=1.7

	./update-autotools || die

	#
	# ipforward detection is broken (and usersandbox will break it too)
	# thanks to Merlin from irc://irc.freenode.net/#quagga
	#
	export IPFORWARD=ipforward_proc.o
	export zebra_ipforward_path="proc"

	# configure the stuff

	./configure --host=${CHOST} \
		    --prefix=${D}/usr \
		    --enable-tcp-zebra \
	            --enable-nssa \
		    --enable-user=${QUAGGA_USER} \
		    --enable-group=${QUAGGA_GROUP} \
		    --enable-vty-group=${QUAGGA_VTYGROUP} \
		    --with-cflags="${CFLAGS}" \
	            --enable-vtysh ${ipv} ${snmp} ${pam} ${tcpmd5} ${ospfapi} \
		    --sysconfdir=/etc/quagga \
		    --enable-exampledir=${D}/etc/quagga/samples \
		    --includedir=${D}/usr/include \
		    --localstatedir=${QUAGGA_STATEDIR} \
		    --libdir=${D}/usr/lib/quagga \
			|| die
	emake || die
}

src_install() {
	einstall || die

	dodir /etc/quagga || die
	dodir /etc/quagga/samples || die

	keepdir /var/run/quagga || die

	local i MY_SERVICES_LIST="zebra ripd ospfd bgpd"
	use ipv6 && MY_SERVICES_LIST="${MY_SERVICES_LIST} ripngd ospf6d"
	for i in ${MY_SERVICES_LIST} ; do
		newinitd ${FILESDIR}/${i}.init ${i} || die "failed to install ${i} init.d script"
	done
	newconfd ${FILESDIR}/zebra.conf zebra || die "failed to install zebra conf.d script"
}

pkg_postinst() {
	# empty dir for pid files for the new priv separation auth
	#set proper owner/group/perms even if dir already existed
	install -d -m0700 -o ${QUAGGA_USER_NAME} -g ${QUAGGA_GROUP_NAME} ${ROOT}/etc/quagga
	install -d -m0755 -o ${QUAGGA_USER_NAME} -g ${QUAGGA_GROUP_NAME} ${ROOT}/var/run/quagga

	einfo "Sample configuration files can be found in /etc/quagga/samples."
	einfo "You have to create config files in /etc/quagga before"
	einfo "starting one of the daemons."
}