mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-08-16 14:20:47 +03:00
Update to handle the NodeJS 16 dependency (#9921)
* preliminary testing of in-directory n on ubuntu always * Use more n chiaminejp (#9971) * Added n as a local npm dependency * Fixed an issue where `install.sh` always tried to run `sudo apt install bc -y` even if `bc` is installed already * Added validations and useful outputs for `start-gui.sh` * Fixed lint error and use shell functions for readability * Replace tags with spaces * Skip installing python39 on RH like OS if it is already installed * Fixed an issue where start-gui.sh failed silently if venv is not activated * Suppressed message from pacman * Support CentOS7 * Fixed typo * Reduced unnecessary install messages * Fixed end of file * Added npm_global/__init__.py to pass CI * Fixed lint errors * Install python/sqlite from source on AMZN2. Clear old venv when changing python version on install * Suppress unnecessary command outputs * Suppress outputs * Added centos7/8 to install test * A minor fix * Fixed yaml syntax error * Fixed an issue where test-install-scripts failed in CentOS Co-authored-by: ChiaMineJP <admin@chiamine.jp>
This commit is contained in:
parent
54053178bf
commit
fc95c638a3
26
.github/workflows/test-install-scripts.yml
vendored
26
.github/workflows/test-install-scripts.yml
vendored
@ -64,7 +64,12 @@ jobs:
|
||||
- name: arch:latest
|
||||
type: arch
|
||||
url: "docker://archlinux:latest"
|
||||
# TODO: what CentOS version provides Python3.7-3.9?
|
||||
- name: centos:7
|
||||
type: centos
|
||||
url: "docker://centos:7"
|
||||
- name: centos:8
|
||||
type: centos
|
||||
url: "docker://centos:8"
|
||||
- name: debian:buster
|
||||
type: debian
|
||||
# https://packages.debian.org/buster/python/python3 (3.7)
|
||||
@ -117,6 +122,25 @@ jobs:
|
||||
run: |
|
||||
pacman --noconfirm --refresh base --sync git sudo
|
||||
|
||||
- name: Prepare CentOS
|
||||
if: ${{ matrix.distribution.type == 'centos' }}
|
||||
# Installing Git from yum brings git@1.x which doesn't work on actions/checkout.
|
||||
# So install git@2.x from source
|
||||
run: |
|
||||
if [ "$(rpm --eval %{centos_ver})" = "8" ]; then
|
||||
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-*;
|
||||
fi
|
||||
yum update -y
|
||||
yum install -y sudo gcc autoconf make wget curl-devel expat-devel gettext-devel openssl-devel perl-devel zlib-devel
|
||||
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.29.0.tar.gz
|
||||
tar zxf git-2.29.0.tar.gz
|
||||
pushd git-2.29.0
|
||||
make configure
|
||||
./configure --prefix=/usr/local
|
||||
make all
|
||||
make install
|
||||
popd
|
||||
|
||||
- name: Prepare Debian
|
||||
if: ${{ matrix.distribution.type == 'debian' }}
|
||||
env:
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -90,6 +90,9 @@ win_code_sign_cert.p12
|
||||
# chia-blockchain wheel build folder
|
||||
build/
|
||||
|
||||
# Temporal `n` (node version manager) directory
|
||||
.n/
|
||||
|
||||
# pytest-monitor
|
||||
# https://pytest-monitor.readthedocs.io/en/latest/operating.html?highlight=.pymon#storage
|
||||
.pymon
|
||||
|
0
build_scripts/npm_global/__init__.py
Normal file
0
build_scripts/npm_global/__init__.py
Normal file
13
build_scripts/npm_global/package-lock.json
generated
Normal file
13
build_scripts/npm_global/package-lock.json
generated
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "npm_global",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"n": {
|
||||
"version": "8.0.2",
|
||||
"resolved": "https://registry.npmjs.org/n/-/n-8.0.2.tgz",
|
||||
"integrity": "sha512-IvKMeWenkEntHnktypexqIi1BCTQc0Po1+zBanui+flF4dwHtsV+B2WNkx6KAMCqlTHyIisSddj1Y7EbnKRgXQ=="
|
||||
}
|
||||
}
|
||||
}
|
15
build_scripts/npm_global/package.json
Normal file
15
build_scripts/npm_global/package.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "npm_global",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"n": "^8.0.2"
|
||||
}
|
||||
}
|
213
install-gui.sh
213
install-gui.sh
@ -2,115 +2,176 @@
|
||||
set -e
|
||||
export NODE_OPTIONS="--max-old-space-size=3000"
|
||||
|
||||
SCRIPT_DIR=$(cd -- "$(dirname -- "$0")"; pwd)
|
||||
|
||||
if [ "${SCRIPT_DIR}" != "$(pwd)" ]; then
|
||||
echo "Please change working directory by the command below"
|
||||
echo " cd ${SCRIPT_DIR}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$VIRTUAL_ENV" ]; then
|
||||
echo "This requires the chia python virtual environment."
|
||||
echo "Execute '. ./activate' before running."
|
||||
exit 1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$(id -u)" = 0 ]; then
|
||||
echo "The Chia Blockchain GUI can not be installed or run by the root user."
|
||||
exit 1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Allows overriding the branch or commit to build in chia-blockchain-gui
|
||||
SUBMODULE_BRANCH=$1
|
||||
|
||||
UBUNTU=false
|
||||
nodejs_is_installed(){
|
||||
if ! npm version >/dev/null 2>&1; then
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
do_install_npm_locally(){
|
||||
NPM_VERSION="$(npm -v | cut -d'.' -f 1)"
|
||||
if [ "$NPM_VERSION" -lt "7" ]; then
|
||||
echo "Current npm version($(npm -v)) is less than 7. GUI app requires npm>=7."
|
||||
|
||||
if [ "$(uname)" = "OpenBSD" ] || [ "$(uname)" = "FreeBSD" ]; then
|
||||
# `n` package does not support OpenBSD/FreeBSD
|
||||
echo "Please install npm>=7 manually"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NPM_GLOBAL="${SCRIPT_DIR}/build_scripts/npm_global"
|
||||
# install-gui.sh can be executed
|
||||
echo "cd ${NPM_GLOBAL}"
|
||||
cd "${NPM_GLOBAL}"
|
||||
if [ "$NPM_VERSION" -lt "6" ]; then
|
||||
# Ubuntu image of Amazon ec2 instance surprisingly uses nodejs@3.5.2
|
||||
# which doesn't support `npm ci` as of 27th Jan, 2022
|
||||
echo "npm install"
|
||||
npm install
|
||||
else
|
||||
echo "npm ci"
|
||||
npm ci
|
||||
fi
|
||||
export N_PREFIX=${SCRIPT_DIR}/.n
|
||||
PATH="${N_PREFIX}/bin:$(npm bin):${PATH}"
|
||||
export PATH
|
||||
# `n 16` here installs nodejs@16 under $N_PREFIX directory
|
||||
echo "n 16"
|
||||
n 16
|
||||
echo "Current npm version: $(npm -v)"
|
||||
if [ "$(npm -v | cut -d'.' -f 1)" -lt "7" ]; then
|
||||
echo "Error: Failed to install npm>=7"
|
||||
exit 1
|
||||
fi
|
||||
cd "${SCRIPT_DIR}"
|
||||
else
|
||||
echo "Found npm $(npm -v)"
|
||||
fi
|
||||
}
|
||||
|
||||
# Manage npm and other install requirements on an OS specific basis
|
||||
if [ "$(uname)" = "Linux" ]; then
|
||||
#LINUX=1
|
||||
if type apt-get; then
|
||||
# Debian/Ubuntu
|
||||
UBUNTU=true
|
||||
#LINUX=1
|
||||
if type apt-get >/dev/null 2>&1; then
|
||||
# Debian/Ubuntu
|
||||
|
||||
# Check if we are running a Raspberry PI 4
|
||||
if [ "$(uname -m)" = "aarch64" ] \
|
||||
&& [ "$(uname -n)" = "raspberrypi" ]; then
|
||||
# Check if NodeJS & NPM is installed
|
||||
type npm >/dev/null 2>&1 || {
|
||||
echo >&2 "Please install NODEJS&NPM manually"
|
||||
}
|
||||
else
|
||||
sudo apt-get install -y npm nodejs libxss1
|
||||
fi
|
||||
elif type yum && [ ! -f "/etc/redhat-release" ] && [ ! -f "/etc/centos-release" ] && [ ! -f /etc/rocky-release ] && [ ! -f /etc/fedora-release ]; then
|
||||
# AMZN 2
|
||||
echo "Installing on Amazon Linux 2."
|
||||
curl -sL https://rpm.nodesource.com/setup_12.x | sudo bash -
|
||||
sudo yum install -y nodejs
|
||||
elif type yum && [ ! -f /etc/rocky-release ] && [ ! -f /etc/fedora-release ] && [ -f /etc/redhat-release ] || [ -f /etc/centos-release ]; then
|
||||
# CentOS or Redhat
|
||||
echo "Installing on CentOS/Redhat."
|
||||
curl -sL https://rpm.nodesource.com/setup_12.x | sudo bash -
|
||||
sudo yum install -y nodejs
|
||||
elif type yum && [ -f /etc/rocky-release ] || [ -f /etc/fedora-release ]; then
|
||||
# RockyLinux
|
||||
echo "Installing on RockyLinux/Fedora"
|
||||
sudo dnf module enable nodejs:12
|
||||
sudo dnf install -y nodejs
|
||||
fi
|
||||
|
||||
elif [ "$(uname)" = "Darwin" ] && type brew && ! npm version >/dev/null 2>&1; then
|
||||
# Install npm if not installed
|
||||
brew install npm
|
||||
# Check if we are running a Raspberry PI 4
|
||||
if [ "$(uname -m)" = "aarch64" ] \
|
||||
&& [ "$(uname -n)" = "raspberrypi" ]; then
|
||||
# Check if NodeJS & NPM is installed
|
||||
type npm >/dev/null 2>&1 || {
|
||||
echo >&2 "Please install NODEJS&NPM manually"
|
||||
}
|
||||
else
|
||||
if ! nodejs_is_installed; then
|
||||
echo "nodejs is not installed. Installing..."
|
||||
echo "sudo apt-get install -y npm nodejs libxss1"
|
||||
sudo apt-get install -y npm nodejs libxss1
|
||||
fi
|
||||
do_install_npm_locally
|
||||
fi
|
||||
elif type yum >/dev/null 2>&1 && [ ! -f "/etc/redhat-release" ] && [ ! -f "/etc/centos-release" ] && [ ! -f /etc/rocky-release ] && [ ! -f /etc/fedora-release ]; then
|
||||
# AMZN 2
|
||||
if ! nodejs_is_installed; then
|
||||
echo "Installing nodejs on Amazon Linux 2."
|
||||
curl -sL https://rpm.nodesource.com/setup_12.x | sudo bash -
|
||||
sudo yum install -y nodejs
|
||||
fi
|
||||
do_install_npm_locally
|
||||
elif type yum >/dev/null 2>&1 && [ ! -f /etc/rocky-release ] && [ ! -f /etc/fedora-release ] && [ -f /etc/redhat-release ] || [ -f /etc/centos-release ]; then
|
||||
# CentOS or Redhat
|
||||
if ! nodejs_is_installed; then
|
||||
echo "Installing nodejs on CentOS/Redhat."
|
||||
curl -sL https://rpm.nodesource.com/setup_12.x | sudo bash -
|
||||
sudo yum install -y nodejs
|
||||
fi
|
||||
do_install_npm_locally
|
||||
elif type yum >/dev/null 2>&1 && [ -f /etc/rocky-release ] || [ -f /etc/fedora-release ]; then
|
||||
# RockyLinux
|
||||
if ! nodejs_is_installed; then
|
||||
echo "Installing nodejs on RockyLinux/Fedora"
|
||||
sudo dnf module enable nodejs:12
|
||||
sudo dnf install -y nodejs
|
||||
fi
|
||||
do_install_npm_locally
|
||||
fi
|
||||
elif [ "$(uname)" = "Darwin" ] && type brew >/dev/null 2>&1; then
|
||||
# MacOS
|
||||
if ! nodejs_is_installed; then
|
||||
echo "Installing nodejs on MacOS"
|
||||
brew install npm
|
||||
fi
|
||||
do_install_npm_locally
|
||||
elif [ "$(uname)" = "OpenBSD" ]; then
|
||||
pkg_add node
|
||||
if ! nodejs_is_installed; then
|
||||
echo "Installing nodejs"
|
||||
pkg_add node
|
||||
fi
|
||||
do_install_npm_locally
|
||||
elif [ "$(uname)" = "FreeBSD" ]; then
|
||||
pkg install node
|
||||
if ! nodejs_is_installed; then
|
||||
echo "Installing nodejs"
|
||||
pkg install node
|
||||
fi
|
||||
do_install_npm_locally
|
||||
fi
|
||||
|
||||
# Ubuntu before 20.04LTS has an ancient node.js
|
||||
echo ""
|
||||
UBUNTU_PRE_2004=false
|
||||
if $UBUNTU; then
|
||||
UBUNTU_PRE_2004=$(python -c 'import subprocess; process = subprocess.run(["lsb_release", "-rs"], stdout=subprocess.PIPE); print(float(process.stdout) < float(20.04))')
|
||||
fi
|
||||
|
||||
if [ "$UBUNTU_PRE_2004" = "True" ]; then
|
||||
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"
|
||||
fi
|
||||
|
||||
if [ "$UBUNTU" = "true" ] && [ "$UBUNTU_PRE_2004" = "False" ]; then
|
||||
echo "Installing on Ubuntu 20.04 LTS or newer: Using installed node.js version."
|
||||
fi
|
||||
|
||||
# For Mac and Windows, we will set up node.js on GitHub Actions and Azure
|
||||
# Pipelines directly, so skip unless you are completing a source/developer install.
|
||||
# Ubuntu special cases above.
|
||||
if [ ! "$CI" ]; then
|
||||
echo "Running git submodule update --init --recursive."
|
||||
echo ""
|
||||
git submodule update --init --recursive
|
||||
echo "Running git submodule update."
|
||||
echo ""
|
||||
git submodule update
|
||||
cd chia-blockchain-gui
|
||||
echo "Running git submodule update --init --recursive."
|
||||
echo ""
|
||||
git submodule update --init --recursive
|
||||
echo "Running git submodule update."
|
||||
echo ""
|
||||
git submodule update
|
||||
cd chia-blockchain-gui
|
||||
|
||||
if [ "$SUBMODULE_BRANCH" ];
|
||||
then
|
||||
if [ "$SUBMODULE_BRANCH" ];
|
||||
then
|
||||
git fetch
|
||||
git checkout "$SUBMODULE_BRANCH"
|
||||
git checkout "$SUBMODULE_BRANCH"
|
||||
git pull
|
||||
echo ""
|
||||
echo "Building the GUI with branch $SUBMODULE_BRANCH"
|
||||
echo ""
|
||||
fi
|
||||
echo ""
|
||||
echo "Building the GUI with branch $SUBMODULE_BRANCH"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
npm ci
|
||||
npm audit fix || true
|
||||
npm run build
|
||||
python ../installhelper.py
|
||||
npm ci
|
||||
npm audit fix || true
|
||||
npm run build
|
||||
python ../installhelper.py
|
||||
else
|
||||
echo "Skipping node.js in install.sh on MacOS ci."
|
||||
echo "Skipping node.js in install.sh on MacOS ci."
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Chia blockchain install-gui.sh completed."
|
||||
echo ""
|
||||
echo "Type 'cd chia-blockchain-gui' and then 'npm run electron &' to start the GUI."
|
||||
echo "Type 'bash start-gui.sh &' to start the GUI."
|
||||
|
271
install.sh
271
install.sh
@ -31,123 +31,176 @@ done
|
||||
UBUNTU=false
|
||||
DEBIAN=false
|
||||
if [ "$(uname)" = "Linux" ]; then
|
||||
#LINUX=1
|
||||
if command -v apt-get &> /dev/null; then
|
||||
OS_ID=$(lsb_release -is)
|
||||
if [ "$OS_ID" = "Debian" ]; then
|
||||
DEBIAN=true
|
||||
else
|
||||
UBUNTU=true
|
||||
fi
|
||||
fi
|
||||
#LINUX=1
|
||||
if command -v apt-get >/dev/null; then
|
||||
OS_ID=$(lsb_release -is)
|
||||
if [ "$OS_ID" = "Debian" ]; then
|
||||
DEBIAN=true
|
||||
else
|
||||
UBUNTU=true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check for non 64 bit ARM64/Raspberry Pi installs
|
||||
if [ "$(uname -m)" = "armv7l" ]; then
|
||||
echo ""
|
||||
echo "WARNING:"
|
||||
echo "The Chia Blockchain requires a 64 bit OS and this is 32 bit armv7l"
|
||||
echo "For more information, see"
|
||||
echo "https://github.com/Chia-Network/chia-blockchain/wiki/Raspberry-Pi"
|
||||
echo "Exiting."
|
||||
exit 1
|
||||
echo "WARNING:"
|
||||
echo "The Chia Blockchain requires a 64 bit OS and this is 32 bit armv7l"
|
||||
echo "For more information, see"
|
||||
echo "https://github.com/Chia-Network/chia-blockchain/wiki/Raspberry-Pi"
|
||||
echo "Exiting."
|
||||
exit 1
|
||||
fi
|
||||
# Get submodules
|
||||
git submodule update --init mozilla-ca
|
||||
|
||||
UBUNTU_PRE_2004=false
|
||||
if $UBUNTU; then
|
||||
LSB_RELEASE=$(lsb_release -rs)
|
||||
# In case Ubuntu minimal does not come with bc
|
||||
if ! command -v bc &> /dev/null; then
|
||||
sudo apt install bc -y
|
||||
fi
|
||||
# Mint 20.04 repsonds with 20 here so 20 instead of 20.04
|
||||
UBUNTU_PRE_2004=$(echo "$LSB_RELEASE<20" | bc)
|
||||
UBUNTU_2100=$(echo "$LSB_RELEASE>=21" | bc)
|
||||
LSB_RELEASE=$(lsb_release -rs)
|
||||
# In case Ubuntu minimal does not come with bc
|
||||
if ! command -v bc > /dev/null 2>&1; then
|
||||
sudo apt install bc -y
|
||||
fi
|
||||
# Mint 20.04 responds with 20 here so 20 instead of 20.04
|
||||
UBUNTU_PRE_2004=$(echo "$LSB_RELEASE<20" | bc)
|
||||
UBUNTU_2100=$(echo "$LSB_RELEASE>=21" | bc)
|
||||
fi
|
||||
|
||||
install_python3_and_sqlite3_from_source_with_yum() {
|
||||
CURRENT_WD=$(pwd)
|
||||
TMP_PATH=/tmp
|
||||
|
||||
# Preparing installing Python
|
||||
echo 'yum groupinstall -y "Development Tools"'
|
||||
sudo yum groupinstall -y "Development Tools"
|
||||
echo "sudo yum install -y openssl-devel libffi-devel bzip2-devel wget"
|
||||
sudo yum install -y openssl-devel libffi-devel bzip2-devel wget
|
||||
|
||||
echo "cd $TMP_PATH"
|
||||
cd "$TMP_PATH"
|
||||
# Install sqlite>=3.37
|
||||
# yum install sqlite-devel brings sqlite3.7 which is not compatible with chia
|
||||
echo "wget https://www.sqlite.org/2022/sqlite-autoconf-3370200.tar.gz"
|
||||
wget https://www.sqlite.org/2022/sqlite-autoconf-3370200.tar.gz
|
||||
tar xf sqlite-autoconf-3370200.tar.gz
|
||||
echo "cd sqlite-autoconf-3370200"
|
||||
cd sqlite-autoconf-3370200
|
||||
echo "./configure --prefix=/usr/local"
|
||||
# '| stdbuf ...' seems weird but this makes command outputs stay in single line.
|
||||
./configure --prefix=/usr/local | stdbuf -o0 cut -b1-"$(tput cols)" | sed -u 'i\\o033[2K' | stdbuf -o0 tr '\n' '\r'; echo
|
||||
echo "make -j$(nproc)"
|
||||
make -j"$(nproc)" | stdbuf -o0 cut -b1-"$(tput cols)" | sed -u 'i\\o033[2K' | stdbuf -o0 tr '\n' '\r'; echo
|
||||
echo "sudo make install"
|
||||
sudo make install | stdbuf -o0 cut -b1-"$(tput cols)" | sed -u 'i\\o033[2K' | stdbuf -o0 tr '\n' '\r'; echo
|
||||
# yum install python3 brings Python3.6 which is not supported by chia
|
||||
cd ..
|
||||
echo "wget https://www.python.org/ftp/python/3.9.9/Python-3.9.9.tgz"
|
||||
wget https://www.python.org/ftp/python/3.9.9/Python-3.9.9.tgz
|
||||
tar xf Python-3.9.9.tgz
|
||||
echo "cd Python-3.9.9"
|
||||
cd Python-3.9.9
|
||||
echo "LD_RUN_PATH=/usr/local/lib ./configure --prefix=/usr/local"
|
||||
# '| stdbuf ...' seems weird but this makes command outputs stay in single line.
|
||||
LD_RUN_PATH=/usr/local/lib ./configure --prefix=/usr/local | stdbuf -o0 cut -b1-"$(tput cols)" | sed -u 'i\\o033[2K' | stdbuf -o0 tr '\n' '\r'; echo
|
||||
echo "LD_RUN_PATH=/usr/local/lib make -j$(nproc)"
|
||||
LD_RUN_PATH=/usr/local/lib make -j"$(nproc)" | stdbuf -o0 cut -b1-"$(tput cols)" | sed -u 'i\\o033[2K' | stdbuf -o0 tr '\n' '\r'; echo
|
||||
echo "LD_RUN_PATH=/usr/local/lib sudo make altinstall"
|
||||
LD_RUN_PATH=/usr/local/lib sudo make altinstall | stdbuf -o0 cut -b1-"$(tput cols)" | sed -u 'i\\o033[2K' | stdbuf -o0 tr '\n' '\r'; echo
|
||||
cd "$CURRENT_WD"
|
||||
}
|
||||
|
||||
|
||||
# Manage npm and other install requirements on an OS specific basis
|
||||
if [ "$(uname)" = "Linux" ]; then
|
||||
#LINUX=1
|
||||
if [ "$UBUNTU" = "true" ] && [ "$UBUNTU_PRE_2004" = "1" ]; then
|
||||
# Ubuntu
|
||||
echo "Installing on Ubuntu pre 20.04 LTS."
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y python3.7-venv python3.7-distutils
|
||||
elif [ "$UBUNTU" = "true" ] && [ "$UBUNTU_PRE_2004" = "0" ] && [ "$UBUNTU_2100" = "0" ]; then
|
||||
echo "Installing on Ubuntu 20.04 LTS."
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y python3.8-venv python3-distutils
|
||||
elif [ "$UBUNTU" = "true" ] && [ "$UBUNTU_2100" = "1" ]; then
|
||||
echo "Installing on Ubuntu 21.04 or newer."
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y python3.9-venv python3-distutils
|
||||
elif [ "$DEBIAN" = "true" ]; then
|
||||
echo "Installing on Debian."
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y python3-venv
|
||||
elif type pacman && [ -f "/etc/arch-release" ]; then
|
||||
# Arch Linux
|
||||
echo "Installing on Arch Linux."
|
||||
echo "Python <= 3.9.9 is required. Installing python-3.9.9-1"
|
||||
case $(uname -m) in
|
||||
x86_64)
|
||||
sudo pacman ${PACMAN_AUTOMATED} -U --needed https://archive.archlinux.org/packages/p/python/python-3.9.9-1-x86_64.pkg.tar.zst
|
||||
;;
|
||||
aarch64)
|
||||
sudo pacman ${PACMAN_AUTOMATED} -U --needed http://tardis.tiny-vps.com/aarm/packages/p/python/python-3.9.9-1-aarch64.pkg.tar.xz
|
||||
;;
|
||||
*)
|
||||
echo "Incompatible CPU architecture. Must be x86_64 or aarch64."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
sudo pacman ${PACMAN_AUTOMATED} -S --needed git
|
||||
elif type yum && [ ! -f "/etc/redhat-release" ] && [ ! -f "/etc/centos-release" ] && [ ! -f "/etc/fedora-release" ]; then
|
||||
# AMZN 2
|
||||
echo "Installing on Amazon Linux 2."
|
||||
AMZN2_PY_LATEST=$(yum --showduplicates list python3 | expand | grep -P '(?!.*3.10.*)x86_64|(?!.*3.10.*)aarch64' | tail -n 1 | awk '{print $2}')
|
||||
AMZN2_ARCH=$(uname -m)
|
||||
sudo yum install -y python3-"$AMZN2_PY_LATEST"."$AMZN2_ARCH" git
|
||||
elif type yum && [ -f "/etc/redhat-release" ] || [ -f "/etc/centos-release" ] || [ -f "/etc/fedora-release" ]; then
|
||||
# CentOS or Redhat or Fedora
|
||||
echo "Installing on CentOS/Redhat/Fedora."
|
||||
fi
|
||||
#LINUX=1
|
||||
if [ "$UBUNTU" = "true" ] && [ "$UBUNTU_PRE_2004" = "1" ]; then
|
||||
# Ubuntu
|
||||
echo "Installing on Ubuntu pre 20.04 LTS."
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y python3.7-venv python3.7-distutils
|
||||
elif [ "$UBUNTU" = "true" ] && [ "$UBUNTU_PRE_2004" = "0" ] && [ "$UBUNTU_2100" = "0" ]; then
|
||||
echo "Installing on Ubuntu 20.04 LTS."
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y python3.8-venv python3-distutils
|
||||
elif [ "$UBUNTU" = "true" ] && [ "$UBUNTU_2100" = "1" ]; then
|
||||
echo "Installing on Ubuntu 21.04 or newer."
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y python3.9-venv python3-distutils
|
||||
elif [ "$DEBIAN" = "true" ]; then
|
||||
echo "Installing on Debian."
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y python3-venv
|
||||
elif type pacman >/dev/null 2>&1 && [ -f "/etc/arch-release" ]; then
|
||||
# Arch Linux
|
||||
echo "Installing on Arch Linux."
|
||||
echo "Python <= 3.9.9 is required. Installing python-3.9.9-1"
|
||||
case $(uname -m) in
|
||||
x86_64)
|
||||
sudo pacman ${PACMAN_AUTOMATED} -U --needed https://archive.archlinux.org/packages/p/python/python-3.9.9-1-x86_64.pkg.tar.zst
|
||||
;;
|
||||
aarch64)
|
||||
sudo pacman ${PACMAN_AUTOMATED} -U --needed http://tardis.tiny-vps.com/aarm/packages/p/python/python-3.9.9-1-aarch64.pkg.tar.xz
|
||||
;;
|
||||
*)
|
||||
echo "Incompatible CPU architecture. Must be x86_64 or aarch64."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
sudo pacman ${PACMAN_AUTOMATED} -S --needed git
|
||||
elif type yum >/dev/null 2>&1 && [ ! -f "/etc/redhat-release" ] && [ ! -f "/etc/centos-release" ] && [ ! -f "/etc/fedora-release" ]; then
|
||||
# AMZN 2
|
||||
echo "Installing on Amazon Linux 2."
|
||||
if ! command -v python3.9 >/dev/null 2>&1; then
|
||||
install_python3_and_sqlite3_from_source_with_yum
|
||||
fi
|
||||
elif type yum >/dev/null 2>&1 && [ -f "/etc/centos-release" ]; then
|
||||
# CentOS
|
||||
echo "Install on CentOS."
|
||||
if ! command -v python3.9 >/dev/null 2>&1; then
|
||||
install_python3_and_sqlite3_from_source_with_yum
|
||||
fi
|
||||
elif type yum >/dev/null 2>&1 && [ -f "/etc/redhat-release" ] || [ -f "/etc/fedora-release" ]; then
|
||||
# Redhat or Fedora
|
||||
echo "Installing on Redhat/Fedora."
|
||||
if ! command -v python3.9 >/dev/null 2>&1; then
|
||||
sudo yum install -y python39
|
||||
fi
|
||||
fi
|
||||
elif [ "$(uname)" = "Darwin" ] && ! type brew >/dev/null 2>&1; then
|
||||
echo "Installation currently requires brew on MacOS - https://brew.sh/"
|
||||
echo "Installation currently requires brew on MacOS - https://brew.sh/"
|
||||
elif [ "$(uname)" = "OpenBSD" ]; then
|
||||
export MAKE=${MAKE:-gmake}
|
||||
export BUILD_VDF_CLIENT=${BUILD_VDF_CLIENT:-N}
|
||||
export MAKE=${MAKE:-gmake}
|
||||
export BUILD_VDF_CLIENT=${BUILD_VDF_CLIENT:-N}
|
||||
elif [ "$(uname)" = "FreeBSD" ]; then
|
||||
export MAKE=${MAKE:-gmake}
|
||||
export BUILD_VDF_CLIENT=${BUILD_VDF_CLIENT:-N}
|
||||
export MAKE=${MAKE:-gmake}
|
||||
export BUILD_VDF_CLIENT=${BUILD_VDF_CLIENT:-N}
|
||||
fi
|
||||
|
||||
find_python() {
|
||||
set +e
|
||||
unset BEST_VERSION
|
||||
for V in 39 3.9 38 3.8 37 3.7 3; do
|
||||
if command -v python$V >/dev/null; then
|
||||
if [ "$BEST_VERSION" = "" ]; then
|
||||
BEST_VERSION=$V
|
||||
if [ "$BEST_VERSION" = "3" ]; then
|
||||
PY3_VERSION=$(python$BEST_VERSION --version | cut -d ' ' -f2)
|
||||
if [[ "$PY3_VERSION" =~ 3.10.* ]]; then
|
||||
echo "Chia requires Python version <= 3.9.9"
|
||||
echo "Current Python version = $PY3_VERSION"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo $BEST_VERSION
|
||||
set -e
|
||||
set +e
|
||||
unset BEST_VERSION
|
||||
for V in 39 3.9 38 3.8 37 3.7 3; do
|
||||
if command -v python$V >/dev/null; then
|
||||
if [ "$BEST_VERSION" = "" ]; then
|
||||
BEST_VERSION=$V
|
||||
if [ "$BEST_VERSION" = "3" ]; then
|
||||
PY3_VERSION=$(python$BEST_VERSION --version | cut -d ' ' -f2)
|
||||
if [[ "$PY3_VERSION" =~ 3.10.* ]]; then
|
||||
echo "Chia requires Python version <= 3.9.9"
|
||||
echo "Current Python version = $PY3_VERSION"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo $BEST_VERSION
|
||||
set -e
|
||||
}
|
||||
|
||||
if [ "$INSTALL_PYTHON_VERSION" = "" ]; then
|
||||
INSTALL_PYTHON_VERSION=$(find_python)
|
||||
INSTALL_PYTHON_VERSION=$(find_python)
|
||||
fi
|
||||
|
||||
# This fancy syntax sets INSTALL_PYTHON_PATH to "python3.7", unless
|
||||
@ -156,10 +209,38 @@ fi
|
||||
|
||||
INSTALL_PYTHON_PATH=python${INSTALL_PYTHON_VERSION:-3.7}
|
||||
|
||||
if ! command -v "$INSTALL_PYTHON_PATH" >/dev/null; then
|
||||
echo "${INSTALL_PYTHON_PATH} was not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Python version is $INSTALL_PYTHON_VERSION"
|
||||
$INSTALL_PYTHON_PATH -m venv venv
|
||||
|
||||
# Check sqlite3 version bound to python
|
||||
SQLITE_VERSION=$($INSTALL_PYTHON_PATH -c 'import sqlite3; print(sqlite3.sqlite_version)')
|
||||
SQLITE_MAJOR_VER=$(echo "$SQLITE_VERSION" | cut -d'.' -f1)
|
||||
SQLITE_MINOR_VER=$(echo "$SQLITE_VERSION" | cut -d'.' -f2)
|
||||
echo "SQLite version of the Python is ${SQLITE_VERSION}"
|
||||
if [ "$SQLITE_MAJOR_VER" -lt "3" ] || [ "$SQLITE_MAJOR_VER" = "3" ] && [ "$SQLITE_MINOR_VER" -lt "8" ]; then
|
||||
echo "Only sqlite>=3.8 is supported"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If version of `python` and "$INSTALL_PYTHON_VERSION" does not match, clear old version
|
||||
VENV_CLEAR=""
|
||||
if [ -e venv/bin/python ]; then
|
||||
VENV_PYTHON_VER=$(venv/bin/python -V)
|
||||
TARGET_PYTHON_VER=$($INSTALL_PYTHON_PATH -V)
|
||||
if [ "$VENV_PYTHON_VER" != "$TARGET_PYTHON_VER" ]; then
|
||||
echo "existing python version in venv is $VENV_PYTHON_VER while target python version is $TARGET_PYTHON_VER"
|
||||
echo "Refreshing venv modules..."
|
||||
VENV_CLEAR="--clear"
|
||||
fi
|
||||
fi
|
||||
|
||||
$INSTALL_PYTHON_PATH -m venv venv $VENV_CLEAR
|
||||
if [ ! -f "activate" ]; then
|
||||
ln -s venv/bin/activate .
|
||||
ln -s venv/bin/activate .
|
||||
fi
|
||||
|
||||
EXTRAS=${EXTRAS%,}
|
||||
|
52
start-gui.sh
Executable file
52
start-gui.sh
Executable file
@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
export NODE_OPTIONS="--max-old-space-size=3000"
|
||||
|
||||
SCRIPT_DIR=$(cd -- "$(dirname -- "$0")"; pwd)
|
||||
|
||||
echo "### Checking GUI dependencies"
|
||||
|
||||
if [ -d "${SCRIPT_DIR}/.n" ]; then
|
||||
export N_PREFIX="${SCRIPT_DIR}/.n"
|
||||
export PATH="${N_PREFIX}/bin:${PATH}"
|
||||
echo "Loading nodejs/npm from"
|
||||
echo " ${N_PREFIX}"
|
||||
fi
|
||||
|
||||
if [ -z "$VIRTUAL_ENV" ]; then
|
||||
echo "This requires the chia python virtual environment."
|
||||
echo "Execute '. ./activate' before running."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! npm version >/dev/null 2>&1; then
|
||||
echo "Please install GUI dependencies by:"
|
||||
echo " sh install-gui.sh"
|
||||
echo "on ${SCRIPT_DIR}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NPM_VERSION="$(npm -v | cut -d'.' -f 1)"
|
||||
if [ "$NPM_VERSION" -lt "7" ]; then
|
||||
echo "Current npm version($(npm -v)) is less than 7. GUI app requires npm>=7."
|
||||
exit 1
|
||||
else
|
||||
echo "Found npm $(npm -v)"
|
||||
fi
|
||||
|
||||
echo "### Checking GUI build"
|
||||
GUI_BUILD_PATH="${SCRIPT_DIR}/chia-blockchain-gui/packages/gui/build/electron/main.js"
|
||||
if [ ! -e "$GUI_BUILD_PATH" ]; then
|
||||
echo "Error: GUI build was not found"
|
||||
echo "It is expected at $GUI_BUILD_PATH"
|
||||
echo "Please build GUI software by:"
|
||||
echo " sh install-gui.sh"
|
||||
exit 1
|
||||
else
|
||||
echo "Found $GUI_BUILD_PATH"
|
||||
fi
|
||||
|
||||
echo "### Starting GUI"
|
||||
cd "${SCRIPT_DIR}/chia-blockchain-gui/"
|
||||
echo "npm run electron"
|
||||
npm run electron
|
Loading…
Reference in New Issue
Block a user