Accepting request 583279 from security:logging

server:monitoring seems to be a better place for grafana then security:logging.

OBS-URL: https://build.opensuse.org/request/show/583279
OBS-URL: https://build.opensuse.org/package/show/server:monitoring/grafana?expand=0&rev=1
This commit is contained in:
Marcus Rückert 2018-03-07 10:11:57 +00:00 committed by Git OBS Bridge
commit f504c80fe4
10 changed files with 2454 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.osc

33
Makefile Normal file
View File

@ -0,0 +1,33 @@
NAME = grafana
SPEC = $(NAME).spec
default: verify-deps clean tar
verify-deps:
@which yarn >/dev/null 2>&1 || ( echo "yarn not found; run \`sudo npm install -g yarn\`" && false )
@which grunt >/dev/null 2>&1 || ( echo "grunt not found; run \`sudo npm install -g grunt-cli\`" && false )
clean:
rm -f $(NAME)-*.tar $(NAME)-*.tar.xz
tar:
osc service disabledrun
@version=$$( awk '/^Version:/ {print $$2}' $(SPEC) ) && \
echo "Package version is $$version" && \
basename=$(NAME)-$$version && \
tar=$$basename.tar && \
tmpdir=$$(mktemp -d -p .) && \
cd $$tmpdir && \
tar -xf ../$$tar && \
cd $$basename && \
sed -i 's/base\///' public/sass/base/_fonts.scss && \
yarn install --pure-lockfile && \
grunt release && \
cp -pr tmp/public . && \
cp -pr tmp/tools . && \
cd .. && \
echo "Updating $$basename/tools $$basename/public in tarball..." && \
tar -rf ../$$tar $$basename/tools $$basename/public && \
cd .. && \
xz $$tar && \
rm -rf $$tmpdir

28
README Normal file
View File

