55b1212
%define selinux_variants mls strict targeted 
55b1212
%define selinux_policyver %(sed -e 's,.*selinux-policy-\\([^/]*\\)/.*,\\1,' /usr/share/selinux/devel/policyhelp)
55b1212
%define modulename memcached
55b1212
55b1212
%define username   memcached
55b1212
%define groupname  memcached
55b1212
618683d
Name:           memcached
76248e2
Version:        1.4.2
f6f5f83
Release:        1%{?dist}
618683d
Summary:        High Performance, Distributed Memory Object Cache
618683d
618683d
Group:          System Environment/Daemons
618683d
License:        BSD
618683d
URL:            http://www.danga.com/memcached/
618683d
Source0:        http://www.danga.com/memcached/dist/%{name}-%{version}.tar.gz
618683d
618683d
# custom init script
618683d
Source1:        memcached.sysv
618683d
55b1212
# SELinux files
55b1212
Source10:       %{modulename}.te
55b1212
Source11:       %{modulename}.fc
55b1212
Source12:       %{modulename}.if
55b1212
97b23d0
# Fixes
97b23d0
618683d
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
618683d
618683d
BuildRequires:  libevent-devel
618683d
BuildRequires:  perl(Test::More)
55b1212
4e7d0fa
Requires: initscripts
4e7d0fa
Requires: libevent
55b1212
Requires(pre):  shadow-utils
618683d
Requires(post): /sbin/chkconfig
618683d
Requires(preun): /sbin/chkconfig, /sbin/service
618683d
Requires(postun): /sbin/service
618683d
618683d
%description
618683d
memcached is a high-performance, distributed memory object caching
618683d
system, generic in nature, but intended for use in speeding up dynamic
618683d
web applications by alleviating database load.
618683d
55b1212
55b1212
%package selinux
55b1212
Summary:        SELinux policy module supporting memcached
55b1212
Group:          System Environment/Base
55b1212
BuildRequires:  checkpolicy, selinux-policy-devel, hardlink
55b1212
%if "%{selinux_policyver}" != ""
55b1212
Requires:       selinux-policy >= %{selinux_policyver}
55b1212
%endif
55b1212
Requires:       %{name} = %{version}-%{release}
55b1212
Requires(post):  policycoreutils
55b1212
Requires(postun): policycoreutils
55b1212
91094ee
55b1212
%description selinux
55b1212
SELinux policy module supporting memcached.
55b1212
91094ee
%package devel
91094ee
Summary:	Files needed for development using memcached protocol
91094ee
Group:		Development/Libraries 
91094ee
91094ee
%description devel
91094ee
Install memcached-devel if you are developing C/C++ applications that require access to the
91094ee
memcached binary include files.
55b1212
618683d
%prep
618683d
%setup -q
55b1212
mkdir SELinux
55b1212
cp -p %{SOURCE10} %{SOURCE11} %{SOURCE12} SELinux/
618683d
618683d
618683d
%build
618683d
%configure --enable-threads
618683d
618683d
make %{?_smp_mflags}
618683d
55b1212
pushd SELinux
55b1212
for selinuxvariant in %{selinux_variants}; do
55b1212
    make NAME=${selinuxvariant} -f /usr/share/selinux/devel/Makefile
55b1212
    mv %{modulename}.pp %{modulename}.pp.${selinuxvariant}
55b1212
    make NAME=${selinuxvariant} -f /usr/share/selinux/devel/Makefile clean
