/
couchdb.spec
196 lines (176 loc) · 5.88 KB
/
couchdb.spec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
%define name couchdb
%define prefix /opt/%{name}
Summary: RESTful document oriented database
License: Apache License v2.0
Name: %{name}
Version: %{_version}
Release: 1%{?dist}
Source: https://www.apache.org/dist/couchdb/source/${version}/apache-couchdb-%{version}.tar.gz
Source1: %{name}.service
Source2: %{name}.init
Source3: 10-filelog.ini
Source5: %{name}.logrotate
Prefix: %{prefix}
Group: Applications/Databases
URL: https://couchdb.apache.org/
Vendor: The Apache Software Foundation
BuildArch: x86_64
ExclusiveArch: x86_64
Exclusiveos: linux
Packager: CouchDB Developers <dev@couchdb.apache.org>
%if 0%{?suse_version}
BuildRequires: erlang
BuildRequires: erlang-rebar
BuildRequires: erlang-reltool
BuildRequires: erlang-epmd
BuildRequires: gcc-c++
BuildRequires: pkg-config
Requires(pre): shadow
BuildRequires: python3
Requires(post): python3-progressbar
Requires(post): python3-requests
%else
BuildRequires: esl-erlang
BuildRequires: gcc
Requires(pre): shadow-utils
#BuildRequires: python-pip
#BuildRequires: python-sphinx >= 1.5.3
Requires(post): python-progressbar
Requires(post): python-requests
%endif
BuildRequires: git
BuildRequires: help2man
#BuildRequires: couch-js-devel = 1:1.8.5
BuildRequires: libcurl-devel
BuildRequires: libicu-devel
BuildRequires: nodejs >= 6.10.1
Requires(post): curl
Requires(post): couch-js = 1:1.8.5
Requires(post): libicu >= 4.2.1
Requires(post): procps
%if 0%{?fedora} || 0%{?rhel} >= 7 || 0%{?suse_version}
%if 0%{?suse_version}
BuildRequires: systemd-rpm-macros
%else
BuildRequires: xfsprogs-devel
%endif
%{?systemd_requires}
BuildRequires: systemd
%else
Requires(post): chkconfig
Requires(preun): chkconfig, initscripts
Requires(postun): initscripts
%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.
CouchDB is written in Erlang, but can be easily accessed from any environment
that provides means to make HTTP requests. There are a multitude of third-party
client libraries that make this even easier for a variety of programming
languages and environments.
# NOTE: Stripping binaries causes issues so we skip it.
%define __os_install_post %{nil}
%build
./configure -c
%{__make} release
%clean
%{__rm} -rf %{buildroot}
%pre
%if 0%{?suse_version}
if ! /usr/bin/getent passwd couchdb > /dev/null; then /usr/sbin/useradd \
--system --home-dir /opt/couchdb --no-create-home \
--shell /bin/bash --comment "CouchDB Administrator" \
--user-group couchdb; fi
%else
if ! /usr/bin/getent passwd couchdb > /dev/null; then /usr/sbin/adduser \
--system --home /opt/couchdb --no-create-home \
--shell /bin/bash --comment "CouchDB Administrator" \
--user-group couchdb; fi
%endif
%install
%{__install} -d -m0755 %{buildroot}/opt
%{__cp} -r rel/couchdb %{buildroot}/opt
%{__install} -d -m0750 %{buildroot}/var/log/%{name}
%if 0%{?suse_version}
%{__install} -d -m0750 %{buildroot}%{_localstatedir}/lib/%{name}
%else
%{__install} -d -m0750 %{buildroot}%{_sharedstatedir}/%{name}
%endif
%{__install} -Dp -m0644 %{SOURCE3} %{buildroot}/opt/%{name}/etc/default.d/10-filelog.ini
%{__install} -Dp -m0644 %{SOURCE5} %{buildroot}/etc/logrotate.d/%{name}
/bin/find %{buildroot}/opt/%{name} -name *.ini -exec %{__chmod} 0640 {} \;
%if 0%{?fedora} || 0%{?rhel} >= 7 || 0%{?suse_version}
%{__install} -Dp -m0644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
%else
%{__install} -Dp -m0755 %{SOURCE2} %{buildroot}%{_initrddir}/%{name}
%endif
%if 0%{?suse_version}
%{__ln_s} -f -T %{_localstatedir}/lib/%{name} %{buildroot}/opt/%{name}/data
%else
%{__ln_s} -f -T %{_sharedstatedir}/%{name} %{buildroot}/opt/%{name}/data
%endif
%{__ln_s} -f -T /var/log/%{name} %{buildroot}/opt/%{name}/var/log/%{name}
%post
%{__chown} -R couchdb:couchdb /opt/%{name}
%{__chmod} a+x /opt/%{name}/bin/*
%if 0%{?fedora} || 0%{?rhel} >= 7
%systemd_post %{name}.service
%else
/sbin/chkconfig --add %{name} || :
%endif
%preun
%if 0%{?fedora} || 0%{?rhel} >= 7 || 0%{?suse_version}
%systemd_preun %{name}.service
%else
# stop couchdb only when uninstalling
if [ $1 -eq 0 ]; then
/sbin/service %{name} stop >/dev/null 2>&1 || :
/sbin/chkconfig --del %{name} || :
fi
killall -u couchdb epmd || :
%endif
%postun
%if 0%{?fedora} || 0%{?rhel} >= 7 || 0%{?suse_version}
%systemd_postun_with_restart %{name}.service
%else
# restart couchdb only when upgrading
if [ $1 -eq 1 ]; then
/sbin/service %{name} condrestart >/dev/null 2>&1 || :
fi
%endif
%files
%attr(0755, %{name}, %{name}) /opt/couchdb
%if 0%{?suse_version}
%attr(0755, %{name}, %{name}) %dir %{_localstatedir}/lib/%{name}
%else
%attr(0755, %{name}, %{name}) %dir %{_sharedstatedir}/%{name}
%endif
%attr(0755, %{name}, %{name}) %dir /var/log/%{name}
%config(noreplace) /opt/couchdb/etc/local.ini
%config /etc/logrotate.d/%{name}
%if 0%{?fedora} || 0%{?rhel} >= 7 || 0%{?suse_version}
%{_unitdir}/%{name}.service
%else
%{_initrddir}/%{name}
%endif
%changelog
* Tue May 2 2017 CouchDB Developers <dev@couchdb.apache.org> 2.0.0-1
- New upstream version
- New sysvinit and systemd service files
- New backported couchup script