app-editors/kakoune: drop old 0_pre20160620
[gentoo.git] / net-misc / cfengine / cfengine-3.5.3.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.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 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
43         epatch "${FILESDIR}/${PN}-3.4.5-acl.patch"
44         epatch "${FILESDIR}/${P}-ifconfig.patch"
45
46         eautoreconf
47 }
48
49 src_configure() {
50         # Enforce /var/cfengine for historical compatibility
51
52         econf \
53                 --enable-fhs \
54                 --docdir=/usr/share/doc/${PF} \
55                 --with-workdir=/var/cfengine \
56                 --with-pcre \
57                 $(use_with acl libacl) \
58                 $(use_with qdbm) \
59                 $(use_with tokyocabinet) \
60                 $(use_with postgres postgresql) \
61                 $(use_with mysql mysql check) \
62                 $(use_with libvirt) \
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 the 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
79         # fix ifconfig path in provided promises
80         find "${D}"/usr/share -name "*.cf" | xargs sed -i "s,/sbin/ifconfig,$(which ifconfig),g"
81
82         # Evil workaround for now..
83         mv "${D}"/usr/share/doc/${PN}/ "${D}"/usr/share/doc/${PF}
84
85         dodoc AUTHORS
86
87         if ! use examples; then
88                 rm -rf "${D}"/usr/share/doc/${PF}/example*
89         fi
90
91         # Create cfengine working directory
92         dodir /var/cfengine/bin
93         fperms 700 /var/cfengine
94
95         # Copy cfagent into the cfengine tree otherwise cfexecd won't
96         # find it. Most hosts cache their copy of the cfengine
97         # binaries here. This is the default search location for the
98         # binaries.
99         for bin in promises agent monitord serverd execd runagent key; do
100                 dosym /usr/sbin/cf-$bin /var/cfengine/bin/cf-$bin || die
101         done
102 }
103
104 pkg_postinst() {
105         echo
106         elog "NOTE: BDB (BerkelyDB) support has been removed as of ${PN}-3.3.0"
107         echo
108         einfo "Init scripts for cf-serverd, cf-monitord, and cf-execd are provided."
109         einfo
110         einfo "To run cfengine out of cron every half hour modify your crontab:"
111         einfo "0,30 * * * *    /usr/sbin/cf-execd -F"
112         echo
113
114         elog "If you run cfengine the very first time, you MUST generate the keys for cfengine by running:"
115         elog "emerge --config ${CATEGORY}/${PN}"
116
117         # Fix old cf-servd, remove it after some releases.
118         local found=0
119         for fname in $(find /etc/runlevels/ -type f -or -type l -name 'cf-servd'); do
120                 found=1
121                 rm $fname
122                 ln -s /etc/init.d/cf-serverd $(echo $fname | sed 's:cf-servd:cf-serverd:')
123         done
124
125         if [ "${found}" -eq 1 ]; then
126                 echo
127                 elog "/etc/init.d/cf-servd has been renamed to /etc/init.d/cf-serverd"
128         fi
129 }
130
131 pkg_config() {
132         if [ "${ROOT}" == "/" ]; then
133                 if [ ! -f "/var/cfengine/ppkeys/localhost.priv" ]; then
134                         einfo "Generating keys for localhost."
135                         /usr/sbin/cf-key
136                 fi
137         else
138                 die "cfengine cfkey does not support any value of ROOT other than /."
139         fi
140 }