shfmt various shell scripts, evaluate grep -c

This commit is contained in:
Gene Hoffman 2020-10-31 19:35:04 -07:00 committed by Yostra
parent 917e51071c
commit 55a1ad8ed1
4 changed files with 133 additions and 137 deletions

View File

@ -4,8 +4,8 @@ pip install setuptools_scm
CHIA_INSTALLER_VERSION=$(python installer-version.py) CHIA_INSTALLER_VERSION=$(python installer-version.py)
if [ ! "$CHIA_INSTALLER_VERSION" ]; then if [ ! "$CHIA_INSTALLER_VERSION" ]; then
echo "WARNING: No environment variable CHIA_INSTALLER_VERSION set. Using 0.0.0." echo "WARNING: No environment variable CHIA_INSTALLER_VERSION set. Using 0.0.0."
CHIA_INSTALLER_VERSION="0.0.0" CHIA_INSTALLER_VERSION="0.0.0"
fi fi
echo "Chia Installer Version is: $CHIA_INSTALLER_VERSION" echo "Chia Installer Version is: $CHIA_INSTALLER_VERSION"
@ -29,8 +29,8 @@ echo "npm build"
npm install npm install
LAST_EXIT_CODE=$? LAST_EXIT_CODE=$?
if [ "$LAST_EXIT_CODE" -ne 0 ]; then if [ "$LAST_EXIT_CODE" -ne 0 ]; then
>&2 echo "npm run build failed!" echo >&2 "npm run build failed!"
exit $LAST_EXIT_CODE exit $LAST_EXIT_CODE
fi 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-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 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

View File

@ -7,60 +7,60 @@ echo "Execute '. ./activate' if you have not already, before running."
UBUNTU=false UBUNTU=false
# Manage npm and other install requirements on an OS specific basis # Manage npm and other install requirements on an OS specific basis
if [ "$(uname)" = "Linux" ]; then if [ "$(uname)" = "Linux" ]; then
#LINUX=1 #LINUX=1
if type apt-get; then if type apt-get; then
# Debian/Ubuntu # Debian/Ubuntu
UBUNTU=true UBUNTU=true
sudo apt-get install -y npm nodejs sudo apt-get install -y npm nodejs
elif type yum && [ ! -f "/etc/redhat-release" ] && [ ! -f "/etc/centos-release" ]; then elif type yum && [ ! -f "/etc/redhat-release" ] && [ ! -f "/etc/centos-release" ]; then
# AMZN 2 # AMZN 2
echo "Installing on Amazon Linux 2" echo "Installing on Amazon Linux 2"
curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash - curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -
sudo yum install -y nodejs sudo yum install -y nodejs
elif type yum && [ -f /etc/redhat-release ] || [ -f /etc/centos-release ]; then elif type yum && [ -f /etc/redhat-release ] || [ -f /etc/centos-release ]; then
# CentOS or Redhat # CentOS or Redhat
echo "Installing on CentOS/Redhat" echo "Installing on CentOS/Redhat"
curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash - curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -
sudo yum install -y nodejs sudo yum install -y nodejs
fi fi
elif [ "$(uname)" = "Darwin" ] && type brew && ! npm version>/dev/null 2>&1; then elif [ "$(uname)" = "Darwin" ] && type brew && ! npm version >/dev/null 2>&1; then
# Install npm if not installed # Install npm if not installed
brew install npm brew install npm
elif [ "$(uname)" = "OpenBSD" ]; then elif [ "$(uname)" = "OpenBSD" ]; then
pkg_add node pkg_add node
elif [ "$(uname)" = "FreeBSD" ]; then elif [ "$(uname)" = "FreeBSD" ]; then
pkg install node pkg install node
fi fi
# Ubuntu before 20.04LTS has an ancient node.js # Ubuntu before 20.04LTS has an ancient node.js
echo "" echo ""
UBUNTU_PRE_2004=false UBUNTU_PRE_2004=false
if $UBUNTU; then 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 fi
if [ "$UBUNTU_PRE_2004" = "True" ]; then if [ "$UBUNTU_PRE_2004" = "True" ]; then
echo "Installing on Ubuntu older than 20.04 LTS: Ugrading node.js to stable" 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 UBUNTU_PRE_2004=true # Unfortunately Python returns True when shell expects true
sudo npm install -g n sudo npm install -g n
sudo n stable sudo n stable
export PATH="$PATH" export PATH="$PATH"
fi fi
if [ "$UBUNTU" = "true" ] && [ "$UBUNTU_PRE_2004" = "False" ]; then 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 fi
# We will set up node.js on GitHub Actions and Azure Pipelines directly # 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 # for Mac and Windows so skip unless completing a source/developer install
# Ubuntu special cases above # Ubuntu special cases above
if [ ! "$CI" ]; then if [ ! "$CI" ]; then
cd ./electron-react cd ./electron-react
npm install npm install
npm audit fix npm audit fix
npm run build npm run build
else else
echo "Skipping node.js in install.sh on MacOS ci" echo "Skipping node.js in install.sh on MacOS ci"
fi fi
echo "" echo ""

