Merge remote-tracking branch 'github/pr/371'.
[gentoo.git] / app-admin / puppet / puppet-3.7.3-r1.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI="5"
6
7 USE_RUBY="ruby19 ruby20"
8
9 RUBY_FAKEGEM_RECIPE_TEST="rspec"
10
11 inherit elisp-common xemacs-elisp-common eutils user ruby-fakegem versionator
12
13 DESCRIPTION="A system automation and configuration management software"
14 HOMEPAGE="http://puppetlabs.com/"
15 SRC_URI="http://downloads.puppetlabs.com/puppet/${P}.tar.gz"
16
17 LICENSE="Apache-2.0 GPL-2"
18 SLOT="0"
19 KEYWORDS="amd64 hppa ppc sparc x86"
20 IUSE="augeas diff doc emacs ldap minimal rrdtool selinux shadow sqlite vim-syntax xemacs"
21
22 ruby_add_rdepend "
23         dev-ruby/hiera
24         >=dev-ruby/rgen-0.6.5 =dev-ruby/rgen-0.6*
25         >=dev-ruby/facter-1.6.2 <dev-ruby/facter-3
26         dev-ruby/json
27         augeas? ( dev-ruby/ruby-augeas )
28         diff? ( dev-ruby/diff-lcs )
29         doc? ( dev-ruby/rdoc )
30         ldap? ( dev-ruby/ruby-ldap )
31         shadow? ( dev-ruby/ruby-shadow )
32         sqlite? ( dev-ruby/sqlite3 )
33         virtual/ruby-ssl"
34
35 DEPEND="${DEPEND}
36         ruby_targets_ruby19? ( dev-lang/ruby:1.9[yaml] )
37         emacs? ( virtual/emacs )
38         xemacs? ( app-editors/xemacs )"
39 RDEPEND="${RDEPEND}
40         ruby_targets_ruby19? ( dev-lang/ruby:1.9[yaml] )
41         rrdtool? ( >=net-analyzer/rrdtool-1.2.23[ruby] )
42         selinux? (
43                 sys-libs/libselinux[ruby]
44                 sec-policy/selinux-puppet
45         )
46         vim-syntax? ( >=app-vim/puppet-syntax-3.0.1 )
47         >=app-portage/eix-0.18.0"
48
49 SITEFILE="50${PN}-mode-gentoo.el"
50
51 pkg_setup() {
52         enewgroup puppet
53         enewuser puppet -1 -1 /var/lib/puppet puppet
54 }
55
56 all_ruby_prepare() {
57         # Avoid spec that require unpackaged json-schema.
58         rm spec/lib/matchers/json.rb $( grep -Rl matchers/json spec) || die
59
60         # Avoid Rails specs to avoid this dependency and because they
61         # currently fail against Rails 4.1.
62         find spec -type f -name '*rails*' -o -name '*active_record*' | xargs rm || die
63         rm -r spec/unit/rails || die
64         rm spec/unit/parser/collector_spec.rb || die
65
66         # Avoid specs that can only run in the puppet.git repository. This
67         # should be narrowed down to the specific specs.
68         rm spec/integration/parser/compiler_spec.rb spec/integration/parser/future_compiler_spec.rb || die
69
70         # Avoid failing spec that need further investigation.
71         rm spec/unit/module_tool/metadata_spec.rb || die
72 }
73
74 all_ruby_compile() {
75         if use emacs ; then
76                 elisp-compile ext/emacs/puppet-mode.el
77         fi
78
79         if use xemacs ; then
80                 # Create a separate version for xemacs to be able to install
81                 # emacs and xemacs in parallel.
82                 mkdir ext/xemacs
83                 cp ext/emacs/* ext/xemacs/
84                 xemacs-elisp-compile ext/xemacs/puppet-mode.el
85         fi
86 }
87
88 each_ruby_install() {
89         each_fakegem_install
90         #${RUBY} install.rb --destdir="${D}" install || die
91 }
92
93 all_ruby_install() {
94         all_fakegem_install
95
96         #systemd stuffs
97         insinto /usr/lib/systemd/system
98         doins "${WORKDIR}/all/${P}/ext/systemd/puppet.service"
99         insinto /usr/lib/tmpfiles.d
100         newins "${FILESDIR}/tmpfiles.d" "puppet.conf"
101
102         newinitd "${FILESDIR}"/puppet.init-r1 puppet
103
104         # Initial configuration files
105         insinto /etc/puppet
106
107         # Location of log and data files
108         keepdir /var/log/puppet
109         fowners -R puppet:puppet /var/log/puppet
110
111         if use minimal ; then
112                 rm "${ED}/etc/puppet/auth.conf"
113         else
114                 insinto /usr/lib/systemd/system
115                 doins "${WORKDIR}/all/${P}/ext/systemd/puppetmaster.service"
116                 newinitd "${FILESDIR}"/puppetmaster.init-r1 puppetmaster
117                 newconfd "${FILESDIR}"/puppetmaster.confd puppetmaster
118
119                 insinto /etc/puppet
120
121                 keepdir /etc/puppet/manifests
122                 keepdir /etc/puppet/modules
123
124                 keepdir /var/lib/puppet/ssl
125                 keepdir /var/lib/puppet/facts
126                 keepdir /var/lib/puppet/files
127                 fowners -R puppet:puppet /var/lib/puppet
128                 fperms 0750 /var/lib/puppet
129         fi
130         fperms 0750 /etc/puppet
131         fowners :puppet /etc/puppet
132
133         if use emacs ; then
134                 elisp-install ${PN} ext/emacs/puppet-mode.el*
135                 elisp-site-file-install "${FILESDIR}/${SITEFILE}"
136         fi
137
138         if use xemacs ; then
139                 xemacs-elisp-install ${PN} ext/xemacs/puppet-mode.el*
140                 xemacs-elisp-site-file-install "${FILESDIR}/${SITEFILE}"
141         fi
142
143         if use ldap ; then
144                 insinto /etc/openldap/schema; doins ext/ldap/puppet.schema
145         fi
146
147         # ext and examples files
148         for f in $(find ext examples -type f) ; do
149                 docinto "$(dirname ${f})"; dodoc "${f}"
150         done
151 }
152
153 pkg_postinst() {
154         elog
155         elog "Please, *don't* include the --ask option in EMERGE_EXTRA_OPTS as this could"
156         elog "cause puppet to hang while installing packages."
157         elog
158         elog "Portage Puppet module with Gentoo-specific resources:"
159         elog "http://forge.puppetlabs.com/gentoo/portage"
160         elog
161
162         if [ \
163                 -f "${EPREFIX}/etc/puppet/puppetd.conf" -o \
164                 -f "${EPREFIX}/etc/puppet/puppetmaster.conf" -o \
165                 -f "${EPREFIX}/etc/puppet/puppetca.conf" \
166         ] ; then
167                 elog
168                 elog "Please remove deprecated config files."
169                 elog "  /etc/puppet/puppetca.conf"
170                 elog "  /etc/puppet/puppetd.conf"
171                 elog "  /etc/puppet/puppetmasterd.conf"
172                 elog
173         fi
174
175         if [ "$(get_major_version $REPLACING_VERSIONS)" = "2" ]; then
176                 elog
177                 elog "If you're upgrading from 2.x then we strongly suggest you to read:"
178                 elog "http://docs.puppetlabs.com/guides/upgrading.html"
179                 elog
180         fi
181
182         use emacs && elisp-site-regen
183         use xemacs && xemacs-elisp-site-regen
184 }
185
186 pkg_postrm() {
187         use emacs && elisp-site-regen
188         use xemacs && xemacs-elisp-site-regen
189 }