summaryrefslogtreecommitdiff
blob: c0c19179498948b0ae53674c5248e43d7885cfd6 (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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-cluster/heartbeat/heartbeat-2.0.8.ebuild,v 1.17 2009/11/18 17:36:35 ssuominen Exp $

inherit autotools flag-o-matic eutils

DESCRIPTION="Heartbeat high availability cluster manager"
HOMEPAGE="http://www.linux-ha.org"
SRC_URI="http://www.linux-ha.org/download/${P}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="amd64 ia64 -mips ~ppc ~ppc64 -s390 sparc ~x86"
IUSE="ldirectord doc snmp management"

RDEPEND="
	=dev-libs/glib-2*
	net-libs/libnet
	>=dev-lang/perl-5.8.8
	net-misc/iputils
	virtual/ssh
	net-libs/gnutls
	ldirectord? (	sys-cluster/ipvsadm
			dev-perl/Net-DNS
			dev-perl/libwww-perl
			dev-perl/perl-ldap
			virtual/perl-libnet
			dev-perl/Crypt-SSLeay
			dev-perl/HTML-Parser
			dev-perl/perl-ldap
			dev-perl/Mail-IMAPClient
			dev-perl/Mail-POP3Client
			dev-perl/MailTools
	)
	snmp? ( net-analyzer/net-snmp )
	net-misc/telnet-bsd
	dev-lang/swig
	management? (
		>=dev-lang/python-2.4
		>=dev-python/pygtk-2.4
		virtual/pam
	)
	"
DEPEND="${RDEPEND}
	dev-util/pkgconfig"

src_unpack() {
	unpack ${A}
	cd "${S}"
	#epatch "${FILESDIR}"/${P}-update-resources-failcount.patch
	epatch "${FILESDIR}"/${P}-crm-leaks.patch
	epatch "${FILESDIR}"/${P}-delay.patch
	epatch "${FILESDIR}"/${P}-glibc.patch
	epatch "${FILESDIR}"/${P}-asneeded.patch
	sed -i \
		-e 's:libgnutls-config:pkg-config gnutls:g' \
		lib/mgmt/Makefile.am \
		lib/plugins/quorumd/Makefile.am \
		lib/plugins/quorum/Makefile.am \
		membership/quorumd/Makefile.am \
		mgmt/client/Makefile.am \
		mgmt/daemon/Makefile.am
	eautoreconf
}

src_compile() {
	./configure --prefix=/usr \
		--mandir=/usr/share/man \
		--sysconfdir=/etc \
		--localstatedir=/var \
		--with-group-name=cluster \
		--with-group-id=65 \
		--with-ccmuser-name=cluster \
		--with-ccmuser-id=65 \
		--enable-checkpointd \
		--enable-crm \
		--enable-lrm \
		--disable-fatal-warnings \
		$(use_enable management mgmt) \
		|| die
	emake -j 1 || die "compile problem"
}

pkg_preinst() {
	# check for cluster group, if it doesn't exist make it
	if ! grep -q cluster.*65 /etc/group ; then
		groupadd -g 65 cluster
	fi
	# check for cluster user, if it doesn't exist make it
	if ! grep -q cluster.*65 /etc/passwd ; then
		useradd -u 65 -g cluster -s /dev/null -d /var/lib/heartbeat cluster
	fi
}

src_install() {
	make DESTDIR="${D}" install || die

	# heartbeat modules need these dirs
	#keepdir /var/lib/heartbeat/ckpt /var/lib/heartbeat/ccm /var/lib/heartbeat

	keepdir /var/lib/heartbeat/crm /var/lib/heartbeat/lrm /var/lib/heartbeat/fencing
	keepdir /var/lib/heartbeat/cores/cluster /var/lib/heartbeat/cores/root /var/lib/heartbeat/cores/nobody

	keepdir /var/run/heartbeat/ccm /var/run/heartbeat/crm

	keepdir /etc/ha.d/conf

	dosym /usr/sbin/ldirectord /etc/ha.d/resource.d/ldirectord || die

	if use management ; then
		keepdir /var/lib/heartbeat/mgmt
	fi

	# if ! USE="ldirectord" then don't install it
	if ! use ldirectord ; then
		rm "${D}"/etc/init.d/ldirectord
		rm "${D}"/etc/logrotate.d/ldirectord
		rm "${D}"/etc/ha.d/resource.d/ldirectord
		rm "${D}"/usr/share/man/man8/supervise-ldirectord-config.8
		rm "${D}"/usr/share/man/man8/ldirectord.8
		rm "${D}"/usr/sbin/ldirectord
		rm "${D}"/usr/sbin/supervise-ldirectord-config
	fi

	dodir /var/lib/heartbeat/cores/cluster
	keepdir /var/lib/heartbeat/cores/cluster
	newinitd "${FILESDIR}"/heartbeat-init heartbeat

	dodoc ldirectord/ldirectord.cf doc/*.cf doc/haresources doc/authkeys || die
	if use doc ; then
		dodoc README doc/*.txt doc/AUTHORS doc/COPYING  || die
	fi
}

pkg_postinst() {
	# Change wrong permissions
	chown -R cluster:cluster /var/run/heartbeat/ccm
	chown -R cluster:cluster /var/run/heartbeat/crm
	chown -R cluster:cluster /var/lib/heartbeat/cores
	chown -R cluster:cluster /var/lib/heartbeat/crm
	chown -R cluster:cluster /var/lib/heartbeat/pengine
	chown -R cluster:cluster /var/lib/heartbeat/cores/cluster
}