# Copyright 1999-2018 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 EAPI="6" inherit eutils autotools flag-o-matic MY_PV="${PV//_beta/b}" MY_PV="${MY_PV/_p/p}" MY_P="${PN}-${MY_PV}" DESCRIPTION="An automated suite of programs for configuring and maintaining *nix computers" HOMEPAGE="http://www.cfengine.org/" SRC_URI="http://cfengine-package-repos.s3.amazonaws.com/tarballs/${MY_P}.tar.gz -> ${MY_P}.tar.gz masterfiles? ( http://cfengine-package-repos.s3.amazonaws.com/tarballs/${PN}-masterfiles-${MY_PV}.tar.gz -> ${PN}-masterfiles-${MY_PV}.tar.gz )" LICENSE="GPL-3" SLOT="3" KEYWORDS="~amd64 ~x86" IUSE="acl examples curl libvirt lmdb mysql masterfiles +qdbm pcre postgres tokyocabinet selinux vim-syntax xml yaml" DEPEND="acl? ( virtual/acl ) curl? ( net-misc/curl ) dev-libs/openssl:* libvirt? ( app-emulation/libvirt ) libvirt? ( app-emulation/libvirt ) lmdb? ( dev-db/lmdb ) mysql? ( virtual/mysql ) net-misc/curl pcre? ( dev-libs/libpcre ) postgres? ( dev-db/postgresql:* >=app-eselect/eselect-postgresql-2.2 ) qdbm? ( dev-db/qdbm ) selinux? ( sys-libs/libselinux ) tokyocabinet? ( dev-db/tokyocabinet ) xml? ( dev-libs/libxml2:2 ) yaml? ( dev-libs/libyaml )" RDEPEND="${DEPEND} masterfiles? ( =net-misc/cfengine-masterfiles-${PV} )" PDEPEND="vim-syntax? ( app-vim/cfengine-syntax )" REQUIRED_USE="^^ ( qdbm lmdb tokyocabinet )" S="${WORKDIR}/${MY_P}" src_prepare() { default eautoreconf } src_unpack() { unpack ${MY_P}.tar.gz if use masterfiles; then unpack ${PN}-masterfiles-${MY_PV}.tar.gz fi } src_configure() { # Enforce /var/cfengine for historical compatibility econf \ --enable-fhs \ --docdir=/usr/share/doc/${PF} \ --with-workdir=/var/cfengine \ $(use_with acl libacl check) \ $(use_with curl libcurl) \ $(use_with libvirt) \ $(use_with lmdb) \ $(use_with mysql) \ $(use_with pcre) \ $(use_with postgres postgresql) \ $(use_with qdbm) \ $(use_with tokyocabinet) \ $(use_with xml libxml2) \ $(use_with yaml libyaml) # Fix Makefile to skip inputs, see below "examples" #sed -i -e 's/\(SUBDIRS.*\) inputs/\1/' Makefile || die # We install the documentation through portage sed -i -e 's/\(install-data-am.*\) install-docDATA/\1/' Makefile || die } src_install() { newinitd "${FILESDIR}"/cf-serverd.rc6 cf-serverd || die newinitd "${FILESDIR}"/cf-monitord.rc6 cf-monitord || die newinitd "${FILESDIR}"/cf-execd.rc6 cf-execd || die emake DESTDIR="${D}" install || die dodoc AUTHORS ChangeLog CFVERSION INSTALL README.md || die "dodoc error" if ! use examples; then rm -rf "${D}"/usr/share/doc/${P}/example* || die fi # Create cfengine working directory dodir /var/cfengine/bin || die fperms 700 /var/cfengine # Copy cfagent into the cfengine tree otherwise cfexecd won't # find it. Most hosts cache their copy of the cfengine # binaries here. This is the default search location for the # binaries. for bin in agent execd key monitord promises rpmvercmp runagent serverd upgrade; do dosym "${ED%/}"/usr/sbin/cf-$bin /var/cfengine/bin/cf-$bin || die "dosym error" done if use masterfiles; then dodir /etc/env.d echo 'CONFIG_PROTECT=/var/cfengine/masterfiles' >"${ED}/etc/env.d/99${PN}" || die fi keepdir /var/cfengine/inputs keepdir /var/cfengine/modules keepdir /var/cfengine/outputs keepdir /var/cfengine/plugins keepdir /var/cfengine/ppkeys } pkg_postinst() { echo elog "NOTE: BDB (BerkelyDB) support has been removed as of ${PN}-3.3.0" echo einfo "Init scripts for cf-serverd, cf-monitord, and cf-execd are provided." einfo einfo "To run cfengine out of cron every half hour modify your crontab:" einfo "0,30 * * * * /usr/sbin/cf-execd -F" echo elog "If you run cfengine the very first time, you MUST generate the keys for cfengine by running:" elog "emerge --config ${CATEGORY}/${PN}" # Fix old cf-servd, remove it after some releases. local found=0 for fname in $(find /etc/runlevels/ -type f -or -type l -name 'cf-servd'); do found=1 rm $fname ln -s /etc/init.d/cf-serverd $(echo $fname | sed 's:cf-servd:cf-serverd:') done if [ "${found}" -eq 1 ]; then echo elog "/etc/init.d/cf-servd has been renamed to /etc/init.d/cf-serverd" fi } pkg_config() { if [ "${ROOT}" == "/" ]; then if [ ! -f "/var/cfengine/ppkeys/localhost.priv" ]; then einfo "Generating keys for localhost." /usr/sbin/cf-key fi else die "cfengine cfkey does not support any value of ROOT other than /." fi }