copay/browser-extensions/chrome/build.sh

65 lines
1.6 KiB
Bash
Raw Normal View History

2014-05-27 13:57:44 -07:00
#! /bin/bash
# Description: This script compiles and copy the needed files to later package the application for Chrome
OpenColor="\033["
Red="1;31m"
Yellow="1;33m"
Green="1;32m"
CloseColor="\033[0m"
# Check function OK
checkOK() {
if [ $? != 0 ]; then
echo "${OpenColor}${Red}* ERROR. Exiting...${CloseColor}"
exit 1
fi
}
# Configs
BUILDDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
APPDIR="$BUILDDIR/copay-chrome-extension"
ZIPFILE="copay-chrome-extension.zip"
2014-07-02 11:53:29 -07:00
VERSION=`cut -d '"' -f2 $BUILDDIR/../../version.js`
2014-05-27 13:57:44 -07:00
# Move to the build directory
cd $BUILDDIR
# Create/Clean temp dir
echo "${OpenColor}${Green}* Checking temp dir...${CloseColor}"
if [ -d $APPDIR ]; then
rm -rf $APPDIR
fi
mkdir -p $APPDIR
# Re-compile copayBundle.js
echo "${OpenColor}${Green}* Generating copay bundle...${CloseColor}"
grunt --target=dev shell
checkOK
# Copy all chrome-extension files
echo "${OpenColor}${Green}* Copying all chrome-extension files...${CloseColor}"
sed "s/APP_VERSION/$VERSION/g" manifest.json > $APPDIR/manifest.json
checkOK
2014-07-02 11:53:29 -07:00
INCLUDE=`cat ../include`
cd $BUILDDIR/../..
LIBS=`cat index.html |grep -o -E 'src="([^"#]+)"' | cut -d'"' -f2|grep lib`
2014-07-02 13:15:54 -07:00
echo "LIBS: $LIBS"
CMD="rsync -rLRv --exclude-from $BUILDDIR/../exclude $INCLUDE $LIBS $APPDIR"
2014-07-02 11:53:29 -07:00
echo $CMD
$CMD
2014-05-27 13:57:44 -07:00
checkOK
# Zipping chrome-extension
echo "${OpenColor}${Green}* Zipping all chrome-extension files...${CloseColor}"
cd $BUILDDIR
2014-07-09 02:21:31 -07:00
rm $ZIPFILE
2014-07-02 11:53:29 -07:00
zip -qr $ZIPFILE "`basename $APPDIR`"
2014-05-27 13:57:44 -07:00
checkOK
echo "${OpenColor}${Yellow}\nThe Chrome Extension is ready at $BUILDDIR/copay-chrome-extension.zip${CloseColor}"