Blame SPECS/grafana.spec

50fcc5
%global grafana_arches %{lua: go_arches = {}
50fcc5
  for arch in rpm.expand("%{go_arches}"):gmatch("%S+") do
50fcc5
    go_arches[arch] = 1
50fcc5
  end
50fcc5
  for arch in rpm.expand("%{nodejs_arches}"):gmatch("%S+") do
50fcc5
    if go_arches[arch] then
50fcc5
      print(arch .. " ")
50fcc5
  end
50fcc5
end}
50fcc5
0d3998
# Unbundle Grafana vendor sources and instead use BuildRequires
d08e3e
# on platforms that have enough golang devel support.
50fcc5
%if 0%{?rhel} == 0
50fcc5
%global           unbundle_vendor_sources 1
50fcc5
%endif
50fcc5
d08e3e
%if 0%{?rhel}
d08e3e
# emulate macros defined by the go-rpm-macros package
d08e3e
# https://pagure.io/go-rpm-macros/blob/master/f/rpm/macros.d/macros.go-compilers-golang
d08e3e
%define gobuild(o:) go build -buildmode pie -compiler gc -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "${LDFLAGS:-}%{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}'" -a -v -x %{?**};
d08e3e
%define gotestextldflags %__global_ldflags %{?__golang_extldflags}
d08e3e
%define gotest() GO111MODULE=off go test -buildmode pie -compiler gc -ldflags "${LDFLAGS:-}%{?currentgoldflags} -extldflags '%{gotestextldflags}'" %{?**};
0d3998
%endif
0d3998
50fcc5
Name:             grafana
d08e3e
Version:          6.7.3
0d3998
Release:          1%{?dist}
50fcc5
Summary:          Metrics dashboard and graph editor
50fcc5
License:          ASL 2.0
50fcc5
URL:              https://grafana.org
50fcc5
50fcc5
# Source0 contains the tagged upstream sources
50fcc5
Source0:          https://github.com/grafana/grafana/archive/v%{version}/%{name}-%{version}.tar.gz
50fcc5
50fcc5
# Source1 contains the front-end javascript modules bundled into a webpack
50fcc5
Source1:          grafana_webpack-%{version}.tar.gz
50fcc5
d08e3e
# Source2 contains Grafana configuration defaults for distributions
d08e3e
Source2:          distro-defaults.ini
d08e3e
d08e3e
# Source3 is the script to create the webpack from grafana sources
d08e3e
Source3:          make_grafana_webpack.sh
d08e3e
d08e3e
# Source4 is the script to generate the list of Go build dependencies:
d08e3e
Source4:          list_go_buildrequires.sh
d08e3e
d08e3e
# Source5 is the script to generate the list of bundled nodejs packages
d08e3e
Source5:          list_bundled_nodejs_packages.py
50fcc5
d08e3e
d08e3e
# Patches
50fcc5
Patch1:           001-login-oauth-use-oauth2-exchange.patch
50fcc5
Patch2:           002-remove-jaeger-tracing.patch
d08e3e
Patch3:           003-manpages.patch
d08e3e
Patch4:           004-wrappers-grafana-cli.patch
d08e3e
Patch5:           005-pkg-main-fix-import-paths.patch
d08e3e
Patch6:           006-pkg-setting-ini-default-section.patch
d08e3e
Patch7:           007-pkg-prometheus-client-query-range.patch
d08e3e
Patch8:           008-pkg-services-notifications-codes-Unknwon.patch
d08e3e
Patch9:           009-pkg-fix-xorm-import.patch
50fcc5
50fcc5
# Intersection of go_arches and nodejs_arches
50fcc5
ExclusiveArch:    %{grafana_arches}
50fcc5
50fcc5
# omit golang debugsource, see BZ995136 and related
0d3998
%global           dwz_low_mem_die_limit 0
50fcc5
%global           _debugsource_template %{nil}
50fcc5
50fcc5
%global           GRAFANA_USER %{name}
50fcc5
%global           GRAFANA_GROUP %{name}
50fcc5
%global           GRAFANA_HOME %{_datadir}/%{name}
50fcc5
50fcc5
# grafana-server service daemon uses systemd
50fcc5
%{?systemd_requires}
50fcc5
Requires(pre):    shadow-utils
50fcc5
0d3998
BuildRequires:    git, systemd, golang, go-srpm-macros
50fcc5
d08e3e
%if 0%{?fedora} || 0%{?rhel} > 7
50fcc5
Recommends: grafana-cloudwatch = %{version}-%{release}
50fcc5
Recommends: grafana-elasticsearch = %{version}-%{release}
50fcc5
Recommends: grafana-azure-monitor = %{version}-%{release}
50fcc5
Recommends: grafana-graphite = %{version}-%{release}
50fcc5
Recommends: grafana-influxdb = %{version}-%{release}
50fcc5
Recommends: grafana-loki = %{version}-%{release}
50fcc5
Recommends: grafana-mssql = %{version}-%{release}
50fcc5
Recommends: grafana-mysql = %{version}-%{release}
50fcc5
Recommends: grafana-opentsdb = %{version}-%{release}
50fcc5
Recommends: grafana-postgres = %{version}-%{release}
50fcc5
Recommends: grafana-prometheus = %{version}-%{release}
50fcc5
Recommends: grafana-stackdriver = %{version}-%{release}
d08e3e
Recommends: grafana-pcp >= 2
d08e3e
%endif
50fcc5
50fcc5
%if 0%{?unbundle_vendor_sources}
50fcc5
# golang build deps. These allow us to unbundle vendor golang source.
d08e3e
# Note: generated with the list_go_buildrequires.sh script (see README.md)
d08e3e
BuildRequires: golang(github.com/apache/arrow/go/arrow)
d08e3e
BuildRequires: golang(github.com/apache/arrow/go/arrow/array)
d08e3e
BuildRequires: golang(github.com/apache/arrow/go/arrow/ipc)
d08e3e
BuildRequires: golang(github.com/apache/arrow/go/arrow/memory)
d08e3e
BuildRequires: golang(github.com/aws/aws-sdk-go/aws)
d08e3e
BuildRequires: golang(github.com/aws/aws-sdk-go/aws/awsutil)
d08e3e
BuildRequires: golang(github.com/aws/aws-sdk-go/aws/credentials)
d08e3e
BuildRequires: golang(github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds)
d08e3e
BuildRequires: golang(github.com/aws/aws-sdk-go/aws/credentials/endpointcreds)
d08e3e
BuildRequires: golang(github.com/aws/aws-sdk-go/aws/defaults)
d08e3e
BuildRequires: golang(github.com/aws/aws-sdk-go/aws/ec2metadata)
d08e3e
BuildRequires: golang(github.com/aws/aws-sdk-go/aws/request)
d08e3e
BuildRequires: golang(github.com/aws/aws-sdk-go/aws/session)
d08e3e
BuildRequires: golang(github.com/aws/aws-sdk-go/service/cloudwatch)
d08e3e
BuildRequires: golang(github.com/aws/aws-sdk-go/service/ec2)
d08e3e
BuildRequires: golang(github.com/aws/aws-sdk-go/service/ec2/ec2iface)
d08e3e
BuildRequires: golang(github.com/aws/aws-sdk-go/service/resourcegroupstaggingapi)
d08e3e
BuildRequires: golang(github.com/aws/aws-sdk-go/service/resourcegroupstaggingapi/resourcegroupstaggingapiiface)
d08e3e
BuildRequires: golang(github.com/aws/aws-sdk-go/service/s3/s3manager)
d08e3e
BuildRequires: golang(github.com/aws/aws-sdk-go/service/sts)
50fcc5
BuildRequires: golang(github.com/benbjohnson/clock)
50fcc5
BuildRequires: golang(github.com/bradfitz/gomemcache/memcache)
50fcc5
BuildRequires: golang(github.com/BurntSushi/toml)
d08e3e
BuildRequires: golang(github.com/cheekybits/genny/generic)
d08e3e
BuildRequires: golang(github.com/crewjam/saml)
50fcc5
BuildRequires: golang(github.com/davecgh/go-spew/spew)
50fcc5
BuildRequires: golang(github.com/denisenkom/go-mssqldb)
50fcc5
BuildRequires: golang(github.com/facebookgo/inject)
50fcc5
BuildRequires: golang(github.com/fatih/color)
d08e3e
BuildRequires: golang(github.com/gobwas/glob)
d08e3e
BuildRequires: golang(github.com/golang/protobuf/proto)
50fcc5
BuildRequires: golang(github.com/go-macaron/binding)
50fcc5
BuildRequires: golang(github.com/go-macaron/gzip)
50fcc5
BuildRequires: golang(github.com/go-macaron/session)
d08e3e
BuildRequires: golang(github.com/google/go-cmp/cmp)
d08e3e
BuildRequires: golang(github.com/google/go-cmp/cmp/cmpopts)
50fcc5
BuildRequires: golang(github.com/gorilla/websocket)
50fcc5
BuildRequires: golang(github.com/gosimple/slug)
50fcc5
BuildRequires: golang(github.com/go-sql-driver/mysql)
50fcc5
BuildRequires: golang(github.com/go-stack/stack)
50fcc5
BuildRequires: golang(github.com/go-xorm/core)
50fcc5
BuildRequires: golang(github.com/hashicorp/go-hclog)
50fcc5
BuildRequires: golang(github.com/hashicorp/go-plugin)
50fcc5
BuildRequires: golang(github.com/hashicorp/go-version)
50fcc5
BuildRequires: golang(github.com/inconshreveable/log15)
50fcc5
BuildRequires: golang(github.com/jmespath/go-jmespath)
d08e3e
BuildRequires: golang(github.com/jung-kurt/gofpdf)
50fcc5
BuildRequires: golang(github.com/lib/pq)
d08e3e
BuildRequires: golang(github.com/linkedin/goavro)
d08e3e
BuildRequires: golang(github.com/mattetti/filebuffer)
50fcc5
BuildRequires: golang(github.com/mattn/go-isatty)
50fcc5
BuildRequires: golang(github.com/mattn/go-sqlite3)
50fcc5
BuildRequires: golang(github.com/opentracing/opentracing-go)
d08e3e
BuildRequires: golang(github.com/opentracing/opentracing-go/ext)
d08e3e
BuildRequires: golang(github.com/opentracing/opentracing-go/log)
50fcc5
BuildRequires: golang(github.com/patrickmn/go-cache)
50fcc5
BuildRequires: golang(github.com/pkg/errors)
50fcc5
BuildRequires: golang(github.com/prometheus/client_golang/api)
50fcc5
BuildRequires: golang(github.com/prometheus/client_golang/api/prometheus/v1)
d08e3e
BuildRequires: golang(github.com/prometheus/client_golang/prometheus)
d08e3e
BuildRequires: golang(github.com/prometheus/client_golang/prometheus/promhttp)
50fcc5
BuildRequires: golang(github.com/prometheus/client_model/go)
50fcc5
BuildRequires: golang(github.com/prometheus/common/expfmt)
50fcc5
BuildRequires: golang(github.com/prometheus/common/model)
d08e3e
BuildRequires: golang(github.com/robfig/cron)
50fcc5
BuildRequires: golang(github.com/smartystreets/goconvey/convey)
d08e3e
BuildRequires: golang(github.com/stretchr/testify/require)
50fcc5
BuildRequires: golang(github.com/teris-io/shortid)
d08e3e
BuildRequires: golang(github.com/ua-parser/uap-go/uaparser)
d08e3e
BuildRequires: golang(github.com/uber/jaeger-client-go/config)
d08e3e
BuildRequires: golang(github.com/uber/jaeger-client-go/zipkin)
50fcc5
BuildRequires: golang(github.com/Unknwon/com)
d08e3e
BuildRequires: golang(github.com/urfave/cli/v2)
50fcc5
BuildRequires: golang(github.com/VividCortex/mysqlerr)
50fcc5
BuildRequires: golang(github.com/yudai/gojsondiff)
d08e3e
BuildRequires: golang(github.com/yudai/gojsondiff/formatter)
50fcc5
BuildRequires: golang(golang.org/x/crypto/pbkdf2)
50fcc5
BuildRequires: golang(golang.org/x/net/context)
50fcc5
BuildRequires: golang(golang.org/x/net/context/ctxhttp)
50fcc5
BuildRequires: golang(golang.org/x/oauth2)
50fcc5
BuildRequires: golang(golang.org/x/oauth2/google)
50fcc5
BuildRequires: golang(golang.org/x/oauth2/jwt)
50fcc5
BuildRequires: golang(golang.org/x/sync/errgroup)
d08e3e
BuildRequires: golang(golang.org/x/xerrors)
d08e3e
BuildRequires: golang(google.golang.org/grpc)
d08e3e
BuildRequires: golang(google.golang.org/grpc/codes)
d08e3e
BuildRequires: golang(google.golang.org/grpc/metadata)
d08e3e
BuildRequires: golang(google.golang.org/grpc/status)
d08e3e
BuildRequires: golang(gopkg.in/ini.v1)
50fcc5
BuildRequires: golang(gopkg.in/ldap.v3)
d08e3e
BuildRequires: golang(gopkg.in/macaron.v1)
50fcc5
BuildRequires: golang(gopkg.in/mail.v2)
d08e3e
BuildRequires: golang(gopkg.in/redis.v5)
d08e3e
BuildRequires: golang(gopkg.in/robfig/cron.v3)
d08e3e
BuildRequires: golang(gopkg.in/square/go-jose.v2)
d08e3e
BuildRequires: golang(gopkg.in/square/go-jose.v2/jwt)
d08e3e
BuildRequires: golang(gopkg.in/yaml.v2)
d08e3e
BuildRequires: golang(xorm.io/xorm)
50fcc5
%endif
50fcc5
50fcc5
# Declare all nodejs modules bundled in the webpack - this is for security
50fcc5
# purposes so if nodejs-foo ever needs an update, affected packages can be
d08e3e
# easily identified.
d08e3e
# Note: generated with the list_bundled_nodejs_packages.sh script (see README.md)
d08e3e
Provides: bundled(nodejs-@braintree/sanitize-url) = 4.0.0
d08e3e
Provides: bundled(nodejs-@grafana/slate-react) = 0.22.9-grafana
d08e3e
Provides: bundled(nodejs-@reduxjs/toolkit) = 1.2.1
d08e3e
Provides: bundled(nodejs-@torkelo/react-select) = 3.0.8
d08e3e
Provides: bundled(nodejs-@types/md5) = 2.1.33
d08e3e
Provides: bundled(nodejs-@types/react-loadable) = 5.5.2
d08e3e
Provides: bundled(nodejs-@types/react-virtualized-auto-sizer) = 1.0.0
d08e3e
Provides: bundled(nodejs-@types/uuid) = 3.4.7
d08e3e
Provides: bundled(nodejs-abortcontroller-polyfill) = 1.4.0
d08e3e
Provides: bundled(nodejs-angular) = 1.6.9
d08e3e
Provides: bundled(nodejs-angular-bindonce) = 0.3.1
d08e3e
Provides: bundled(nodejs-angular-native-dragdrop) = 1.2.2
d08e3e
Provides: bundled(nodejs-angular-route) = 1.6.6
d08e3e
Provides: bundled(nodejs-angular-sanitize) = 1.6.6
d08e3e
Provides: bundled(nodejs-baron) = 3.0.3
d08e3e
Provides: bundled(nodejs-brace) = 0.10.0
d08e3e
Provides: bundled(nodejs-calculate-size) = 1.1.1
d08e3e
Provides: bundled(nodejs-classnames) = 2.2.6
d08e3e
Provides: bundled(nodejs-clipboard) = 2.0.4
d08e3e
Provides: bundled(nodejs-core-js) = 1.2.7
d08e3e
Provides: bundled(nodejs-d3) = 5.15.0
d08e3e
Provides: bundled(nodejs-d3-scale-chromatic) = 1.5.0
d08e3e
Provides: bundled(nodejs-emotion) = 10.0.27
d08e3e
Provides: bundled(nodejs-eventemitter3) = 2.0.3
d08e3e
Provides: bundled(nodejs-fast-text-encoding) = 1.0.0
d08e3e
Provides: bundled(nodejs-file-saver) = 1.3.8
d08e3e
Provides: bundled(nodejs-hoist-non-react-statics) = 3.3.0
d08e3e
Provides: bundled(nodejs-immutable) = 3.8.2
d08e3e
Provides: bundled(nodejs-is-hotkey) = 0.1.4
d08e3e
Provides: bundled(nodejs-jquery) = 3.4.1
d08e3e
Provides: bundled(nodejs-lodash) = 3.10.1
d08e3e
Provides: bundled(nodejs-lru-cache) = 4.1.5
d08e3e
Provides: bundled(nodejs-marked) = 0.3.19
d08e3e
Provides: bundled(nodejs-md5) = 2.2.1
d08e3e
Provides: bundled(nodejs-memoize-one) = 4.1.0
d08e3e
Provides: bundled(nodejs-moment) = 2.24.0
d08e3e
Provides: bundled(nodejs-mousetrap) = 1.6.3
d08e3e
Provides: bundled(nodejs-mousetrap-global-bind) = 1.1.0
d08e3e
Provides: bundled(nodejs-nodemon) = 1.18.10
d08e3e
Provides: bundled(nodejs-papaparse) = 4.6.3
d08e3e
Provides: bundled(nodejs-prismjs) = 1.16.0
d08e3e
Provides: bundled(nodejs-prop-types) = 15.7.2
d08e3e
Provides: bundled(nodejs-rc-cascader) = 0.17.5
d08e3e
Provides: bundled(nodejs-re-resizable) = 6.2.0
d08e3e
Provides: bundled(nodejs-react) = 16.10.2
d08e3e
Provides: bundled(nodejs-react-dom) = 16.10.2
d08e3e
Provides: bundled(nodejs-react-grid-layout) = 0.17.1
d08e3e
Provides: bundled(nodejs-react-highlight-words) = 0.11.0
d08e3e
Provides: bundled(nodejs-react-loadable) = 5.5.0
d08e3e
Provides: bundled(nodejs-react-popper) = 1.3.3
d08e3e
Provides: bundled(nodejs-react-redux) = 7.1.1
d08e3e
Provides: bundled(nodejs-react-sizeme) = 2.5.2
d08e3e
Provides: bundled(nodejs-react-split-pane) = 0.1.89
d08e3e
Provides: bundled(nodejs-react-transition-group) = 2.6.1
d08e3e
Provides: bundled(nodejs-react-use) = 12.8.0
d08e3e
Provides: bundled(nodejs-react-virtualized-auto-sizer) = 1.0.2
d08e3e
Provides: bundled(nodejs-react-window) = 1.7.1
d08e3e
Provides: bundled(nodejs-redux) = 3.7.2
d08e3e
Provides: bundled(nodejs-redux-logger) = 3.0.6
d08e3e
Provides: bundled(nodejs-redux-thunk) = 2.3.0
d08e3e
Provides: bundled(nodejs-regenerator-runtime) = 0.11.1
d08e3e
Provides: bundled(nodejs-reselect) = 4.0.0
d08e3e
Provides: bundled(nodejs-rst2html) = 1.0.4
d08e3e
Provides: bundled(nodejs-rxjs) = 5.5.12
d08e3e
Provides: bundled(nodejs-search-query-parser) = 1.5.2
d08e3e
Provides: bundled(nodejs-slate) = 0.47.8
d08e3e
Provides: bundled(nodejs-slate-plain-serializer) = 0.7.10
d08e3e
Provides: bundled(nodejs-tether) = 1.4.5
d08e3e
Provides: bundled(nodejs-tether-drop) = 1.5.0
d08e3e
Provides: bundled(nodejs-tinycolor2) = 1.4.1
d08e3e
Provides: bundled(nodejs-tti-polyfill) = 0.2.2
d08e3e
Provides: bundled(nodejs-uuid) = 3.3.3
d08e3e
Provides: bundled(nodejs-whatwg-fetch) = 3.0.0
d08e3e
Provides: bundled(nodejs-xss) = 1.0.3
50fcc5
50fcc5
50fcc5
%description
50fcc5
Grafana is an open source, feature rich metrics dashboard and graph editor for
50fcc5
Graphite, InfluxDB & OpenTSDB.
50fcc5
50fcc5
50fcc5
%package cloudwatch
50fcc5
Requires: %{name} = %{version}-%{release}
50fcc5
Summary: Grafana cloudwatch datasource
50fcc5
50fcc5
%description cloudwatch
50fcc5
The Grafana cloudwatch datasource.
50fcc5
50fcc5
%package elasticsearch
50fcc5
Requires: %{name} = %{version}-%{release}
50fcc5
Summary: Grafana elasticsearch datasource
50fcc5
50fcc5
%description elasticsearch
50fcc5
The Grafana elasticsearch datasource.
50fcc5
50fcc5
%package azure-monitor
50fcc5
Requires: %{name} = %{version}-%{release}
50fcc5
Summary: Grafana azure-monitor datasource
50fcc5
50fcc5
%description azure-monitor
50fcc5
The Grafana azure-monitor datasource.
50fcc5
50fcc5
%package graphite
50fcc5
Requires: %{name} = %{version}-%{release}
50fcc5
Summary: Grafana graphite datasource
50fcc5
50fcc5
%description graphite
50fcc5
The Grafana graphite datasource.
50fcc5
50fcc5
%package influxdb
50fcc5
Requires: %{name} = %{version}-%{release}
50fcc5
Summary: Grafana influxdb datasource
50fcc5
50fcc5
%description influxdb
50fcc5
The Grafana influxdb datasource.
50fcc5
50fcc5
%package loki
50fcc5
Requires: %{name} = %{version}-%{release}
50fcc5
Summary: Grafana loki datasource
50fcc5
50fcc5
%description loki
50fcc5
The Grafana loki datasource.
50fcc5
50fcc5
%package mssql
50fcc5
Requires: %{name} = %{version}-%{release}
50fcc5
Summary: Grafana mssql datasource
50fcc5
50fcc5
%description mssql
50fcc5
The Grafana mssql datasource.
50fcc5
50fcc5
%package mysql
50fcc5
Requires: %{name} = %{version}-%{release}
50fcc5
Summary: Grafana mysql datasource
50fcc5
50fcc5
%description mysql
50fcc5
The Grafana mysql datasource.
50fcc5
50fcc5
%package opentsdb
50fcc5
Requires: %{name} = %{version}-%{release}
50fcc5
Summary: Grafana opentsdb datasource
50fcc5
50fcc5
%description opentsdb
50fcc5
The Grafana opentsdb datasource.
50fcc5
50fcc5
%package postgres
50fcc5
Requires: %{name} = %{version}-%{release}
50fcc5
Summary: Grafana postgres datasource
50fcc5
50fcc5
%description postgres
50fcc5
The Grafana postgres datasource.
50fcc5
50fcc5
%package prometheus
50fcc5
Requires: %{name} = %{version}-%{release}
50fcc5
Summary: Grafana prometheus datasource
50fcc5
50fcc5
%description prometheus
50fcc5
The Grafana prometheus datasource.
50fcc5
50fcc5
%package stackdriver
50fcc5
Requires: %{name} = %{version}-%{release}
50fcc5
Summary: Grafana stackdriver datasource
50fcc5
50fcc5
%description stackdriver
50fcc5
The Grafana stackdriver datasource.
50fcc5
50fcc5
50fcc5
%prep
50fcc5
%setup -q -T -D -b 0
50fcc5
%setup -q -T -D -b 1
50fcc5
%patch1 -p1
50fcc5
%patch2 -p1
50fcc5
%patch3 -p1
0d3998
%patch4 -p1
d08e3e
%patch6 -p1
d08e3e
d08e3e
%if 0%{?unbundle_vendor_sources}
0d3998
%patch5 -p1
d08e3e
%patch7 -p1
d08e3e
%patch8 -p1
d08e3e
%patch9 -p1
d08e3e
%endif
50fcc5
50fcc5
# Set up build subdirs and links
50fcc5
mkdir -p %{_builddir}/src/github.com/grafana
50fcc5
ln -sf %{_builddir}/%{name}-%{version} \
50fcc5
    %{_builddir}/src/github.com/grafana/grafana
