You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
216 lines
7.4 KiB
216 lines
7.4 KiB
## |
|
## redis.spec -- OpenPKG RPM Package Specification |
|
## Copyright (c) 2000-2021 OpenPKG Project <http://openpkg.org/> |
|
## |
|
## Permission to use, copy, modify, and distribute this software for |
|
## any purpose with or without fee is hereby granted, provided that |
|
## the above copyright notice and this permission notice appear in all |
|
## copies. |
|
## |
|
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
|
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR |
|
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
|
## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
|
## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
|
## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
|
## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
## SUCH DAMAGE. |
|
## |
|
|
|
# package version |
|
%define V_opkg 6.2.6 |
|
%define V_dist 6.2.6 |
|
|
|
# package information |
|
Name: redis |
|
Summary: Persistent Key-Value Database |
|
URL: http://redis.io/ |
|
Vendor: Salvatore Sanfilippo |
|
Packager: OpenPKG Project |
|
Distribution: OpenPKG Community |
|
Class: PLUS |
|
Group: Database |
|
License: BSD |
|
Version: %{V_opkg} |
|
Release: 20211004 |
|
|
|
# package options |
|
%option with_cluster no |
|
%option with_tls no |
|
|
|
# list of sources |
|
Source0: http://download.redis.io/releases/redis-%{V_dist}.tar.gz |
|
Source1: rc.redis |
|
Source2: redis.conf |
|
Source3: redis.master.conf |
|
Source4: redis.slave.conf |
|
Source5: redis-tls.conf |
|
Source6: redis-tls.sh |
|
Patch0: redis.patch |
|
|
|
# build information |
|
BuildPreReq: OpenPKG, openpkg >= 20160101 |
|
PreReq: OpenPKG, openpkg >= 20160101 |
|
%if "%{with_cluster}" == "yes" |
|
PreReq: ruby |
|
PreReq: redis-libs |
|
PreReq: redis-libs::with_ruby = yes |
|
%endif |
|
%if "%{with_tls}" == "yes" |
|
PreReq: stunnel |
|
%endif |
|
|
|
%description |
|
Redis 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 |
|
this data types can be manipulated with atomic operations to |
|
push/pop elements, add/remove elements, perform server side union, |
|
intersection, difference between sets, and so forth. Redis supports |
|
different kind of sorting abilities. |
|
|
|
%track |
|
prog redis = { |
|
version = %{V_dist} |
|
url = http://redis.io/download |
|
regex = redis-(\d+\.\d+\.\d+)\.tar\.gz |
|
} |
|
|
|
%prep |
|
%setup -q -n redis-%{V_dist} |
|
%patch -p0 |
|
|
|
%build |
|
# build program |
|
%{l_shtool} subst \ |
|
-e 's;/var/run/redis\.pid;%{l_prefix}/var/redis/run/redis.pid;' \ |
|
src/server.h |
|
%{l_make} %{l_mflags -O} \ |
|
CC="%{l_cc} %{l_cflags -O}" \ |
|
DEBUG="" |
|
|
|
%install |
|
# create installation directories |
|
%{l_shtool} mkdir -f -p -m 755 \ |
|
$RPM_BUILD_ROOT%{l_prefix}/bin \ |
|
$RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \ |
|
$RPM_BUILD_ROOT%{l_prefix}/etc/redis \ |
|
$RPM_BUILD_ROOT%{l_prefix}/var/redis/run \ |
|
$RPM_BUILD_ROOT%{l_prefix}/var/redis/log \ |
|
$RPM_BUILD_ROOT%{l_prefix}/var/redis/db |
|
|
|
# install programs |
|
%{l_shtool} install -c -s -m 755 \ |
|
src/redis-server \ |
|
src/redis-cli \ |
|
src/redis-benchmark \ |
|
src/redis-sentinel \ |
|
src/redis-check-aof \ |
|
src/redis-check-rdb \ |
|
$RPM_BUILD_ROOT%{l_prefix}/bin/ |
|
%if "%{with_cluster}" == "yes" |
|
%{l_shtool} install -c -m 755 \ |
|
-e 's;/usr/bin/env ruby;%{l_prefix}/bin/ruby;g' \ |
|
src/redis-trib.rb $RPM_BUILD_ROOT%{l_prefix}/bin/redis-trib |
|
%endif |
|
|
|
# install run-command script |
|
%if "%{with_cluster}" == "yes" |
|
cluster=yes |
|
%else |
|
cluster=no |
|
%endif |
|
%if "%{with_tls}" == "yes" |
|
tls=yes |
|
%else |
|
tls=no |
|
%endif |
|
%{l_shtool} install -c -m 755 %{l_value -s -a} \ |
|
-e "s;@cluster@;$cluster;g" \ |
|
-e "s;@tls@;$tls;g" \ |
|
%{SOURCE rc.redis} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ |
|
|
|
# install default configuration |
|
%if "%{with_cluster}" == "yes" |
|
%{l_shtool} install -c -m 644 %{l_value -s -a} \ |
|
%{SOURCE redis.master.conf} \ |
|
%{SOURCE redis.slave.conf} \ |
|
$RPM_BUILD_ROOT%{l_prefix}/etc/redis/ |
|
%{l_shtool} mkdir -f -p -m 755 \ |
|
$RPM_BUILD_ROOT%{l_prefix}/var/redis/db/master \ |
|
$RPM_BUILD_ROOT%{l_prefix}/var/redis/db/slave |
|
%else |
|
%{l_shtool} install -c -m 644 %{l_value -s -a} \ |
|
%{SOURCE redis.conf} $RPM_BUILD_ROOT%{l_prefix}/etc/redis/ |
|
%endif |
|
%if "%{with_tls}" == "yes" |
|
%{l_shtool} install -c -m 644 %{l_value -s -a} \ |
|
%{SOURCE redis-tls.conf} $RPM_BUILD_ROOT%{l_prefix}/etc/redis/ |
|
%{l_shtool} install -c -m 644 %{l_value -s -a} \ |
|
%{SOURCE redis-tls.sh} $RPM_BUILD_ROOT%{l_prefix}/etc/redis/ |
|
%endif |
|
|
|
# determine installation files |
|
%{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \ |
|
%{l_files_std} \ |
|
'%config %{l_prefix}/etc/redis/*' \ |
|
%if "%{with_cluster}" == "yes" |
|
'%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/redis/*/*' \ |
|
%endif |
|
'%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/redis/*' |
|
|
|
%files -f files |
|
|
|
%clean |
|
|
|
%post |
|
%if "%{with_tls}" == "yes" |
|
if [ $1 -eq 1 ]; then |
|
# on initial installation, generate initial credentials |
|
echo "Generate initial TLS credentials..." | \ |
|
%{l_rpmtool} msg -b -t notice |
|
( cd $RPM_INSTALL_PREFIX/etc/redis && %{l_bash} redis-tls.sh ) || exit $? |
|
fi |
|
%endif |
|
%if "%{with_cluster}" == "yes" |
|
if [ $1 -eq 1 ]; then |
|
# display information about next steps |
|
( echo "For setting up the Redis cluster of N machines (N >= 3)," |
|
echo "start Redis on all nodes and then perform the following command" |
|
echo "on one of the nodes:" |
|
echo " \$ $RPM_INSTALL_PREFIX/bin/redis-trib create\\%{l_nil}" |
|
echo " --replicas 1 \\%{l_nil}" |
|
echo " <node1>:6379 <node2>:6379 ... <nodeN>:6379 \\%{l_nil}" |
|
echo " <node2>:3680 ... <nodeN>:3680 <node1>:3680" |
|
echo "The current nodes in the Redis cluster can then be checked with:" |
|
echo " \$ $RPM_INSTALL_PREFIX/bin/redis-cli cluster nodes" |
|
echo "Notice: on each node, two Redis servers are started: one in master" |
|
echo "mode, the other in slave mode. This is because a single Redis" |
|
echo "instance can be just in one of the two possible modes per time." |
|
echo "With this and the above redis-trib(8) schema you get N servers" |
|
echo "which effectively act in a master/master fashion and where 1" |
|
echo "server at maximum can break at an time." |
|
) | %{l_rpmtool} msg -b -t notice |
|
fi |
|
%endif |
|
if [ $1 -eq 2 ]; then |
|
# after upgrade, restart service |
|
eval `%{l_rc} redis status 2>/dev/null` |
|
[ ".$redis_active" = .yes ] && %{l_rc} redis restart |
|
fi |
|
exit 0 |
|
|
|
%preun |
|
if [ $1 -eq 0 ]; then |
|
# before erase, stop service and remove log files |
|
%{l_rc} redis stop 2>/dev/null |
|
rm -f $RPM_INSTALL_PREFIX/var/redis/run/* >/dev/null 2>&1 || true |
|
rm -f $RPM_INSTALL_PREFIX/var/redis/log/* >/dev/null 2>&1 || true |
|
rm -rf $RPM_INSTALL_PREFIX/var/redis/db/* >/dev/null 2>&1 || true |
|
fi |
|
exit 0 |
|
|
|
|