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