summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--memcached.service12
-rw-r--r--memcached.spec173
-rwxr-xr-xmemcached.sysv10
-rwxr-xr-xmemcached.sysvel490
4 files changed, 173 insertions, 112 deletions
diff --git a/memcached.service b/memcached.service
new file mode 100644
index 0000000..ee5198d
--- /dev/null
+++ b/memcached.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Memcached
+Before=httpd.service
+After=network.target
+
+[Service]
+Type=simple
+EnvironmentFile=-/etc/sysconfig/memcached
+ExecStart=/usr/bin/memcached -u $USER -p $PORT -m $CACHESIZE -c $MAXCONN $OPTIONS
+
+[Install]
+WantedBy=multi-user.target
diff --git a/memcached.spec b/memcached.spec
index 3a460c2..89381c3 100644
--- a/memcached.spec
+++ b/memcached.spec
@@ -1,10 +1,16 @@
%global username memcached
%global groupname memcached
+%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7
+%global with_systemd 1
+%else
+%global with_systemd 0
+%endif
+
Name: memcached
-Version: 1.4.5
-Release: 2%{?dist}.1
-Epoch: 0
+Version: 1.4.15
+Release: 1%{?dist}
+Epoch: 0
Summary: High Performance, Distributed Memory Object Cache
Group: System Environment/Daemons
@@ -12,23 +18,35 @@ License: BSD
URL: http://www.memcached.org/
Source0: http://memcached.googlecode.com/files/%{name}-%{version}.tar.gz
+# custom unit file
+Source1: memcached.service
# custom init script
-Source1: memcached.sysv
-Source2: memcached.sysvel4
+Source2: memcached.sysv
+
+# Patches
# Fixes
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: libevent-devel
-BuildRequires: perl(Test::More)
-
+BuildRequires: perl(Test::More), perl(Test::Harness)
+
+%if %{with_systemd}
+Requires(post): systemd
+Requires(preun): systemd
+Requires(postun): systemd
+# For triggerun
+Requires(post): systemd-sysv
+%else
Requires: initscripts
Requires: libevent
-Requires(pre): shadow-utils
Requires(post): /sbin/chkconfig
Requires(preun): /sbin/chkconfig, /sbin/service
Requires(postun): /sbin/service
+%endif
+Requires(pre): shadow-utils
+
# as of 3.5.5-4 selinux has memcache included
Obsoletes: memcached-selinux
@@ -38,6 +56,7 @@ memcached is a high-performance, distributed memory object caching
system, generic in nature, but intended for use in speeding up dynamic
web applications by alleviating database load.
+
%package devel
Summary: Files needed for development using memcached protocol
Group: Development/Libraries
@@ -47,41 +66,49 @@ Requires: %{name} = %{epoch}:%{version}-%{release}
Install memcached-devel if you are developing C/C++ applications that require access to the
memcached binary include files.
+
%prep
%setup -q
+
%build
%configure
-
+sed -i 's/-Werror/ /' Makefile
make %{?_smp_mflags}
%check
+# whitespace tests fail locally on fedpkg systems now that they use git
+rm -f t/whitespace.t
+
# Parts of the test suite only succeed as non-root.
if [ `id -u` -ne 0 ]; then
# remove failing test that doesn't work in
# build systems
- rm -f t/daemonize.t
- make test
+ rm -f t/daemonize.t
fi
+make test
+
%install
rm -rf %{buildroot}
-make install DESTDIR=%{buildroot} INSTALL="%{__install} -p"
+make install DESTDIR=%{buildroot} INSTALL="%{__install} -p"
# remove memcached-debug
rm -f %{buildroot}/%{_bindir}/memcached-debug
# Perl script for monitoring memcached
install -Dp -m0755 scripts/memcached-tool %{buildroot}%{_bindir}/memcached-tool
+%if %{with_systemd}
+# Unit file
+install -Dp -m0644 %{SOURCE1} %{buildroot}%{_unitdir}/memcached.service
+%else
# Init script
-%if 0%{?rhel} == 4
install -Dp -m0755 %{SOURCE2} %{buildroot}%{_initrddir}/memcached
-%else
-install -Dp -m0755 %{SOURCE1} %{buildroot}%{_initrddir}/memcached
-%endif
# pid directory
mkdir -p %{buildroot}/%{_localstatedir}/run/memcached
+%endif
+
# Default configs
mkdir -p %{buildroot}/%{_sysconfdir}/sysconfig
@@ -96,6 +123,7 @@ EOF
# Constant timestamp on the config file.
touch -r %{SOURCE1} %{buildroot}/%{_sysconfdir}/sysconfig/%{name}
+
%clean
rm -rf %{buildroot}
@@ -103,45 +131,152 @@ rm -rf %{buildroot}
%pre
getent group %{groupname} >/dev/null || groupadd -r %{groupname}
getent passwd %{username} >/dev/null || \
+%if %{with_systemd}
+useradd -r -g %{groupname} -d /run/memcached \
+%else
useradd -r -g %{groupname} -d %{_localstatedir}/run/memcached \
+%endif
-s /sbin/nologin -c "Memcached daemon" %{username}
exit 0
%post
-/sbin/chkconfig --add %{name}
+%if 0%{?systemd_post:1}
+%systemd_post %{name}.service
+%else
+if [ $1 = 1 ]; then
+ # Initial installation
+%if %{with_systemd}
+ /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+%else
+ /sbin/chkconfig --add %{name}
+%endif
+fi
+%endif
%preun
+%if 0%{?systemd_preun:1}
+%systemd_preun %{name}.service
+%else
if [ "$1" = 0 ] ; then
+ # Package removal, not upgrade
+%if %{with_systemd}
+ /bin/systemctl --no-reload disable %{name}.service >/dev/null 2>&1 || :
+ /bin/systemctl stop %{name}.service >/dev/null 2>&1 || :
+%else
/sbin/service %{name} stop > /dev/null 2>&1
/sbin/chkconfig --del %{name}
+%endif
fi
exit 0
+%endif
%postun
+%if 0%{?systemd_postun_with_restart:1}
+%systemd_postun_with_restart %{name}.service
+%else
+%if %{with_systemd}
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ]; then
+ # Package upgrade, not uninstall
+ /bin/systemctl try-restart %{name}.service >/dev/null 2>&1 || :
+fi
+%else
if [ "$1" -ge 1 ]; then
/sbin/service %{name} condrestart > /dev/null 2>&1
fi
exit 0
+%endif
+%endif
+
+%triggerun -- memcached
+%if %{with_systemd}
+if [ -f /etc/rc.d/init.d/memcached ]; then
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply memcached
+# to migrate them to systemd targets
+/usr/bin/systemd-sysv-convert --save memcached >/dev/null 2>&1 ||:
+
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del memcached >/dev/null 2>&1 || :
+/bin/systemctl try-restart memcached.service >/dev/null 2>&1 || :
+fi
+%endif
%files
%defattr(-,root,root,-)
-%doc AUTHORS ChangeLog COPYING NEWS README doc/CONTRIBUTORS doc/*.txt
+%doc AUTHORS ChangeLog COPYING NEWS README.md doc/CONTRIBUTORS doc/*.txt
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
-%dir %attr(755,%{username},%{groupname}) %{_localstatedir}/run/memcached
%{_bindir}/memcached-tool
%{_bindir}/memcached
%{_mandir}/man1/memcached.1*
+%if %{with_systemd}
+%{_unitdir}/memcached.service
+%else
%{_initrddir}/memcached
+%dir %attr(755,%{username},%{groupname}) %{_localstatedir}/run/memcached
+%endif
+
%files devel
%defattr(-,root,root,0755)
%{_includedir}/memcached/*
%changelog
+* Mon Nov 26 2012 Remi Collet <rpms@famillecollet.com> - 0:1.4.15-1
+- sync with rawhide, backport for remi repo
+
+* Tue Nov 20 2012 Joe Orton <jorton@redhat.com> - 0:1.4.15-2
+- BR perl(Test::Harness)
+
+* Tue Nov 20 2012 Joe Orton <jorton@redhat.com> - 0:1.4.15-1
+- update to 1.4.15 (#782395)
+- switch to simple systemd service (#878198)
+- use systemd scriptlet macros (Václav Pavlín, #850204)
+
+* Fri Jul 20 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0:1.4.13-3
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
+
+* Fri May 04 2012 Jon Ciesla <limburgher@gmail.com> - 0:1.4.13-2
+- Migrate to systemd, 783112.
+
+* Tue Feb 7 2012 Paul Lindner <lindner@mirth.inuus.com> - 0:1.4.13-1
+- Upgrade to memcached 1.4.13
+- http://code.google.com/p/memcached/wiki/ReleaseNotes1413
+- http://code.google.com/p/memcached/wiki/ReleaseNotes1412
+- http://code.google.com/p/memcached/wiki/ReleaseNotes1411
+
+* Fri Jan 13 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0:1.4.10-2
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
+
+* Wed Nov 9 2011 Paul Lindner <lindner@mirth.inuus.com> - 0:1.4.10-1
+- Upgrade to memcached 1.4.10 (http://code.google.com/p/memcached/wiki/ReleaseNotes1410)
+
+* Tue Aug 16 2011 Paul Lindner <lindner@inuus.com> - 0:1.4.7-1
+- Upgrade to memcached 1.4.7 (http://code.google.com/p/memcached/wiki/ReleaseNotes147)
+- Fix some rpmlint errors/warnings.
+
+* Tue Aug 2 2011 Paul Lindner <lindner@inuus.com> - 0:1.4.6-1
+- Upgrade to memcached-1.4.6
+
+* Wed Feb 16 2011 Joe Orton <jorton@redhat.com> - 0:1.4.5-7
+- fix build
+
+* Mon Feb 14 2011 Paul Lindner <lindner@inuus.com> - 0:1.4.5-6
+- Rebuild for updated libevent
+
+* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0:1.4.5-5
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
+
+* Sun Nov 28 2010 Paul Lindner <lindner@inuus.com> - 0:1.4.5-4
+- Add code to deal with /var/run/memcached on tmpfs
+
+* Wed Sep 8 2010 Paul Lindner <lindner@inuus.com> - 0:1.4.5-3
+- Apply patch from memcached issue #60, solves Bugzilla 631051
+
* Tue Jun 15 2010 Remi Collet <rpms@famillecollet.com> - 1.4.5-2.el4.1
- also use /var/run/memcached/memcached.pid on EL-4
diff --git a/memcached.sysv b/memcached.sysv
index 62ac51f..19e5a12 100755
--- a/memcached.sysv
+++ b/memcached.sysv
@@ -37,9 +37,13 @@ lockfile=${LOCKFILE-/var/lock/subsys/memcached}
start () {
echo -n $"Starting $prog: "
- # Ensure that /var/run/memcached has proper permissions
- if [ "`stat -c %U /var/run/memcached`" != "$USER" ]; then
- chown $USER /var/run/memcached
+ # Ensure that $pidfile directory has proper permissions and exists
+ piddir=`dirname $pidfile`
+ if [ ! -d $piddir ]; then
+ mkdir $piddir
+ fi
+ if [ "`stat -c %U $piddir`" != "$USER" ]; then
+ chown $USER $piddir
fi
daemon --pidfile ${pidfile} memcached -d -p $PORT -u $USER -m $CACHESIZE -c $MAXCONN -P ${pidfile} $OPTIONS
diff --git a/memcached.sysvel4 b/memcached.sysvel4
deleted file mode 100755
index fd606a0..0000000
--- a/memcached.sysvel4
+++ /dev/null
@@ -1,90 +0,0 @@
-#! /bin/sh
-#
-# chkconfig: - 55 45
-# description: The memcached daemon is a network memory cache service.
-# processname: memcached
-# config: /etc/sysconfig/memcached
-# pidfile: /var/run/memcached/memcached.pid
-
-# Standard LSB functions
-#. /lib/lsb/init-functions
-
-# Source function library.
-. /etc/init.d/functions
-
-PORT=11211
-USER=memcached
-MAXCONN=1024
-CACHESIZE=64
-OPTIONS=""
-
-if [ -f /etc/sysconfig/memcached ];then
- . /etc/sysconfig/memcached
-fi
-
-# Check that networking is up.
-. /etc/sysconfig/network
-
-if [ "$NETWORKING" = "no" ]
-then
- exit 0
-fi
-
-RETVAL=0
-prog="memcached"
-pidfile=${PIDFILE-/var/run/memcached/memcached.pid}
-lockfile=${LOCKFILE-/var/lock/subsys/memcached}
-
-start () {
- echo -n $"Starting $prog: "
- # Ensure that /var/run/memcached has proper permissions
- if [ "`stat -c %U /var/run/memcached`" != "$USER" ]; then
- chown $USER /var/run/memcached
- fi
-
- daemon memcached -d -p $PORT -u $USER -m $CACHESIZE -c $MAXCONN -P ${pidfile} $OPTIONS
- RETVAL=$?
- echo
- [ $RETVAL -eq 0 ] && touch ${lockfile}
-}
-stop () {
- echo -n $"Stopping $prog: "
- killproc /usr/bin/memcached
- RETVAL=$?
- echo
- if [ $RETVAL -eq 0 ] ; then
- rm -f ${lockfile} ${pidfile}
- fi
-}
-
-restart () {
- stop
- start
-}
-
-
-# See how we were called.
-case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- status)
- status memcached
- RETVAL=$?
- ;;
- restart|reload|force-reload)
- restart
- ;;
- condrestart|try-restart)
- [ -f ${lockfile} ] && restart || :
- ;;
- *)
- echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart|try-restart}"
- RETVAL=2
- ;;
-esac
-
-exit $RETVAL