dev-db/valkey: new package, add 9.1.0

Closes: https://bugs.gentoo.org/928145
Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Sam James
2026-05-31 20:52:11 +01:00
parent 8d878fd772
commit e2131d4be0
15 changed files with 471 additions and 0 deletions

1
dev-db/valkey/Manifest Normal file
View File

@@ -0,0 +1 @@
DIST valkey-9.1.0.gh.tar.gz 4375381 BLAKE2B 6d4427463313d5d70afd3215875461cbb9e028b9229d25629a6ddb1e6138d2706bc5fbfb5bafdfee1b8aa6c86685a41c4c64c3ff0b0f2e5c34663ee569759a15 SHA512 39218e256471103a2e9e8ba77c0b87cbc479aa8b2a402a64f55aef4ab38e4ff613aca27ff3c19a7142ee9caa9099a987be2a710033244aee0ac3de0f72b3ff5a

View File

@@ -0,0 +1,20 @@
--- a/sentinel.conf
+++ b/sentinel.conf
@@ -17,7 +17,7 @@ daemonize no
# When running daemonized, Valkey Sentinel writes a pid file in
# /var/run/valkey-sentinel.pid by default. You can specify a custom pid file
# location here.
-pidfile /var/run/valkey-sentinel.pid
+pidfile /run/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 "/var/log/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.

View File

@@ -0,0 +1,38 @@
--- a/valkey.conf
+++ b/valkey.conf
@@ -425,7 +425,7 @@ daemonize no
#
# Note that on modern Linux systems "/run/valkey.pid" is more conforming
# and should be used instead.
-pidfile /var/run/valkey_6379.pid
+pidfile /run/valkey/valkey.pid
# Specify the server verbosity level.
# This can be one of:
@@ -457,7 +457,7 @@ loglevel notice
# Specify the log file name. Also the empty string can be used to force
# the server 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 /var/log/valkey/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.
@@ -661,7 +661,7 @@ rdb-del-sync-files no
# Note that modifying 'dir' during runtime may have unexpected behavior,
# for example when a child process is running, related file operations may
# have unexpected effects.
-dir ./
+dir /var/lib/valkey/
################################# REPLICATION #################################
@@ -1323,7 +1323,7 @@ acllog-max-len 128
# limit for maxmemory so that there is some free RAM on the system for replica
# output buffers (but this is not needed if the policy is 'noeviction').
#
-# maxmemory <bytes>
+maxmemory 64MB
# MAXMEMORY POLICY: how the server will select what to remove when maxmemory
# is reached. You can select one from the following behaviors:

View File

@@ -0,0 +1,55 @@
--- a/runtest
+++ b/runtest
@@ -3,7 +3,7 @@ TCL_VERSIONS="8.5 8.6 9.0"
TCLSH=""
for VERSION in $TCL_VERSIONS; do
- TCL=`which tclsh$VERSION 2>/dev/null` && TCLSH=$TCL
+ TCL=`command -v tclsh$VERSION 2>/dev/null` && TCLSH=$TCL
done
if [ -z $TCLSH ]
--- a/runtest-moduleapi
+++ b/runtest-moduleapi
@@ -4,7 +4,7 @@ TCLSH=""
[ -z "$MAKE" ] && MAKE=make
for VERSION in $TCL_VERSIONS; do
- TCL=`which tclsh$VERSION 2>/dev/null` && TCLSH=$TCL
+ TCL=`command -v tclsh$VERSION 2>/dev/null` && TCLSH=$TCL
done
if [ -z $TCLSH ]
--- a/runtest-sentinel
+++ b/runtest-sentinel
@@ -3,7 +3,7 @@ TCL_VERSIONS="8.5 8.6 9.0"
TCLSH=""
for VERSION in $TCL_VERSIONS; do
- TCL=`which tclsh$VERSION 2>/dev/null` && TCLSH=$TCL
+ TCL=`command -v tclsh$VERSION 2>/dev/null` && TCLSH=$TCL
done
if [ -z $TCLSH ]
--- a/src/Makefile
+++ b/src/Makefile
@@ -68,7 +68,7 @@ INSTALL=install
PKG_CONFIG?=pkg-config
ifndef PYTHON
-PYTHON := $(shell which python3 || which python)
+PYTHON := $(shell command -v python3 || command -v python)
endif
# Default allocator defaults to Jemalloc on Linux and libc otherwise
--- a/utils/generate-module-api-doc.rb
+++ b/utils/generate-module-api-doc.rb
@@ -241,7 +241,7 @@ end
# Populate the 'since' map (name => version) if we're in a git repo.
require "./" ++ File.dirname(__FILE__) ++ '/module-api-since.rb'
git_dir = File.dirname(__FILE__) ++ "/../.git"
-if File.directory?(git_dir) && `which git` != ""
+if File.directory?(git_dir) && `command -v git` != ""
`git --git-dir="#{git_dir}" tag --sort=v:refname`.each_line do |git_tag|
next if git_tag !~ /^(\d+)\.(\d+)\.(\d+)(?:-rc\d+)?$/ || $1.to_i < 7
# Version number, ignoring suffixes like -rc1.

