1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 inherit autotools eutils flag-o-matic systemd toolchain-funcs user
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"
13 KEYWORDS="amd64 ~arm arm64 hppa ppc ppc64 x86 ~amd64-linux ~x86-linux ~x86-macos ~x86-solaris"
14 IUSE="+jemalloc tcmalloc luajit test"
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= )
25 REQUIRED_USE="?? ( tcmalloc jemalloc )"
27 S="${WORKDIR}/${PN}-${PV/_/-}"
31 enewuser redis 75 -1 /var/lib/redis redis
36 "${FILESDIR}"/${PN}-3.2.5-shared.patch \
37 "${FILESDIR}"/${PN}-3.2.3-config.patch \
38 "${FILESDIR}"/${PN}-3.2.3-sharedlua.patch
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"
48 # now we will rewrite present 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' \
55 -e 's:$(OBJARCH)::g' \
57 -e '/^CCOPT=/s:$: $(LDFLAGS):g' \
59 || die "Sed failed for ${MKF}"
62 # autodetection of compiler and settings; generates the modified Makefiles
63 cp "${FILESDIR}"/configure.ac-3.2 configure.ac
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"
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
83 tc-export CC AR RANLIB
87 if use tcmalloc ; then
88 myconf="${myconf} USE_TCMALLOC=yes"
89 elif use jemalloc ; then
90 myconf="${myconf} JEMALLOC_SHARED=yes"
92 myconf="${myconf} MALLOC=yes"
95 emake ${myconf} V=1 CC="${CC}" AR="${AR} rcu" RANLIB="${RANLIB}"
100 doins redis.conf sentinel.conf
101 use prefix || fowners redis:redis /etc/{redis,sentinel}.conf
102 fperms 0644 /etc/{redis,sentinel}.conf
104 newconfd "${FILESDIR}/redis.confd" redis
105 newinitd "${FILESDIR}/redis.initd-4" redis
107 systemd_newunit "${FILESDIR}/redis.service-2" redis.service
108 systemd_newtmpfilesd "${FILESDIR}/redis.tmpfiles" redis.conf
110 dodoc 00-RELEASENOTES BUGS CONTRIBUTING MANIFESTO README.md
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 redis-server /usr/sbin/redis-sentinel
120 diropts -m0750 -o redis -g redis
122 keepdir /var/{log,lib}/redis