From 95ad5c7d590a859de15820809ba7fb3bcac88ea0675dff328b0828c6ca961df4 Mon Sep 17 00:00:00 2001 From: Martin Pluskal Date: Tue, 31 Dec 2019 08:22:02 +0000 Subject: [PATCH] Accepting request 760070 from home:kukuk:ei-demo - Make redis useable in a container (drop size from 100MB to 20MB): - Change user generation from shadow to sysusers - Drop redis-initscript.patch and sudo requires, we use systemd - Drop BuildRequires for procps and tcl, they are not needed - Make logrotate recommend, it's not required for redis to work OBS-URL: https://build.opensuse.org/request/show/760070 OBS-URL: https://build.opensuse.org/package/show/server:database/redis?expand=0&rev=129 --- redis-initscript.patch | 176 ----------------------------------------- redis-user.conf | 2 + redis.changes | 9 +++ redis.spec | 36 ++++----- 4 files changed, 28 insertions(+), 195 deletions(-) delete mode 100644 redis-initscript.patch create mode 100644 redis-user.conf diff --git a/redis-initscript.patch b/redis-initscript.patch deleted file mode 100644 index 3c9e0e5..0000000 --- a/redis-initscript.patch +++ /dev/null @@ -1,176 +0,0 @@ -Index: utils/redis_init_script -=================================================================== ---- utils/redis_init_script.orig -+++ utils/redis_init_script -@@ -1,50 +1,133 @@ - #!/bin/sh --# --# Simple Redis init.d script conceived to work on Linux systems --# as it does use of the /proc filesystem. - -+# System startup script for Redis for OpenSUSE >= 11.4 -+# -+# Author: Marcello Barnaba -+# Tue Jul 31 17:32:27 CEST 2012 -+# -+# LSB-compatible service control script; see http://www.linuxbase.org/spec/ -+# Install it in /etc/init.d/redis and run insserv /etc/init.d/redis -+# Define configurations in /etc/init.d/redis/NAME.conf -+# -+# Source: https://gist.github.com/804026 -+# - ### BEGIN INIT INFO --# Provides: redis_6379 --# Default-Start: 2 3 4 5 --# Default-Stop: 0 1 6 --# Short-Description: Redis data structure server --# Description: Redis data structure server. See https://redis.io -+# Provides: redis -+# Required-Start: $syslog $remote_fs -+# Required-Stop: $syslog $remote_fs -+# Default-Start: 3 5 -+# Default-Stop: 0 1 2 6 -+# Short-Description: Redis server -+# Description: Starts and stops the configured Redis instances - ### END INIT INFO - --REDISPORT=6379 --EXEC=/usr/local/bin/redis-server --CLIEXEC=/usr/local/bin/redis-cli -+EXEC=/usr/sbin/redis-server -+USER=redis -+STATE=/var/run/redis -+CONF=/etc/redis -+ -+. /etc/rc.status -+ -+if [ ! -d $STATE ]; then -+ install -d $state -o $USER -g $USER -m 0755 $STATE -+fi -+ -+_get_env() { -+ INSTANCE=$1 -+ PIDFILE=${STATE}/${INSTANCE}.pid -+ CONFIG=${CONF}/${INSTANCE}.conf -+} -+ -+_foreach_config() { -+ command=$1 -+ -+ if [ -n "$2" ]; then -+ $command $2 -+ else -+ for file in /etc/redis/*.conf; do -+ $command `basename "$file" .conf` -+ done -+ fi -+} -+ -+start() { -+ _get_env $1 -+ -+ echo -n "Starting Redis server '${INSTANCE}'... " -+ -+ if [ ! -f ${CONFIG} ]; then -+ echo "$CONFIG not found" -+ rc_failed -+ -+ elif [ -f ${PIDFILE} ] && [ -x /proc/`cat ${PIDFILE}` ]; then -+ echo -n "already running (PID `cat ${PIDFILE}`)" -+ -+ else -+ rm -f ${PIDFILE} -+ sudo -u $USER $EXEC $CONFIG -+ fi -+ rc_status -v -+} -+ -+stop() { -+ _get_env $1 -+ -+ echo -n "Stopping Redis server '${INSTANCE}' ... " -+ -+ if [ ! -f $PIDFILE ]; then -+ echo -n "not running" -+ else -+ PID=`cat $PIDFILE` -+ CLI='/usr/bin/redis-cli' -+ PASS=`grep ^requirepass $CONFIG | awk '{print $2}'` -+ PORT=`grep ^port $CONFIG | awk '{print $2}'` -+ BIND=`grep ^bind $CONFIG | awk '{print $2}'` -+ -+ CLI="$CLI -p $PORT" -+ [ -n "$PASS" ] && CLI="$CLI -a $PASS" -+ [ -n "$BIND" ] && CLI="$CLI -h $BIND" -+ -+ $CLI shutdown -+ echo -n "Waiting... " -+ -+ while [ -x /proc/${PID} ]; do -+ sleep 1 -+ echo -n '.' -+ done -+ rm -f ${PIDFILE} -+ fi -+ rc_status -v -+} -+ -+status() { -+ _get_env $1 -+ -+ echo -n "Checking for redis '${INSTANCE}'" -+ /sbin/checkproc -p $PIDFILE $EXEC -+ rc_status -v -+} - --PIDFILE=/var/run/redis_${REDISPORT}.pid --CONF="/etc/redis/${REDISPORT}.conf" - - case "$1" in - start) -- if [ -f $PIDFILE ] -- then -- echo "$PIDFILE exists, process is already running or crashed" -- else -- echo "Starting Redis server..." -- $EXEC $CONF -- fi -- ;; -+ _foreach_config start $2 -+ ;; -+ - stop) -- if [ ! -f $PIDFILE ] -- then -- echo "$PIDFILE does not exist, process is not running" -- else -- PID=$(cat $PIDFILE) -- echo "Stopping ..." -- $CLIEXEC -p $REDISPORT shutdown -- while [ -x /proc/${PID} ] -- do -- echo "Waiting for Redis to shutdown ..." -- sleep 1 -- done -- echo "Redis stopped" -- fi -- ;; -+ _foreach_config stop $2 -+ ;; -+ -+ status) -+ _foreach_config status $2 -+ ;; -+ -+ restart) -+ $0 stop $2 -+ $0 start $2 -+ ;; -+ - *) -- echo "Please use start or stop as first argument" -- ;; -+ echo "Usage: $0 " -+ exit 1 -+ ;; - esac diff --git a/redis-user.conf b/redis-user.conf new file mode 100644 index 0000000..d84f317 --- /dev/null +++ b/redis-user.conf @@ -0,0 +1,2 @@ +# Type Name ID GECOS [HOME] +u redis - "User for redis key-value store" /var/lib/redis diff --git a/redis.changes b/redis.changes index 30df1fd..25e2f78 100644 --- a/redis.changes +++ b/redis.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Mon Dec 30 17:59:52 UTC 2019 - Thorsten Kukuk + +- Make redis useable in a container (drop size from 100MB to 20MB): + - Change user generation from shadow to sysusers + - Drop redis-initscript.patch and sudo requires, we use systemd + - Drop BuildRequires for procps and tcl, they are not needed + - Make logrotate recommend, it's not required for redis to work + ------------------------------------------------------------------- Sun Dec 1 15:47:06 UTC 2019 - Илья Индиго diff --git a/redis.spec b/redis.spec index e785d00..eacae31 100644 --- a/redis.spec +++ b/redis.spec @@ -35,20 +35,18 @@ Source5: README.SUSE Source6: %{name}.sysctl Source7: %{name}-sentinel@.service Source8: %{name}-sentinel.target -# PATCH-FIX-OPENSUSE -- openSUSE-style init script -Patch0: %{name}-initscript.patch +Source9: %{name}-user.conf # PATCH-MISSING-TAG -- See https://wiki.opensuse.org/openSUSE:Packaging_Patches_guidelines -Patch1: %{name}-conf.patch -Patch2: %{name}-enable-bactrace-on-x86-ia64-and_arm32_only.patch -Patch3: %{name}-disable_integration_logging.patch -Patch4: reproducible.patch +Patch0: %{name}-conf.patch +Patch1: %{name}-enable-bactrace-on-x86-ia64-and_arm32_only.patch +Patch2: %{name}-disable_integration_logging.patch +Patch3: reproducible.patch BuildRequires: pkgconfig -BuildRequires: procps -BuildRequires: tcl +BuildRequires: sysuser-shadow +BuildRequires: sysuser-tools BuildRequires: pkgconfig(systemd) -Requires: logrotate -Requires: sudo -Requires(pre): shadow +Recommends: logrotate +%sysusers_requires %description %{name} is an advanced key-value store. It is similar to memcached but the dataset @@ -62,16 +60,16 @@ different kind of sorting abilities. %setup -q %patch0 %patch1 -%patch2 %ifnarch %{ix86} x86_64 ia64 %{arm} # We have no backtrace, so disable logging test -%patch3 +%patch2 %endif -%patch4 -p1 +%patch3 -p1 %build export HOST=OBS # for reproducible builds make %{?_smp_mflags} CFLAGS="%{optflags}" V=1 +%sysusers_generate_pre %{SOURCE9} redis %install install -m 0750 -d \ @@ -110,6 +108,9 @@ install -Dm 0644 %{SOURCE8} %{buildroot}%{_unitdir}/%{name}-sentinel.target ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name} cp %{SOURCE5} README.SUSE +mkdir -p %{buildroot}%{_sysusersdir} +install -m 644 %{SOURCE9} %{buildroot}%{_sysusersdir}/ + %check %ifnarch ppc ppc64 cat </dev/null || %{_sbindir}/groupadd -r %{name} || : -getent passwd %{name} >/dev/null || \ - %{_sbindir}/useradd -g %{name} -s /bin/false -r \ - -c "User for %{name} key-value store" -d %{_data_dir} %{name} || : +%pre -f redis.pre %service_add_pre redis.target redis@.service redis-sentinel.target redis-sentinel@.service %post @@ -148,6 +145,7 @@ echo "See %{_docdir}/%{name}/README.SUSE to continue" %{_sbindir}/%{name}-* %{_sbindir}/rc%{name} %{_libexecdir}/tmpfiles.d/%{name}.conf +%{_sysusersdir}/redis-user.conf %{_unitdir}/%{name}@.service %{_unitdir}/%{name}.target %{_unitdir}/%{name}-sentinel@.service