View File

@@ -0,0 +1,17 @@
--- a/src/Makefile
+++ b/src/Makefile
@@ -141,6 +141,14 @@ FINAL_LDFLAGS=$(LDFLAGS) $(OPT) $(SERVER_LDFLAGS) $(DEBUG)
FINAL_LIBS=-lm
DEBUG=-g -ggdb
+ifneq (,$(filter powerpc ppc,$(uname_M)))
+ FINAL_LIBS+=-latomic
+else
+ifneq (,$(findstring ppc,$(uname_M)))
+ FINAL_LIBS+=-latomic
+endif
+endif
+
# Linux ARM32 needs -latomic at linking time
ifneq (,$(findstring armv,$(uname_M)))
FINAL_LIBS+=-latomic

View File

@@ -0,0 +1,26 @@
--- a/src/Makefile
+++ b/src/Makefile
@@ -72,10 +72,7 @@ PYTHON := $(shell which python3 || which python)
endif
# Default allocator defaults to Jemalloc on Linux and libc otherwise
-MALLOC=libc
-ifeq ($(uname_S),Linux)
- MALLOC=jemalloc
-endif
+MALLOC?=jemalloc
# To get ARM stack traces if Valkey crashes we need a special C flag.
ifneq (,$(filter aarch64 armv%,$(uname_M)))
@@ -330,9 +327,8 @@ ifeq ($(MALLOC),tcmalloc_minimal)
endif
ifeq ($(MALLOC),jemalloc)
- DEPENDENCY_TARGETS+= jemalloc
- FINAL_CFLAGS+= -DUSE_JEMALLOC -I../deps/jemalloc/include
- FINAL_LIBS := ../deps/jemalloc/lib/libjemalloc.a $(FINAL_LIBS)
+ FINAL_CFLAGS+= -DUSE_JEMALLOC -DJEMALLOC_NO_DEMANGLE
+ FINAL_LIBS+= -ljemalloc -ldl
endif
ifeq ($(USE_LTTNG),yes)

View File

@@ -0,0 +1,16 @@
# valkey-sentinel user.
VALKEY_SENTINEL_USER="valkey"
# valkey-sentinel group.
VALKEY_SENTINEL_GROUP="valkey"
# valkey-sentinel configuration file.
VALKEY_SENTINEL_CONF="/etc/valkey/sentinel.conf"
# valkey-sentinel working directory.
VALKEY_SENTINEL_DIR="/tmp"
# Specify the network service that corresponds to the "bind" setting
# in your sentinel.conf. For example, if you bind to 127.0.0.1, this should
# be set to "net.lo" which provides the loopback interface.
rc_need="net.lo"

View File

@@ -0,0 +1,22 @@
#!/sbin/openrc-run
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
: ${VALKEY_SENTINEL_DIR:=/tmp}
: ${VALKEY_SENTINEL_CONF:=/etc/valkey/sentinel.conf}
: ${VALKEY_SENTINEL_USER:=valkey}
: ${VALKEY_SENTINEL_GROUP:=valkey}
: ${VALKEY_SENTINEL_TIMEOUT:=30}
command="/usr/sbin/valkey-sentinel"
command_args="${VALKEY_SENTINEL_CONF}"
command_background="true"
command_user="${VALKEY_SENTINEL_USER}:${VALKEY_SENTINEL_GROUP}"
pidfile="/run/${RC_SVCNAME}.pid"
retry="${VALKEY_SENTINEL_TIMEOUT}"
start_stop_daemon_args="--chdir \"${VALKEY_SENTINEL_DIR}\""
depend() {
use localmount logger
after keepalived valkey
}

View File

