diff --git a/CMakeLists.txt b/CMakeLists.txt index b6179154e55..bbcaf805a6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ set( CXX_STANDARD_REQUIRED ON) set(VERSION_MAJOR 1) set(VERSION_MINOR 8) -set(VERSION_PATCH 0) +set(VERSION_PATCH 1) #set(VERSION_SUFFIX develop) if(VERSION_SUFFIX) diff --git a/README.md b/README.md index 6dca7ff2d2f..75579b854ff 100644 --- a/README.md +++ b/README.md @@ -44,13 +44,13 @@ $ brew remove eosio #### Ubuntu 18.04 Package Install ```sh -$ wget https://github.com/eosio/eos/releases/download/v1.8.0/eosio_1.8.0-1-ubuntu-18.04_amd64.deb -$ sudo apt install ./eosio_1.8.0-1-ubuntu-18.04_amd64.deb +$ wget https://github.com/eosio/eos/releases/download/v1.8.1/eosio_1.8.1-1-ubuntu-18.04_amd64.deb +$ sudo apt install ./eosio_1.8.1-1-ubuntu-18.04_amd64.deb ``` #### Ubuntu 16.04 Package Install ```sh -$ wget https://github.com/eosio/eos/releases/download/v1.8.0/eosio_1.8.0-1-ubuntu-16.04_amd64.deb -$ sudo apt install ./eosio_1.8.0-1-ubuntu-16.04_amd64.deb +$ wget https://github.com/eosio/eos/releases/download/v1.8.1/eosio_1.8.1-1-ubuntu-16.04_amd64.deb +$ sudo apt install ./eosio_1.8.1-1-ubuntu-16.04_amd64.deb ``` #### Ubuntu Package Uninstall ```sh @@ -58,8 +58,8 @@ $ sudo apt remove eosio ``` #### Centos RPM Package Install ```sh -$ wget https://github.com/eosio/eos/releases/download/v1.8.0/eosio-1.8.0-1.el7.x86_64.rpm -$ sudo yum install ./eosio-1.8.0-1.el7.x86_64.rpm +$ wget https://github.com/eosio/eos/releases/download/v1.8.1/eosio-1.8.1-1.el7.x86_64.rpm +$ sudo yum install ./eosio-1.8.1-1.el7.x86_64.rpm ``` #### Centos RPM Package Uninstall ```sh @@ -68,9 +68,10 @@ $ sudo yum remove eosio #### Build Script Uninstall -If you have previously installed EOSIO using build scripts, you may execute `./scripts/eosio_uninstall.sh` to uninstall. -- Passing `--force` will answer yes to all prompts -- Passing `--full` will remove data directories (be very careful with this) +If you have previously installed EOSIO using build scripts, you can execute `eosio_uninstall.sh` to uninstall. +- Passing `-y` will answer yes to all prompts (does not remove data directories) +- Passing `-f` will remove data directories (be very careful with this) +- Passing in `-i` allows you to specify where your eosio installation is located ## Supported Operating Systems EOSIO currently supports the following operating systems: diff --git a/libraries/chain/block_header_state.cpp b/libraries/chain/block_header_state.cpp index f7dd7aba656..59a1eaa3394 100644 --- a/libraries/chain/block_header_state.cpp +++ b/libraries/chain/block_header_state.cpp @@ -156,7 +156,7 @@ namespace eosio { namespace chain { } else { result.active_schedule = active_schedule; result.producer_to_last_produced = producer_to_last_produced; - result.producer_to_last_produced[prokey.producer_name] = block_num; + result.producer_to_last_produced[prokey.producer_name] = result.block_num; result.producer_to_last_implied_irb = producer_to_last_implied_irb; result.producer_to_last_implied_irb[prokey.producer_name] = dpos_proposed_irreversible_blocknum; } diff --git a/libraries/fc b/libraries/fc index 6593ef120a7..f4755d330fa 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 6593ef120a79d97e3274a986acc84b3741a15de9 +Subproject commit f4755d330faf9d2342d646a93f9a27bf68ca759e diff --git a/scripts/.build_vars b/scripts/.build_vars index 585c521c935..6663f9d86fc 100644 --- a/scripts/.build_vars +++ b/scripts/.build_vars @@ -1,3 +1,4 @@ +# See install-directory-prompt for logic that sets EOSIO_INSTALL_DIR export SRC_DIR=${EOSIO_INSTALL_DIR}/src export OPT_DIR=${EOSIO_INSTALL_DIR}/opt export VAR_DIR=${EOSIO_INSTALL_DIR}/var diff --git a/scripts/.environment b/scripts/.environment index d5542098253..11246ff1147 100644 --- a/scripts/.environment +++ b/scripts/.environment @@ -13,7 +13,11 @@ else export EOSIO_VERSION_FULL="${EOSIO_VERSION_MAJOR}.${EOSIO_VERSION_MINOR}.${EOSIO_VERSION_PATCH}-${EOSIO_VERSION_SUFFIX}" fi -export EOSIO_INSTALL_DIR="${EOSIO_INSTALL_DIR:-${HOME}/eosio/${EOSIO_VERSION}}" +export CMAKE_REQUIRED_VERSION=$(cat $REPO_ROOT/CMakeLists.txt | grep -E "^[[:blank:]]*cmake_minimum_required[[:blank:]]*\([[:blank:]]*VERSION" | tail -1 | sed 's/.*VERSION //g' | sed 's/ //g' | sed 's/"//g' | cut -d\) -f1) + +export EOSIO_INSTALL_DIR="${HOME}/eosio/${EOSIO_VERSION}" export TEMP_DIR="${TEMP_DIR:-${HOME}/tmp}" +[[ -f ${BUILD_DIR}/CMakeCache.txt ]] && export CACHED_INSTALL_PATH=$(grep "CMAKE_INSTALL_PREFIX:PATH" ${BUILD_DIR}/CMakeCache.txt | cut -d= -f2) + . ./scripts/.build_vars diff --git a/scripts/eosio_build.sh b/scripts/eosio_build.sh index 2cf27cd0464..e214ec88768 100755 --- a/scripts/eosio_build.sh +++ b/scripts/eosio_build.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail -SCRIPT_VERSION=3.0 # Build script version (change this to re-build the CICD image) +SCRIPT_VERSION=3.1 # Build script version (change this to re-build the CICD image) ########################################################################## # This is the EOSIO automated install script for Linux and Mac OS. # This file was downloaded from https://github.com/EOSIO/eos @@ -111,6 +111,8 @@ if [ $# -ne 0 ]; then done fi +export CURRENT_WORKING_DIR=$(pwd) # relative path support + # Ensure we're in the repo root and not inside of scripts cd $( dirname "${BASH_SOURCE[0]}" )/.. @@ -147,7 +149,17 @@ execute cd $REPO_ROOT ensure-submodules-up-to-date # Check if cmake already exists -( [[ -z "${CMAKE}" ]] && [[ ! -z $(command -v cmake 2>/dev/null) ]] ) && export CMAKE=$(command -v cmake 2>/dev/null) +( [[ -z "${CMAKE}" ]] && [[ ! -z $(command -v cmake 2>/dev/null) ]] ) && export CMAKE=$(command -v cmake 2>/dev/null) && export CMAKE_CURRENT_VERSION=$($CMAKE --version | grep -E "cmake version[[:blank:]]*" | sed 's/.*cmake version //g') +# If it exists, check that it's > required version + +if [[ ! -z $CMAKE_CURRENT_VERSION ]] && [[ $((10#$( echo $CMAKE_CURRENT_VERSION | awk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }' ))) -lt $((10#$( echo $CMAKE_REQUIRED_VERSION | awk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }' ))) ]]; then + export CMAKE= + if [[ $ARCH == 'Darwin' ]]; then + echo "${COLOR_RED}The currently installed cmake version ($CMAKE_CURRENT_VERSION) is less than the required version ($CMAKE_REQUIRED_VERSION). Cannot proceed." + exit 1 + else + echo "${COLOR_YELLOW}The currently installed cmake version ($CMAKE_CURRENT_VERSION) is less than the required version ($CMAKE_REQUIRED_VERSION). We will be installing $CMAKE_VERSION.${COLOR_NC}" + fi +fi # Use existing cmake on system (either global or specific to eosio) # Setup based on architecture @@ -227,8 +239,8 @@ echo "(_______/(_______)\_______)\_______/(_______)" echo "=============================================${COLOR_NC}" echo "${COLOR_GREEN}EOSIO has been successfully built. $(($TIME_END/3600)):$(($TIME_END%3600/60)):$(($TIME_END%60))" -echo "${COLOR_GREEN}You can now install using: ./scripts/eosio_install.sh${COLOR_NC}" -echo "${COLOR_YELLOW}Uninstall with: ./scripts/eosio_uninstall.sh${COLOR_NC}" +echo "${COLOR_GREEN}You can now install using: ${SCRIPT_DIR}/eosio_install.sh${COLOR_NC}" +echo "${COLOR_YELLOW}Uninstall with: ${SCRIPT_DIR}/eosio_uninstall.sh${COLOR_NC}" echo "" echo "${COLOR_CYAN}If you wish to perform tests to ensure functional code:${COLOR_NC}" @@ -236,7 +248,7 @@ if $ENABLE_MONGO; then echo "${BIN_DIR}/mongod --dbpath ${MONGODB_DATA_DIR} -f ${MONGODB_CONF} --logpath ${MONGODB_LOG_DIR}/mongod.log &" PATH_TO_USE=" PATH=\$PATH:$OPT_DIR/mongodb/bin" fi -echo "cd ./build &&${PATH_TO_USE} make test" # PATH is set as currently 'mongo' binary is required for the mongodb test +echo "cd ${BUILD_DIR} && ${PATH_TO_USE} make test" # PATH is set as currently 'mongo' binary is required for the mongodb test echo "" resources diff --git a/scripts/eosio_install.sh b/scripts/eosio_install.sh index f8909fcac39..239c2214d92 100755 --- a/scripts/eosio_install.sh +++ b/scripts/eosio_install.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eo pipefail -VERSION=2.0 +VERSION=2.1 ########################################################################## # This is the EOSIO automated install script for Linux and Mac OS. # This file was downloaded from https://github.com/EOSIO/eos @@ -32,12 +32,15 @@ VERSION=2.0 # https://github.com/EOSIO/eos/blob/master/LICENSE.txt ########################################################################## +# Ensure we're in the repo root and not inside of scripts +cd $( dirname "${BASH_SOURCE[0]}" )/.. + # Load eosio specific helper functions . ./scripts/helpers/eosio.sh [[ ! $NAME == "Ubuntu" ]] && set -i # Ubuntu doesn't support interactive mode since it uses dash -[[ ! -d $BUILD_DIR ]] && printf "${COLOR_RED}Please run ./eosio_build.sh first!${COLOR_NC}" && exit 1 +[[ -f ${BUILD_DIR}/CMakeCache.txt ]] && printf "${COLOR_RED}Please run ${SCRIPT_DIR}/eosio_build.sh first!${COLOR_NC}" && exit 1 echo "${COLOR_CYAN}=====================================================================================" echo "========================== ${COLOR_WHITE}Starting EOSIO Installation${COLOR_CYAN} ==============================${COLOR_NC}" execute cd $BUILD_DIR @@ -57,7 +60,8 @@ printf " \\ \\::/ \\ \\::/ /__/:/ \\__\\/ \\ \\:: printf " \\__\\/ \\__\\/ \\__\\/ \\__\\/ \n\n${COLOR_NC}" printf "==============================================================================================\\n" -printf "${COLOR_GREEN}EOSIO has been installed into ${EOSIO_INSTALL_DIR}/bin${COLOR_NC}" -printf "\\n${COLOR_YELLOW}Uninstall with: ./scripts/eosio_uninstall.sh${COLOR_NC}\\n" +printf "${COLOR_GREEN}EOSIO has been installed into ${CACHED_INSTALL_PATH}/bin${COLOR_NC}" +printf "\\n${COLOR_YELLOW}Uninstall with: ${SCRIPT_DIR}/eosio_uninstall.sh${COLOR_NC}\\n" printf "==============================================================================================\\n\\n" resources + diff --git a/scripts/eosio_uninstall.sh b/scripts/eosio_uninstall.sh index fb595779ac8..ed19035bc96 100755 --- a/scripts/eosio_uninstall.sh +++ b/scripts/eosio_uninstall.sh @@ -1,89 +1,125 @@ #!/usr/bin/env bash set -eo pipefail +VERSION=2.1 +# User input handling +DEP_PROCEED=false +FULL=false + +function usage() { + printf "Usage: $0 OPTION... + -i DIR Directory where eosio is installed) + -y Noninteractive mode (answers yes to every prompt) + -f Removal of data directory (be absolutely sure you want to delete it before using this!) + \\n" "$0" 1>&2 + exit 1 +} + +TIME_BEGIN=$( date -u +%s ) +if [ $# -ne 0 ]; then + while getopts "i:yf" opt; do + case "${opt}" in + i ) + INSTALL_LOCATION=$OPTARG + ;; + y ) + NONINTERACTIVE=true + PROCEED=true + DEP_PROCEED=true + ;; + f ) + FULL=true + ;; + h ) + usage + ;; + ? ) + echo "Invalid Option!" 1>&2 + usage + ;; + : ) + echo "Invalid Option: -${OPTARG} requires an argument." 1>&2 + usage + ;; + * ) + usage + ;; + esac + done +fi + +export CURRENT_WORKING_DIR=$(pwd) # relative path support + +# Ensure we're in the repo root and not inside of scripts +cd $( dirname "${BASH_SOURCE[0]}" )/.. # Load bash script helper functions . ./scripts/helpers/eosio.sh -usage() { - printf "Usage --- \\n $ %s [ --full ] [ --force ]\\n - --full: Removal of data directory (be absolutely sure you want to delete it before using this!)\\n - --force: Unattended uninstall which works regardless of the eosio directory existence.\\n This helps cleanup dependencies and start fresh if you need to. - \\n" "$0" -} +# Support relative paths : https://github.com/EOSIO/eos/issues/7560 +( [[ ! -z $INSTALL_LOCATION ]] && [[ ! $INSTALL_LOCATION =~ ^\/ ]] ) && export INSTALL_LOCATION="${CURRENT_WORKING_DIR}/$INSTALL_LOCATION" INSTALL_PATHS=() -# User input handling -PROCEED=false -DEP_PROCEED=false -FORCED=false -FULL=false -if [[ $@ =~ [[:space:]]?--force[[:space:]]? ]]; then - echo "[Forcing Unattended Removal: Enabled]" - FORCED=true - PROCEED=true - DEP_PROCEED=true +# -y alone should not remove the data directories and not prompt the user for anything. +# -f alone should remove the data directories after prompting the user if they are sure. +# -f -y should proceed forward with removing the data directories without prompting the user. +if [[ $NONINTERACTIVE == false ]] && $FULL; then + while true; do + read -p "By specifying -f, removal of the eosio data directory will require a resync of data which can take days. Do you wish to proceed? (y/n) " PROCEED + case $PROCEED in + "" ) echo "What would you like to do?";; + 0 | true | [Yy]* ) break;; + 1 | false | [Nn]* ) exit 0;; + * ) echo "Please type 'y' for yes or 'n' for no.";; + esac + done +fi + +export EOSIO_INSTALL_DIR=${INSTALL_LOCATION:-$EOSIO_INSTALL_DIR} + +if [[ ! -d "${EOSIO_INSTALL_DIR}" ]]; then + echo "[EOSIO installation ${COLOR_YELLOW}NOT${COLOR_NC} found in ${EOSIO_INSTALL_DIR}]" +else + # As of 1.8.0, we're using a versioned directories under home: https://github.com/EOSIO/eos/issues/6940 + echo "[EOSIO installation found: ${EOSIO_INSTALL_DIR}]" && INSTALL_PATHS+=("${EOSIO_INSTALL_DIR}") # EOSIO_INSTALL_DIR set in .environment + while true; do + [[ $NONINTERACTIVE == false ]] && read -p "Do you wish to remove the installation in ${EOSIO_INSTALL_DIR}? (y/n) " PROCEED + case $PROCEED in + "" ) echo "What would you like to do?";; + 0 | true | [Yy]* ) + # Handle cleanup of data directory + if $FULL; then + ## Add both just to be safe + [[ $ARCH == "Darwin" ]] && INSTALL_PATHS+=("${HOME}/Library/Application\ Support/eosio") + [[ $ARCH != "Darwin" ]] && INSTALL_PATHS+=("${HOME}/.local/share/eosio") + fi + # Version < 1.8.0; Before we started using ~/eosio/1.8.x + # Arrays should return with newlines (IFS=\n;helpers.sh) as Application\ Support will split into two + for INSTALL_PATH in ${INSTALL_PATHS[@]}; do + execute rm -rf $INSTALL_PATH + done + echo " - EOSIO Removal Complete" + break;; + 1 | false | [Nn]* ) echo " - Cancelled EOSIO Removal!"; exit 1;; + * ) echo "Please type 'y' for yes or 'n' for no.";; + esac + done fi -if [[ $@ =~ [[:space:]]?--full[[:space:]]? ]]; then - echo "[Full removal (nodeos generated state, etc): Enabled]" - if $FORCED; then - FULL=true - elif [[ $FORCED == false ]]; then + +echo "[Removing EOSIO Dependencies]" +if [[ $ARCH == "Darwin" ]]; then + for package in $(cat scripts/eosio_build_darwin_deps | cut -d, -f1 2>/dev/null); do while true; do - read -p "Removal of the eosio data directory will require a resync of data which can take days. Do you wish to proceed? (y/n) " PROCEED - case $PROCEED in - "" ) echo "What would you like to do?";; + [[ $NONINTERACTIVE == false ]] && read -p "Do you wish to uninstall and unlink all brew installed ${package} versions? (y/n) " DEP_PROCEED + case $DEP_PROCEED in + "") echo "What would you like to do?";; 0 | true | [Yy]* ) - FULL=true - break;; + execute brew uninstall $package --force || true + execute brew cleanup -s $package || true + break;; 1 | false | [Nn]* ) break;; * ) echo "Please type 'y' for yes or 'n' for no.";; esac done - fi + done fi -if [[ ! -z $@ ]] && [[ ! $@ =~ [[:space:]]?--force[[:space:]]? ]] && [[ ! $@ =~ [[:space:]]?--full[[:space:]]? ]]; then usage && exit; fi - -# As of 1.8.0, we're using a versioned directories under home: https://github.com/EOSIO/eos/issues/6940 -[[ -d "${EOSIO_INSTALL_DIR}" ]] && echo "[EOSIO Installation Found: ${EOSIO_INSTALL_DIR}]" && INSTALL_PATHS+=("${EOSIO_INSTALL_DIR}") # EOSIO_INSTALL_DIR set in .environment - -# Removal -while true; do - [[ $FORCED == false ]] && read -p "Do you wish to remove the installation? (y/n) " PROCEED - case $PROCEED in - "" ) echo "What would you like to do?";; - 0 | true | [Yy]* ) - echo "[Removing EOSIO and Dependencies]" - if [[ $ARCH == "Darwin" ]]; then - for package in $(cat scripts/eosio_build_darwin_deps | cut -d, -f1 2>/dev/null); do - while true; do - [[ $FORCED == false ]] && read -p "Do you wish to uninstall and unlink all brew installed ${package} versions? (y/n) " DEP_PROCEED - case $DEP_PROCEED in - "") echo "What would you like to do?";; - 0 | true | [Yy]* ) - execute brew uninstall $package --force || true - execute brew cleanup -s $package || true - break;; - 1 | false | [Nn]* ) break;; - * ) echo "Please type 'y' for yes or 'n' for no.";; - esac - done - done - fi - # Handle cleanup of data directory - if $FULL; then - ## Add both just to be safe - [[ $ARCH == "Darwin" ]] && INSTALL_PATHS+=("${HOME}/Library/Application\ Support/eosio") - [[ $ARCH != "Darwin" ]] && INSTALL_PATHS+=("${HOME}/.local/share/eosio") - fi - # Version < 1.8.0; Before we started using ~/eosio/1.8.x - # Arrays should return with newlines (IFS=\n;helpers.sh) as Application\ Support will split into two - for INSTALL_PATH in ${INSTALL_PATHS[@]}; do - execute rm -rf $INSTALL_PATH - done - echo "[EOSIO Removal Complete]" - break;; - 1 | false | [Nn]* ) echo " - Cancelled EOSIO Removal!"; exit 1;; - * ) echo "Please type 'y' for yes or 'n' for no.";; - esac -done \ No newline at end of file diff --git a/scripts/generate_bottle.sh b/scripts/generate_bottle.sh index 034ea7bc935..9371f929eb8 100644 --- a/scripts/generate_bottle.sh +++ b/scripts/generate_bottle.sh @@ -46,7 +46,7 @@ echo "class Eosio < Formula depends_on \"gettext\" depends_on \"openssl\" depends_on \"libusb\" - depends_on :macos => :high_sierra + depends_on :macos => :mojave depends_on :arch => :intel bottle do diff --git a/scripts/helpers/eosio.sh b/scripts/helpers/eosio.sh index 34fbacac445..bcac1497ad8 100755 --- a/scripts/helpers/eosio.sh +++ b/scripts/helpers/eosio.sh @@ -53,8 +53,10 @@ function setup() { execute mkdir -p $VAR_DIR/log execute mkdir -p $ETC_DIR execute mkdir -p $LIB_DIR - execute mkdir -p $MONGODB_LOG_DIR - execute mkdir -p $MONGODB_DATA_DIR + if $ENABLE_MONGO; then + execute mkdir -p $MONGODB_LOG_DIR + execute mkdir -p $MONGODB_DATA_DIR + fi } function ensure-which() { @@ -74,28 +76,30 @@ function ensure-which() { # Prompt user for installation directory. function install-directory-prompt() { - if [[ -z $INSTALL_LOCATION ]]; then - echo "No installation location was specified. Please provide the location where EOSIO is installed." - while true; do - [[ $NONINTERACTIVE == false ]] && printf "${COLOR_YELLOW}Do you wish to use the default location? ${EOSIO_INSTALL_DIR}? (y/n)${COLOR_NC}" && read -p " " PROCEED - echo "" - case $PROCEED in - "" ) - echo "What would you like to do?";; - 0 | true | [Yy]* ) - break;; - 1 | false | [Nn]* ) - printf "Enter the desired installation location." && read -p " " EOSIO_INSTALL_DIR; - export EOSIO_INSTALL_DIR; - break;; - * ) echo "Please type 'y' for yes or 'n' for no.";; - esac - done - else - export EOSIO_INSTALL_DIR=${INSTALL_LOCATION} - fi - . ./scripts/.build_vars - echo "EOSIO will be installed to: ${EOSIO_INSTALL_DIR}" + if [[ -z $INSTALL_LOCATION ]]; then + echo "No installation location was specified. Please provide the location where EOSIO is installed." + while true; do + [[ $NONINTERACTIVE == false ]] && printf "${COLOR_YELLOW}Do you wish to use the default location? ${EOSIO_INSTALL_DIR}? (y/n)${COLOR_NC}" && read -p " " PROCEED + echo "" + case $PROCEED in + "" ) + echo "What would you like to do?";; + 0 | true | [Yy]* ) + break;; + 1 | false | [Nn]* ) + printf "Enter the desired installation location." && read -p " " EOSIO_INSTALL_DIR; + export EOSIO_INSTALL_DIR; + break;; + * ) echo "Please type 'y' for yes or 'n' for no.";; + esac + done + else + # Support relative paths : https://github.com/EOSIO/eos/issues/7560 + [[ ! $INSTALL_LOCATION =~ ^\/ ]] && export INSTALL_LOCATION="${CURRENT_WORKING_DIR}/$INSTALL_LOCATION" + export EOSIO_INSTALL_DIR="$INSTALL_LOCATION" + fi + . ./scripts/.build_vars + echo "EOSIO will be installed to: ${EOSIO_INSTALL_DIR}" } function previous-install-prompt() { diff --git a/scripts/helpers/general.sh b/scripts/helpers/general.sh index 4fc4761fda1..0983a9299ab 100755 --- a/scripts/helpers/general.sh +++ b/scripts/helpers/general.sh @@ -87,9 +87,9 @@ function install-package() { EXECUTION_FUNCTION="execute" [[ $2 == "WETRUN" ]] && EXECUTION_FUNCTION="execute-always" ( [[ $2 =~ "--" ]] || [[ $3 =~ "--" ]] ) && OPTIONS="${2}${3}" - [[ $CURRENT_USER != "root" ]] && [[ ! -z $SUDO_LOCATION ]] && SUDO_COMMAND="$SUDO_LOCATION -E" - ( [[ $NAME =~ "Amazon Linux" ]] || [[ $NAME == "CentOS Linux" ]] ) && eval $EXECUTION_FUNCTION $SUDO_COMMAND $YUM $OPTIONS install -y $1 - ( [[ $NAME =~ "Ubuntu" ]] ) && eval $EXECUTION_FUNCTION $SUDO_COMMAND $APTGET $OPTIONS install -y $1 + [[ $CURRENT_USER != "root" ]] && [[ ! -z $SUDO_LOCATION ]] && NEW_SUDO_COMMAND="$SUDO_LOCATION -E" + ( [[ $NAME =~ "Amazon Linux" ]] || [[ $NAME == "CentOS Linux" ]] ) && eval $EXECUTION_FUNCTION $NEW_SUDO_COMMAND $YUM $OPTIONS install -y $1 + ( [[ $NAME =~ "Ubuntu" ]] ) && eval $EXECUTION_FUNCTION $NEW_SUDO_COMMAND $APTGET $OPTIONS install -y $1 fi true # Required; Weird behavior without it } @@ -101,10 +101,10 @@ function uninstall-package() { [[ $2 == "WETRUN" ]] && EXECUTION_FUNCTION="execute-always" ( [[ $2 == "autoremove" ]] || [[ $3 == "autoremove" ]] ) && REMOVE="autoremove" ( [[ $2 =~ "--" ]] || [[ $3 =~ "--" ]] ) && OPTIONS="${2}${3}" - [[ $CURRENT_USER != "root" ]] && [[ ! -z $SUDO_LOCATION ]] && SUDO_COMMAND="$SUDO_LOCATION -E" + [[ $CURRENT_USER != "root" ]] && [[ ! -z $SUDO_LOCATION ]] && NEW_SUDO_COMMAND="$SUDO_LOCATION -E" # Check if the packages exist before uninstalling them. This speeds things up for tests. - ( ( [[ $NAME =~ "Amazon Linux" ]] || [[ $NAME == "CentOS Linux" ]] ) && [[ ! -z $(rpm -qa $1) ]] ) && eval $EXECUTION_FUNCTION $SUDO_COMMAND $YUM $OPTIONS $REMOVE -y $1 - ( [[ $NAME =~ "Ubuntu" ]] && $(dpkg -s $1 &>/dev/null) ) && eval $EXECUTION_FUNCTION $SUDO_COMMAND $APTGET $OPTIONS $REMOVE -y $1 + ( ( [[ $NAME =~ "Amazon Linux" ]] || [[ $NAME == "CentOS Linux" ]] ) && [[ ! -z $(rpm -qa $1) ]] ) && eval $EXECUTION_FUNCTION $NEW_SUDO_COMMAND $YUM $OPTIONS $REMOVE -y $1 + ( [[ $NAME =~ "Ubuntu" ]] && $(dpkg -s $1 &>/dev/null) ) && eval $EXECUTION_FUNCTION $NEW_SUDO_COMMAND $APTGET $OPTIONS $REMOVE -y $1 fi true } @@ -220,10 +220,10 @@ function ensure-yum-packages() { # || [[ -n "$testee" ]]; needed to see last line of deps file (https://stackoverflow.com/questions/12916352/shell-script-read-missing-last-line) while read -r testee tester || [[ -n "$testee" ]]; do if [[ ! -z $(eval $tester $testee) ]]; then - echo " - ${testee} ${COLOR_GREEN}found!${COLOR_NC}" + echo " - ${testee} ${COLOR_GREEN}ok${COLOR_NC}" else DEPS=$DEPS"${testee} " - echo " - ${testee} ${COLOR_RED}NOT${COLOR_NC} found." + echo " - ${testee} ${COLOR_RED}NOT${COLOR_NC} found!" (( COUNT+=1 )) fi done < $DEPS_FILE @@ -269,18 +269,18 @@ function ensure-brew-packages() { # || [[ -n "$nmae" ]]; needed to see last line of deps file (https://stackoverflow.com/questions/12916352/shell-script-read-missing-last-line) while read -r name path || [[ -n "$name" ]]; do if [[ -f $path ]] || [[ -d $path ]]; then - echo " - ${name} ${COLOR_GREEN}found!${COLOR_NC}" + echo " - ${name} ${COLOR_GREEN}ok${COLOR_NC}" continue fi # resolve conflict with homebrew glibtool and apple/gnu installs of libtool if [[ "${testee}" == "/usr/local/bin/glibtool" ]]; then if [ "${tester}" "/usr/local/bin/libtool" ]; then - echo " - ${name} ${COLOR_GREEN}found!${COLOR_NC}" + echo " - ${name} ${COLOR_GREEN}ok${COLOR_NC}" continue fi fi DEPS=$DEPS"${name} " - echo " - ${name} ${COLOR_RED}NOT${COLOR_NC} found." + echo " - ${name} ${COLOR_RED}NOT${COLOR_NC} found!" (( COUNT+=1 )) done < $DEPS_FILE if [[ $COUNT > 0 ]]; then @@ -348,10 +348,10 @@ function ensure-apt-packages() { # || [[ -n "$testee" ]]; needed to see last line of deps file (https://stackoverflow.com/questions/12916352/shell-script-read-missing-last-line) while read -r testee tester || [[ -n "$testee" ]]; do if [[ ! -z $(eval $tester $testee 2>/dev/null) ]]; then - echo " - ${testee} ${COLOR_GREEN}found!${COLOR_NC}" + echo " - ${testee} ${COLOR_GREEN}ok${COLOR_NC}" else DEPS=$DEPS"${testee} " - echo " - ${testee} ${COLOR_RED}NOT${COLOR_NC} found." + echo " - ${testee} ${COLOR_RED}NOT${COLOR_NC} found!" (( COUNT+=1 )) fi done < $DEPS_FILE diff --git a/tests/bash-bats/eosio_build.sh b/tests/bash-bats/eosio_build.sh index fe1e8f8c8c2..c343397a35e 100644 --- a/tests/bash-bats/eosio_build.sh +++ b/tests/bash-bats/eosio_build.sh @@ -57,6 +57,11 @@ TEST_LABEL="[eosio_build]" run bash -c "printf \"y\ny\nn\nn\n\"| ./$SCRIPT_LOCATION -i /NEWPATH -P" [[ ! -z $(echo "${output}" | grep "EOSIO_INSTALL_DIR: /NEWPATH") ]] || exit [[ ! -z $(echo "${output}" | grep "TEMP_DIR: ${HOME}/tmp") ]] || exit + ### Relative path support + cd $TEMP_DIR # Also test that we can run the script from a directory other than the root + run bash -c "printf \"y\ny\nn\nn\n\"| ${CURRENT_WORKING_DIR}/$SCRIPT_LOCATION -i NEWPATH -P" + [[ ! -z $(echo "${output}" | grep "EOSIO_INSTALL_DIR: $TEMP_DIR/NEWPATH") ]] || exit + cd $CURRENT_WORKING_DIR ## -c run bash -c "printf \"y\ny\nn\nn\n\"| ./$SCRIPT_LOCATION -c -P" [[ ! -z $(echo "${output}" | grep "ENABLE_COVERAGE_TESTING: true") ]] || exit @@ -72,4 +77,4 @@ TEST_LABEL="[eosio_build]" [[ ! -z $(echo "${output}" | grep "Invalid Option!") ]] || exit run bash -c "./$SCRIPT_LOCATION -h" [[ ! -z $(echo "${output}" | grep "Usage:") ]] || exit -} \ No newline at end of file +} diff --git a/tests/bash-bats/eosio_build_amazonlinux.sh b/tests/bash-bats/eosio_build_amazonlinux.sh index 3ff1d12a71c..64f53021cc5 100644 --- a/tests/bash-bats/eosio_build_amazonlinux.sh +++ b/tests/bash-bats/eosio_build_amazonlinux.sh @@ -30,11 +30,11 @@ export TEST_LABEL="[eosio_build_amazonlinux]" [[ ! -z $(echo "${output}" | grep "Starting EOSIO Dependency Install") ]] || exit [[ ! -z $(echo "${output}" | grep "Executing: eval /usr/bin/yum -y update") ]] || exit if [[ $NAME == "Amazon Linux" ]]; then - [[ ! -z $(echo "${output}" | grep "libstdc++.*found!") ]] || exit + [[ ! -z $(echo "${output}" | grep "libstdc++") ]] || exit elif [[ $NAME == "Amazon Linux AMI" ]]; then [[ ! -z $(echo "${output}" | grep "make.*found!") ]] || exit fi - [[ ! -z $(echo "${output}" | grep "sudo.*NOT.*found.") ]] || exit + [[ ! -z $(echo "${output}" | grep "sudo.*NOT.*found") ]] || exit [[ -z $(echo "${output}" | grep "- NOT found.") ]] || exit [[ ! -z $(echo "${output}" | grep /NEWPATH*/src/boost) ]] || exit [[ ! -z $(echo "${output}" | grep "Starting EOSIO Build") ]] || exit diff --git a/tests/bash-bats/eosio_build_centos.sh b/tests/bash-bats/eosio_build_centos.sh index c7927b4a38d..a0f05562299 100644 --- a/tests/bash-bats/eosio_build_centos.sh +++ b/tests/bash-bats/eosio_build_centos.sh @@ -28,14 +28,14 @@ export TEST_LABEL="[eosio_build_centos]" install-package devtoolset-8 WETRUN &>/dev/null # Ensure SCL and devtoolset-8 for c++ binary installation run bash -c "printf \"y\n%.0s\" {1..100}| ./${SCRIPT_LOCATION} -i /NEWPATH" - [[ ! -z $(echo "${output}" | grep "centos-release-scl-2-3.el7.centos.noarch found") ]] || exit + [[ ! -z $(echo "${output}" | grep "centos-release-.*centos.noarch found") ]] || exit [[ ! -z $(echo "${output}" | grep "devtoolset-8.* found") ]] || exit [[ ! -z $(echo "${output}" | grep "Executing: source /opt/rh/devtoolset-8/enable") ]] || exit [[ ! -z $(echo "${output}" | grep "Executing: make -j${JOBS}") ]] || exit [[ ! -z $(echo "${output}" | grep "Starting EOSIO Dependency Install") ]] || exit [[ ! -z $(echo "${output}" | grep "Executing: eval /usr/bin/yum -y update") ]] || exit [[ ! -z $(echo "${output}" | grep "Python36 successfully enabled") ]] || exit - [[ -z $(echo "${output}" | grep "- NOT found.") ]] || exit + [[ -z $(echo "${output}" | grep "- NOT found") ]] || exit [[ ! -z $(echo "${output}" | grep "Ensuring CMAKE") ]] || exit [[ ! -z $(echo "${output}" | grep /NEWPATH.*/src/boost) ]] || exit [[ ! -z $(echo "${output}" | grep "Starting EOSIO Build") ]] || exit diff --git a/tests/bash-bats/eosio_build_darwin.sh b/tests/bash-bats/eosio_build_darwin.sh index da7f6f1b5bc..0fc231950dc 100644 --- a/tests/bash-bats/eosio_build_darwin.sh +++ b/tests/bash-bats/eosio_build_darwin.sh @@ -29,7 +29,7 @@ export TEST_LABEL="[eosio_build_darwin]" ### Make sure deps are loaded properly [[ ! -z $(echo "${output}" | grep "Starting EOSIO Dependency Install") ]] || exit [[ ! -z $(echo "${output}" | grep "Executing: /usr/bin/xcode-select --install") ]] || exit - [[ -z $(echo "${output}" | grep "- NOT found.") ]] || exit + [[ -z $(echo "${output}" | grep " - NOT found") ]] || exit rm -f $CMAKE [[ ! -z $(echo "${output}" | grep "[Updating HomeBrew]") ]] || exit [[ ! -z $(echo "${output}" | grep "brew tap eosio/eosio") ]] || exit @@ -39,4 +39,4 @@ export TEST_LABEL="[eosio_build_darwin]" [[ ! -z $(echo "${output}" | grep "Starting EOSIO Build") ]] || exit [[ ! -z $(echo "${output}" | grep " --with-iostreams --with-date_time") ]] || exit # BOOST [[ ! -z $(echo "${output}" | grep "EOSIO has been successfully built") ]] || exit -} \ No newline at end of file +} diff --git a/tests/bash-bats/eosio_build_ubuntu.sh b/tests/bash-bats/eosio_build_ubuntu.sh index f5153719359..7b7694180c7 100644 --- a/tests/bash-bats/eosio_build_ubuntu.sh +++ b/tests/bash-bats/eosio_build_ubuntu.sh @@ -29,7 +29,7 @@ export TEST_LABEL="[eosio_build_ubuntu]" run bash -c "printf \"y\n%.0s\" {1..100} | ./$SCRIPT_LOCATION -i /NEWPATH" [[ ! -z $(echo "${output}" | grep "Executing: make -j${JOBS}") ]] || exit [[ ! -z $(echo "${output}" | grep "Starting EOSIO Dependency Install") ]] || exit - [[ ! -z $(echo "${output}" | grep python.*found) ]] || exit + [[ ! -z $(echo "${output}" | grep python.*) ]] || exit [[ ! -z $(echo "${output}" | grep make.*NOT.*found) ]] || exit [[ ! -z $(echo "${output}" | grep /NEWPATH.*/src/boost) ]] || exit [[ ! -z $(echo "${output}" | grep "make -j${CPU_CORES}") ]] || exit @@ -37,8 +37,8 @@ export TEST_LABEL="[eosio_build_ubuntu]" if [[ "$(echo ${VERSION_ID})" == "18.04" ]]; then [[ ! -z $(echo "${output}" | grep llvm-4.0.*found) ]] || exit fi - [[ -z $(echo "${output}" | grep "- NOT found.") ]] || exit - [[ -z $(echo "${output}" | grep lcov.*found.) ]] || exit + [[ -z $(echo "${output}" | grep "- NOT found") ]] || exit + [[ -z $(echo "${output}" | grep lcov.*found) ]] || exit [[ ! -z $(echo "${output}" | grep "EOSIO has been successfully built") ]] || exit [[ "$(echo ${VERSION_ID})" == "16.04" ]] && apt autoremove build-essential -y || uninstall-package clang WETRUN } diff --git a/tests/bash-bats/eosio_uninstall.sh b/tests/bash-bats/eosio_uninstall.sh index 77e4779438a..4942693cff9 100644 --- a/tests/bash-bats/eosio_uninstall.sh +++ b/tests/bash-bats/eosio_uninstall.sh @@ -16,24 +16,13 @@ mkdir -p $MONGODB_DATA_DIR # A helper function is available to show output and status: `debug` -@test "${TEST_LABEL} > Usage is visible with right interaction" { - run ./$SCRIPT_LOCATION -help - [[ $output =~ "Usage ---" ]] || exit - run ./$SCRIPT_LOCATION --help - [[ $output =~ "Usage ---" ]] || exit - run ./$SCRIPT_LOCATION help - [[ $output =~ "Usage ---" ]] || exit - run ./$SCRIPT_LOCATION blah - [[ $output =~ "Usage ---" ]] || exit -} - @test "${TEST_LABEL} > Testing user prompts" { ## No y or no warning and re-prompt run bash -c "echo -e \"\nx\nx\nx\" | ./$SCRIPT_LOCATION" ( [[ "${lines[${#lines[@]}-1]}" == "Please type 'y' for yes or 'n' for no." ]] && [[ "${lines[${#lines[@]}-2]}" == "Please type 'y' for yes or 'n' for no." ]] ) || exit ## All yes pass run bash -c "printf \"y\n%.0s\" {1..100} | ./$SCRIPT_LOCATION" - [[ "${output##*$'\n'}" == "[EOSIO Removal Complete]" ]] || exit + [[ $output =~ " - EOSIO Removal Complete" ]] || exit ## First no shows "Cancelled..." run bash -c "echo \"n\" | ./$SCRIPT_LOCATION" [[ "${output##*$'\n'}" =~ "Cancelled EOSIO Removal!" ]] || exit @@ -50,16 +39,27 @@ mkdir -p $MONGODB_DATA_DIR fi } -@test "${TEST_LABEL} > --force" { - run ./$SCRIPT_LOCATION --force - # Make sure we reach the end - [[ "${output##*$'\n'}" == "[EOSIO Removal Complete]" ]] || exit +@test "${TEST_LABEL} > Usage is visible with right interaction" { + run ./$SCRIPT_LOCATION -h + [[ $output =~ "Usage:" ]] || exit +} + +@test "${TEST_LABEL} > -y" { + run ./$SCRIPT_LOCATION -y + [[ $output =~ " - EOSIO Removal Complete" ]] || exit +} + +@test "${TEST_LABEL} > -i" { + run ./$SCRIPT_LOCATION -y -i eosiotest + [[ $output =~ .*/eosiotest ]] || exit + ([[ ! $output =~ "Library/Application\ Support/eosio" ]] && [[ ! $output =~ ".local/share/eosio" ]]) || exit + [[ ! $output =~ "EOSIO Removal Complete" ]] || exit } -@test "${TEST_LABEL} > --force + --full" { - run ./$SCRIPT_LOCATION --force --full - ([[ ! "${output[*]}" =~ "Library/Application\ Support/eosio" ]] && [[ ! "${output[*]}" =~ ".local/share/eosio" ]]) && exit - [[ "${output##*$'\n'}" == "[EOSIO Removal Complete]" ]] || exit +@test "${TEST_LABEL} > -f" { + run bash -c "printf \"y\n%.0s\" {1..100} | ./$SCRIPT_LOCATION -f" + ([[ "${output[*]}" =~ "Library/Application\ Support/eosio" ]] && [[ "${output[*]}" =~ ".local/share/eosio" ]]) && exit + [[ $output =~ "EOSIO Removal Complete" ]] || exit } rm -rf $SRC_DIR @@ -70,4 +70,4 @@ rm -rf $VAR_DIR/log rm -rf $ETC_DIR rm -rf $LIB_DIR rm -rf $MONGODB_LOG_DIR -rm -rf $MONGODB_DATA_DIR \ No newline at end of file +rm -rf $MONGODB_DATA_DIR diff --git a/tests/bash-bats/helpers/general.sh b/tests/bash-bats/helpers/general.sh index 2e9dd206bfe..1a03c29ead3 100644 --- a/tests/bash-bats/helpers/general.sh +++ b/tests/bash-bats/helpers/general.sh @@ -7,6 +7,7 @@ export VERBOSE=true export BATS_RUN=true export CURRENT_USER=$(whoami) export HOME="$BATS_TMPDIR/bats-eosio-user-home" # Ensure $HOME is available for all scripts +export CURRENT_WORKING_DIR=$(pwd) load helpers/functions if [[ $NAME == "Ubuntu" ]]; then # Ubuntu won't find any packages until this runs + ensure update only runs once @@ -20,4 +21,4 @@ fi if [[ ! -d "tests" ]] && [[ ! -f "README.md" ]]; then echo "You must navigate into the root directory to execute tests..." >&3 exit 1 -fi \ No newline at end of file +fi diff --git a/tests/bash-bats/modules/cmake.sh b/tests/bash-bats/modules/cmake.sh index 89b5b6dd883..e9be5319ce9 100755 --- a/tests/bash-bats/modules/cmake.sh +++ b/tests/bash-bats/modules/cmake.sh @@ -2,13 +2,37 @@ load ../helpers/functions @test "${TEST_LABEL} > Testing CMAKE" { + # Testing for if CMAKE already exists export CMAKE=${HOME}/cmake touch $CMAKE + export CMAKE_CURRENT_VERSION=3.7.1 + run bash -c " ./$SCRIPT_LOCATION -y -P" + if [[ $ARCH == "Darwin" ]]; then + [[ "${output##*$'\n'}" =~ "($CMAKE_REQUIRED_VERSION). Cannot proceed" ]] || exit # Test the required version + else + [[ ! -z $(echo "${output}" | grep "We will be installing $CMAKE_VERSION") ]] || exit # Test the required version + [[ ! -z $(echo "${output}" | grep "Executing: bash -c ${BIN_DIR}/cmake") ]] || exit + fi + export CMAKE_CURRENT_VERSION= run bash -c " ./$SCRIPT_LOCATION -y -P" [[ ! -z $(echo "${output}" | grep "Executing: bash -c ${HOME}/cmake") ]] || exit + if [[ $ARCH != "Darwin" ]]; then + [[ -z $(echo "${output}" | grep "CMAKE successfully installed") ]] || exit + fi + # Testing for if cmake doesn't exist to be sure it's set properly export CMAKE= + export CMAKE_CURRENT_VERSION=3.6 + run bash -c "./$SCRIPT_LOCATION -y -P" + if [[ $ARCH == "Darwin" ]]; then + [[ "${output##*$'\n'}" =~ "($CMAKE_REQUIRED_VERSION). Cannot proceed" ]] || exit # Test the required version + else + [[ ! -z $(echo "${output}" | grep "We will be installing $CMAKE_VERSION") ]] || exit # Test the required version + [[ ! -z $(echo "${output}" | grep "Executing: bash -c ${BIN_DIR}/cmake") ]] || exit + [[ ! -z $(echo "${output}" | grep "CMAKE successfully installed") ]] || exit + fi + export CMAKE_CURRENT_VERSION= run bash -c "./$SCRIPT_LOCATION -y -P" if [[ $ARCH == "Darwin" ]]; then [[ ! -z $(echo "${output}" | grep "Executing: bash -c /usr/local/bin/cmake -DCMAKE_BUILD") ]] || exit @@ -16,4 +40,4 @@ load ../helpers/functions [[ ! -z $(echo "${output}" | grep "Executing: bash -c ${BIN_DIR}/cmake") ]] || exit [[ ! -z $(echo "${output}" | grep "CMAKE successfully installed") ]] || exit fi -} \ No newline at end of file +}