dev-db/redis: ppc stable wrt bug #614182
[gentoo.git] / dev-db / redis / redis-3.2.8-r2.ebuild
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 inherit autotools eutils flag-o-matic systemd toolchain-funcs user
7
8 DESCRIPTION="A persistent caching system, key-value and data structures database"
9 HOMEPAGE="http://redis.io/"
10 SRC_URI="http://download.redis.io/releases/${P}.tar.gz"
11
12 LICENSE="BSD"
13 KEYWORDS="amd64 ~arm ~arm64 ~hppa ppc ~ppc64 x86 ~amd64-linux ~x86-linux ~x86-macos ~x86-solaris"
14 IUSE="+jemalloc tcmalloc luajit test"
15 SLOT="0"
16
17 RDEPEND="luajit? ( dev-lang/luajit:2 )
18         !luajit? ( >=dev-lang/lua-5.1:* )
19         tcmalloc? ( dev-util/google-perftools )
20         jemalloc? ( >=dev-libs/jemalloc-3.2 )"
21 DEPEND="virtual/pkgconfig
22         >=sys-devel/autoconf-2.63
23         test? ( dev-lang/tcl:0= )
24         ${RDEPEND}"
25 REQUIRED_USE="?? ( tcmalloc jemalloc )"
26
27 S="${WORKDIR}/${PN}-${PV/_/-}"
28
29 pkg_setup() {
30         enewgroup redis 75
31         enewuser redis 75 -1 /var/lib/redis redis
32 }
33
34 src_prepare() {
35         epatch \
36                 "${FILESDIR}"/${PN}-3.2.5-shared.patch \
37                 "${FILESDIR}"/${PN}-3.2.3-config.patch \
38                 "${FILESDIR}"/${PN}-3.2.3-sharedlua.patch
39         eapply_user
40
41         # Copy lua modules into build dir
42         cp "${S}"/deps/lua/src/{fpconv,lua_bit,lua_cjson,lua_cmsgpack,lua_struct,strbuf}.c "${S}"/src || die
43         cp "${S}"/deps/lua/src/{fpconv,strbuf}.h "${S}"/src || die
44         # Append cflag for lua_cjson
45         # https://github.com/antirez/redis/commit/4fdcd213#diff-3ba529ae517f6b57803af0502f52a40bL61
46         append-cflags "-DENABLE_CJSON_GLOBAL"
47
48         # now we will rewrite present Makefiles
49         local makefiles=""
50         for MKF in $(find -name 'Makefile' | cut -b 3-); do
51                 mv "${MKF}" "${MKF}.in"
52                 sed -i  -e 's:$(CC):@CC@:g' \
53                         -e 's:$(CFLAGS):@AM_CFLAGS@:g' \
54                         -e 's: $(DEBUG)::g' \
55                         -e 's:$(OBJARCH)::g' \
56                         -e 's:ARCH:TARCH:g' \
57                         -e '/^CCOPT=/s:$: $(LDFLAGS):g' \
58                         "${MKF}.in" \
59                 || die "Sed failed for ${MKF}"
60                 makefiles+=" ${MKF}"
61         done
62         # autodetection of compiler and settings; generates the modified Makefiles
63         cp "${FILESDIR}"/configure.ac-3.2 configure.ac
64         sed -i  \
65                 -e "/^AC_INIT/s|, [0-9].+, |, $PV, |" \
66                 -e "s:AC_CONFIG_FILES(\[Makefile\]):AC_CONFIG_FILES([${makefiles}]):g" \
67                 -e "/PKG_CHECK_MODULES.*\<LUA\>/s,lua5.1,lua,g" \
68                 configure.ac || die "Sed failed for configure.ac"
69         eautoreconf
70 }
71
72 src_configure() {
73         econf \
74                 $(use_with luajit)
75
76         # Linenoise can't be built with -std=c99, see https://bugs.gentoo.org/451164
77         # geohash-int can't be built with -std=c99 either
78         # also, don't define ANSI/c99 for lua twice
79         sed -i -e "s:-std=c99::g" deps/linenoise/Makefile deps/geohash-int/Makefile deps/Makefile || die
80 }
81
82 src_compile() {
83         tc-export CC AR RANLIB
84
85         local myconf=""
86
87         if use tcmalloc ; then
88                 myconf="${myconf} USE_TCMALLOC=yes"
89         elif use jemalloc ; then
90                 myconf="${myconf} JEMALLOC_SHARED=yes"
91         else
92                 myconf="${myconf} MALLOC=yes"
93         fi
94
95         emake ${myconf} V=1 CC="${CC}" AR="${AR} rcu" RANLIB="${RANLIB}"
96 }
97
98 src_install() {
99         insinto /etc/
100         doins redis.conf sentinel.conf
101         use prefix || fowners redis:redis /etc/{redis,sentinel}.conf
102         fperms 0644 /etc/{redis,sentinel}.conf
103
104         newconfd "${FILESDIR}/redis.confd" redis
105         newinitd "${FILESDIR}/redis.initd-4" redis
106
107         systemd_newunit "${FILESDIR}/redis.service-2" redis.service
108         systemd_newtmpfilesd "${FILESDIR}/redis.tmpfiles" redis.conf
109
110         dodoc 00-RELEASENOTES BUGS CONTRIBUTING MANIFESTO README.md
111
112         dobin src/redis-cli
113         dosbin src/redis-benchmark src/redis-server src/redis-check-aof src/redis-check-rdb
114         fperms 0750 /usr/sbin/redis-benchmark
115         dosym /usr/sbin/redis-server /usr/sbin/redis-sentinel
116
117         if use prefix; then
118                 diropts -m0750
119         else
120                 diropts -m0750 -o redis -g redis
121         fi
122         keepdir /var/{log,lib}/redis
123 }