50fcc5
50fcc5
# remove some (apparent) development files, for rpmlint
50fcc5
rm -f public/sass/.sass-lint.yml public/test/.jshintrc
50fcc5
50fcc5
%if 0%{?unbundle_vendor_sources}
50fcc5
# Unbundle all grafana vendor sources, as per BuildRequires above.
d08e3e
# Note there are some exceptions.
d08e3e
cp --parents -a \
d08e3e
    vendor/github.com/grafana/grafana-plugin-model \
d08e3e
    vendor/github.com/grafana/grafana-plugin-sdk-go \
0d3998
    %{_builddir}
50fcc5
rm -r vendor # remove all vendor sources
50fcc5
mv %{_builddir}/vendor vendor # put back what we're keeping
50fcc5
%endif
50fcc5
50fcc5
%build
0d3998
# Build the server-side binaries
50fcc5
cd %{_builddir}/src/github.com/grafana/grafana
0d3998
%global archbindir bin/`go env GOOS`-`go env GOARCH`
d08e3e
echo _builddir=%{_builddir} archbindir=%{archbindir} gopath=%{gopath}
0d3998
[ ! -d %{archbindir} ] && mkdir -p %{archbindir}
d08e3e
d08e3e
# non-modular build
50fcc5
export GOPATH=%{_builddir}:%{gopath}
d08e3e
export GO111MODULE=off; rm -f go.mod
50fcc5
d08e3e
# see grafana-X.X.X/build.go
d08e3e
export LDFLAGS="-X main.version=%{version} -X main.buildstamp=${SOURCE_DATE_EPOCH}"
d08e3e
for cmd in grafana-cli grafana-server; do
d08e3e
    %gobuild -o %{archbindir}/${cmd} ./pkg/cmd/${cmd}
