diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5c9e18c --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +clog +valkey-8.*.tar.gz +valkey-doc-8.*.tar.gz +/valkey-9.0.0.tar.gz +/valkey-doc-9.0.0.tar.gz +/valkey-9.0.1.tar.gz +/valkey-doc-9.0.1.tar.gz diff --git a/README.md b/README.md new file mode 100644 index 0000000..37b6c08 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# valkey + +The valkey package diff --git a/dead.package b/dead.package deleted file mode 100644 index 5694108..0000000 --- a/dead.package +++ /dev/null @@ -1 +0,0 @@ -Added to RHEL 9.7 rhbz#2369374 diff --git a/migrate_redis_to_valkey.sh b/migrate_redis_to_valkey.sh new file mode 100644 index 0000000..3934956 --- /dev/null +++ b/migrate_redis_to_valkey.sh @@ -0,0 +1,24 @@ +#!/bin/sh +if [ -f /etc/redis/redis.conf ]; then + cp /etc/redis/redis.conf /etc/valkey/valkey.conf + mv /etc/redis/redis.conf /etc/redis/redis.conf.rpmsave + chown valkey:root /etc/valkey/valkey.conf + sed -i 's|^dir\s.*|dir /var/lib/valkey|g' /etc/valkey/valkey.conf + sed -i 's|logfile /var/log/redis/redis.log|logfile /var/log/valkey/valkey.log|' /etc/valkey/valkey.conf + echo "/etc/redis/redis.conf has been copied to /etc/valkey/valkey.conf. Manual review of valkey.conf is strongly suggested especially if you had modified redis.conf." +fi +if [ -f /etc/redis/sentinel.conf ]; then + cp /etc/redis/sentinel.conf /etc/valkey/sentinel.conf + mv /etc/redis/sentinel.conf /etc/redis/sentinel.conf.rpmsave + chown valkey:root /etc/valkey/sentinel.conf + sed -i 's|logfile /var/log/redis/sentinel.log|logfile /var/log/valkey/sentinel.log|' /etc/valkey/sentinel.conf + echo "/etc/redis/sentinel.conf has been copied to /etc/valkey/sentinel.conf. Manual review of sentinel.conf is strongly suggested especially if you had modified sentinel.conf." +fi +if [ -d /var/lib/redis ]; then + # cp could take a while, and this is a one-way move anyway + mv /var/lib/redis/* /var/lib/valkey/ + # don't leave garbage behind, plus we check if this dir exists when running this script + rm -rf /var/lib/redis + chown -R valkey. /var/lib/valkey + echo "On-disk redis dumps moved from /var/lib/redis/ to /var/lib/valkey" +fi diff --git a/sources b/sources new file mode 100644 index 0000000..6d26371 --- /dev/null +++ b/sources @@ -0,0 +1,2 @@ +SHA512 (valkey-9.0.1.tar.gz) = 99e1ab2abd0e1229df7804ac398088d4b3a8e1b031ab66da56ce98f56d0a97c7365b065bacc29d559194a18f5a85c9bf35c0c54f3a8402ec7c6fdbcf4f89181c +SHA512 (valkey-doc-9.0.1.tar.gz) = 061d3758cd754767bd0a45d6be3d709d82d91b2f7b0591b58cecd98cd39529bc0ec1bd490ef0890fb455f81fde33066412655005e25aa460989417803b15f45d diff --git a/valkey-conf.patch b/valkey-conf.patch new file mode 100644 index 0000000..a079055 --- /dev/null +++ b/valkey-conf.patch @@ -0,0 +1,61 @@ +diff -up ./sentinel.conf.rpm ./sentinel.conf +--- ./sentinel.conf.rpm 2025-07-07 09:18:20.000000000 +0200 ++++ ./sentinel.conf 2025-08-01 07:57:21.892278834 +0200 +@@ -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. +diff -up ./valkey.conf.rpm ./valkey.conf +--- ./valkey.conf.rpm 2025-07-07 09:18:20.000000000 +0200 ++++ ./valkey.conf 2025-08-01 07:57:17.825116953 +0200 +@@ -43,6 +43,9 @@ + # include /path/to/other.conf + # include /path/to/fragments/*.conf + # ++# Module configuration files ++include /etc/valkey/modules/*.conf ++ + + ################################## MODULES ##################################### + +@@ -163,7 +166,7 @@ tcp-backlog 511 + # incoming connections. There is no default, so the server will not listen + # on a unix socket when not specified. + # +-# unixsocket /run/valkey.sock ++unixsocket /run/valkey/valkey.sock + # unixsocketgroup wheel + # unixsocketperm 700 + +@@ -409,7 +412,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: +@@ -440,7 +443,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. diff --git a/valkey-loadmod.patch b/valkey-loadmod.patch new file mode 100644 index 0000000..dad9cb9 --- /dev/null +++ b/valkey-loadmod.patch @@ -0,0 +1,161 @@ +From b40ab88996d0bbe9bdd366af9426f7400b21e19c Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Sat, 4 Oct 2025 07:23:52 +0200 +Subject: [PATCH] Fix #2678 don't add loadmodule when from config + +only protect loadmodule from include files + +Signed-off-by: Remi Collet +--- + src/config.c | 8 ++++++-- + src/module.c | 17 ++++++++++++----- + src/module.h | 4 ++-- + 3 files changed, 20 insertions(+), 9 deletions(-) + +diff --git a/src/config.c b/src/config.c +index d0158b2c4d..ab453056df 100644 +--- a/src/config.c ++++ b/src/config.c +@@ -448,6 +448,8 @@ static int updateClientOutputBufferLimit(sds *args, int arg_len, const char **er + * within conf file parsing. This is only needed to support the deprecated + * abnormal aggregate `save T C` functionality. Remove in the future. */ + static int reading_config_file; ++/* support detecting include vs main config file */ ++static int reading_include_file = 0; + + void loadServerConfigFromString(sds config) { + deprecatedConfig deprecated_configs[] = { +@@ -539,7 +541,9 @@ void loadServerConfigFromString(sds config) { + + /* Execute config directives */ + if (!strcasecmp(argv[0], "include") && argc == 2) { ++ reading_include_file = 1; + loadServerConfig(argv[1], 0, NULL); ++ reading_include_file = 0; + } else if (!strcasecmp(argv[0], "rename-command") && argc == 3) { + struct serverCommand *cmd = lookupCommandBySds(argv[1]); + +@@ -572,7 +576,7 @@ void loadServerConfigFromString(sds config) { + goto loaderr; + } + } else if (!strcasecmp(argv[0], "loadmodule") && argc >= 2) { +- moduleEnqueueLoadModule(argv[1], &argv[2], argc - 2); ++ moduleEnqueueLoadModule(argv[1], &argv[2], argc - 2, reading_include_file); + } else if (strchr(argv[0], '.')) { + if (argc < 2) { + err = "Module config specified without value"; +@@ -1605,7 +1609,7 @@ void rewriteConfigLoadmoduleOption(struct rewriteConfigState *state) { + while ((de = dictNext(di)) != NULL) { + struct ValkeyModule *module = dictGetVal(de); + line = moduleLoadQueueEntryToLoadmoduleOptionStr(module, "loadmodule"); +- rewriteConfigRewriteLine(state, "loadmodule", line, 1); ++ if (line) rewriteConfigRewriteLine(state, "loadmodule", line, 1); + } + dictReleaseIterator(di); + /* Mark "loadmodule" as processed in case modules is empty. */ +diff --git a/src/module.c b/src/module.c +index e5afa952fa..f18bc3c6bf 100644 +--- a/src/module.c ++++ b/src/module.c +@@ -84,6 +84,7 @@ + + struct moduleLoadQueueEntry { + sds path; ++ int from_include; + int argc; + robj **argv; + }; +@@ -670,7 +671,7 @@ void freeClientModuleData(client *c) { + c->module_data = NULL; + } + +-void moduleEnqueueLoadModule(sds path, sds *argv, int argc) { ++void moduleEnqueueLoadModule(sds path, sds *argv, int argc, int from_include) { + int i; + struct moduleLoadQueueEntry *loadmod; + +@@ -678,6 +679,7 @@ void moduleEnqueueLoadModule(sds path, sds *argv, int argc) { + loadmod->argv = argc ? zmalloc(sizeof(robj *) * argc) : NULL; + loadmod->path = sdsnew(path); + loadmod->argc = argc; ++ loadmod->from_include = from_include; + for (i = 0; i < argc; i++) { + loadmod->argv[i] = createRawStringObject(argv[i], sdslen(argv[i])); + } +@@ -688,6 +690,10 @@ sds moduleLoadQueueEntryToLoadmoduleOptionStr(ValkeyModule *module, + const char *config_option_str) { + sds line; + ++ if (module->loadmod->from_include) { ++ /* no need to add as already from config */ ++ return NULL; ++ } + line = sdsnew(config_option_str); + line = sdscatlen(line, " ", 1); + line = sdscatsds(line, module->loadmod->path); +@@ -12350,7 +12356,7 @@ void moduleLoadFromQueue(void) { + listRewind(server.loadmodule_queue, &li); + while ((ln = listNext(&li))) { + struct moduleLoadQueueEntry *loadmod = ln->value; +- if (moduleLoad(loadmod->path, (void **)loadmod->argv, loadmod->argc, 0) == C_ERR) { ++ if (moduleLoad(loadmod->path, (void **)loadmod->argv, loadmod->argc, 0, loadmod->from_include) == C_ERR) { + serverLog(LL_WARNING, "Can't load module from %s: server aborting", loadmod->path); + exit(1); + } +@@ -12531,7 +12537,7 @@ void moduleUnregisterCleanup(ValkeyModule *module) { + + /* Load a module and initialize it. On success C_OK is returned, otherwise + * C_ERR is returned. */ +-int moduleLoad(const char *path, void **module_argv, int module_argc, int is_loadex) { ++int moduleLoad(const char *path, void **module_argv, int module_argc, int is_loadex, int from_include) { + int (*onload)(void *, void **, int); + void *handle; + +@@ -12606,6 +12612,7 @@ int moduleLoad(const char *path, void **module_argv, int module_argc, int is_loa + ctx.module->loadmod->path = sdsnew(path); + ctx.module->loadmod->argv = module_argc ? zmalloc(sizeof(robj *) * module_argc) : NULL; + ctx.module->loadmod->argc = module_argc; ++ ctx.module->loadmod->from_include = from_include; + for (int i = 0; i < module_argc; i++) { + ctx.module->loadmod->argv[i] = module_argv[i]; + incrRefCount(ctx.module->loadmod->argv[i]); +@@ -13529,7 +13536,7 @@ void moduleCommand(client *c) { + argv = &c->argv[3]; + } + +- if (moduleLoad(c->argv[2]->ptr, (void **)argv, argc, 0) == C_OK) ++ if (moduleLoad(c->argv[2]->ptr, (void **)argv, argc, 0, 0) == C_OK) + addReply(c, shared.ok); + else + addReplyError(c, "Error loading the extension. Please check the server logs."); +@@ -13544,7 +13551,7 @@ void moduleCommand(client *c) { + /* If this is a loadex command we want to populate server.module_configs_queue with + * sds NAME VALUE pairs. We also want to increment argv to just after ARGS, if supplied. */ + if (parseLoadexArguments((ValkeyModuleString ***)&argv, &argc) == VALKEYMODULE_OK && +- moduleLoad(c->argv[2]->ptr, (void **)argv, argc, 1) == C_OK) ++ moduleLoad(c->argv[2]->ptr, (void **)argv, argc, 1, 0) == C_OK) + addReply(c, shared.ok); + else { + dictEmpty(server.module_configs_queue, NULL); +diff --git a/src/module.h b/src/module.h +index f6c266b592..1f9e729e56 100644 +--- a/src/module.h ++++ b/src/module.h +@@ -169,7 +169,7 @@ static inline void moduleInitDigestContext(ValkeyModuleDigest *mdvar) { + memset(mdvar->x, 0, sizeof(mdvar->x)); + } + +-void moduleEnqueueLoadModule(sds path, sds *argv, int argc); ++void moduleEnqueueLoadModule(sds path, sds *argv, int argc, int from_include); + sds moduleLoadQueueEntryToLoadmoduleOptionStr(ValkeyModule *module, + const char *config_option_str); + ValkeyModuleCtx *moduleAllocateContext(void); +@@ -180,7 +180,7 @@ void moduleFreeContext(ValkeyModuleCtx *ctx); + void moduleInitModulesSystem(void); + void moduleInitModulesSystemLast(void); + void modulesCron(void); +-int moduleLoad(const char *path, void **argv, int argc, int is_loadex); ++int moduleLoad(const char *path, void **argv, int argc, int is_loadex, int from_include); + int moduleUnload(sds name, const char **errmsg); + void moduleLoadFromQueue(void); + int moduleGetCommandKeysViaAPI(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result); diff --git a/valkey-sentinel.service b/valkey-sentinel.service new file mode 100644 index 0000000..36093e0 --- /dev/null +++ b/valkey-sentinel.service @@ -0,0 +1,34 @@ +[Unit] +Description=Valkey Sentinel +After=network.target +After=network-online.target +Wants=network-online.target + +[Service] +# ensure var is set +Environment=OPTIONS= +EnvironmentFile=-/etc/sysconfig/valkey-sentinel +# we must keep $OPTIONS and the env file as some older installs will still be using /etc/sysconfig/valkey-sentinel +ExecStart=/usr/bin/valkey-sentinel /etc/valkey/sentinel.conf --daemonize no --supervised systemd $OPTIONS +Type=notify +User=valkey +Group=valkey +RuntimeDirectory=valkey +RuntimeDirectoryMode=0755 + +# If you need to change max open file limit +# for example, when you change maxclient in configuration +# you can change the LimitNOFILE value below. +# See "man systemd.exec" for more information. +LimitNOFILE=10240 + +# Slave nodes on large system may take lot of time to start. +# You may need to uncomment TimeoutStartSec and TimeoutStopSec +# directives below and raise their value. +# See "man systemd.service" for more information. +#TimeoutStartSec=90s +#TimeoutStopSec=90s + +[Install] +WantedBy=multi-user.target + diff --git a/valkey.logrotate b/valkey.logrotate new file mode 100644 index 0000000..e91fcd3 --- /dev/null +++ b/valkey.logrotate @@ -0,0 +1,9 @@ +/var/log/valkey/*.log { + weekly + rotate 10 + copytruncate + delaycompress + compress + notifempty + missingok +} diff --git a/valkey.service b/valkey.service new file mode 100644 index 0000000..827f5f2 --- /dev/null +++ b/valkey.service @@ -0,0 +1,35 @@ +[Unit] +Description=Valkey persistent key-value database +After=network.target +After=network-online.target +Wants=network-online.target + +[Service] +WorkingDirectory=/var/lib/valkey +# ensure var is set +Environment=OPTIONS= +EnvironmentFile=-/etc/sysconfig/valkey +# we must keep $OPTIONS and the env file as some older installs will still be using /etc/sysconfig/valkey +ExecStart=/usr/bin/valkey-server /etc/valkey/valkey.conf --daemonize no --supervised systemd $OPTIONS +Type=notify +User=valkey +Group=valkey +RuntimeDirectory=valkey +RuntimeDirectoryMode=0755 + +# If you need to change max open file limit +# for example, when you change maxclient in configuration +# you can change the LimitNOFILE value below. +# See "man systemd.exec" for more information. +LimitNOFILE=10240 + +# Slave nodes on large system may take lot of time to start. +# You may need to uncomment TimeoutStartSec and TimeoutStopSec +# directives below and raise their value. +# See "man systemd.service" for more information. +#TimeoutStartSec=90s +#TimeoutStopSec=90s + +[Install] +WantedBy=multi-user.target + diff --git a/valkey.spec b/valkey.spec new file mode 100644 index 0000000..8b97070 --- /dev/null +++ b/valkey.spec @@ -0,0 +1,588 @@ +# Docs require pandoc, which is not included in RHEL +%if %{undefined rhel} || %{defined epel} +%bcond_without docs +%else +%bcond_with docs +%endif +# See https://github.com/valkey-io/valkey-doc/tags +%global doc_version 9.0.1 +# Tests fail in mock, not in local build. +%bcond_with tests + +Name: valkey +Version: 9.0.1 +Release: 1%{?dist} +Summary: A persistent key-value database +# valkey: BSD-3-Clause +# hiredis: BSD-3-Clause +# hdrhistogram, jemalloc, lzf, linenoise: BSD-2-Clause +# lua: MIT +# fpconv: BSL-1.0 +License: BSD-3-Clause AND BSD-2-Clause AND MIT AND BSL-1.0 +URL: https://valkey.io +Source0: https://github.com/valkey-io/%{name}/archive/%{version}/%{name}-%{version}.tar.gz +Source1: %{name}.logrotate +Source2: %{name}-sentinel.service +Source3: %{name}.service +Source4: %{name}.sysusers +Source5: %{name}.tmpfiles +Source9: migrate_redis_to_valkey.sh +Source50: https://github.com/valkey-io/%{name}-doc/archive/%{doc_version}/%{name}-doc-%{doc_version}.tar.gz + +# Fix default paths in configuration files for RPM layout +Patch0: %{name}-conf.patch +# Workaround to https://github.com/valkey-io/valkey/issues/2678 +Patch1: %{name}-loadmod.patch + +BuildRequires: make +BuildRequires: gcc +%if %{with tests} +BuildRequires: procps-ng +BuildRequires: tcl +%endif +BuildRequires: pkgconfig(libsystemd) +BuildRequires: systemd-devel +BuildRequires: systemd-rpm-macros +BuildRequires: rdma-core-devel +BuildRequires: openssl-devel +%if %{with docs} +# for docs/man pages +BuildRequires: pandoc +BuildRequires: python3 +BuildRequires: python3-pyyaml +%endif + +Requires: logrotate +# from deps/libvalkey/include/valkey/valkey.h +Provides: bundled(libvalkey) = 0.2.1 +# from deps/jemalloc/VERSION +Provides: bundled(jemalloc) = 5.3.0 +# from deps/lua/src/lua.h +Provides: bundled(lua-libs) = 5.1.5 +# from deps/linenoise/linenoise.h +Provides: bundled(linenoise) = 1.0 +Provides: bundled(lzf) +# from deps/README.md +# e4448cf6d1cd08fff519812d3b1e58bd5a94ac42 +Provides: bundled(hdr_histogram) = 0.11.9 +# no version +Provides: bundled(fpconv) + +# sub-package was dropped +Obsoletes: valkey-tls < %{version}-%{release} +Provides: valkey-tls = %{version}-%{release} + +%global valkey_modules_abi 1 +%global valkey_modules_dir %{_libdir}/%{name}/modules +%global valkey_modules_cfg %{_sysconfdir}/%{name}/modules +Provides: valkey(modules_abi)%{?_isa} = %{valkey_modules_abi} + +ExcludeArch: %{ix86} + +%description +Valkey is an advanced key-value store. It is often referred to as a data +structure server since keys can contain strings, hashes, lists, sets and +sorted sets. + +You can run atomic operations on these types, like appending to a string; +incrementing the value in a hash; pushing to a list; computing set +intersection, union and difference; or getting the member with highest +ranking in a sorted set. + +In order to achieve its outstanding performance, Valkey works with an +in-memory dataset. Depending on your use case, you can persist it either +by dumping the dataset to disk every once in a while, or by appending +each command to a log. + +Valkey also supports trivial-to-setup master-slave replication, with very +fast non-blocking first synchronization, auto-reconnection on net split +and so forth. + +Other features include Transactions, Pub/Sub, Lua scripting, Keys with a +limited time-to-live, and configuration settings to make Valkey behave like +a cache. + +You can use Valkey from most programming languages also. + +See https://valkey.io/topics/ + +%package devel +Summary: Development header for Valkey module development +# Header-Only Library (https://fedoraproject.org/wiki/Packaging:Guidelines) +Provides: %{name}-static = %{version}-%{release} +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description devel +Header file required for building loadable Valkey modules. + +%package rdma +Summary: RDMA module for %{name} +Requires: %{name}%{?_isa} = %{version}-%{release} +Supplements: %{name} + +%description rdma +%summary. + +See https://valkey.io/topics/RDMA/ + + +%package compat-redis +Summary: Conversion script and compatibility symlinks for Redis +Requires: valkey = %{version}-%{release} +%if 0%{?fedora} > 40 || 0%{?rhel} > 9 +Obsoletes: redis < 7.4 +Provides: redis = %{version}-%{release} +%else +Conflicts: redis < 7.4 +%endif +BuildArch: noarch + + +%description compat-redis +%summary + + +%package compat-redis-devel +Summary: Compatibility development header for Redis API Valkey modules +Requires: valkey-devel = %{version}-%{release} +%if 0%{?fedora} > 40 || 0%{?rhel} > 9 +Obsoletes: redis-devel < 7.4 +Provides: redis-devel = %{version}-%{release} +# Header-Only Library (https://fedoraproject.org/wiki/Packaging:Guidelines) +Obsoletes: redis-static < 7.4 +Provides: redis-static = %{version}-%{release} +%else +Conflicts: redis-devel < 7.4 +Conflicts: redis-static < 7.4 +%endif +BuildArch: noarch + + +%description compat-redis-devel +Header file required for building loadable Valkey modules with the legacy +Redis API. + + +%if %{with docs} +%package doc +Summary: Documentation and extra man pages for %{name} +BuildArch: noarch +License: CC-BY-SA-4.0 +%if 0%{?fedora} > 40 || 0%{?rhel} > 9 +Obsoletes: redis-doc < 7.4 +Provides: redis-doc = %{version}-%{release} +%endif + + +%description doc +%summary +%endif + + +%prep +# no autosetup due to no support for multiple source extraction +%setup -n %{name}-%{version} -a50 +%patch -P0 -p1 -b .rpm +%patch -P1 -p1 -b .loadmod + +mv deps/lua/COPYRIGHT COPYRIGHT-lua +mv deps/jemalloc/COPYING COPYING-jemalloc +mv deps/libvalkey/COPYING COPYING-libvalkey +mv deps/hdr_histogram/LICENSE.txt LICENSE-hdrhistogram +mv deps/hdr_histogram/COPYING.txt COPYING-hdrhistogram +mv deps/fpconv/LICENSE.txt LICENSE-fpconv + +# See https://bugzilla.redhat.com/2240293 +# See https://src.fedoraproject.org/rpms/jemalloc/blob/rawhide/f/jemalloc.spec#_34 +%ifarch %ix86 %arm x86_64 s390x +sed -e 's/--with-lg-quantum/--with-lg-page=12 --with-lg-quantum/' -i deps/Makefile +%endif +%ifarch ppc64 ppc64le aarch64 +sed -e 's/--with-lg-quantum/--with-lg-page=16 --with-lg-quantum/' -i deps/Makefile +%endif + +# Module API version safety check +api=`sed -n -e 's/#define VALKEYMODULE_APIVER_[0-9][0-9]* //p' src/valkeymodule.h` +if test "$api" != "%{valkey_modules_abi}"; then + : Error: Upstream API version is now ${api}, expecting %%{valkey_modules_abi}. + : Update the valkey_modules_abi macro, and rebuild. + exit 1 +fi + +# Generates macro file +cat << 'EOF' | tee macros.%{name} +%%valkey_version %version +%%valkey_modules_abi %valkey_modules_abi +%%valkey_modules_dir %valkey_modules_dir +%%valkey_modules_cfg %valkey_modules_cfg +EOF + +%if (%{defined fedora} && 0%{?fedora} < 42) || (%{defined rhel} && 0%{?rhel} < 10) +# these lines are for conditionals around sysconfig to valkey.conf porting scriptlets to avoid re-runs +echo '# valkey_rpm_conf' >> valkey.conf +echo '# valkey-sentinel_rpm_conf' >> sentinel.conf +%endif + +%global make_flags DEBUG="" V="echo" PREFIX=%{buildroot}%{_prefix} BUILD_WITH_SYSTEMD=yes BUILD_TLS=yes BUILD_RDMA=module + +: RDMA configuration file +cat << EOF | tee rdma.conf +# RDMA module +loadmodule %{valkey_modules_dir}/rdma.so +EOF + + +%build +%make_build %{make_flags} + +%if %{with docs} +# docs +pushd %{name}-doc-%{doc_version} +# build man pages +%make_build VALKEY_ROOT=../ +# build html docs +%make_build html VALKEY_ROOT=../ +popd +%endif + + +%install +%make_install %{make_flags} +%if %{with docs} +# install docs +pushd %{name}-doc-%{doc_version} +# man pages +%make_install INSTALL_MAN_DIR=%{buildroot}%{_mandir} VALKEY_ROOT=../ +# install html docs +install -d %{buildroot}%{_docdir}/%{name}/ +cp -ra _build/html/* %{buildroot}%{_docdir}/%{name}/ +# install doc license +install -d %{buildroot}%{_defaultlicensedir}/valkey-doc/ +cp -a LICENSE %{buildroot}%{_defaultlicensedir}/valkey-doc/ +popd +%endif + +# remove sample confs +rm -rf %{buildroot}%{_datadir}/%{name} + +# System user +install -p -D -m 0644 %{S:4} %{buildroot}%{_sysusersdir}/%{name}.conf + +# Install tmpfiles.d file +install -p -D -m 0644 %{S:5} %{buildroot}%{_tmpfilesdir}/%{name}.conf + +# Filesystem. +install -d %{buildroot}%{_sharedstatedir}/%{name} +install -d %{buildroot}%{_localstatedir}/log/%{name} +install -d %{buildroot}%{_localstatedir}/run/%{name} +install -d %{buildroot}%{valkey_modules_dir} + +# Install logrotate file. +install -pDm644 %{S:1} %{buildroot}%{_sysconfdir}/logrotate.d/%{name} + +# Install configuration files. +install -pDm640 %{name}.conf %{buildroot}%{_sysconfdir}/%{name}/%{name}.conf +install -pDm640 sentinel.conf %{buildroot}%{_sysconfdir}/%{name}/sentinel.conf +install -dm750 %{buildroot}%{valkey_modules_cfg} + +# Install systemd unit files. +mkdir -p %{buildroot}%{_unitdir} +install -pm644 %{S:3} %{buildroot}%{_unitdir} +install -pm644 %{S:2} %{buildroot}%{_unitdir} + +# Fix non-standard-executable-perm error. +chmod 755 %{buildroot}%{_bindir}/%{name}-* + +# Install valkey module header +install -pDm644 src/%{name}module.h %{buildroot}%{_includedir}/%{name}module.h + +# Install rpm macros for valkey modules +#mkdir -p %{buildroot}%{_rpmmacrodir} +install -pDm644 macros.%{name} %{buildroot}%{_rpmmacrodir}/macros.%{name} + +# compat script +install -Dpm 755 %{S:9} %{buildroot}%{_libexecdir}/migrate_redis_to_valkey.sh + +# compat header +install -pDm644 src/redismodule.h %{buildroot}%{_includedir}/redismodule.h + +# compat systemd symlinks +ln -sr %{buildroot}/usr/lib/systemd/system/valkey.service %{buildroot}/usr/lib/systemd/system/redis.service +ln -sr %{buildroot}/usr/lib/systemd/system/valkey-sentinel.service %{buildroot}/usr/lib/systemd/system/redis-sentinel.service + +# RDMA module +install -pm755 src/valkey-rdma.so %{buildroot}%{valkey_modules_dir}/rdma.so +install -pm640 rdma.conf %{buildroot}%{valkey_modules_cfg}/rdma.conf + + +%check +%if %{with tests} +# https://github.com/redis/redis/issues/1417 (for "taskset -c 1") +taskset -c 1 ./runtest --clients 50 --skiptest "Active defrag - AOF loading" + +# sentinel tests fail in mock, but we want the normal tests above +#./runtest-sentinel +%endif + + + +%post +%if (%{defined fedora} && 0%{?fedora} < 42) || (%{defined rhel} && 0%{?rhel} < 10) +# migrate away from /etc/sysconfig/valkey +# only during upgrades, not installs +if [ $1 -eq 2 ]; then + # if valkey.rpmsave doesn't exist then it wasn't modified by the user + # and we should write our defaults into the config file to ensure continuity of service + # these defaults are what was previously in /etc/sysconfig/valkey + # if there's no .rpmnew file they got the updated default config file so we don't need to sed + if [ ! -f /etc/sysconfig/valkey.rpmsave ] && [ -f /etc/valkey/valkey.conf.rpmnew ] && ! grep -q valkey_rpm_conf /etc/valkey/valkey.conf; then + sed -i -e 's|^logfile ""$|logfile /var/log/valkey/valkey.log|g' \ + -e 's|^pidfile /var/run/valkey_6379.pid$|pidfile /run/valkey/valkey.pid|g' \ + /etc/valkey/valkey.conf + # we need an extra conditional around this one to make sure we don't end up with duplicate + # config lines for unixsocket since the default is commented + if ! grep -q "^unixsocket " /etc/valkey/valkey.conf; then + sed -i 's|^# unixsocket /run/valkey.sock$|unixsocket /run/valkey/valkey.sock|g' /etc/valkey/valkey.conf + fi + echo '# valkey_rpm_conf' >> /etc/valkey/valkey.conf + fi + if [ ! -f /etc/sysconfig/valkey-sentinel.rpmsave ] && [ -f /etc/valkey/valkey-sentinel.conf.rpmnew ] && ! grep -q valkey-sentinel_rpm_conf /etc/valkey/sentinel.conf; then + sed -i -e 's|^logfile ""$|logfile /var/log/valkey/sentinel.log|g' \ + -e 's|^pidfile /var/run/valkey_6379.pid$|pidfile /run/valkey/sentinel.pid|g' \ + /etc/valkey/sentinel.conf + echo '# valkey-sentinel_rpm_conf' >> /etc/valkey/sentinel.conf + fi + + # if valkey.rpmsave does exist then it was modified and we still need it + # becuase we don't know what was modified so we cannot sed the main config + # or remove the sysconfig file. This will detach the sysconfig file from the RPM + # and as long as we keep the line to load it in the service file nothing will break + # for the user + if [ -f /etc/sysconfig/valkey.rpmsave ]; then + mv -n /etc/sysconfig/valkey{.rpmsave,} + fi + if [ -f /etc/sysconfig/valkey-sentinel.rpmsave ]; then + mv -n /etc/sysconfig/valkey-sentinel{.rpmsave,} + fi +fi +%endif + +%systemd_post %{name}.service +%systemd_post %{name}-sentinel.service + + +%post compat-redis +%{_libexecdir}/migrate_redis_to_valkey.sh + + +%preun +%systemd_preun %{name}.service +%systemd_preun %{name}-sentinel.service + + +%postun +%systemd_postun_with_restart %{name}.service +%systemd_postun_with_restart %{name}-sentinel.service + + +%files +%license COPYING +%license COPYRIGHT-lua +%license COPYING-jemalloc +%license LICENSE-hdrhistogram +%license COPYING-hdrhistogram +%license LICENSE-fpconv +%license COPYING-libvalkey +%config(noreplace) %{_sysconfdir}/logrotate.d/%{name} +%attr(0750, valkey, root) %dir %{_sysconfdir}/%{name} +%attr(0750, valkey, root) %dir %{valkey_modules_cfg} +%attr(0640, valkey, root) %config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf +%attr(0640, valkey, root) %config(noreplace) %{_sysconfdir}/%{name}/sentinel.conf +%dir %{_libdir}/%{name} +%dir %{valkey_modules_dir} +%dir %attr(0750, valkey, valkey) %{_sharedstatedir}/%{name} +%dir %attr(0750, valkey, valkey) %{_localstatedir}/log/%{name} +%{_bindir}/%{name}-* +%{_unitdir}/%{name}.service +%{_unitdir}/%{name}-sentinel.service +%dir %attr(0755, valkey, valkey) %ghost %{_localstatedir}/run/%{name} +%{_sysusersdir}/%{name}.conf +%{_tmpfilesdir}/%{name}.conf +%if %{with docs} +%{_mandir}/man1/%{name}*.gz +%{_mandir}/man5/%{name}.conf.5.gz +%endif + + +%if %{with docs} +%files doc +%license LICENSE +%doc %{_docdir}/valkey/ +%{_mandir}/man{3,7}/*%{name}*.gz +%endif + +%files rdma +%attr(0640, valkey, root) %config(noreplace) %{valkey_modules_cfg}/rdma.conf +%{valkey_modules_dir}/rdma.so + +%files devel +# main package is not required +%license COPYING +%{_includedir}/%{name}module.h +%{_rpmmacrodir}/macros.%{name} + + +%files compat-redis +%{_libexecdir}/migrate_redis_to_valkey.sh +%{_bindir}/redis-* +%{_unitdir}/redis.service +%{_unitdir}/redis-sentinel.service + +%files compat-redis-devel +%{_includedir}/redismodule.h + + +%changelog +* Wed Dec 10 2025 Remi Collet - 9.0.1-1 +- Valkey 9.0.1 - December 9, 2025 +- Upgrade urgency MODERATE + +* Thu Nov 27 2025 Remi Collet - 9.0.0-2 +- build TLS statically as module not supported by sentinel +- drop sub-package for TLS module + +* Wed Oct 22 2025 Remi Collet - 9.0.0-1 +- Valkey 9.0.0 GA - October 21, 2025 +- bundled hiredis replaced by libvalkey + +* Mon Oct 6 2025 Remi Collet - 8.1.4-2 +- improve the patch for loadmodule directive + +* Sat Oct 4 2025 Remi Collet - 8.1.4-1 +- Valkey 8.1.4 - Released Fri 09 October 2025 +- Upgrade urgency SECURITY: + CVE-2025-49844 CVE-2025-46817 CVE-2025-46818 CVE-2025-46819 +- fix CONFIG REWRITE breaks configuration + reported as https://github.com/valkey-io/valkey/issues/2678 + using patch from https://github.com/valkey-io/valkey/pull/2689 + +* Wed Oct 1 2025 Remi Collet - 8.1.3-6 +- add sub-package for RDMA module +- add sub-package for TLS module + +* Fri Sep 26 2025 Nathan Scott - 8.1.3-5 +- enable Remote Direct Memory Access (RDMA) capabilities + +* Tue Sep 9 2025 Remi Collet - 8.1.3-4 +- fix for ImageMode: ensure ownership of /etc/valkey + +* Thu Aug 28 2025 Remi Collet - 8.1.3-3 +- use patch for configuration changes +- add /etc/valkey/modules drop-in directory for module configuration files +- add %%valkey_version and %%valkey_modules_cfg macros + +* Fri Jul 25 2025 Fedora Release Engineering - 8.1.3-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild + +* Mon Jul 7 2025 Remi Collet - 8.1.3-1 +- update to 8.1.3 + fixes CVE-2025-CVE-2025-32023 and CVE-2025-48367 + +* Wed Jun 18 2025 Remi Collet - 8.1.2-1 +- update to 8.1.2 + fixes CVE-2025-27151 + +* Thu Apr 24 2025 Remi Collet - 8.1.1-1 +- update to 8.1.1 + fixes CVE-2025-21605 + +* Fri Apr 04 2025 Nathan Scott - 8.1.0-1 +- include tmpfiles.d configuration file +- redis.log transition rhbz#2316030 +- update to 8.1.0 rhbz#22356280 + +* Tue Feb 11 2025 Zbigniew Jędrzejewski-Szmek - 8.0.2-3 +- Drop call to %sysusers_create_compat + +* Sun Jan 19 2025 Fedora Release Engineering - 8.0.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild + +* Wed Jan 08 2025 Jonathan Wright - 8.0.2-1 +- update to 8.0.2 rhbz#2336259 + fixes CVE-2024-46981 + fixes CVE-2024-51741 + +* Wed Nov 13 2024 Jonathan Wright - 8.0.1-3 +- include license with doc sub-package +- include systemd symlinks for redis in compat package + +* Mon Oct 07 2024 Jonathan Wright - 8.0.1-2 +- fix spec for epel8 +- buildrequires python3 for docs + +* Mon Oct 07 2024 Jonathan Wright - 8.0.1-1 +- update to 8.0.1 rhbz#2316254 + fixes CVE-2024-31449 + fixes CVE-2024-31227 + fixes CVE-2024-31228 + +* Fri Sep 27 2024 Yaakov Selkowitz - 8.0.0-3 +- Disable docs on RHEL + +* Tue Sep 24 2024 Jonathan Wright - 8.0.0-2 +- add man pages rhbz#2276017 +- add doc subpackage rhbz#2276020 + +* Mon Sep 16 2024 Jonathan Wright - 8.0.0-1 +- update to 8.0.0 rhbz#2312577 + +* Mon Aug 12 2024 Neal Gompa - 7.2.6-2 +- Add compat-redis-devel subpackage for Redis API Valkey modules + Resolves: rhbz#2304083 + +* Mon Aug 05 2024 Jonathan Wright - 7.2.6-1 +- update to 7.2.6 rhbz#2302510 + +* Thu Aug 1 2024 Remi Collet - 7.2.5-11 +- merge limit.conf in main service files +- fix obsoletes/conflicts up to 7.4 + +* Sat Jul 20 2024 Fedora Release Engineering - 7.2.5-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild + +* Mon Jul 15 2024 Jonathan Wright - 7.2.5-9 +- Fix journal warning rhbz#2297457 + +* Tue Jul 02 2024 Jonathan Wright - 7.2.5-8 +- Enable tests by default + selectively disable tests that fail in mock for redis + disable redis-sentinel tests, they always fail in mock + +* Sat Jun 22 2024 Neal Gompa - 7.2.5-7 +- Enable automatic replacement of redis with valkey + +* Mon Jun 17 2024 Jonathan Wright - 7.2.5-6 +- drop /etc/sysconfig/valkey + +* Mon Apr 29 2024 Jonathan Wright - 7.2.5-5 +- improve migration scripts +- rename compat package +- fix working dir + +* Mon Apr 22 2024 Nathan Scott - 7.2.5-3 +- remove version_no_tilde code + +* Mon Apr 22 2024 Nathan Scott - 7.2.5-2 +- move redis compat symlinks to compat subpackage + +* Wed Apr 17 2024 Jonathan Wright - 7.2.5-1 +- update to 7.2.5 rhbz#2275379 + +* Fri Apr 12 2024 Jonathan Wright - 7.2.5~rc1-2 +- add compat subpackage with migration scripts from redis + +* Fri Apr 12 2024 Jonathan Wright - 7.2.5~rc1-1 +- update to 7.2.5-rc1 + +* Tue Apr 09 2024 Jonathan Wright - 7.2.4~rc1-1 +- Initial package build, release candidate diff --git a/valkey.sysusers b/valkey.sysusers new file mode 100644 index 0000000..94242f3 --- /dev/null +++ b/valkey.sysusers @@ -0,0 +1 @@ +u valkey - "Valkey Database Server" /dev/null /sbin/nologin diff --git a/valkey.tmpfiles b/valkey.tmpfiles new file mode 100644 index 0000000..2c99bad --- /dev/null +++ b/valkey.tmpfiles @@ -0,0 +1,4 @@ +Z /etc/valkey ~0750 valkey root - +D /run/valkey 0755 valkey valkey - +d /var/lib/valkey 0750 valkey valkey - +d /var/log/valkey 0750 valkey valkey -