Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

[develop] BASE IMAGE Fixes #7532

Merged
merged 22 commits into from
Jun 26, 2019
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions scripts/eosio_build_centos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ echo "Disk space available: ${DISK_AVAIL}G"

echo ""

# Repo necessary for rh-python3 and devtoolset-8
# Repo necessary for rh-python3 and devtoolset-7
ensure-scl
# GCC7 for Centos / Needed for CMAKE install even if we're pinning
ensure-devtoolset
if [[ -d /opt/rh/devtoolset-8 ]]; then
echo "${COLOR_CYAN}[Enabling Centos devtoolset-8 (for newer GCC)]${COLOR_NC}"
execute-always source /opt/rh/devtoolset-8/enable
echo " - ${COLOR_GREEN}Centos devtoolset-8 successfully enabled!${COLOR_NC}"
if [[ -d /opt/rh/devtoolset-7 ]]; then
echo "${COLOR_CYAN}[Enabling Centos devtoolset-7 (for newer GCC)]${COLOR_NC}"
arhag marked this conversation as resolved.
Show resolved Hide resolved
execute-always source /opt/rh/devtoolset-7/enable
echo " - ${COLOR_GREEN}Centos devtoolset-7 successfully enabled!${COLOR_NC}"
fi
# Handle clang/compiler
ensure-compiler
# Ensure packages exist
ensure-yum-packages "${REPO_ROOT}/scripts/eosio_build_centos7_deps"
export PYTHON3PATH="/opt/rh/rh-python36"
Expand All @@ -32,6 +30,8 @@ if $DRYRUN || [ -d $PYTHON3PATH ]; then
echo " ${COLOR_GREEN}- Python36 successfully enabled!${COLOR_NC}"
echo ""
fi
# Handle clang/compiler
ensure-compiler
# CMAKE Installation
ensure-cmake
# CLANG Installation
Expand Down
4 changes: 3 additions & 1 deletion scripts/eosio_build_ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ echo "Disk space available: ${DISK_AVAIL}G"
[[ "${DISK_AVAIL}" -lt "${DISK_MIN}" ]] && echo " - You must have at least ${DISK_MIN}GB of available storage to install EOSIO." && exit 1

# system clang and build essential for Ubuntu 18 (16 too old)
( [[ $PIN_COMPILER == false ]] && [[ "$(echo ${VERSION_ID})" == "18.04" ]] ) && ensure-build-essential && EXTRA_DEPS=(clang,dpkg\ -s)
( [[ $PIN_COMPILER == false ]] && [[ $VERSION_ID == "18.04" ]] ) && EXTRA_DEPS=(clang,dpkg\ -s)
# We install clang8 for Ubuntu 16, but we still need something to compile cmake, boost, etc + pinned 18 still needs something to build source
( [[ $VERSION_ID == "16.04" ]] || ( $PIN_COMPILER && [[ $VERSION_ID == "18.04" ]] ) ) && ensure-build-essential
# Ensure packages exist
([[ $PIN_COMPILER == false ]] && [[ $BUILD_CLANG == false ]]) && EXTRA_DEPS+=(llvm-4.0,dpkg\ -s)
$ENABLE_COVERAGE_TESTING && EXTRA_DEPS+=(lcov,dpkg\ -s)
Expand Down
17 changes: 8 additions & 9 deletions scripts/helpers/eosio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,22 +146,21 @@ function prompt-mongo-install() {
}

