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.package-repos.s3.amazonaws.com/tarballs/${MY_P}.tar.gz -> ${MY_P}.tar.gz"
19 KEYWORDS="~amd64 ~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}"
42 epatch "${FILESDIR}/${P}-ifconfig.patch"
43 epatch "${FILESDIR}/${P}-sysmacros.patch"
48 # Enforce /var/cfengine for historical compatibility
52 --docdir=/usr/share/doc/${PF} \
53 --with-workdir=/var/cfengine \
55 $(use_with acl libacl) \
57 $(use_with tokyocabinet) \
58 $(use_with postgres postgresql) \
59 $(use_with mysql mysql check) \
63 # Fix Makefile to skip inputs, see below "examples"
64 #sed -i -e 's/\(SUBDIRS.*\) inputs/\1/' Makefile || die
66 # We install the documentation through portage
67 sed -i -e 's/\(install-data-am.*\) install-docDATA/\1/' Makefile || die
71 newinitd "${FILESDIR}"/cf-serverd.rc6 cf-serverd || die
72 newinitd "${FILESDIR}"/cf-monitord.rc6 cf-monitord || die
73 newinitd "${FILESDIR}"/cf-execd.rc6 cf-execd || die
75 emake DESTDIR="${D}" install || die
77 # fix ifconfig path in provided promises
78 find "${D}"/usr/share -name "*.cf" | xargs sed -i "s,/sbin/ifconfig,$(which ifconfig),g"
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; do
98 dosym /usr/sbin/cf-$bin /var/cfengine/bin/cf-$bin || die
104 elog "NOTE: BDB (BerkelyDB) support has been removed as of ${PN}-3.3.0"
106 einfo "Init scripts for cf-serverd, cf-monitord, and cf-execd are provided."
108 einfo "To run cfengine out of cron every half hour modify your crontab:"
109 einfo "0,30 * * * * /usr/sbin/cf-execd -F"
112 elog "If you run cfengine the very first time, you MUST generate the keys for cfengine by running:"
113 elog "emerge --config ${CATEGORY}/${PN}"
115 # Fix old cf-servd, remove it after some releases.
117 for fname in $(find /etc/runlevels/ -type f -or -type l -name 'cf-servd'); do
120 ln -s /etc/init.d/cf-serverd $(echo $fname | sed 's:cf-servd:cf-serverd:')
123 if [ "${found}" -eq 1 ]; then
125 elog "/etc/init.d/cf-servd has been renamed to /etc/init.d/cf-serverd"
130 if [ "${ROOT}" == "/" ]; then
131 if [ ! -f "/var/cfengine/ppkeys/localhost.priv" ]; then
132 einfo "Generating keys for localhost."
136 die "cfengine cfkey does not support any value of ROOT other than /."