Blame SOURCES/make_grafana_webpack.sh

50fcc5
#! /bin/bash
50fcc5
#
50fcc5
# Copyright (c) 2019 Red Hat.
50fcc5
#
50fcc5
# This program is free software; you can redistribute it and/or modify it
50fcc5
# under the terms of the GNU General Public License as published by the
50fcc5
# Free Software Foundation; either version 2 of the License, or (at your
50fcc5
# option) any later version.
50fcc5
#
50fcc5
# This program is distributed in the hope that it will be useful, but
50fcc5
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
50fcc5
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
50fcc5
# for more details.
50fcc5
#
50fcc5
50fcc5
[ $# -ne 1 ] && echo "Usage: $0 version" && exit 1
50fcc5
50fcc5
# grafana version (must be tagged on github.com/grafana/grafana as "v$VER")
50fcc5
VER=$1
50fcc5
BUILDDIR=`mktemp -d buildXXXXXX`
50fcc5
50fcc5
[ ! -f /usr/bin/npm ] && echo Error, please install \"npm\" package && exit 1
50fcc5
50fcc5
# get src tree and set cwd
50fcc5
echo Fetching pristine upstream git tagged branch for grafana version v$VER ...
50fcc5
git clone https://github.com/grafana/grafana grafana-$VER
50fcc5
cd grafana-$VER
50fcc5
git checkout -b v$VER v$VER
50fcc5
50fcc5
# exclude the phantomjs-prebuilt binary module from the webpack
50fcc5
sed -i '/phantomjs-prebuilt/d' package.json
50fcc5
50fcc5
# nuke grunt task for copying phantomjs
50fcc5
rm -f scripts/grunt/options/phantomjs.js
50fcc5
sed -i '/phantomjs/d' scripts/grunt/*.js
50fcc5
50fcc5
# populate node_modules using package.json
50fcc5
echo Running yarn to populate local node_modules ....
50fcc5
npm install yarn
50fcc5
node_modules/yarn/bin/yarn --non-interactive --no-progress --ignore-engines install --pure-lockfile > yarn.out 2>&1
50fcc5
node_modules/yarn/bin/yarn --non-interactive -W add webpack-cli
50fcc5
50fcc5
# build the webpack
50fcc5
echo;echo Building production webpack ....
50fcc5
node_modules/webpack/bin/webpack.js --display errors-only --mode production --config scripts/webpack/webpack.prod.js
50fcc5
50fcc5
cd ..
50fcc5
50fcc5
# webpack tarball. Includes public/views because index.html references the webpack
50fcc5
tar czf grafana_webpack-$VER.tar.gz grafana-$VER/public/build grafana-$VER/public/views
50fcc5
50fcc5
# source tarball (if needed)
50fcc5
if [ ! -f grafana-$VER.tar.gz ]; then
50fcc5
  wget --quiet -O grafana-$VER.tar.gz https://github.com/grafana/grafana/archive/v$VER/grafana-$VER.tar.gz
50fcc5
fi
50fcc5
50fcc5
# done
50fcc5
echo Both grafana-$VER.tar.gz and grafana_webpack-$VER.tar.gz
50fcc5
echo should now be copied to your \$HOME/rpmbuild/SOURCES
50fcc5
50fcc5
exit 0