1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 inherit eutils autotools
12 DESCRIPTION="An automated suite of programs for configuring and maintaining
14 HOMEPAGE="http://www.cfengine.org/"
15 SRC_URI="http://cfengine.com/source-code/download?file=${MY_P}.tar.gz -> ${MY_P}.tar.gz"
19 KEYWORDS="~amd64 ~arm ~ppc ~s390 ~sparc ~x86"
21 IUSE="acl examples html libvirt mysql postgres +qdbm selinux tests tokyocabinet
24 DEPEND=">=sys-libs/db-4
26 mysql? ( virtual/mysql )
27 postgres? ( dev-db/postgresql )
28 selinux? ( sys-libs/libselinux )
29 tokyocabinet? ( dev-db/tokyocabinet )
31 libvirt? ( app-emulation/libvirt )
32 xml? ( dev-libs/libxml2:2 ) \
36 PDEPEND="vim-syntax? ( app-vim/cfengine-syntax )"
38 REQUIRED_USE="^^ ( qdbm tokyocabinet )"
40 S="${WORKDIR}/${MY_P}"
45 epatch "${FILESDIR}/${P}-acl.patch"
46 epatch "${FILESDIR}/${P}-ifconfig.patch"
52 # Enforce /var/cfengine for historical compatibility
55 --docdir=/usr/share/doc/${PF} \
56 --with-workdir=/var/cfengine \
58 $(use_with acl libacl) \
60 $(use_with tokyocabinet) \
61 $(use_with postgres postgresql) \
66 # Fix Makefile to skip inputs, see below "examples"
67 #sed -i -e 's/\(SUBDIRS.*\) inputs/\1/' Makefile || die
69 # We install the documentation through portage
70 sed -i -e 's/\(install-data-am.*\) install-docDATA/\1/' Makefile || die
74 newinitd "${FILESDIR}"/cf-serverd.rc6 cf-serverd || die
75 newinitd "${FILESDIR}"/cf-monitord.rc6 cf-monitord || die
76 newinitd "${FILESDIR}"/cf-execd.rc6 cf-execd || die
78 emake DESTDIR="${D}" install || die
80 # Evil workaround for now..
81 mv "${D}"/usr/share/doc/${PN}/ "${D}"/usr/share/doc/${PF}
85 if ! use examples; then
86 rm -rf "${D}"/usr/share/doc/${PF}/example*
89 # Create cfengine working directory
90 dodir /var/cfengine/bin
91 fperms 700 /var/cfengine
93 # Copy cfagent into the cfengine tree otherwise cfexecd won't
94 # find it. Most hosts cache their copy of the cfengine
95 # binaries here. This is the default search location for the
97 for bin in promises agent monitord serverd execd runagent key report; do
98 dosym /usr/sbin/cf-$bin /var/cfengine/bin/cf-$bin || die
103 dohtml -r docs/ || die
109 elog "NOTE: BDB (BerkelyDB) support has been removed as of ${PN}-3.3.0"
111 einfo "Init scripts for cf-serverd, cf-monitord, and cf-execd are provided."
113 einfo "To run cfengine out of cron every half hour modify your crontab:"
114 einfo "0,30 * * * * /usr/sbin/cf-execd -F"
117 elog "If you run cfengine the very first time, you MUST generate the keys for cfengine by running:"
118 elog "emerge --config ${CATEGORY}/${PN}"
120 # Fix old cf-servd, remove it after some releases.
122 for fname in $(find /etc/runlevels/ -type f -or -type l -name 'cf-servd'); do
125 ln -s /etc/init.d/cf-serverd $(echo $fname | sed 's:cf-servd:cf-serverd:')
128 if [ "${found}" -eq 1 ]; then
130 elog "/etc/init.d/cf-servd has been renamed to /etc/init.d/cf-serverd"
135 if [ "${ROOT}" == "/" ]; then
136 if [ ! -f "/var/cfengine/ppkeys/localhost.priv" ]; then
137 einfo "Generating keys for localhost."
141 die "cfengine cfkey does not support any value of ROOT other than /."