| 1 |
# Copyright 1999-2013 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.2.4.ebuild,v 1.6 2012/07/30 14:14:10 blueness Exp $ |
| 4 |
|
| 5 |
EAPI="3" |
| 6 |
|
| 7 |
MY_PV="${PV//_beta/b}" |
| 8 |
MY_PV="${MY_PV/_p/p}" |
| 9 |
MY_P="${PN}-${MY_PV}" |
| 10 |
|
| 11 |
DESCRIPTION="An automated suite of programs for configuring and maintaining |
| 12 |
Unix-like computers" |
| 13 |
HOMEPAGE="http://www.cfengine.org/" |
| 14 |
SRC_URI="http://cfengine.com/source-code/download?file=${MY_P}.tar.gz -> ${MY_P}.tar.gz" |
| 15 |
|
| 16 |
LICENSE="GPL-3" |
| 17 |
SLOT="3" |
| 18 |
KEYWORDS="amd64 arm ppc ppc64 ~s390 sparc x86" |
| 19 |
|
| 20 |
# libvirt disabled for now because it blocks stabilization etc. |
| 21 |
IUSE="examples html mysql postgres qdbm selinux tests tokyocabinet vim-syntax" |
| 22 |
|
| 23 |
# libvirt? ( app-emulation/libvirt ) |
| 24 |
DEPEND=">=sys-libs/db-4 |
| 25 |
mysql? ( virtual/mysql ) |
| 26 |
postgres? ( dev-db/postgresql-base ) |
| 27 |
selinux? ( sys-libs/libselinux ) |
| 28 |
tokyocabinet? ( dev-db/tokyocabinet ) |
| 29 |
!tokyocabinet? ( qdbm? ( dev-db/qdbm ) ) |
| 30 |
!tokyocabinet? ( !qdbm? ( >=sys-libs/db-4 ) ) |
| 31 |
>=dev-libs/openssl-0.9.7 |
| 32 |
dev-libs/libpcre" |
| 33 |
RDEPEND="${DEPEND}" |
| 34 |
PDEPEND="vim-syntax? ( app-vim/cfengine-syntax )" |
| 35 |
|
| 36 |
S="${WORKDIR}/${MY_P}" |
| 37 |
|
| 38 |
src_configure() { |
| 39 |
local myconf |
| 40 |
|
| 41 |
# BDB by default, prefer tokyocabinet above qdbm... |
| 42 |
# sqlite3 has been added but stated as experimental/broken... |
| 43 |
if ! use qdbm && ! use tokyocabinet; then |
| 44 |
myconf="${myconf} --with-berkeleydb=/usr" |
| 45 |
elif use qdbm && use tokyocabinet; then |
| 46 |
elog "QDBM and Tokyo Cabinet can't be used together, using Tokyo Cabinet by default" |
| 47 |
myconf="${myconf} --with-tokyocabinet" |
| 48 |
elif use qdbm && ! use tokyocabinet; then |
| 49 |
myconf="${myconf} --with-qdbm" |
| 50 |
elif ! use qdbm && use tokyocabinet; then |
| 51 |
myconf="${myconf} --with-tokyocabinet" |
| 52 |
fi |
| 53 |
|
| 54 |
# Enforce /var/cfengine for historical compatibility |
| 55 |
# $(use_with libvirt) \ |
| 56 |
econf \ |
| 57 |
--docdir=/usr/share/doc/"${PF}" \ |
| 58 |
--with-workdir=/var/cfengine \ |
| 59 |
--with-pcre \ |
| 60 |
${myconf} \ |
| 61 |
$(use_with postgres postgresql) \ |
| 62 |
$(use_with mysql) \ |
| 63 |
$(use_enable selinux) |
| 64 |
|
| 65 |
# Fix Makefile to skip inputs, see below "examples" |
| 66 |
#sed -i -e 's/\(SUBDIRS.*\) inputs/\1/' Makefile || die |
| 67 |
|
| 68 |
# We install documentation through portage |
| 69 |
sed -i -e 's/\(install-data-am.*\) install-docDATA/\1/' Makefile || die |
| 70 |
} |
| 71 |
|
| 72 |
src_install() { |
| 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 |
| 76 |
|
| 77 |
emake DESTDIR="${D}" install || die |
| 78 |
dodoc AUTHORS ChangeLog README INSTALL |
| 79 |
|
| 80 |
if ! use examples; then |
| 81 |
rm -rf "${D}"/usr/share/doc/${PF}/example* |
| 82 |
fi |
| 83 |
|
| 84 |
# Create cfengine working directory |
| 85 |
dodir /var/cfengine/bin |
| 86 |
fperms 700 /var/cfengine |
| 87 |
|
| 88 |
# Copy cfagent into the cfengine tree otherwise cfexecd won't |
| 89 |
# find it. Most hosts cache their copy of the cfengine |
| 90 |
# binaries here. This is the default search location for the |
| 91 |
# binaries. |
| 92 |
for bin in know promises agent monitord serverd execd runagent key report; do |
| 93 |
dosym /usr/sbin/cf-$bin /var/cfengine/bin/cf-$bin || die |
| 94 |
done |
| 95 |
|
| 96 |
if use html; then |
| 97 |
docinto html |
| 98 |
dohtml -r docs/ || die |
| 99 |
fi |
| 100 |
} |
| 101 |
|
| 102 |
pkg_postinst() { |
| 103 |
echo |
| 104 |
einfo "Init scripts for cf-serverd, cf-monitord, and cf-execd are provided." |
| 105 |
einfo |
| 106 |
einfo "To run cfengine out of cron every half hour modify your crontab:" |
| 107 |
einfo "0,30 * * * * /usr/sbin/cf-execd -F" |
| 108 |
echo |
| 109 |
|
| 110 |
elog "If you run cfengine the very first time, you MUST generate the keys for cfengine by running:" |
| 111 |
elog "emerge --config ${CATEGORY}/${PN}" |
| 112 |
|
| 113 |
# Fix old cf-servd, remove it after some releases. |
| 114 |
local found=0 |
| 115 |
for fname in $(find /etc/runlevels/ -type f -or -type l -name 'cf-servd'); do |
| 116 |
found=1 |
| 117 |
rm $fname |
| 118 |
ln -s /etc/init.d/cf-serverd $(echo $fname | sed 's:cf-servd:cf-serverd:') |
| 119 |
done |
| 120 |
|
| 121 |
if [ "${found}" -eq 1 ]; then |
| 122 |
echo |
| 123 |
elog "/etc/init.d/cf-servd has been renamed to /etc/init.d/cf-serverd" |
| 124 |
fi |
| 125 |
} |
| 126 |
|
| 127 |
pkg_config() { |
| 128 |
if [ "${ROOT}" == "/" ]; then |
| 129 |
if [ ! -f "/var/cfengine/ppkeys/localhost.priv" ]; then |
| 130 |
einfo "Generating keys for localhost." |
| 131 |
/usr/sbin/cf-key |
| 132 |
fi |
| 133 |
else |
| 134 |
die "cfengine cfkey does not support any value of ROOT other than /." |
| 135 |
fi |
| 136 |
} |