Commit 777beae3 authored by Markus Frosch's avatar Markus Frosch 📣

Add SUSE packaging support

parent 38f5d95b
......@@ -10,7 +10,14 @@
%global commit f10596b960b05a492f4524c123a2522d4626a6e0
%global shortcommit %(c=%{commit}; echo ${c:0:7})
%global golang_min_version 1.10
%if "%{_vendor}" == "suse"
%global golang_pkg go
%else # suse
%global golang_pkg golang
%global golang_scl go-toolset-7
%endif # suse
%if 0%{?golang_scl:1}
%global golang_scl_prefix %{golang_scl}-
......@@ -30,13 +37,17 @@ Version: 0.0.0.%{shortcommit}
Release: %{revision}%{?dist}
Summary: Icinga DB
Group: System Environment/Daemons
%if "%{_vendor}" == "suse"
License: GPL-2.0-or-later
%else
License: GPLv2+
%endif # suse
URL: https://%{provider_prefix}
Source0: https://%{import_path}/-/archive/%{commit}/%{repo}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}
BuildRequires: %{?golang_scl_prefix}golang >= 1.10
BuildRequires: %{?golang_scl_prefix}%{golang_pkg} >= %{golang_min_version}
BuildRequires: git
%{?systemd_requires}
......@@ -47,7 +58,7 @@ Requires(pre): shadow-utils
%if "%{_vendor}" == "suse"
Provides: user(icingadb)
Provides: group(icingadb)
%endif
%endif # suse
%define configdir %{_sysconfdir}/%{name}
%define service %{name}.service
......@@ -88,18 +99,38 @@ install -m 0755 icingadb %{buildroot}%{_sbindir}/
install -m 0644 etc/config_production.ini %{buildroot}%{configdir}/config.ini
install -m 0644 etc/%{service} %{buildroot}%{_unitdir}/
%if "%{_vendor}" == "suse"
ln -sf /usr/sbin/service %{buildroot}%{_sbindir}/rc%{name}
%endif # suse
%pre
getent group icingadb >/dev/null || groupadd -r icingadb
getent passwd icingadb >/dev/null || useradd -r -g icingadb -d / -s /sbin/nologin -c 'Icinga DB' icingadb
%if "%{_vendor}" == "suse"
%service_add_pre %{service}
%endif # suse
%post
%if "%{_vendor}" == "suse"
%service_add_post %{service}
%else # suse
%systemd_post %{service}
%endif # suse
%preun
%if "%{_vendor}" == "suse"
%service_del_preun %{service}
%else # suse
%systemd_preun %{service}
%endif # suse
%postun
%if "%{_vendor}" == "suse"
%service_del_postun %{service}
%else # suse
%systemd_postun %{service}
%endif # suse
%clean
rm -rf %{buildroot}
......@@ -111,6 +142,10 @@ rm -rf %{buildroot}
%{_sbindir}/icingadb
%{_unitdir}/%{service}
%if "%{_vendor}" == "suse"
%{_sbindir}/rc%{name}
%endif # suse
%defattr(0640,icingadb,icingadb,0750)
%dir %{configdir}
......
......@@ -5,3 +5,7 @@ addFilter("W: unversioned-explicit-provides group\(icingadb\)")
# we want secure permissions
addFilter("E: non-standard-dir-perm /etc/icingadb 0750L")
addFilter("E: non-readable /etc/icingadb/config.ini 0640L")
# we want our daemon user
addFilter("W: non-standard-uid /etc/icingadb.* icingadb")
addFilter("W: non-standard-gid /etc/icingadb.* icingadb")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment