File couchdb.spec of Package couchdb
#
# spec file for package couchdb
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
#
%define couchdb_user couchdb
%define couchdb_group couchdb
%define couchdb_log %{_localstatedir}/log/%{name}
%define couchdb_home %{_localstatedir}/lib/%{name}
# This should be in RPM as %%{_runstatedir}
%if 0%{?suse_version} >= 1230
%define runstatedir /run/%{name}
%else
%define runstatedir %{_localstatedir}/run/%{name}
%endif
Name: couchdb
Version: 1.6.1
Release: 0
Summary: A document database server, accessible via a RESTful JSON API
License: Apache-2.0
Group: Productivity/File utilities
Url: http://couchdb.apache.org/
Source0: http://www.apache.org/dist/%{name}/source/%{version}/apache-couchdb-%{version}.tar.gz
Source1: %{name}.init
Source2: %{name}.sysconfig
Source3: %{name}.service
Source4: %{name}.tmpfiles.conf
Source5: http://www.apache.org/dist/%{name}/source/%{version}/apache-couchdb-%{version}.tar.gz.asc
Source6: %{name}.keyring
Patch0: couchdb-futon-default-view-language.patch
# PATCH-FIX-UPSTREAM couchdb-glibc-2.20.patch dimstar@opensuse.org -- Fix build with glibc 2.20; _BSD_SOURCE is deprecated in favor of _DEFAULT_SOURCE; using both for backwards compatibility
Patch1: couchdb-glibc-2.20.patch
Patch2: apache-couchdb-1.6.1-fix-bashisms.patch
Patch3: apache-couchdb-1.6.x-otp18-support.patch
# PATCH-FIX-UPSTREAM couchdb-1.6.1-fix-restart.patch bwiedemann@suse.de -- Fix heartbeat restart bnc#919927 https://issues.apache.org/jira/browse/COUCHDB-1917
Patch4: couchdb-1.6.1-fix-restart.patch
BuildRequires: autoconf-archive
BuildRequires: automake
BuildRequires: curl-devel
BuildRequires: erlang
BuildRequires: gcc-c++
BuildRequires: help2man
BuildRequires: libicu-devel
BuildRequires: libtool
BuildRequires: makeinfo
BuildRequires: pkgconfig
Requires: erlang
Requires: logrotate
Requires(post): aaa_base
Requires(post): info
Requires(pre): %fillup_prereq
# Users and groups
Requires(pre): pwdutils
Requires(preun): aaa_base
Requires(preun): info
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} < 1200
BuildRequires: mozilla-xulrunner192-devel
%else
BuildRequires: js-devel
%endif
%if 0%{?suse_version} >= 1230
BuildRequires: pkgconfig(systemd)
%{?systemd_requires}
%else
Requires(pre): %insserv_prereq
%endif
%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-couchdb-%{version}
%patch0
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%build
autoreconf -fi
# Versions of SpiderMonkey after the js185-1.0.0 release remove the optional
# enforcement of preventing anonymous functions in a statement context. This
# will most likely break your existing JavaScript code as well as render all
# example code invalid.
# If you wish to ignore this error pass --enable-js-trunk to ./configure.
#
# We need to define the use of gnu99 standard. It seems expected in the code, but not passed.
export CFLAGS="%{optflags} -std=gnu99"
%configure --enable-js-trunk
make %{?_smp_mflags}
%install
make DESTDIR=%{buildroot} install %{?_smp_mflags}
chmod -x %{buildroot}%{_datadir}/couchdb/server/main{,-coffee}.js
install -d %{buildroot}%{_sbindir}
%if 0%{?suse_version} >= 1230
# Service & tmpfiles config
install -D -m 0644 %{SOURCE3} %{buildroot}%{_unitdir}/%{name}.service
install -d -m 0755 %{buildroot}%{_libexecdir}/tmpfiles.d/
install -D -m 0644 %{SOURCE4} %{buildroot}%{_libexecdir}/tmpfiles.d/%{name}.conf
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
%else
# sysvinit script
install -D -m 0755 %{SOURCE1} %{buildroot}%{_initddir}/%{name}
ln -s %{_initddir}/%{name} %{buildroot}%{_sbindir}/rc%{name}
# Sysconfig template
mkdir -p %{buildroot}%{_var}/adm/fillup-templates/
install -p -D -m 644 %{SOURCE2} %{buildroot}%{_var}/adm/fillup-templates/sysconfig.%{name}
%endif
# Create needed directories
install -d %{buildroot}%{_sysconfdir}/%{name}/{default.d,local.d}
# Remove unecessary files
rm %{buildroot}%{_sysconfdir}/rc.d/%{name}
rm -rf %{buildroot}%{_datadir}/doc/%{name}
# clean-up .la archives
find %{buildroot} -type f -name "*.la" -delete -print
%pre
getent group %{couchdb_group} >/dev/null || groupadd -r %{couchdb_group} || :
if getent passwd %{couchdb_user} >/dev/null ; then
# There was a bad login shell up to openSUSE 12.2 (bnc#796242), SLE11SP2 used /bin/bash. Fix it.
usermod -s $(which nologin) %{couchdb_user} || :
else
useradd -r -g %{couchdb_group} -d %{couchdb_home} -s $(which nologin) \
-c "Couchdb Database Server" %{couchdb_user} || :
fi
%if 0%{?suse_version} >= 1230
%service_add_pre %{name}.service
%endif
%post
install -o %{couchdb_user} -g %{couchdb_group} -d %{runstatedir}
%if 0%{?suse_version} >= 1230
%fillup_only
%service_add_post %{name}.service
%if 0%{?suse_version} > 1320
%tmpfiles_create %{_libexecdir}/tmpfiles.d/%{name}.conf
%else
systemd-tmpfiles --create %{_libexecdir}/tmpfiles.d/%{name}.conf
%endif
%else
%{fillup_and_insserv %{name}}
%endif
%install_info --info-dir=%{_infodir} %{_infodir}/CouchDB.gz
%postun
%if 0%{?suse_version} >= 1230
%service_del_postun %{name}.service
%else
%restart_on_update %{name}
%insserv_cleanup
%endif
%preun
%install_info_delete --info-dir=%{_infodir} %{_infodir}/CouchDB.gz
%if 0%{?suse_version} >= 1230
%service_del_preun %{name}.service
%else
%stop_on_removal %{name}
%endif
%files
%defattr(-,root,root,-)
%doc AUTHORS BUGS DEVELOPERS LICENSE NOTICE README.rst THANKS
%dir %{_sysconfdir}/%{name}
%dir %{_sysconfdir}/%{name}/local.d
%dir %{_sysconfdir}/%{name}/default.d
%config(noreplace) %attr(0644, %{couchdb_user}, root) %{_sysconfdir}/%{name}/default.ini
%config(noreplace) %attr(0644, %{couchdb_user}, root) %{_sysconfdir}/%{name}/local.ini
%config(noreplace) %{_sysconfdir}/default/%{name}
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%if 0%{?suse_version} >= 1230
%{_unitdir}/%{name}.service
%{_libexecdir}/tmpfiles.d/%{name}.conf
%else
%{_initddir}/%{name}
%{_var}/adm/fillup-templates/sysconfig.%{name}
%endif
%{_sbindir}/rc%{name}
%{_bindir}/*
%{_libdir}/%{name}
%{_datadir}/%{name}
%{_mandir}/man1/*
%{_infodir}/CouchDB*
%dir %attr(0755, %{couchdb_user}, %{couchdb_group}) %{couchdb_log}
%dir %attr(0755, %{couchdb_user}, %{couchdb_group}) %{couchdb_home}
%ghost %dir %attr(0755, %{couchdb_user}, root) %{runstatedir}
%changelog