LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File couchdb.spec of Package couchdb (Project server:database)

#
# spec file for package couchdb
#
# Copyright (c) 2014 SUSE LINUX Products 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.5.0
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
Patch0:         couchdb-futon-default-view-language.patch
Patch1:         bnc-871111-remote-dos-via_uuids.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  autoconf-archive
BuildRequires:  automake
BuildRequires:  erlang
BuildRequires:  gcc-c++
BuildRequires:  help2man
BuildRequires:  libicu-devel
BuildRequires:  libtool
%if 0%{?suse_version} < 1200
BuildRequires:  mozilla-xulrunner192-devel
%else
BuildRequires:  js-devel
%endif
BuildRequires:  pkgconfig
Requires:       erlang
Requires:       logrotate
Requires(post): aaa_base
Requires(post): info
Requires(preun):aaa_base
Requires(preun):info
# Users and groups
Requires(pre):  pwdutils
%if 0%{?suse_version} >= 1230
BuildRequires:  pkgconfig(systemd)
%{?systemd_requires}
%else
Requires(pre):  %insserv_prereq
%endif
Requires(pre):  %fillup_prereq

%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

%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
%makeinstall
chmod -x %{buildroot}/usr/share/couchdb/server/main{,-coffee}.js
%if 0%{?suse_version} >= 1230
# Service & tmpfiles config
install -D -m 0644 %{SOURCE3} %{buildroot}%{_unitdir}/%{name}.service
install -d -m 0755 %{buildroot}/usr/lib/tmpfiles.d/
install -D -m 0644 %{SOURCE4} %{buildroot}/usr/lib/tmpfiles.d/%{name}.conf
%else
# sysvinit script
install -D -m 0755 %{SOURCE1} %{buildroot}%{_initddir}/%{name}
install -d %{buildroot}%{_sbindir}
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} -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

%post
install -o %{couchdb_user} -g %{couchdb_group} -d %{runstatedir}

%if 0%{?suse_version} >= 1230
%{fillup_only}
%service_add_post %{name}.service
%else
%{fillup_and_insserv %{name}}
%endif
%install_info --info-dir=%{_infodir} %{_infodir}/%{name}.info.gz

%postun
%if 0%{?suse_version} >= 1230
%service_del_postun %{name}.service
%else
%restart_on_update %{name}
%insserv_cleanup
%endif

%install_info_delete --info-dir=%{_infodir} %{_infodir}/%{name}.info.gz

%preun
%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}
%{_sbindir}/rc%{name}
%{_var}/adm/fillup-templates/sysconfig.%{name}
%endif
%{_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