%define couchdb_user couchdb
%define couchdb_group couchdb
%define couchdb_home %{_localstatedir}/lib/couchdb
Name: couchdb
Version: 0.11.2
Release: 2%{?dist}
Summary: A document database server, accessible via a RESTful JSON API
Group: Applications/Databases
License: ASL 2.0
URL: http://couchdb.apache.org/
Source0: http://www.apache.org/dist/%{name}/%{version}/apache-%{name}-%{version}.tar.gz
Source1: %{name}.init
Patch1: couchdb0.11.x-0001-Force-init-script-installation.patch
Patch2: couchdb0.11.x-0002-Install-into-erllibdir-by-default.patch
Patch3: couchdb0.11.x-0003-Remove-bundled-erlang-oauth-library.patch
Patch4: couchdb0.11.x-0004-Remove-bundled-erlang-etap-library.patch
Patch5: couchdb0.11.x-0005-Remove-bundled-mochiweb-library.patch
Patch6: couchdb0.11.x-0006-Remove-bundled-ibrowse-library.patch
Patch7: couchdb0.11.x-0007-Workaround-for-system-wide-ibrowse.patch
Patch8: couchdb0.11.x-0008-Remove-pid-file-after-stop.patch
Patch9: couchdb0.11.x-0009-deleting-a-DB-while-it-was-being-opened-would-crash-.patch
Patch10: couchdb0.11.x-0010-Relax-curl-dependency-to-7.15-for-RHEL5.patch
Patch11: couchdb0.11.x-0011-Do-not-install-gzipped-docs.patch
Patch12: couchdb0.11.x-0012-Fix-respawn-timeout-to-match-default-value.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: curl-devel
BuildRequires: erlang
BuildRequires: erlang-etap
BuildRequires: erlang-ibrowse
BuildRequires: erlang-mochiweb
BuildRequires: erlang-oauth
BuildRequires: help2man
BuildRequires: js-devel
BuildRequires: libicu-devel
# For /usr/bin/prove
BuildRequires: perl(Test::Harness)
Requires: erlang-crypto
Requires: erlang-erts
Requires: erlang-ibrowse
Requires: erlang-inets
Requires: erlang-kernel
Requires: erlang-mochiweb
Requires: erlang-oauth
Requires: erlang-sasl
Requires: erlang-stdlib
Requires: erlang-tools
#Initscripts
Requires(post): chkconfig
Requires(preun): chkconfig initscripts
# Users and groups
Requires(pre): shadow-utils
%description
Apache CouchDB is a distributed, fault-tolerant and schema-free
document-oriented database accessible via a RESTful HTTP/JSON API.
Among other features, it provides robust, incremental replication
with bi-directional conflict detection and resolution, and is
queryable and indexable using a table-oriented view engine with
JavaScript acting as the default view definition language.
%prep
%setup -q -n apache-%{name}-%{version}
%patch1 -p1 -b .initenabled
%patch2 -p1 -b .fix_lib_path
%patch3 -p1 -b .remove_bundled_oauth
%patch4 -p1 -b .remove_bundled_etap
%patch5 -p1 -b .remove_bundled_mochiweb
%patch6 -p1 -b .remove_bundled_ibrowse
%patch7 -p1 -b .workaround_for_ssl
%patch8 -p1 -b .remove_pid_file
%patch9 -p1 -b .fix_crash
%if 0%{?el5}
%patch10 -p1 -b .curl_7_15
%endif
%patch11 -p1 -b .gzipped_docs
%patch12 -p1 -b .fix_respawn
# Restore original timestamps to avoid reconfiguring
touch -r configure.ac.initenabled configure.ac
touch -r configure.fix_lib_path configure
%build
%configure
make %{?_smp_mflags}
%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
# Install our custom couchdb initscript
install -D -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_initrddir}/%{name}
# ...and remove previously installed one
rm $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/couchdb
# Use /etc/sysconfig instead of /etc/default
mv $RPM_BUILD_ROOT%{_sysconfdir}/{default,sysconfig}
%check
make check || exit 1
%clean
rm -rf $RPM_BUILD_ROOT
%pre
getent group %{couchdb_group} >/dev/null || groupadd -r %{couchdb_group}
getent passwd %{couchdb_user} >/dev/null || \
useradd -r -g %{couchdb_group} -d %{couchdb_home} -s /bin/bash \
-c "Couchdb Database Server" %{couchdb_user}
exit 0
%post
/sbin/chkconfig --add couchdb
%preun
if [ $1 = 0 ] ; then
/sbin/service couchdb stop >/dev/null 2>&1
/sbin/chkconfig --del couchdb
fi
%files
%defattr(-,root,root,-)
%doc AUTHORS BUGS CHANGES LICENSE NEWS NOTICE README THANKS
%dir %{_sysconfdir}/couchdb
%dir %{_sysconfdir}/couchdb/local.d
%dir %{_sysconfdir}/couchdb/default.d
%config(noreplace) %attr(0644, %{couchdb_user}, root) %{_sysconfdir}/couchdb/default.ini
%config(noreplace) %attr(0644, %{couchdb_user}, root) %{_sysconfdir}/couchdb/local.ini
%config(noreplace) %{_sysconfdir}/sysconfig/couchdb
%config(noreplace) %{_sysconfdir}/logrotate.d/couchdb
%{_initrddir}/couchdb
%{_bindir}/couchdb
%{_bindir}/couchjs
%{_libdir}/erlang/lib/couch-%{version}
%{_datadir}/couchdb
%{_mandir}/man1/couchdb.1.*
%{_mandir}/man1/couchjs.1.*
%dir %attr(0755, %{couchdb_user}, root) %{_localstatedir}/log/couchdb
%dir %attr(0755, %{couchdb_user}, root) %{_localstatedir}/run/couchdb
%dir %attr(0755, %{couchdb_user}, root) %{_localstatedir}/lib/couchdb
%changelog
* Thu Aug 26 2010 Peter Lemenkov <lemenkov@gmail.com> 0.11.2-2
- Cleaned up spec-file a bit
* Tue Aug 17 2010 Peter Lemenkov <lemenkov@gmail.com> 0.11.2-1
- Ver. 0.11.2
* Wed Jul 14 2010 Peter Lemenkov <lemenkov@gmail.com> 0.11.1-1
- Ver. 0.11.1
- Removed patch for compatibility with Erlang/OTP R14A (merged upstream)
* Sun Jul 11 2010 Peter Lemenkov <lemenkov@gmail.com> 0.11.0-3
- Compatibility with Erlang R14A (see patch9)
* Tue Jun 22 2010 Peter Lemenkov <lemenkov@gmail.com> 0.11.0-2
- Massive spec cleanup
* Tue Jun 18 2010 Peter Lemenkov <lemenkov@gmail.com> 0.11.0-1
- Ver. 0.11.0 (a feature-freeze release candidate)
* Fri Jun 18 2010 Peter Lemenkov <lemenkov@gmail.com> 0.10.2-13
- Remove ldconfig invocation (no system-wide shared libraries)
- Removed icu-config requires
* Tue Jun 15 2010 Peter Lemenkov <lemenkov@gmail.com> 0.10.2-12
- Narrow explicit requires
* Tue Jun 8 2010 Peter Lemenkov <lemenkov@gmail.com> 0.10.2-11
- Remove bundled ibrowse library (see rhbz #581282).
* Mon Jun 7 2010 Peter Lemenkov <lemenkov@gmail.com> 0.10.2-10
- Use system-wide erlang-mochiweb instead of bundled copy (rhbz #581284)
- Added %%check target and necessary BuildRequires - etap, oauth, mochiweb
* Wed Jun 2 2010 Peter Lemenkov <lemenkov@gmail.com> 0.10.2-9
- Remove pid-file after stopping CouchDB
* Tue Jun 1 2010 Peter Lemenkov <lemenkov@gmail.com> 0.10.2-8
- Suppress unneeded message while stopping CouchDB via init-script
* Mon May 31 2010 Peter Lemenkov <lemenkov@gmail.com> 0.10.2-7
- Do not manually remove pid-file while stopping CouchDB
* Mon May 31 2010 Peter Lemenkov <lemenkov@gmail.com> 0.10.2-6
- Fix 'stop' and 'status' targets in the init-script (see rhbz #591026)
* Thu May 27 2010 Peter Lemenkov <lemenkov@gmail.com> 0.10.2-5
- Use system-wide erlang-etap instead of bundled copy (rhbz #581281)
* Fri May 14 2010 Peter Lemenkov <lemenkov@gmail.com> 0.10.2-4
- Use system-wide erlang-oauth instead of bundled copy (rhbz #581283)
* Thu May 13 2010 Peter Lemenkov <lemenkov@gmail.com> 0.10.2-3
- Fixed init-script to use /etc/sysconfig/couchdb values (see rhbz #583004)
- Fixed installation location of beam-files (moved to erlang directory)
* Fri May 7 2010 Peter Lemenkov <lemenkov@gmail.com> 0.10.2-2
- Remove useless BuildRequires
* Fri May 7 2010 Peter Lemenkov <lemenkov@gmail.com> 0.10.2-1
- Update to 0.10.2 (resolves rhbz #578580 and #572176)
- Fixed chkconfig priority (see rhbz #579568)
* Fri Apr 02 2010 Caolán McNamara <caolanm@redhat.com> 0.10.0-3
- rebuild for icu 4.4
* Thu Oct 15 2009 Allisson Azevedo <allisson@gmail.com> 0.10.0-2
- Added patch to force init_enabled=true in configure.ac.
* Thu Oct 15 2009 Allisson Azevedo <allisson@gmail.com> 0.10.0-1
- Update to 0.10.0.
* Sun Oct 04 2009 Rahul Sundaram <sundaram@fedoraproject.org> 0.9.1-2
- Change url. Fixes rhbz#525949
* Thu Jul 30 2009 Allisson Azevedo <allisson@gmail.com> 0.9.1-1
- Update to 0.9.1.
- Drop couchdb-0.9.0-pid.patch.
* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
* Tue Apr 21 2009 Allisson Azevedo <allisson@gmail.com> 0.9.0-2
- Fix permission for ini files.
- Fix couchdb.init start process.
* Tue Apr 21 2009 Allisson Azevedo <allisson@gmail.com> 0.9.0-1
- Update to 0.9.0.
* Tue Nov 25 2008 Allisson Azevedo <allisson@gmail.com> 0.8.1-4
- Use /etc/sysconfig for settings.
* Tue Nov 25 2008 Allisson Azevedo <allisson@gmail.com> 0.8.1-3
- Fix couchdb_home.
- Added libicu-devel for requires.
* Tue Nov 25 2008 Allisson Azevedo <allisson@gmail.com> 0.8.1-2
- Fix spec issues.
* Tue Nov 25 2008 Allisson Azevedo <allisson@gmail.com> 0.8.1-1
- Initial RPM release