app-editors/kakoune: drop old 0_pre20160620
[gentoo.git] / net-misc / cfengine / cfengine-3.6.2.ebuild
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="5"
5
6 inherit eutils autotools flag-o-matic
7
8 MY_PV="${PV//_beta/b}"
9 MY_PV="${MY_PV/_p/p}"
10 MY_P="${PN}-${MY_PV}"
11
12 DESCRIPTION="An automated suite of programs for configuring and maintaining
13 Unix-like computers"
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"
16
17 LICENSE="GPL-3"
18 SLOT="3"
19 KEYWORDS="~amd64 ~x86"
20
21 IUSE="acl examples libvirt mysql postgres +qdbm selinux tokyocabinet vim-syntax xml"
22
23 DEPEND="acl? ( virtual/acl )
24         mysql? ( virtual/mysql )
25         postgres? ( dev-db/postgresql )
26         selinux? ( sys-libs/libselinux )
27         tokyocabinet? ( dev-db/tokyocabinet )
28         qdbm? ( dev-db/qdbm )
29         libvirt? ( app-emulation/libvirt )
30         xml? ( dev-libs/libxml2:2  ) \
31         dev-libs/openssl
32         dev-libs/libpcre"
33 RDEPEND="${DEPEND}"
34 PDEPEND="vim-syntax? ( app-vim/cfengine-syntax )"
35
36 REQUIRED_USE="^^ ( qdbm tokyocabinet )"
37
38 S="${WORKDIR}/${MY_P}"
39
40 src_prepare() {
41         default
42         epatch "${FILESDIR}/${P}-ifconfig.patch"
43         epatch "${FILESDIR}/${P}-sysmacros.patch"
44         eautoreconf
45 }
46
47 src_configure() {
48         # Enforce /var/cfengine for historical compatibility
49
50         econf \
51                 --enable-fhs \
52                 --docdir=/usr/share/doc/${PF} \
53                 --with-workdir=/var/cfengine \
54                 --with-pcre \
55                 $(use_with acl libacl) \
56                 $(use_with qdbm) \
57                 $(use_with tokyocabinet) \
58                 $(use_with postgres postgresql) \
59                 $(use_with mysql mysql check) \
60                 $(use_with libvirt) \
61                 $(use_enable selinux)
62
63         # Fix Makefile to skip inputs, see below "examples"
64         #sed -i -e 's/\(SUBDIRS.*\) inputs/\1/' Makefile || die
65
66         # We install the documentation through portage
67         sed -i -e 's/\(install-data-am.*\) install-docDATA/\1/' Makefile || die
68 }
69
70 src_install() {
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
74
75         emake DESTDIR="${D}" install || die
76
77         # fix ifconfig path in provided promises
78         find "${D}"/usr/share -name "*.cf" | xargs sed -i "s,/sbin/ifconfig,$(which ifconfig),g"
79
80         # Evil workaround for now..
81         mv "${D}"/usr/share/doc/${PN}/ "${D}"/usr/share/doc/${PF}
82
83         dodoc AUTHORS
84
85         if ! use examples; then
86                 rm -rf "${D}"/usr/share/doc/${PF}/example*
87         fi
88
89         # Create cfengine working directory
90         dodir /var/cfengine/bin
91         fperms 700 /var/cfengine
92
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
96         # binaries.
97         for bin in promises agent monitord serverd execd runagent key; do
98                 dosym /usr/sbin/cf-$bin /var/cfengine/bin/cf-$bin || die
99         done
100 }
101
102 pkg_postinst() {
103         echo
104         elog "NOTE: BDB (BerkelyDB) support has been removed as of ${PN}-3.3.0"
105         echo
106         einfo "Init scripts for cf-serverd, cf-monitord, and cf-execd are provided."
107         einfo
108         einfo "To run cfengine out of cron every half hour modify your crontab:"
109         einfo "0,30 * * * *    /usr/sbin/cf-execd -F"
110         echo
111
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}"
114
115         # Fix old cf-servd, remove it after some releases.
116         local found=0
117         for fname in $(find /etc/runlevels/ -type f -or -type l -name 'cf-servd'); do
118                 found=1
119                 rm $fname
120                 ln -s /etc/init.d/cf-serverd $(echo $fname | sed 's:cf-servd:cf-serverd:')
121         done
122
123         if [ "${found}" -eq 1 ]; then
124                 echo
125                 elog "/etc/init.d/cf-servd has been renamed to /etc/init.d/cf-serverd"
126         fi
127 }
128
129 pkg_config() {
130         if [ "${ROOT}" == "/" ]; then
131                 if [ ! -f "/var/cfengine/ppkeys/localhost.priv" ]; then
132                         einfo "Generating keys for localhost."
133                         /usr/sbin/cf-key
134                 fi
135         else
136                 die "cfengine cfkey does not support any value of ROOT other than /."
137         fi
138 }