@ -0,0 +1,28 @@
The tarball is generated via the OBS source service, but Grafana
needs to ship the compiled frontend assets as well, which have to
be built by running yarn and grunt inside the source tree (see
https://github.com/grafana/grafana#building-frontend-assets).
This can't be done at build time on OBS, because it involves
downloading and installing packages from the internet, so instead
we have a Makefile which does the following:
- Runs `osc service disabledrun` to get the latest source tarball
- Unpacks the tarball to a temporary directory
- Runs `yarn install --pure-lockfile && grunt release`
- Adds the generated "vendor" and "public" content to the tarball,
then compresses it with xz.
- The tarball can then be used by OBS to build an RPM.
In order for this to work you need to have npm6, yarn and grunt
installed. To get set up, run:
# zypper in npm6
# npm install -g yarn
# npm install -g grunt-cli
Then, to package a new release of Grafana, run `make` then `osc ci`
and you should be good.
Please direct any questions to Tim Serong <tserong@suse.com>

13
_service Normal file
View File

@ -0,0 +1,13 @@
<services>
<service name="tar_scm" mode="disabled">
<param name="url">https://github.com/grafana/grafana</param>
<param name="scm">git</param>
<param name="exclude">.git</param>
<param name="versionformat">5.0.0</param>
<param name="revision">v5.0.0</param>
<param name="changesgenerate">enable</param>
</service>
<service name="set_version" mode="disabled">
<param name="basename">grafana</param>
</service>
</services>

4
_servicedata Normal file
View File

@ -0,0 +1,4 @@
<servicedata>
<service name="tar_scm">
<param name="url">https://github.com/grafana/grafana</param>
<param name="changesrevision">af6e28366bf3413ee3af56c540513dd70f467c41</param></service></servicedata>

3
grafana-5.0.0.tar.xz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:5647b158b4961fba4f70c945c74610a4baf25eca607aa892a22d3582d83cfed1
size 30139268

2
grafana-rpmlintrc Normal file
View File

@ -0,0 +1,2 @@
addFilter("binaryinfo-readelf-failed") # go binaries are suposedly ELF-compliant
addFilter("no-manual-page-for-binary")

2190
grafana.changes Normal file

File diff suppressed because it is too large Load Diff

157
grafana.spec Normal file
View File

@ -0,0 +1,157 @@
#
# spec file for package grafana
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#
%define GRAFANA_USER %{name}
%define GRAFANA_GROUP %{name}
Name: grafana
Version: 5.0.0
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
Requires: phantomjs
# Needed as a BuildRequires too, so setting up a symlink will work
BuildRequires: phantomjs
BuildRequires: fdupes
BuildRequires: golang-packaging
BuildRequires: libgcc_s1
BuildRequires: shadow
BuildRequires: go >= 1.8
Requires(post): %insserv_prereq
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%{?systemd_requires}
%description
The leading graph and dashboard builder for visualizing time series metrics.
Grafana provides a powerful and elegant way to create, explore, and share
dashboards and data with your team and the world.
%prep
%setup -q -n grafana-%{version}
%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"
export BUILDFLAGS="-s -v -p 4 -x -buildmode=pie"
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
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
cp -pr public %{buildroot}%{_datadir}/%{name}/
install -d -m755 %{buildroot}%{_datadir}/%{name}/vendor
install -d -m755 %{buildroot}%{_datadir}/%{name}/tools
# 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 %{buildroot}%{_datadir}/%{name}/tools/phantomjs/phantomjs
ln -s %{_bindir}/phantomjs %{buildroot}%{_datadir}/%{name}/tools/phantomjs/phantomjs
# 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
if [ $1 -eq 1 ]; then
if ! %{_bindir}/id %{GRAFANA_USER} &>/dev/null; then
echo -n "Create a new group %{GRAFANA_GROUP}:"
%{_sbindir}/groupadd -r %{GRAFANA_GROUP} ||:
echo "... done"
echo -n "Create a new user %{GRAFANA_USER}:"
%{_sbindir}/useradd -r -g %{GRAFANA_GROUP} -d %{_datadir}/%{name} \
-s /sbin/nologin -c "%{GRAFANA_USER} user" %{GRAFANA_GROUP}
echo "... done";
fi
fi
%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
if [ $1 -eq 0 ]; then
userdel %{GRAFANA_USER} || logger "User \"%{GRAFANA_USER}\" could not be deleted."
groupdel %{GRAFANA_GROUP} || logger "Group \"%{GRAFANA_GROUP}\" could not be deleted."
rm -rf %{_localstatedir}/lib/%{name}
rm -rf %{_localstatedir}/log/%{name}; fi
%files
%defattr(-,root,root)
%doc CHANGELOG* LICENSE*
%{_sbindir}/%{name}*
%{_sbindir}/rc%{name}-server
%{_unitdir}/%{name}-server.service
%{_fillupdir}/sysconfig.%{name}-server
%attr(0750,root,%{GRAFANA_GROUP}) %dir %{_sysconfdir}/%{name}
%attr(0750,root,%{GRAFANA_GROUP}) %dir %{_datadir}/%{name}/conf
%attr(0640,root,%{GRAFANA_GROUP}) %config(noreplace) %{_sysconfdir}/%{name}/%{name}.ini
%attr(0640,root,%{GRAFANA_GROUP}) %config(noreplace) %{_sysconfdir}/%{name}/ldap.toml
%attr(0750,%{GRAFANA_USER},%{GRAFANA_GROUP}) %dir %{_localstatedir}/lib/%{name}
%attr(0750,%{GRAFANA_USER},%{GRAFANA_GROUP}) %dir %{_localstatedir}/lib/%{name}/plugins
%attr(0750,%{GRAFANA_USER},%{GRAFANA_GROUP}) %dir %{_localstatedir}/lib/%{name}/dashboards
%attr(0750,%{GRAFANA_USER},%{GRAFANA_GROUP}) %dir %{_localstatedir}/log/%{name}
%doc %{_datadir}/%{name}/conf/sample.ini
%config %{_datadir}/%{name}/conf/defaults.ini
%{_datadir}/%{name}
%changelog