forked from Chia-Network/chia-blockchain
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to handle the NodeJS 16 dependency (Chia-Network#9921)
* preliminary testing of in-directory n on ubuntu always * Use more n chiaminejp (Chia-Network#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 <[email protected]>
- Loading branch information
1 parent
5405317
commit fc95c63
Showing
8 changed files
with
424 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 [email protected] which doesn't work on actions/checkout. | ||
# So install [email protected] 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: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 [email protected] | ||
# 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 | ||
|
||
# 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 | ||
#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 | ||
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 | ||
|
||
if [ "$SUBMODULE_BRANCH" ]; | ||
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 | ||
|
||
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 | ||
|
||
npm ci | ||
npm audit fix || true | ||
npm run build | ||
python ../installhelper.py | ||
echo "" | ||
echo "Building the GUI with branch $SUBMODULE_BRANCH" | ||
echo "" | ||
fi | ||
|
||
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." |
Oops, something went wrong.