File couchdb-lucene.spec of Package couchdb-lucene
# Copyright (c) 2013 Marcello Barnaba <vjt@openssl.it>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the
# distribution.
# 3. Neither the name of Marcello Barnaba nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
%define revision 9f61ade64f90599654c37c4a0c51ef93afd90e11
Name: couchdb-lucene
Version: 0.10.1.IFAD
Release: 0
Summary: Full-text indexer for CouchDB
Group: Productivity/Databases/Tools
License: Apache-2.0
URL: https://github.com/ifad/%{name}-build
Source0: https://github.com/ifad/%{name}-build/archive/%{revision}.tar.gz
Source1: %{name}.couchdb.ini
Source2: %{name}.sh
Source3: %{name}.ini
Source4: %{name}.log4j.xml
Source5: %{name}.service
Source6: %{name}.tmpfiles.conf
# Legacy for OpenSuSE < 12.1
Source100: %{name}.init
Source101: %{name}.sysconfig
# End legacy
BuildArch: noarch
Requires: couchdb >= 1.1
Requires: python
Requires: java >= 1.6.0
# Users and groups
Requires(pre): pwdutils
# Service setup
%if 0%{?suse_version} >= 1210
BuildRequires: pkgconfig(systemd)
%{?systemd_requires}
%else
Requires(post): %insserv_prereq
Requires(post): %fillup_prereq
%endif
%define couchdb_lucene_user %{name}
%define couchdb_lucene_group %{name}
%define couchdb_lucene_logs %{_localstatedir}/log/%{name}
%define couchdb_lucene_home %{_localstatedir}/lib/%{name}
%description
This software enables full-text searching of CouchDB documents using Lucene.
All Lucene full-text capability are available, the indexing strategy is
defined through a Javascript source file that receives a document and
manipulates / extracts its properties and adds them to the index. Index
updates are automatic, leveraging CouchDB's _changes feed.
This package is based off the IFAD fork of CouchDB-Lucene
<https://github.com/ifad/couchdb-lucene> that increases granularity of range
queries and sorting over date fields, and allows queries to be passed via HTTP
POST, useful if you do faceted search on many attributes / values.
Built at IFAD, http://github.com/ifad/.
%prep
%setup -n %{name}-build-%{revision}
%build
%install
export NO_BRP_CHECK_BYTECODE_VERSION=true
%{__install} -D -p -m 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/couchdb/default.d/lucene.ini
%{__install} -D -p -m 0755 %{SOURCE2} %{buildroot}%{_bindir}/%{name}
%{__mkdir_p} %{buildroot}/%{_sysconfdir}/%{name}
%{__install} -m 0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/%{name}/couchdb-lucene.ini
%{__install} -m 0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/%{name}/log4j.xml
%{__mkdir_p} %{buildroot}%{_usr}/lib/%{name}/bin
%{__install} -p -m 0644 lib/* %{buildroot}%{_usr}/lib/%{name}
%if 0%{?suse_version} >= 1230
%{__install} -D -p -m 0644 %{SOURCE5} %{buildroot}%{_unitdir}/%{name}.service
%{__install} -D -p -m 0644 %{SOURCE6} %{buildroot}/%{_usr}/lib/tmpfiles.d/%{name}.conf
%else
%{__install} -D -p -m 0755 %{SOURCE100} %{buildroot}%{_initddir}/%{name}
%{__mkdir_p} %{buildroot}%{_var}/adm/fillup-templates
%{__install} -p -m 0644 %{SOURCE101} %{buildroot}%{_var}/adm/fillup-templates/sysconfig.%{name}
%endif
%pre
getent group %{couchdb_lucene_group} >/dev/null || groupadd -r %{couchdb_lucene_group} || :
getent passwd %{couchdb_lucene_user} >/dev/null || \
useradd -r -g %{couchdb_lucene_group} -d %{couchdb_lucene_home} -s $(which nologin) \
-c "CouchDB-Lucene Full-text-Indexer Service" %{couchdb_lucene_user} || :
%post
%{__install} -d -o %{couchdb_lucene_user} -g %{couchdb_lucene_group} %{couchdb_lucene_home}
%{__install} -d -o %{couchdb_lucene_user} -g %{couchdb_lucene_group} %{couchdb_lucene_logs}
%if 0%{?suse_version} >= 1230
%service_add_post %{name}.service
%else
%{fillup_and_insserv -y %{name}}
%endif
%postun
%if 0%{?suse_version} >= 1230
%service_del_postun %{name}.service
%else
%restart_on_update %{name}
%insserv_cleanup
%endif
%preun
%if 0%{?suse_version} >= 1230
%service_del_preun %{name}.service
%else
%stop_on_removal %{name}
%endif
%files
%defattr(-,root,root,0755)
%doc README.md LICENSE LICENSE.dependencies
%dir %{_sysconfdir}/%{name}
%dir %{_sysconfdir}/couchdb
%dir %{_sysconfdir}/couchdb/default.d
%dir %{_usr}/lib/%{name}
%config(noreplace) %{_sysconfdir}/couchdb/default.d/lucene.ini
%config(noreplace) %{_sysconfdir}/%{name}/*
%if 0%{?suse_version} >= 1230
%{_unitdir}/%{name}.service
%{_usr}/lib/tmpfiles.d/%{name}.conf
%else
%{_initddir}/%{name}
%{_var}/adm/fillup-templates/sysconfig.%{name}
%endif
%{_bindir}/%{name}
%{_usr}/lib/%{name}/*
%changelog