diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 48909093ac7..00000000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,92 +0,0 @@ -stages: - - publish builder - - publish to gitlab registry normal - - publish to gitlab registry dev - -variables: - REGISTRY: "registry.gitlab.com/cyberos/infrastructure" - -.docker-login: &docker-login - variables: - GIT_STRATEGY: clone - DOCKER_HOST: tcp://docker:2375/ - DOCKER_DRIVER: overlay2 - image: docker:stable - except: - - schedules - services: - - docker:dind - before_script: - - echo "${GITLAB_PASS}" | docker login registry.gitlab.com -u "${GITLAB_USER}" --password-stdin - -publish-nomral: - stage: publish to gitlab registry normal - image: docker:stable - variables: - GIT_STRATEGY: clone - DOCKER_HOST: tcp://docker:2375/ - DOCKER_DRIVER: overlay2 - only: - refs: - - master - - develop - services: - - docker:dind - except: - - schedules - <<: *docker-login - script: - - docker build -f Docker/Dockerfile -t haya --build-arg registry=${REGISTRY} . - - docker tag haya ${REGISTRY}/haya:${CI_COMMIT_SHA:0:8} - - docker tag haya ${REGISTRY}/haya:${CI_COMMIT_REF_NAME}-latest - - docker tag haya ${REGISTRY}/haya:latest - - docker push ${REGISTRY}/haya - -publish-dev: - stage: publish to gitlab registry dev - image: docker:stable - variables: - GIT_STRATEGY: clone - DOCKER_HOST: tcp://docker:2375/ - DOCKER_DRIVER: overlay2 - only: - refs: - - master - - develop - services: - - docker:dind - except: - - schedules - <<: *docker-login - script: - - docker build -f Docker/dev/Dockerfile -t haya-dev --build-arg registry=${REGISTRY} . - - docker tag haya-dev ${REGISTRY}/haya-dev:${CI_COMMIT_SHA:0:8} - - docker tag haya-dev ${REGISTRY}/haya-dev:${CI_COMMIT_REF_NAME}-latest - - docker tag haya-dev ${REGISTRY}/haya-dev:latest - - docker push ${REGISTRY}/haya-dev - -publish-builder: - stage: publish builder - image: docker:stable - variables: - GIT_STRATEGY: clone - DOCKER_HOST: tcp://docker:2375/ - DOCKER_DRIVER: overlay2 - only: - refs: - - develop - - master - changes: - - Docker/builder/Dockerfile - services: - - docker:dind - except: - - schedules - <<: *docker-login - script: - - cd Docker/builder - - docker build -t haya-builder . - - docker tag haya-builder ${REGISTRY}/haya-builder:${CI_COMMIT_SHA:0:8} - - docker tag haya-builder ${REGISTRY}/haya-builder:${CI_COMMIT_REF_NAME}-latest - - docker tag haya-builder ${REGISTRY}/haya-builder:latest - - docker push ${REGISTRY}/haya-builder diff --git a/.travis.yml b/.travis.yml index 60fd21c883f..2d333da9bf3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,7 +31,7 @@ before_script: fi script: - - ./cicd/run build -d $DISTRO -p --build-type=${BUILD_TYPE} --tests=$TESTS haya + - ./cicd/run build -d $DISTRO -p --build-type=${BUILD_TYPE} --tests=$TESTS --timeout=2400 haya - | if [ $DISTRO == "ubuntu" ]; then ./cicd/run build -d $DISTRO -i mixbytes/haya:$TRAVIS_BRANCH haya diff --git a/CMakeLists.txt b/CMakeLists.txt index ec4e1944104..6d2f74443f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -181,11 +181,11 @@ else() # Apple AND UNIX if( APPLE ) # Apple Specific Options Here message( STATUS "Configuring EOSIO on OS X" ) - set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-deprecated-declarations" ) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-deprecated-declarations" ) else() # UNIX # Linux Specific Options Here message( STATUS "Configuring EOSIO on Linux" ) - set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall" ) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall" ) if ( FULL_STATIC_BUILD ) set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc") endif ( FULL_STATIC_BUILD ) diff --git a/cicd/Dockerfile-centos-tools b/cicd/Dockerfile-centos-tools index 5c35f3a18a6..b66c52216ac 100644 --- a/cicd/Dockerfile-centos-tools +++ b/cicd/Dockerfile-centos-tools @@ -8,7 +8,7 @@ LABEL author="Andrey Levkin " \ version="0.1.0" \ description="Base image for building Haya on CentOS" -COPY . /var/src/${project_name} +COPY ./scripts /var/src/${project_name}/scripts WORKDIR /var/src/${project_name} @@ -16,12 +16,8 @@ RUN yum -y update && \ yum -y --enablerepo=extras install centos-release-scl && \ yum install -y epel-release && \ yum update -y --enablerepo=epel && \ - yum install -y devtoolset-7 git rpm-build ccache \ - autoconf automake libtool make bzip2 doxygen graphviz \ - bzip2-devel openssl-devel gmp-devel \ - ocaml libicu-devel python python-devel python33 \ - gettext-devel file sudo libusbx-devel libcurl-devel && \ - git submodule update --init --recursive && \ + yum install -y git curl sudo ccache && \ cd scripts && \ bash ${project_name}_build.sh -y -t && \ - rm -rf /var/src && rm -rf /var/cache/* + yum clean all && \ + rm -rf /var/src && rm -rf /var/cache/* && rm -rf /root/src diff --git a/cicd/Dockerfile-ubuntu-tools b/cicd/Dockerfile-ubuntu-tools index 139e7f81f70..c36f98a122c 100644 --- a/cicd/Dockerfile-ubuntu-tools +++ b/cicd/Dockerfile-ubuntu-tools @@ -8,16 +8,13 @@ LABEL author="Andrey Levkin " \ version="0.1.0" \ description="Base image for building Haya on Ubuntu" -COPY . /var/src/${project_name} +COPY ./scripts /var/src/${project_name}/scripts WORKDIR /var/src/${project_name} RUN apt-get update && \ - apt-get install -y \ - sudo git ccache llvm-4.0 clang-4.0 libclang-4.0-dev make automake libbz2-dev libssl-dev doxygen graphviz \ - libgmp3-dev autotools-dev build-essential libicu-dev python2.7 python2.7-dev python3 python3-dev \ - autoconf libtool curl zlib1g-dev sudo ruby libusb-1.0-0-dev libcurl4-gnutls-dev pkg-config && \ - git submodule update --init --recursive && \ + apt-get install -y git curl sudo ccache && \ cd scripts && \ bash ${project_name}_build.sh -y -t && \ - rm -rf /var/src && rm -rf /var/cache + rm -rf /var/src && rm -rf /var/cache && \ + rm -rf /var/lib/apt/lists/* && rm -rf /root/src diff --git a/cicd/build-in-docker.sh b/cicd/build-in-docker.sh index 0a0081a7b14..4f054765dab 100755 --- a/cicd/build-in-docker.sh +++ b/cicd/build-in-docker.sh @@ -21,7 +21,13 @@ cp -arf ${SRC_DIR}/${PROJECT_NAME} ${BUILD_DIR}/${PROJECT_NAME} cd "${BUILD_DIR}/${PROJECT_NAME}" #git submodule update --init --recursive cd scripts -./${PROJECT_NAME}_build.sh -y -f -o ${BUILD_TYPE} +./${PROJECT_NAME}_build.sh -y -f -n -o ${BUILD_TYPE} + +if [ -x $(command -v ccache) ]; then + echo "================CCACHE=================" + ccache -s + echo "=======================================" +fi if [ $TESTS ]; then if [ $DIST == "centos" ]; then diff --git a/cicd/run b/cicd/run index 7ab5180aaa2..03eb127f309 100755 --- a/cicd/run +++ b/cicd/run @@ -12,7 +12,7 @@ ProgName="./cicd/run" GIT_TAG=$(git describe --tags --abbrev=1) BUILD_DIR=build CACHE_DIR=${CCACHE_DIR:-$HOME/.ccache} -_BUILD_TYPE="Release" +_BUILD_TYPE="RelWithDebInfo" #SHELL=$3 @@ -46,6 +46,7 @@ function sub_help(){ echo " -d target platform {ubuntu,centos}" echo " --build-type build type {Debug,Release,RelWithDebInfo}" echo " --tests unit tests regex pattern" + echo " --timeout build timeout in seconds" echo "" echo "Example:" echo "# Build toolchain and project package for Ubuntu" @@ -112,6 +113,9 @@ function sub_build(){ build-type*) _BUILD_TYPE=$LONG_OPTARG ;; + timeout*) + _TIMEOUT=$LONG_OPTARG + ;; '') break ;; @@ -144,6 +148,11 @@ function sub_build(){ echo "Building ${_PROJECT_NAME} and create package for ${_DIST}" local _command="/mnt/src/${_PROJECT_NAME}/cicd/build-in-docker.sh ${_PROJECT_NAME} ${_DIST} ${_BUILD_TYPE} ${_TESTS}" local docker_image="${_PROJECT_NAME}-build-tools-${_DIST}:latest" + + if [[ $_TIMEOUT ]]; then + _command="timeout $_TIMEOUT $_command" + fi + if [[ login_to_container -eq 1 ]]; then _command=${_SHELL} docker_image="ubuntu:18.04" diff --git a/scripts/haya_build.sh b/scripts/haya_build.sh index 3f0268e51be..0aeaca29d55 100755 --- a/scripts/haya_build.sh +++ b/scripts/haya_build.sh @@ -67,7 +67,8 @@ export BOOST_VERSION_MAJOR=1 export BOOST_VERSION_MINOR=67 export BOOST_VERSION_PATCH=0 export BOOST_VERSION=${BOOST_VERSION_MAJOR}_${BOOST_VERSION_MINOR}_${BOOST_VERSION_PATCH} -export BOOST_ROOT=${SRC_LOCATION}/boost_${BOOST_VERSION} +export BOOST_SRC=${SRC_LOCATION}/boost_${BOOST_VERSION} +export BOOST_ROOT=${OPT_LOCATION}/boost_${BOOST_VERSION} export BOOST_LINK_LOCATION=${OPT_LOCATION}/boost export LLVM_VERSION=release_40 export LLVM_ROOT=${OPT_LOCATION}/llvm @@ -75,6 +76,7 @@ export LLVM_DIR=${LLVM_ROOT}/lib/cmake/llvm export DOXYGEN_VERSION=1_8_14 export DOXYGEN_ROOT=${SRC_LOCATION}/doxygen-${DOXYGEN_VERSION} export TINI_VERSION=0.18.0 +export CMAKE_CXX_FLAGS="" # Setup directories mkdir -p $SRC_LOCATION @@ -107,9 +109,10 @@ function usage() NONINTERACTIVE=0 BUILDTOOLSONLY=0 +NOWARNING=0 if [ $# -ne 0 ]; then - while getopts ":cdo:s:ahytf" opt; do + while getopts ":cdo:s:ahytfn" opt; do case "${opt}" in o ) options=( "Debug" "Release" "RelWithDebInfo" "MinSizeRel" ) @@ -152,6 +155,9 @@ if [ $# -ne 0 ]; then f) SKIP_DEPS_CHECK=1 ;; + n) + NOWARNING=1 + ;; \? ) printf "\\nInvalid Option: %s\\n" "-${OPTARG}" 1>&2 usage @@ -170,26 +176,31 @@ if [ $# -ne 0 ]; then done fi -if [ ! -d "${REPO_ROOT}/.git" ]; then - printf "\\nThis build script only works with sources cloned from git\\n" - printf "Please clone a new haya directory with 'git clone https://github.com/mixbytes/haya --recursive'\\n" - exit 1 -fi - cd $REPO_ROOT -STALE_SUBMODS=$(( $(git submodule status --recursive | grep -c "^[+\-]") )) -if [ $STALE_SUBMODS -gt 0 ]; then - printf "\\ngit submodules are not up to date.\\n" - printf "Please run the command 'git submodule update --init --recursive'.\\n" - exit 1 +if [ $BUILDTOOLSONLY == 0 ]; then + if [ ! -d "${REPO_ROOT}/.git" ]; then + printf "\\nThis build script only works with sources cloned from git\\n" + printf "Please clone a new haya directory with 'git clone https://github.com/mixbytes/haya --recursive'\\n" + exit 1 + fi + + STALE_SUBMODS=$(( $(git submodule status --recursive | grep -c "^[+\-]") )) + if [ $STALE_SUBMODS -gt 0 ]; then + printf "\\ngit submodules are not up to date.\\n" + printf "Please run the command 'git submodule update --init --recursive'.\\n" + exit 1 + fi fi printf "\\nBeginning build version: %s\\n" "${VERSION}" printf "%s\\n" "$( date -u )" printf "User: %s\\n" "$( whoami )" # printf "git head id: %s\\n" "$( cat .git/refs/heads/master )" -printf "Current branch: %s\\n" "$( git rev-parse --abbrev-ref HEAD )" + +if [ $BUILDTOOLSONLY == 0 ]; then + printf "Current branch: %s\\n" "$( git rev-parse --abbrev-ref HEAD )" +fi ARCH=$( uname ) printf "\\nARCHITECTURE: %s\\n" "${ARCH}" @@ -197,6 +208,10 @@ printf "\\nARCHITECTURE: %s\\n" "${ARCH}" # Find and use existing CMAKE export CMAKE=$(command -v cmake 2>/dev/null) +if [ "$NOWARNING" == 1 ]; then + CMAKE_CXX_FLAGS="-w" +fi + if [ "$ARCH" == "Linux" ]; then # Check if cmake is already installed or not and use source install location if [ -z $CMAKE ]; then export CMAKE=$HOME/bin/cmake; fi @@ -223,7 +238,6 @@ if [ "$ARCH" == "Linux" ]; then FILE="${REPO_ROOT}/scripts/haya_build_centos.sh" CXX_COMPILER=g++ C_COMPILER=gcc - export PATH=$PATH:/opt/rh/devtoolset-7/root/usr/bin ;; "elementary OS") FILE="${REPO_ROOT}/scripts/haya_build_ubuntu.sh" @@ -293,7 +307,8 @@ $CMAKE -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" -DCMAKE_CXX_COMPILER="${CXX_COMP -DCMAKE_C_COMPILER="${C_COMPILER}" -DCORE_SYMBOL_NAME="${CORE_SYMBOL_NAME}" \ -DOPENSSL_ROOT_DIR="${OPENSSL_ROOT_DIR}" -DBUILD_MONGO_DB_PLUGIN=true \ -DENABLE_COVERAGE_TESTING="${ENABLE_COVERAGE_TESTING}" -DBUILD_DOXYGEN="${DOXYGEN}" \ - -DCMAKE_INSTALL_PREFIX=$OPT_LOCATION/haya -DENABLE_TX_SPONSORSHIP=1 $LOCAL_CMAKE_FLAGS "${REPO_ROOT}" + -DCMAKE_INSTALL_PREFIX=$OPT_LOCATION/haya -DENABLE_TX_SPONSORSHIP=1 $LOCAL_CMAKE_FLAGS "${REPO_ROOT}" \ + -DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS" set +x if [ $? -ne 0 ]; then exit -1; fi make -j"${JOBS}" diff --git a/scripts/haya_build_centos.sh b/scripts/haya_build_centos.sh index 9c93883f4e9..969d5068735 100755 --- a/scripts/haya_build_centos.sh +++ b/scripts/haya_build_centos.sh @@ -21,302 +21,305 @@ printf "CPU speed: ${CPU_SPEED}Mhz\\n" printf "CPU cores: ${CPU_CORE}\\n" printf "Physical Memory: ${MEM_MEG}Mgb\\n" printf "Disk install: ${DISK_INSTALL}\\n" -printf "Disk space total: ${DISK_TOTAL%.*}G\\n" +printf "Disk space total: ${DISK_TOTAL%.*}G\\n" printf "Disk space available: ${DISK_AVAIL%.*}G\\n" printf "Concurrent Jobs (make -j): ${JOBS}\\n" if [ "${MEM_MEG}" -lt 7000 ]; then - printf "\\nYour system must have 7 or more Gigabytes of physical memory installed.\\n" - printf "Exiting now.\\n\\n" - exit 1; + printf "\\nYour system must have 7 or more Gigabytes of physical memory installed.\\n" + printf "Exiting now.\\n\\n" + exit 1; fi if [ "${OS_VER}" -lt 7 ]; then - printf "\\nYou must be running Centos 7 or higher to install EOSIO.\\n" - printf "Exiting now.\\n\\n" - exit 1; + printf "\\nYou must be running Centos 7 or higher to install EOSIO.\\n" + printf "Exiting now.\\n\\n" + exit 1; fi if [ "${DISK_AVAIL%.*}" -lt "${DISK_MIN}" ]; then - printf "\\nYou must have at least %sGB of available storage to install EOSIO.\\n" "${DISK_MIN}" - printf "Exiting now.\\n\\n" - exit 1; + printf "\\nYou must have at least %sGB of available storage to install EOSIO.\\n" "${DISK_MIN}" + printf "Exiting now.\\n\\n" + exit 1; fi -if [ -d /opt/rh/devtoolset-7 ]; then - printf "Enabling Centos devtoolset-7 so we can use GCC 7...\\n" - source /opt/rh/devtoolset-7/enable || exit 1 - printf " - Centos devtoolset-7 successfully enabled!\\n" +if [ -d /opt/rh/devtoolset-8 ]; then + printf "Enabling Centos devtoolset-8 so we can use GCC 8...\\n" + source /opt/rh/devtoolset-8/enable || exit 1 + printf " - Centos devtoolset-8 successfully enabled!\\n" fi if [ -d /opt/rh/python33 ]; then - printf "Enabling python33...\\n" - source /opt/rh/python33/enable || exit 1 - printf " - Python33 successfully enabled!\\n" + printf "Enabling python33...\\n" + source /opt/rh/python33/enable || exit 1 + printf " - Python33 successfully enabled!\\n" fi if [ -z $SKIP_DEPS_CHECK ]; then -printf "\\n" - -printf "Checking Yum installation...\\n" -if ! YUM=$( command -v yum 2>/dev/null ); then - printf "!! Yum must be installed to compile EOS.IO !!\\n" - printf "Exiting now.\\n" - exit 1; -fi -printf " - Yum installation found at %s.\\n" "${YUM}" - -if [ $ANSWER != 1 ]; then read -p "Do you wish to update YUM repositories? (y/n) " ANSWER; fi -case $ANSWER in - 1 | [Yy]* ) - if ! "${YUM}" -y update; then - printf " - YUM update failed.\\n" - exit 1; - else - printf " - YUM update complete.\\n" - fi - ;; - [Nn]* ) echo " - Proceeding without update!";; - * ) echo "Please type 'y' for yes or 'n' for no."; exit;; -esac - -printf "Checking installation of Centos Software Collections Repository...\\n" -SCL=$( rpm -qa | grep -E 'centos-release-scl-[0-9].*' ) -if [ -z "${SCL}" ]; then - if [ $ANSWER != 1 ]; then read -p "Do you wish to install and enable this repository? (y/n)? " ANSWER; fi - case $ANSWER in - 1 | [Yy]* ) - printf "Installing SCL...\\n" - if ! "${YUM}" -y --enablerepo=extras install centos-release-scl 2>/dev/null; then - printf "!! Centos Software Collections Repository installation failed !!\\n" - printf "Exiting now.\\n\\n" - exit 1; - else - printf "Centos Software Collections Repository installed successfully.\\n" - fi - ;; - [Nn]* ) echo "User aborting installation of required Centos Software Collections Repository, Exiting now."; exit;; - * ) echo "Please type 'y' for yes or 'n' for no."; exit;; - esac -else - printf " - ${SCL} found.\\n" -fi - -printf "Checking installation of devtoolset-7...\\n" -DEVTOOLSET=$( rpm -qa | grep -E 'devtoolset-7-[0-9].*' ) -if [ -z "${DEVTOOLSET}" ]; then - if [ $ANSWER != 1 ]; then read -p "Do you wish to install devtoolset-7? (y/n)? " ANSWER; fi - case $ANSWER in - 1 | [Yy]* ) - printf "Installing devtoolset-7...\\n" - if ! "${YUM}" install -y devtoolset-7; then - printf "!! Centos devtoolset-7 installation failed !!\\n" - printf "Exiting now.\\n" - exit 1; - else - printf " - Centos devtoolset installed successfully!\\n" - fi - ;; - [Nn]* ) echo "User aborting installation of devtoolset-7. Exiting now."; exit;; - * ) echo "Please type 'y' for yes or 'n' for no."; exit;; - esac -else - printf " - ${DEVTOOLSET} found.\\n" -fi -if [ -d /opt/rh/devtoolset-7 ]; then - printf "Enabling Centos devtoolset-7 so we can use GCC 7...\\n" - source /opt/rh/devtoolset-7/enable || exit 1 - printf " - Centos devtoolset-7 successfully enabled!\\n" -fi - -printf "\\n" - -DEP_ARRAY=( - git autoconf automake libtool make bzip2 doxygen graphviz \ - bzip2-devel openssl-devel gmp-devel \ - ocaml libicu-devel python python-devel python33 \ - gettext-devel file sudo libusbx-devel libcurl-devel - ) -COUNT=1 -DISPLAY="" -DEP="" -printf "Checking RPM for installed dependencies...\\n" -for (( i=0; i<${#DEP_ARRAY[@]}; i++ )); do - pkg=$( rpm -qi "${DEP_ARRAY[$i]}" 2>/dev/null | grep Name ) - if [[ -z $pkg ]]; then - DEP=$DEP" ${DEP_ARRAY[$i]} " - DISPLAY="${DISPLAY}${COUNT}. ${DEP_ARRAY[$i]}\\n" - printf " - Package %s ${bldred} NOT ${txtrst} found!\\n" "${DEP_ARRAY[$i]}" - (( COUNT++ )) - else - printf " - Package %s found.\\n" "${DEP_ARRAY[$i]}" - continue - fi -done -if [ "${COUNT}" -gt 1 ]; then - printf "\\nThe following dependencies are required to install EOSIO:\\n" - printf "${DISPLAY}\\n\\n" - if [ $ANSWER != 1 ]; then read -p "Do you wish to install these dependencies? (y/n) " ANSWER; fi - case $ANSWER in - 1 | [Yy]* ) - if ! "${YUM}" -y install ${DEP}; then - printf " - YUM dependency installation failed!\\n" - exit 1; - else - printf " - YUM dependencies installed successfully.\\n" - fi - ;; - [Nn]* ) echo "User aborting installation of required dependencies, Exiting now."; exit;; - * ) echo "Please type 'y' for yes or 'n' for no."; exit;; - esac -else - printf " - No required YUM dependencies to install.\\n" -fi - -if [ -d /opt/rh/python33 ]; then - printf "Enabling python33...\\n" - source /opt/rh/python33/enable || exit 1 - printf " - Python33 successfully enabled!\\n" + printf "\\n" + + printf "Checking Yum installation...\\n" + if ! YUM=$( command -v yum 2>/dev/null ); then + printf "!! Yum must be installed to compile EOS.IO !!\\n" + printf "Exiting now.\\n" + exit 1; + fi + printf " - Yum installation found at %s.\\n" "${YUM}" + + if [ $ANSWER != 1 ]; then read -p "Do you wish to update YUM repositories? (y/n) " ANSWER; fi + case $ANSWER in + 1 | [Yy]* ) + if ! "${YUM}" -y update; then + printf " - YUM update failed.\\n" + exit 1; + else + printf " - YUM update complete.\\n" + fi + ;; + [Nn]* ) echo " - Proceeding without update!";; + * ) echo "Please type 'y' for yes or 'n' for no."; exit;; + esac + + printf "Checking installation of Centos Software Collections Repository...\\n" + SCL=$( rpm -qa | grep -E 'centos-release-scl-[0-9].*' ) + if [ -z "${SCL}" ]; then + if [ $ANSWER != 1 ]; then read -p "Do you wish to install and enable this repository? (y/n)? " ANSWER; fi + case $ANSWER in + 1 | [Yy]* ) + printf "Installing SCL...\\n" + if ! "${YUM}" -y --enablerepo=extras install centos-release-scl 2>/dev/null; then + printf "!! Centos Software Collections Repository installation failed !!\\n" + printf "Exiting now.\\n\\n" + exit 1; + else + printf "Centos Software Collections Repository installed successfully.\\n" + fi + ;; + [Nn]* ) echo "User aborting installation of required Centos Software Collections Repository, Exiting now."; exit;; + * ) echo "Please type 'y' for yes or 'n' for no."; exit;; + esac + else + printf " - ${SCL} found.\\n" + fi + + printf "Checking installation of devtoolset-8...\\n" + DEVTOOLSET=$( rpm -qa | grep -E 'devtoolset-8-[0-9].*' ) + if [ -z "${DEVTOOLSET}" ]; then + if [ $ANSWER != 1 ]; then read -p "Do you wish to install devtoolset-8? (y/n)? " ANSWER; fi + case $ANSWER in + 1 | [Yy]* ) + printf "Installing devtoolset-8...\\n" + if ! "${YUM}" install -y devtoolset-8; then + printf "!! Centos devtoolset-8 installation failed !!\\n" + printf "Exiting now.\\n" + exit 1; + else + printf " - Centos devtoolset installed successfully!\\n" + fi + ;; + [Nn]* ) echo "User aborting installation of devtoolset-8. Exiting now."; exit;; + * ) echo "Please type 'y' for yes or 'n' for no."; exit;; + esac + else + printf " - ${DEVTOOLSET} found.\\n" + fi + if [ -d /opt/rh/devtoolset-8 ]; then + printf "Enabling Centos devtoolset-8 so we can use GCC 7...\\n" + source /opt/rh/devtoolset-8/enable || exit 1 + printf " - Centos devtoolset-8 successfully enabled!\\n" + fi + + printf "\\n" + + DEV_DEP_ARRAY=( + doxygen graphviz bzip2-devel python python-devel + ) + DEP_ARRAY=( + git autoconf automake libtool make \ + openssl-devel gmp-devel bzip2 \ + ocaml libicu-devel python33 rpm-build \ + gettext-devel file sudo libusbx-devel libcurl-devel + ) + + if [ $BUILDTOOLSONLY == 0 ]; then + DEP_ARRAY=( ${DEP_ARRAY[@]} ${DEV_DEP_ARRAY[@]} ) + fi + + COUNT=1 + DISPLAY="" + DEP="" + + printf "Checking RPM for installed dependencies...\\n" + for (( i=0; i<${#DEP_ARRAY[@]}; i++ )); do + pkg=$( rpm -qi "${DEP_ARRAY[$i]}" 2>/dev/null | grep Name ) + if [[ -z $pkg ]]; then + DEP=$DEP" ${DEP_ARRAY[$i]} " + DISPLAY="${DISPLAY}${COUNT}. ${DEP_ARRAY[$i]}\\n" + printf " - Package %s ${bldred} NOT ${txtrst} found!\\n" "${DEP_ARRAY[$i]}" + (( COUNT++ )) + else + printf " - Package %s found.\\n" "${DEP_ARRAY[$i]}" + continue + fi + done + if [ "${COUNT}" -gt 1 ]; then + printf "\\nThe following dependencies are required to install EOSIO:\\n" + printf "${DISPLAY}\\n\\n" + if [ $ANSWER != 1 ]; then read -p "Do you wish to install these dependencies? (y/n) " ANSWER; fi + case $ANSWER in + 1 | [Yy]* ) + if ! "${YUM}" -y install ${DEP}; then + printf " - YUM dependency installation failed!\\n" + exit 1; + else + printf " - YUM dependencies installed successfully.\\n" + fi + ;; + [Nn]* ) echo "User aborting installation of required dependencies, Exiting now."; exit;; + * ) echo "Please type 'y' for yes or 'n' for no."; exit;; + esac + else + printf " - No required YUM dependencies to install.\\n" + fi + + if [ -d /opt/rh/python33 ]; then + printf "Enabling python33...\\n" + source /opt/rh/python33/enable || exit 1 + printf " - Python33 successfully enabled!\\n" + fi + + printf "\\n" + + printf "Checking CMAKE installation...\\n" + if [ ! -e $CMAKE ]; then + printf "Installing CMAKE...\\n" + curl -LO https://cmake.org/files/v$CMAKE_VERSION_MAJOR.$CMAKE_VERSION_MINOR/cmake-$CMAKE_VERSION.tar.gz \ + && tar -xzf cmake-$CMAKE_VERSION.tar.gz \ + && cd cmake-$CMAKE_VERSION \ + && ./bootstrap --prefix=$HOME \ + && make -j"${JOBS}" \ + && make install \ + && cd .. \ + && rm -f cmake-$CMAKE_VERSION.tar.gz \ + || exit 1 + printf " - CMAKE successfully installed @ ${CMAKE} \\n" + else + printf " - CMAKE found @ ${CMAKE}.\\n" + fi + if [ $? -ne 0 ]; then exit -1; fi + + printf "\\n" + + export CPATH="$CPATH:/opt/rh/python33/root/usr/include/python3.3m" # m on the end causes problems with boost finding python3 + printf "Checking Boost library (${BOOST_VERSION}) installation...\\n" + BOOSTVERSION=$( grep "#define BOOST_VERSION" "$HOME/opt/boost/include/boost/version.hpp" 2>/dev/null | tail -1 | tr -s ' ' | cut -d\ -f3 ) + if [ "${BOOSTVERSION}" != "${BOOST_VERSION_MAJOR}0${BOOST_VERSION_MINOR}0${BOOST_VERSION_PATCH}" ]; then + printf "Installing Boost library...\\n" + curl -LO https://dl.bintray.com/boostorg/release/${BOOST_VERSION_MAJOR}.${BOOST_VERSION_MINOR}.${BOOST_VERSION_PATCH}/source/boost_$BOOST_VERSION.tar.bz2 \ + && tar -xjf boost_$BOOST_VERSION.tar.bz2 \ + && cd $BOOST_SRC \ + && ./bootstrap.sh --prefix=$BOOST_ROOT \ + && ./b2 -q -j"${JOBS}" --with-iostreams --with-date_time --with-filesystem --with-system --with-program_options --with-chrono --with-test install \ + && cd .. \ + && rm -f boost_$BOOST_VERSION.tar.bz2 \ + && rm -rf $BOOST_SRC \ + || exit 1 + printf " - Boost library successfully installed @ ${BOOST_ROOT} (Copied to ${BOOST_LINK_LOCATION}).\\n" + else + printf " - Boost library found with correct version @ ${BOOST_ROOT} (Copied to ${BOOST_LINK_LOCATION}).\\n" + fi + if [ $? -ne 0 ]; then exit -1; fi + + printf "\\n" + + if [ $BUILDTOOLSONLY == 0 ]; then + printf "Checking MongoDB installation...\\n" + if [ ! -d $MONGODB_ROOT ]; then + printf "Installing MongoDB into ${MONGODB_ROOT}...\\n" + curl -OL https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \ + && tar -xzf mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \ + && mv $SRC_LOCATION/mongodb-linux-x86_64-amazon-$MONGODB_VERSION $MONGODB_ROOT \ + && touch $MONGODB_LOG_LOCATION/mongod.log \ + && rm -f mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \ + && cp -f $REPO_ROOT/scripts/mongod.conf $MONGODB_CONF \ + && mkdir -p $MONGODB_DATA_LOCATION \ + && rm -rf $MONGODB_LINK_LOCATION \ + && rm -rf $BIN_LOCATION/mongod \ + && ln -s $MONGODB_ROOT $MONGODB_LINK_LOCATION \ + && ln -s $MONGODB_LINK_LOCATION/bin/mongod $BIN_LOCATION/mongod \ + || exit 1 + printf " - MongoDB successfully installed @ ${MONGODB_ROOT} (Symlinked to ${MONGODB_LINK_LOCATION}).\\n" + else + printf " - MongoDB found with correct version @ ${MONGODB_ROOT} (Symlinked to ${MONGODB_LINK_LOCATION}).\\n" + fi + if [ $? -ne 0 ]; then exit -1; fi + fi + + printf "Checking MongoDB C driver installation...\\n" + if [ ! -d $MONGO_C_DRIVER_ROOT ]; then + printf "Installing MongoDB C driver...\\n" + curl -LO https://github.com/mongodb/mongo-c-driver/releases/download/$MONGO_C_DRIVER_VERSION/mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \ + && tar -xzf mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \ + && cd mongo-c-driver-$MONGO_C_DRIVER_VERSION \ + && mkdir -p cmake-build \ + && cd cmake-build \ + && $CMAKE -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME -DENABLE_BSON=ON -DENABLE_SSL=OPENSSL -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_STATIC=ON .. \ + && make -j"${JOBS}" \ + && make install \ + && cd ../.. \ + && rm mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \ + || exit 1 + printf " - MongoDB C driver successfully installed @ ${MONGO_C_DRIVER_ROOT}.\\n" + else + printf " - MongoDB C driver found with correct version @ ${MONGO_C_DRIVER_ROOT}.\\n" + fi + if [ $? -ne 0 ]; then exit -1; fi + + printf "Checking MongoDB C++ driver installation...\\n" + if [ ! -d $MONGO_CXX_DRIVER_ROOT ]; then + printf "Installing MongoDB C++ driver...\\n" + curl -L https://github.com/mongodb/mongo-cxx-driver/archive/r$MONGO_CXX_DRIVER_VERSION.tar.gz -o mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \ + && tar -xzf mongo-cxx-driver-r${MONGO_CXX_DRIVER_VERSION}.tar.gz \ + && cd mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION/build \ + && $CMAKE -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME .. \ + && make -j"${JOBS}" VERBOSE=1 \ + && make install \ + && cd ../.. \ + && rm -f mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \ + || exit 1 + printf " - MongoDB C++ driver successfully installed @ ${MONGO_CXX_DRIVER_ROOT}.\\n" + else + printf " - MongoDB C++ driver found with correct version @ ${MONGO_CXX_DRIVER_ROOT}.\\n" + fi + if [ $? -ne 0 ]; then exit -1; fi + + printf "\\n" + + printf "Checking LLVM 4 support...\\n" + if [ ! -d $LLVM_ROOT ]; then + printf "Installing LLVM 4...\\n" + cd ../opt \ + && git clone --depth 1 --single-branch --branch $LLVM_VERSION https://github.com/llvm-mirror/llvm.git llvm && cd llvm \ + && mkdir build \ + && cd build \ + && $CMAKE -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${LLVM_ROOT}" -DLLVM_TARGETS_TO_BUILD="host" -DLLVM_BUILD_TOOLS=false -DLLVM_ENABLE_RTTI=1 -DCMAKE_BUILD_TYPE="Release" .. \ + && make -j"${JOBS}" \ + && make install \ + && cd ../.. \ + || exit 1 + printf " - LLVM successfully installed @ ${LLVM_ROOT}\\n" + else + printf " - LLVM found @ ${LLVM_ROOT}.\\n" + fi + if [ $? -ne 0 ]; then exit -1; fi + + cd .. + printf "\\n" fi -printf "\\n" - -printf "Checking CMAKE installation...\\n" -if [ ! -e $CMAKE ]; then - printf "Installing CMAKE...\\n" - curl -LO https://cmake.org/files/v$CMAKE_VERSION_MAJOR.$CMAKE_VERSION_MINOR/cmake-$CMAKE_VERSION.tar.gz \ - && tar -xzf cmake-$CMAKE_VERSION.tar.gz \ - && cd cmake-$CMAKE_VERSION \ - && ./bootstrap --prefix=$HOME \ - && make -j"${JOBS}" \ - && make install \ - && cd .. \ - && rm -f cmake-$CMAKE_VERSION.tar.gz \ - || exit 1 - printf " - CMAKE successfully installed @ ${CMAKE} \\n" -else - printf " - CMAKE found @ ${CMAKE}.\\n" -fi -if [ $? -ne 0 ]; then exit -1; fi - - -printf "\\n" - - -export CPATH="$CPATH:/opt/rh/python33/root/usr/include/python3.3m" # m on the end causes problems with boost finding python3 -printf "Checking Boost library (${BOOST_VERSION}) installation...\\n" -BOOSTVERSION=$( grep "#define BOOST_VERSION" "$HOME/opt/boost/include/boost/version.hpp" 2>/dev/null | tail -1 | tr -s ' ' | cut -d\ -f3 ) -if [ "${BOOSTVERSION}" != "${BOOST_VERSION_MAJOR}0${BOOST_VERSION_MINOR}0${BOOST_VERSION_PATCH}" ]; then - printf "Installing Boost library...\\n" - curl -LO https://dl.bintray.com/boostorg/release/${BOOST_VERSION_MAJOR}.${BOOST_VERSION_MINOR}.${BOOST_VERSION_PATCH}/source/boost_$BOOST_VERSION.tar.bz2 \ - && tar -xjf boost_$BOOST_VERSION.tar.bz2 \ - && cd $BOOST_ROOT \ - && ./bootstrap.sh --prefix=$BOOST_ROOT \ - && ./b2 -q -j"${JOBS}" install \ - && cd .. \ - && rm -f boost_$BOOST_VERSION.tar.bz2 \ - && rm -rf $BOOST_LINK_LOCATION \ - && mkdir $BOOST_LINK_LOCATION \ - && cp -r $BOOST_ROOT/lib $BOOST_LINK_LOCATION/ \ - && cp -r $BOOST_ROOT/include $BOOST_LINK_LOCATION/ \ - || exit 1 - printf " - Boost library successfully installed @ ${BOOST_ROOT} (Copied to ${BOOST_LINK_LOCATION}).\\n" -else - printf " - Boost library found with correct version @ ${BOOST_ROOT} (Copied to ${BOOST_LINK_LOCATION}).\\n" -fi -if [ $? -ne 0 ]; then exit -1; fi - - -printf "\\n" - - -printf "Checking MongoDB installation...\\n" -if [ ! -d $MONGODB_ROOT ]; then - printf "Installing MongoDB into ${MONGODB_ROOT}...\\n" - curl -OL https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \ - && tar -xzf mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \ - && mv $SRC_LOCATION/mongodb-linux-x86_64-amazon-$MONGODB_VERSION $MONGODB_ROOT \ - && touch $MONGODB_LOG_LOCATION/mongod.log \ - && rm -f mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \ - && cp -f $REPO_ROOT/scripts/mongod.conf $MONGODB_CONF \ - && mkdir -p $MONGODB_DATA_LOCATION \ - && rm -rf $MONGODB_LINK_LOCATION \ - && rm -rf $BIN_LOCATION/mongod \ - && ln -s $MONGODB_ROOT $MONGODB_LINK_LOCATION \ - && ln -s $MONGODB_LINK_LOCATION/bin/mongod $BIN_LOCATION/mongod \ - || exit 1 - printf " - MongoDB successfully installed @ ${MONGODB_ROOT} (Symlinked to ${MONGODB_LINK_LOCATION}).\\n" -else - printf " - MongoDB found with correct version @ ${MONGODB_ROOT} (Symlinked to ${MONGODB_LINK_LOCATION}).\\n" -fi -if [ $? -ne 0 ]; then exit -1; fi -printf "Checking MongoDB C driver installation...\\n" -if [ ! -d $MONGO_C_DRIVER_ROOT ]; then - printf "Installing MongoDB C driver...\\n" - curl -LO https://github.com/mongodb/mongo-c-driver/releases/download/$MONGO_C_DRIVER_VERSION/mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \ - && tar -xzf mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \ - && cd mongo-c-driver-$MONGO_C_DRIVER_VERSION \ - && mkdir -p cmake-build \ - && cd cmake-build \ - && $CMAKE -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME -DENABLE_BSON=ON -DENABLE_SSL=OPENSSL -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_STATIC=ON .. \ - && make -j"${JOBS}" \ - && make install \ - && cd ../.. \ - && rm mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \ - || exit 1 - printf " - MongoDB C driver successfully installed @ ${MONGO_C_DRIVER_ROOT}.\\n" -else - printf " - MongoDB C driver found with correct version @ ${MONGO_C_DRIVER_ROOT}.\\n" -fi -if [ $? -ne 0 ]; then exit -1; fi -printf "Checking MongoDB C++ driver installation...\\n" -if [ ! -d $MONGO_CXX_DRIVER_ROOT ]; then - printf "Installing MongoDB C++ driver...\\n" - curl -L https://github.com/mongodb/mongo-cxx-driver/archive/r$MONGO_CXX_DRIVER_VERSION.tar.gz -o mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \ - && tar -xzf mongo-cxx-driver-r${MONGO_CXX_DRIVER_VERSION}.tar.gz \ - && cd mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION/build \ - && $CMAKE -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME .. \ - && make -j"${JOBS}" VERBOSE=1 \ - && make install \ - && cd ../.. \ - && rm -f mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \ - || exit 1 - printf " - MongoDB C++ driver successfully installed @ ${MONGO_CXX_DRIVER_ROOT}.\\n" -else - printf " - MongoDB C++ driver found with correct version @ ${MONGO_CXX_DRIVER_ROOT}.\\n" -fi -if [ $? -ne 0 ]; then exit -1; fi - - -printf "\\n" - - -printf "Checking LLVM 4 support...\\n" -if [ ! -d $LLVM_ROOT ]; then - printf "Installing LLVM 4...\\n" - cd ../opt \ - && git clone --depth 1 --single-branch --branch $LLVM_VERSION https://github.com/llvm-mirror/llvm.git llvm && cd llvm \ - && mkdir build \ - && cd build \ - && $CMAKE -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${LLVM_ROOT}" -DLLVM_TARGETS_TO_BUILD="host" -DLLVM_BUILD_TOOLS=false -DLLVM_ENABLE_RTTI=1 -DCMAKE_BUILD_TYPE="Release" .. \ - && make -j"${JOBS}" \ - && make install \ - && cd ../.. \ - || exit 1 - printf " - LLVM successfully installed @ ${LLVM_ROOT}\\n" -else - printf " - LLVM found @ ${LLVM_ROOT}.\\n" -fi -if [ $? -ne 0 ]; then exit -1; fi - - -cd .. -printf "\\n" - function print_instructions() { - printf "source /opt/rh/python33/enable\\n" - printf "source /opt/rh/devtoolset-7/enable\\n" - return 0 + printf "source /opt/rh/python33/enable\\n" + printf "source /opt/rh/devtoolset-8/enable\\n" + return 0 } -fi diff --git a/scripts/haya_build_ubuntu.sh b/scripts/haya_build_ubuntu.sh index 689a3450de4..478c6cb6a55 100755 --- a/scripts/haya_build_ubuntu.sh +++ b/scripts/haya_build_ubuntu.sh @@ -26,239 +26,239 @@ printf "Disk space total: ${DISK_TOTAL%.*}G\\n" printf "Disk space available: ${DISK_AVAIL%.*}G\\n" if [ "${MEM_MEG}" -lt 7000 ]; then - printf "Your system must have 7 or more Gigabytes of physical memory installed.\\n" - printf "Exiting now.\\n" - exit 1 + printf "Your system must have 7 or more Gigabytes of physical memory installed.\\n" + printf "Exiting now.\\n" + exit 1 fi case "${OS_NAME}" in - "Linux Mint") - if [ "${OS_MAJ}" -lt 18 ]; then - printf "You must be running Linux Mint 18.x or higher to install EOSIO.\\n" - printf "Exiting now.\\n" - exit 1 - fi - ;; - "Ubuntu") - if [ "${OS_MAJ}" -lt 16 ]; then - printf "You must be running Ubuntu 16.04.x or higher to install EOSIO.\\n" - printf "Exiting now.\\n" - exit 1 - fi - # UBUNTU 18 doesn't have MONGODB 3.6.3 - if [ $OS_MAJ -gt 16 ]; then - export MONGODB_VERSION=4.1.1 - fi - # We have to re-set this with the new version - export MONGODB_ROOT=${OPT_LOCATION}/mongodb-${MONGODB_VERSION} - ;; - "Debian") - if [ $OS_MAJ -lt 10 ]; then - printf "You must be running Debian 10 to install EOSIO, and resolve missing dependencies from unstable (sid).\n" - printf "Exiting now.\n" - exit 1 - fi - ;; + "Linux Mint") + if [ "${OS_MAJ}" -lt 18 ]; then + printf "You must be running Linux Mint 18.x or higher to install EOSIO.\\n" + printf "Exiting now.\\n" + exit 1 + fi + ;; + "Ubuntu") + if [ "${OS_MAJ}" -lt 16 ]; then + printf "You must be running Ubuntu 16.04.x or higher to install EOSIO.\\n" + printf "Exiting now.\\n" + exit 1 + fi + # UBUNTU 18 doesn't have MONGODB 3.6.3 + if [ $OS_MAJ -gt 16 ]; then + export MONGODB_VERSION=4.1.1 + fi + # We have to re-set this with the new version + export MONGODB_ROOT=${OPT_LOCATION}/mongodb-${MONGODB_VERSION} + ;; + "Debian") + if [ $OS_MAJ -lt 10 ]; then + printf "You must be running Debian 10 to install EOSIO, and resolve missing dependencies from unstable (sid).\n" + printf "Exiting now.\n" + exit 1 + fi + ;; esac if [ "${DISK_AVAIL%.*}" -lt "${DISK_MIN}" ]; then - printf "You must have at least %sGB of available storage to install EOSIO.\\n" "${DISK_MIN}" - printf "Exiting now.\\n" - exit 1 + printf "You must have at least %sGB of available storage to install EOSIO.\\n" "${DISK_MIN}" + printf "Exiting now.\\n" + exit 1 fi if [ -z $SKIP_DEPS_CHECK ]; then + # llvm-4.0 is installed into /usr/lib/llvm-4.0 + # clang is necessary for building on ubuntu + DEV_DEP_ARRAY=( + libbz2-dev doxygen graphviz python2.7 python2.7-dev ruby + ) + DEP_ARRAY=( + git llvm-4.0 clang-4.0 libclang-4.0-dev make automake libssl-dev \ + libgmp3-dev autotools-dev build-essential libicu-dev python3 python3-dev \ + autoconf libtool curl zlib1g-dev sudo libusb-1.0-0-dev libcurl4-gnutls-dev pkg-config + ) -# llvm-4.0 is installed into /usr/lib/llvm-4.0 -# clang is necessary for building on ubuntu -DEP_ARRAY=( - git llvm-4.0 clang-4.0 libclang-4.0-dev make automake libbz2-dev libssl-dev doxygen graphviz \ - libgmp3-dev autotools-dev build-essential libicu-dev python2.7 python2.7-dev python3 python3-dev \ - autoconf libtool curl zlib1g-dev sudo ruby libusb-1.0-0-dev libcurl4-gnutls-dev pkg-config -) -COUNT=1 -DISPLAY="" -DEP="" + if [ $BUILDTOOLSONLY == 0 ]; then + DEP_ARRAY=( ${DEP_ARRAY[@]} ${DEV_DEP_ARRAY[@]} ) + fi -if [[ "${ENABLE_CODE_COVERAGE}" == true ]]; then - DEP_ARRAY+=(lcov) -fi - -if [ $ANSWER != 1 ]; then read -p "Do you wish to update repositories with apt-get update? (y/n) " ANSWER; fi -case $ANSWER in - 1 | [Yy]* ) - if ! sudo apt-get update; then - printf " - APT update failed.\\n" - exit 1; - else - printf " - APT update complete.\\n" - fi - ;; - [Nn]* ) echo "Proceeding without update!";; - * ) echo "Please type 'y' for yes or 'n' for no."; exit;; -esac + COUNT=1 + DISPLAY="" + DEP="" -printf "\\nChecking for installed dependencies...\\n" -for (( i=0; i<${#DEP_ARRAY[@]}; i++ )); do - pkg=$( dpkg -s "${DEP_ARRAY[$i]}" 2>/dev/null | grep Status | tr -s ' ' | cut -d\ -f4 ) - if [ -z "$pkg" ]; then - DEP=$DEP" ${DEP_ARRAY[$i]} " - DISPLAY="${DISPLAY}${COUNT}. ${DEP_ARRAY[$i]}\\n" - printf " - Package %s${bldred} NOT${txtrst} found!\\n" "${DEP_ARRAY[$i]}" - (( COUNT++ )) - else - printf " - Package %s found.\\n" "${DEP_ARRAY[$i]}" - continue - fi -done -if [ "${COUNT}" -gt 1 ]; then - printf "\\nThe following dependencies are required to install EOSIO:\\n" - printf "${DISPLAY}\\n\\n" - if [ $ANSWER != 1 ]; then read -p "Do you wish to install these packages? (y/n) " ANSWER; fi - case $ANSWER in - 1 | [Yy]* ) - if ! sudo apt-get -y install ${DEP}; then - printf " - APT dependency failed.\\n" - exit 1 - else - printf " - APT dependencies installed successfully.\\n" - fi - ;; - [Nn]* ) echo "User aborting installation of required dependencies, Exiting now."; exit;; - * ) echo "Please type 'y' for yes or 'n' for no."; exit;; - esac -else - printf " - No required APT dependencies to install." -fi + if [[ "${ENABLE_CODE_COVERAGE}" == true ]]; then + DEP_ARRAY+=(lcov) + fi + if [ $ANSWER != 1 ]; then read -p "Do you wish to update repositories with apt-get update? (y/n) " ANSWER; fi + case $ANSWER in + 1 | [Yy]* ) + if ! sudo apt-get update; then + printf " - APT update failed.\\n" + exit 1; + else + printf " - APT update complete.\\n" + fi + ;; + [Nn]* ) echo "Proceeding without update!";; + * ) echo "Please type 'y' for yes or 'n' for no."; exit;; + esac -printf "\\n" - - -printf "Checking CMAKE installation...\\n" -if [ ! -e $CMAKE ]; then - printf "Installing CMAKE...\\n" - curl -LO https://cmake.org/files/v$CMAKE_VERSION_MAJOR.$CMAKE_VERSION_MINOR/cmake-$CMAKE_VERSION.tar.gz \ - && tar -xzf cmake-$CMAKE_VERSION.tar.gz \ - && cd cmake-$CMAKE_VERSION \ - && ./bootstrap --prefix=$HOME \ - && make -j"${JOBS}" \ - && make install \ - && cd .. \ - && rm -f cmake-$CMAKE_VERSION.tar.gz \ - || exit 1 - printf " - CMAKE successfully installed @ ${CMAKE} \\n" -else - printf " - CMAKE found @ ${CMAKE}.\\n" -fi -if [ $? -ne 0 ]; then exit -1; fi + printf "\\nChecking for installed dependencies...\\n" + for (( i=0; i<${#DEP_ARRAY[@]}; i++ )); do + pkg=$( dpkg -s "${DEP_ARRAY[$i]}" 2>/dev/null | grep Status | tr -s ' ' | cut -d\ -f4 ) + if [ -z "$pkg" ]; then + DEP=$DEP" ${DEP_ARRAY[$i]} " + DISPLAY="${DISPLAY}${COUNT}. ${DEP_ARRAY[$i]}\\n" + printf " - Package %s${bldred} NOT${txtrst} found!\\n" "${DEP_ARRAY[$i]}" + (( COUNT++ )) + else + printf " - Package %s found.\\n" "${DEP_ARRAY[$i]}" + continue + fi + done + if [ "${COUNT}" -gt 1 ]; then + printf "\\nThe following dependencies are required to install EOSIO:\\n" + printf "${DISPLAY}\\n\\n" + if [ $ANSWER != 1 ]; then read -p "Do you wish to install these packages? (y/n) " ANSWER; fi + case $ANSWER in + 1 | [Yy]* ) + if ! sudo apt-get -y install ${DEP}; then + printf " - APT dependency failed.\\n" + exit 1 + else + printf " - APT dependencies installed successfully.\\n" + fi + ;; + [Nn]* ) echo "User aborting installation of required dependencies, Exiting now."; exit;; + * ) echo "Please type 'y' for yes or 'n' for no."; exit;; + esac + else + printf " - No required APT dependencies to install." + fi -printf "\\n" + printf "\\n" + printf "Checking CMAKE installation...\\n" + if [ ! -e $CMAKE ]; then + printf "Installing CMAKE...\\n" + curl -LO https://cmake.org/files/v$CMAKE_VERSION_MAJOR.$CMAKE_VERSION_MINOR/cmake-$CMAKE_VERSION.tar.gz \ + && tar -xzf cmake-$CMAKE_VERSION.tar.gz \ + && cd cmake-$CMAKE_VERSION \ + && ./bootstrap --prefix=$HOME \ + && make -j"${JOBS}" \ + && make install \ + && cd .. \ + && rm -f cmake-$CMAKE_VERSION.tar.gz \ + || exit 1 + printf " - CMAKE successfully installed @ ${CMAKE} \\n" + else + printf " - CMAKE found @ ${CMAKE}.\\n" + fi + if [ $? -ne 0 ]; then exit -1; fi -printf "Checking Boost library (${BOOST_VERSION}) installation...\\n" -BOOSTVERSION=$( grep "#define BOOST_VERSION" "$HOME/opt/boost/include/boost/version.hpp" 2>/dev/null | tail -1 | tr -s ' ' | cut -d\ -f3 ) -if [ "${BOOSTVERSION}" != "${BOOST_VERSION_MAJOR}0${BOOST_VERSION_MINOR}0${BOOST_VERSION_PATCH}" ]; then - printf "Installing Boost library...\\n" - curl -LO https://dl.bintray.com/boostorg/release/${BOOST_VERSION_MAJOR}.${BOOST_VERSION_MINOR}.${BOOST_VERSION_PATCH}/source/boost_$BOOST_VERSION.tar.bz2 \ - && tar -xjf boost_$BOOST_VERSION.tar.bz2 \ - && cd $BOOST_ROOT \ - && ./bootstrap.sh --prefix=$BOOST_ROOT \ - && ./b2 -q -j"${JOBS}" install \ - && cd .. \ - && rm -f boost_$BOOST_VERSION.tar.bz2 \ - && rm -rf $BOOST_LINK_LOCATION \ - && mkdir $BOOST_LINK_LOCATION \ - && cp -r $BOOST_ROOT/lib $BOOST_LINK_LOCATION/ \ - && cp -r $BOOST_ROOT/include $BOOST_LINK_LOCATION/ \ - || exit 1 - printf " - Boost library successfully installed @ ${BOOST_ROOT} (Copied to ${BOOST_LINK_LOCATION}).\\n" -else - printf " - Boost library found with correct version @ ${BOOST_ROOT} (Copied to ${BOOST_LINK_LOCATION}).\\n" -fi -if [ $? -ne 0 ]; then exit -1; fi + printf "\\n" + printf "Checking Boost library (${BOOST_VERSION}) installation...\\n" + BOOSTVERSION=$( grep "#define BOOST_VERSION" "$HOME/opt/boost/include/boost/version.hpp" 2>/dev/null | tail -1 | tr -s ' ' | cut -d\ -f3 ) + if [ "${BOOSTVERSION}" != "${BOOST_VERSION_MAJOR}0${BOOST_VERSION_MINOR}0${BOOST_VERSION_PATCH}" ]; then + printf "Installing Boost library...\\n" + curl -LO https://dl.bintray.com/boostorg/release/${BOOST_VERSION_MAJOR}.${BOOST_VERSION_MINOR}.${BOOST_VERSION_PATCH}/source/boost_$BOOST_VERSION.tar.bz2 \ + && tar -xjf boost_$BOOST_VERSION.tar.bz2 \ + && cd $BOOST_SRC \ + && ./bootstrap.sh --prefix=$BOOST_ROOT \ + && ./b2 -q -j"${JOBS}" --with-iostreams --with-date_time --with-filesystem --with-system --with-program_options --with-chrono --with-test install \ + && cd .. \ + && rm -f boost_$BOOST_VERSION.tar.bz2 \ + && rm -rf $BOOST_SRC \ + || exit 1 + printf " - Boost library successfully installed @ ${BOOST_ROOT} (Copied to ${BOOST_LINK_LOCATION}).\\n" + else + printf " - Boost library found with correct version @ ${BOOST_ROOT} (Copied to ${BOOST_LINK_LOCATION}).\\n" + fi + if [ $? -ne 0 ]; then exit -1; fi -printf "\\n" + printf "\\n" + if [ $BUILDTOOLSONLY == 0 ]; then + printf "Checking MongoDB installation...\\n" + if [ ! -d $MONGODB_ROOT ]; then + printf "Installing MongoDB into ${MONGODB_ROOT}...\\n" + curl -OL http://downloads.mongodb.org/linux/mongodb-linux-x86_64-ubuntu$OS_MAJ$OS_MIN-$MONGODB_VERSION.tgz \ + && tar -xzf mongodb-linux-x86_64-ubuntu$OS_MAJ$OS_MIN-$MONGODB_VERSION.tgz \ + && mv $SRC_LOCATION/mongodb-linux-x86_64-ubuntu$OS_MAJ$OS_MIN-$MONGODB_VERSION $MONGODB_ROOT \ + && touch $MONGODB_LOG_LOCATION/mongod.log \ + && rm -f mongodb-linux-x86_64-ubuntu$OS_MAJ$OS_MIN-$MONGODB_VERSION.tgz \ + && cp -f $REPO_ROOT/scripts/mongod.conf $MONGODB_CONF \ + && mkdir -p $MONGODB_DATA_LOCATION \ + && rm -rf $MONGODB_LINK_LOCATION \ + && rm -rf $BIN_LOCATION/mongod \ + && ln -s $MONGODB_ROOT $MONGODB_LINK_LOCATION \ + && ln -s $MONGODB_LINK_LOCATION/bin/mongod $BIN_LOCATION/mongod \ + || exit 1 + printf " - MongoDB successfully installed @ ${MONGODB_ROOT} (Symlinked to ${MONGODB_LINK_LOCATION}).\\n" + else + printf " - MongoDB found with correct version @ ${MONGODB_ROOT} (Symlinked to ${MONGODB_LINK_LOCATION}).\\n" + fi + if [ $? -ne 0 ]; then exit -1; fi + fi -printf "Checking MongoDB installation...\\n" -if [ ! -d $MONGODB_ROOT ]; then - printf "Installing MongoDB into ${MONGODB_ROOT}...\\n" - curl -OL http://downloads.mongodb.org/linux/mongodb-linux-x86_64-ubuntu$OS_MAJ$OS_MIN-$MONGODB_VERSION.tgz \ - && tar -xzf mongodb-linux-x86_64-ubuntu$OS_MAJ$OS_MIN-$MONGODB_VERSION.tgz \ - && mv $SRC_LOCATION/mongodb-linux-x86_64-ubuntu$OS_MAJ$OS_MIN-$MONGODB_VERSION $MONGODB_ROOT \ - && touch $MONGODB_LOG_LOCATION/mongod.log \ - && rm -f mongodb-linux-x86_64-ubuntu$OS_MAJ$OS_MIN-$MONGODB_VERSION.tgz \ - && cp -f $REPO_ROOT/scripts/mongod.conf $MONGODB_CONF \ - && mkdir -p $MONGODB_DATA_LOCATION \ - && rm -rf $MONGODB_LINK_LOCATION \ - && rm -rf $BIN_LOCATION/mongod \ - && ln -s $MONGODB_ROOT $MONGODB_LINK_LOCATION \ - && ln -s $MONGODB_LINK_LOCATION/bin/mongod $BIN_LOCATION/mongod \ - || exit 1 - printf " - MongoDB successfully installed @ ${MONGODB_ROOT} (Symlinked to ${MONGODB_LINK_LOCATION}).\\n" -else - printf " - MongoDB found with correct version @ ${MONGODB_ROOT} (Symlinked to ${MONGODB_LINK_LOCATION}).\\n" -fi -if [ $? -ne 0 ]; then exit -1; fi -printf "Checking MongoDB C driver installation...\\n" -if [ ! -d $MONGO_C_DRIVER_ROOT ]; then - printf "Installing MongoDB C driver...\\n" - curl -LO https://github.com/mongodb/mongo-c-driver/releases/download/$MONGO_C_DRIVER_VERSION/mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \ - && tar -xzf mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \ - && cd mongo-c-driver-$MONGO_C_DRIVER_VERSION \ - && mkdir -p cmake-build \ - && cd cmake-build \ - && $CMAKE -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME -DENABLE_BSON=ON -DENABLE_SSL=OPENSSL -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_STATIC=ON .. \ - && make -j"${JOBS}" \ - && make install \ - && cd ../.. \ - && rm mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \ - || exit 1 - printf " - MongoDB C driver successfully installed @ ${MONGO_C_DRIVER_ROOT}.\\n" -else - printf " - MongoDB C driver found with correct version @ ${MONGO_C_DRIVER_ROOT}.\\n" -fi -if [ $? -ne 0 ]; then exit -1; fi -printf "Checking MongoDB C++ driver installation...\\n" -if [ ! -d $MONGO_CXX_DRIVER_ROOT ]; then - printf "Installing MongoDB C++ driver...\\n" - curl -L https://github.com/mongodb/mongo-cxx-driver/archive/r$MONGO_CXX_DRIVER_VERSION.tar.gz -o mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \ - && tar -xzf mongo-cxx-driver-r${MONGO_CXX_DRIVER_VERSION}.tar.gz \ - && cd mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION/build \ - && $CMAKE -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME .. \ - && make -j"${JOBS}" VERBOSE=1 \ - && make install \ - && cd ../.. \ - && rm -f mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \ - || exit 1 - printf " - MongoDB C++ driver successfully installed @ ${MONGO_CXX_DRIVER_ROOT}.\\n" -else - printf " - MongoDB C++ driver found with correct version @ ${MONGO_CXX_DRIVER_ROOT}.\\n" -fi -if [ $? -ne 0 ]; then exit -1; fi + printf "Checking MongoDB C driver installation...\\n" + if [ ! -d $MONGO_C_DRIVER_ROOT ]; then + printf "Installing MongoDB C driver...\\n" + curl -LO https://github.com/mongodb/mongo-c-driver/releases/download/$MONGO_C_DRIVER_VERSION/mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \ + && tar -xzf mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \ + && cd mongo-c-driver-$MONGO_C_DRIVER_VERSION \ + && mkdir -p cmake-build \ + && cd cmake-build \ + && $CMAKE -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME -DENABLE_BSON=ON -DENABLE_SSL=OPENSSL -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_STATIC=ON .. \ + && make -j"${JOBS}" \ + && make install \ + && cd ../.. \ + && rm mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \ + || exit 1 + printf " - MongoDB C driver successfully installed @ ${MONGO_C_DRIVER_ROOT}.\\n" + else + printf " - MongoDB C driver found with correct version @ ${MONGO_C_DRIVER_ROOT}.\\n" + fi + if [ $? -ne 0 ]; then exit -1; fi + printf "Checking MongoDB C++ driver installation...\\n" + if [ ! -d $MONGO_CXX_DRIVER_ROOT ]; then + printf "Installing MongoDB C++ driver...\\n" + curl -L https://github.com/mongodb/mongo-cxx-driver/archive/r$MONGO_CXX_DRIVER_VERSION.tar.gz -o mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \ + && tar -xzf mongo-cxx-driver-r${MONGO_CXX_DRIVER_VERSION}.tar.gz \ + && cd mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION/build \ + && $CMAKE -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME .. \ + && make -j"${JOBS}" VERBOSE=1 \ + && make install \ + && cd ../.. \ + && rm -f mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \ + || exit 1 + printf " - MongoDB C++ driver successfully installed @ ${MONGO_CXX_DRIVER_ROOT}.\\n" + else + printf " - MongoDB C++ driver found with correct version @ ${MONGO_CXX_DRIVER_ROOT}.\\n" + fi + if [ $? -ne 0 ]; then exit -1; fi -printf "\\n" + printf "\\n" + printf "Checking LLVM 4 support...\\n" + if [ ! -d $LLVM_ROOT ]; then + ln -s /usr/lib/llvm-4.0 $LLVM_ROOT \ + || exit 1 + printf " - LLVM successfully linked from /usr/lib/llvm-4.0 to ${LLVM_ROOT}\\n" + else + printf " - LLVM found @ ${LLVM_ROOT}.\\n" + fi + if [ $? -ne 0 ]; then exit -1; fi -printf "Checking LLVM 4 support...\\n" -if [ ! -d $LLVM_ROOT ]; then - ln -s /usr/lib/llvm-4.0 $LLVM_ROOT \ - || exit 1 - printf " - LLVM successfully linked from /usr/lib/llvm-4.0 to ${LLVM_ROOT}\\n" -else - printf " - LLVM found @ ${LLVM_ROOT}.\\n" + cd .. + printf "\\n" fi -if [ $? -ne 0 ]; then exit -1; fi - - -cd .. -printf "\\n" function print_instructions() { - return 0 + return 0 } -fi