# Template file for 'redis'
pkgname=redis
version=7.0.8
revision=2
build_style=gnu-makefile
make_build_args="V=1"
make_check_target="test"
checkdepends="pkg-config procps-ng tcl-devel which"
short_desc="Advanced key-value store"
maintainer="Enno Boland <gottox@voidlinux.org>"
license="BSD-3-Clause"
homepage="https://redis.io"
changelog="https://raw.githubusercontent.com/redis/redis/${version%.*}/00-RELEASENOTES"
distfiles="http://download.redis.io/releases/redis-${version}.tar.gz"
checksum=06a339e491306783dcf55b97f15a5dbcbdc01ccbde6dc23027c475cab735e914

system_accounts="redis"
redis_homedir="/var/lib/redis"
conf_files="/etc/redis/redis.conf"

make_dirs="
 /var/lib/redis 0700 redis redis
 /etc/redis 0750 root redis"

if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
	make_build_args+=" MALLOC=libc"
else
	makedepends+=" jemalloc-devel"
	make_build_args+=" MALLOC=jemalloc"
fi

post_patch() {
	vsed -i \
		-e "s|^# bind 127.0.0.1|bind 127.0.0.1|" \
		-e "s|^dir .*|dir ${redis_homedir}|" \
		-e "s|^pidfile .*|pidfile /run/redis/redis.pid|" redis.conf
}

do_install() {
	make INSTALL_BIN=${DESTDIR}/usr/bin PREFIX=/usr install
	vlicense COPYING

	vinstall redis.conf 644 etc/redis
	vsv redis
}
