-
Notifications
You must be signed in to change notification settings - Fork 41
/
prepare.sh
executable file
·102 lines (81 loc) · 3.25 KB
/
prepare.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
set -e
if [ "$(uname)" == "Darwin" ]; then
SED=gsed
else
SED=sed
fi
# Had better results using yarn to install node modules than npm
# In theory you could assign NODE_PACMAN=npm here
NODE_PACMAN=${NODE_PACMAN:-yarn}
# This workaround is necessary
# https://github.com/electron-userland/electron-builder/issues/993
export USE_SYSTEM_XORRISO=true
# Define the network config to use, one of: mainnet, testnet, regtest, liveregtest
# Default to mainnet, allow override via command line argument
BITCOIN_NETWORK=${1:-mainnet}
# Define the default build type
BUILD_TYPE=${2:-release}
BITCOIN_NETWORK_FOR_TITLE=
if [ "${BITCOIN_NETWORK}" != "mainnet" ]; then
# FIXME: Should use something like the below but not released yet
# ${NODE_PACMAN} config set name greenaddress-electron-${BITCOIN_NETWORK}
# requires a release with https://github.com/yarnpkg/yarn/pull/5518 1.5.2+ yarn
$SED -i "s/SEDREPLACED_NETWORK/-${BITCOIN_NETWORK}/" package.json
$SED -i "s/SEDREPLACED_NAME/ ${BITCOIN_NETWORK}/" package.json
CAMELCASE_NET=$(echo ${BITCOIN_NETWORK} | sed -e "s/\b\(.\)/\u\1/g")
BITCOIN_NETWORK_FOR_TITLE="--network ${CAMELCASE_NET}"
else
$SED -i "s/SEDREPLACED_NETWORK//" package.json
$SED -i "s/SEDREPLACED_NAME//" package.json
fi
if [ \! -e webfiles ]; then
WEBFILES_REPO=${WEBFILES_REPO:-https://github.com/greenaddress/GreenAddressWebFiles.git}
WEBFILES_COMMIT=${WEBFILES_COMMIT:-jswally-v0.0.20}
git clone ${WEBFILES_REPO} webfiles
cd webfiles
git checkout ${WEBFILES_COMMIT}
./fetch_libwally.sh
cd libwally-core
# full make run is not necessary to succeed with gen_context which is our only requirement
./tools/autogen.sh
./configure --disable-dependency-tracking --enable-js-wrappers --disable-swig-java --disable-swig-python
make -j2 >/dev/null 2>/dev/null || true
test -f src/secp256k1/src/ecmult_static_context.h || (echo ecmult_static_context.h not generated properly - aborting; exit 1)
cd ../..
fi
if [ \! -e venv ]; then
command -v python2 >/dev/null &&
python2 -m virtualenv venv ||
python -m virtualenv venv
fi
venv/bin/pip install -r webfiles/requirements.txt
cd webfiles
# 1. Build *.js:
export LIBWALLY_DIR=$(pwd)/libwally-core
${NODE_PACMAN} install
${NODE_PACMAN} run build
rm -rf node_modules
# 2. Render *.html:
../venv/bin/python render_templates.py --electron $BITCOIN_NETWORK_FOR_TITLE ../app
TMPDIR=`mktemp -d`
# 3. Copy *.js:
cp ../app/static/wallet/config*.js $TMPDIR
cp ../app/static/wallet/network*.js $TMPDIR
rm -rf ../app/static
cp -r build/static ../app/static
rm -rf ../app/static/fonts/*.svg # .woff are enough for crx
rm -rf ../app/static/sound/*.wav # .mp3 are enough for crx
rm ../app/static/js/cdv-plugin-fb-connect.js # cordova only
rm ../app/static/js/{greenaddress,instant}.js # web only
mkdir -p ../app/static/wallet >/dev/null
mv $TMPDIR/config*.js ../app/static/wallet/
mv $TMPDIR/network*.js ../app/static/wallet/
rm -rf $TMPDIR
cd ..
echo Copying config file for ${BITCOIN_NETWORK}
cp app/static/wallet/config_${BITCOIN_NETWORK}.js app/static/wallet/config.js
cp app/static/wallet/network_${BITCOIN_NETWORK}.js app/static/wallet/network.js
${NODE_PACMAN} install
${NODE_PACMAN} run $BUILD_TYPE
chmod +x dist/greenaddress*.AppImage || true