-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathhyperkitty.spec
258 lines (214 loc) · 9.19 KB
/
hyperkitty.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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
%global pypi_name HyperKitty
#%%global prerel 1
Name: hyperkitty
Version: 1.0.2
Release: %{?prerel:0.}1%{?dist}
Summary: A web interface to access GNU Mailman v3 archives
License: GPLv3
URL: https://gitlab.com/mailman/hyperkitty
Source0: http://pypi.python.org/packages/source/H/%{pypi_name}/%{pypi_name}-%{version}%{?prerel:dev}.tar.gz
# To get SOURCE1:
# git clone https://gitlab.com/mailman/hyperkitty_standalone.git
# make sdist -C hyperkitty_standalone
# mv hyperkitty_standalone/dist/hyperkitty_standalone-%{version}.tar.gz .
Source1: hyperkitty_standalone-%{version}%{?prerel:dev}.tar.gz
BuildArch: noarch
BuildRequires: python-devel
BuildRequires: python-sphinx
# Unit tests in %%check
BuildRequires: django-gravatar2
BuildRequires: django-rest-framework >= 2.2.0
BuildRequires: python-social-auth
BuildRequires: django-crispy-forms
BuildRequires: python-django-compressor
BuildRequires: python-rjsmin
BuildRequires: nodejs-less
BuildRequires: python-mailman-client
BuildRequires: python-robot-detection
BuildRequires: pytz
BuildRequires: django-paintstore
BuildRequires: django-browserid
BuildRequires: python-django >= 1.6
BuildRequires: python-django-south >= 1.0.0
BuildRequires: python-dateutil
BuildRequires: python-networkx
BuildRequires: python-enum34
BuildRequires: python-django-haystack
BuildRequires: python-django-extensions
BuildRequires: python-lockfile
# Unit tests only
BuildRequires: python-beautifulsoup4
BuildRequires: python-mock
BuildRequires: python-whoosh
# SELinux
BuildRequires: checkpolicy, selinux-policy-devel, /usr/share/selinux/devel/policyhelp
BuildRequires: hardlink
Requires: django-gravatar2
Requires: python-social-auth
Requires: django-rest-framework >= 2.2.0
Requires: django-crispy-forms
Requires: python-django-compressor
Requires: python-rjsmin
Requires: nodejs-less
Requires: python-mailman-client
Requires: python-robot-detection
Requires: pytz
Requires: django-paintstore
Requires: django-browserid >= 0.10.1
Requires: python-django >= 1.6
Requires: python-django-south >= 1.0.0
Requires: python-dateutil
Requires: python-networkx
Requires: python-enum34
Requires: python-django-haystack
Requires: python-django-extensions
Requires: python-lockfile
Requires: numpy
%description
HyperKitty is an open source Django application under development. It aims at
providing a web interface to access GNU Mailman archives.
The code is available from: https://gitlab.com/mailman/hyperkitty .
The documentation can be browsed online at https://hyperkitty.readthedocs.org .
%package selinux
%global selinux_variants mls targeted
Summary: SELinux policy module for %{name}
Requires: %{name} = %{version}-%{release}
%{!?_selinux_policy_version: %global _selinux_policy_version %(sed -e 's,.*selinux-policy-\\([^/]*\\)/.*,\\1,' /usr/share/selinux/devel/policyhelp 2>/dev/null)}
%if "%{_selinux_policy_version}" != ""
Requires: selinux-policy >= %{_selinux_policy_version}
%endif
Requires(post): /usr/sbin/semodule, /sbin/restorecon, /sbin/fixfiles, %{name}
Requires(postun): /usr/sbin/semodule, /sbin/restorecon, /sbin/fixfiles, %{name}
%description selinux
This is the SELinux module for %{name}, install it if you are using SELinux.
%prep
%setup -q -n %{pypi_name}-%{version}%{?prerel:dev} -a 1
# Remove bundled egg-info
rm -rf %{pypi_name}.egg-info
mv hyperkitty_standalone-%{version}%{?prerel:dev} hyperkitty_standalone
# remove shebang on manage.py
sed -i -e '1d' hyperkitty_standalone/manage.py
# remove executable permissions on wsgi.py
chmod -x hyperkitty_standalone/wsgi.py
# remove __init__.py in hyperkitty_standalone to prevent it from being
# installed (find_package won't find it). It's empty anyway.
rm -f hyperkitty_standalone/__init__.py
# SELinux
mkdir SELinux
echo '%{_localstatedir}/lib/%{name}/sites(/.*)? gen_context(system_u:object_r:httpd_sys_content_t,s0)' \
> SELinux/%{name}.fc
# remember to bump the following version if the policy is updated
echo "policy_module(%{name}, 1.0)" > SELinux/%{name}.te
%build
%{__python} setup.py build
# generate html docs
sphinx-build doc html
# remove the sphinx-build leftovers
rm -rf html/.{doctrees,buildinfo}
# SELinux
cd SELinux
for selinuxvariant in %{selinux_variants}; do
make NAME=${selinuxvariant} -f /usr/share/selinux/devel/Makefile
mv %{name}.pp %{name}.pp.${selinuxvariant}
make NAME=${selinuxvariant} -f /usr/share/selinux/devel/Makefile clean
done
cd -
%install
rm -rf %{buildroot}
%{__python} setup.py install --skip-build --root %{buildroot}
# Install the Django files
mkdir -p %{buildroot}%{_sysconfdir}/%{name}/sites/default
cp -p hyperkitty_standalone/{manage,settings,urls,wsgi}.py \
%{buildroot}%{_sysconfdir}/%{name}/sites/default/
touch --reference hyperkitty_standalone/manage.py \
%{buildroot}%{_sysconfdir}/%{name}/sites/default/__init__.py
# Apache HTTPd config file
mkdir -p %{buildroot}/%{_sysconfdir}/httpd/conf.d/
sed -e 's,/path/to/hyperkitty_standalone/static,%{_localstatedir}/lib/%{name}/sites/default/static,g' \
-e 's,/path/to/hyperkitty_standalone,%{_sysconfdir}/%{name}/sites/default,g' \
hyperkitty_standalone/hyperkitty.apache.conf \
> %{buildroot}/%{_sysconfdir}/httpd/conf.d/hyperkitty.conf
touch --reference hyperkitty_standalone/hyperkitty.apache.conf \
%{buildroot}/%{_sysconfdir}/httpd/conf.d/hyperkitty.conf
# SQLite databases directory, static files and fulltext_index
mkdir -p %{buildroot}%{_localstatedir}/lib/%{name}/sites/default/static
mkdir -p %{buildroot}%{_localstatedir}/lib/%{name}/sites/default/db
mkdir -p %{buildroot}%{_localstatedir}/lib/%{name}/sites/default/fulltext_index
sed -i -e 's,/path/to/rw,%{_localstatedir}/lib/%{name}/sites/default/db,g' \
-e 's,^BASE_DIR = .*$,BASE_DIR = "%{_localstatedir}/lib/%{name}/sites/default",g' \
%{buildroot}%{_sysconfdir}/%{name}/sites/default/settings.py
touch --reference hyperkitty_standalone/settings.py \
%{buildroot}%{_sysconfdir}/%{name}/sites/default/settings.py
# Cron jobs
mkdir -p %{buildroot}%{_sysconfdir}/cron.d
sed -e 's,/path/to/hyperkitty_standalone,%{_sysconfdir}/%{name}/sites/default,g' \
hyperkitty_standalone/crontab \
> %{buildroot}%{_sysconfdir}/cron.d/%{name}
touch --reference hyperkitty_standalone/crontab \
%{buildroot}%{_sysconfdir}/cron.d/%{name}
# SELinux
for selinuxvariant in %{selinux_variants}; do
install -d %{buildroot}%{_datadir}/selinux/${selinuxvariant}
install -p -m 644 SELinux/%{name}.pp.${selinuxvariant} \
%{buildroot}%{_datadir}/selinux/${selinuxvariant}/%{name}.pp
done
/usr/sbin/hardlink -cv %{buildroot}%{_datadir}/selinux
%check
PYTHONPATH=`pwd`:`pwd`/hyperkitty_standalone %{_bindir}/django-admin test --settings=settings hyperkitty
%post
# Build the static files cache
%{_bindir}/django-admin collectstatic \
--pythonpath=%{_sysconfdir}/%{name}/sites/default \
--settings=settings --noinput &>/dev/null || :
%{_bindir}/django-admin compress \
--pythonpath=%{_sysconfdir}/%{name}/sites/default \
--settings=settings &>/dev/null || :
%post selinux
for selinuxvariant in %{selinux_variants}; do
/usr/sbin/semodule -s ${selinuxvariant} -i \
%{_datadir}/selinux/${selinuxvariant}/%{name}.pp &> /dev/null || :
done
/sbin/fixfiles -R %{name} restore || :
/sbin/restorecon -R %{_localstatedir}/lib/%{name} || :
%postun selinux
if [ $1 -eq 0 ] ; then
for selinuxvariant in %{selinux_variants}; do
/usr/sbin/semodule -s ${selinuxvariant} -r %{name} &> /dev/null || :
done
/sbin/fixfiles -R %{name} restore || :
[ -d %{_localstatedir}/lib/%{name} ] && \
/sbin/restorecon -R %{_localstatedir}/lib/%{name} &> /dev/null || :
fi
%files
%doc html README.rst COPYING.txt
%config(noreplace) %{_sysconfdir}/%{name}
%config(noreplace) %attr(640,root,apache) %{_sysconfdir}/%{name}/sites/default/settings.py
%config(noreplace) %{_sysconfdir}/httpd/conf.d/%{name}.conf
%config(noreplace) %{_sysconfdir}/cron.d/%{name}
%{python_sitelib}/%{name}
%{python_sitelib}/%{pypi_name}-*.egg-info
%dir %{_localstatedir}/lib/%{name}
%dir %{_localstatedir}/lib/%{name}/sites
%dir %{_localstatedir}/lib/%{name}/sites/default
%dir %{_localstatedir}/lib/%{name}/sites/default/static
%attr(755,apache,apache) %{_localstatedir}/lib/%{name}/sites/default/db
%attr(755,apache,apache) %{_localstatedir}/lib/%{name}/sites/default/fulltext_index
%files selinux
%defattr(-,root,root,0755)
%doc SELinux/*
%{_datadir}/selinux/*/%{name}.pp
%changelog
* Mon Nov 25 2013 Aurelien Bompard <[email protected]> - 0.1.7-0.1
- add SELinux policy module, according to:
http://fedoraproject.org/wiki/SELinux_Policy_Modules_Packaging_Draft
* Thu Aug 15 2013 Aurelien Bompard <[email protected]> - 0.1.7-0.1
- don't remove the static files cache on uninstall (it may have local
modifications)
* Tue Jul 23 2013 Aurelien Bompard <[email protected]> - 0.1.6-1
- version 0.1.6
* Thu Mar 28 2013 Aurelien Bompard <[email protected]> - 0.1.5-0.2
- put collected static files in _localstatedir
* Tue Feb 19 2013 Aurelien Bompard <[email protected]> - 0.1.4-1
- update to 0.1.4
* Thu Nov 29 2012 Aurelien Bompard <[email protected]> - 0.1.3-1
- Initial package.