View File

@ -7,72 +7,72 @@ PYTHON_VERSION=$(python -c 'import sys; print(f"python{sys.version_info.major}.{
echo "Python version: $PYTHON_VERSION" echo "Python version: $PYTHON_VERSION"
export BUILD_VDF_BENCH=Y # Installs the useful vdf_bench test of CPU squaring speed 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)') CHIAVDF_VERSION=$(python -c 'from setup import dependencies; t = [_ for _ in dependencies if _.startswith("chiavdf")][0]; print(t)')
ubuntu_cmake_install() { 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))') 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 if [ "$UBUNTU_PRE_2004" = "True" ]; then
echo "Ubuntu version is pre 20.04LTS - installing CMake with snap" echo "Ubuntu version is pre 20.04LTS - installing CMake with snap"
sudo apt-get install snap -y sudo apt-get install snap -y
sudo apt-get remove --purge cmake -y sudo apt-get remove --purge cmake -y
hash -r hash -r
sudo snap install cmake --classic sudo snap install cmake --classic
else else
echo "Ubuntu 20.04LTS and newer support CMake 3.16+" echo "Ubuntu 20.04LTS and newer support CMake 3.16+"
sudo apt-get install cmake -y sudo apt-get install cmake -y
fi fi
} }
symlink_vdf_bench() { symlink_vdf_bench() {
if [ ! -e vdf_bench ] && [ -e venv/lib/"$1"/site-packages/vdf_bench ]; then if [ ! -e vdf_bench ] && [ -e venv/lib/"$1"/site-packages/vdf_bench ]; then
echo ln -s venv/lib/"$1"/site-packages/vdf_bench echo ln -s venv/lib/"$1"/site-packages/vdf_bench
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 elif [ ! -e venv/lib/"$1"/site-packages/vdf_bench ]; then
echo "ERROR: Could not find venv/lib/$1/site-packages/vdf_bench" echo "ERROR: Could not find venv/lib/$1/site-packages/vdf_bench"
else else
echo "./vdf_bench link exists" echo "./vdf_bench link exists"
fi fi
} }
if [ "$(uname)" = "Linux" ] && type apt-get; then if [ "$(uname)" = "Linux" ] && type apt-get; then
UBUNTU_DEBIAN=true UBUNTU_DEBIAN=true
echo "Found Ubuntu/Debian" echo "Found Ubuntu/Debian"
elif [ "$(uname)" = "Darwin" ]; then elif [ "$(uname)" = "Darwin" ]; then
MACOS=true MACOS=true
echo "Found MacOS" echo "Found MacOS"
fi fi
if [ -e "$THE_PATH" ]; then if [ -e "$THE_PATH" ]; then
echo "$THE_PATH" echo "$THE_PATH"
echo "vdf_client already exists, no action taken" echo "vdf_client already exists, no action taken"
else else
if [ -e venv/bin/python ] && test $UBUNTU_DEBIAN; then if [ -e venv/bin/python ] && test $UBUNTU_DEBIAN; then
echo "Installing chiavdf from source on Ubuntu/Debian" echo "Installing chiavdf from source on Ubuntu/Debian"
# If Ubuntu version is older than 20.04LTS then upgrade CMake # If Ubuntu version is older than 20.04LTS then upgrade CMake
ubuntu_cmake_install ubuntu_cmake_install
# Install remaining needed development tools - assumes venv and prior run of install.sh # 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 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 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" 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" venv/bin/python -m pip install --force --no-binary chiavdf "$CHIAVDF_VERSION"
symlink_vdf_bench "$PYTHON_VERSION" symlink_vdf_bench "$PYTHON_VERSION"
elif [ -e venv/bin/python ] && [ test $MACOS ] && [ brew info boost | grep -c 'Not installed' ]; then elif [ -e venv/bin/python ] && [ test $MACOS ] && [ brew info boost | grep -c 'Not installed' ]; then
echo "Installing chiavdf requirement boost for MacOS" echo "Installing chiavdf requirement boost for MacOS"
brew install boost brew install boost
echo "installing chiavdf from source" echo "installing chiavdf from source"
# User needs to provide required packages # User needs to provide required packages
echo venv/bin/python -m pip install --force --no-binary chiavdf "$CHIAVDF_VERSION" 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" venv/bin/python -m pip install --force --no-binary chiavdf "$CHIAVDF_VERSION"
symlink_vdf_bench "$PYTHON_VERSION" symlink_vdf_bench "$PYTHON_VERSION"
elif [ -e venv/bin/python ]; then elif [ -e venv/bin/python ]; then
echo "installing chiavdf from source" echo "installing chiavdf from source"
# User needs to provide required packages # User needs to provide required packages
echo venv/bin/python -m pip install --force --no-binary chiavdf "$CHIAVDF_VERSION" 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" venv/bin/python -m pip install --force --no-binary chiavdf "$CHIAVDF_VERSION"
symlink_vdf_bench "$PYTHON_VERSION" symlink_vdf_bench "$PYTHON_VERSION"
else else
echo "no venv created yet, please run install.sh" echo "no venv created yet, please run install.sh"
fi fi
fi fi
echo "To estimate a timelord on this CPU try './vdf_bench square_asm 400000' for an ips estimate" echo "To estimate a timelord on this CPU try './vdf_bench square_asm 400000' for an ips estimate"

