icingadb.spec 1.89 KB
Newer Older
Alexander A. Klimov's avatar
Alexander A. Klimov committed
1 2 3
%define revision 1
%define debug_package %{nil}

Markus Frosch's avatar
Markus Frosch committed
4 5 6
%global commit          f10596b960b05a492f4524c123a2522d4626a6e0
%global shortcommit     %(c=%{commit}; echo ${c:0:7})

Alexander A. Klimov's avatar
Alexander A. Klimov committed
7
Name:       icingadb
Markus Frosch's avatar
Markus Frosch committed
8
Version:    0.0.0.%{shortcommit}
Alexander A. Klimov's avatar
Alexander A. Klimov committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
Release:    %{revision}%{?dist}
Summary:    Icinga DB
Group:      System Environment/Daemons
License:    GPLv2+
URL:        https://git.icinga.com/icingadb/icingadb
Source0:    %{name}-%{version}.tar.gz

BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}
BuildRequires:  golang git

%{?systemd_requires}
BuildRequires:  systemd

Requires(pre):  shadow-utils

Provides:   user(icingadb)
Provides:   group(icingadb)

%define configdir %{_sysconfdir}/%{name}
%define service %{name}.service
%define gopath %{_tmppath}/%{name}-%{version}-%{release}-gopath


%description
Icinga DB

%prep
Markus Frosch's avatar
Markus Frosch committed
36
%setup -q -n %{name}-%{commit}
Alexander A. Klimov's avatar
Alexander A. Klimov committed
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

%build
mkdir -p %{gopath}/src/git.icinga.com/icingadb
ln -s $(pwd) %{gopath}/src/git.icinga.com/icingadb/icingadb
GOPATH=%{gopath} go get git.icinga.com/icingadb/icingadb
GOPATH=%{gopath} go install git.icinga.com/icingadb/icingadb

%install
mkdir -p %{buildroot}%{_sbindir}
mkdir -p %{buildroot}%{configdir}
mkdir -p %{buildroot}%{_unitdir}
cp %{gopath}/bin/icingadb %{buildroot}%{_sbindir}
cp etc/config_production.ini %{buildroot}%{configdir}/config.ini
cp etc/%{service} %{buildroot}%{_unitdir}

%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

%post
%systemd_post %{service}

%preun
%systemd_preun %{service}

%postun
%systemd_postun %{service}

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root)
#%doc AUTHORS COPYING
%attr(0755,icingadb,icingadb) %{_sbindir}/icingadb
%attr(0750,icingadb,icingadb) %config(noreplace) %dir %{configdir}
%attr(0640,icingadb,icingadb) %config(noreplace) %{configdir}/config.ini
%attr(0644,root,root) %{_unitdir}/%{service}