Initial import

This commit is contained in:
Jitka Plesnikova 2025-05-29 22:29:13 +02:00
parent 49b9467b80
commit 177f361ebf
13 changed files with 427 additions and 0 deletions

1
.fmf/version Normal file
View File

@ -0,0 +1 @@
1

1
.gitignore vendored
View File

@ -0,0 +1 @@
/valkey-8.0.3.tar.gz

1
ci.fmf Normal file
View File

@ -0,0 +1 @@
resultsdb-testcase: separate

7
gating.yaml Normal file
View File

@ -0,0 +1,7 @@
#gating rhel
--- !Policy
product_versions:
- rhel-*
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build./plans/tier1-internal.functional}

2
macros.valkey Normal file
View File

@ -0,0 +1,2 @@
%valkey_modules_abi 1
%valkey_modules_dir %{_libdir}/valkey/modules

View File

@ -0,0 +1,26 @@
#!/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
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
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
# TODO
# 1. expand logic to read current redis conf for the dir setting. same for sentinel conf. if not stock /var/lib/redis, don't do the mv. redis and sentinel may be using two different paths.

10
plans/tier1-internal.fmf Normal file
View File

@ -0,0 +1,10 @@
summary: Internal Tier1 beakerlib tests
discover:
how: fmf
url: https://gitlab.com/redhat/rhel/tests/valkey
filter: "tier:1"
execute:
how: tmt
adjust:
enabled: false
when: distro == centos-stream-9

1
sources Normal file
View File

@ -0,0 +1 @@
SHA512 (valkey-8.0.3.tar.gz) = 3639855d2eced9dd1b38e95e46c515441c850b4fb087c45b2c81a15c5e864555281715fa90b47dc60260485c9469f523f1fac716b3e2114cf7e05c39833e6c96

34
valkey-sentinel.service Normal file
View File

@ -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

9
valkey.logrotate Normal file
View File

@ -0,0 +1,9 @@
/var/log/valkey/*.log {
weekly
rotate 10
copytruncate
delaycompress
compress
notifempty
missingok
}

35
valkey.service Normal file
View File

@ -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

299
valkey.spec Normal file
View File

@ -0,0 +1,299 @@
# Tests fail in mock, not in local build.
%bcond_with tests
Name: valkey
Version: 8.0.3
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
Source8: macros.%{name}
Source9: migrate_redis_to_valkey.sh
BuildRequires: make
BuildRequires: gcc
%if %{with tests}
BuildRequires: procps-ng
BuildRequires: tcl
%endif
BuildRequires: pkgconfig(libsystemd)
BuildRequires: systemd-devel
BuildRequires: systemd-rpm-macros
BuildRequires: openssl-devel
Requires: logrotate
# from deps/hiredis/hiredis.h
Provides: bundled(hiredis) = 1.0.3
# 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/hdr_histogram/README.md
Provides: bundled(hdr_histogram) = 0.11.0
# no version
Provides: bundled(fpconv)
%global valkey_modules_abi 1
%global valkey_modules_dir %{_libdir}/%{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.
%package devel
Summary: Development header for Valkey module development
# Header-Only Library (https://fedoraproject.org/wiki/Packaging:Guidelines)
Provides: %{name}-static = %{version}-%{release}
%description devel
Header file required for building loadable Valkey modules.
%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
%prep
%autosetup -n %{name}-%{version} -p1
mv deps/lua/COPYRIGHT COPYRIGHT-lua
mv deps/jemalloc/COPYING COPYING-jemalloc
mv deps/hiredis/COPYING COPYING-hiredis-BSD-3-Clause
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, the rpmmacros file, and rebuild.
exit 1
fi
sed -i -e 's|^logfile .*$|logfile /var/log/valkey/valkey.log|g' \
-e 's|^# unixsocket .*$|unixsocket /run/valkey/valkey.sock|g' \
-e 's|^pidfile .*$|pidfile /run/valkey/valkey.pid|g' \
valkey.conf
sed -i -e 's|^logfile .*$|logfile /var/log/valkey/sentinel.log|g' \
-e 's|^pidfile .*$|pidfile /run/valkey/sentinel.pid|g' \
sentinel.conf
%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
%make_build %{make_flags}
%install
%make_install %{make_flags}
# remove sample confs
rm -rf %{buildroot}%{_datadir}/%{name}
# System user
install -p -D -m 0644 %{S:4} %{buildroot}%{_sysusersdir}/%{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 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 %{S:8} %{buildroot}%{_rpmmacrodir}/macros.%{name}
# compat script
install -Dpm 755 %{S:9} %{buildroot}%{_libexecdir}/migrate_redis_to_valkey.sh
%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
%pre
%sysusers_create_compat %{S:4}
%post
%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-hiredis-BSD-3-Clause
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%attr(0750, valkey, root) %dir %{_sysconfdir}/%{name}
%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
%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-*
%changelog
* Thu Apr 24 2025 Remi Collet <rcollet@redhat.com> - 8.0.3.1
- rebase to 8.0.3
* Thu Jan 23 2025 Remi Collet <rcollet@redhat.com> - 8.0.2.1
- rebase to 8.0.2
Resolves: RHEL-73273
* Tue Oct 29 2024 Troy Dawson <tdawson@redhat.com> - 7.2.6-2
- Bump release for October 2024 mass rebuild:
Resolves: RHEL-64018
* Tue Aug 6 2024 Remi Collet <rcollet@redhat.com> - 7.2.6.1
- rebase to 7.2.6
- merge limit.conf in main service files
- drop /etc/sysconfig/valkey
- rename compat package
- fix working dir
- partially enable upstream test suite
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 7.2.5-4
- Bump release for June 2024 mass rebuild
* Mon Apr 22 2024 Nathan Scott <nathans@redhat.com> - 7.2.5-3
- remove version_no_tilde code
* Mon Apr 22 2024 Nathan Scott <nathans@redhat.com> - 7.2.5-2
- move redis compat symlinks to compat subpackage
* Wed Apr 17 2024 Jonathan Wright <jonathan@almalinux.org> - 7.2.5-1
- update to 7.2.5 rhbz#2275379
* Fri Apr 12 2024 Jonathan Wright <jonathan@almalinux.org> - 7.2.5~rc1-2
- add compat subpackage with migration scripts from redis
* Fri Apr 12 2024 Jonathan Wright <jonathan@almalinux.org> - 7.2.5~rc1-1
- update to 7.2.5-rc1
* Tue Apr 09 2024 Jonathan Wright <jonathan@almalinux.org> - 7.2.4~rc1-1
- Initial package build, release candidate

1
valkey.sysusers Normal file
View File

@ -0,0 +1 @@
u valkey - "Valkey Database Server" /dev/null /sbin/nologin