View File

@ -2,68 +2,64 @@
set -e set -e
UBUNTU=false UBUNTU=false
if [ "$(uname)" = "Linux" ]; then if [ "$(uname)" = "Linux" ]; then
#LINUX=1 #LINUX=1
if type apt-get; then if type apt-get; then
UBUNTU=true UBUNTU=true
fi fi
fi fi
UBUNTU_PRE_2004=false UBUNTU_PRE_2004=false
if $UBUNTU; then if $UBUNTU; then
LSB_RELEASE=$(lsb_release -rs) LSB_RELEASE=$(lsb_release -rs)
UBUNTU_PRE_2004=$(echo "$LSB_RELEASE<20.04" | bc) UBUNTU_PRE_2004=$(echo "$LSB_RELEASE<20.04" | bc)
fi fi
# Manage npm and other install requirements on an OS specific basis # Manage npm and other install requirements on an OS specific basis
if [ "$(uname)" = "Linux" ]; then if [ "$(uname)" = "Linux" ]; then
#LINUX=1 #LINUX=1
if [ "$UBUNTU" = "true" ] && [ "$UBUNTU_PRE_2004" = "1" ]; then if [ "$UBUNTU" = "true" ] && [ "$UBUNTU_PRE_2004" = "1" ]; then
# Debian/Ubuntu # Debian/Ubuntu
echo "Installing on Ubuntu/Debian pre 20.04 LTS" echo "Installing on Ubuntu/Debian pre 20.04 LTS"
sudo apt-get update sudo apt-get update
sudo apt-get install -y python3.7-venv python3.7-distutils sudo apt-get install -y python3.7-venv python3.7-distutils
elif [ "$UBUNTU" = "true" ] && [ "$UBUNTU_PRE_2004" = "0" ]; then elif [ "$UBUNTU" = "true" ] && [ "$UBUNTU_PRE_2004" = "0" ]; then
echo "Installing on Ubuntu/Debian 20.04 LTS or newer" echo "Installing on Ubuntu/Debian 20.04 LTS or newer"
sudo apt-get update sudo apt-get update
sudo apt-get install -y python3.8-venv python3.8-distutils sudo apt-get install -y python3.8-venv python3.8-distutils
elif type yum && [ ! -f "/etc/redhat-release" ] && [ ! -f "/etc/centos-release" ]; then elif type yum && [ ! -f "/etc/redhat-release" ] && [ ! -f "/etc/centos-release" ]; then
# AMZN 2 # AMZN 2
echo "Installing on Amazon Linux 2" echo "Installing on Amazon Linux 2"
sudo yum install -y python3 git sudo yum install -y python3 git
elif type yum && [ -f /etc/redhat-release ] || [ -f /etc/centos-release ]; then elif type yum && [ -f /etc/redhat-release ] || [ -f /etc/centos-release ]; then
# CentOS or Redhat # CentOS or Redhat
echo "Installing on CentOS/Redhat" echo "Installing on CentOS/Redhat"
fi fi
elif [ "$(uname)" = "Darwin" ] && ! type brew >/dev/null 2>&1; then 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 elif [ "$(uname)" = "OpenBSD" ]; then
export MAKE=${MAKE:-gmake} export MAKE=${MAKE:-gmake}
export BUILD_VDF_CLIENT=${BUILD_VDF_CLIENT:-N} export BUILD_VDF_CLIENT=${BUILD_VDF_CLIENT:-N}
elif [ "$(uname)" = "FreeBSD" ]; then elif [ "$(uname)" = "FreeBSD" ]; then
export MAKE=${MAKE:-gmake} export MAKE=${MAKE:-gmake}
export BUILD_VDF_CLIENT=${BUILD_VDF_CLIENT:-N} export BUILD_VDF_CLIENT=${BUILD_VDF_CLIENT:-N}
fi fi
find_python() { find_python() {
set +e set +e
unset BEST_VERSION unset BEST_VERSION
for V in 37 3.7 38 3.8 3 for V in 37 3.7 38 3.8 3; do
do if which python$V >/dev/null; then
if which python$V > /dev/null if [ x"$BEST_VERSION" = x ]; then
then BEST_VERSION=$V
if [ x"$BEST_VERSION" = x ] fi
then fi
BEST_VERSION=$V done
fi echo $BEST_VERSION
fi set -e
done
echo $BEST_VERSION
set -e
} }
if [ x"$INSTALL_PYTHON_VERSION" = x ] if [ x"$INSTALL_PYTHON_VERSION" = x ]; then
then INSTALL_PYTHON_VERSION=$(find_python)
INSTALL_PYTHON_VERSION=$(find_python)
fi fi
# this fancy syntax sets INSTALL_PYTHON_PATH to "python3.7" unless INSTALL_PYTHON_VERSION is defined # 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" echo "Python version is $INSTALL_PYTHON_VERSION"
$INSTALL_PYTHON_PATH -m venv venv $INSTALL_PYTHON_PATH -m venv venv
if [ ! -f "activate" ]; then if [ ! -f "activate" ]; then
ln -s venv/bin/activate . ln -s venv/bin/activate .
fi fi
# shellcheck disable=SC1091 # shellcheck disable=SC1091