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

Add SUSE packaging support

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