~cypheon/pkgsrc-wip

f604fc26789d5809dcdc3a36858dfcda9cacb68a — Johann Rudloff 8 months ago 6ff8739 redict
redict: New package, persistent key-value database with built-in net interface

Redict is an advanced key-value store. It is similar to memcached but the
dataset is not volatile, and values can be strings, exactly like in memcached,
but also lists, sets, and ordered sets. All these data types can be manipulated
with atomic operations to push/pop elements, add/remove elements, perform
server side union, intersection, and difference between sets, and so forth.
Redict also supports different kinds of sorting.

Redict 7.3.0 is a fork of and is broadly compatible with Redis 7.2.4. The
following notable changes are included:

 * The name has been updated throughout the software from "redis" to "redict".
   As a result, for example, redis-server is now redict-server.
 * The Lua API global has been renamed to "redict". "redis" is an alias for
   this for backwards compatibility.
 * The Modules API symbols have been renamed to RedictModule. Modules are
   binary compatible with Redis Modules targetting Redis 7.2.4.
A redict/DESCR => redict/DESCR +16 -0
@@ 0,0 1,16 @@
Redict is an advanced key-value store. It is similar to memcached but the
dataset is not volatile, and values can be strings, exactly like in memcached,
but also lists, sets, and ordered sets. All these data types can be manipulated
with atomic operations to push/pop elements, add/remove elements, perform
server side union, intersection, and difference between sets, and so forth.
Redict also supports different kinds of sorting.

Redict 7.3.0 is a fork of and is broadly compatible with Redis 7.2.4. The
following notable changes are included:

 * The name has been updated throughout the software from "redis" to "redict".
   As a result, for example, redis-server is now redict-server.
 * The Lua API global has been renamed to "redict". "redis" is an alias for
   this for backwards compatibility.
 * The Modules API symbols have been renamed to RedictModule. Modules are
   binary compatible with Redis Modules targetting Redis 7.2.4.

A redict/Makefile => redict/Makefile +82 -0
@@ 0,0 1,82 @@
# $NetBSD$

DISTNAME=	${PKGVERSION}
PKGNAME=	redict-7.3.0
CATEGORIES=	databases
MASTER_SITES=	https://codeberg.org/redict/redict/archive/

MAINTAINER=	pkgsrc-users@NetBSD.org
HOMEPAGE=	https://redict.io/
COMMENT=	Persistent key-value database with built-in net interface
LICENSE=	gnu-lgpl-v3
WRKSRC=		${WRKDIR}/redict

TEST_DEPENDS+=	tcl>=8.5:../../lang/tcl

USE_LANGUAGES=		c
USE_CC_FEATURES=	c99
USE_TOOLS+=		gmake pkg-config

# Don't let LTO kick in as it is not supported on all platforms.
MAKE_ENV+=	OPTIMIZATION=${DBG:U-O2:Q}
# Use standard malloc by default
MAKE_ENV+=	USE_JEMALLOC=no

.include "../../mk/bsd.prefs.mk"

.include "options.mk"

RCD_SCRIPTS+=		redict
RCD_SCRIPT_SRC.redict=	${FILESDIR}/redict.sh

DOCDIR=			share/doc/redict
DOCFILES+=		README.md SECURITY.md TLS.md
EGDIR=			${PREFIX}/share/examples/${PKGBASE}
INSTALLATION_DIRS+=	bin ${DOCDIR} ${EGDIR} ${EGDIR}/utils ${EGDIR}/tests

BUILD_DEFS+=		VARBASE REDICT_USER REDICT_GROUP REDICT_DATADIR
BUILD_DEFS+=		REDICT_LOGDIR REDICT_PIDDIR PKG_SYSCONFDIR

REDICT_USER?=		redict
REDICT_GROUP?=		redict
REDICT_DATADIR?=	${VARBASE}/db/redict
REDICT_LOGDIR?=		${VARBASE}/log/redict
REDICT_PIDDIR?=		${VARBASE}/run

OWN_DIRS_PERMS+=	${REDICT_DATADIR} ${REDICT_USER} ${REDICT_GROUP} 0770
OWN_DIRS_PERMS+=	${REDICT_LOGDIR} ${REDICT_USER} ${REDICT_GROUP} 0770

CONF_FILES_PERMS+=	${PREFIX}/share/redict/redict.conf ${PKG_SYSCONFDIR}/redict.conf \
			${REAL_ROOT_USER} ${REDICT_GROUP} 0640