function ensure-compiler() {
DEFAULT_CXX=clang++
DEFAULT_CC=clang
if [[ $NAME == "CentOS Linux" ]]; then
DEFAULT_CXX=g++
DEFAULT_CC=gcc
# Support build-essentials on ubuntu
if [[ $NAME == "CentOS Linux" ]] || [[ $VERSION_ID == "16.04" ]] || ( $PIN_COMPILER && [[ $VERSION_ID == "18.04" ]] ); then
export CXX=${CXX:-'g++'}
export CC=${CC:-'gcc'}
fi
export CXX=${CXX:-$DEFAULT_CXX}
export CC=${CC:-$DEFAULT_CC}
export CXX=${CXX:-'clang++'}
export CC=${CC:-'clang'}
if $PIN_COMPILER || [[ -f $CLANG_ROOT/bin/clang++ ]]; then
export PIN_COMPILER=true
export BUILD_CLANG=true
export CPP_COMP=$CLANG_ROOT/bin/clang++
export CC_COMP=$CLANG_ROOT/bin/clang
export PATH=$CLANG_ROOT/bin:$PATH
elif [[ $PIN_COMPILER == false ]]; then
which $CXX &>/dev/null || ( echo "${COLOR_RED}Unable to find compiler: Pass in the -P option if you wish for us to install it or install a C++17 compiler and set \$CXX and \$CC to the proper binary locations. ${COLOR_NC}"; exit 1 )
which $CXX &>/dev/null || ( echo "${COLOR_RED}Unable to find $CXX compiler: Pass in the -P option if you wish for us to install it or install a C++17 compiler and set \$CXX and \$CC to the proper binary locations. ${COLOR_NC}"; exit 1 )
# readlink on mac differs from linux readlink (mac doesn't have -f)
[[ $ARCH == "Linux" ]] && READLINK_COMMAND="readlink -f" || READLINK_COMMAND="readlink"
COMPILER_TYPE=$( eval $READLINK_COMMAND $(which $CXX) || true )
Expand All @@ -181,7 +180,7 @@ function ensure-compiler() {
[[ $( $(which $CXX) -dumpversion | cut -d '.' -f 1 ) -lt 7 ]] && export NO_CPP17=true
if [[ $NO_CPP17 == false ]]; then # https://github.com/EOSIO/eos/issues/7402
while true; do
echo "${COLOR_YELLOW}WARNING: Your GCC compiler is less performant than clang (https://github.com/EOSIO/eos/issues/7402). We suggest running the build script with -P or install your own clang and try again. ${CXX}!${COLOR_NC}"
echo "${COLOR_YELLOW}WARNING: Your GCC compiler ($CXX) is less performant than clang (https://github.com/EOSIO/eos/issues/7402). We suggest running the build script with -P or install your own clang and try again.${COLOR_NC}"
[[ $NONINTERACTIVE == false ]] && printf "${COLOR_YELLOW}Do you wish to proceed anyway? (y/n)?${COLOR_NC}" && read -p " " PROCEED
case $PROCEED in
"" ) echo "What would you like to do?";;
Expand Down
54 changes: 27 additions & 27 deletions scripts/helpers/general.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,14 @@ function install-package() {
function uninstall-package() {
if [[ $ARCH == "Linux" ]]; then
EXECUTION_FUNCTION="execute"
REMOVE="remove"
[[ $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"
# 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 $SUDO_COMMAND $YUM $OPTIONS $REMOVE -y $1
( [[ $NAME =~ "Ubuntu" ]] && $(dpkg -s $1 &>/dev/null) ) && eval $EXECUTION_FUNCTION $SUDO_COMMAND $APTGET $OPTIONS $REMOVE -y $1
fi
true
}
Expand Down Expand Up @@ -150,16 +152,16 @@ function ensure-scl() {
}

function ensure-devtoolset() {
echo "${COLOR_CYAN}[Ensuring installation of devtoolset-8]${COLOR_NC}"
DEVTOOLSET=$( rpm -qa | grep -E 'devtoolset-8-[0-9].*' || true )
echo "${COLOR_CYAN}[Ensuring installation of devtoolset-7]${COLOR_NC}"
DEVTOOLSET=$( rpm -qa | grep -E 'devtoolset-7-[0-9].*' || true )
if [[ -z "${DEVTOOLSET}" ]]; then
while true; do
[[ $NONINTERACTIVE == false ]] && printf "${COLOR_YELLOW}Not Found: Do you wish to install it? (y/n)?${COLOR_NC}" && read -p " " PROCEED
echo ""
case $PROCEED in
"" ) echo "What would you like to do?";;
0 | true | [Yy]* ) install-package devtoolset-8; break;;
1 | false | [Nn]* ) echo " - User aborted installation of devtoolset-8."; break;;
0 | true | [Yy]* ) install-package devtoolset-7; break;;
1 | false | [Nn]* ) echo " - User aborted installation of devtoolset-7."; break;;
* ) echo "Please type 'y' for yes or 'n' for no.";;
esac
done
Expand All @@ -169,28 +171,26 @@ function ensure-devtoolset() {
}