55b1212
done
55b1212
popd
55b1212
80d6042
618683d
%check
f858079
# remove failing test that doesn't work in
f858079
# build systems
f858079
rm -f t/daemonize.t 
618683d
make test
618683d
618683d
%install
618683d
rm -rf %{buildroot}
618683d
make install DESTDIR=%{buildroot} INSTALL="%{__install} -p"                                         
618683d
# remove memcached-debug
618683d
rm -f %{buildroot}/%{_bindir}/memcached-debug
618683d
618683d
# Perl script for monitoring memcached
618683d
install -Dp -m0755 scripts/memcached-tool %{buildroot}%{_bindir}/memcached-tool
618683d
618683d
# Init script
618683d
install -Dp -m0755 %{SOURCE1} %{buildroot}%{_initrddir}/memcached
618683d
618683d
# Default configs
618683d
mkdir -p %{buildroot}/%{_sysconfdir}/sysconfig
618683d
cat <<EOF >%{buildroot}/%{_sysconfdir}/sysconfig/%{name}
618683d
PORT="11211"
55b1212
USER="%{username}"
618683d
MAXCONN="1024"
618683d
CACHESIZE="64"
618683d
OPTIONS=""
618683d
EOF
618683d
618683d
# pid directory
618683d
mkdir -p %{buildroot}/%{_localstatedir}/run/memcached
618683d
55b1212
# Install SELinux policy modules
55b1212
pushd SELinux
55b1212
for selinuxvariant in %{selinux_variants}; do
55b1212
    install -d %{buildroot}%{_datadir}/selinux/${selinuxvariant}
55b1212
    install -p -m 644 %{modulename}.pp.${selinuxvariant} \
55b1212
        %{buildroot}%{_datadir}/selinux/${selinuxvariant}/%{modulename}.pp
55b1212
done
55b1212
popd
55b1212
55b1212
# Hardlink identical policy module packages together
55b1212
/usr/sbin/hardlink -cv %{buildroot}%{_datadir}/selinux
55b1212
55b1212
618683d
%clean
618683d
rm -rf %{buildroot}
618683d
618683d
55b1212
%pre
55b1212
getent group %{groupname} >/dev/null || groupadd -r %{groupname}
55b1212
getent passwd %{username} >/dev/null || \
55b1212
useradd -r -g %{groupname} -d %{_localstatedir}/run/memcached \
55b1212
    -s /sbin/nologin -c "Memcached daemon" %{username}
55b1212
exit 0
55b1212
55b1212
618683d
%post
618683d
/sbin/chkconfig --add %{name}
618683d
55b1212
618683d
%preun
618683d
if [ "$1" = 0 ] ; then
618683d
    /sbin/service %{name} stop > /dev/null 2>&1
618683d
    /sbin/chkconfig --del %{name}
618683d
fi
618683d
exit 0
618683d
55b1212
618683d
%postun
618683d
if [ "$1" -ge 1 ]; then
618683d
    /sbin/service %{name} condrestart > /dev/null 2>&1
618683d
fi
618683d
exit 0
618683d
618683d
55b1212
%post selinux
55b1212
# Install SELinux policy modules
55b1212
for selinuxvariant in %{selinux_variants}
55b1212
do
55b1212
  /usr/sbin/semodule -s ${selinuxvariant} -i \
55b1212
    %{_datadir}/selinux/${selinuxvariant}/%{modulename}.pp &> /dev/null || :
55b1212
done
55b1212
/usr/sbin/semanage port -a -t memcached_port_t -p tcp 11211 &> /dev/null || :
55b1212
/sbin/fixfiles -R %{name} restore || :
55b1212
55b1212
55b1212
%postun selinux
55b1212
# Clean up after package removal
55b1212
if [ $1 -eq 0 ]; then
55b1212
  /usr/sbin/semanage port -d -t memcached_port_t -p tcp 11211 &> /dev/null || :
55b1212
  # Remove SELinux policy modules
55b1212
  for selinuxvariant in %{selinux_variants}
55b1212
  do
55b1212
    /usr/sbin/semodule -s ${selinuxvariant} -r %{modulename} &> /dev/null || :
55b1212
  done
55b1212
  /sbin/fixfiles -R %{name} restore || :
