1 |
# Fedora spec initially based on upstream spec file from OBS: |
2 |
# https://build.opensuse.org/package/view_file/devel:openQA/openQA/openQA.spec |
3 |
# License: GPLv2+ |
4 |
|
5 |
# openQA doesn't provide its own libs as they're not in the path, |
6 |
# so we need to exclude the auto-requires for them |
7 |
%global __requires_exclude perl\\(OpenQA |
8 |
|
9 |
%global github_owner os-autoinst |
10 |
%global github_name openQA |
11 |
%global github_version 4.2 |
12 |
%global github_commit 9953cb8cc89f4e9187f4209035ce2990dbf544cc |
13 |
# if set, will be a post-release snapshot build, otherwise a 'normal' build |
14 |
#global github_date 20150814 |
15 |
%global shortcommit %(c=%{github_commit}; echo ${c:0:7}) |
16 |
|
17 |
# can't use linebreaks here! |
18 |
%global openqa_services openqa-webui.service openqa-gru.service openqa-websockets.service openqa-scheduler.service |
19 |
%global openqa_worker_services openqa-worker.target openqa-worker@.service openqa-slirpvde.service openqa-vde_switch.service |
20 |
|
21 |
%define rel 8 |
22 |
|
23 |
Name: openqa |
24 |
Version: %{github_version} |
25 |
Release: %mkrel %{rel}%{?github_date:.%{github_date}git%{shortcommit}} |
26 |
Summary: The openQA web-frontend, scheduler and tools |
27 |
License: GPLv2+ |
28 |
Group: Development/Tools |
29 |
Url: http://os-autoinst.github.io/openQA/ |
30 |
Source0: https://github.com/%{github_owner}/%{github_name}/archive/%{github_commit}/%{github_name}-%{github_commit}.tar.gz |
31 |
# Backport: add my admin user creation script |
32 |
# https://github.com/os-autoinst/openQA/commit/3678b8599f5fc269b24b62eb2efecc0169a64264 |
33 |
Patch0: 0001-add-a-script-to-create-admin-user-and-API-key.patch |
34 |
# Backport: don't make sqlite db world-readable |
35 |
# https://github.com/os-autoinst/openQA/commit/ca5371222096d4fb347124a353a9d868acf40c76 |
36 |
Patch1: 0001-the-sqlite-database-should-be-only-readable-by-the-o.patch |
37 |
# Backport: improve branding (removes the SUSE navbar) |
38 |
# https://github.com/os-autoinst/openQA/commit/fbe15becd89f0dc278457fd8f25b87e43d60079c |
39 |
# https://github.com/os-autoinst/openQA/commit/ab76b525eb9d436ecc5f3395cd7de89a0e272e86 |
40 |
Patch2: 0001-replace-tabs-with-spaces.patch |
41 |
Patch3: 0002-Improve-web-UI-branding-mechanism-drop-topbar-in-pla.patch |
42 |
# Backport: adjust worker unit for change to %u in upstream systemd |
43 |
# https://github.com/os-autoinst/openQA/commit/834fa647fd835be2c33eada31e9b875ba7363f8b |
44 |
Patch4: 0001-adjust-openqa-worker-service-for-new-systemd.patch |
45 |
# Backport: start services after database services |
46 |
# https://github.com/os-autoinst/openQA/commit/9c52ad47e1e55a2f0b809ecc59f2a0081c22eb14 |
47 |
Patch5: 0001-systemd-start-scheduler-and-webui-and-websockets-aft.patch |
48 |
Requires(pre): rpm-helper >= %{rpmhelper_required_version} |
49 |
Requires(post): rpm-helper >= %{rpmhelper_required_version} |
50 |
Requires(post): sqlite3-tools |
51 |
BuildRequires: os-autoinst |
52 |
Requires: openqa-common = %{version} |
53 |
Requires: perl(URI) |
54 |
# (doktor5000) require a working version, see (mga#17345) |
55 |
BuildRequires: ruby-sass >= 3.4.20 |
56 |
# needed for openid support |
57 |
Requires: perl(LWP::Protocol::https) |
58 |
# (doktor5000) require apache directly to ease setup as upstream template configs assume apache |
59 |
Requires: apache |
60 |
# (doktor5000) pull in additional required apache modules |
61 |
Requires: apache-mod_proxy |
62 |
Requires: apache-mod_proxy_html |
63 |
|
64 |
# Recommends: logrotate |
65 |
# for postgresql |
66 |
# Recommends: perl(DateTime::Format::Pg) perl(DBD::Pg) |
67 |
|
68 |
# (doktor5000) perl Requires are autodetected, explicit Requires are disregarded |
69 |
# FIXME: this macro is used for packages that are both BuildRequires and Requires |
70 |
# runtime requirements that also the testsuite needs |
71 |
%define t_requires perl(DBD::SQLite) perl(DBIx::Class) perl(Config::IniFiles) perl(SQL::Translator) perl(Date::Format) perl(File::Copy::Recursive) perl(DateTime::Format::SQLite) perl(Net::OpenID::Consumer) perl(Mojolicious::Plugin::RenderFile) perl(Mojolicious::Plugin::AssetPack) perl(YAML) perl(aliased) perl(Config::Tiny) perl(DBIx::Class::DynamicDefault) perl(DBIx::Class::Schema::Config) perl(DBIx::Class::Storage::Statistics) perl(IO::Socket::INET6) perl(IO::Socket::SSL) perl(Data::Dump) perl(DBIx::Class::OptimisticLocking) perl(Mojolicious::Plugin::Bootstrap3) perl(Text::Markdown) perl(Net::DBus) perl(IPC::Run) perl(JavaScript::Minifier::XS) |
72 |
BuildRequires: perl(Mojolicious) >= 5.60 |
73 |
# (doktor5000) require minimum version, automatic requires generation detects this only as unversionned perl(Mojolicious::Lite) |
74 |
Requires: perl(Mojolicious) >= 5.60 |
75 |
# (doktor5000) require minimum version for critical bug fix |
76 |
# our perl module versioning differs from fedora |
77 |
# mga5 only has 0.82.700, might be important for backports |
78 |
BuildRequires: perl(DBIx::Class) >= 0.82.801 |
79 |
Requires: perl(DBIx::Class) >= 0.82.801 |
80 |
# needed for test suite |
81 |
BuildRequires: git |
82 |
# needed for saving needles optimized |
83 |
Requires: optipng |
84 |
BuildRequires: %{t_requires} |
85 |
Requires: dbus |
86 |
%ifarch %x86 x86_64 |
87 |
# These two are only used for some tests, we can skip 'em for now |
88 |
BuildRequires: phantomjs |
89 |
%endif |
90 |
BuildRequires: perl(Selenium::Remote::Driver) |
91 |
BuildRequires: perl(Test::Compile) |
92 |
BuildRequires: perl(DBIx::Class::DeploymentHandler) |
93 |
Requires(post): perl(DBIx::Class::DeploymentHandler) |
94 |
# (doktor5000) versionned Requires might be important for backports, we need is_literal_value function |
95 |
BuildRequires: perl(SQL::Abstract) >= 1.790.0 |
96 |
BuildRequires: perl(SQL::SplitStatement) |
97 |
# (doktor5000) not detected by automatic Requires generation |
98 |
Requires(post): perl(SQL::SplitStatement) |
99 |
BuildRequires: systemd |
100 |
%{?systemd_requires} |
101 |
# if EV is installed, Mojolicious will use it; but then workers won't |
102 |
# work, because EV conflicts with interpreter threads. |
103 |
# https://github.com/os-autoinst/openQA/issues/450 |
104 |
# FIXME: this may actually need to be in -worker, I'm not sure if |
105 |
# it's the webUI or the worker where we need to make sure EV is not |
106 |
# present (or both). |
107 |
Conflicts: perl(EV) |
108 |
BuildArch: noarch |
109 |
# we need to have the same sha1 as expected |
110 |
BuildRequires: perl-Mojolicious-Plugin-Bootstrap3 perl-Mojolicious-Plugin-AssetPack |
111 |
|
112 |
# (doktor5000) requires_eq might be expanded before BuildRequires have been resolved/satisfied, hence breaks spec parsing |
113 |
# see https://bugzilla.novell.com/show_bug.cgi?id=888467 for related information |
114 |
# and http://comments.gmane.org/gmane.linux.suse.opensuse.packaging/14693 |
115 |
|
116 |
# this is used to have the exact same versions as Requires wich where used as BuildRequires |
117 |
%requires_eq perl-Mojolicious-Plugin-Bootstrap3 perl-Mojolicious-Plugin-AssetPack |
118 |
|
119 |
# (doktor5000) recommend the workers subpackage - for a casual install of all openqa components on one server |
120 |
Recommends: %{name}-worker |
121 |
|
122 |
%description |
123 |
The openQA framework consists of two parts, which are tracked in |
124 |
separate git repositories. The OS-autoinst test engine and the front-end |
125 |
with web-interface, test-scheduler and other high-level logic, which |
126 |
is part of this repo. |
127 |
|
128 |
%package common |
129 |
Summary: The openQA common tools for web-frontend and workers |
130 |
Group: Development/Tools |
131 |
Requires: %{t_requires} |
132 |
|
133 |
%description common |
134 |
This package contain shared resources for openQA web-frontend and |
135 |
openQA workers. |
136 |
|
137 |
%package worker |
138 |
Summary: The openQA worker |
139 |
Group: Development/Tools |
140 |
Requires: openqa-common = %{version}-%{release} |
141 |
Requires(post): coreutils |
142 |
Requires(post): os-autoinst >= 4 |
143 |
Requires: os-autoinst < 5 |
144 |
# (doktor5000) needed in pre for the qemu user/group to exist, but we don't have a qemu user/group |
145 |
Requires: qemu |
146 |
# (doktor5000) not detected by automatic Requires generation |
147 |
Requires: perl(SQL::SplitStatement) |
148 |
|
149 |
%description worker |
150 |
The openQA worker manages test engine (provided by os-autoinst package). |
151 |
|
152 |
%prep |
153 |
%autosetup -p1 -n %{github_name}-%{github_commit} |
154 |
# GNU patch doesn't apply file mode? This goes with Patch0 |
155 |
chmod 0755 script/create_admin |
156 |
# Fedora calls it httpd.service, SUSE calls it apache2.service... |
157 |
sed -i -e 's,apache2\.service,httpd\.service,g' systemd/*.service |
158 |
# ...Fedora keeps httpd config here, SUSE keeps it there. |
159 |
sed -i -e 's,"$(DESTDIR)"/etc/apache2/vhosts.d,"$(DESTDIR)"%{_sysconfdir}/httpd/conf.d,g' Makefile |
160 |
sed -i -e 's,/etc/apache2/vhosts.d,%{_sysconfdir}/httpd/conf.d,g' etc/apache2/vhosts.d/* |
161 |
# These are the Fedora-y standard TLS cert/key locations. |
162 |
sed -i -e 's,/etc/apache2/ssl.crt,%{_sysconfdir}/pki/tls/certs,g' etc/apache2/vhosts.d/* |
163 |
sed -i -e 's,/etc/apache2/ssl.key,%{_sysconfdir}/pki/tls/private,g' etc/apache2/vhosts.d/* |
164 |
|
165 |
%build |
166 |
%make_build |
167 |
|
168 |
%check |
169 |
# we don't really need the tidy test |
170 |
rm -f t/00-tidy.t |
171 |
|
172 |
%make_build test |
173 |
|
174 |
%install |
175 |
%make_install |
176 |
mkdir -p %{buildroot}%{_datadir}/openqa/etc/openqa |
177 |
ln -s %{_sysconfdir}/openqa/openqa.ini %{buildroot}%{_datadir}/openqa/etc/openqa/openqa.ini |
178 |
ln -s %{_sysconfdir}/openqa/database.ini %{buildroot}%{_datadir}/openqa/etc/openqa/database.ini |
179 |
|
180 |
rm -rf /tmp/etc_openqa |
181 |
cp -a etc/openqa /tmp/etc_openqa |
182 |
export OPENQA_CONFIG=/tmp/etc_openqa |
183 |
export OPENQA_LOGFILE=/tmp/logfile |
184 |
rm -rf /tmp/db |
185 |
mkdir -p /tmp/db |
186 |
sed -i -e 's,/var/lib/openqa/db,/tmp/db,' /tmp/etc_openqa/database.ini |
187 |
# strange way to precompile assets :) |
188 |
./script/initdb --init_database |
189 |
./script/openqa version -m production |
190 |
cp -a public/packed %{buildroot}%{_datadir}/openqa/public/ |
191 |
|
192 |
cd %buildroot |
193 |
grep -rl /usr/bin/env . | while read file; do |
194 |
sed -e 's,/usr/bin/env perl,/usr/bin/perl,' -i $file |
195 |
done |
196 |
# Mojo cannot create a logfile if it doesn't exist: https://bugs.launchpad.net/mojo/+bug/1474224 |
197 |
# So we need to pre-create it, but we don't want it owned by the package, so |
198 |
# you don't lose logs on package uninstall. So we ghost it in the package |
199 |
# and create it in post. Here, we create it in the buildroot so it can be |
200 |
# ghosted. |
201 |
install -D -m 644 /dev/null %{buildroot}%{_localstatedir}/log/openqa |
202 |
# |
203 |
mkdir %{buildroot}%{_localstatedir}/lib/openqa/pool/1 |
204 |
# |
205 |
|
206 |
# We don't do AppArmor |
207 |
rm -rf %{buildroot}%{_sysconfdir}/apparmor.d |
208 |
|
209 |
%pre |
210 |
%_pre_useradd geekotest /var/lib/openqa /sbin/nologin |
211 |
|
212 |
%pre worker |
213 |
# (doktor5000) fedora seems to use qemu group to control qemu access |
214 |
# we don't have a qemu group, check if permissions of normal system user suffice |
215 |
%_pre_useradd _openqa-worker /dev/null /sbin/nologin |
216 |
|
217 |
%post |
218 |
# install empty log file (see above for reasoning) |
219 |
if [ ! -e /var/log/openqa ]; then |
220 |
install -D -m 644 -o geekotest /dev/null %{_localstatedir}/log/openqa || : |
221 |
fi |
222 |
|
223 |
# do database |
224 |
if [ $1 -eq 1 ]; then |
225 |
/usr/share/openqa/script/initdb --user geekotest --init_database || : |
226 |
|
227 |
echo "### copy and edit /etc/httpd/conf.d/openqa.conf.template!" |
228 |
fi |
229 |
|
230 |
%_post_service %openqa_services |
231 |
|
232 |
%post worker |
233 |
%tmpfiles_create %{_tmpfilesdir}/openqa.conf |
234 |
%_post_service %openqa_worker_services |
235 |
|
236 |
%preun |
237 |
%_preun_service %openqa_services |
238 |
|
239 |
%preun worker |
240 |
%_preun_service %openqa_worker_services |
241 |
|
242 |
|
243 |
%files |
244 |
%doc README.asciidoc docs/* |
245 |
%dir %{_sysconfdir}/openqa |
246 |
%config(noreplace) %attr(-,geekotest,root) %{_sysconfdir}/openqa/openqa.ini |
247 |
%config(noreplace) %attr(-,geekotest,root) %{_sysconfdir}/openqa/database.ini |
248 |
%dir %{_datadir}/openqa |
249 |
%dir %{_datadir}/openqa/etc |
250 |
%dir %{_datadir}/openqa/etc/openqa |
251 |
%{_datadir}/openqa/etc/openqa/openqa.ini |
252 |
%{_datadir}/openqa/etc/openqa/database.ini |
253 |
%config %{_sysconfdir}/logrotate.d |
254 |
%config(noreplace) %{_sysconfdir}/dbus-1/system.d/org.opensuse.openqa.conf |
255 |
# apache vhost |
256 |
%dir %{_sysconfdir}/httpd |
257 |
%dir %{_sysconfdir}/httpd/conf.d |
258 |
%config %{_sysconfdir}/httpd/conf.d/openqa.conf.template |
259 |
%config %{_sysconfdir}/httpd/conf.d/openqa-common.inc |
260 |
%config %{_sysconfdir}/httpd/conf.d/openqa-ssl.conf.template |
261 |
# init |
262 |
%dir %{_unitdir} |
263 |
%{_unitdir}/openqa-webui.service |
264 |
%{_unitdir}/openqa-gru.service |
265 |
%{_unitdir}/openqa-scheduler.service |
266 |
%{_unitdir}/openqa-websockets.service |
267 |
# web libs |
268 |
%{_datadir}/openqa/templates |
269 |
%{_datadir}/openqa/public |
270 |
%{_datadir}/openqa/dbicdh |
271 |
%{_datadir}/openqa/script/backlog |
272 |
%{_datadir}/openqa/script/check_dependencies |
273 |
%{_datadir}/openqa/script/clean_needles |
274 |
%{_datadir}/openqa/script/client |
275 |
%{_datadir}/openqa/script/clone_job.pl |
276 |
%{_datadir}/openqa/script/create_admin |
277 |
%{_datadir}/openqa/script/dump_templates |
278 |
%{_datadir}/openqa/script/fetchneedles |
279 |
%{_datadir}/openqa/script/initdb |
280 |
%{_datadir}/openqa/script/load_templates |
281 |
%{_datadir}/openqa/script/openqa |
282 |
%{_datadir}/openqa/script/openqa-scheduler |
283 |
%{_datadir}/openqa/script/openqa-websockets |
284 |
%{_datadir}/openqa/script/tidy |
285 |
%{_datadir}/openqa/script/upgradedb |
286 |
%{_datadir}/openqa/script/migrate_images |
287 |
# TODO: define final user |
288 |
%defattr(-,geekotest,root) |
289 |
# attention: never package subdirectories owned by a user other |
290 |
# than root as that opens a security hole! |
291 |
%dir %{_localstatedir}/lib/openqa/db |
292 |
%dir %{_localstatedir}/lib/openqa/images |
293 |
%{_localstatedir}/lib/openqa/testresults |
294 |
%dir %{_localstatedir}/lib/openqa/share |
295 |
%dir %{_localstatedir}/lib/openqa/share/tests |
296 |
%dir %{_localstatedir}/lib/openqa/share/factory |
297 |
%ghost %attr(0640,geekotest,root) %{_localstatedir}/lib/openqa/db/db.sqlite |
298 |
%ghost %{_localstatedir}/log/openqa |
299 |
|
300 |
%files common |
301 |
%dir %{_datadir}/openqa |
302 |
%{_datadir}/openqa/lib |
303 |
%dir %{_localstatedir}/lib/openqa |
304 |
%{_localstatedir}/lib/openqa/factory |
305 |
%{_localstatedir}/lib/openqa/script |
306 |
%{_localstatedir}/lib/openqa/tests |
307 |
|
308 |
%files worker |
309 |
%config(noreplace) %attr(0400,_openqa-worker,root) %{_sysconfdir}/openqa/client.conf |
310 |
%config(noreplace) %{_sysconfdir}/openqa/workers.ini |
311 |
# init |
312 |
%dir %{_unitdir} |
313 |
%{_prefix}/lib/systemd/system-generators |
314 |
%{_unitdir}/openqa-worker.target |
315 |
%{_unitdir}/openqa-worker@.service |
316 |
%{_unitdir}/openqa-slirpvde.service |
317 |
%{_unitdir}/openqa-vde_switch.service |
318 |
%{_tmpfilesdir}/openqa.conf |
319 |
%ghost %dir %{_rundir}/openqa |
320 |
# worker libs |
321 |
%dir %{_datadir}/openqa |
322 |
%dir %{_datadir}/openqa/script |
323 |
%{_datadir}/openqa/script/worker |
324 |
%dir %{_localstatedir}/lib/openqa/pool |
325 |
%defattr(-,_openqa-worker,root) |
326 |
# own one pool - to create the others is task of the admin |
327 |
%dir %{_localstatedir}/lib/openqa/pool/1 |
328 |
|