-
Notifications
You must be signed in to change notification settings - Fork 2
/
dbs.spec
230 lines (170 loc) · 6.15 KB
/
dbs.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
%global dbs_statedir %{_sharedstatedir}/dbs
%global dbs_confdir %{_sysconfdir}/dbs
%global httpd_confdir %{_sysconfdir}/httpd/conf.d
Name: dbs
Version: 0.2
Release: 1%{?dist}
Summary: Docker Build Service
Group: Development Tools
License: BSD
URL: https://github.com/orgs/DBuildService/dashboard
Source0: http://github.srcurl.net/DBuildService/%{name}/%{version}/%{name}-%{version}.tar.gz
BuildArch: noarch
BuildRequires: python-devel
BuildRequires: python-setuptools
BuildRequires: systemd
Requires: dock
Requires: httpd
Requires: mod_ssl
Requires: mod_wsgi
Requires: python-celery
Requires: python-django >= 1.7
Requires: python-django-celery
Requires(pre): /usr/sbin/useradd
%description
Docker Build Service
%package server
Summary: Docker Build Service Web
Group: Development Tools
Requires: %{name}
%description server
Docker Build Service Web
%package worker
Summary: Docker Build Service Worker
Group: Development Tools
Requires: %{name}
Requires: docker
Requires: systemd
Requires: GitPython
Requires: docker-registry
Requires: redis
Requires(preun): systemd-units
Requires(postun): systemd-units
Requires(post): systemd-units
%description worker
Docker Build Service Worker
%prep
%setup -q
%build
# prepare config file
rm dbs/site_settings.py
mv dbs/site_settings-production.py site_settings
# move wsgi to document root
mv dbs/wsgi.py htdocs/
# build python package
%{__python} setup.py build
%install
# install python package
%{__python} setup.py install --skip-build --root %{buildroot}
# install config file as target of site_settings.py symlink
install -p -D -m 0644 site_settings \
%{buildroot}%{dbs_confdir}/site_settings
ln -s %{dbs_confdir}/site_settings \
%{buildroot}%{python_sitelib}/dbs/site_settings.py
# install commandline interface with bash completion
install -p -D -m 0755 manage.py %{buildroot}%{_bindir}/dbs
install -p -D -m 0644 dbs_bash_completion \
%{buildroot}%{_sysconfdir}/bash_completion.d/dbs_bash_completion
# install httpd config file and wsgi config file
install -p -D -m 0644 conf/httpd/dbs.conf \
%{buildroot}%{httpd_confdir}/dbs.conf
install -p -D -m 0644 htdocs/wsgi.py \
%{buildroot}%{dbs_statedir}/htdocs/wsgi.py
# install worker unit file
install -p -D -m 0644 conf/systemd/dbs-worker.service %{buildroot}%{_unitdir}/dbs-worker.service
# install directories for static content and site media
install -p -d -m 0775 htdocs/static \
%{buildroot}%{dbs_statedir}/htdocs/static
install -p -d -m 0775 htdocs/media \
%{buildroot}%{dbs_statedir}/htdocs/media
# install separate directory for sqlite db
install -p -d -m 0775 data \
%{buildroot}%{dbs_statedir}/data
# remove .po files
find %{buildroot} -name "*.po" | xargs rm -f
%pre
# add the dbs user
/usr/sbin/useradd -c "DBuildService" -s /sbin/nologin -r -d %{dbs_statedir} dbs 2> /dev/null || :
%post
# create secret key
if [ ! -e %{dbs_statedir}/secret_key ]; then
touch %{dbs_statedir}/secret_key
chown dbs %{dbs_statedir}/secret_key
chgrp dbs %{dbs_statedir}/secret_key
chmod 0400 %{dbs_statedir}/secret_key
dd bs=1k of=%{dbs_statedir}/secret_key if=/dev/urandom count=5
fi
# install / update database
dbs syncdb --noinput || :
%posttrans server
# link default certificate
if [ ! -e %{_sysconfdir}/pki/tls/certs/dbs.crt ]; then
ln -s localhost.crt %{_sysconfdir}/pki/tls/certs/dbs.crt
fi
# link default private key
if [ ! -e %{_sysconfdir}/pki/tls/private/dbs.key ]; then
ln -s localhost.key %{_sysconfdir}/pki/tls/private/dbs.key
fi
# link default chain file
if [ ! -e %{_sysconfdir}/pki/tls/certs/dbs.CA.crt ]; then
ln -s localhost.crt %{_sysconfdir}/pki/tls/certs/dbs.CA.crt
fi
# allow httpd read from htdocs and secret_key
chcon -t httpd_sys_content_t /var/lib/dbs/secret_key
chcon -t httpd_sys_content_t /var/lib/dbs/htdocs
chcon -t httpd_sys_content_t /var/lib/dbs/htdocs/wsgi.py*
chcon -R -t httpd_sys_content_t /var/lib/dbs/htdocs/static
# allow httpd write to data and media
chcon -R -t httpd_sys_rw_content_t /var/lib/dbs/data
chcon -R -t httpd_sys_rw_content_t /var/lib/dbs/htdocs/media
# allow httpd network connect
setsebool httpd_can_network_connect on
# collect static files
dbs collectstatic --noinput || :
# restart httpd
test -f /etc/sysconfig/dbs-disable-posttrans || \
/bin/systemctl try-restart httpd.service >/dev/null 2>&1 || :
%post worker
# add user dbs to group docker
usermod -a -G docker dbs || :
# run systemd stuff
%systemd_post dbs-worker.service
%preun worker
# run systemd stuff
%systemd_preun dbs-worker.service
%postun worker
# run systemd stuff
%systemd_postun
%files
%doc README.md LICENSE
%{_bindir}/dbs
%{_sysconfdir}/bash_completion.d/dbs_bash_completion
%config(noreplace) %{dbs_confdir}/site_settings
%attr(775,root,dbs) %dir %{dbs_statedir}/data
%{python_sitelib}/dbs
%{python_sitelib}/dbs-%{version}-py2.*.egg-info
%files server
%config(noreplace) %{httpd_confdir}/dbs.conf
%{dbs_statedir}/htdocs/wsgi.py*
%attr(755,root,root) %dir %{dbs_statedir}/htdocs/static
%attr(775,root,dbs) %dir %{dbs_statedir}/htdocs/media
%files worker
%doc README-worker.md
%{_unitdir}/dbs-worker.service
%changelog
* Mon Nov 10 2014 Tomas Tomecek <[email protected]> 0.2-1
- Better task list ([email protected])
- Enable task list ([email protected])
- api,build: store list of rpms in DB ([email protected])
- implement new api system ([email protected])
- api: implement invalidation ([email protected])
- api: implement move image, store data in DB ([email protected])
- implement rebuild ([email protected])
- import all models the same way ([email protected])
- default values for Task.status and Image.status ([email protected])
- new model dockerfile; store df in db after build ([email protected])
- replace docker-io with docker ([email protected])
* Mon Nov 03 2014 Jakub Dorňák <[email protected]> 0.1-1
- new package built with tito
* Wed Oct 22 2014 Jakub Dorňák <[email protected]> - 0.1-1
- Initial package