2020-09-19 21:55:17 +03:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
echo "This requires the chia python virtual environment."
|
|
|
|
echo "Execute '. ./activate' if you have not already, before running."
|
|
|
|
|
2021-02-09 23:24:58 +03:00
|
|
|
# Allows overriding the branch or commit to build in chia-blockchain-gui
|
|
|
|
SUBMODULE_BRANCH=$1
|
|
|
|
|
2020-09-19 21:55:17 +03:00
|
|
|
UBUNTU=false
|
|
|
|
# Manage npm and other install requirements on an OS specific basis
|
|
|
|
if [ "$(uname)" = "Linux" ]; then
|
2020-11-01 05:35:04 +03:00
|
|
|
#LINUX=1
|
|
|
|
if type apt-get; then
|
|
|
|
# Debian/Ubuntu
|
|
|
|
UBUNTU=true
|
2021-01-09 23:12:21 +03:00
|
|
|
sudo apt-get install -y npm nodejs libxss1
|
2020-11-01 05:35:04 +03:00
|
|
|
elif type yum && [ ! -f "/etc/redhat-release" ] && [ ! -f "/etc/centos-release" ]; then
|
|
|
|
# AMZN 2
|
|
|
|
echo "Installing on Amazon Linux 2"
|
|
|
|
curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -
|
|
|
|
sudo yum install -y nodejs
|
|
|
|
elif type yum && [ -f /etc/redhat-release ] || [ -f /etc/centos-release ]; then
|
|
|
|
# CentOS or Redhat
|
|
|
|
echo "Installing on CentOS/Redhat"
|
|
|
|
curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -
|
|
|
|
sudo yum install -y nodejs
|
|
|
|
fi
|
|
|
|
elif [ "$(uname)" = "Darwin" ] && type brew && ! npm version >/dev/null 2>&1; then
|
|
|
|
# Install npm if not installed
|
|
|
|
brew install npm
|
2020-09-19 21:55:17 +03:00
|
|
|
elif [ "$(uname)" = "OpenBSD" ]; then
|
2020-11-01 05:35:04 +03:00
|
|
|
pkg_add node
|
2020-09-19 21:55:17 +03:00
|
|
|
elif [ "$(uname)" = "FreeBSD" ]; then
|
2020-11-01 05:35:04 +03:00
|
|
|
pkg install node
|
2020-09-19 21:55:17 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Ubuntu before 20.04LTS has an ancient node.js
|
|
|
|
echo ""
|
|
|
|
UBUNTU_PRE_2004=false
|
|
|
|
if $UBUNTU; then
|
2020-11-01 05:35:04 +03:00
|
|
|
UBUNTU_PRE_2004=$(python -c 'import subprocess; process = subprocess.run(["lsb_release", "-rs"], stdout=subprocess.PIPE); print(float(process.stdout) < float(20.04))')
|
2020-09-19 21:55:17 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$UBUNTU_PRE_2004" = "True" ]; then
|
2020-11-01 05:35:04 +03:00
|
|
|
echo "Installing on Ubuntu older than 20.04 LTS: Ugrading node.js to stable"
|
|
|
|
UBUNTU_PRE_2004=true # Unfortunately Python returns True when shell expects true
|
|
|
|
sudo npm install -g n
|
|
|
|
sudo n stable
|
|
|
|
export PATH="$PATH"
|
2020-09-19 21:55:17 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$UBUNTU" = "true" ] && [ "$UBUNTU_PRE_2004" = "False" ]; then
|
2020-11-01 05:35:04 +03:00
|
|
|
echo "Installing on Ubuntu 20.04 LTS or newer: Using installed node.js version"
|
2020-09-19 21:55:17 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
# We will set up node.js on GitHub Actions and Azure Pipelines directly
|
|
|
|
# for Mac and Windows so skip unless completing a source/developer install
|
|
|
|
# Ubuntu special cases above
|
|
|
|
if [ ! "$CI" ]; then
|
2021-02-09 23:24:58 +03:00
|
|
|
echo "Running git submodule update --init --recursive."
|
|
|
|
echo ""
|
2021-02-18 03:43:28 +03:00
|
|
|
git submodule update --init --recursive
|
|
|
|
echo "Running git submodule update."
|
|
|
|
echo ""
|
2021-02-11 20:48:02 +03:00
|
|
|
git submodule update
|
2021-02-18 03:43:28 +03:00
|
|
|
cd chia-blockchain-gui
|
|
|
|
|
2021-02-09 23:24:58 +03:00
|
|
|
if [ "$SUBMODULE_BRANCH" ];
|
2021-02-09 01:01:40 +03:00
|
|
|
then
|
2021-02-09 23:24:58 +03:00
|
|
|
git checkout "$SUBMODULE_BRANCH"
|
2021-02-18 03:43:28 +03:00
|
|
|
git pull
|
2021-02-09 01:01:40 +03:00
|
|
|
echo ""
|
2021-02-09 23:24:58 +03:00
|
|
|
echo "Building the GUI with branch $SUBMODULE_BRANCH"
|
2021-02-09 01:01:40 +03:00
|
|
|
echo ""
|
2021-02-18 03:43:28 +03:00
|
|
|
fi
|
|
|
|
|
2020-11-01 05:35:04 +03:00
|
|
|
npm install
|
|
|
|
npm audit fix
|
2021-01-12 23:22:06 +03:00
|
|
|
npm run locale:extract
|
|
|
|
npm run locale:compile
|
2020-11-01 05:35:04 +03:00
|
|
|
npm run build
|
2020-09-19 21:55:17 +03:00
|
|
|
else
|
2020-11-01 05:35:04 +03:00
|
|
|
echo "Skipping node.js in install.sh on MacOS ci"
|
2020-09-19 21:55:17 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "Chia blockchain install-gui.sh complete."
|
|
|
|
echo ""
|
2021-02-08 07:39:59 +03:00
|
|
|
echo "Type 'cd chia-blockchain-gui' and then 'npm run electron &' to start the GUI"
|