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

4 5 6 7 8 9 10
%global provider        git.icinga
%global provider_tld    com
%global project         icingadb
%global repo            icingadb
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
%global import_path     %{provider_prefix}

Markus Frosch's avatar
Markus Frosch committed
11 12 13
%global commit          f10596b960b05a492f4524c123a2522d4626a6e0
%global shortcommit     %(c=%{commit}; echo ${c:0:7})

14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
%global golang_scl      go-toolset-7

%if 0%{?golang_scl:1}
%global golang_scl_prefix %{golang_scl}-
%global golang_scl_enable scl enable %{golang_scl} --
%endif

%if ! 0%{?gobuild:1}
%define gobuild(o:) %{?golang_scl_enable} go build -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n')" -a -v -x %{?**};
%endif

%if ! 0%{?gopath:1}
%define gopath %(%{?golang_scl_enable} go env GOPATH)
%endif

Alexander A. Klimov's avatar
Alexander A. Klimov committed
29
Name:       icingadb
Markus Frosch's avatar
Markus Frosch committed
30
Version:    0.0.0.%{shortcommit}
Alexander A. Klimov's avatar
Alexander A. Klimov committed
31 32 33 34
Release:    %{revision}%{?dist}
Summary:    Icinga DB
Group:      System Environment/Daemons
License:    GPLv2+
35
URL:        https://%{provider_prefix}
Alexander A. Klimov's avatar
Alexander A. Klimov committed
36 37 38
Source0:    %{name}-%{version}.tar.gz

BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}
39 40 41

BuildRequires:  %{?golang_scl_prefix}golang >= 1.10
BuildRequires:  git
Alexander A. Klimov's avatar
Alexander A. Klimov committed
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57

%{?systemd_requires}
BuildRequires:  systemd

Requires(pre):  shadow-utils

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

%define configdir %{_sysconfdir}/%{name}
%define service %{name}.service

%description
Icinga DB

%prep
Markus Frosch's avatar
Markus Frosch committed
58
%setup -q -n %{name}-%{commit}
Alexander A. Klimov's avatar
Alexander A. Klimov committed
59 60

%build
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
mkdir -p src/%{provider}.%{provider_tld}/%{project}
ln -s ../../../ src/%{import_path}

export GOPATH=$(pwd):%{gopath}

pushd src/%{import_path}
%gobuild .
popd

%check
export GOPATH=%{buildroot}/%{gopath}:%{gopath}

%if ! 0%{?gotest:1}
%global gotest %{?golang_scl_enable} go test
%endif

%gotest %{import_path}/...
Alexander A. Klimov's avatar
Alexander A. Klimov committed
78 79

%install
80 81 82 83 84 85 86
install -d -m 0755 %{buildroot}%{_sbindir}
install -d -m 0755 %{buildroot}%{configdir}
install -d -m 0755 %{buildroot}%{_unitdir}

install -m 0755 icingadb %{buildroot}%{_sbindir}/
install -m 0644 etc/config_production.ini %{buildroot}%{configdir}/config.ini
install -m 0644 etc/%{service} %{buildroot}%{_unitdir}/
Alexander A. Klimov's avatar
Alexander A. Klimov committed
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106

%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
107 108 109 110 111 112 113
%{_sbindir}/icingadb
%{_unitdir}/%{service}

%defattr(0750,icingadb,icingadb,0640)

%dir %{configdir}
%config(noreplace) %{configdir}/config.ini