1*8460358cSPatrick WilliamsSUMMARY = "Redis key-value store"
2*8460358cSPatrick WilliamsDESCRIPTION = "Redis is an open source, advanced key-value store."
3*8460358cSPatrick WilliamsHOMEPAGE = "http://redis.io"
4*8460358cSPatrick WilliamsSECTION = "libs"
5*8460358cSPatrick WilliamsLICENSE = "BSD-3-Clause"
6*8460358cSPatrick WilliamsLIC_FILES_CHKSUM = "file://COPYING;md5=8ffdd6c926faaece928cf9d9640132d2"
7*8460358cSPatrick WilliamsDEPENDS = "readline lua ncurses"
8*8460358cSPatrick Williams
9*8460358cSPatrick WilliamsSRC_URI = "http://download.redis.io/releases/${BP}.tar.gz \
10*8460358cSPatrick Williams           file://redis.conf \
11*8460358cSPatrick Williams           file://init-redis-server \
12*8460358cSPatrick Williams           file://redis.service \
13*8460358cSPatrick Williams           file://0001-hiredis-use-default-CC-if-it-is-set.patch \
14*8460358cSPatrick Williams           file://0002-lua-update-Makefile-to-use-environment-build-setting.patch \
15*8460358cSPatrick Williams           file://0003-hack-to-force-use-of-libc-malloc.patch \
16*8460358cSPatrick Williams           file://0004-src-Do-not-reset-FINAL_LIBS.patch \
17*8460358cSPatrick Williams           file://0005-Define-_GNU_SOURCE-to-get-PTHREAD_MUTEX_INITIALIZER.patch \
18*8460358cSPatrick Williams           file://0006-Define-correct-gregs-for-RISCV32.patch \
19*8460358cSPatrick Williams          "
20*8460358cSPatrick Williams
21*8460358cSPatrick WilliamsSRC_URI[sha256sum] = "fb10d67a2fe2b4556f6cb840064dd6e6e3175ce8ca035f0726990ec2da9f3d0e"
22*8460358cSPatrick Williams
23*8460358cSPatrick Williamsinherit autotools-brokensep pkgconfig update-rc.d systemd useradd
24*8460358cSPatrick Williams
25*8460358cSPatrick WilliamsFINAL_LIBS:x86:toolchain-clang = "-latomic"
26*8460358cSPatrick WilliamsFINAL_LIBS:riscv32 = "-latomic"
27*8460358cSPatrick WilliamsFINAL_LIBS:mips = "-latomic"
28*8460358cSPatrick WilliamsFINAL_LIBS:arm = "-latomic"
29*8460358cSPatrick WilliamsFINAL_LIBS:powerpc = "-latomic"
30*8460358cSPatrick Williams
31*8460358cSPatrick Williamsexport FINAL_LIBS
32*8460358cSPatrick Williams
33*8460358cSPatrick WilliamsUSERADD_PACKAGES = "${PN}"
34*8460358cSPatrick WilliamsUSERADD_PARAM:${PN}  = "--system --home-dir /var/lib/redis -g redis --shell /bin/false redis"
35*8460358cSPatrick WilliamsGROUPADD_PARAM:${PN} = "--system redis"
36*8460358cSPatrick Williams
37*8460358cSPatrick WilliamsPACKAGECONFIG = "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}"
38*8460358cSPatrick WilliamsPACKAGECONFIG[systemd] = "USE_SYSTEMD=yes,USE_SYSTEMD=no,systemd"
39*8460358cSPatrick Williams
40*8460358cSPatrick WilliamsEXTRA_OEMAKE += "${PACKAGECONFIG_CONFARGS}"
41*8460358cSPatrick Williams
42*8460358cSPatrick Williamsdo_compile:prepend() {
43*8460358cSPatrick Williams    (cd deps && oe_runmake hiredis lua linenoise)
44*8460358cSPatrick Williams}
45*8460358cSPatrick Williams
46*8460358cSPatrick Williamsdo_install() {
47*8460358cSPatrick Williams    export PREFIX=${D}/${prefix}
48*8460358cSPatrick Williams    oe_runmake install
49*8460358cSPatrick Williams    install -d ${D}/${sysconfdir}/redis
50*8460358cSPatrick Williams    install -m 0644 ${UNPACKDIR}/redis.conf ${D}/${sysconfdir}/redis/redis.conf
51*8460358cSPatrick Williams    install -d ${D}/${sysconfdir}/init.d
52*8460358cSPatrick Williams    install -m 0755 ${UNPACKDIR}/init-redis-server ${D}/${sysconfdir}/init.d/redis-server
53*8460358cSPatrick Williams    install -d ${D}/var/lib/redis/
54*8460358cSPatrick Williams    chown redis.redis ${D}/var/lib/redis/
55*8460358cSPatrick Williams
56*8460358cSPatrick Williams    install -d ${D}${systemd_system_unitdir}
57*8460358cSPatrick Williams    install -m 0644 ${UNPACKDIR}/redis.service ${D}${systemd_system_unitdir}
58*8460358cSPatrick Williams    sed -i 's!/usr/sbin/!${sbindir}/!g' ${D}${systemd_system_unitdir}/redis.service
59*8460358cSPatrick Williams
60*8460358cSPatrick Williams    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
61*8460358cSPatrick Williams        sed -i 's!daemonize yes!# daemonize yes!' ${D}/${sysconfdir}/redis/redis.conf
62*8460358cSPatrick Williams        sed -i 's!supervised no!supervised systemd!' ${D}/${sysconfdir}/redis/redis.conf
63*8460358cSPatrick Williams    fi
64*8460358cSPatrick Williams}
65*8460358cSPatrick Williams
66*8460358cSPatrick WilliamsCONFFILES:${PN} = "${sysconfdir}/redis/redis.conf"
67*8460358cSPatrick Williams
68*8460358cSPatrick WilliamsINITSCRIPT_NAME = "redis-server"
69*8460358cSPatrick WilliamsINITSCRIPT_PARAMS = "defaults 87"
70*8460358cSPatrick Williams
71*8460358cSPatrick WilliamsSYSTEMD_SERVICE:${PN} = "redis.service"
72*8460358cSPatrick Williams
73*8460358cSPatrick WilliamsCVE_STATUS[CVE-2022-3734] = "not-applicable-platform: CVE only applies for Windows."
74