2018-03-07 11:11:57 +01:00
|
|
|
#
|
|
|
|
# spec file for package grafana
|
|
|
|
#
|
2019-01-11 16:50:03 +01:00
|
|
|
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
|
2018-03-07 11:11:57 +01:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2019-05-28 14:44:25 +02:00
|
|
|
# Please submit bugfixes or comments via https://bugs.opensuse.org/
|
2018-03-07 11:11:57 +01:00
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
%define GRAFANA_USER %{name}
|
|
|
|
%define GRAFANA_GROUP %{name}
|
2018-03-07 13:18:37 +01:00
|
|
|
%define GRAFANA_HOME %{_datadir}/%{name}
|
2018-03-07 11:11:57 +01:00
|
|
|
|
2018-05-07 08:18:24 +02:00
|
|
|
#Compat macro for new _fillupdir macro introduced in Nov 2017
|
|
|
|
%if ! %{defined _fillupdir}
|
|
|
|
%define _fillupdir /var/adm/fillup-templates
|
|
|
|
%endif
|
|
|
|
|
2019-08-08 16:15:00 +02:00
|
|
|
%bcond_with phantomjs
|
|
|
|
|
2018-03-07 11:11:57 +01:00
|
|
|
Name: grafana
|
2019-09-10 09:49:45 +02:00
|
|
|
Version: 6.3.5
|
2018-03-07 11:11:57 +01:00
|
|
|
Release: 0
|
|
|
|
Summary: Dashboards and editors for Graphite, InfluxDB, OpenTSDB
|
|
|
|
License: Apache-2.0
|
|
|
|
Group: System/Monitoring
|
|
|
|
Url: http://grafana.org/
|
|
|
|
Source: %{name}-%{version}.tar.xz
|
|
|
|
Source1: %{name}-rpmlintrc
|
2018-03-07 13:23:46 +01:00
|
|
|
# Instructions on the build process
|
|
|
|
Source2: README
|
|
|
|
# Makefile to automate build process
|
2019-08-08 16:15:00 +02:00
|
|
|
Source3: Makefile.no_phantomjs
|
|
|
|
Source4: Makefile.phantomjs
|
2018-03-07 11:11:57 +01:00
|
|
|
BuildRequires: fdupes
|
2018-10-31 10:18:34 +01:00
|
|
|
BuildRequires: go >= 1.11
|
2018-03-07 11:11:57 +01:00
|
|
|
BuildRequires: golang-packaging
|
|
|
|
BuildRequires: shadow
|
|
|
|
Requires(post): %insserv_prereq
|
|
|
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
2019-08-08 16:15:00 +02:00
|
|
|
%if %{with phantomjs}
|
|
|
|
BuildRequires: phantomjs
|
|
|
|
Requires: phantomjs
|
|
|
|
%endif
|
2018-03-07 11:11:57 +01:00
|
|
|
%{?systemd_requires}
|
|
|
|
|
|
|
|
%description
|
2018-03-07 17:32:44 +01:00
|
|
|
A graph and dashboard builder for visualizing time series metrics.
|
2018-03-07 11:11:57 +01:00
|
|
|
|
2018-03-07 17:32:44 +01:00
|
|
|
Grafana provides ways to create, explore, and share
|
|
|
|
dashboards and data with teams.
|
2018-03-07 11:11:57 +01:00
|
|
|
|
|
|
|
%prep
|
|
|
|
%setup -q -n grafana-%{version}
|
2019-08-08 16:15:00 +02:00
|
|
|
%if %{with phantomjs}
|
|
|
|
cp %{S:4} %_sourcedir/Makefile
|
|
|
|
%else
|
|
|
|
cp %{S:3} %_sourcedir/Makefile
|
|
|
|
%endif
|
2018-03-07 11:11:57 +01:00
|
|
|
|
|
|
|
%build
|
|
|
|
%goprep github.com/grafana/grafana
|
|
|
|
# Manual build in order to inject ldflags so grafana correctly displays
|
|
|
|
# the version in the footer of each page. Note that we're only injecting
|
|
|
|
# main.version, not main.commit or main.buildstamp as is done in the upstream
|
|
|
|
# build.go, because we don't have access to the git commit history here.
|
|
|
|
# (The %%gobuild macro can't take quoted strings; they get split up when
|
|
|
|
# expanded to $extra_flags in process_build() in /usr/lib/rpm/golang.sh.)
|
|
|
|
export IMPORTPATH="github.com/grafana/grafana"
|
2018-06-26 15:57:56 +02:00
|
|
|
export BUILDFLAGS="-v -p 4 -x -buildmode=pie"
|
2018-03-07 11:11:57 +01:00
|
|
|
export GOPATH=%{_builddir}/go:%{_builddir}/contrib
|
|
|
|
export GOBIN=%{_builddir}/go/bin
|
|
|
|
go install $BUILDFLAGS -ldflags '-X main.version=%{version}' $IMPORTPATH/pkg/cmd/...
|
|
|
|
|
|
|
|
%install
|
|
|
|
%goinstall
|
|
|
|
|
|
|
|
# we're missing %%gosrc and %%gofilelist... (although that *might* be ok...)
|
|
|
|
|
|
|
|
install -Dm644 {packaging/rpm/systemd/,%{buildroot}%{_unitdir}/}%{name}-server.service
|
|
|
|
install -dm755 %{buildroot}%{_sbindir}
|
|
|
|
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-server
|
|
|
|
mv %{buildroot}/%{_bindir}/grafana-* %{buildroot}/%{_sbindir}
|
|
|
|
|
|
|
|
install -Dm644 packaging/rpm/sysconfig/%{name}-server \
|
|
|
|
%{buildroot}%{_fillupdir}/sysconfig.%{name}-server
|
|
|
|
|
|
|
|
install -d -m0750 %{buildroot}%{_localstatedir}/lib/%{name}
|
|
|
|
install -d -m0750 %{buildroot}%{_localstatedir}/log/%{name}
|
|
|
|
install -d -m0755 %{buildroot}/%{_localstatedir}/lib/%{name}/plugins
|
|
|
|
install -d -m0755 %{buildroot}/%{_localstatedir}/lib/%{name}/dashboards
|
2019-01-11 16:50:03 +01:00
|
|
|
install -d -m0755 %{buildroot}%{_sysconfdir}/%{name}/provisioning/dashboards
|
2018-03-07 11:11:57 +01:00
|
|
|
|
|
|
|
install -Dm640 conf/sample.ini %{buildroot}%{_sysconfdir}/%{name}/%{name}.ini
|
|
|
|
install -Dm640 {conf/,%{buildroot}%{_sysconfdir}/%{name}/}ldap.toml
|
|
|
|
install -Dm644 {conf/,%{buildroot}%{_datadir}/%{name}/conf/}defaults.ini
|
|
|
|
install -m644 {conf/,%{buildroot}%{_datadir}/%{name}/conf/}sample.ini
|
2019-01-11 16:50:03 +01:00
|
|
|
install -Dm644 {conf/provisioning/dashboards/,%{buildroot}%{_datadir}/%{name}/conf/provisioning/dashboards/}sample.yaml
|
|
|
|
install -Dm644 {conf/provisioning/datasources/,%{buildroot}%{_datadir}/%{name}/conf/provisioning/datasources/}sample.yaml
|
2018-03-07 11:11:57 +01:00
|
|
|
cp -pr public %{buildroot}%{_datadir}/%{name}/
|
|
|
|
install -d -m755 %{buildroot}%{_datadir}/%{name}/vendor
|
|
|
|
install -d -m755 %{buildroot}%{_datadir}/%{name}/tools
|
|
|
|
|
2019-08-08 16:15:00 +02:00
|
|
|
%if %{with phantomjs}
|
|
|
|
# phantomjs is used for rendering PNG images of graphs. The frontend asset
|
|
|
|
# build process downloadsa prebuilt x86_64 binary, which ends up in
|
|
|
|
# vendor/phantomjs/phantomjs. This is ugly but works for x86_64. It naturally
|
|
|
|
# will not work for other architectures, so instead we remove the phantomjs
|
|
|
|
# binary and install a symlink to the systemwide /usr/bin/phantomjs.
|
|
|
|
cp -pr tools/phantomjs %{buildroot}%{_datadir}/%{name}/tools/
|
|
|
|
rm -f %{buildroot}%{_datadir}/%{name}/tools/phantomjs/phantomjs
|
|
|
|
ln -s %{_bindir}/phantomjs %{buildroot}%{_datadir}/%{name}/tools/phantomjs/phantomjs
|
|
|
|
%endif
|
|
|
|
|
2018-03-07 11:11:57 +01:00
|
|
|
# Do *not* use %%fudpes -s -- this will result in grafana failing to load
|
|
|
|
# all the plugins (something in the plugin scanner can't cope with files
|
|
|
|
# in there being symlinks).
|
|
|
|
%fdupes %{buildroot}/%{_datadir}
|
|
|
|
|
|
|
|
%check
|
|
|
|
#gotest github.com/grafana/grafana/pkg...
|
|
|
|
|
|
|
|
%pre
|
|
|
|
%service_add_pre %{name}-server.service
|
|
|
|
|
2018-03-07 13:18:37 +01:00
|
|
|
echo "Creating user %{GRAFANA_USER} and group %{GRAFANA_GROUP} if not present"
|
|
|
|
getent group %{GRAFANA_GROUP} > /dev/null || groupadd -r %{GRAFANA_GROUP}
|
|
|
|
getent passwd %{GRAFANA_GROUP} > /dev/null || useradd -r -g %{GRAFANA_GROUP} \
|
|
|
|
-d %{GRAFANA_HOME} -s /sbin/nologin -c "%{GRAFANA_USER} user" %{GRAFANA_GROUP}
|
2018-03-07 11:11:57 +01:00
|
|
|
|
|
|
|
%post
|
|
|
|
%{fillup_only -n %{name}-server}
|
|
|
|
%service_add_post %{name}-server.service
|
|
|
|
|
|
|
|
%preun
|
|
|
|
%service_del_preun %{name}-server.service
|
|
|
|
|
|
|
|
%postun
|
|
|
|
%service_del_postun %{name}-server.service
|
|
|
|
|
|
|
|
%files
|
|
|
|
%defattr(-,root,root)
|
2019-05-28 14:44:25 +02:00
|
|
|
%license LICENSE*
|
|
|
|
%doc CHANGELOG*
|
2018-03-07 11:11:57 +01:00
|
|
|
%{_sbindir}/%{name}*
|
|
|
|
%{_sbindir}/rc%{name}-server
|
|
|
|
%{_unitdir}/%{name}-server.service
|
|
|
|
%{_fillupdir}/sysconfig.%{name}-server
|
2019-07-11 10:39:07 +02:00
|
|
|
%attr(0755,root,root) %dir %{_sysconfdir}/%{name}
|
|
|
|
%attr(0755,root,root) %dir %{_sysconfdir}/%{name}/provisioning
|
|
|
|
%attr(0755,root,root) %dir %{_sysconfdir}/%{name}/provisioning/dashboards
|
|
|
|
%attr(0755,root,%{GRAFANA_GROUP}) %dir %{_datadir}/%{name}/conf
|
2018-03-07 11:11:57 +01:00
|
|
|
%attr(0640,root,%{GRAFANA_GROUP}) %config(noreplace) %{_sysconfdir}/%{name}/%{name}.ini
|
|
|
|
%attr(0640,root,%{GRAFANA_GROUP}) %config(noreplace) %{_sysconfdir}/%{name}/ldap.toml
|
2019-07-11 10:39:07 +02:00
|
|
|
%attr(0755,%{GRAFANA_USER},%{GRAFANA_GROUP}) %dir %{_localstatedir}/lib/%{name}
|
|
|
|
%attr(0755,%{GRAFANA_USER},%{GRAFANA_GROUP}) %dir %{_localstatedir}/lib/%{name}/plugins
|
|
|
|
%attr(0755,%{GRAFANA_USER},%{GRAFANA_GROUP}) %dir %{_localstatedir}/lib/%{name}/dashboards
|
2018-03-07 11:11:57 +01:00
|
|
|
%attr(0750,%{GRAFANA_USER},%{GRAFANA_GROUP}) %dir %{_localstatedir}/log/%{name}
|
|
|
|
%doc %{_datadir}/%{name}/conf/sample.ini
|
2019-01-11 16:50:03 +01:00
|
|
|
%doc %{_datadir}/%{name}/conf/provisioning/dashboards/sample.yaml
|
|
|
|
%doc %{_datadir}/%{name}/conf/provisioning/datasources/sample.yaml
|
2018-03-07 11:11:57 +01:00
|
|
|
%config %{_datadir}/%{name}/conf/defaults.ini
|
|
|
|
%{_datadir}/%{name}
|
|
|
|
|
|
|
|
%changelog
|