1 |
# Copyright 1999-2010 Gentoo Foundation |
2 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
# $Header: /var/cvsroot/gentoo-x86/net-misc/cfengine/cfengine-3.1.1.ebuild,v 1.1 2010/11/24 16:56:35 idl0r Exp $ |
4 |
|
5 |
EAPI="3" |
6 |
|
7 |
inherit eutils |
8 |
|
9 |
MY_PV="${PV//_beta/b}" |
10 |
MY_PV="${MY_PV/_p/p}" |
11 |
MY_P="${PN}-${MY_PV}" |
12 |
|
13 |
DESCRIPTION="An automated suite of programs for configuring and maintaining |
14 |
Unix-like computers" |
15 |
HOMEPAGE="http://www.cfengine.org/" |
16 |
SRC_URI="http://www.cfengine.org/tarballs/${MY_P}.tar.gz" |
17 |
|
18 |
LICENSE="GPL-3" |
19 |
SLOT="3" |
20 |
KEYWORDS="~amd64 ~arm ~s390 ~sparc ~x86" |
21 |
|
22 |
IUSE="examples gd graphviz html ldap libvirt mysql pcre postgres qdbm selinux tests tokyocabinet vim-syntax" |
23 |
|
24 |
DEPEND=">=sys-libs/db-4 |
25 |
gd? ( media-libs/gd ) |
26 |
graphviz? ( media-gfx/graphviz ) |
27 |
ldap? ( net-nds/openldap ) |
28 |
libvirt? ( app-emulation/libvirt ) |
29 |
mysql? ( virtual/mysql ) |
30 |
pcre? ( dev-libs/libpcre ) |
31 |
postgres? ( dev-db/postgresql-base ) |
32 |
selinux? ( sys-libs/libselinux ) |
33 |
tokyocabinet? ( dev-db/tokyocabinet ) |
34 |
qdbm? ( dev-db/qdbm ) |
35 |
!tokyocabinet? ( !qdbm? ( >=sys-libs/db-4 ) ) |
36 |
>=dev-libs/openssl-0.9.7" |
37 |
RDEPEND="${DEPEND}" |
38 |
PDEPEND="vim-syntax? ( app-vim/cfengine-syntax )" |
39 |
|
40 |
S="${WORKDIR}/${MY_P}" |
41 |
|
42 |
src_prepare() { |
43 |
# https://cfengine.com/bugtracker/view.php?id=390 |
44 |
epatch "${FILESDIR}/${PN}-3.1.0-cf-key.patch" |
45 |
} |
46 |
|
47 |
src_configure() { |
48 |
local myconf |
49 |
|
50 |
if use mysql || use postgres ; then |
51 |
myconf="--with-sql" |
52 |
else |
53 |
myconf="--without-sql" |
54 |
fi |
55 |
|
56 |
if ! use qdbm && ! use tokyocabinet; then |
57 |
myconf="${myconf} --with-berkeleydb=/usr" |
58 |
fi |
59 |
|
60 |
# Enforce /var/cfengine for historical compatibility |
61 |
econf \ |
62 |
--docdir=/usr/share/doc/"${PF}" \ |
63 |
--with-workdir=/var/cfengine \ |
64 |
${myconf} \ |
65 |
$(use_with gd) \ |
66 |
$(use_with graphviz) \ |
67 |
$(use_with ldap) \ |
68 |
$(use_with libvirt) \ |
69 |
$(use_with pcre) \ |
70 |
$(use_with qdbm) \ |
71 |
$(use_enable selinux) \ |
72 |
$(use_with tokyocabinet) |
73 |
|
74 |
# Fix Makefile to skip inputs, see below "examples" |
75 |
sed -i -e 's/\(SUBDIRS.*\) inputs/\1/' Makefile || die |
76 |
|
77 |
# We install documentation through portage |
78 |
sed -i -e 's/\(install-data-am.*\) install-docDATA/\1/' Makefile || die |
79 |
|
80 |
if use tests; then |
81 |
# Fix Makefiles to install tests in correct directory |
82 |
for i in file_masters file_operands units ; do |
83 |
sed -i -e "s/\(docdir.*\) =.*/\1 = \/usr\/share\/doc\/${PF}\/tests\/${i}/" \ |
84 |
tests/${i}/Makefile || die |
85 |
done |
86 |
else |
87 |
sed -i -e 's/\(SUBDIRS =\).*/\1/' tests/Makefile || die |
88 |
fi |
89 |
} |
90 |
|
91 |
src_install() { |
92 |
newinitd "${FILESDIR}"/cf-serverd.rc6 cf-serverd || die |
93 |
newinitd "${FILESDIR}"/cf-monitord.rc6 cf-monitord || die |
94 |
newinitd "${FILESDIR}"/cf-execd.rc6 cf-execd || die |
95 |
|
96 |
emake DESTDIR="${D}" install || die |
97 |
dodoc AUTHORS ChangeLog NEWS README TODO INSTALL |
98 |
|
99 |
if use examples; then |
100 |
docinto examples |
101 |
dodoc inputs/*.cf || die |
102 |
fi |
103 |
|
104 |
# Create cfengine working directory |
105 |
dodir /var/cfengine/bin |
106 |
fperms 700 /var/cfengine |
107 |
|
108 |
# Copy cfagent into the cfengine tree otherwise cfexecd won't |
109 |
# find it. Most hosts cache their copy of the cfengine |
110 |
# binaries here. This is the default search location for the |
111 |
# binaries. |
112 |
for bin in know promises agent monitord serverd execd runagent key report; do |
113 |
dosym /usr/sbin/cf-$bin /var/cfengine/bin/cf-$bin || die |
114 |
done |
115 |
|
116 |
if use html; then |
117 |
docinto html |
118 |
dohtml -r docs/ || die |
119 |
fi |
120 |
} |
121 |
|
122 |
pkg_postinst() { |
123 |
echo |
124 |
einfo "Init scripts for cf-serverd, cf-monitord, and cf-execd are provided." |
125 |
einfo |
126 |
einfo "To run cfengine out of cron every half hour modify your crontab:" |
127 |
einfo "0,30 * * * * /usr/sbin/cf-execd -F" |
128 |
echo |
129 |
|
130 |
elog "If you run cfengine the very first time, you MUST generate the keys for cfengine by running:" |
131 |
elog "emerge --config ${CATEGORY}/${PN}" |
132 |
|
133 |
# Fix old cf-servd, remove it after some releases. |
134 |
local found=0 |
135 |
for fname in $(find /etc/runlevels/ -type f -or -type l -name 'cf-servd'); do |
136 |
found=1 |
137 |
rm $fname |
138 |
ln -s /etc/init.d/cf-serverd $(echo $fname | sed 's:cf-servd:cf-serverd:') |
139 |
done |
140 |
|
141 |
if [ "${found}" -eq 1 ]; then |
142 |
echo |
143 |
elog "/etc/init.d/cf-servd has been renamed to /etc/init.d/cf-serverd" |
144 |
fi |
145 |
} |
146 |
|
147 |
pkg_config() { |
148 |
if [ "${ROOT}" == "/" ]; then |
149 |
if [ ! -f "/var/cfengine/ppkeys/localhost.priv" ]; then |
150 |
einfo "Generating keys for localhost." |
151 |
/usr/sbin/cf-key |
152 |
fi |
153 |
else |
154 |
die "cfengine cfkey does not support any value of ROOT other than /." |
155 |
fi |
156 |
} |