PKG_GROUPS+=			${REDICT_GROUP}
PKG_USERS+=			${REDICT_USER}:${REDICT_GROUP}
PKG_GECOS.${REDICT_USER}=	redict daemon user
PKG_HOME.${REDICT_USER}=	${REDICT_DBDIR}

FILES_SUBST+=		REDICT_USER=${REDICT_USER}
FILES_SUBST+=		REDICT_GROUP=${REDICT_GROUP}
FILES_SUBST+=		REDICT_DATADIR=${REDICT_DATADIR}

SUBST_CLASSES+=			fix-paths
SUBST_STAGE.fix-paths=		pre-configure
SUBST_MESSAGE.fix-paths=	Fixing paths.
SUBST_FILES.fix-paths=		redict.conf
SUBST_VARS.fix-paths=		REDICT_DATADIR REDICT_LOGDIR REDICT_PIDDIR

CHECK_PORTABILITY_SKIP+=	deps/jemalloc/configure

post-extract:
	${CHMOD} -R g-w ${WRKSRC}

post-install:
.for file in ${DOCFILES}
	${INSTALL_DATA} ${WRKSRC}/${file} ${DESTDIR}${PREFIX}/${DOCDIR}/${file}
.endfor

do-test:
	cd ${WRKSRC} && ${SH} runtest

.include "../../mk/pthread.buildlink3.mk"
.include "../../mk/atomic64.mk"
.include "../../mk/bsd.pkg.mk"

A redict/PLIST => redict/PLIST +12 -0
@@ 0,0 1,12 @@
@comment $NetBSD$
bin/redict-benchmark
bin/redict-check-aof
bin/redict-check-rdb
bin/redict-cli
bin/redict-sentinel
bin/redict-server
share/doc/redict/README.md
share/doc/redict/SECURITY.md
share/doc/redict/TLS.md
share/redict/redict.conf
share/redict/sentinel.conf

A redict/distinfo => redict/distinfo +8 -0
@@ 0,0 1,8 @@
$NetBSD$

BLAKE2s (7.3.0.tar.gz) = a2ae5b1b74a211c35613eb43f3875ffaf04e509727f1ae3b4e5257905aab09a3
SHA512 (7.3.0.tar.gz) = d33f4dfaf728f5a22abe7a6223f3192c39dc41a32e7bcb0f453caaa859f35b512534979c26ced9f4458c19611debd282f37955e930151c0f827035f349647226
Size (7.3.0.tar.gz) = 3414514 bytes
SHA1 (patch-redict.conf) = fc87f130d9ca67f0fcb6293dbb2b3ec5cad069ef
SHA1 (patch-src_hyperloglog.c) = 27ac35394e1da9d9c7b6d433dd08118a59497c64
SHA1 (patch-src_object.c) = 30ffaec9c7e6135e3a5576cd1a35d7bcec668299

A redict/files/redict.sh => redict/files/redict.sh +25 -0
@@ 0,0 1,25 @@
#!@RCD_SCRIPTS_SHELL@
#
# $NetBSD$
#
# PROVIDE: redict
# REQUIRE: DAEMON NETWORKING
# KEYWORD: shutdown

if [ -f /etc/rc.subr ]; then
	. /etc/rc.subr
fi

name="redict"
rcvar=$name
command="@PREFIX@/bin/redict-server"
redict_user="@REDICT_USER@"
redict_flags="@PKG_SYSCONFDIR@/redict.conf"

if [ -f /etc/rc.subr ]; then
        load_rc_config $name
	run_rc_command "$1"
else
	echo -n "${name}"
	@SU@ -m ${redict_user} -c "${command}"
fi

A redict/files/smf/manifest.xml => redict/files/smf/manifest.xml +31 -0
@@ 0,0 1,31 @@
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<service_bundle type="manifest" name="export">
  <service name="@SMF_PREFIX@/@SMF_NAME@" type="service" version="1">
    <create_default_instance enabled="false" />
    <single_instance />
    <dependency name="network" grouping="require_all" restart_on="error" type="service">
      <service_fmri value="svc:/milestone/network:default" />
    </dependency>
    <dependency name="filesystem" grouping="require_all" restart_on="error" type="service">
      <service_fmri value="svc:/system/filesystem/local" />
    </dependency>
    <method_context working_directory="@REDIS_DATADIR@">
      <method_credential user="@REDIS_USER@" group="@REDIS_GROUP@" />
    </method_context>
    <exec_method type="method" name="start" exec="@PREFIX@/bin/redis-server %{config_file}" timeout_seconds="60" />
    <exec_method type="method" name="stop" exec=":kill" timeout_seconds="60" />
    <property_group name="startd" type="framework">
      <propval name="duration" type="astring" value="contract" />
      <propval name="ignore_error" type="astring" value="core,signal" />
    </property_group>
    <property_group name="application" type="application">
      <propval name="config_file" type="astring" value="@PKG_SYSCONFDIR@/redis.conf" />
    </property_group>
    <template>
      <common_name>
        <loctext xml:lang="C">Redis server</loctext>
      </common_name>
    </template>
  </service>
