mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-08-17 06:41:17 +03:00
shfmt various shell scripts, evaluate grep -c
This commit is contained in:
parent
917e51071c
commit
55a1ad8ed1
@ -4,8 +4,8 @@ pip install setuptools_scm
|
||||
CHIA_INSTALLER_VERSION=$(python installer-version.py)
|
||||
|
||||
if [ ! "$CHIA_INSTALLER_VERSION" ]; then
|
||||
echo "WARNING: No environment variable CHIA_INSTALLER_VERSION set. Using 0.0.0."
|
||||
CHIA_INSTALLER_VERSION="0.0.0"
|
||||
echo "WARNING: No environment variable CHIA_INSTALLER_VERSION set. Using 0.0.0."
|
||||
CHIA_INSTALLER_VERSION="0.0.0"
|
||||
fi
|
||||
echo "Chia Installer Version is: $CHIA_INSTALLER_VERSION"
|
||||
|
||||
@ -29,8 +29,8 @@ echo "npm build"
|
||||
npm install
|
||||
LAST_EXIT_CODE=$?
|
||||
if [ "$LAST_EXIT_CODE" -ne 0 ]; then
|
||||
>&2 echo "npm run build failed!"
|
||||
exit $LAST_EXIT_CODE
|
||||
echo >&2 "npm run build failed!"
|
||||
exit $LAST_EXIT_CODE
|
||||
fi
|
||||
electron-packager . Chia --asar.unpack="**/daemon/**" --platform=darwin --icon=src/assets/img/Chia.icns --overwrite --app-bundle-id=net.chia.blockchain --appVersion=$CHIA_INSTALLER_VERSION
|
||||
electron-osx-sign Chia-darwin-x64/Chia.app --platform=darwin --hardened-runtime=true --provisioning-profile=chiablockchain.provisionprofile --entitlements=entitlements.mac.plist --entitlements-inherit=entitlements.mac.plist
|
||||
|
@ -7,60 +7,60 @@ echo "Execute '. ./activate' if you have not already, before running."
|
||||
UBUNTU=false
|
||||
# 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
|
||||
sudo apt-get install -y npm nodejs
|
||||
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
|
||||
#LINUX=1
|
||||
if type apt-get; then
|
||||
# Debian/Ubuntu
|
||||
UBUNTU=true
|
||||
sudo apt-get install -y npm nodejs
|
||||
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
|
||||
elif [ "$(uname)" = "OpenBSD" ]; then
|
||||
pkg_add node
|
||||
pkg_add node
|
||||
elif [ "$(uname)" = "FreeBSD" ]; then
|
||||
pkg install node
|
||||
pkg install node
|
||||
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))')
|
||||
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"
|
||||
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"
|
||||
echo "Installing on Ubuntu 20.04 LTS or newer: Using installed node.js version"
|
||||
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
|
||||
cd ./electron-react
|
||||
npm install
|
||||
npm audit fix
|
||||
npm run build
|
||||
cd ./electron-react
|
||||
npm install
|
||||
npm audit fix
|
||||
npm run build
|
||||
else
|
||||
echo "Skipping node.js in install.sh on MacOS ci"
|
||||
echo "Skipping node.js in install.sh on MacOS ci"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
@ -7,72 +7,72 @@ PYTHON_VERSION=$(python -c 'import sys; print(f"python{sys.version_info.major}.{
|
||||
echo "Python version: $PYTHON_VERSION"
|
||||
|
||||
export BUILD_VDF_BENCH=Y # Installs the useful vdf_bench test of CPU squaring speed
|
||||
THE_PATH=$(python -c 'import pkg_resources; print( pkg_resources.get_distribution("chiavdf").location)' 2> /dev/null)/vdf_client
|
||||
THE_PATH=$(python -c 'import pkg_resources; print( pkg_resources.get_distribution("chiavdf").location)' 2>/dev/null)/vdf_client
|
||||
CHIAVDF_VERSION=$(python -c 'from setup import dependencies; t = [_ for _ in dependencies if _.startswith("chiavdf")][0]; print(t)')
|
||||
|
||||
ubuntu_cmake_install() {
|
||||
UBUNTU_PRE_2004=$(python -c 'import subprocess; process = subprocess.run(["lsb_release", "-rs"], stdout=subprocess.PIPE); print(float(process.stdout) < float(20.04))')
|
||||
if [ "$UBUNTU_PRE_2004" = "True" ]; then
|
||||
echo "Ubuntu version is pre 20.04LTS - installing CMake with snap"
|
||||
sudo apt-get install snap -y
|
||||
sudo apt-get remove --purge cmake -y
|
||||
hash -r
|
||||
sudo snap install cmake --classic
|
||||
else
|
||||
echo "Ubuntu 20.04LTS and newer support CMake 3.16+"
|
||||
sudo apt-get install cmake -y
|
||||
fi
|
||||
UBUNTU_PRE_2004=$(python -c 'import subprocess; process = subprocess.run(["lsb_release", "-rs"], stdout=subprocess.PIPE); print(float(process.stdout) < float(20.04))')
|
||||
if [ "$UBUNTU_PRE_2004" = "True" ]; then
|
||||
echo "Ubuntu version is pre 20.04LTS - installing CMake with snap"
|
||||
sudo apt-get install snap -y
|
||||
sudo apt-get remove --purge cmake -y
|
||||
hash -r
|
||||
sudo snap install cmake --classic
|
||||
else
|
||||
echo "Ubuntu 20.04LTS and newer support CMake 3.16+"
|
||||
sudo apt-get install cmake -y
|
||||
fi
|
||||
}
|
||||
|
||||
symlink_vdf_bench() {
|
||||
if [ ! -e vdf_bench ] && [ -e venv/lib/"$1"/site-packages/vdf_bench ]; then
|
||||
echo ln -s venv/lib/"$1"/site-packages/vdf_bench
|
||||
ln -s venv/lib/"$1"/site-packages/vdf_bench .
|
||||
elif [ ! -e venv/lib/"$1"/site-packages/vdf_bench ]; then
|
||||
echo "ERROR: Could not find venv/lib/$1/site-packages/vdf_bench"
|
||||
else
|
||||
echo "./vdf_bench link exists"
|
||||
fi
|
||||
if [ ! -e vdf_bench ] && [ -e venv/lib/"$1"/site-packages/vdf_bench ]; then
|
||||
echo ln -s venv/lib/"$1"/site-packages/vdf_bench
|
||||
ln -s venv/lib/"$1"/site-packages/vdf_bench .
|
||||
elif [ ! -e venv/lib/"$1"/site-packages/vdf_bench ]; then
|
||||
echo "ERROR: Could not find venv/lib/$1/site-packages/vdf_bench"
|
||||
else
|
||||
echo "./vdf_bench link exists"
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$(uname)" = "Linux" ] && type apt-get; then
|
||||
UBUNTU_DEBIAN=true
|
||||
echo "Found Ubuntu/Debian"
|
||||
UBUNTU_DEBIAN=true
|
||||
echo "Found Ubuntu/Debian"
|
||||
elif [ "$(uname)" = "Darwin" ]; then
|
||||
MACOS=true
|
||||
echo "Found MacOS"
|
||||
MACOS=true
|
||||
echo "Found MacOS"
|
||||
fi
|
||||
|
||||
if [ -e "$THE_PATH" ]; then
|
||||
echo "$THE_PATH"
|
||||
echo "vdf_client already exists, no action taken"
|
||||
echo "$THE_PATH"
|
||||
echo "vdf_client already exists, no action taken"
|
||||
else
|
||||
if [ -e venv/bin/python ] && test $UBUNTU_DEBIAN; then
|
||||
echo "Installing chiavdf from source on Ubuntu/Debian"
|
||||
# If Ubuntu version is older than 20.04LTS then upgrade CMake
|
||||
ubuntu_cmake_install
|
||||
# Install remaining needed development tools - assumes venv and prior run of install.sh
|
||||
echo apt-get install libgmp-dev libboost-python-dev lib"$PYTHON_VERSION"-dev libboost-system-dev build-essential -y
|
||||
sudo apt-get install libgmp-dev libboost-python-dev lib"$PYTHON_VERSION"-dev libboost-system-dev build-essential -y
|
||||
echo venv/bin/python -m pip install --force --no-binary chiavdf "$CHIAVDF_VERSION"
|
||||
venv/bin/python -m pip install --force --no-binary chiavdf "$CHIAVDF_VERSION"
|
||||
symlink_vdf_bench "$PYTHON_VERSION"
|
||||
elif [ -e venv/bin/python ] && [ test $MACOS ] && [ brew info boost | grep -c 'Not installed' ]; then
|
||||
echo "Installing chiavdf requirement boost for MacOS"
|
||||
brew install boost
|
||||
echo "installing chiavdf from source"
|
||||
# User needs to provide required packages
|
||||
echo venv/bin/python -m pip install --force --no-binary chiavdf "$CHIAVDF_VERSION"
|
||||
venv/bin/python -m pip install --force --no-binary chiavdf "$CHIAVDF_VERSION"
|
||||
symlink_vdf_bench "$PYTHON_VERSION"
|
||||
elif [ -e venv/bin/python ]; then
|
||||
echo "installing chiavdf from source"
|
||||
# User needs to provide required packages
|
||||
echo venv/bin/python -m pip install --force --no-binary chiavdf "$CHIAVDF_VERSION"
|
||||
venv/bin/python -m pip install --force --no-binary chiavdf "$CHIAVDF_VERSION"
|
||||
symlink_vdf_bench "$PYTHON_VERSION"
|
||||
else
|
||||
echo "no venv created yet, please run install.sh"
|
||||
fi
|
||||
if [ -e venv/bin/python ] && test $UBUNTU_DEBIAN; then
|
||||
echo "Installing chiavdf from source on Ubuntu/Debian"
|
||||
# If Ubuntu version is older than 20.04LTS then upgrade CMake
|
||||
ubuntu_cmake_install
|
||||
# Install remaining needed development tools - assumes venv and prior run of install.sh
|
||||
echo apt-get install libgmp-dev libboost-python-dev lib"$PYTHON_VERSION"-dev libboost-system-dev build-essential -y
|
||||
sudo apt-get install libgmp-dev libboost-python-dev lib"$PYTHON_VERSION"-dev libboost-system-dev build-essential -y
|
||||
echo venv/bin/python -m pip install --force --no-binary chiavdf "$CHIAVDF_VERSION"
|
||||
venv/bin/python -m pip install --force --no-binary chiavdf "$CHIAVDF_VERSION"
|
||||
symlink_vdf_bench "$PYTHON_VERSION"
|
||||
elif [ -e venv/bin/python ] && [ test $MACOS ] && [ brew info boost | grep -c 'Not installed' ]; then
|
||||
echo "Installing chiavdf requirement boost for MacOS"
|
||||
brew install boost
|
||||
echo "installing chiavdf from source"
|
||||
# User needs to provide required packages
|
||||
echo venv/bin/python -m pip install --force --no-binary chiavdf "$CHIAVDF_VERSION"
|
||||
venv/bin/python -m pip install --force --no-binary chiavdf "$CHIAVDF_VERSION"
|
||||
symlink_vdf_bench "$PYTHON_VERSION"
|
||||
elif [ -e venv/bin/python ]; then
|
||||
echo "installing chiavdf from source"
|
||||
# User needs to provide required packages
|
||||
echo venv/bin/python -m pip install --force --no-binary chiavdf "$CHIAVDF_VERSION"
|
||||
venv/bin/python -m pip install --force --no-binary chiavdf "$CHIAVDF_VERSION"
|
||||
symlink_vdf_bench "$PYTHON_VERSION"
|
||||
else
|
||||
echo "no venv created yet, please run install.sh"
|
||||
fi
|
||||
fi
|
||||
echo "To estimate a timelord on this CPU try './vdf_bench square_asm 400000' for an ips estimate"
|
||||
|
90
install.sh
90
install.sh
@ -2,68 +2,64 @@
|
||||
set -e
|
||||
UBUNTU=false
|
||||
if [ "$(uname)" = "Linux" ]; then
|
||||
#LINUX=1
|
||||
if type apt-get; then
|
||||
UBUNTU=true
|
||||
fi
|
||||
#LINUX=1
|
||||
if type apt-get; then
|
||||
UBUNTU=true
|
||||
fi
|
||||
fi
|
||||
|
||||
UBUNTU_PRE_2004=false
|
||||
if $UBUNTU; then
|
||||
LSB_RELEASE=$(lsb_release -rs)
|
||||
UBUNTU_PRE_2004=$(echo "$LSB_RELEASE<20.04" | bc)
|
||||
LSB_RELEASE=$(lsb_release -rs)
|
||||
UBUNTU_PRE_2004=$(echo "$LSB_RELEASE<20.04" | bc)
|
||||
fi
|
||||
|
||||
# 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
|
||||
# Debian/Ubuntu
|
||||
echo "Installing on Ubuntu/Debian 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" ]; then
|
||||
echo "Installing on Ubuntu/Debian 20.04 LTS or newer"
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y python3.8-venv python3.8-distutils
|
||||
elif type yum && [ ! -f "/etc/redhat-release" ] && [ ! -f "/etc/centos-release" ]; then
|
||||
# AMZN 2
|
||||
echo "Installing on Amazon Linux 2"
|
||||
sudo yum install -y python3 git
|
||||
elif type yum && [ -f /etc/redhat-release ] || [ -f /etc/centos-release ]; then
|
||||
# CentOS or Redhat
|
||||
echo "Installing on CentOS/Redhat"
|
||||
fi
|
||||
#LINUX=1
|
||||
if [ "$UBUNTU" = "true" ] && [ "$UBUNTU_PRE_2004" = "1" ]; then
|
||||
# Debian/Ubuntu
|
||||
echo "Installing on Ubuntu/Debian 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" ]; then
|
||||
echo "Installing on Ubuntu/Debian 20.04 LTS or newer"
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y python3.8-venv python3.8-distutils
|
||||
elif type yum && [ ! -f "/etc/redhat-release" ] && [ ! -f "/etc/centos-release" ]; then
|
||||
# AMZN 2
|
||||
echo "Installing on Amazon Linux 2"
|
||||
sudo yum install -y python3 git
|
||||
elif type yum && [ -f /etc/redhat-release ] || [ -f /etc/centos-release ]; then
|
||||
# CentOS or Redhat
|
||||
echo "Installing on CentOS/Redhat"
|
||||
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 37 3.7 38 3.8 3
|
||||
do
|
||||
if which python$V > /dev/null
|
||||
then
|
||||
if [ x"$BEST_VERSION" = x ]
|
||||
then
|
||||
BEST_VERSION=$V
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo $BEST_VERSION
|
||||
set -e
|
||||
set +e
|
||||
unset BEST_VERSION
|
||||
for V in 37 3.7 38 3.8 3; do
|
||||
if which python$V >/dev/null; then
|
||||
if [ x"$BEST_VERSION" = x ]; then
|
||||
BEST_VERSION=$V
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo $BEST_VERSION
|
||||
set -e
|
||||
}
|
||||
|
||||
if [ x"$INSTALL_PYTHON_VERSION" = x ]
|
||||
then
|
||||
INSTALL_PYTHON_VERSION=$(find_python)
|
||||
if [ x"$INSTALL_PYTHON_VERSION" = x ]; then
|
||||
INSTALL_PYTHON_VERSION=$(find_python)
|
||||
fi
|
||||
|
||||
# this fancy syntax sets INSTALL_PYTHON_PATH to "python3.7" unless INSTALL_PYTHON_VERSION is defined
|
||||
@ -74,7 +70,7 @@ INSTALL_PYTHON_PATH=python${INSTALL_PYTHON_VERSION:-3.7}
|
||||
echo "Python version is $INSTALL_PYTHON_VERSION"
|
||||
$INSTALL_PYTHON_PATH -m venv venv
|
||||
if [ ! -f "activate" ]; then
|
||||
ln -s venv/bin/activate .
|
||||
ln -s venv/bin/activate .
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
|
Loading…
Reference in New Issue
Block a user