function ensure-build-essential() {
echo "${COLOR_CYAN}[Ensuring installation of build-essential with C++7]${COLOR_NC}"
BUILD_ESSENTIAL=$( dpkg -s build-essential | grep 'Package: build-essential' || true )
if [[ -z $BUILD_ESSENTIAL ]]; then
while true; do
[[ $NONINTERACTIVE == false ]] && printf "${COLOR_YELLOW}Do you wish to install it? (y/n)?${COLOR_NC}" && read -p " " PROCEED
echo ""
case $PROCEED in
"" ) echo "What would you like to do?";;
0 | true | [Yy]* )
if install-package build-essential; then
if [[ ! $(dpkg -s clang 2>/dev/null) ]]; then # Clang already exists, so no need for build essentials
echo "${COLOR_CYAN}[Ensuring installation of build-essential (needed for installing depedencies; we will remove it after)]${COLOR_NC}"
arhag marked this conversation as resolved.
Show resolved Hide resolved
BUILD_ESSENTIAL=$( dpkg -s build-essential | grep 'Package: build-essential' || true )
if [[ -z $BUILD_ESSENTIAL ]]; then
while true; do
[[ $NONINTERACTIVE == false ]] && printf "${COLOR_YELLOW}Do you wish to install it? (y/n)?${COLOR_NC}" && read -p " " PROCEED
echo ""
case $PROCEED in
"" ) echo "What would you like to do?";;
0 | true | [Yy]* )
install-package build-essential
echo " - ${COLOR_GREEN}Installed build-essential${COLOR_NC}"
else
echo " - ${COLOR_GREEN}Install of build-essential failed. Please try a manual install.${COLOR_NC}"
exit 1
fi
break;;
1 | false | [Nn]* ) echo " - User aborted installation of build-essential."; break;;
* ) echo "Please type 'y' for yes or 'n' for no.";;
esac
done
else
echo " - ${BUILD_ESSENTIAL} found."
break;;
1 | false | [Nn]* ) echo " - User aborted installation of build-essential."; break;;
* ) echo "Please type 'y' for yes or 'n' for no.";;
esac
done
else
echo " - ${BUILD_ESSENTIAL} found."
fi
fi
}

Expand Down
11 changes: 6 additions & 5 deletions tests/bash-bats/eosio_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,20 @@ TEST_LABEL="[eosio_build]"
fi

if [[ $ARCH == "Linux" ]]; then
if [[ $NAME == "CentOS Linux" ]]; then # Centos has the SCL prompt before checking for the compiler
# No c++!
run bash -c "printf \"y\ny\ny\nn\n\" | ./${SCRIPT_LOCATION}"
else
if [[ $NAME != "CentOS Linux" ]]; then # Centos has the SCL prompt before checking for the compiler
# No c++!
run bash -c "printf \"y\ny\ny\nn\nn\n\" | ./${SCRIPT_LOCATION}"
[[ ! -z $(echo "${output}" | grep "Unable to find .* compiler") ]] || exit
fi
[[ ! -z $(echo "${output}" | grep "Unable to find compiler") ]] || exit
fi