d08e3e
done
50fcc5
50fcc5
%install
50fcc5
# Fix up arch bin directories
50fcc5
[ ! -d bin/x86_64 ] && ln -sf linux-amd64 bin/x86_64
50fcc5
[ ! -d bin/i386 ] && ln -sf linux-386 bin/i386
50fcc5
[ ! -d bin/ppc64le ] && ln -sf linux-ppc64le bin/ppc64le
50fcc5
[ ! -d bin/s390x ] && ln -sf linux-s390x bin/s390x
50fcc5
[ ! -d bin/arm ] && ln -sf linux-arm bin/arm
50fcc5
[ ! -d bin/arm64 ] && ln -sf linux-arm64 bin/aarch64
50fcc5
[ ! -d bin/aarch64 ] && ln -sf linux-aarch64 bin/aarch64
50fcc5
0d3998
# dirs, shared files, public html, webpack
50fcc5
install -d %{buildroot}%{_sbindir}
d08e3e
install -d %{buildroot}%{_datadir}/%{name}
d08e3e
install -d %{buildroot}%{_libexecdir}/%{name}
50fcc5
cp -a conf public %{buildroot}%{_datadir}/%{name}
50fcc5
0d3998
# wrappers
0d3998
install -p -m 755 packaging/wrappers/grafana-cli %{buildroot}%{_sbindir}/%{name}-cli
0d3998
0d3998
# binaries
0d3998
install -p -m 755 %{archbindir}/%{name}-server %{buildroot}%{_sbindir}
d08e3e
install -p -m 755 %{archbindir}/%{name}-cli %{buildroot}%{_libexecdir}/%{name}
0d3998
50fcc5
# man pages
50fcc5
install -d %{buildroot}%{_mandir}/man1
50fcc5
install -p -m 644 docs/man/man1/* %{buildroot}%{_mandir}/man1
50fcc5
50fcc5
# config dirs
50fcc5
install -d %{buildroot}%{_sysconfdir}/%{name}
50fcc5
install -d %{buildroot}%{_sysconfdir}/sysconfig
50fcc5
50fcc5
# config defaults
d08e3e
install -p -m 640 %{SOURCE2} %{buildroot}%{_sysconfdir}/%{name}/grafana.ini
d08e3e
install -p -m 640 conf/ldap.toml %{buildroot}%{_sysconfdir}/%{name}/ldap.toml
d08e3e
install -p -m 644 %{SOURCE2} %{buildroot}%{_datadir}/%{name}/conf/defaults.ini
50fcc5
install -p -m 644 packaging/rpm/sysconfig/grafana-server \
50fcc5
    %{buildroot}%{_sysconfdir}/sysconfig/grafana-server
50fcc5
50fcc5
# config database directory and plugins
d08e3e
install -d -m 750 %{buildroot}%{_sharedstatedir}/%{name}
50fcc5
install -d -m 755 %{buildroot}%{_sharedstatedir}/%{name}/plugins
50fcc5
50fcc5
# log directory
50fcc5
install -d %{buildroot}%{_localstatedir}/log/%{name}
50fcc5
50fcc5
# systemd service files
50fcc5
install -d %{buildroot}%{_unitdir} # only needed for manual rpmbuilds
50fcc5
install -p -m 644 packaging/rpm/systemd/grafana-server.service \
50fcc5
    %{buildroot}%{_unitdir}
50fcc5
50fcc5
# daemon run pid file config for using tmpfs
50fcc5
install -d %{buildroot}%{_tmpfilesdir}
50fcc5
echo "d %{_rundir}/%{name} 0755 %{GRAFANA_USER} %{GRAFANA_GROUP} -" \
50fcc5
    > %{buildroot}%{_tmpfilesdir}/%{name}.conf
50fcc5
50fcc5
%pre
50fcc5
getent group %{GRAFANA_GROUP} >/dev/null || groupadd -r %{GRAFANA_GROUP}
50fcc5
getent passwd %{GRAFANA_USER} >/dev/null || \
50fcc5
    useradd -r -g %{GRAFANA_GROUP} -d %{GRAFANA_HOME} -s /sbin/nologin \
50fcc5
    -c "%{GRAFANA_USER} user account" %{GRAFANA_USER}
50fcc5
exit 0
50fcc5
50fcc5
%preun
50fcc5
%systemd_preun grafana-server.service
50fcc5
50fcc5
%post
50fcc5
%systemd_post grafana-server.service
d08e3e
# create grafana.db with secure permissions on new installations
d08e3e
# otherwise grafana-server is creating grafana.db on first start
d08e3e
# with world-readable permissions, which may leak encrypted datasource
d08e3e
# passwords to all users (if the secret_key in grafana.ini was not changed)
d08e3e
d08e3e
# https://bugzilla.redhat.com/show_bug.cgi?id=1805472
d08e3e
if [ "$1" = 1 ] && [ ! -f %{_sharedstatedir}/%{name}/grafana.db ]; then
d08e3e
    touch %{_sharedstatedir}/%{name}/grafana.db
d08e3e
fi
d08e3e
d08e3e
# apply secure permissions to grafana.db if it exists
d08e3e
# (may not exist on upgrades, because users can choose between sqlite/mysql/postgres)
d08e3e
if [ -f %{_sharedstatedir}/%{name}/grafana.db ]; then
d08e3e
    chown %{GRAFANA_USER}:%{GRAFANA_GROUP} %{_sharedstatedir}/%{name}/grafana.db
d08e3e
    chmod 640 %{_sharedstatedir}/%{name}/grafana.db
d08e3e
fi
d08e3e
d08e3e
# required for upgrades
d08e3e
chmod 640 %{_sysconfdir}/%{name}/grafana.ini
d08e3e
chmod 640 %{_sysconfdir}/%{name}/ldap.toml
50fcc5
50fcc5
%postun
50fcc5
%systemd_postun_with_restart grafana-server.service
50fcc5
50fcc5
50fcc5
%check
50fcc5
cd %{_builddir}/src/github.com/grafana/grafana
50fcc5
export GOPATH=%{_builddir}:%{gopath}
d08e3e
# remove tests currently failing - these two are due to a symlink
d08e3e
# BUILD/src/github.com/grafana/grafana -> BUILD/grafana-6.6.1
50fcc5
rm -f pkg/services/provisioning/dashboards/file_reader_linux_test.go
50fcc5
rm -f pkg/services/provisioning/dashboards/file_reader_test.go
0d3998
export GO111MODULE=off
d08e3e
%gotest ./pkg/...
50fcc5
50fcc5
50fcc5
%files
d08e3e
# binaries and wrappers
50fcc5
%{_sbindir}/%{name}-server
50fcc5
%{_sbindir}/%{name}-cli
d08e3e
%{_libexecdir}/%{name}
50fcc5
50fcc5
# config files
50fcc5
%dir %{_sysconfdir}/%{name}
d08e3e
%config(noreplace) %attr(640, root, %{GRAFANA_GROUP}) %{_sysconfdir}/%{name}/grafana.ini
d08e3e
%config(noreplace) %attr(640, root, %{GRAFANA_GROUP}) %{_sysconfdir}/%{name}/ldap.toml
50fcc5
%config(noreplace) %{_sysconfdir}/sysconfig/grafana-server
50fcc5
50fcc5
# Grafana configuration to dynamically create /run/grafana/grafana.pid on tmpfs
50fcc5
%{_tmpfilesdir}/%{name}.conf
50fcc5
d08e3e
# config database directory and plugins
d08e3e
%attr(750, %{GRAFANA_USER}, %{GRAFANA_GROUP}) %dir %{_sharedstatedir}/%{name}
50fcc5
%attr(-, %{GRAFANA_USER}, %{GRAFANA_GROUP}) %dir %{_sharedstatedir}/%{name}/plugins
50fcc5
50fcc5
# shared directory and all files therein, except some datasources
d08e3e
%{_datadir}/%{name}
50fcc5
50fcc5
# built-in datasources that are sub-packaged
50fcc5
%global dsdir %{_datadir}/%{name}/public/app/plugins/datasource
50fcc5
%exclude %{dsdir}/cloudwatch 
50fcc5
%exclude %{dsdir}/elasticsearch 
50fcc5
%exclude %{dsdir}/graphite
50fcc5
%exclude %{dsdir}/grafana-azure-monitor-datasource
50fcc5
%exclude %{dsdir}/influxdb
50fcc5
%exclude %{dsdir}/loki
50fcc5
%exclude %{dsdir}/mssql
50fcc5
%exclude %{dsdir}/mysql
50fcc5
%exclude %{dsdir}/opentsdb
50fcc5
%exclude %{dsdir}/postgres
50fcc5
%exclude %{dsdir}/prometheus
50fcc5
%exclude %{dsdir}/stackdriver
50fcc5
50fcc5
%dir %{_datadir}/%{name}/conf
50fcc5
%attr(-, root, %{GRAFANA_GROUP}) %{_datadir}/%{name}/conf/*
50fcc5
50fcc5
# systemd service file
50fcc5
%{_unitdir}/grafana-server.service
50fcc5
50fcc5
# log directory - grafana.log is created by grafana-server, and it does it's own log rotation
50fcc5
%attr(0755, %{GRAFANA_USER}, %{GRAFANA_GROUP}) %dir %{_localstatedir}/log/%{name}
50fcc5
50fcc5
# man pages for grafana binaries
50fcc5
%{_mandir}/man1/%{name}-server.1*
50fcc5
%{_mandir}/man1/%{name}-cli.1*
50fcc5
50fcc5
# other docs and license
50fcc5
%license LICENSE
50fcc5
%doc CHANGELOG.md CODE_OF_CONDUCT.md CONTRIBUTING.md NOTICE.md
50fcc5
%doc PLUGIN_DEV.md README.md ROADMAP.md UPGRADING_DEPENDENCIES.md
50fcc5
50fcc5
#
50fcc5
# datasources split out into subpackages
50fcc5
#
50fcc5
%files cloudwatch
50fcc5
%{_datadir}/%{name}/public/app/plugins/datasource/cloudwatch
d08e3e
%doc %{_datadir}/%{name}/public/app/plugins/datasource/cloudwatch/README.md
50fcc5
50fcc5
%files elasticsearch
50fcc5
%{_datadir}/%{name}/public/app/plugins/datasource/elasticsearch
d08e3e
%doc %{_datadir}/%{name}/public/app/plugins/datasource/elasticsearch/README.md
50fcc5
50fcc5
%files azure-monitor
50fcc5
%{_datadir}/%{name}/public/app/plugins/datasource/grafana-azure-monitor-datasource
50fcc5
50fcc5
%files graphite
50fcc5
%{_datadir}/%{name}/public/app/plugins/datasource/graphite
d08e3e
%doc %{_datadir}/%{name}/public/app/plugins/datasource/graphite/README.md
50fcc5
50fcc5
%files influxdb
50fcc5
%{_datadir}/%{name}/public/app/plugins/datasource/influxdb
d08e3e
%doc %{_datadir}/%{name}/public/app/plugins/datasource/influxdb/README.md
50fcc5
50fcc5
%files loki
50fcc5
%{_datadir}/%{name}/public/app/plugins/datasource/loki
d08e3e
%doc %{_datadir}/%{name}/public/app/plugins/datasource/loki/README.md
50fcc5
50fcc5
%files mssql
50fcc5
%{_datadir}/%{name}/public/app/plugins/datasource/mssql
d08e3e
%doc %{_datadir}/%{name}/public/app/plugins/datasource/mssql/README.md
50fcc5
50fcc5
%files mysql
50fcc5
%{_datadir}/%{name}/public/app/plugins/datasource/mysql
d08e3e
%doc %{_datadir}/%{name}/public/app/plugins/datasource/mysql/README.md
50fcc5
50fcc5
%files opentsdb
50fcc5
%{_datadir}/%{name}/public/app/plugins/datasource/opentsdb
d08e3e
%doc %{_datadir}/%{name}/public/app/plugins/datasource/opentsdb/README.md
50fcc5
50fcc5
%files postgres
50fcc5
%{_datadir}/%{name}/public/app/plugins/datasource/postgres
d08e3e
%doc %{_datadir}/%{name}/public/app/plugins/datasource/postgres/README.md
50fcc5
50fcc5
%files prometheus
50fcc5
%{_datadir}/%{name}/public/app/plugins/datasource/prometheus
d08e3e
%doc %{_datadir}/%{name}/public/app/plugins/datasource/prometheus/README.md
50fcc5
50fcc5
%files stackdriver
50fcc5
%{_datadir}/%{name}/public/app/plugins/datasource/stackdriver
d08e3e
%doc %{_datadir}/%{name}/public/app/plugins/datasource/stackdriver/README.md
50fcc5
50fcc5
50fcc5
%changelog
d08e3e
* Tue Apr 28 2020 Andreas Gerstmayr <agerstmayr@redhat.com> 6.7.3-1
d08e3e
- update to 6.7.3 tagged upstream community sources, see CHANGELOG
d08e3e
- add scripts to list Go dependencies and bundled npmjs dependencies
d08e3e
- set Grafana version in Grafana UI and grafana-cli --version
d08e3e
- declare README.md as documentation of datasource plugins
d08e3e
- create grafana.db on first installation (fixes RH BZ #1805472)
d08e3e
- change permissions of /var/lib/grafana to 750 (CVE-2020-12458)
d08e3e
- change permissions of /var/lib/grafana/grafana.db to 640 and
d08e3e
  user/group grafana:grafana (CVE-2020-12458)
d08e3e
- change permissions of grafana.ini and ldap.toml to 640 (CVE-2020-12459)
d08e3e
d08e3e
* Wed Feb 26 2020 Mark Goodwin <mgoodwin@redhat.com> 6.6.2-1
d08e3e
- added patch0 to set the version string correctly
d08e3e
- removed patch 004-xerrors.patch, it's now upstream
d08e3e
- added several patches for golang vendored vrs build dep differences
d08e3e
- added patch to move grafana-cli binary to libexec dir
d08e3e
- update to 6.6.2 tagged upstream community sources, see CHANGELOG
d08e3e
0d3998
* Wed Nov 20 2019 Mark Goodwin <mgoodwin@redhat.com> 6.3.6-1
0d3998
- add weak depenency on grafana-pcp
0d3998
- add patch to mute shellcheck SC1090 for grafana-cli
0d3998
- update to 6.3.6 upstream community sources, see CHANGELOG
0d3998
0d3998
* Thu Sep 05 2019 Mark Goodwin <mgoodwin@redhat.com> 6.3.5-1
0d3998
- drop uaparser patch now it's upstream
0d3998
- add xerrors patch, see https://github.com/golang/go/issues/32246
0d3998
- use vendor sources on rawhide until modules are fully supported
0d3998
- update to latest upstream community sources, see CHANGELOG
0d3998
0d3998
* Fri Aug 30 2019 Mark Goodwin <mgoodwin@redhat.com> 6.3.4-1
0d3998
- include fix for CVE-2019-15043
0d3998
- add patch for uaparser on 32bit systems
0d3998
- update to latest upstream community sources, see CHANGELOG
0d3998
0d3998
* Wed Jul 31 2019 Mark Goodwin <mgoodwin@redhat.com> 6.2.5-1
0d3998
- update to latest upstream community sources, see CHANGELOG
0d3998
0d3998
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 6.2.2-2
0d3998
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
50fcc5
50fcc5
* Fri Jun 07 2019 Mark Goodwin <mgoodwin@redhat.com> 6.2.2-1
50fcc5
- split out some datasource plugins to sub-packages
50fcc5
- update to latest upstream community sources, see CHANGELOG
50fcc5
50fcc5
* Wed Jun 05 2019 Mark Goodwin <mgoodwin@redhat.com> 6.2.1-1
50fcc5
- update to latest upstream community sources, see CHANGELOG
50fcc5
50fcc5
* Fri May 24 2019 Mark Goodwin <mgoodwin@redhat.com> 6.2.0-1
50fcc5
- update to latest upstream community sources
50fcc5
- drop a couple of patches
50fcc5
50fcc5
* Wed May 08 2019 Mark Goodwin <mgoodwin@redhat.com> 6.1.6-2
50fcc5
- add conditional unbundle_vendor_sources macro
50fcc5
50fcc5
* Tue Apr 30 2019 Mark Goodwin <mgoodwin@redhat.com> 6.1.6-1
50fcc5
- update to latest upstream stable release 6.1.6, see CHANGELOG
50fcc5
- includes jQuery 3.4.0 security update
50fcc5
50fcc5
* Wed Apr 24 2019 Mark Goodwin <mgoodwin@redhat.com> 6.1.4-1
50fcc5
- update to latest upstream stable release 6.1.4, see CHANGELOG
50fcc5
- use gobuild and gochecks macros, eliminate arch symlinks
50fcc5
- re-enable grafana-debugsource package
50fcc5
- fix GRAFANA_GROUP typo
50fcc5
- fix more modes for brp-mangle-shebangs
50fcc5
- vendor source unbundling now done in prep after patches
50fcc5
- remove all rhel and fedora conditional guff
50fcc5
50fcc5
* Tue Apr 16 2019 Mark Goodwin <mgoodwin@redhat.com> 6.1.3-1
50fcc5
- update to latest upstream stable release 6.1.3, see CHANGELOG
50fcc5
- unbundle all vendor sources, replace with BuildRequires, see
50fcc5
  the long list of blocker BZs linked to BZ#1670656
50fcc5
- BuildRequires go-plugin >= v1.0.0 for grpc_broker (thanks eclipseo)
50fcc5
- tweak make_webpack to no longer use grunt, switch to prod build
50fcc5
- add ExclusiveArch lua script (thanks quantum.analyst)
50fcc5
- move db directory and plugins to /var/lib/grafana
50fcc5
- split out into 6 patches, ready for upstream PRs
50fcc5
- add check to run go tests for gating checks
50fcc5
50fcc5
* Thu Apr 04 2019 Mark Goodwin <mgoodwin@redhat.com> 6.1.0-1
50fcc5
- update to latest upstream stable release 6.1.0, see CHANGELOG
50fcc5
50fcc5
* Thu Mar 21 2019 Mark Goodwin <mgoodwin@redhat.com> 6.0.2-1
50fcc5
- bump to latest upstream stable release 6.0.2-1
50fcc5
- unbundle almost all remaining vendor code, see linked blockers in BZ#1670656
50fcc5
50fcc5
* Fri Mar 15 2019 Mark Goodwin <mgoodwin@redhat.com> 6.0.1-3
50fcc5
- bump to latest upstream stable release 6.0.1-1
50fcc5
50fcc5
* Thu Mar 14 2019 Mark Goodwin <mgoodwin@redhat.com> 6.0.1-2
50fcc5
- unbundle and add BuildRequires for golang-github-rainycape-unidecode-devel
50fcc5
50fcc5
* Thu Mar 07 2019 Mark Goodwin <mgoodwin@redhat.com> 6.0.1-1
50fcc5
- update to v6.0.1 upstream sources, tweak distro config, re-do patch
50fcc5
- simplify make_webpack.sh script (Elliott Sales de Andrade)
50fcc5
- vendor/github.com/go-ldap is now gone, so don't unbundle it
50fcc5
50fcc5
* Thu Mar 07 2019 Mark Goodwin <mgoodwin@redhat.com> 5.4.3-11
50fcc5
- tweak after latest feedback, bump to 5.4.3-11 (BZ 1670656)
50fcc5
- build debuginfo package again
50fcc5
- unbundle BuildRequires for golang-github-hashicorp-version-devel
50fcc5
- remove some unneeded development files
50fcc5
- remove macros from changelog and other rpmlint tweaks
50fcc5
50fcc5
* Fri Feb 22 2019 Mark Goodwin <mgoodwin@redhat.com> 5.4.3-10
50fcc5
- tweak spec for available and unavailable (bundled) golang packages
50fcc5
50fcc5
* Wed Feb 20 2019 Xavier Bachelot <xavier@bachelot.org> 5.4.3-9
50fcc5
- Remove extraneous slash (cosmetic)
50fcc5
- Create directories just before moving stuff in them
50fcc5
- Truncate long lines
50fcc5
- Group all golang stuff
50fcc5
- Simplify BuildRequires/bundled Provides
50fcc5
- Sort BuildRequires/bundled Provides
50fcc5
- Fix bundled go packages Provides
50fcc5
50fcc5
* Fri Feb 15 2019 Mark Goodwin <mgoodwin@redhat.com> 5.4.3-8
50fcc5
- add BuildRequires (and unbundle) vendor sources available in Fedora
50fcc5
- declare Provides for remaining (bundled) vendor go sources
50fcc5
- do not attempt to unbundle anything on RHEL < 7 or Fedora < 28
50fcc5
50fcc5
* Thu Feb 07 2019 Mark Goodwin <mgoodwin@redhat.com> 5.4.3-7
50fcc5
- further refinement for spec doc section from Xavier Bachelot
50fcc5
- disable debug_package to avoid empty debugsourcefiles.list
50fcc5
50fcc5
* Wed Feb 06 2019 Mark Goodwin <mgoodwin@redhat.com> 5.4.3-6
50fcc5
- further refinement following review by Xavier Bachelot
50fcc5
50fcc5
* Tue Feb 05 2019 Mark Goodwin <mgoodwin@redhat.com> 5.4.3-5
50fcc5
- further refinement following review by Xavier Bachelot
50fcc5
50fcc5
* Fri Feb 01 2019 Mark Goodwin <mgoodwin@redhat.com> 5.4.3-4
50fcc5
- further spec updates after packaging review
50fcc5
- reworked post-install scriplets
50fcc5
50fcc5
* Thu Jan 31 2019 Mark Goodwin <mgoodwin@redhat.com> 5.4.3-3
50fcc5
- tweak FHS patch, update spec after packaging review
50fcc5
50fcc5
* Wed Jan 30 2019 Mark Goodwin <mgoodwin@redhat.com> 5.4.3-2
50fcc5
- add patch to be standard FHS compliant, remove phantomjs
50fcc5
- update to v5.4.3 upstream community sources
50fcc5
50fcc5
* Wed Jan 09 2019 Mark Goodwin <mgoodwin@redhat.com> 5.4.2-1
50fcc5
- update to v5.4.2 upstream community sources
50fcc5
50fcc5
* Thu Oct 18 2018 Mark Goodwin <mgoodwin@redhat.com> 5.3.1-1
50fcc5
- update to v5.3.1 upstream community sources
50fcc5
50fcc5
* Tue Oct 02 2018 Mark Goodwin <mgoodwin@redhat.com> 5.2.5-1
50fcc5
- native RPM spec build with current tagged v5.2.5 sources