1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 inherit eutils autotools flag-o-matic
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 libvirt mysql postgres +qdbm selinux tokyocabinet vim-syntax xml"
23 DEPEND="acl? ( virtual/acl )
24 mysql? ( virtual/mysql )
25 postgres? ( dev-db/postgresql )
26 selinux? ( sys-libs/libselinux )
27 tokyocabinet? ( dev-db/tokyocabinet )
29 libvirt? ( app-emulation/libvirt )
30 xml? ( dev-libs/libxml2:2 ) \
34 PDEPEND="vim-syntax? ( app-vim/cfengine-syntax )"
36 REQUIRED_USE="^^ ( qdbm tokyocabinet )"
38 S="${WORKDIR}/${MY_P}"
43 epatch "${FILESDIR}/${PN}-3.4.5-acl.patch"
44 epatch "${FILESDIR}/${P}-ifconfig.patch"
50 # Enforce /var/cfengine for historical compatibility
54 --docdir=/usr/share/doc/${PF} \
55 --with-workdir=/var/cfengine \
57 $(use_with acl libacl) \
59 $(use_with tokyocabinet) \
60 $(use_with postgres postgresql) \
61 $(use_with mysql mysql check) \
65 # Fix Makefile to skip inputs, see below "examples"
66 #sed -i -e 's/\(SUBDIRS.*\) inputs/\1/' Makefile || die
68 # We install the documentation through portage
69 sed -i -e 's/\(install-data-am.*\) install-docDATA/\1/' Makefile || die
73 newinitd "${FILESDIR}"/cf-serverd.rc6 cf-serverd || die
74 newinitd "${FILESDIR}"/cf-monitord.rc6 cf-monitord || die
75 newinitd "${FILESDIR}"/cf-execd.rc6 cf-execd || die
77 emake DESTDIR="${D}" install || die
79 # fix ifconfig path in provided promises
80 find "${D}"/usr/share -name "*.cf" | xargs sed -i "s,/sbin/ifconfig,$(which ifconfig),g"
82 # Evil workaround for now..
83 mv "${D}"/usr/share/doc/${PN}/ "${D}"/usr/share/doc/${PF}
87 if ! use examples; then
88 rm -rf "${D}"/usr/share/doc/${PF}/example*
91 # Create cfengine working directory
92 dodir /var/cfengine/bin
93 fperms 700 /var/cfengine
95 # Copy cfagent into the cfengine tree otherwise cfexecd won't
96 # find it. Most hosts cache their copy of the cfengine
97 # binaries here. This is the default search location for the
99 for bin in promises agent monitord serverd execd runagent key; do
100 dosym /usr/sbin/cf-$bin /var/cfengine/bin/cf-$bin || die
106 elog "NOTE: BDB (BerkelyDB) support has been removed as of ${PN}-3.3.0"
108 einfo "Init scripts for cf-serverd, cf-monitord, and cf-execd are provided."
110 einfo "To run cfengine out of cron every half hour modify your crontab:"
111 einfo "0,30 * * * * /usr/sbin/cf-execd -F"
114 elog "If you run cfengine the very first time, you MUST generate the keys for cfengine by running:"
115 elog "emerge --config ${CATEGORY}/${PN}"
117 # Fix old cf-servd, remove it after some releases.
119 for fname in $(find /etc/runlevels/ -type f -or -type l -name 'cf-servd'); do
122 ln -s /etc/init.d/cf-serverd $(echo $fname | sed 's:cf-servd:cf-serverd:')
125 if [ "${found}" -eq 1 ]; then
127 elog "/etc/init.d/cf-servd has been renamed to /etc/init.d/cf-serverd"
132 if [ "${ROOT}" == "/" ]; then
133 if [ ! -f "/var/cfengine/ppkeys/localhost.priv" ]; then
134 einfo "Generating keys for localhost."
138 die "cfengine cfkey does not support any value of ROOT other than /."