55b1212
fi
55b1212
55b1212
618683d
%files
618683d
%defattr(-,root,root,-)
76248e2
%doc AUTHORS ChangeLog COPYING NEWS README doc/CONTRIBUTORS doc/*.txt
618683d
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
618683d
55b1212
%dir %attr(755,%{username},%{groupname}) %{_localstatedir}/run/memcached
618683d
%{_bindir}/memcached-tool
618683d
%{_bindir}/memcached
618683d
%{_mandir}/man1/memcached.1*
618683d
%{_initrddir}/memcached
618683d
618683d
55b1212
%files selinux
55b1212
%defattr(-,root,root,0755)
55b1212
%doc SELinux/*.te SELinux/*.fc SELinux/*.if
55b1212
%{_datadir}/selinux/*/%{modulename}.pp
55b1212
91094ee
%files devel
91094ee
%defattr(-,root,root,0755)
91094ee
%{_includedir}/memcached/*
55b1212
618683d
%changelog
76248e2
* Mon Oct 12 2009 Paul Lindner <lindner@inuus.com> - 1.4.2-1
76248e2
- Upgrade to memcached-1.4.2
76248e2
- Addresses CVE-2009-2415
76248e2
4dea1b0
* Sat Aug 29 2009 Paul Lindner <lindner@inuus.com> - 1.4.1-1
4dea1b0
- Upgrade to 1.4.1 
4dea1b0
- http://code.google.com/p/memcached/wiki/ReleaseNotes141
4dea1b0
f6f5f83
* Wed Apr 29 2009 Paul Lindner <lindner@inuus.com> - 1.2.8-1
f6f5f83
- Upgrade to memcached-1.2.8
f6f5f83
- Addresses CVE-2009-1255
f6f5f83
07c829e
* Wed Feb 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.2.6-2
07c829e
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild
07c829e
cfc5f85
* Tue Jul 29 2008 Paul Lindner <lindner@inuus.com> - 1.2.6-1
cfc5f85
- Upgrade to memcached-1.2.6
cfc5f85
7bbc263
* Tue Mar  4 2008 Paul Lindner <lindner@inuus.com> - 1.2.5-1
7bbc263
- Upgrade to memcached-1.2.5
7bbc263
6fd5609
* Tue Feb 19 2008 Fedora Release Engineering <rel-eng@fedoraproject.org> - 1.2.4-4
6fd5609
- Autorebuild for GCC 4.3
6fd5609
4e7d0fa
* Sun Jan 27 2008 Paul Lindner <lindner@inuus.com> - 1.2.4-3
4e7d0fa
- Adjust libevent dependencies
4e7d0fa
4e7d0fa
* Sat Dec 22 2007 Paul Lindner <lindner@inuus.com> - 1.2.4-2
55b1212
- Upgrade to memcached-1.2.4
55b1212
55b1212
* Fri Sep 07 2007 Konstantin Ryabitsev <icon@fedoraproject.org> - 1.2.3-8
55b1212
- Add selinux policies
55b1212
- Create our own system user
55b1212
fdeed36
* Mon Aug  6 2007 Paul Lindner <lindner@inuus.com> - 1.2.3-7
888f13f
- Fix problem with -P and -d flag combo on x86_64
888f13f
- Fix init script for FC-6
888f13f
f858079
* Fri Jul 13 2007 Paul Lindner <lindner@inuus.com> - 1.2.3-4
f858079
- Remove test that fails in fedora build system on ppc64
80d6042
80d6042
* Sat Jul  7 2007 root <lindner@inuus.com> - 1.2.3-2
618683d
- Upgrade to 1.2.3 upstream
618683d
- Adjust make install to preserve man page timestamp
618683d
- Conform with LSB init scripts standards, add force-reload
618683d
618683d
* Wed Jul  4 2007 Paul Lindner <lindner@inuus.com> - 1.2.2-5
618683d
- Use /var/run/memcached/ directory to hold PID file
618683d
618683d
* Sat May 12 2007 Paul Lindner <lindner@inuus.com> - 1.2.2-4
618683d
- Remove tabs from spec file, rpmlint reports no more errors
618683d
618683d
* Thu May 10 2007 Paul Lindner <lindner@inuus.com> - 1.2.2-3
618683d
- Enable build-time regression tests
618683d
- add dependency on initscripts
618683d
- remove memcached-debug (not needed in dist)
618683d
- above suggestions from Bernard Johnson
618683d
618683d
* Mon May  7 2007 Paul Lindner <lindner@inuus.com> - 1.2.2-2
618683d
- Tidyness improvements suggested by Ruben Kerkhof in bugzilla #238994
618683d
618683d
* Fri May  4 2007 Paul Lindner <lindner@inuus.com> - 1.2.2-1
618683d
- Initial spec file created via rpmdev-newspec