%global app_root %{_datadir}/%{name}
%global semodule_name now
-%global commit0 7496c4388c785eee5c3115dc63eded398e17b349
+%global commit0 4cd4d76de20a2a6230fcae4bcb4718ef2105a84c
%global shortcommit0 %(c=%{commit0}; echo ${c:0:7})
%if 0%{?rhel} && 0%{?rhel} <= 7
# old rspec
%global with_tests 0
+%global selinux_pkg policycoreutils-python
%else
%global with_tests 1
+%global selinux_pkg policycoreutils-python-utils
%endif
Name: NOW
Version: 0.0.1
-Release: 0%{?dist}.20160918git%{shortcommit0}
+Release: 0.20160928git4cd4d76
Summary: Network Orchestrator Wrapper for OpenNebula
License: ASL 2.0
URL: https://github.com/CESNET/NOW
Source0: https://github.com/CESNET/%{name}/archive/%{commit0}.tar.gz#/%{name}-%{shortcommit0}.tar.gz
Source1: NOW.conf
+Source2: %{semodule_name}.te
+Source3: %{semodule_name}.fc
+Source4: README.Fedora
BuildArch: noarch
+BuildRequires: checkpolicy
+BuildRequires: %{selinux_pkg}
BuildRequires: ruby-devel
%if 0%{?with_tests}
BuildRequires: rubygem(bigdecimal)
BuildRequires: rubygem(sinatra)
BuildRequires: rubygem(sinatra-cross_origin)
%endif
+Requires(post): %{selinux_pkg}
+Requires(preun): %{selinux_pkg}
Requires(pre): shadow-utils
Requires: mod_passenger
Requires: rubygem(bigdecimal)
%build
+checkmodule -M -m -o %{semodule_name}.mod %{SOURCE2}
+semodule_package -o %{semodule_name}.pp -m %{semodule_name}.mod -f %{SOURCE3}
%install
rdoc --op rdoc/ models/ lib/ *.rb README*
mv rdoc %{buildroot}%{_pkgdocdir}/
+# Fedora README
+install -p -m 0644 %{SOURCE4} %{buildroot}%{_pkgdocdir}/
+
+# SELinux
+mkdir -p %{buildroot}%{_datadir}/selinux/packages/%{name}
+install -m 0644 %{semodule_name}.pp %{buildroot}%{_datadir}/selinux/packages/%{name}
+rm -f %{buildroot}%{app_root}/%{semodule_name}.mod
+rm -f %{buildroot}%{app_root}/%{semodule_name}.pp
+
%check
%if 0%{?with_tests}
getent passwd now >/dev/null || \
useradd -r -g now -d %{app_root} -s /sbin/nologin -c "NOW user" now
-# no SELinux support yet (will be similar to rOCCI server)
-%if 0
%post
if [ "$1" -le "1" ] ; then # First install
semodule -i %{_datadir}/selinux/packages/%{name}/%{semodule_name}.pp 2>/dev/null || :
- restorecon -R %{app_root} %{_localstatedir}/log/rocci-server 2>/dev/null || :
- semanage port -a -t http_port_t -p tcp 11443 2>/dev/null || :
+ restorecon -R %{app_root} 2>/dev/null || :
+ semanage port -a -t http_port_t -p tcp 2633 2>/dev/null || :
+ semanage port -a -t http_port_t -p tcp 11080 2>/dev/null || :
fi
%preun
if [ "$1" -lt "1" ] ; then # Final removal
semodule -r %{semodule_name} 2>/dev/null || :
- restorecon -R %{app_root} %{_localstatedir}/log/rocci-server 2>/dev/null || :
- semanage port -d -t http_port_t -p tcp 11443 2>/dev/null || :
+ restorecon -R %{app_root} 2>/dev/null || :
+ semanage port -d -t http_port_t -p tcp 2633 2>/dev/null || :
+ semanage port -d -t http_port_t -p tcp 11080 2>/dev/null || :
+fi
+
+%postun
+if [ "$1" -ge "1" ] ; then # Upgrade
+ semodule -i %{_datadir}/selinux/packages/%{name}/%{semodule_name}.pp 2>/dev/null || :
+ restorecon -R %{app_root} 2>/dev/null || :
fi
-%endif
%files
%dir %{app_root}/
%license %{app_root}/LICENSE
%license %{app_root}/NOTICE
+%{_pkgdocdir}/README.Fedora
%attr(0600, now, now) %config(noreplace) %{_sysconfdir}/now.yml
%config(noreplace) %{_sysconfdir}/httpd/conf.d/%{name}.conf
%{app_root}/models/
%{app_root}/templates/
%{app_root}/config.ru
%{app_root}/*.rb
+%{_datadir}/selinux/packages/%{name}/%{semodule_name}.pp
%files doc
%doc %{app_root}/README.md
%changelog
-* Sun Sep 18 2016 František Dvořák <valtri@civ.zcu.cz> - 0.0.1-0.20160918git7496c43
+* Wed Oct 19 2016 František Dvořák <valtri@civ.zcu.cz> - 0.0.1-0.20160928git4cd4d76
- Initial package