Merge remote-tracking branch 'remotes/github/pr/118'.
[gentoo.git] / sys-cluster / glusterfs / glusterfs-3.7.4.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 PYTHON_COMPAT=( python2_7 )
8 AUTOTOOLS_AUTORECONF=1
9
10 inherit autotools-utils elisp-common eutils multilib python-single-r1 systemd versionator
11
12 DESCRIPTION="GlusterFS is a powerful network/cluster filesystem"
13 HOMEPAGE="http://www.gluster.org/"
14 SRC_URI="http://download.gluster.org/pub/gluster/${PN}/$(get_version_component_range '1-2')/${PV}/${P}.tar.gz"
15
16 LICENSE="|| ( GPL-2 LGPL-3+ )"
17 SLOT="0"
18 KEYWORDS="~amd64 ~ppc ~ppc64 ~x86"
19 IUSE="bd-xlator crypt-xlator debug emacs +fuse +georeplication glupy infiniband qemu-block rsyslog static-libs +syslog systemtap test +tiering vim-syntax +xml"
20
21 REQUIRED_USE="georeplication? ( ${PYTHON_REQUIRED_USE} )
22         glupy? ( ${PYTHON_REQUIRED_USE} )"
23
24 # the tests must be run as root
25 RESTRICT="test"
26
27 # sys-apps/util-linux is required for libuuid
28 RDEPEND="bd-xlator? ( sys-fs/lvm2 )
29         emacs? ( virtual/emacs )
30         fuse? ( >=sys-fs/fuse-2.7.0 )
31         georeplication? ( ${PYTHON_DEPS} )
32         infiniband? ( sys-infiniband/libibverbs:* sys-infiniband/librdmacm:* )
33         qemu-block? ( dev-libs/glib:2 )
34         systemtap? ( dev-util/systemtap )
35         tiering? ( dev-db/sqlite:3 )
36         xml? ( dev-libs/libxml2 )
37         sys-libs/readline:=
38         dev-libs/libaio
39         dev-libs/openssl:=[-bindist]
40         dev-libs/userspace-rcu:=
41         || ( sys-libs/glibc sys-libs/argp-standalone )
42         sys-apps/util-linux"
43 DEPEND="${RDEPEND}
44         virtual/pkgconfig
45         sys-devel/bison
46         sys-devel/flex
47         test? ( >=dev-util/cmocka-1.0.1
48                 app-benchmarks/dbench
49                 dev-vcs/git
50                 net-fs/nfs-utils
51                 virtual/perl-Test-Harness
52                 dev-libs/yajl
53                 sys-fs/xfsprogs
54                 sys-apps/attr )"
55
56 SITEFILE="50${PN}-mode-gentoo.el"
57
58 PATCHES=(
59         "${FILESDIR}/${PN}-3.4.0-silent_rules.patch"
60 )
61
62 DOCS=( AUTHORS ChangeLog NEWS README.md THANKS )
63
64 # Maintainer notes:
65 # * The build system will always configure & build argp-standalone but it'll never use it
66 #   if the argp.h header is found in the system. Which should be the case with
67 #   glibc or if argp-standalone is installed.
68
69 pkg_setup() {
70         ( use georeplication || use glupy ) && python-single-r1_pkg_setup
71 }
72
73 src_prepare() {
74         # build rpc-transport and xlators only once as shared libs
75         find rpc/rpc-transport xlators -name Makefile.am -print0 \
76                 | xargs -0 sed -i -e 's|.*_la_LDFLAGS = .*|\0 -shared|'
77
78         autotools-utils_src_prepare
79 }
80
81 src_configure() {
82         local myeconfargs=(
83                 --disable-dependency-tracking
84                 --disable-silent-rules
85                 --disable-fusermount
86                 $(use_enable debug)
87                 $(use_enable bd-xlator)
88                 $(use_enable crypt-xlator)
89                 $(use_enable fuse fuse-client)
90                 $(use_enable georeplication)
91                 $(use_enable glupy)
92                 $(use_enable infiniband ibverbs)
93                 $(use_enable qemu-block)
94                 $(use_enable static-libs static)
95                 $(use_enable syslog)
96                 $(use_enable systemtap)
97                 $(use_enable test cmocka)
98                 $(use_enable tiering)
99                 $(use_enable xml xml-output)
100                 --docdir=/usr/share/doc/${PF}
101                 --localstatedir=/var
102         )
103         autotools-utils_src_configure
104 }
105
106 src_compile() {
107         autotools-utils_src_compile
108
109         use emacs && elisp-compile extras/glusterfs-mode.el
110 }
111
112 src_install() {
113         autotools-utils_src_install
114
115         rm \
116                 "${D}"/etc/glusterfs/glusterfs-{georep-,}logrotate \
117                 "${D}"/etc/glusterfs/gluster-rsyslog-*.conf \
118                 "${D}"/usr/share/doc/${PF}/glusterfs{-mode.el,.vim} || die "removing false files failed"
119
120         insinto /etc/logrotate.d
121         newins "${FILESDIR}"/glusterfs.logrotate glusterfs
122
123         if use rsyslog ; then
124                 insinto /etc/rsyslog.d
125                 newins extras/gluster-rsyslog-7.2.conf 60-gluster.conf
126         fi
127
128         if use emacs ; then
129                 elisp-install ${PN} extras/glusterfs-mode.el*
130                 elisp-site-file-install "${FILESDIR}/${SITEFILE}"
131         fi
132
133         if use vim-syntax ; then
134                 insinto /usr/share/vim/vimfiles/ftdetect; doins "${FILESDIR}"/${PN}.vim
135                 insinto /usr/share/vim/vimfiles/syntax; doins extras/${PN}.vim
136         fi
137
138         # insert some other tools which might be useful
139         insinto /usr/share/glusterfs/scripts
140         doins \
141                 extras/backend-{cleanup,xattr-sanitize}.sh \
142                 extras/clear_xattrs.sh \
143                 extras/migrate-unify-to-distribute.sh
144
145         # correct permissions on installed scripts
146         # fperms 0755 /usr/share/glusterfs/scripts/*.sh
147         chmod 0755 "${ED}"/usr/share/glusterfs/scripts/*.sh || die
148
149         if use georeplication ; then
150                 # move the gsync-sync-gfid tool to a binary path
151                 # and set a symlink to be compliant with all other distros
152                 mv "${ED}"/usr/{share/glusterfs/scripts/gsync-sync-gfid,libexec/glusterfs/} || die
153                 dosym ../../../libexec/glusterfs/gsync-sync-gfid /usr/share/glusterfs/scripts/gsync-sync-gfid
154         fi
155
156         newinitd "${FILESDIR}/${PN}-r1.initd" glusterfsd
157         newinitd "${FILESDIR}/glusterd-r2.initd" glusterd
158         newconfd "${FILESDIR}/${PN}.confd" glusterfsd
159
160         keepdir /var/log/${PN}
161         keepdir /var/lib/glusterd
162
163         # QA
164         rm -rf "${ED}/var/run/" || die
165         use static-libs || find "${ED}"/usr/$(get_libdir)/ -type f -name '*.la' -delete
166
167         use georeplication && python_fix_shebang "${ED}"
168
169         # upstream already has a patch ready, to be removed once available, http://review.gluster.org/#/c/9458/
170         echo "d /run/gluster 0755 root root -" > "${T}/gluster.tmpfiles" || die
171         systemd_newtmpfilesd "${T}/gluster.tmpfiles" gluster.conf
172 }
173
174 src_test() {
175         ./run-tests.sh || die
176 }
177
178 pkg_postinst() {
179         elog "Starting with ${PN}-3.1.0, you can use the glusterd daemon to configure your"
180         elog "volumes dynamically. To do so, simply use the gluster CLI after running:"
181         elog "  /etc/init.d/glusterd start"
182         echo
183         elog "For static configurations, the glusterfsd startup script can be multiplexed."
184         elog "The default startup script uses /etc/conf.d/glusterfsd to configure the"
185         elog "separate service.  To create additional instances of the glusterfsd service"
186         elog "simply create a symlink to the glusterfsd startup script."
187         echo
188         elog "Example:"
189         elog "    # ln -s glusterfsd /etc/init.d/glusterfsd2"
190         elog "    # ${EDITOR} /etc/glusterfs/glusterfsd2.vol"
191         elog "You can now treat glusterfsd2 like any other service"
192         echo
193         ewarn "You need to use a ntp client to keep the clocks synchronized across all"
194         ewarn "of your servers. Setup a NTP synchronizing service before attempting to"
195         ewarn "run GlusterFS."
196
197         elog
198         elog "If you are upgrading from a previous version of ${PN}, please read:"
199         elog "  http://www.gluster.org/community/documentation/index.php/Upgrade_to_3.5"
200
201         use emacs && elisp-site-regen
202 }
203
204 pkg_postrm() {
205         use emacs && elisp-site-regen
206 }