git: a08336423d72 - main - databases/valkey: Add new port

From: Yasuhiro Kimura <yasu_at_FreeBSD.org>
Date: Tue, 02 Apr 2024 07:14:21 UTC
The branch main has been updated by yasu:

URL: https://cgit.FreeBSD.org/ports/commit/?id=a08336423d727103442208c74633a2f01aacdb74

commit a08336423d727103442208c74633a2f01aacdb74
Author:     Yasuhiro Kimura <yasu@FreeBSD.org>
AuthorDate: 2024-04-02 07:07:00 +0000
Commit:     Yasuhiro Kimura <yasu@FreeBSD.org>
CommitDate: 2024-04-02 07:13:36 +0000

    databases/valkey: Add new port
    
    Add databases/valkey, High-performance data structure server that
    primarily serves key/value workloads.
---
 GIDs                                               |  2 +-
 UIDs                                               |  2 +-
 databases/Makefile                                 |  1 +
 databases/valkey/Makefile                          | 75 ++++++++++++++++++++++
 databases/valkey/distinfo                          |  3 +
 databases/valkey/files/patch-deps-Makefile         | 21 ++++++
 databases/valkey/files/patch-deps-hiredis-Makefile | 41 ++++++++++++
 databases/valkey/files/patch-deps-hiredis-net.c    | 39 +++++++++++
 .../valkey/files/patch-deps-linenoise-Makefile     | 15 +++++
 .../valkey/files/patch-deps_lua_src_lua__cjson.c   | 12 ++++
 databases/valkey/files/patch-redis.conf            | 38 +++++++++++
 databases/valkey/files/patch-sentinel.conf         | 26 ++++++++
 databases/valkey/files/patch-src-Makefile          | 39 +++++++++++
 databases/valkey/files/patch-src-mkreleasehdr.sh   | 11 ++++
 databases/valkey/files/pkg-message.in              | 11 ++++
 databases/valkey/files/valkey.in                   | 67 +++++++++++++++++++
 databases/valkey/files/valkeysentinel.in           | 39 +++++++++++
 databases/valkey/pkg-descr                         |  4 ++
 databases/valkey/pkg-plist                         | 11 ++++
 19 files changed, 455 insertions(+), 2 deletions(-)

diff --git a/GIDs b/GIDs
index 9484f962f0ff..80c1e80341da 100644
--- a/GIDs
+++ b/GIDs
@@ -477,7 +477,7 @@ dkimproxy:*:525:
 pgbouncer:*:534:
 redis:*:535:
 keydb:*:536:
-# free: 537
+valkey:*:537:
 # free: 538
 # free: 539
 # free: 540
diff --git a/UIDs b/UIDs
index 09f572b79759..3315630967c2 100644
--- a/UIDs
+++ b/UIDs
@@ -482,7 +482,7 @@ dkimproxy:*:525:525::0:0:DKIM Proxy Owner:/nonexistent:/usr/sbin/nologin
 pgbouncer:*:534:534::0:0:Pgbouncer Daemon:/nonexistent:/usr/sbin/nologin
 redis:*:535:535::0:0:Redis Daemon:/nonexistent:/usr/sbin/nologin
 keydb:*:536:536::0:0:KeyDB Daemon:/nonexistent:/usr/sbin/nologin
-# free: 537
+valkey:*:537:537::0:0:Valkey Daemon:/nonexistent:/usr/sbin/nologin
 # free: 538
 # free: 539
 # free: 540
diff --git a/databases/Makefile b/databases/Makefile
index aa4cf2575b76..f65e1cf2175b 100644
--- a/databases/Makefile
+++ b/databases/Makefile
@@ -1061,6 +1061,7 @@
     SUBDIR += twemproxy
     SUBDIR += unixODBC
     SUBDIR += usql
+    SUBDIR += valkey
     SUBDIR += vfront
     SUBDIR += virtualpg
     SUBDIR += vsqlite
