Blame 006-native-RPM-spec-and-webpack-build-script.patch

1f64cbe
diff --git a/packaging/rpm/spec/README b/packaging/rpm/spec/README
1f64cbe
new file mode 100644
1f64cbe
index 000000000..f97c2a26b
1f64cbe
--- /dev/null
1f64cbe
+++ b/packaging/rpm/spec/README
1f64cbe
@@ -0,0 +1,7 @@
1f64cbe
+The make_webpack.sh script in this directory can be used to create
1f64cbe
+a webpack tarball of all the nodejs dependencies needed to build a
1f64cbe
+particular tagged version of grafana, along with the grafana tarball
1f64cbe
+itself. After running the script, the two tarballs should be copied
1f64cbe
+to your rpmbuild SOURCES. You can then run a native rpm spec build
1f64cbe
+using grafana.spec.
1f64cbe
+
1f64cbe
diff --git a/packaging/rpm/spec/grafana.spec b/packaging/rpm/spec/grafana.spec
1f64cbe
new file mode 100644
1f64cbe
index 000000000..9d69b105e
1f64cbe
--- /dev/null
1f64cbe
+++ b/packaging/rpm/spec/grafana.spec
1f64cbe
@@ -0,0 +1,511 @@
1f64cbe
+%global grafana_arches %{lua: go_arches = {}
1f64cbe
+  for arch in rpm.expand("%{go_arches}"):gmatch("%S+") do
1f64cbe
+    go_arches[arch] = 1
1f64cbe
+  end
1f64cbe
+  for arch in rpm.expand("%{nodejs_arches}"):gmatch("%S+") do
1f64cbe
+    if go_arches[arch] then
1f64cbe
+      print(arch .. " ")
1f64cbe
+  end
1f64cbe
+end}
1f64cbe
+
1f64cbe
+Name:             grafana
1f64cbe
+Version:          6.1.4
1f64cbe
+Release:          1%{?dist}
1f64cbe
+Summary:          Metrics dashboard and graph editor
1f64cbe
+License:          ASL 2.0
1f64cbe
+URL:              https://grafana.org
1f64cbe
+
1f64cbe
+# Source0 contains the tagged upstream sources
1f64cbe
+Source0:          https://github.com/grafana/grafana/archive/v%{version}/%{name}-%{version}.tar.gz
1f64cbe
+
1f64cbe
+# Source1 contains the front-end javascript modules bundled into a webpack
1f64cbe
+Source1:          grafana_webpack-%{version}.tar.gz
1f64cbe
+
1f64cbe
+# Source2 is the script to create the above webpack from grafana sources
1f64cbe
+Source2:          make_webpack.sh
1f64cbe
+
1f64cbe
+# Patches for upstream (except Patch5)
1f64cbe
+Patch0:           000-go-test-fixes.patch
1f64cbe
+Patch1:           001-man-pages.patch
1f64cbe
+Patch2:           002-update-golang-oauth2-vendor-sources.patch
1f64cbe
+Patch3:           003-file-mode-updates.patch
1f64cbe
+Patch4:           004-grafana.ini-for-Linux-distros.patch
1f64cbe
+Patch5:           005-remove-jaeger-tracing.patch
1f64cbe
+Patch6:           006-native-RPM-spec-and-webpack-build-script.patch
1f64cbe
+
1f64cbe
+# Intersection of go_arches and nodejs_arches
1f64cbe
+ExclusiveArch:    %{grafana_arches}
1f64cbe
+
1f64cbe
+%global           GRAFANA_USER %{name}
1f64cbe
+%global           GRAFANA_GROUP %{name}
1f64cbe
+%global           GRAFANA_HOME %{_datadir}/%{name}
1f64cbe
+
1f64cbe
+# grafana-server service daemon uses systemd
1f64cbe
+%{?systemd_requires}
1f64cbe
+Requires(pre):    shadow-utils
1f64cbe
+
1f64cbe
+BuildRequires:    systemd, golang, compiler(go-compiler)
1f64cbe
+
1f64cbe
+# golang build deps. These allow us to unbundle vendor golang source.
1f64cbe
+BuildRequires: golang(github.com/aws/aws-sdk-go)
1f64cbe
+BuildRequires: golang(github.com/benbjohnson/clock)
1f64cbe
+BuildRequires: golang(github.com/beorn7/perks/quantile)
1f64cbe
+BuildRequires: golang(github.com/bmizerany/assert)
1f64cbe
+BuildRequires: golang(github.com/bradfitz/gomemcache/memcache)
1f64cbe
+BuildRequires: golang(github.com/BurntSushi/toml)
1f64cbe
+BuildRequires: golang(github.com/codahale/hdrhistogram)
1f64cbe
+BuildRequires: golang(github.com/codegangsta/cli)
1f64cbe
+BuildRequires: golang(github.com/davecgh/go-spew/spew)
1f64cbe
+BuildRequires: golang(github.com/denisenkom/go-mssqldb)
1f64cbe
+BuildRequires: golang(github.com/facebookgo/inject)
1f64cbe
+BuildRequires: golang(github.com/facebookgo/structtag)
1f64cbe
+BuildRequires: golang(github.com/fatih/color)
1f64cbe
+BuildRequires: golang(github.com/go-ini/ini)
1f64cbe
+BuildRequires: golang(google.golang.org/appengine)
1f64cbe
+BuildRequires: golang(golang.org/x/sys/unix)
1f64cbe
+BuildRequires: golang(github.com/go-macaron/binding)
1f64cbe
+BuildRequires: golang(github.com/go-macaron/gzip)
1f64cbe
+BuildRequires: golang(github.com/go-macaron/inject)
1f64cbe
+BuildRequires: golang(github.com/go-macaron/session)
1f64cbe
+BuildRequires: golang(google.golang.org/genproto/googleapis/rpc/status)
1f64cbe
+BuildRequires: golang(github.com/gopherjs/gopherjs/js)
1f64cbe
+BuildRequires: golang(github.com/gorilla/websocket)
1f64cbe
+BuildRequires: golang(github.com/gosimple/slug)
1f64cbe
+BuildRequires: golang(github.com/go-sql-driver/mysql)
1f64cbe
+BuildRequires: golang(github.com/go-stack/stack)
1f64cbe
+BuildRequires: golang(github.com/go-xorm/builder)
1f64cbe
+BuildRequires: golang(github.com/go-xorm/core)
1f64cbe
+BuildRequires: golang(github.com/go-xorm/xorm)
1f64cbe
+BuildRequires: golang(google.golang.org/grpc)
1f64cbe
+BuildRequires: golang(github.com/hashicorp/go-hclog)
1f64cbe
+# need grpc_broker in go-plugin >= 1.0.0-1
1f64cbe
+BuildRequires: golang(github.com/hashicorp/go-plugin)
1f64cbe
+BuildRequires: golang(github.com/hashicorp/go-version)
1f64cbe
+BuildRequires: golang(github.com/hashicorp/yamux)
1f64cbe
+BuildRequires: golang(github.com/inconshreveable/log15)
1f64cbe
+BuildRequires: golang(github.com/jmespath/go-jmespath)
1f64cbe
+BuildRequires: golang(github.com/jtolds/gls)
1f64cbe
+BuildRequires: golang(github.com/klauspost/compress/flate)
1f64cbe
+BuildRequires: golang(github.com/klauspost/compress/gzip)
1f64cbe
+BuildRequires: golang(github.com/klauspost/compress/snappy)
1f64cbe
+BuildRequires: golang(github.com/klauspost/cpuid)
1f64cbe
+BuildRequires: golang(github.com/klauspost/crc32)
1f64cbe
+BuildRequires: golang(github.com/kr/pretty)
1f64cbe
+BuildRequires: golang(github.com/kr/text)
1f64cbe
+BuildRequires: golang(github.com/lib/pq)
1f64cbe
+BuildRequires: golang(github.com/mattn/go-colorable)
1f64cbe
+BuildRequires: golang(github.com/mattn/go-isatty)
1f64cbe
+BuildRequires: golang(github.com/mattn/go-sqlite3)
1f64cbe
+BuildRequires: golang(github.com/matttproud/golang_protobuf_extensions/pbutil)
1f64cbe
+BuildRequires: golang(github.com/mitchellh/go-testing-interface)
1f64cbe
+BuildRequires: golang(github.com/oklog/run)
1f64cbe
+BuildRequires: golang(github.com/opentracing/opentracing-go)
1f64cbe
+BuildRequires: golang(github.com/patrickmn/go-cache)
1f64cbe
+BuildRequires: golang(github.com/pkg/errors)
1f64cbe
+BuildRequires: golang(github.com/prometheus/client_golang/api)
1f64cbe
+BuildRequires: golang(github.com/prometheus/client_golang/api/prometheus/v1)
1f64cbe
+BuildRequires: golang(github.com/prometheus/client_model/go)
1f64cbe
+BuildRequires: golang-github-prometheus-common-devel
1f64cbe
+BuildRequires: golang(github.com/prometheus/common/expfmt)
1f64cbe
+BuildRequires: golang(github.com/prometheus/common/model)
1f64cbe
+BuildRequires: golang(github.com/prometheus/common/expfmt)
1f64cbe
+BuildRequires: golang(github.com/prometheus/procfs)
1f64cbe
+BuildRequires: golang(github.com/prometheus/procfs/internal/util)
1f64cbe
+BuildRequires: golang(github.com/prometheus/procfs)
1f64cbe
+BuildRequires: golang(github.com/prometheus/procfs/internal/util)
1f64cbe
+BuildRequires: golang(github.com/prometheus/procfs/nfs)
1f64cbe
+BuildRequires: golang(github.com/prometheus/procfs/xfs)
1f64cbe
+BuildRequires: golang(github.com/rainycape/unidecode)
1f64cbe
+BuildRequires: golang(github.com/sergi/go-diff/diffmatchpatch)
1f64cbe
+BuildRequires: golang(github.com/smartystreets/assertions)
1f64cbe
+BuildRequires: golang(github.com/smartystreets/goconvey/convey)
1f64cbe
+BuildRequires: golang(github.com/smartystreets/goconvey/convey/gotest)
1f64cbe
+BuildRequires: golang(github.com/smartystreets/goconvey/convey/reporting)
1f64cbe
+BuildRequires: golang(github.com/teris-io/shortid)
1f64cbe
+BuildRequires: golang(github.com/Unknwon/com)
1f64cbe
+BuildRequires: golang(github.com/VividCortex/mysqlerr)
1f64cbe
+BuildRequires: golang(github.com/yudai/gojsondiff)
1f64cbe
+BuildRequires: golang(github.com/yudai/golcs)
1f64cbe
+BuildRequires: golang(golang.org/x/crypto/pbkdf2)
1f64cbe
+BuildRequires: golang(golang.org/x/crypto/ed25519)
1f64cbe
+BuildRequires: golang(golang.org/x/crypto/md4)
1f64cbe
+BuildRequires: golang(golang.org/x/net/context)
1f64cbe
+BuildRequires: golang(golang.org/x/net/context/ctxhttp)
1f64cbe
+BuildRequires: golang(golang.org/x/net/http2)
1f64cbe
+BuildRequires: golang(golang.org/x/net/http2/hpack)
1f64cbe
+BuildRequires: golang(golang.org/x/net/http/httpguts)
1f64cbe
+BuildRequires: golang(golang.org/x/net/idna)
1f64cbe
+BuildRequires: golang(golang.org/x/net/internal/timeseries)
1f64cbe
+BuildRequires: golang(golang.org/x/net/trace)
1f64cbe
+BuildRequires: golang(golang.org/x/text/collate)
1f64cbe
+BuildRequires: golang(golang.org/x/text/collate/build)
1f64cbe
+BuildRequires: golang(golang.org/x/text/internal/colltab)
1f64cbe
+BuildRequires: golang(golang.org/x/text/internal/gen)
1f64cbe
+BuildRequires: golang(golang.org/x/text/internal/tag)
1f64cbe
+BuildRequires: golang(golang.org/x/text/internal/triegen)
1f64cbe
+BuildRequires: golang(golang.org/x/text/internal/ucd)
1f64cbe
+BuildRequires: golang(golang.org/x/oauth2)
1f64cbe
+BuildRequires: golang(golang.org/x/oauth2/google)
1f64cbe
+BuildRequires: golang(golang.org/x/oauth2/internal)
1f64cbe
+BuildRequires: golang(golang.org/x/oauth2/jws)
1f64cbe
+BuildRequires: golang(golang.org/x/oauth2/jwt)
1f64cbe
+BuildRequires: golang(github.com/golang/protobuf/proto)
1f64cbe
+BuildRequires: golang(github.com/golang/protobuf/ptypes)
1f64cbe
+BuildRequires: golang(github.com/golang/protobuf/ptypes)
1f64cbe
+BuildRequires: golang(github.com/golang/protobuf/ptypes/duration)
1f64cbe
+BuildRequires: golang(github.com/golang/protobuf/ptypes/any)
1f64cbe
+BuildRequires: golang(github.com/golang/protobuf/ptypes/timestamp)
1f64cbe
+BuildRequires: golang(cloud.google.com/go/compute/metadata)
1f64cbe
+BuildRequires: golang(gopkg.in/alexcesaro/quotedprintable.v3)
1f64cbe
+BuildRequires: golang(gopkg.in/asn1-ber.v1)
1f64cbe
+BuildRequires: golang(github.com/go-bufio/bufio)
1f64cbe
+BuildRequires: golang(github.com/go-ini/ini)
1f64cbe
+BuildRequires: golang(github.com/go-macaron/macaron)
1f64cbe
+BuildRequires: golang(github.com/go-redis/redis)
1f64cbe
+BuildRequires: golang(gopkg.in/square/go-jose.v2)
1f64cbe
+BuildRequires: golang(gopkg.in/square/go-jose.v2/cipher)
1f64cbe
+BuildRequires: golang(gopkg.in/square/go-jose.v2/json)
1f64cbe
+BuildRequires: golang(github.com/go-yaml/yaml)
1f64cbe
+BuildRequires: golang(golang.org/x/sync/errgroup)
1f64cbe
+BuildRequires: golang(gopkg.in/ldap.v3)
1f64cbe
+BuildRequires: golang(gopkg.in/mail.v2)
1f64cbe
+
1f64cbe
+# Declare all nodejs modules bundled in the webpack - this is for security
1f64cbe
+# purposes so if nodejs-foo ever needs an update, affected packages can be
1f64cbe
+# easily identified. This is generated from package-lock.json once the webpack
1f64cbe
+# has been built with make_webpack.sh.
1f64cbe
+Provides: bundled(nodejs-abbrev) = 1.1.1
1f64cbe
+Provides: bundled(nodejs-ansi-regex) = 2.1.1
1f64cbe
+Provides: bundled(nodejs-ansi-styles) = 2.2.1
1f64cbe
+Provides: bundled(nodejs-argparse) = 1.0.10
1f64cbe
+Provides: bundled(nodejs-array-find-index) = 1.0.2
1f64cbe
+Provides: bundled(nodejs-async) = 1.5.2
1f64cbe
+Provides: bundled(nodejs-balanced-match) = 1.0.0
1f64cbe
+Provides: bundled(nodejs-brace-expansion) = 1.1.11
1f64cbe
+Provides: bundled(nodejs-builtin-modules) = 1.1.1
1f64cbe
+Provides: bundled(nodejs-camelcase) = 2.1.1
1f64cbe
+Provides: bundled(nodejs-camelcase-keys) = 2.1.0
1f64cbe
+Provides: bundled(nodejs-chalk) = 1.1.3
1f64cbe
+Provides: bundled(nodejs-coffee-script) = 1.10.0
1f64cbe
+Provides: bundled(nodejs-colors) = 1.1.2
1f64cbe
+Provides: bundled(nodejs-concat-map) = 0.0.1
1f64cbe
+Provides: bundled(nodejs-currently-unhandled) = 0.4.1
1f64cbe
+Provides: bundled(nodejs-dateformat) = 1.0.12
1f64cbe
+Provides: bundled(nodejs-decamelize) = 1.2.0
1f64cbe
+Provides: bundled(nodejs-error-ex) = 1.3.2
1f64cbe
+Provides: bundled(nodejs-escape-string-regexp) = 1.0.5
1f64cbe
+Provides: bundled(nodejs-esprima) = 2.7.3
1f64cbe
+Provides: bundled(nodejs-eventemitter2) = 0.4.14
1f64cbe
+Provides: bundled(nodejs-exit) = 0.1.2
1f64cbe
+Provides: bundled(nodejs-find-up) = 1.1.2
1f64cbe
+Provides: bundled(nodejs-findup-sync) = 0.3.0
1f64cbe
+Provides: bundled(nodejs-fs.realpath) = 1.0.0
1f64cbe
+Provides: bundled(nodejs-get-stdin) = 4.0.1
1f64cbe
+Provides: bundled(nodejs-getobject) = 0.1.0
1f64cbe
+Provides: bundled(nodejs-glob) = 7.0.6
1f64cbe
+Provides: bundled(nodejs-graceful-fs) = 4.1.15
1f64cbe
+Provides: bundled(nodejs-grunt) = 1.0.1
1f64cbe
+Provides: bundled(nodejs-grunt-cli) = 1.2.0
1f64cbe
+Provides: bundled(nodejs-grunt-known-options) = 1.1.1
1f64cbe
+Provides: bundled(nodejs-grunt-legacy-log) = 1.0.2
1f64cbe
+Provides: bundled(nodejs-lodash) = 4.17.11
1f64cbe
+Provides: bundled(nodejs-grunt-legacy-log-utils) = 1.0.0
1f64cbe
+Provides: bundled(nodejs-grunt-legacy-util) = 1.0.0
1f64cbe
+Provides: bundled(nodejs-has-ansi) = 2.0.0
1f64cbe
+Provides: bundled(nodejs-hooker) = 0.2.3
1f64cbe
+Provides: bundled(nodejs-hosted-git-info) = 2.7.1
1f64cbe
+Provides: bundled(nodejs-iconv-lite) = 0.4.24
1f64cbe
+Provides: bundled(nodejs-indent-string) = 2.1.0
1f64cbe
+Provides: bundled(nodejs-inflight) = 1.0.6
1f64cbe
+Provides: bundled(nodejs-inherits) = 2.0.3
1f64cbe
+Provides: bundled(nodejs-is-arrayish) = 0.2.1
1f64cbe
+Provides: bundled(nodejs-is-builtin-module) = 1.0.0
1f64cbe
+Provides: bundled(nodejs-is-finite) = 1.0.2
1f64cbe
+Provides: bundled(nodejs-is-utf8) = 0.2.1
1f64cbe
+Provides: bundled(nodejs-isexe) = 2.0.0
1f64cbe
+Provides: bundled(nodejs-js-yaml) = 3.5.5
1f64cbe
+Provides: bundled(nodejs-load-json-file) = 1.1.0
1f64cbe
+Provides: bundled(nodejs-loud-rejection) = 1.6.0
1f64cbe
+Provides: bundled(nodejs-map-obj) = 1.0.1
1f64cbe
+Provides: bundled(nodejs-meow) = 3.7.0
1f64cbe
+Provides: bundled(nodejs-minimatch) = 3.0.4
1f64cbe
+Provides: bundled(nodejs-minimist) = 1.2.0
1f64cbe
+Provides: bundled(nodejs-nopt) = 3.0.6
1f64cbe
+Provides: bundled(nodejs-normalize-package-data) = 2.4.2
1f64cbe
+Provides: bundled(nodejs-number-is-nan) = 1.0.1
1f64cbe
+Provides: bundled(nodejs-object-assign) = 4.1.1
1f64cbe
+Provides: bundled(nodejs-once) = 1.4.0
1f64cbe
+Provides: bundled(nodejs-parse-json) = 2.2.0
1f64cbe
+Provides: bundled(nodejs-path-exists) = 2.1.0
1f64cbe
+Provides: bundled(nodejs-path-is-absolute) = 1.0.1
1f64cbe
+Provides: bundled(nodejs-path-type) = 1.1.0
1f64cbe
+Provides: bundled(nodejs-pify) = 2.3.0
1f64cbe
+Provides: bundled(nodejs-pinkie) = 2.0.4
1f64cbe
+Provides: bundled(nodejs-pinkie-promise) = 2.0.1
1f64cbe
+Provides: bundled(nodejs-read-pkg) = 1.1.0
1f64cbe
+Provides: bundled(nodejs-read-pkg-up) = 1.0.1
1f64cbe
+Provides: bundled(nodejs-redent) = 1.0.0
1f64cbe
+Provides: bundled(nodejs-repeating) = 2.0.1
1f64cbe
+Provides: bundled(nodejs-resolve) = 1.1.7
1f64cbe
+Provides: bundled(nodejs-rimraf) = 2.2.8
1f64cbe
+Provides: bundled(nodejs-safer-buffer) = 2.1.2
1f64cbe
+Provides: bundled(nodejs-semver) = 5.6.0
1f64cbe
+Provides: bundled(nodejs-signal-exit) = 3.0.2
1f64cbe
+Provides: bundled(nodejs-spdx-correct) = 3.1.0
1f64cbe
+Provides: bundled(nodejs-spdx-exceptions) = 2.2.0
1f64cbe
+Provides: bundled(nodejs-spdx-expression-parse) = 3.0.0
1f64cbe
+Provides: bundled(nodejs-spdx-license-ids) = 3.0.3
1f64cbe
+Provides: bundled(nodejs-sprintf-js) = 1.0.3
1f64cbe
+Provides: bundled(nodejs-strip-ansi) = 3.0.1
1f64cbe
+Provides: bundled(nodejs-strip-bom) = 2.0.0
1f64cbe
+Provides: bundled(nodejs-strip-indent) = 1.0.1
1f64cbe
+Provides: bundled(nodejs-supports-color) = 2.0.0
1f64cbe
+Provides: bundled(nodejs-trim-newlines) = 1.0.0
1f64cbe
+Provides: bundled(nodejs-underscore.string) = 3.2.3
1f64cbe
+Provides: bundled(nodejs-validate-npm-package-license) = 3.0.4
1f64cbe
+Provides: bundled(nodejs-which) = 1.2.14
1f64cbe
+Provides: bundled(nodejs-wrappy) = 1.0.2
1f64cbe
+Provides: bundled(nodejs-yarn) = 1.13.0
1f64cbe
+
1f64cbe
+
1f64cbe
+%description
1f64cbe
+Grafana is an open source, feature rich metrics dashboard and graph editor for
1f64cbe
+Graphite, InfluxDB & OpenTSDB.
1f64cbe
+
1f64cbe
+
1f64cbe
+%prep
1f64cbe
+%setup -q -T -D -b 0
1f64cbe
+%setup -q -T -D -b 1
1f64cbe
+%patch0 -p1
1f64cbe
+%patch1 -p1
1f64cbe
+%patch2 -p1
1f64cbe
+%patch3 -p1
1f64cbe
+%patch4 -p1
1f64cbe
+%patch5 -p1
1f64cbe
+%patch6 -p1
1f64cbe
+
1f64cbe
+# Set up build subdirs and links
1f64cbe
+mkdir -p %{_builddir}/src/github.com/grafana
1f64cbe
+ln -sf %{_builddir}/%{name}-%{version} \
1f64cbe
+    %{_builddir}/src/github.com/grafana/grafana
1f64cbe
+
1f64cbe
+# remove some (apparent) development files, for rpmlint
1f64cbe
+rm -f %{_builddir}/src/github.com/grafana/grafana/public/sass/.sass-lint.yml
1f64cbe
+rm -f %{_builddir}/src/github.com/grafana/grafana/public/test/.jshintrc
1f64cbe
+
1f64cbe
+# Unbundle all grafana vendor sources, as per BuildRequires above.
1f64cbe
+# An exception is grafana-plugin-model, which is part of grafana.
1f64cbe
+cp --parents -a vendor/github.com/grafana %{_builddir}
1f64cbe
+rm -r vendor # remove all vendor sources
1f64cbe
+mv %{_builddir}/vendor vendor # put back what we're keeping
1f64cbe
+
1f64cbe
+
1f64cbe
+%build
1f64cbe
+# Build the server-side binaries: grafana-server and grafana-cli
1f64cbe
+export GOPATH=%{_builddir}:%{gopath}
1f64cbe
+%gobuild -o grafana-cli ./pkg/cmd/grafana-cli
1f64cbe
+%gobuild -o grafana-server ./pkg/cmd/grafana-server
1f64cbe
+
1f64cbe
+
1f64cbe
+%install
1f64cbe
+# binaries
1f64cbe
+install -d %{buildroot}%{_sbindir}
1f64cbe
+install -p -m 755 %{name}-server %{name}-cli %{buildroot}%{_sbindir}
1f64cbe
+
1f64cbe
+# other shared files, public html, webpack
1f64cbe
+install -d %{buildroot}%{_datadir}/%{name}
1f64cbe
+cp -a conf public %{buildroot}%{_datadir}/%{name}
1f64cbe
+
1f64cbe
+# man pages
1f64cbe
+install -d %{buildroot}%{_mandir}/man1
1f64cbe
+install -p -m 644 docs/man/man1/* %{buildroot}%{_mandir}/man1
1f64cbe
+
1f64cbe
+# config dirs
1f64cbe
+install -d %{buildroot}%{_sysconfdir}/%{name}
1f64cbe
+install -d %{buildroot}%{_sysconfdir}/sysconfig
1f64cbe
+
1f64cbe
+# config defaults
1f64cbe
+install -p -m 644 conf/distro-defaults.ini \
1f64cbe
+    %{buildroot}%{_sysconfdir}/%{name}/grafana.ini
1f64cbe
+install -p -m 644 conf/distro-defaults.ini \
1f64cbe
+    %{buildroot}%{_datadir}/%{name}/conf/defaults.ini
1f64cbe
+install -p -m 644 conf/ldap.toml %{buildroot}%{_sysconfdir}/%{name}/ldap.toml
1f64cbe
+install -p -m 644 packaging/rpm/sysconfig/grafana-server \
1f64cbe
+    %{buildroot}%{_sysconfdir}/sysconfig/grafana-server
1f64cbe
+
1f64cbe
+# config database directory and plugins
1f64cbe
+install -d %{buildroot}%{_sharedstatedir}/%{name}
1f64cbe
+install -d -m 755 %{buildroot}%{_sharedstatedir}/%{name}
1f64cbe
+install -d -m 755 %{buildroot}%{_sharedstatedir}/%{name}/plugins
1f64cbe
+
1f64cbe
+# log directory
1f64cbe
+install -d %{buildroot}%{_localstatedir}/log/%{name}
1f64cbe
+
1f64cbe
+# systemd service files
1f64cbe
+install -d %{buildroot}%{_unitdir} # only needed for manual rpmbuilds
1f64cbe
+install -p -m 644 packaging/rpm/systemd/grafana-server.service \
1f64cbe
+    %{buildroot}%{_unitdir}
1f64cbe
+
1f64cbe
+# daemon run pid file config for using tmpfs
1f64cbe
+install -d %{buildroot}%{_tmpfilesdir}
1f64cbe
+echo "d %{_rundir}/%{name} 0755 %{GRAFANA_USER} %{GRAFANA_GROUP} -" \
1f64cbe
+    > %{buildroot}%{_tmpfilesdir}/%{name}.conf
1f64cbe
+
1f64cbe
+%pre
1f64cbe
+getent group %{GRAFANA_GROUP} >/dev/null || groupadd -r %{GRAFANA_GROUP}
1f64cbe
+getent passwd %{GRAFANA_USER} >/dev/null || \
1f64cbe
+    useradd -r -g %{GRAFANA_GROUP} -d %{GRAFANA_HOME} -s /sbin/nologin \
1f64cbe
+    -c "%{GRAFANA_USER} user account" %{GRAFANA_USER}
1f64cbe
+exit 0
1f64cbe
+
1f64cbe
+%preun
1f64cbe
+%systemd_preun grafana-server.service
1f64cbe
+
1f64cbe
+%post
1f64cbe
+%systemd_post grafana-server.service
1f64cbe
+
1f64cbe
+%postun
1f64cbe
+%systemd_postun_with_restart grafana-server.service
1f64cbe
+
1f64cbe
+
1f64cbe
+%check
1f64cbe
+cd %{_builddir}/src/github.com/grafana/grafana
1f64cbe
+export GOPATH=%{_builddir}:%{gopath}
1f64cbe
+# this test fails for some reason
1f64cbe
+rm -f pkg/services/provisioning/dashboards/file_reader_linux_test.go
1f64cbe
+# should be using %%gochecks here, but it doesn't work
1f64cbe
+go test ./pkg/...
1f64cbe
+
1f64cbe
+
1f64cbe
+%files
1f64cbe
+# binaries
1f64cbe
+%{_sbindir}/%{name}-server
1f64cbe
+%{_sbindir}/%{name}-cli
1f64cbe
+
1f64cbe
+# config files
1f64cbe
+%dir %{_sysconfdir}/%{name}
1f64cbe
+%config(noreplace) %attr(644, root, %{GRAFANA_GROUP}) %{_sysconfdir}/%{name}/grafana.ini
1f64cbe
+%config(noreplace) %attr(644, root, %{GRAFANA_GROUP}) %{_sysconfdir}/%{name}/ldap.toml
1f64cbe
+%config(noreplace) %{_sysconfdir}/sysconfig/grafana-server
1f64cbe
+
1f64cbe
+# Grafana configuration to dynamically create /run/grafana/grafana.pid on tmpfs
1f64cbe
+%{_tmpfilesdir}/%{name}.conf
1f64cbe
+
1f64cbe
+# config database directory and plugins (actual db files are created by grafana-server)
1f64cbe
+%attr(-, %{GRAFANA_USER}, %{GRAFANA_GROUP}) %dir %{_sharedstatedir}/%{name}
1f64cbe
+%attr(-, %{GRAFANA_USER}, %{GRAFANA_GROUP}) %dir %{_sharedstatedir}/%{name}/plugins
1f64cbe
+
1f64cbe
+# shared directory and all files therein
1f64cbe
+%dir %{_datadir}/%{name}
1f64cbe
+%{_datadir}/%{name}/public
1f64cbe
+%dir %{_datadir}/%{name}/conf
1f64cbe
+%attr(-, root, %{GRAFANA_GROUP}) %{_datadir}/%{name}/conf/*
1f64cbe
+
1f64cbe
+# systemd service file
1f64cbe
+%{_unitdir}/grafana-server.service
1f64cbe
+
1f64cbe
+# log directory - grafana.log is created by grafana-server, and it does it's own log rotation
1f64cbe
+%attr(0755, %{GRAFANA_USER}, %{GRAFANA_GROUP}) %dir %{_localstatedir}/log/%{name}
1f64cbe
+
1f64cbe
+# man pages for grafana binaries
1f64cbe
+%{_mandir}/man1/%{name}-server.1*
1f64cbe
+%{_mandir}/man1/%{name}-cli.1*
1f64cbe
+
1f64cbe
+# other docs and license
1f64cbe
+%license LICENSE
1f64cbe
+%doc CHANGELOG.md CODE_OF_CONDUCT.md CONTRIBUTING.md NOTICE.md
1f64cbe
+%doc PLUGIN_DEV.md README.md ROADMAP.md UPGRADING_DEPENDENCIES.md
1f64cbe
+
1f64cbe
+
1f64cbe
+%changelog
1f64cbe
+* Wed Apr 24 2019 Mark Goodwin <mgoodwin@redhat.com> 6.1.4-1
1f64cbe
+- update to latest upstream stable release 6.1.4, see CHANGELOG
1f64cbe
+- use gobuild and gochecks macros, eliminate arch symlinks
1f64cbe
+- re-enable grafana-debugsource package
1f64cbe
+- fix GRAFANA_GROUP typo
1f64cbe
+- fix more modes for brp-mangle-shebangs
1f64cbe
+- vendor source unbundling now done in prep after patches
1f64cbe
+- remove all rhel and fedora conditional guff
1f64cbe
+
1f64cbe
+* Tue Apr 16 2019 Mark Goodwin <mgoodwin@redhat.com> 6.1.3-1
1f64cbe
+- update to latest upstream stable release 6.1.3, see CHANGELOG
1f64cbe
+- unbundle all vendor sources, replace with BuildRequires, see
1f64cbe
+  the long list of blocker BZs linked to BZ#1670656
1f64cbe
+- BuildRequires go-plugin >= v1.0.0 for grpc_broker (thanks eclipseo)
1f64cbe
+- tweak make_webpack to no longer use grunt, switch to prod build
1f64cbe
+- add ExclusiveArch lua script (thanks quantum.analyst)
1f64cbe
+- move db directory and plugins to /var/lib/grafana
1f64cbe
+- split out into 6 patches, ready for upstream PRs
1f64cbe
+- add check to run go tests for gating checks
1f64cbe
+
1f64cbe
+* Thu Apr 04 2019 Mark Goodwin <mgoodwin@redhat.com> 6.1.0-1
1f64cbe
+- update to latest upstream stable release 6.1.0, see CHANGELOG
1f64cbe
+
1f64cbe
+* Thu Mar 21 2019 Mark Goodwin <mgoodwin@redhat.com> 6.0.2-1
1f64cbe
+- bump to latest upstream stable release 6.0.2-1
1f64cbe
+- unbundle almost all remaining vendor code, see linked blockers in BZ#1670656
1f64cbe
+
1f64cbe
+* Fri Mar 15 2019 Mark Goodwin <mgoodwin@redhat.com> 6.0.1-3
1f64cbe
+- bump to latest upstream stable release 6.0.1-1
1f64cbe
+
1f64cbe
+* Thu Mar 14 2019 Mark Goodwin <mgoodwin@redhat.com> 6.0.1-2
1f64cbe
+- unbundle and add BuildRequires for golang-github-rainycape-unidecode-devel
1f64cbe
+
1f64cbe
+* Thu Mar 07 2019 Mark Goodwin <mgoodwin@redhat.com> 6.0.1-1
1f64cbe
+- update to v6.0.1 upstream sources, tweak distro config, re-do patch
1f64cbe
+- simplify make_webpack.sh script (Elliott Sales de Andrade)
1f64cbe
+- vendor/github.com/go-ldap is now gone, so don't unbundle it
1f64cbe
+
1f64cbe
+* Thu Mar 07 2019 Mark Goodwin <mgoodwin@redhat.com> 5.4.3-11
1f64cbe
+- tweak after latest feedback, bump to 5.4.3-11 (BZ 1670656)
1f64cbe
+- build debuginfo package again
1f64cbe
+- unbundle BuildRequires for golang-github-hashicorp-version-devel
1f64cbe
+- remove some unneeded development files
1f64cbe
+- remove macros from changelog and other rpmlint tweaks
1f64cbe
+
1f64cbe
+* Fri Feb 22 2019 Mark Goodwin <mgoodwin@redhat.com> 5.4.3-10
1f64cbe
+- tweak spec for available and unavailable (bundled) golang packages
1f64cbe
+
1f64cbe
+* Wed Feb 20 2019 Xavier Bachelot <xavier@bachelot.org> 5.4.3-9
1f64cbe
+- Remove extraneous slash (cosmetic)
1f64cbe
+- Create directories just before moving stuff in them
1f64cbe
+- Truncate long lines
1f64cbe
+- Group all golang stuff
1f64cbe
+- Simplify BuildRequires/bundled Provides
1f64cbe
+- Sort BuildRequires/bundled Provides
1f64cbe
+- Fix bundled go packages Provides
1f64cbe
+
1f64cbe
+* Fri Feb 15 2019 Mark Goodwin <mgoodwin@redhat.com> 5.4.3-8
1f64cbe
+- add BuildRequires (and unbundle) vendor sources available in Fedora
1f64cbe
+- declare Provides for remaining (bundled) vendor go sources
1f64cbe
+- do not attempt to unbundle anything on RHEL < 7 or Fedora < 28
1f64cbe
+
1f64cbe
+* Thu Feb 07 2019 Mark Goodwin <mgoodwin@redhat.com> 5.4.3-7
1f64cbe
+- further refinement for spec doc section from Xavier Bachelot
1f64cbe
+- disable debug_package to avoid empty debugsourcefiles.list
1f64cbe
+
1f64cbe
+* Wed Feb 06 2019 Mark Goodwin <mgoodwin@redhat.com> 5.4.3-6
1f64cbe
+- further refinement following review by Xavier Bachelot
1f64cbe
+
1f64cbe
+* Tue Feb 05 2019 Mark Goodwin <mgoodwin@redhat.com> 5.4.3-5
1f64cbe
+- further refinement following review by Xavier Bachelot
1f64cbe
+
1f64cbe
+* Fri Feb 01 2019 Mark Goodwin <mgoodwin@redhat.com> 5.4.3-4
1f64cbe
+- further spec updates after packaging review
1f64cbe
+- reworked post-install scriplets
1f64cbe
+
1f64cbe
+* Thu Jan 31 2019 Mark Goodwin <mgoodwin@redhat.com> 5.4.3-3
1f64cbe
+- tweak FHS patch, update spec after packaging review
1f64cbe
+
1f64cbe
+* Wed Jan 30 2019 Mark Goodwin <mgoodwin@redhat.com> 5.4.3-2
1f64cbe
+- add patch to be standard FHS compliant, remove phantomjs
1f64cbe
+- update to v5.4.3 upstream community sources
1f64cbe
+
1f64cbe
+* Wed Jan 09 2019 Mark Goodwin <mgoodwin@redhat.com> 5.4.2-1
1f64cbe
+- update to v5.4.2 upstream community sources
1f64cbe
+
1f64cbe
+* Thu Oct 18 2018 Mark Goodwin <mgoodwin@redhat.com> 5.3.1-1
1f64cbe
+- update to v5.3.1 upstream community sources
1f64cbe
+
1f64cbe
+* Tue Oct 02 2018 Mark Goodwin <mgoodwin@redhat.com> 5.2.5-1
1f64cbe
+- native RPM spec build with current tagged v5.2.5 sources
1f64cbe
diff --git a/packaging/rpm/spec/make_webpack.sh b/packaging/rpm/spec/make_webpack.sh
1f64cbe
new file mode 100755
1f64cbe
index 000000000..47a8025ff
1f64cbe
--- /dev/null
1f64cbe
+++ b/packaging/rpm/spec/make_webpack.sh
1f64cbe
@@ -0,0 +1,61 @@
1f64cbe
+#! /bin/bash
1f64cbe
+#
1f64cbe
+# Copyright (c) 2019 Red Hat.
1f64cbe
+#
1f64cbe
+# This program is free software; you can redistribute it and/or modify it
1f64cbe
+# under the terms of the GNU General Public License as published by the
1f64cbe
+# Free Software Foundation; either version 2 of the License, or (at your
1f64cbe
+# option) any later version.
1f64cbe
+#
1f64cbe
+# This program is distributed in the hope that it will be useful, but
1f64cbe
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1f64cbe
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1f64cbe
+# for more details.
1f64cbe
+#
1f64cbe
+
1f64cbe
+[ $# -ne 1 ] && echo "Usage: $0 version" && exit 1
1f64cbe
+
1f64cbe
+# grafana version (must be tagged on github.com/grafana/grafana as "v$VER")
1f64cbe
+VER=$1
1f64cbe
+BUILDDIR=`mktemp -d buildXXXXXX`
1f64cbe
+
1f64cbe
+[ ! -f /usr/bin/npm ] && echo Error, please install \"npm\" package && exit 1
1f64cbe
+
1f64cbe
+# get src tree and set cwd
1f64cbe
+echo Fetching pristine upstream git tagged branch for grafana version v$VER ...
1f64cbe
+git clone https://github.com/grafana/grafana grafana-$VER
1f64cbe
+cd grafana-$VER
1f64cbe
+git checkout -b v$VER v$VER
1f64cbe
+
1f64cbe
+# exclude the phantomjs-prebuilt binary module from the webpack
1f64cbe
+sed -i '/phantomjs-prebuilt/d' package.json
1f64cbe
+
1f64cbe
+# nuke grunt task for copying phantomjs
1f64cbe
+rm -f scripts/grunt/options/phantomjs.js
1f64cbe
+sed -i '/phantomjs/d' scripts/grunt/*.js
1f64cbe
+
1f64cbe
+# populate node_modules using package.json
1f64cbe
+echo Running yarn to populate local node_modules ....
1f64cbe
+npm install yarn
1f64cbe
+node_modules/yarn/bin/yarn --non-interactive --no-progress --ignore-engines install --pure-lockfile > yarn.out 2>&1
1f64cbe
+node_modules/yarn/bin/yarn --non-interactive -W add webpack-cli
1f64cbe
+
1f64cbe
+# build the webpack
1f64cbe
+echo;echo Building production webpack ....
1f64cbe
+node_modules/webpack/bin/webpack.js --display errors-only --mode production --config scripts/webpack/webpack.prod.js
1f64cbe
+
1f64cbe
+cd ..
1f64cbe
+
1f64cbe
+# webpack tarball. Includes public/views because index.html references the webpack
1f64cbe
+tar czf grafana_webpack-$VER.tar.gz grafana-$VER/public/build grafana-$VER/public/views
1f64cbe
+
1f64cbe
+# source tarball (if needed)
1f64cbe
+if [ ! -f grafana-$VER.tar.gz ]; then
1f64cbe
+  wget --quiet -O grafana-$VER.tar.gz https://github.com/grafana/grafana/archive/v$VER/grafana-$VER.tar.gz
1f64cbe
+fi
1f64cbe
+
1f64cbe
+# done
1f64cbe
+echo Both grafana-$VER.tar.gz and grafana_webpack-$VER.tar.gz
1f64cbe
+echo should now be copied to your \$HOME/rpmbuild/SOURCES
1f64cbe
+
1f64cbe
+exit 0