</service_bundle>

A redict/options.mk => redict/options.mk +12 -0
@@ 0,0 1,12 @@
# $NetBSD: options.mk,v 1.1 2020/08/19 16:32:40 jperkin Exp $

PKG_OPTIONS_VAR=	PKG_OPTIONS.redict
PKG_SUPPORTED_OPTIONS=	ssl
PKG_SUGGESTED_OPTIONS=	ssl

.include "../../mk/bsd.options.mk"

.if !empty(PKG_OPTIONS:Mssl)
.  include "../../security/openssl/buildlink3.mk"
MAKE_ENV+=		BUILD_TLS=yes
.endif

A redict/patches/patch-redict.conf => redict/patches/patch-redict.conf +42 -0
@@ 0,0 1,42 @@
$NetBSD$

Sane defaults for the config file.

--- redict.conf.orig	2021-02-22 21:23:58.000000000 +0000
+++ redict.conf
@@ -244,7 +244,7 @@ tcp-keepalive 300
 # By default redict does not run as a daemon. Use 'yes' if you need it.
 # Note that redict will write a pid file in /var/run/redict.pid when daemonized.
 # When redict is supervised by upstart or systemd, this parameter has no impact.
-daemonize no
+daemonize yes
 
 # If you run redict from upstart or systemd, redict can interact with your
 # supervision tree. Options:
@@ -276,7 +276,7 @@ daemonize no
 #
 # Note that on modern Linux systems "/run/redict.pid" is more conforming
 # and should be used instead.
-pidfile /var/run/redict_6379.pid
+pidfile @REDICT_PIDDIR@/redict.pid
 
 # Specify the server verbosity level.
 # This can be one of:
@@ -289,7 +289,7 @@ loglevel notice
 # Specify the log file name. Also the empty string can be used to force
 # redict to log on the standard output. Note that if you use standard
 # output for logging but daemonize, logs will be sent to /dev/null
-logfile ""
+logfile @REDICT_LOGDIR@/redict.log
 
 # To enable logging to the system logger, just set 'syslog-enabled' to yes,
 # and optionally update the other syslog parameters to suit your needs.
@@ -441,7 +441,7 @@ rdb-del-sync-files no
 # The Append Only File will also be created inside this directory.
 #
 # Note that you must specify a directory here, not a file name.
-dir ./
+dir @REDICT_DATADIR@ 
 
 ################################# REPLICATION #################################
 

A redict/patches/patch-src_hyperloglog.c => redict/patches/patch-src_hyperloglog.c +23 -0
@@ 0,0 1,23 @@
$NetBSD$

Fix the case of the missing llroundl on NetBSD. Patch by Matthias Petermann.

--- src/hyperloglog.c.orig	2020-10-27 07:12:01.000000000 +0000
+++ src/hyperloglog.c
@@ -11,6 +11,16 @@
 #include <stdint.h>
 #include <math.h>
 
+#ifdef __NetBSD__
+#include <sys/param.h>
+#if __NetBSD_Version__ < 799007200
+/* llroundl not present in NetBSD libm before 7.99.71 */
+long long int llroundl (long double x) {
+    return (long long int) roundl (x);
+}
+#endif
+#endif
+
 /* The Redict HyperLogLog implementation is based on the following ideas:
  *
  * * The use of a 64 bit hash function as proposed in [1], in order to estimate

A redict/patches/patch-src_object.c => redict/patches/patch-src_object.c +15 -0
@@ 0,0 1,15 @@
$NetBSD: patch-src_object.c,v 1.3 2015/04/13 11:33:35 fhajny Exp $

Add MirBSD support.

--- src/object.c.orig	2015-04-01 14:01:44.000000000 +0000
+++ src/object.c
@@ -32,7 +32,7 @@
 #include <math.h>
 #include <ctype.h>
 
-#ifdef __CYGWIN__
+#if defined(__CYGWIN__) || defined(__MirBSD__)
 #define strtold(a,b) ((long double)strtod((a),(b)))
 #endif