%if 0%{?fedora} || 0%{?rhel} >= 6 %global with_devel 1 %global with_bundled 1 %global with_debug 1 # No test files so far %global with_check 0 %global with_unit_test 0 %else %global with_devel 0 %global with_bundled 0 %global with_debug 1 %global with_check 0 %global with_unit_test 0 %endif %global default_port 9090 %global default_user grafana %global default_group grafana %if 0%{?with_debug} %global _dwz_low_mem_die_limit 0 %else %global debug_package %{nil} %endif %define copying() \ %if 0%{?fedora} >= 21 || 0%{?rhel} >= 7 \ %license %{*} \ %else \ %doc %{*} \ %endif %global isgccgoarch 0 %if 0%{?gccgo_arches:1} %ifarch %{gccgo_arches} %global isgccgoarch 1 %endif %endif %define __gopath %{gopath}:/usr/share/gocode:/usr/lib/golang/ %global provider github %global provider_tld com %global project grafana %global repo grafana %global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo} %global import_path %{provider_prefix} %global commit 2040f61c568b83dda3ef4934c86c993a215345ec %global shortcommit %(c=%{commit}; echo ${c:0:7}) Name: golang-%{provider}-%{project}-%{repo} Version: 5.2.1 Release: 1%{?dist} Summary: Dashboards and editors for Graphite, InfluxDB, OpenTSDB License: ASL 2.0 URL: https://%{provider_prefix} Source0: https://%{provider_prefix}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz Patch0: hack-makefile.patch Source1: sysconfig.grafana Source2: grafana.service Source3: grafana.FEDORA-README.md Source4: grafana-fedora.ini Patch1: grafana-5.1.2.Makefile.patch # If go_arches not defined fall through to implicit golang archs %if 0%{?go_arches:1} ExclusiveArch: %{go_arches} %else ExclusiveArch: %{ix86} x86_64 %{arm} %endif # If gccgo_arches does not fit or is not defined fall through to golang %if %{isgccgoarch} BuildRequires: gcc-go >= %{gccgo_min_vers} %else BuildRequires: golang >= 1.7 %endif BuildRequires: systemd Requires: npm Requires: nodejs-grunt-cli Requires(pre): shadow-utils %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. %package -n %{repo} Summary: %{summary} %if ! 0%{?with_bundled} BuildRequires: golang(github.com/BurntSushi/toml) BuildRequires: golang(github.com/Unknwon/com) BuildRequires: golang(github.com/aws/aws-sdk-go) BuildRequires: golang(github.com/go-sql-driver/mysql) BuildRequires: golang(github.com/go-xorm/core) BuildRequires: golang(github.com/go-xorm/xorm) BuildRequires: golang(github.com/gosimple/slug) BuildRequires: golang(github.com/jmespath/go-jmespath) BuildRequires: golang(github.com/jtolds/gls) BuildRequires: golang(github.com/lib/pq) BuildRequires: golang(github.com/go-macaron/binding) BuildRequires: golang(github.com/go-macaron/gzip) BuildRequires: golang(github.com/go-macaron/session) BuildRequires: golang(github.com/mattn/go-sqlite3) BuildRequires: golang(github.com/rainycape/unidecode) BuildRequires: golang(github.com/smartystreets/goconvey) BuildRequires: golang(github.com/streadway/amqp) BuildRequires: golang(golang.org/x/net/context) BuildRequires: golang(golang.org/x/oauth2) BuildRequires: golang(gopkg.in/asn1-ber.v1) BuildRequires: golang(gopkg.in/bufio.v1) BuildRequires: golang(gopkg.in/ldap.v2) BuildRequires: golang(gopkg.in/macaron.v1) BuildRequires: golang(gopkg.in/ini.v1) BuildRequires: golang(gopkg.in/redis.v2) BuildRequires: golang(golang.org/x/sync/errgroup) BuildRequires: golang(github.com/codegangsta/cli) %endif BuildRequires: nodejs-grunt-cli Provides: grafana = %{version}-%{release} %description -n %{repo} %{summary} %if 0%{?with_devel} %package devel Summary: %{summary} BuildArch: noarch %if 0%{?with_check} BuildRequires: golang(github.com/aws/aws-sdk-go) BuildRequires: golang(github.com/benbjohnson/clock) BuildRequires: golang(github.com/fatih/color) BuildRequires: golang(github.com/go-ldap/ldap) BuildRequires: golang(github.com/go-macaron/binding) BuildRequires: golang(github.com/go-macaron/gzip) BuildRequires: golang(github.com/go-macaron/session) BuildRequires: golang(github.com/gorilla/websocket) BuildRequires: golang(github.com/gosimple/slug) BuildRequires: golang(github.com/go-sql-driver/mysql) BuildRequires: golang(github.com/go-stack/stack) BuildRequires: golang(github.com/go-xorm/core) BuildRequires: golang(github.com/go-xorm/xorm) BuildRequires: golang(github.com/hashicorp/go-version) BuildRequires: golang(github.com/inconshreveable/log15) BuildRequires: golang(github.com/lib/pq) BuildRequires: golang(github.com/mattn/go-sqlite3) BuildRequires: golang(github.com/patrickmn/go-cache) BuildRequires: golang(github.com/streadway/amqp) BuildRequires: golang(github.com/Unknwon/com) BuildRequires: golang(golang.org/x/oauth2) BuildRequires: golang(gopkg.in/gomail.v2) BuildRequires: golang(gopkg.in/ini.v1) BuildRequires: golang(gopkg.in/macaron.v1) %endif # TODO # Requires: golang(bitbucket.org/ww/goautoneg) # TODO # Provides: golang(%{import_path}/config) = %{version}-%{release} %description devel %{summary} This package contains library source intended for building other packages which use %{project}/%{repo}. %endif %if 0%{?with_unit_test} %package unit-test Summary: Unit tests for %{name} package # If go_arches not defined fall through to implicit golang archs %if 0%{?go_arches:1} ExclusiveArch: %{go_arches} %else ExclusiveArch: %{ix86} x86_64 %{arm} %endif # If gccgo_arches does not fit or is not defined fall through to golang %if %{isgccgoarch} BuildRequires: gcc-go >= %{gccgo_min_vers} %else BuildRequires: golang %endif %if 0%{?with_check} #Here comes all BuildRequires: PACKAGE the unit tests #in %%check section need for running %endif # test subpackage tests code from devel subpackage Requires: %{name}-devel = %{version}-%{release} %description unit-test %{summary} This package contains unit tests for project providing packages with %{import_path} prefix. %endif %prep %setup -q -n %{repo}-%{commit} #%patch0 -p1 cp %{SOURCE3} FEDORA-README.md %patch1 -p1 %build # If gccgo_arches does not fit or is not defined fall through to golang # gccco arches %if %{isgccgoarch} %if 0%{?gcc_go_build:1} export GOCOMPILER='%{gcc_go_build}' %else echo "No compiler for SA" exit 1 %endif # golang arches (due to ExclusiveArch) %else %if 0%{?golang_build:1} export GOCOMPILER='%{golang_build} -ldflags "$LDFLAGS"' %else export GOCOMPILER='go build -ldflags "$LDFLAGS"' %endif %endif export LDFLAGS="" %if 0%{?with_debug} %if %{isgccgoarch} export OLD_RPM_OPT_FLAGS="$RPM_OPT_FLAGS" function gobuild { export RPM_OPT_FLAGS="$OLD_RPM_OPT_FLAGS -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n')" eval ${GOCOMPILER} -a -v -x "$@"; } %else export OLD_LDFLAGS="$LDFLAGS" function gobuild { export LDFLAGS="$OLD_LDFLAGS -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n')" eval ${GOCOMPILER} -a -v -x "$@"; } %endif %else function gobuild { eval ${GOCOMPILER} -a -v -x "$@"; } %endif # set working directory mkdir -p src/github.com/grafana/ ln -s ../../../ src/github.com/grafana/grafana %if ! 0%{?with_bundled} export GOPATH=$(pwd):%{__gopath} %else # build from bundled dependencies export GOPATH=$(pwd):$(pwd)/Godeps/_workspace:%{__gopath} %endif # set environment variables export GO_VERSION=$(go version | cut -d' ' -f3 | sed 's/go//') export BUILDDATE=$(date +%Y%m%d-%H:%M:%S) # build grafana export OLD_LDFLAGS="$OLD_LDFLAGS -X main.buildVersion=%{version} -X main.buildRevision=%{shortcommit} -X main.buildBranch=master -X main.buildUser=fedora -X main.buildDate=${BUILDDATE} -X main.goVersion=${GO_VERSION}" gobuild -o bin/grafana-server %{import_path}/pkg/cmd/grafana-server gobuild -o bin/grafana-cli %{import_path}/pkg/cmd/grafana-cli %install install -d -p %{buildroot}%{_bindir} \ %{buildroot}%{_sysconfdir}/grafana \ %{buildroot}%{_sysconfdir}/sysconfig \ %{buildroot}%{_unitdir} \ %{buildroot}%{_sharedstatedir}/grafana/data \ %{buildroot}%{_sharedstatedir}/grafana/frontend \ %{buildroot}%{_defaultdocdir}/grafana \ %{buildroot}%{_localstatedir}/log/grafana install -D -p -m 0755 {bin/,%{buildroot}%{_bindir}/}grafana-cli install -D -p -m 0755 {bin/,%{buildroot}%{_bindir}/}grafana-server install -p -m 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/sysconfig/grafana install -p -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/grafana.service install -D -m 0640 %{SOURCE4} %{buildroot}%{_sysconfdir}/grafana/grafana.ini # install -D -m 0640 {conf/,%{buildroot}%{_sysconfdir}/grafana/}ldap.toml # install -D -m 0640 {conf/,%{buildroot}%{_sysconfdir}/grafana/}sample.ini # install -D -m 0644 {conf/,%{buildroot}%{_sharedstatedir}/grafana/frontend/conf/}defaults.ini install -d -m 0755 %{buildroot}%{_sharedstatedir}/grafana/frontend/ # ./vendor/phantomjs \ cp -ar \ appveyor.yml \ .bra.toml \ build.go \ conf \ codecov.yml \ Gopkg.lock \ Gopkg.toml \ .editorconfig \ emails \ Gruntfile.js \ jest.config.js \ .jscs.json \ .jshintrc \ karma.conf.js \ latest.json \ Makefile \ package.json \ public \ scripts \ tasks \ tsconfig.json \ tslint.json \ yarn.lock \ %{buildroot}%{_sharedstatedir}/grafana/frontend/ # install -d -p docs %{buildroot}%{_defaultdocdir}/grafana # source codes for building projects %if 0%{?with_devel} install -d -p %{buildroot}/%{gopath}/src/%{import_path}/ # find all *.go but no *_test.go files and generate devel.file-list for file in $(find . -iname "*.go" \! -iname "*_test.go") ; do install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file) cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list done %endif # testing files for this project %if 0%{?with_unit_test} install -d -p %{buildroot}/%{gopath}/src/%{import_path}/ # find all *_test.go files and generate unit-test.file-list for file in $(find . -iname "*_test.go"); do install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file) cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test.file-list done for file in $(find ./config/testdata -iname "*"); do install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file) cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test.file-list done for file in $(find ./promql/testdata -iname "*"); do install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file) cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test.file-list done %endif %check %if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel} %if %{isgccgoarch} function gotest { %{gcc_go_test} "$@"; } %else %if 0%{?golang_test:1} function gotest { %{golang_test} "$@"; } %else function gotest { go test "$@"; } %endif %endif export GOPATH=%{buildroot}/%{gopath}:%{gopath} gotest %{import_path}/web/api gotest %{import_path}/utility gotest %{import_path}/templates gotest %{import_path}/storage/remote gotest %{import_path}/storage/remote/opentsdb gotest %{import_path}/storage/remote/influxdb gotest %{import_path}/storage/metric #gotest %{import_path}/storage/local #gotest %{import_path}/storage/local/flock #gotest %{import_path}/storage/local/codable #gotest %{import_path}/rules #gotest %{import_path}/promql gotest %{import_path}/retrieval gotest %{import_path}/notification gotest %{import_path}/config %endif %pre getent group %{default_group} > /dev/null || groupadd -r %{default_group} getent passwd %default_user} > /dev/null || \ useradd -r -g %{default_group} -d %{_sharedstatedir}/grafana -s /sbin/nologin \ -c "Grafana dashboard system" %{default_user} exit 0 %post if [ -f %{_sysconfdir}/sysconfig/grafana ] then . %{_sysconfdir}/sysconfig/grafana if [ "$AUTOUPDATE_FRONTEND" = "YES" ] then pushd %{_sharedstatedir}/grafana/frontend make frontend popd fi fi %systemd_post grafana.service %preun %systemd_preun grafana.service %postun %systemd_postun %files -n %{repo} %copying LICENSE.md %doc CHANGELOG.md NOTICE.md README.md ROADMAP.md docs FEDORA-README.md CODE_OF_CONDUCT.md LICENSE.md PLUGIN_DEV.md examples %{_bindir}/* %{_unitdir}/grafana.service %config(noreplace) %{_sysconfdir}/sysconfig/grafana %attr(-,%{default_user},%{default_group}) %config(noreplace) %{_sysconfdir}/grafana/* %attr(-,%{default_user},%{default_group}) %{_sharedstatedir}/grafana %attr(-,%{default_user},%{default_group}) %{_localstatedir}/log/grafana %if 0%{?with_devel} %files devel -f devel.file-list %copying LICENSE.md %doc CHANGELOG.md NOTICE.md README.md ROADMAP.md docs %dir %{gopath}/src/%{provider}.%{provider_tld}/%{project} %dir %{gopath}/src/%{import_path} %endif %if 0%{?with_unit_test} %files unit-test -f unit-test.file-list %copying LICENSE.md %doc README.md %endif %changelog * Mon Jul 16 2018 Michal Ingeli - 5.2.1-1 - New upstream release * Mon Jul 2 2018 Michal Ingeli - 5.1.5-1 - New upstream release * Mon Jun 4 2018 Michal Ingeli - 5.1.3-1 - New upstream release * Thu May 10 2018 Michal Ingeli - 5.1.2-2 - Fixed user pre-inst * Thu May 10 2018 Michal Ingeli - 5.1.2-1 - Version upgrade from upstream * Thu May 10 2018 Michal Ingeli - 4.6.3-1 - Version upgrade from upstream * Fri Dec 1 2017 Michal Ingeli - 4.6.2-2 - Added files into frontend directory * Fri Dec 1 2017 Michal Ingeli - 4.6.2-1 - New upstream release * Tue May 30 2017 Michal Ingeli - 4.3.1-3 - Added option for autoupdating frontend * Mon May 29 2017 Michal Ingeli - 4.3.1-2 - Added fedora readme and moved frontend to dedicated directory * Thu May 25 2017 Michal Ingeli - 3.1.1-1 - SPEC file pulled from OpenSUSE and merged with prometheus one. https://build.opensuse.org/package/view_file/devel:ARM:containers/grafana/grafana.spec