diff --git a/databases/valkey/Makefile b/databases/valkey/Makefile
new file mode 100644
index 000000000000..860a061d7c6d
--- /dev/null
+++ b/databases/valkey/Makefile
@@ -0,0 +1,75 @@
+PORTNAME=	valkey
+DISTVERSION=	g20240402
+CATEGORIES=	databases
+
+MAINTAINER=	yasu@FreeBSD.org
+COMMENT=	High-performance data structure server that primarily serves key/value workloads
+WWW=		https://valkey.io/
+
+LICENSE=	BSD3CLAUSE
+LICENSE_FILE=	${WRKSRC}/COPYING
+
+USES+=		gmake tcl:test
+USE_GITHUB=	yes
+GH_ACCOUNT=	valkey-io
+GH_TAGNAME=	0ba2f1b14
+USE_RC_SUBR=	valkey valkeysentinel
+
+MAKE_ENV=	OPTIMIZATION= \
+		V=1
+
+LDFLAGS+=	-lpthread -lm -lexecinfo
+
+PORTSCOUT=	ignore:1
+SUB_FILES=	pkg-message
+SUB_LIST+=	PORTNAME=${PORTNAME} \
+		VALKEY_DBDIR=${VALKEY_DBDIR} \
+		VALKEY_LOGDIR=${VALKEY_LOGDIR} \
+		VALKEY_RUNDIR=${VALKEY_RUNDIR} \
+		VALKEY_USER=${USERS}
+
+USERS=		valkey
+GROUPS=		valkey
+
+PLIST_SUB+=	VALKEY_DBDIR=${VALKEY_DBDIR} \
+		VALKEY_GROUP=${GROUPS} \
+		VALKEY_LOGDIR=${VALKEY_LOGDIR} \
+		VALKEY_RUNDIR=${VALKEY_RUNDIR} \
+		VALKEY_USER=${USERS}
+
+OPTIONS_DEFINE=		JEMALLOC TLS
+OPTIONS_DEFAULT=	TLS
+OPTIONS_SUB=		yes
+
+JEMALLOC_DESC=	Use jemalloc
+TLS_DESC=	Use TLS
+
+JEMALLOC_MAKE_ENV=	MALLOC=jemalloc
+TLS_USES=		ssl
+TLS_MAKE_ENV=		BUILD_TLS=yes
+
+BIN_FILES=	valkey-benchmark valkey-check-aof valkey-check-rdb valkey-cli \
+		valkey-sentinel valkey-server
+
+VALKEY_DBDIR?=	/var/db/valkey
+VALKEY_RUNDIR?=	/var/run/valkey
+VALKEY_LOGDIR?=	/var/log/valkey
+
+post-build:
+	${SED} ${SUB_LIST:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \
+		${WRKSRC}/redis.conf > ${WRKDIR}/valkey.conf
+	${SED} ${SUB_LIST:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \
+		${WRKSRC}/sentinel.conf > ${WRKDIR}/valkey-sentinel.conf
+
+do-install:
+	${INSTALL_PROGRAM} ${BIN_FILES:C!^!${WRKSRC}/src/!} ${STAGEDIR}${PREFIX}/bin/
+	${INSTALL_DATA} ${WRKDIR}/valkey.conf ${STAGEDIR}${PREFIX}/etc/valkey.conf.sample
+	${INSTALL_DATA} ${WRKDIR}/valkey-sentinel.conf ${STAGEDIR}${PREFIX}/etc/valkey-sentinel.conf.sample
+	${MKDIR} ${STAGEDIR}${VALKEY_LOGDIR} \
+		${STAGEDIR}${VALKEY_DBDIR} \
+		${STAGEDIR}${VALKEY_RUNDIR}
+
+do-test:
+	@cd ${WRKSRC} && ${TCLSH} tests/test_helper.tcl
+
+.include <bsd.port.mk>
diff --git a/databases/valkey/distinfo b/databases/valkey/distinfo
new file mode 100644
index 000000000000..b3c31618a17a
--- /dev/null
+++ b/databases/valkey/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1712041530
+SHA256 (valkey-io-valkey-g20240402-0ba2f1b14_GH0.tar.gz) = 134eb1521ab2b1dfd9d8f30208b6c4261621e5d05218825881d2cc53cf1bfefb
+SIZE (valkey-io-valkey-g20240402-0ba2f1b14_GH0.tar.gz) = 3474270
diff --git a/databases/valkey/files/patch-deps-Makefile b/databases/valkey/files/patch-deps-Makefile
new file mode 100644
index 000000000000..003ae439c2c5
--- /dev/null
+++ b/databases/valkey/files/patch-deps-Makefile
@@ -0,0 +1,21 @@
+--- deps/Makefile.orig	2024-04-01 02:56:24 UTC
++++ deps/Makefile
+@@ -84,7 +84,7 @@ else
+ ifeq ($(LUA_DEBUG),yes)
+ 	LUA_CFLAGS+= -O0 -g -DLUA_USE_APICHECK
+ else
+-	LUA_CFLAGS+= -O2 
++	LUA_CFLAGS+=
+ endif
+ ifeq ($(LUA_COVERAGE),yes)
+ 	LUA_CFLAGS += -fprofile-arcs -ftest-coverage
+@@ -112,7 +112,7 @@ jemalloc: .make-prerequisites
+ 
+ jemalloc: .make-prerequisites
+ 	@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
+-	cd jemalloc && ./configure --disable-cxx --with-version=5.3.0-0-g0 --with-lg-quantum=3 --disable-cache-oblivious --with-jemalloc-prefix=je_ CFLAGS="$(JEMALLOC_CFLAGS)" LDFLAGS="$(JEMALLOC_LDFLAGS)" $(JEMALLOC_CONFIGURE_OPTS)
+-	cd jemalloc && $(MAKE) lib/libjemalloc.a
++	cd jemalloc && ./configure --disable-cxx --with-version=5.3.0-0-g0 --with-lg-quantum=3 --disable-cache-oblivious --with-jemalloc-prefix=je_ CFLAGS="$(JEMALLOC_CFLAGS)" CXXFLAGS="$(JEMALLOC_CFLAGS)" LDFLAGS="$(JEMALLOC_LDFLAGS)" $(JEMALLOC_CONFIGURE_OPTS)
++	cd jemalloc && $(MAKE) CFLAGS="$(JEMALLOC_CFLAGS)" CXXFLAGS="$(JEMALLOC_CFLAGS)" LDFLAGS="$(JEMALLOC_LDFLAGS)" lib/libjemalloc.a
+ 
+ .PHONY: jemalloc
diff --git a/databases/valkey/files/patch-deps-hiredis-Makefile b/databases/valkey/files/patch-deps-hiredis-Makefile
new file mode 100644
index 000000000000..a2789076673c
--- /dev/null
+++ b/databases/valkey/files/patch-deps-hiredis-Makefile
@@ -0,0 +1,41 @@
+--- deps/hiredis/Makefile.orig	2023-07-30 05:48:29 UTC
++++ deps/hiredis/Makefile
+@@ -15,7 +15,7 @@ HIREDIS_PATCH=$(shell grep HIREDIS_PATCH hiredis.h | a
+ HIREDIS_SONAME=$(shell grep HIREDIS_SONAME hiredis.h | awk '{print $$3}')
+ 
+ # Installation related variables and target
+-PREFIX?=/usr/local
++PREFIX?=${PREFIX}
+ INCLUDE_PATH?=include/hiredis
+ LIBRARY_PATH?=lib
+ PKGCONF_PATH?=pkgconfig
+@@ -38,10 +38,8 @@ export REDIS_TEST_CONFIG
+ # Fallback to gcc when $CC is not in $PATH.
+ CC:=$(shell sh -c 'type $${CC%% *} >/dev/null 2>/dev/null && echo $(CC) || echo gcc')
+ CXX:=$(shell sh -c 'type $${CXX%% *} >/dev/null 2>/dev/null && echo $(CXX) || echo g++')
+-OPTIMIZATION?=-O3
+ WARNINGS=-Wall -Wextra -Werror -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers
+-DEBUG_FLAGS?= -g -ggdb
+-REAL_CFLAGS=$(OPTIMIZATION) -fPIC $(CPPFLAGS) $(CFLAGS) $(WARNINGS) $(DEBUG_FLAGS) $(PLATFORM_FLAGS)
++REAL_CFLAGS=$(OPTIMIZATION) -fPIC $(CFLAGS) $(WARNINGS) $(DEBUG_FLAGS) $(PLATFORM_FLAGS)
+ REAL_LDFLAGS=$(LDFLAGS)
+ 
+ DYLIBSUFFIX=so
+@@ -122,7 +120,16 @@ ifeq ($(uname_S),FreeBSD)
+ else
+   REAL_CFLAGS+=-pedantic
+ endif
+-
++ifeq ($(uname_S),FreeBSD)
++  CFLAGS?=$(CFLAGS)
++  CCLINK?=pthread
++  LDFLAGS?=-L. -Wl,-rpath,.
++  DYLIBNAME?=libhiredis.so
++  DYLIB_MAKE_CMD?=$(CC) -o ${DYLIBNAME} ${OBJ}
++  STLIBNAME?=libhiredis.a
++  STLIB_MAKE_CMD?=ar rcs ${STLIBNAME} ${OBJ}
++  SSL_LDFLAGS+=${OPENSSL_LDFLAGS}
++endif
+ ifeq ($(uname_S),SunOS)
+   IS_SUN_CC=$(shell sh -c '$(CC) -V 2>&1 |egrep -i -c "sun|studio"')
+   ifeq ($(IS_SUN_CC),1)
diff --git a/databases/valkey/files/patch-deps-hiredis-net.c b/databases/valkey/files/patch-deps-hiredis-net.c
new file mode 100644
index 000000000000..434ebf0e81a4
--- /dev/null
+++ b/databases/valkey/files/patch-deps-hiredis-net.c
@@ -0,0 +1,39 @@
+--- deps/hiredis/net.c.orig	2024-04-01 02:56:24 UTC
++++ deps/hiredis/net.c
+@@ -185,14 +185,34 @@ int redisKeepAlive(redisContext *c, int interval) {
+         __redisSetError(c,REDIS_ERR_OTHER,strerror(errno));
+         return REDIS_ERR;
+     }
+-#else
+-#if defined(__GLIBC__) && !defined(__FreeBSD_kernel__)
++#elif defined(__GLIBC__)
+     if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &val, sizeof(val)) < 0) {
+         __redisSetError(c,REDIS_ERR_OTHER,strerror(errno));
+         return REDIS_ERR;
+     }
+ 
+     val = interval/3;
++    if (val == 0) val = 1;
++    if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, &val, sizeof(val)) < 0) {
++        __redisSetError(c,REDIS_ERR_OTHER,strerror(errno));
++        return REDIS_ERR;
++    }
++
++    val = 3;
++    if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, &val, sizeof(val)) < 0) {
++        __redisSetError(c,REDIS_ERR_OTHER,strerror(errno));
++        return REDIS_ERR;
++    }
++#else
++#if !defined(__sun) && defined(TCP_KEEPIDLE) && defined(TCP_KEEPINTL) && \
++    defined(TCP_KEEPCNT)
++    val = interval;
++    if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &val, sizeof(val)) < 0) {
++        __redisSetError(c,REDIS_ERR_OTHER,strerror(errno));
++        return REDIS_ERR;
++    }
++
++    val = internal/3;
+     if (val == 0) val = 1;
+     if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, &val, sizeof(val)) < 0) {
+         __redisSetError(c,REDIS_ERR_OTHER,strerror(errno));
diff --git a/databases/valkey/files/patch-deps-linenoise-Makefile b/databases/valkey/files/patch-deps-linenoise-Makefile
new file mode 100644
index 000000000000..aef0f10966af
--- /dev/null
+++ b/databases/valkey/files/patch-deps-linenoise-Makefile
@@ -0,0 +1,15 @@
+--- deps/linenoise/Makefile.orig	2019-09-25 10:40:18 UTC
++++ deps/linenoise/Makefile
+@@ -1,10 +1,10 @@
+ STD=
+ WARN= -Wall
+-OPT= -Os
++#OPT= -Os
+ 
+ R_CFLAGS= $(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS)
+ R_LDFLAGS= $(LDFLAGS)
+-DEBUG= -g
++#DEBUG= -g
+ 
+ R_CC=$(CC) $(R_CFLAGS)
+ R_LD=$(CC) $(R_LDFLAGS)
diff --git a/databases/valkey/files/patch-deps_lua_src_lua__cjson.c b/databases/valkey/files/patch-deps_lua_src_lua__cjson.c
new file mode 100644
index 000000000000..55f700aee7f3
--- /dev/null
+++ b/databases/valkey/files/patch-deps_lua_src_lua__cjson.c
@@ -0,0 +1,12 @@
+--- deps/lua/src/lua_cjson.c.orig	2024-04-01 02:56:24 UTC
++++ deps/lua/src/lua_cjson.c
+@@ -47,7 +47,9 @@
+ #include "strbuf.h"
+ #include "fpconv.h"
+ 
++#if defined(__sun)
+ #include "../../../src/solarisfixes.h"
++#endif
+ 
+ #ifndef CJSON_MODNAME
+ #define CJSON_MODNAME   "cjson"
diff --git a/databases/valkey/files/patch-redis.conf b/databases/valkey/files/patch-redis.conf
new file mode 100644
index 000000000000..4dcc57584424
--- /dev/null
+++ b/databases/valkey/files/patch-redis.conf
@@ -0,0 +1,38 @@
+--- redis.conf.orig	2024-04-01 02:56:24 UTC
++++ redis.conf
+@@ -307,7 +307,7 @@ tcp-keepalive 300
+ # By default Redis does not run as a daemon. Use 'yes' if you need it.
+ # Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
+ # When Redis is supervised by upstart or systemd, this parameter has no impact.
+-daemonize no
++daemonize yes
+ 
+ # If you run Redis from upstart or systemd, Redis can interact with your
+ # supervision tree. Options:
+@@ -339,7 +339,7 @@ daemonize no
+ #
+ # Note that on modern Linux systems "/run/redis.pid" is more conforming
+ # and should be used instead.
+-pidfile /var/run/redis_6379.pid
++pidfile %%VALKEY_RUNDIR%%/valkey.pid
+ 
+ # Specify the server verbosity level.
+ # This can be one of:
+@@ -353,7 +353,7 @@ loglevel notice
+ # Specify the log file name. Also the empty string can be used to force
+ # Redis 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 %%VALKEY_LOGDIR%%/valkey.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.
+@@ -508,7 +508,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 %%VALKEY_DBDIR%%/
+ 
+ ################################# REPLICATION #################################
+ 
diff --git a/databases/valkey/files/patch-sentinel.conf b/databases/valkey/files/patch-sentinel.conf
new file mode 100644
index 000000000000..d02120641775
--- /dev/null
+++ b/databases/valkey/files/patch-sentinel.conf
@@ -0,0 +1,26 @@
+--- sentinel.conf.orig	2024-04-01 02:56:24 UTC
++++ sentinel.conf
+@@ -12,12 +12,12 @@ port 26379
+ # By default Redis Sentinel does not run as a daemon. Use 'yes' if you need it.
+ # Note that Redis will write a pid file in /var/run/redis-sentinel.pid when
+ # daemonized.
+-daemonize no
++daemonize yes
+ 
+ # When running daemonized, Redis Sentinel writes a pid file in
+ # /var/run/redis-sentinel.pid by default. You can specify a custom pid file
+ # location here.
+-pidfile /var/run/redis-sentinel.pid
++pidfile %%VALKEY_RUNDIR%%/valkey-sentinel.pid
+ 
+ # Specify the server verbosity level.
+ # This can be one of:
+@@ -31,7 +31,7 @@ loglevel notice
+ # Specify the log file name. Also the empty string can be used to force
+ # Sentinel 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 %%VALKEY_LOGDIR%%/valkey-sentinel.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.
diff --git a/databases/valkey/files/patch-src-Makefile b/databases/valkey/files/patch-src-Makefile
new file mode 100644
index 000000000000..20997e2d3b04
--- /dev/null
+++ b/databases/valkey/files/patch-src-Makefile
@@ -0,0 +1,39 @@
+--- src/Makefile.orig	2024-04-01 02:56:24 UTC
++++ src/Makefile
+@@ -61,7 +61,7 @@ endif
+ 	STD+=-std=c99
+ endif
+ 
+-PREFIX?=/usr/local
++PREFIX:=$(PREFIX)
+ INSTALL_BIN=$(PREFIX)/bin
+ INSTALL=install
+ PKG_CONFIG?=pkg-config
+@@ -133,7 +133,6 @@ FINAL_LIBS=-lm
+ FINAL_CFLAGS=$(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) $(SERVER_CFLAGS)
+ FINAL_LDFLAGS=$(LDFLAGS) $(OPT) $(SERVER_LDFLAGS) $(DEBUG)
+ FINAL_LIBS=-lm
+-DEBUG=-g -ggdb
+ 
+ # Linux ARM32 needs -latomic at linking time
+ ifneq (,$(findstring armv,$(uname_M)))
+@@ -172,6 +171,11 @@ else
+ 	OPENSSL_PREFIX?=/usr/local/opt/openssl
+ endif
+ else
++ifeq ($(uname_S),FreeBSD)
++        # FreeBSD
++        FINAL_CFLAGS?= $(CFLAGS) $(REDIS_CFLAGS) -I${PREFIX}/include
++        FINAL_LDFLAGS= $(LDFLAGS) -pthread
++else
+ ifeq ($(uname_S),AIX)
+         # AIX
+         FINAL_LDFLAGS+= -Wl,-bexpall
+@@ -221,6 +225,7 @@ else
+ 	# All the other OSes (notably Linux)
+ 	FINAL_LDFLAGS+= -rdynamic
+ 	FINAL_LIBS+=-ldl -pthread -lrt
++endif
+ endif
+ endif
+ endif
diff --git a/databases/valkey/files/patch-src-mkreleasehdr.sh b/databases/valkey/files/patch-src-mkreleasehdr.sh
new file mode 100644
index 000000000000..65920da3a3ff
--- /dev/null
+++ b/databases/valkey/files/patch-src-mkreleasehdr.sh
@@ -0,0 +1,11 @@
+--- src/mkreleasehdr.sh.orig	2024-01-27 09:11:53 UTC
++++ src/mkreleasehdr.sh
+@@ -1,6 +1,6 @@
+ #!/bin/sh
+-GIT_SHA1=`(git show-ref --head --hash=8 2> /dev/null || echo 00000000) | head -n1`
+-GIT_DIRTY=`git diff --no-ext-diff -- ../src ../deps 2> /dev/null | wc -l`
++GIT_SHA1="00000000"
++GIT_DIRTY="0"
+ BUILD_ID=`uname -n`"-"`date +%s`
+ if [ -n "$SOURCE_DATE_EPOCH" ]; then
+   BUILD_ID=$(date -u -d "@$SOURCE_DATE_EPOCH" +%s 2>/dev/null || date -u -r "$SOURCE_DATE_EPOCH" +%s 2>/dev/null || date -u +%s)
diff --git a/databases/valkey/files/pkg-message.in b/databases/valkey/files/pkg-message.in
new file mode 100644
index 000000000000..e32864db05c1
--- /dev/null
+++ b/databases/valkey/files/pkg-message.in
@@ -0,0 +1,11 @@
+[
+{ type: install
+  message: <<EOM
+      To setup "%%PORTNAME%%" you need to edit the configuration file:
+      %%PREFIX%%/etc/%%PORTNAME%%.conf
+
+      To run valkey from startup, add %%PORTNAME%%_enable="YES"
+      in your /etc/rc.conf.
+EOM
+}
+]
diff --git a/databases/valkey/files/valkey.in b/databases/valkey/files/valkey.in
new file mode 100644
index 000000000000..23be6ccb8a9e
--- /dev/null
+++ b/databases/valkey/files/valkey.in
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+# PROVIDE: valkey
+# REQUIRE: LOGIN
+# BEFORE:  securelevel
+# KEYWORD: shutdown
+
+# Add the following line to /etc/rc.conf to enable `valkey':
+#
+#valkey_enable="YES"
+#
+# Define profiles here to run separate valkey instances:
+#
+#valkey_profiles="foo bar" #  Script uses %%PREFIX%%/etc/valkey-NAME.conf respectively.
+#			     For correct script working please update pidfile entries in
+#			     valkey-NAME.conf files.
+
+. /etc/rc.subr
+
+name="valkey"
+rcvar="${name}_enable"
+
+extra_commands="reload"
+
+command="%%PREFIX%%/bin/valkey-server"
+pidfile="%%VALKEY_RUNDIR%%/$name.pid"
+
+# read configuration and set defaults
+load_rc_config "$name"
+: ${valkey_enable="NO"}
+: ${valkey_user="%%VALKEY_USER%%"}
+: ${valkey_config="%%PREFIX%%/etc/$name.conf"}
+
+command_args="${valkey_config}"
+required_files="${valkey_config}"
+
+_profile_exists() {
+	for _p in ${valkey_profiles}; do
+		[ "${_p}" = "$1" ] && return 1;
+	done
+	return 0
+}
+
+if [ $# -eq 2 ]; then
+	_profile=$2
+	_profile_exists $_profile
+	_exists=$?
+	[ ${_exists} -ne 1 ] && {
+		echo "`basename %%PREFIX%%/etc/rc.d/valkey`: no '$2' in 'valkey_profiles'"
+		exit 1
+	};
+	echo "-- Profile: ${_profile} --"
+	config_file="%%PREFIX%%/etc/${name}-${_profile}.conf"
+	command_args="${config_file}"
+	pidfile="%%VALKEY_RUNDIR%%/${_profile}.pid"
+	required_files="${config_file}"
+elif [ -n "${valkey_profiles}" ]; then
+	_swap=$*; shift; _profiles=$*
+	_profiles=${_profiles:-${valkey_profiles}}
+	set -- ${_swap}
+	for _profile in ${_profiles}; do
+		%%PREFIX%%/etc/rc.d/valkey $1 ${_profile}
+	done
+	exit 0
+fi
+
+run_rc_command "$1"
diff --git a/databases/valkey/files/valkeysentinel.in b/databases/valkey/files/valkeysentinel.in
new file mode 100644
index 000000000000..ec940321b1cd
--- /dev/null
+++ b/databases/valkey/files/valkeysentinel.in
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# PROVIDE: valkeysentinel
+# REQUIRE: LOGIN
+# BEFORE:  securelevel
+# KEYWORD: shutdown
+
+# Add the following line to /etc/rc.conf to enable `valkeysentinel':
+#
+#valkeysentinel_enable="YES"
+#
+
+. /etc/rc.subr
+
+name="valkeysentinel"
+rcvar="$valkeysentinel_enable"
+
+command="/usr/local/bin/valkey-sentinel"
+pidfile="/var/run/valkey/valkey-sentinel.pid"
+
+# read configuration and set defaults
+load_rc_config "$name"
+: ${valkeysentinel_enable="NO"}
+: ${valkeysentinel_user="valkey"}
+: ${valkeysentinel_config="/usr/local/etc/valkey-sentinel.conf"}
+
+command_args="${valkeysentinel_config} --daemonize yes --pidfile ${pidfile}"
+required_files="${valkeysentinel_config}"
+start_precmd="valkeysentinel_checks"
+restart_precmd="valkeysentinel_checks"
+
+valkeysentinel_checks()
+{
+    if [ x`id -u ${valkeysentinel_user}` != x`stat -f %u ${valkeysentinel_config}` ]; then
+	err 1 "${valkeysentinel_config} must be owned by user ${valkeysentinel_user}"
+    fi
+}
+
+run_rc_command "$1"
diff --git a/databases/valkey/pkg-descr b/databases/valkey/pkg-descr
new file mode 100644
index 000000000000..cbf8f62894b1
--- /dev/null
+++ b/databases/valkey/pkg-descr
@@ -0,0 +1,4 @@
+Valkey is a high-performance data structure server that primarily
+serves key/value workloads. It supports a wide range of native
+structures and an extensible plugin system for adding new data
+structures and access patterns.
diff --git a/databases/valkey/pkg-plist b/databases/valkey/pkg-plist
new file mode 100644
index 000000000000..9ccd7d930e5a
--- /dev/null
+++ b/databases/valkey/pkg-plist
@@ -0,0 +1,11 @@
+bin/valkey-benchmark
+bin/valkey-check-aof
+bin/valkey-check-rdb
+bin/valkey-cli
+bin/valkey-sentinel
+bin/valkey-server
+@sample etc/valkey.conf.sample
+@sample(%%VALKEY_USER%%,%%VALKEY_GROUP%%,) etc/valkey-sentinel.conf.sample
+@dir(%%VALKEY_USER%%,%%VALKEY_GROUP%%,) %%VALKEY_DBDIR%%
+@dir(%%VALKEY_USER%%,%%VALKEY_GROUP%%,) %%VALKEY_LOGDIR%%
+@dir(%%VALKEY_USER%%,%%VALKEY_GROUP%%,) %%VALKEY_RUNDIR%%