Merge remote-tracking branch 'github/pr/371'.
[gentoo.git] / app-admin / puppet / puppet-4.2.1-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="ruby20 ruby21"
8
9 RUBY_FAKEGEM_RECIPE_TEST="rspec3"
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 ~x86"
20 IUSE="augeas diff doc emacs ldap rrdtool selinux shadow sqlite vim-syntax xemacs"
21 RESTRICT="test"
22
23 ruby_add_rdepend "
24         dev-ruby/hiera
25         >=dev-ruby/rgen-0.6.5
26         dev-ruby/json
27         >=dev-ruby/facter-3.0.0
28         augeas? ( dev-ruby/ruby-augeas )
29         diff? ( dev-ruby/diff-lcs )
30         doc? ( dev-ruby/rdoc )
31         ldap? ( dev-ruby/ruby-ldap )
32         shadow? ( dev-ruby/ruby-shadow )
33         sqlite? ( dev-ruby/sqlite3 )
34         virtual/ruby-ssl"
35
36 ruby_add_bdepend "
37         test? (
38                 dev-ruby/mocha
39                 dev-ruby/rack
40                 dev-ruby/rspec-its
41         )"
42 # this should go in the above lists, but isn't because of test deps not being keyworded
43 #               dev-ruby/rspec-collection_matchers
44
45 DEPEND+=" ${DEPEND}
46         emacs? ( virtual/emacs )
47         xemacs? ( app-editors/xemacs )"
48 RDEPEND+=" ${RDEPEND}
49         rrdtool? ( >=net-analyzer/rrdtool-1.2.23[ruby] )
50         selinux? (
51                 sys-libs/libselinux[ruby]
52                 sec-policy/selinux-puppet
53         )
54         vim-syntax? ( >=app-vim/puppet-syntax-3.0.1 )
55         >=app-portage/eix-0.18.0"
56
57 SITEFILE="50${PN}-mode-gentoo.el"
58
59 pkg_setup() {
60         enewgroup puppet
61         enewuser puppet -1 -1 /var/lib/puppet puppet
62 }
63
64 all_ruby_prepare() {
65         # Avoid spec that require unpackaged json-schema.
66         rm spec/lib/matchers/json.rb $( grep -Rl matchers/json spec) || die
67
68         # can't be run within portage.
69         epatch "${FILESDIR}/puppet-fix-tests-4.x.patch"
70
71         # Avoid specs that can only run in the puppet.git repository. This
72         # should be narrowed down to the specific specs.
73         rm spec/integration/parser/compiler_spec.rb || die
74
75         # Avoid failing spec that need further investigation.
76         rm spec/unit/module_tool/metadata_spec.rb || die
77 }
78
79 all_ruby_compile() {
80         if use emacs ; then
81                 elisp-compile ext/emacs/puppet-mode.el
82         fi
83
84         if use xemacs ; then
85                 # Create a separate version for xemacs to be able to install
86                 # emacs and xemacs in parallel.
87                 mkdir ext/xemacs
88                 cp ext/emacs/* ext/xemacs/
89                 xemacs-elisp-compile ext/xemacs/puppet-mode.el
90         fi
91 }
92
93 each_ruby_install() {
94         each_fakegem_install
95 #       dosym "/usr/$(get_libdir)/ruby/gems/$(ruby_get_version)/gems/${P}" "/usr/$(get_libdir)/ruby/gems/$(ruby_get_version)/gems/${PN}"
96 }
97
98 all_ruby_install() {
99         all_fakegem_install
100
101         # systemd stuffs
102         insinto /usr/lib/systemd/system
103         doins "${WORKDIR}/all/${P}/ext/systemd/puppet.service"
104
105         # tmpfiles stuff
106         insinto /usr/lib/tmpfiles.d
107         newins "${FILESDIR}/tmpfiles.d" "puppet.conf"
108
109         # openrc init stuff
110         newinitd "${FILESDIR}"/puppet.init-4.x puppet
111         newinitd "${FILESDIR}"/puppetmaster.init-4.x puppetmaster
112         newconfd "${FILESDIR}"/puppetmaster.confd puppetmaster
113
114         keepdir /etc/puppetlabs/puppet/ssl
115
116         keepdir /var/lib/puppet/facts
117         keepdir /var/lib/puppet/files
118         fowners -R puppet:puppet /var/lib/puppet
119
120         fperms 0750 /var/lib/puppet
121
122         fperms 0750 /etc/puppetlabs
123         fperms 0750 /etc/puppetlabs/puppet
124         fperms 0750 /etc/puppetlabs/puppet/ssl
125         fowners -R :puppet /etc/puppetlabs
126         fowners -R :puppet /var/lib/puppet
127
128         if use emacs ; then
129                 elisp-install ${PN} ext/emacs/puppet-mode.el*
130                 elisp-site-file-install "${FILESDIR}/${SITEFILE}"
131         fi
132
133         if use xemacs ; then
134                 xemacs-elisp-install ${PN} ext/xemacs/puppet-mode.el*
135                 xemacs-elisp-site-file-install "${FILESDIR}/${SITEFILE}"
136         fi
137
138         if use ldap ; then
139                 insinto /etc/openldap/schema; doins ext/ldap/puppet.schema
140         fi
141
142         # ext and examples files
143         for f in $(find ext examples -type f) ; do
144                 docinto "$(dirname ${f})"; dodoc "${f}"
145         done
146 }
147
148 pkg_postinst() {
149         elog
150         elog "Please, *don't* include the --ask option in EMERGE_EXTRA_OPTS as this could"
151         elog "cause puppet to hang while installing packages."
152         elog
153         elog "Portage Puppet module with Gentoo-specific resources:"
154         elog "http://forge.puppetlabs.com/gentoo/portage"
155         elog
156
157         if [ "$(get_major_version $REPLACING_VERSIONS)" = "3" ]; then
158                 elog
159                 elog "If you're upgrading from 3.x then please move everything in /etc/puppet to"
160                 elog "/etc/puppetlabs/puppet"
161                 elog "Also, puppet now uses config directories for modules and manifests."
162                 elog "See https://docs.puppetlabs.com/puppet/4.0/reference/upgrade_agent.html"
163                 elog "and https://docs.puppetlabs.com/puppet/4.0/reference/upgrade_server.html"
164                 elog "for more information."
165                 elog
166         fi
167
168         use emacs && elisp-site-regen
169         use xemacs && xemacs-elisp-site-regen
170 }
171
172 pkg_postrm() {
173         use emacs && elisp-site-regen
174         use xemacs && xemacs-elisp-site-regen
175 }