@@ -0,0 +1,20 @@
# valkey user.
VALKEY_USER="valkey"
# valkey group.
VALKEY_GROUP="valkey"
# valkey configuration file.
VALKEY_CONF="/etc/valkey/valkey.conf"
# valkey dump directory.
VALKEY_DIR="/var/lib/valkey"
# valkey options.
# (valkey expects the first argument to be the configuration file.)
VALKEY_OPTS="${VALKEY_CONF}"
# Specify the network service that corresponds to the "bind" setting
# in your valkey.conf. For example, if you bind to 127.0.0.1, this should
# be set to "net.lo" which provides the loopback interface.
rc_need="net.lo"

View File

@@ -0,0 +1,25 @@
#!/sbin/openrc-run
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
: ${VALKEY_DIR:=/var/lib/valkey}
: ${VALKEY_CONF:=/etc/valkey/valkey.conf}
: ${VALKEY_OPTS:="${VALKEY_CONF}"}
: ${VALKEY_USER:=valkey}
: ${VALKEY_GROUP:=valkey}
: ${VALKEY_TIMEOUT:=30}
# https://bugs.gentoo.org/631002#c10
# Force '--daemonize no' to override the config file
command="/usr/sbin/valkey-server"
command_args="${VALKEY_OPTS} --daemonize no"
command_background="true"
command_user="${VALKEY_USER}:${VALKEY_GROUP}"
pidfile="/run/${RC_SVCNAME}.pid"
retry="${VALKEY_TIMEOUT}"
start_stop_daemon_args="--chdir \"${VALKEY_DIR}\""
depend() {
use localmount logger
after keepalived
}

View File

@@ -0,0 +1,6 @@
/var/log/valkey/valkey.log /var/log/valkey/sentinel.log {
compress
delaycompress
notifempty
missingok
}

View File

@@ -0,0 +1,13 @@
[Unit]
Description=A persistent key-value database
After=syslog.target network.target
[Service]
Type=simple
PIDFile=/run/valkey/valkey.pid
ExecStart=/usr/sbin/valkey-server /etc/valkey/valkey.conf
User=valkey
Group=valkey
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,2 @@
# valkey runtime directory
d /run/valkey 0755 valkey root -

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="person">
<email>sam@gentoo.org</email>
<name>Sam James</name>
</maintainer>
<use>
<flag name="tcmalloc">
Use tcmalloc from <pkg>dev-util/google-perftools</pkg> for allocations.
</flag>
</use>
<upstream>
<remote-id type="github">valkey-io/valkey</remote-id>
</upstream>
</pkgmetadata>

View File

