File influxdb.spec of Package influxdb
#
# spec file for package influxdb
#
# Copyright (c) 2020 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%if 0%{?suse_version} > 1230 || 0%{?rhel_version} > 6 || 0%{?centos_version} > 6 || 0%{?fedora_version} >= 20 || 0%{?el7}%{?fc20}%{?fc21}%{?fc22}
%bcond_without systemd
%else
%bcond_with systemd
%endif
Name: influxdb
Summary: Scalable datastore for metrics, events, and real-time analytics
License: MIT
Group: Productivity/Databases/Servers
Version: 1.3.8
Release: 0
URL: https://github.com/influxdata/influxdb
Source: %{name}-%{version}.tar.xz
Source1: influxdb.service
Source2: influxdb.tmpfiles
Source3: influxdb.init
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: asciidoc
BuildRequires: fdupes
BuildRequires: go >= 1.8.1
BuildRequires: golang-packaging
BuildRequires: xmlto
%if %{with systemd}
BuildRequires: systemd-rpm-macros
%{!?_tmpfilesdir:%global _tmpfilesdir /usr/lib/tmpfiles.d}
%endif
Requires(pre): pwdutils
%if %{with systemd}
%{systemd_requires}
Requires(post): systemd
%else
Requires(pre): %fillup_prereq
Requires(pre): %insserv_prereq
%endif
%description
InfluxDB is an open source distributed time series database with no external dependencies. It's useful for recording metrics, events, and performing analytics.
%package devel
Summary: InfluxDB development files
Group: Development/Languages/Golang
%description devel
Go sources and other development files for InfluxDB
%prep
%setup -q -n %{name}-%{version}
%build
# Disable phone-home to usage.influxdata.com
sed -i 's/.*reporting-disabled = false/reporting-disabled = true/' etc/config.sample.toml
%goprep github.com/influxdata/influxdb
%gobuild -ldflags="-X main.version=%{version}" cmd/...
make -C ./man build
%install
%gosrc
%fdupes -s %{buildroot}/%{go_contribsrcdir}/github.com/influxdata/influxdb
mkdir -p %{buildroot}%{_sysconfdir}/influxdb
install -D -m 644 etc/config.sample.toml %{buildroot}%{_sysconfdir}/influxdb/config.toml
mkdir -p %{buildroot}%{_localstatedir}/log/influxdb
mkdir -p %{buildroot}%{_localstatedir}/lib/influxdb
mkdir -p %{buildroot}%{_localstatedir}/lib/influxdb/{data,meta,hh,wal}
mkdir -p %{buildroot}%{_sbindir}
%if %{with systemd}
install -D -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/influxdb.service
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rcinfluxdb
install -D -m 0644 %{SOURCE2} %{buildroot}%{_tmpfilesdir}/influxdb.conf
%else
%{__install} -D -m 0755 %{S:3} %{buildroot}%{_sysconfdir}/init.d/influxdb
%{__ln_s} -f %{_sysconfdir}/init.d/influxdb %{buildroot}%{_sbindir}/rcinfluxdb
mkdir -p %{buildroot}%{_localstatedir}/run/influxdb
%endif
%{__install} -D -m 0755 %{_builddir}/go/bin/* %{buildroot}%{_bindir}
make -C ./man install DESTDIR=%{buildroot}%{_prefix}
%check
#%%gotest github.com/influxdata/influxdb
%pre
getent group influxdb >/dev/null || groupadd -r influxdb
getent passwd influxdb >/dev/null || useradd -r -g influxdb \
-d %{_localstatedir}/lib/influxdb \
-s /sbin/nologin \
-c "user for InfluxDB database server" influxdb
%if %{with systemd}
%service_add_pre influxdb.service
%endif
%preun
%if %{with systemd}
%service_del_preun influxdb.service
%else
%stop_on_removal influxdb
%endif
%if %{with systemd}
%post
systemd-tmpfiles --create /usr/lib/tmpfiles.d/influxdb.conf || true
%service_add_post influxdb.service
%endif
%postun
%if %{with systemd}
%service_del_postun influxdb.service
%else
%restart_on_update influxdb
%insserv_cleanup
%endif
%files
%defattr(-,root,root,-)
%doc LICENSE LICENSE_OF_DEPENDENCIES.md QUERIES.md README.md CHANGELOG.md
%dir %{_sysconfdir}/influxdb
%config %{_sysconfdir}/influxdb/config.toml
%{_bindir}/influx
%{_bindir}/influx_inspect
%{_bindir}/influxd
%{_bindir}/influx_stress
%{_bindir}/influx_tsm
%{_sbindir}/rcinfluxdb
%if %{with systemd}
%{_unitdir}/influxdb.service
%dir %{_tmpfilesdir}
%{_tmpfilesdir}/influxdb.conf
%else
/etc/init.d/influxdb
%attr(0755, influxdb, influxdb) %dir %{_localstatedir}/run/influxdb
%endif
%attr(0755, influxdb, influxdb) %dir %{_localstatedir}/log/influxdb
%attr(0755, influxdb, influxdb) %dir %{_localstatedir}/lib/influxdb
%attr(0755, influxdb, influxdb) %dir %{_localstatedir}/lib/influxdb/meta
%attr(0755, influxdb, influxdb) %dir %{_localstatedir}/lib/influxdb/data
%attr(0755, influxdb, influxdb) %dir %{_localstatedir}/lib/influxdb/hh
%attr(0700, influxdb, influxdb) %dir %{_localstatedir}/lib/influxdb/wal
%{_mandir}/man1/influx.1.gz
%{_mandir}/man1/influx_inspect.1.gz
%{_mandir}/man1/influx_stress.1.gz
%{_mandir}/man1/influx_tsm.1.gz
%{_mandir}/man1/influxd-backup.1.gz
%{_mandir}/man1/influxd-config.1.gz
%{_mandir}/man1/influxd-restore.1.gz
%{_mandir}/man1/influxd-run.1.gz
%{_mandir}/man1/influxd-version.1.gz
%{_mandir}/man1/influxd.1.gz
%files devel
%defattr(-,root,root,-)
%doc LICENSE LICENSE_OF_DEPENDENCIES.md
%if 0%{?suse_version} == 1315 && 0%{?is_opensuse}
%dir %{_datadir}/go/contrib
%dir %{_datadir}/go/contrib/src
%endif
%dir %{go_contribsrcdir}/github.com
%dir %{go_contribsrcdir}/github.com/influxdata
%{go_contribsrcdir}/github.com/influxdata/influxdb
%changelog