1SUMMARY = "Redis key-value store"
2DESCRIPTION = "Redis is an open source, advanced key-value store."
3HOMEPAGE = "http://redis.io"
4SECTION = "libs"
5LICENSE = "BSD-3-Clause"
6LIC_FILES_CHKSUM = "file://COPYING;md5=8ffdd6c926faaece928cf9d9640132d2"
7DEPENDS = "readline lua ncurses"
8
9SRC_URI = "http://download.redis.io/releases/${BP}.tar.gz \
10           file://redis.conf \
11           file://init-redis-server \
12           file://redis.service \
13           file://hiredis-use-default-CC-if-it-is-set.patch \
14           file://lua-update-Makefile-to-use-environment-build-setting.patch \
15           file://oe-use-libc-malloc.patch \
16           file://0001-src-Do-not-reset-FINAL_LIBS.patch \
17           file://GNU_SOURCE-7.patch \
18           file://0006-Define-correct-gregs-for-RISCV32.patch \
19           "
20SRC_URI[sha256sum] = "8d104c26a154b29fd67d6568b4f375212212ad41e0c2caa3d66480e78dbd3b59"
21
22inherit autotools-brokensep pkgconfig update-rc.d systemd useradd
23
24FINAL_LIBS:x86:toolchain-clang = "-latomic"
25FINAL_LIBS:riscv32:toolchain-clang = "-latomic"
26FINAL_LIBS:mips = "-latomic"
27FINAL_LIBS:arm = "-latomic"
28FINAL_LIBS:powerpc = "-latomic"
29
30export FINAL_LIBS
31
32USERADD_PACKAGES = "${PN}"
33USERADD_PARAM:${PN}  = "--system --home-dir /var/lib/redis -g redis --shell /bin/false redis"
34GROUPADD_PARAM:${PN} = "--system redis"
35
36PACKAGECONFIG = "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}"
37PACKAGECONFIG[systemd] = "USE_SYSTEMD=yes,USE_SYSTEMD=no,systemd"
38
39EXTRA_OEMAKE += "${PACKAGECONFIG_CONFARGS}"
40
41do_compile:prepend() {
42    (cd deps && oe_runmake hiredis lua linenoise)
43}
44
45do_install() {
46    export PREFIX=${D}/${prefix}
47    oe_runmake install
48    install -d ${D}/${sysconfdir}/redis
49    install -m 0644 ${WORKDIR}/redis.conf ${D}/${sysconfdir}/redis/redis.conf
50    install -d ${D}/${sysconfdir}/init.d
51    install -m 0755 ${WORKDIR}/init-redis-server ${D}/${sysconfdir}/init.d/redis-server
52    install -d ${D}/var/lib/redis/
53    chown redis.redis ${D}/var/lib/redis/
54
55    install -d ${D}${systemd_system_unitdir}
56    install -m 0644 ${WORKDIR}/redis.service ${D}${systemd_system_unitdir}
57    sed -i 's!/usr/sbin/!${sbindir}/!g' ${D}${systemd_system_unitdir}/redis.service
58
59    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
60        sed -i 's!daemonize yes!# daemonize yes!' ${D}/${sysconfdir}/redis/redis.conf
61        sed -i 's!supervised no!supervised systemd!' ${D}/${sysconfdir}/redis/redis.conf
62    fi
63}
64
65CONFFILES:${PN} = "${sysconfdir}/redis/redis.conf"
66
67INITSCRIPT_NAME = "redis-server"
68INITSCRIPT_PARAMS = "defaults 87"
69
70SYSTEMD_SERVICE:${PN} = "redis.service"
71