@@ -0,0 +1,194 @@
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit edo multiprocessing systemd tmpfiles toolchain-funcs
DESCRIPTION="Persistent key-value store, fork of dev-db/redis"
HOMEPAGE="https://valkey.io https://github.com/valkey-io/valkey"
SRC_URI="
https://github.com/valkey-io/valkey/archive/refs/tags/${PV}.tar.gz -> ${P}.gh.tar.gz
"
# deps/fast_float: || ( Apache-2.0 MIT Boost-1.0 )
# deps/fpconv: Boost-1.0
# deps/hdr_histogram: CC0-1.0
# deps/lua: MIT
LICENSE="BSD || ( Apache-2.0 MIT Boost-1.0 ) Boost-1.0 CC0-1.0 MIT"
SLOT="0/$(ver_cut 1-2)"
KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~loong ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
IUSE="jemalloc ssl systemd tcmalloc test"
RESTRICT="!test? ( test )"
REQUIRED_USE="?? ( jemalloc tcmalloc )"
DEPEND="
jemalloc? ( >=dev-libs/jemalloc-5.1:=[stats] )
ssl? ( dev-libs/openssl:= )
systemd? ( sys-apps/systemd:= )
tcmalloc? ( dev-util/google-perftools )
"
RDEPEND="
${DEPEND}
acct-group/valkey
acct-user/valkey
"
BDEPEND="
acct-group/valkey
acct-user/valkey
virtual/pkgconfig
test? (
dev-lang/tcl:0=
ssl? ( dev-tcltk/tls )
)
"
PATCHES=(
"${FILESDIR}"/${PN}-9.1.0-config.patch
"${FILESDIR}"/${PN}-9.1.0-config-sentinel.patch
"${FILESDIR}"/${PN}-9.1.0-system-jemalloc.patch
"${FILESDIR}"/${PN}-9.1.0-ppc-atomic.patch
"${FILESDIR}"/${PN}-9.1.0-no-which.patch
)
src_prepare() {
default
# Respect user CFLAGS in bundled lua
sed -i '/LUA_CFLAGS/s: -O2::g' deps/Makefile || die
local mysedconf=(
-e 's:-Werror ::g'
-e 's:-Werror=deprecated-declarations ::g'
)
local f
while IFS= read -r -d '' f; do
sed -i "${mysedconf[@]}" "${f}" || die "sed failed for ${f}"
done < <(find -name 'Makefile' -print0)
# Linenoise can't be built with -std=c99, see bug #451164
# also, don't define ANSI/c99 for lua twice
sed -i -e "s:-std=c99::g" deps{,/linenoise}/Makefile || die
}
src_compile() {
tc-export AR CC RANLIB
# No point in unbundling Lua, as upstream have deviated too far from
# vanilla Lua, adding their own APIs like lua_enablereadonlytable.
local myconf=(
AR="${AR}"
CC="${CC}"
RANLIB="${RANLIB}"
V=1
# OPTIMIZATION defaults to -O3. Let's respect user CFLAGS by setting it
# to empty value.
OPTIMIZATION=''
# Disable debug flags in bundled libvalkey
DEBUG=''
DEBUG_FLAGS=''
BUILD_TLS=$(usex ssl)
USE_SYSTEMD=$(usex systemd)
)
if use jemalloc; then
myconf+=( MALLOC=jemalloc )
elif use tcmalloc; then
myconf+=( MALLOC=tcmalloc )
else
myconf+=( MALLOC=libc )
fi
emake "${myconf[@]}"
}
src_test() {
local runtestargs=(
--verbose
--clients "$(makeopts_jobs)" # bug #649868
# The Active defrag for argv test fails with edge values, it does not seem to be
# critical issue, see https://github.com/redis/redis/issues/14006
--skiptest "/Active defrag for argv retained by the main thread from IO thread.*"
# The following test fails with system jemalloc, as it expects
# different values, because the bundled jemalloc is compiled with
# --with-lg-quantum=3 parameter in order to provide additional size
# classes which are not 16 byte alligned.
--skiptest "Check MEMORY USAGE for embedded key strings with jemalloc"
# Timing-sensitive, see https://github.com/valkey-io/valkey/issues/2482
--skiptest "COPY Preserves TTLs"
--skiptest "RESTORE Preserves Field TTLs"
# Missing tmp in string
--skiptest "Process title set as expected"
# Unclear failure
--tags -external:skip
)
if has usersandbox ${FEATURES} || ! has userpriv ${FEATURES}; then
ewarn "oom-score-adj related tests will be skipped." \
"They are known to fail with FEATURES usersandbox or -userpriv. See bug #756382."
runtestargs+=(
# unit/oom-score-adj was introduced in version 6.2.0
--skipunit unit/oom-score-adj # bug #756382
# Following test was added in version 7.0.0 to unit/introspection.
# It also tries to adjust OOM score.
--skiptest "CONFIG SET rollback on apply error"
)
fi
if use ssl; then
edo ./utils/gen-test-certs.sh
runtestargs+=( --tls )
fi
edo ./runtest "${runtestargs[@]}"
}
src_install() {
insinto /etc/valkey
doins valkey.conf sentinel.conf
use prefix || fowners -R redis:redis /etc/valkey /etc/valkey/{valkey,sentinel}.conf
fperms 0750 /etc/valkey
fperms 0644 /etc/valkey/{valkey,sentinel}.conf
newconfd "${FILESDIR}"/valkey.confd valkey
newinitd "${FILESDIR}"/valkey.initd valkey
systemd_newunit "${FILESDIR}"/valkey.service valkey.service
newtmpfiles "${FILESDIR}"/valkey.tmpfiles valkey.conf
newconfd "${FILESDIR}"/valkey-sentinel.confd valkey-sentinel
newinitd "${FILESDIR}"/valkey-sentinel.initd valkey-sentinel
insinto /etc/logrotate.d
newins "${FILESDIR}"/${PN}.logrotate ${PN}
dodoc 00-RELEASENOTES CONTRIBUTING.md README.md
dobin src/valkey-cli
dosbin src/valkey-benchmark src/valkey-server src/valkey-check-aof src/valkey-check-rdb
fperms 0750 /usr/sbin/valkey-benchmark
dosym valkey-server /usr/sbin/valkey-sentinel
if use prefix; then
diropts -m0750
else
diropts -m0750 -o redis -g redis
fi
keepdir /var/{log,lib}/valkey
}
pkg_postinst() {
tmpfiles_process valkey.conf
}