cd ./scripts # Also test that we can run the script from a directory other than the root
run bash -c "./eosio_build.sh -y -P"
[[ ! -z $(echo "${output}" | grep "PIN_COMPILER: true") ]] || exit
# Ensure build-essentials is installed so we can compile cmake, clang, boost, etc
if [[ $NAME == "Ubuntu" ]]; then
[[ ! -z $(echo "${output}" | grep "Installed build-essential") ]] || exit
fi
[[ "${output}" =~ -DCMAKE_TOOLCHAIN_FILE=\'.*/scripts/../build/pinned_toolchain.cmake\' ]] || exit
[[ "${output}" =~ "Clang 8 successfully installed" ]] || exit
# -P with prompts
Expand Down
11 changes: 5 additions & 6 deletions tests/bash-bats/eosio_build_centos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,22 @@ export TEST_LABEL="[eosio_build_centos]"
set_system_vars # Obtain current machine's resources and set the necessary variables (like JOBS, etc)

execute-always yum -y --enablerepo=extras install centos-release-scl &>/dev/null
install-package devtoolset-8 WETRUN &>/dev/null
# Ensure SCL and devtoolset-8 for c++ binary installation
install-package devtoolset-7 WETRUN &>/dev/null
# Ensure SCL and devtoolset-7 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 "devtoolset-8-8.0-2.el7.x86_64 found") ]] || exit
[[ ! -z $(echo "${output}" | grep "Executing: source /opt/rh/devtoolset-8/enable") ]] || exit
[[ ! -z $(echo "${output}" | grep "devtoolset-7.* found") ]] || exit
[[ ! -z $(echo "${output}" | grep "Executing: source /opt/rh/devtoolset-7/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 "python.*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
[[ ! -z $(echo "${output}" | grep "make -j${CPU_CORES}") ]] || exit
[[ ! -z $(echo "${output}" | grep "EOSIO has been successfully built") ]] || exit
uninstall-package devtoolset-8* WETRUN &>/dev/null
uninstall-package devtoolset-7* WETRUN &>/dev/null
uninstall-package centos-release-scl WETRUN &>/dev/null
}
6 changes: 2 additions & 4 deletions tests/bash-bats/eosio_build_ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ export TEST_LABEL="[eosio_build_ubuntu]"
@test "${TEST_LABEL} > General" {
set_system_vars # Obtain current machine's resources and set the necessary variables (like JOBS, etc)

# Testing clang already existing (no pinning of clang8)
install-package clang WETRUN &>/dev/null
[[ "$(echo ${VERSION_ID})" == "16.04" ]] && install-package build-essential WETRUN 1>/dev/null || install-package clang WETRUN 1>/dev/null
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
Expand All @@ -42,5 +40,5 @@ export TEST_LABEL="[eosio_build_ubuntu]"
[[ -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" ]] && uninstall-package clang WETRUN || uninstall-package build-essential WETRUN
[[ "$(echo ${VERSION_ID})" == "16.04" ]] && apt autoremove build-essential -y || uninstall-package clang WETRUN
}
17 changes: 11 additions & 6 deletions tests/bash-bats/helpers/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ setup-bats-dirs

function teardown() { # teardown is run once after each test, even if it fails
[[ -d "$HOME" ]] && rm -rf "$HOME"
uninstall-package which WETRUN
uninstall-package sudo WETRUN
uninstall-package devtoolset-8* WETRUN
uninstall-package centos-release-scl
uninstall-package gcc-c++ WETRUN
uninstall-package build-essential WETRUN
if [[ $ARCH == "Linux" ]]; then
uninstall-package which WETRUN
export SUDO_FORCE_REMOVE=yes
uninstall-package sudo WETRUN
uninstall-package devtoolset-7* WETRUN
uninstall-package centos-release-scl
uninstall-package gcc-c++ WETRUN
if [[ $NAME == 'Ubuntu' ]]; then
[[ ! $( dpkg -s build-essential 2>/dev/null ) ]] && apt autoremove build-essential -y &>/dev/null
fi
fi
}
trap teardown EXIT
4 changes: 2 additions & 2 deletions tests/bash-bats/modules/clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ load ../helpers/functions
# [[ ! -z $(echo "${output}" | grep "$CLANG_ROOT") ]] || exit
# fi
## CLANG
uninstall-package build-essential WETRUN 1>/dev/null
apt autoremove build-essential -y 1>/dev/null
run bash -c "./$SCRIPT_LOCATION -y -P"
[[ ! -z $(echo "${output}" | grep "PIN_COMPILER: true") ]] || exit
[[ ! -z $(echo "${output}" | grep "Clang 8 successfully installed") ]] || exit
Expand All @@ -30,6 +30,6 @@ load ../helpers/functions
export CXX=c2234
export CC=ewwqd
run bash -c "./$SCRIPT_LOCATION -y"
[[ ! -z $(echo "${output}" | grep "Unable to find compiler") ]] || exit
[[ ! -z $(echo "${output}" | grep "Unable to find .* compiler") ]] || exit

}