app-editors/kakoune: drop old 0_pre20160620
[gentoo.git] / net-misc / cfengine / cfengine-3.4.5.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
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.com/source-code/download?file=${MY_P}.tar.gz -> ${MY_P}.tar.gz"
16
17 LICENSE="GPL-3"
18 SLOT="3"
19 KEYWORDS="~amd64 ~arm ~ppc ~s390 ~sparc ~x86"
20
21 IUSE="acl examples html libvirt mysql postgres +qdbm selinux tests tokyocabinet
22 vim-syntax xml"
23
24 DEPEND=">=sys-libs/db-4
25         acl? ( virtual/acl )
26         mysql? ( virtual/mysql )
27         postgres? ( dev-db/postgresql )
28         selinux? ( sys-libs/libselinux )
29         tokyocabinet? ( dev-db/tokyocabinet )
30         qdbm? ( dev-db/qdbm )
31         libvirt? ( app-emulation/libvirt )
32         xml? ( dev-libs/libxml2:2  ) \
33         dev-libs/openssl
34         dev-libs/libpcre"
35 RDEPEND="${DEPEND}"
36 PDEPEND="vim-syntax? ( app-vim/cfengine-syntax )"
37
38 REQUIRED_USE="^^ ( qdbm tokyocabinet )"
39
40 S="${WORKDIR}/${MY_P}"
41
42 src_prepare() {
43         default
44
45         epatch "${FILESDIR}/${P}-acl.patch"
46         epatch "${FILESDIR}/${P}-ifconfig.patch"
47
48         eautoreconf
49 }
50
51 src_configure() {
52         # Enforce /var/cfengine for historical compatibility
53         econf \
54                 --enable-fhs \
55                 --docdir=/usr/share/doc/${PF} \
56                 --with-workdir=/var/cfengine \
57                 --with-pcre \
58                 $(use_with acl libacl) \
59                 $(use_with qdbm) \
60                 $(use_with tokyocabinet) \
61                 $(use_with postgres postgresql) \
62                 $(use_with mysql) \
63                 $(use_with libvirt) \
64                 $(use_enable selinux)
65
66         # Fix Makefile to skip inputs, see below "examples"
67         #sed -i -e 's/\(SUBDIRS.*\) inputs/\1/' Makefile || die
68
69         # We install the documentation through portage
70         sed -i -e 's/\(install-data-am.*\) install-docDATA/\1/' Makefile || die
71 }
72
73 src_install() {
74         newinitd "${FILESDIR}"/cf-serverd.rc6 cf-serverd || die
75         newinitd "${FILESDIR}"/cf-monitord.rc6 cf-monitord || die
76         newinitd "${FILESDIR}"/cf-execd.rc6 cf-execd || die
77
78         emake DESTDIR="${D}" install || die
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 report; do
98                 dosym /usr/sbin/cf-$bin /var/cfengine/bin/cf-$bin || die
99         done
100
101         if use html; then
102                 docinto html
103                 dohtml -r docs/ || die
104         fi
105 }
106
107 pkg_postinst() {
108         echo
109         elog "NOTE: BDB (BerkelyDB) support has been removed as of ${PN}-3.3.0"
110         echo
111         einfo "Init scripts for cf-serverd, cf-monitord, and cf-execd are provided."
112         einfo
113         einfo "To run cfengine out of cron every half hour modify your crontab:"
114         einfo "0,30 * * * *    /usr/sbin/cf-execd -F"
115         echo
116
117         elog "If you run cfengine the very first time, you MUST generate the keys for cfengine by running:"
118         elog "emerge --config ${CATEGORY}/${PN}"
119
120         # Fix old cf-servd, remove it after some releases.
121         local found=0
122         for fname in $(find /etc/runlevels/ -type f -or -type l -name 'cf-servd'); do
123                 found=1
124                 rm $fname
125                 ln -s /etc/init.d/cf-serverd $(echo $fname | sed 's:cf-servd:cf-serverd:')
126         done
127
128         if [ "${found}" -eq 1 ]; then
129                 echo
130                 elog "/etc/init.d/cf-servd has been renamed to /etc/init.d/cf-serverd"
131         fi
132 }
133
134 pkg_config() {
135         if [ "${ROOT}" == "/" ]; then
136                 if [ ! -f "/var/cfengine/ppkeys/localhost.priv" ]; then
137                         einfo "Generating keys for localhost."
138                         /usr/sbin/cf-key
139                 fi
140         else
141                 die "cfengine cfkey does not support any value of ROOT other than /."
142         fi
143 }