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