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://0001-hiredis-use-default-CC-if-it-is-set.patch \
14           file://0002-lua-update-Makefile-to-use-environment-build-setting.patch \
15           file://0003-hack-to-force-use-of-libc-malloc.patch \
16           file://0004-src-Do-not-reset-FINAL_LIBS.patch \
17           file://0005-Define-_GNU_SOURCE-to-get-PTHREAD_MUTEX_INITIALIZER.patch \
18           file://0006-Define-correct-gregs-for-RISCV32.patch \
19          "
20
21SRC_URI[sha256sum] = "fb10d67a2fe2b4556f6cb840064dd6e6e3175ce8ca035f0726990ec2da9f3d0e"
22
23inherit autotools-brokensep pkgconfig update-rc.d systemd useradd
24
25FINAL_LIBS:x86:toolchain-clang = "-latomic"
26FINAL_LIBS:riscv32 = "-latomic"
27FINAL_LIBS:mips = "-latomic"
28FINAL_LIBS:arm = "-latomic"
29FINAL_LIBS:powerpc = "-latomic"
30
31export FINAL_LIBS
32
33USERADD_PACKAGES = "${PN}"
34USERADD_PARAM:${PN}  = "--system --home-dir /var/lib/redis -g redis --shell /bin/false redis"
35GROUPADD_PARAM:${PN} = "--system redis"
36
37PACKAGECONFIG = "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}"
38PACKAGECONFIG[systemd] = "USE_SYSTEMD=yes,USE_SYSTEMD=no,systemd"
39
40EXTRA_OEMAKE += "${PACKAGECONFIG_CONFARGS}"
41
42do_compile:prepend() {
43    (cd deps && oe_runmake hiredis lua linenoise)
44}
45
46do_install() {
47    export PREFIX=${D}/${prefix}
48    oe_runmake install
49    install -d ${D}/${sysconfdir}/redis
50    install -m 0644 ${UNPACKDIR}/redis.conf ${D}/${sysconfdir}/redis/redis.conf
51    install -d ${D}/${sysconfdir}/init.d
52    install -m 0755 ${UNPACKDIR}/init-redis-server ${D}/${sysconfdir}/init.d/redis-server
53    install -d ${D}/var/lib/redis/
54    chown redis.redis ${D}/var/lib/redis/
55
56    install -d ${D}${systemd_system_unitdir}
57    install -m 0644 ${UNPACKDIR}/redis.service ${D}${systemd_system_unitdir}
58    sed -i 's!/usr/sbin/!${sbindir}/!g' ${D}${systemd_system_unitdir}/redis.service
59
60    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
61        sed -i 's!daemonize yes!# daemonize yes!' ${D}/${sysconfdir}/redis/redis.conf
62        sed -i 's!supervised no!supervised systemd!' ${D}/${sysconfdir}/redis/redis.conf
63    fi
64}
65
66CONFFILES:${PN} = "${sysconfdir}/redis/redis.conf"
67
68INITSCRIPT_NAME = "redis-server"
69INITSCRIPT_PARAMS = "defaults 87"
70
71SYSTEMD_SERVICE:${PN} = "redis.service"
72
73CVE_STATUS[CVE-2022-3734] = "not-applicable-platform: CVE only applies for Windows."
74