@@ -0,0 +1,115 @@
+Name: couchdb
+Version: 0.8.1
+Release: 1
+Summary: The next generation of web storage
+Group: Development/Libraries
+License: GPL
+Source0: apache-%{name}-%{version}-incubating.tar.gz
+Source1: couchdb.apache.conf
+Source2: couchdb.suse.init
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+
+BuildRequires: libicu-devel curl-devel libxml2-devel
+BuildRequires: erlang gcc-c++
+BuildRequires: mozilla-xulrunner181-devel >= 1.8.1.14
+Requires: mozilla-xulrunner181 >= 1.8.1.14
+Requires: erlang apache2 libicu-devel
+
+# Macro that print mesages to syslog at package (un)install time
+%define nnmmsg logger -t %{name}/rpm
+
+
+%description
+A CouchDB server hosts named databases, which store documents.
+Each document is uniquely named in the database, and CouchDB
+provides a [WWW] RESTful HTTP API for reading and
+updating (add, edit, delete) database documents.
+
+%prep
+%setup -n apache-%{name}-%{version}-incubating
+
+export JSINCLUDE=`xulrunner-config --idlflags | sed -e s@-I@@g`
+export JSLIB=`xulrunner-config --libs | sed -e s@-L@@g`
+
+%configure --with-js-include=${JSINCLUDE} --with-js-lib=${JSLIB} \
+ CFLAGS="`xulrunner-config --idlflags`/js" || cat config.log
+
+%build
+%{__make}
+
+%makeinstall
+mkdir -p %{buildroot}/%{_sysconfdir}/init.d
+mkdir -p %{buildroot}/var/adm/fillup-templates/
+mkdir -p %{buildroot}/%{_docdir}/%{name}
+mkdir -p %{buildroot}/%{_sysconfdir}/apache2/conf.d
+mv %{buildroot}/%{_sysconfdir}/rc.d/couchdb %{buildroot}/%{_sysconfdir}/init.d/
+mv %{buildroot}/%{_sysconfdir}/default/couchdb %{buildroot}/var/adm/fillup-templates/sysconfig.%{name}
+mv %{buildroot}%{_datadir}/doc/%{name}/* %{buildroot}/%{_docdir}/%{name}/
+rmdir %{buildroot}/%{_sysconfdir}/rc.d
+rmdir %{buildroot}/%{_sysconfdir}/default
+rm -Rf %{buildroot}%{_datadir}/doc/%{name}
+# this was used with original init script
+#sed -i s@default@sysconfig@g %{buildroot}/%{_sysconfdir}/init.d/%{name}
+# replace original init script with Source2
+%{__install} -m 755 %{S:2} %{buildroot}/%{_sysconfdir}/init.d/%{name}
+# match entrys in config file
+mkdir -p %{buildroot}/var/log/%{name}
+mkdir -p %{buildroot}/var/lib/%{name}
+
+# install apache config file
+%{__install} -m 644 %{S:1} %{buildroot}/%{_sysconfdir}/apache2/conf.d/%{name}.conf
+
+%pre
+# Create `couchdb' user on the system if necessary
+if /usr/bin/id %{name} > /dev/null 2>&1 ; then
+ : # user already exists
+ /usr/sbin/usermod -d -d %{_localstatedir}/lib/%{name} -g www -s /bin/bash %{name} || \
+ %nnmmsg Unexpected error changing user "%{name}". Aborting update process.
+else
+ /usr/sbin/useradd -r -d %{_localstatedir}/lib/%{name} -g www -s /bin/bash -c "CouchDB" %{name} || \
+ %nnmmsg Unexpected error adding user "%{name}". Aborting install process.
+fi
+
+%post
+%fillup_and_insserv couchdb
+
+%postun
+if [ $1 = 0 ]; then
+ /bin/grep '^%{name}:' /etc/passwd > /dev/null 2>&1 && /usr/sbin/userdel %{name} || %nnmmsg "User %{name} could not be deleted."
+fi
+
+%files
+%defattr(-,root,root)
+%dir %{_sysconfdir}/%{name}
+%config(noreplace) %{_sysconfdir}/%{name}/couch.ini
+%config(noreplace) %{_sysconfdir}/apache2/conf.d/%{name}.conf
+%{_sysconfdir}/logrotate.d/%{name}
+/var/adm/fillup-templates/sysconfig.%{name}
+%defattr(0755,root,root)
+%{_sysconfdir}/init.d/%{name}
+%{_bindir}
+%{_libdir}/%{name}
+%{_mandir}/man1
+%{_docdir}/%{name}
+%defattr(-,couchdb,www)
+%{_datadir}/%{name}
+%dir /var/log/%{name}
+%dir /var/lib/%{name}
+
+%changelog
+* Sun Nov 23 2008 Carsten Schoene <cs@linux-administrator.com>
+- new release 0.8.1
+
+* Mon Jun 30 2008 Carsten Schoene <cs@linux-administrator.com>
+- new release 0.8.0
+
+* Tue Apr 15 2008 Carsten Schoene <cs@linux-administrator.com>
+- update to current SVN from new location http://svn.apache.org/repos/asf/incubator/couchdb/trunk
+
+* Thu Mar 27 2008 Carsten Schoene <cs@linux-administrator.com>
+- fix postun
+- replace init script
+- changed couchdb users homedir
+
+* Fri Mar 21 2008 Carsten Schoene <cs@linux-administrator.com>
+- initial svn build
|