# Fedora spec initially based on upstream spec file from OBS: # https://build.opensuse.org/package/view_file/devel:openQA/openQA/openQA.spec # License: GPLv2+ # openQA doesn't provide its own libs as they're not in the path, # so we need to exclude the auto-requires for them %global __requires_exclude perl\\(OpenQA %global github_owner os-autoinst %global github_name openQA %global github_version 4.2 %global github_commit 9953cb8cc89f4e9187f4209035ce2990dbf544cc # if set, will be a post-release snapshot build, otherwise a 'normal' build #global github_date 20150814 %global shortcommit %(c=%{github_commit}; echo ${c:0:7}) # can't use linebreaks here! %global openqa_services openqa-webui.service openqa-gru.service openqa-websockets.service openqa-scheduler.service %global openqa_worker_services openqa-worker.target openqa-worker@.service openqa-slirpvde.service openqa-vde_switch.service Name: openqa Version: %{github_version} Release: %mkrel 4%{?github_date:.%{github_date}git%{shortcommit}} Summary: The openQA web-frontend, scheduler and tools License: GPLv2+ Group: Development/Tools Url: http://os-autoinst.github.io/openQA/ Source0: https://github.com/%{github_owner}/%{github_name}/archive/%{github_commit}/%{github_name}-%{github_commit}.tar.gz # Backport: add my admin user creation script # https://github.com/os-autoinst/openQA/commit/3678b8599f5fc269b24b62eb2efecc0169a64264 Patch0: 0001-add-a-script-to-create-admin-user-and-API-key.patch # Backport: don't make sqlite db world-readable # https://github.com/os-autoinst/openQA/commit/ca5371222096d4fb347124a353a9d868acf40c76 Patch1: 0001-the-sqlite-database-should-be-only-readable-by-the-o.patch # Backport: improve branding (removes the SUSE navbar) # https://github.com/os-autoinst/openQA/commit/fbe15becd89f0dc278457fd8f25b87e43d60079c # https://github.com/os-autoinst/openQA/commit/ab76b525eb9d436ecc5f3395cd7de89a0e272e86 Patch2: 0001-replace-tabs-with-spaces.patch Patch3: 0002-Improve-web-UI-branding-mechanism-drop-topbar-in-pla.patch Requires(pre): rpm-helper >= %{rpmhelper_required_version} Requires(post): rpm-helper >= %{rpmhelper_required_version} Requires(post): sqlite3-tools BuildRequires: os-autoinst Requires: openqa-common = %{version} Requires: perl(URI) # (doktor5000) require a working version, see (mga#17345) BuildRequires: ruby-sass >= 3.4.20 # needed for openid support Requires: perl(LWP::Protocol::https) # (doktor5000) require apache directly to ease setup as upstream template configs assume apache Requires: httpd # (doktor5000) pull in additional required apache modules Requires: apache-mod_proxy Requires: apache-mod_proxy_html # Recommends: logrotate # for postgresql # Recommends: perl(DateTime::Format::Pg) perl(DBD::Pg) # (doktor5000) perl Requires are autodetected, explicit Requires are disregarded # FIXME: this macro is used for packages that are both BuildRequires and Requires # runtime requirements that also the testsuite needs %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) BuildRequires: perl(Mojolicious) >= 5.60 # (doktor5000) require minimum version, automatic requires generation detects this only as unversionned perl(Mojolicious::Lite) Requires: perl(Mojolicious) >= 5.60 # (doktor5000) require minimum version for critical bug fix # our perl module versioning differs from fedora # mga5 only has 0.82.700, might be important for backports BuildRequires: perl(DBIx::Class) >= 0.82.801 Requires: perl(DBIx::Class) >= 0.82.801 # needed for test suite BuildRequires: git # needed for saving needles optimized Requires: optipng BuildRequires: %{t_requires} Requires: dbus %ifarch %x86 x86_64 # These two are only used for some tests, we can skip 'em for now BuildRequires: phantomjs %endif BuildRequires: perl(Selenium::Remote::Driver) BuildRequires: perl(Test::Compile) BuildRequires: perl(DBIx::Class::DeploymentHandler) Requires(post): perl(DBIx::Class::DeploymentHandler) # (doktor5000) versionned Requires might be important for backports, we need is_literal_value function BuildRequires: perl(SQL::Abstract) >= 1.790.0 BuildRequires: perl(SQL::SplitStatement) # (doktor5000) not detected by automatic Requires generation Requires(post): perl(SQL::SplitStatement) BuildRequires: systemd %{?systemd_requires} # if EV is installed, Mojolicious will use it; but then workers won't # work, because EV conflicts with interpreter threads. # https://github.com/os-autoinst/openQA/issues/450 # FIXME: this may actually need to be in -worker, I'm not sure if # it's the webUI or the worker where we need to make sure EV is not # present (or both). Conflicts: perl(EV) BuildArch: noarch # we need to have the same sha1 as expected BuildRequires: perl-Mojolicious-Plugin-Bootstrap3 perl-Mojolicious-Plugin-AssetPack # (doktor5000) requires_eq might be expanded before BuildRequires have been resolved/satisfied, hence breaks spec parsing # see https://bugzilla.novell.com/show_bug.cgi?id=888467 for related information # and http://comments.gmane.org/gmane.linux.suse.opensuse.packaging/14693 # this is used to have the exact same versions as Requires wich where used as BuildRequires %requires_eq perl-Mojolicious-Plugin-Bootstrap3 perl-Mojolicious-Plugin-AssetPack # (doktor5000) recommend the workers subpackage - for a casual install of all openqa components on one server Recommends: %{name}-worker %description The openQA framework consists of two parts, which are tracked in separate git repositories. The OS-autoinst test engine and the front-end with web-interface, test-scheduler and other high-level logic, which is part of this repo. %package common Summary: The openQA common tools for web-frontend and workers Group: Development/Tools Requires: %{t_requires} %description common This package contain shared resources for openQA web-frontend and openQA workers. %package worker Summary: The openQA worker Group: Development/Tools Requires: openqa-common = %{version}-%{release} Requires(post): coreutils Requires(post): os-autoinst >= 4 Requires: os-autoinst < 5 # (doktor5000) needed in pre for the qemu user/group to exist, but we don't have a qemu user/group Requires: qemu # (doktor5000) not detected by automatic Requires generation Requires: perl(SQL::SplitStatement) %description worker The openQA worker manages test engine (provided by os-autoinst package). %prep %autosetup -p1 -n %{github_name}-%{github_commit} # GNU patch doesn't apply file mode? This goes with Patch0 chmod 0755 script/create_admin # Fedora calls it httpd.service, SUSE calls it apache2.service... sed -i -e 's,apache2\.service,httpd\.service,g' systemd/*.service # ...Fedora keeps httpd config here, SUSE keeps it there. sed -i -e 's,"$(DESTDIR)"/etc/apache2/vhosts.d,"$(DESTDIR)"%{_sysconfdir}/httpd/conf.d,g' Makefile sed -i -e 's,/etc/apache2/vhosts.d,%{_sysconfdir}/httpd/conf.d,g' etc/apache2/vhosts.d/* # These are the Fedora-y standard TLS cert/key locations. sed -i -e 's,/etc/apache2/ssl.crt,%{_sysconfdir}/pki/tls/certs,g' etc/apache2/vhosts.d/* sed -i -e 's,/etc/apache2/ssl.key,%{_sysconfdir}/pki/tls/private,g' etc/apache2/vhosts.d/* %build %make %check # we don't really need the tidy test rm -f t/00-tidy.t %make test %install %make_install mkdir -p %{buildroot}%{_datadir}/openqa/etc/openqa ln -s %{_sysconfdir}/openqa/openqa.ini %{buildroot}%{_datadir}/openqa/etc/openqa/openqa.ini ln -s %{_sysconfdir}/openqa/database.ini %{buildroot}%{_datadir}/openqa/etc/openqa/database.ini rm -rf /tmp/etc_openqa cp -a etc/openqa /tmp/etc_openqa export OPENQA_CONFIG=/tmp/etc_openqa export OPENQA_LOGFILE=/tmp/logfile rm -rf /tmp/db mkdir -p /tmp/db sed -i -e 's,/var/lib/openqa/db,/tmp/db,' /tmp/etc_openqa/database.ini # strange way to precompile assets :) ./script/initdb --init_database ./script/openqa version -m production cp -a public/packed %{buildroot}%{_datadir}/openqa/public/ cd %buildroot grep -rl /usr/bin/env . | while read file; do sed -e 's,/usr/bin/env perl,/usr/bin/perl,' -i $file done # Mojo cannot create a logfile if it doesn't exist: https://bugs.launchpad.net/mojo/+bug/1474224 # So we need to pre-create it, but we don't want it owned by the package, so # you don't lose logs on package uninstall. So we ghost it in the package # and create it in post. Here, we create it in the buildroot so it can be # ghosted. install -D -m 644 /dev/null %{buildroot}%{_localstatedir}/log/openqa # mkdir %{buildroot}%{_localstatedir}/lib/openqa/pool/1 # # We don't do AppArmor rm -rf %{buildroot}%{_sysconfdir}/apparmor.d %pre %_pre_useradd geekotest /var/lib/openqa /sbin/nologin %pre worker # (doktor5000) fedora seems to use qemu group to control qemu access # we don't have a qemu group, check if permissions of normal system user suffice %_pre_useradd _openqa-worker /dev/null /sbin/nologin %post # install empty log file (see above for reasoning) if [ ! -e /var/log/openqa ]; then install -D -m 644 -o geekotest /dev/null %{_localstatedir}/log/openqa || : fi # do database if [ $1 -eq 1 ]; then /usr/share/openqa/script/initdb --user geekotest --init_database || : echo "### copy and edit /etc/httpd/conf.d/openqa.conf.template!" fi %systemd_post %openqa_services %post worker %tmpfiles_create %{_tmpfilesdir}/openqa.conf %systemd_post %openqa_worker_services %preun %systemd_preun %openqa_services %preun worker %systemd_preun %openqa_worker_services %postun %systemd_postun_with_restart %openqa_services %postun worker %systemd_postun_with_restart %openqa_worker_services %files %doc README.asciidoc docs/* %dir %{_sysconfdir}/openqa %config(noreplace) %attr(-,geekotest,root) %{_sysconfdir}/openqa/openqa.ini %config(noreplace) %attr(-,geekotest,root) %{_sysconfdir}/openqa/database.ini %dir %{_datadir}/openqa %dir %{_datadir}/openqa/etc %dir %{_datadir}/openqa/etc/openqa %{_datadir}/openqa/etc/openqa/openqa.ini %{_datadir}/openqa/etc/openqa/database.ini %config %{_sysconfdir}/logrotate.d %config(noreplace) %{_sysconfdir}/dbus-1/system.d/org.opensuse.openqa.conf # apache vhost %dir %{_sysconfdir}/httpd %dir %{_sysconfdir}/httpd/conf.d %config %{_sysconfdir}/httpd/conf.d/openqa.conf.template %config %{_sysconfdir}/httpd/conf.d/openqa-common.inc %config %{_sysconfdir}/httpd/conf.d/openqa-ssl.conf.template # init %dir %{_unitdir} %{_unitdir}/openqa-webui.service %{_unitdir}/openqa-gru.service %{_unitdir}/openqa-scheduler.service %{_unitdir}/openqa-websockets.service # web libs %{_datadir}/openqa/templates %{_datadir}/openqa/public %{_datadir}/openqa/dbicdh %{_datadir}/openqa/script/backlog %{_datadir}/openqa/script/check_dependencies %{_datadir}/openqa/script/clean_needles %{_datadir}/openqa/script/client %{_datadir}/openqa/script/clone_job.pl %{_datadir}/openqa/script/create_admin %{_datadir}/openqa/script/dump_templates %{_datadir}/openqa/script/fetchneedles %{_datadir}/openqa/script/initdb %{_datadir}/openqa/script/load_templates %{_datadir}/openqa/script/openqa %{_datadir}/openqa/script/openqa-scheduler %{_datadir}/openqa/script/openqa-websockets %{_datadir}/openqa/script/tidy %{_datadir}/openqa/script/upgradedb %{_datadir}/openqa/script/migrate_images # TODO: define final user %defattr(-,geekotest,root) # attention: never package subdirectories owned by a user other # than root as that opens a security hole! %dir %{_localstatedir}/lib/openqa/db %dir %{_localstatedir}/lib/openqa/images %{_localstatedir}/lib/openqa/testresults %dir %{_localstatedir}/lib/openqa/share %dir %{_localstatedir}/lib/openqa/share/tests %dir %{_localstatedir}/lib/openqa/share/factory %ghost %attr(0640,geekotest,root) %{_localstatedir}/lib/openqa/db/db.sqlite %ghost %{_localstatedir}/log/openqa %files common %dir %{_datadir}/openqa %{_datadir}/openqa/lib %dir %{_localstatedir}/lib/openqa %{_localstatedir}/lib/openqa/factory %{_localstatedir}/lib/openqa/script %{_localstatedir}/lib/openqa/tests %files worker %config(noreplace) %attr(0400,_openqa-worker,root) %{_sysconfdir}/openqa/client.conf %config(noreplace) %{_sysconfdir}/openqa/workers.ini # init %dir %{_unitdir} %{_prefix}/lib/systemd/system-generators %{_unitdir}/openqa-worker.target %{_unitdir}/openqa-worker@.service %{_unitdir}/openqa-slirpvde.service %{_unitdir}/openqa-vde_switch.service %{_tmpfilesdir}/openqa.conf %ghost %dir %{_rundir}/openqa # worker libs %dir %{_datadir}/openqa %dir %{_datadir}/openqa/script %{_datadir}/openqa/script/worker %dir %{_localstatedir}/lib/openqa/pool %defattr(-,_openqa-worker,root) # own one pool - to create the others is task of the admin %dir %{_localstatedir}/lib/openqa/pool/1