-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #338 from fioprotocol/develop
Ubuntu 20 and 22 Upgrade (BD-4617)
- Loading branch information
Showing
5 changed files
with
370 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# CMAKE | ||
export CMAKE_BUILD_TYPE=Release | ||
export CMAKE_VERSION_MAJOR=3 | ||
export CMAKE_VERSION_MINOR=21 | ||
export CMAKE_VERSION_PATCH=7 | ||
export CMAKE_VERSION=${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}.${CMAKE_VERSION_PATCH} | ||
export CMAKE_INSTALL_DIR=${FIO_CNTRX_APTS_DIR} | ||
|
||
# FIO.CDT | ||
export CDT_VERSION_MAJOR=1 | ||
export CDT_VERSION_MINOR=5 | ||
export CDT_VERSION_PATCH=0 | ||
export CDT_VERSION=${CDT_VERSION_MAJOR}.${CDT_VERSION_MINOR}.${CDT_VERSION_PATCH} | ||
|
||
export FIO_CDT_INSTALL_DIR=${FIO_CDT_INSTALL_DIR:-/usr/local} | ||
|
||
# GENERAL | ||
export CURRENT_USER=${CURRENT_USER:-$(whoami)} | ||
export DRYRUN=${DRYRUN:-false} | ||
export VERBOSE=${VERBOSE:-false} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
export REPO_ROOT=$(realpath "${SCRIPT_DIR}") | ||
export BUILD_DIR="${REPO_ROOT}/build" | ||
|
||
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 FIO_CNTRX_VERSION_MAJOR=$(cat $REPO_ROOT/CMakeLists.txt | grep -E "^[[:blank:]]*set[[:blank:]]*\([[:blank:]]*VERSION_MAJOR" | tail -1 | sed 's/.*VERSION_MAJOR //g' | sed 's/ //g' | sed 's/"//g' | cut -d\) -f1) | ||
export FIO_CNTRX_VERSION_MINOR=$(cat $REPO_ROOT/CMakeLists.txt | grep -E "^[[:blank:]]*set[[:blank:]]*\([[:blank:]]*VERSION_MINOR" | tail -1 | sed 's/.*VERSION_MINOR //g' | sed 's/ //g' | sed 's/"//g' | cut -d\) -f1) | ||
export FIO_CNTRX_VERSION_PATCH=$(cat $REPO_ROOT/CMakeLists.txt | grep -E "^[[:blank:]]*set[[:blank:]]*\([[:blank:]]*VERSION_PATCH" | tail -1 | sed 's/.*VERSION_PATCH //g' | sed 's/ //g' | sed 's/"//g' | cut -d\) -f1) | ||
export FIO_CNTRX_VERSION_SUFFIX=$(cat $REPO_ROOT/CMakeLists.txt | grep -E "^[[:blank:]]*set[[:blank:]]*\([[:blank:]]*VERSION_SUFFIX" | tail -1 | sed 's/.*VERSION_SUFFIX //g' | sed 's/ //g' | sed 's/"//g' | cut -d\) -f1) | ||
export FIO_CNTRX_VERSION="${FIO_CNTRX_VERSION_MAJOR}.${FIO_CNTRX_VERSION_MINOR}" | ||
if [[ -z $FIO_CNTRX_VERSION_SUFFIX ]]; then | ||
export FIO_CNTRX_VERSION_FULL="${FIO_CNTRX_VERSION_MAJOR}.${FIO_CNTRX_VERSION_MINOR}.${FIO_CNTRX_VERSION_PATCH}" | ||
else | ||
export FIO_CNTRX_CNTRX_VERSION_FULL="${FIO_CNTRX_VERSION_MAJOR}.${FIO_CNTRX_VERSION_MINOR}.${FIO_CNTRX_VERSION_PATCH}-${FIO_CNTRX_VERSION_SUFFIX}" | ||
fi | ||
|
||
export TEMP_DIR="${TEMP_DIR:-${HOME}/tmp}" | ||
export FIO_CNTRX_APTS_DIR="${FIO_APTS_DIR:-${TEMP_DIR}/fio/apts}" | ||
|
||
. ./.build_vars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,165 @@ | ||
#! /bin/bash | ||
#!/usr/bin/env bash | ||
|
||
printf "\t=========== Building FIO system contracts ===========\n\n" | ||
function usage() { | ||
printf "Usage: $0 OPTION... | ||
-c DIR Directory where CMAKE install is located | ||
\\n" "$0" 1>&2 | ||
exit 1 | ||
} | ||
|
||
CLEAN=${CLEAN:-false} | ||
DEBUG=${DEBUG:-false} | ||
VERBOSE=${VERBOSE:-false} | ||
|
||
TIME_BEGIN=$(date -u +%s) | ||
if [ $# -ne 0 ]; then | ||
while getopts "a:cdhv" opt; do | ||
case "${opt}" in | ||
a) | ||
APTS_DIR=$OPTARG | ||
;; | ||
c) | ||
CLEAN=true | ||
;; | ||
d) | ||
DEBUG=true | ||
set -x | ||
;; | ||
v) | ||
VERBOSE=true | ||
;; | ||
h) | ||
usage | ||
;; | ||
?) | ||
echo "Invalid Option!" 1>&2 | ||
usage | ||
;; | ||
:) | ||
echo "Invalid Option: -${OPTARG} requires an argument." 1>&2 | ||
usage | ||
;; | ||
*) | ||
usage | ||
;; | ||
esac | ||
done | ||
fi | ||
|
||
SCRIPT_VERSION=2.10 | ||
|
||
export CURRENT_WORKING_DIR=$(pwd) # relative path support | ||
|
||
export CLEAN | ||
export DEBUG | ||
export VERBOSE | ||
|
||
# Obtain dependency versions; Must come first in the script | ||
. ./.environment | ||
|
||
# Load general helpers | ||
. ./utils.sh | ||
|
||
echo | ||
echo "FIO Contracts Build Script Version: ${SCRIPT_VERSION}" | ||
echo "FIO Contracts Version: ${FIO_CNTRX_VERSION_FULL}" | ||
echo "$(date -u)" | ||
echo "User: ${CURRENT_USER}" | ||
# echo "git head id: %s" "$( cat .git/refs/heads/master )" | ||
echo "Current branch: $(execute git rev-parse --abbrev-ref HEAD 2>/dev/null)" | ||
|
||
# Checks for Arch and OS + Support for tests setting them manually | ||
## Necessary for linux exclusion while running bats tests/bash-bats/*.sh | ||
[[ -z "${ARCH}" ]] && export ARCH=$(uname) | ||
if [[ -z "${NAME}" ]]; then | ||
if [[ $ARCH == "Linux" ]]; then | ||
[[ ! -e /etc/os-release ]] && echo "${COLOR_RED} - /etc/os-release not found! It seems you're attempting to use an unsupported Linux distribution.${COLOR_NC}" && exit 1 | ||
# Obtain OS NAME, and VERSION | ||
. /etc/os-release | ||
elif [[ $ARCH == "Darwin" ]]; then | ||
export NAME=$(sw_vers -productName) | ||
else | ||
echo " ${COLOR_RED}- FIO is not supported for your Architecture!${COLOR_NC}" && exit 1 | ||
fi | ||
set-system-vars | ||
fi | ||
|
||
echo | ||
echo "Performing OS/System Validation..." | ||
([[ $NAME == "Ubuntu" ]] && ([[ "$(echo ${VERSION_ID})" == "18.04" ]] || [[ "$(echo ${VERSION_ID})" == "20.04" ]] || [[ "$(echo ${VERSION_ID})" == "22.04" ]])) || (echo " - You must be running 18.04.x, 20.04.x, or 22.04 to build the FIO Contracts." && exit 1) | ||
|
||
# Set up the working directories for build, etc | ||
setup | ||
|
||
# CMAKE Installation | ||
# cmake may have been passed as arg to build or previously installed in local apts dir, check these and set if appropriate | ||
export CMAKE= | ||
([[ -z "${CMAKE}" ]] && [[ -d ${APTS_DIR} ]] && [[ -x ${APTS_DIR}/bin/cmake ]]) && export CMAKE=${APTS_DIR}/bin/cmake | ||
([[ -z "${CMAKE}" ]] && [[ -d ${FIO_CNTRX_APTS_DIR} ]] && [[ -x ${FIO_CNTRX_APTS_DIR}/bin/cmake ]]) && export CMAKE=${FIO_CNTRX_APTS_DIR}/bin/cmake && export APTS_DIR=${FIO_CNTRX_APTS_DIR} | ||
if [[ $ARCH == "Darwin" ]]; then | ||
([[ -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 | ||
echo "${COLOR_RED}The currently installed cmake version ($CMAKE_CURRENT_VERSION) is less than the required version ($CMAKE_REQUIRED_VERSION). Cannot proceed." | ||
exit 1 | ||
fi | ||
fi | ||
ensure-cmake | ||
[[ ! -x "${CMAKE}" ]] && echo "CMake not found! Exiting..." && exit 1 | ||
|
||
ensure-cdt | ||
if ! hash eosio-cpp 2>/dev/null; then | ||
echo "The FIO Contract Development Toolkit is not installed (not found in PATH)! Either update PATH or" | ||
echo "perform the following steps to clone, build and install the fio.cdt suite;" | ||
echo " git clone https://www.github.com/fioprotocol/fio.cdt.git" | ||
echo " cd fio.cdt" | ||
echo " git submodule update --init --recursive" | ||
echo " ./build.sh" | ||
echo " sudo ./install.sh" | ||
echo | ||
exit 1 | ||
fi | ||
|
||
echo | ||
printf "\t=========== Building FIO Contracts ===========\n\n" | ||
|
||
RED='\033[0;31m' | ||
NC='\033[0m' | ||
|
||
CORES=`getconf _NPROCESSORS_ONLN` | ||
mkdir -p build | ||
pushd build &> /dev/null | ||
cmake ../ | ||
make -j${CORES} | ||
popd &> /dev/null | ||
|
||
printf "\t=========== Copying FIO source abi ===========\n\n" | ||
cp contracts/fio.address/fio.address.abi build/contracts/fio.address/ | ||
cp contracts/fio.fee/fio.fee.abi build/contracts/fio.fee/ | ||
cp contracts/fio.request.obt/fio.request.obt.abi build/contracts/fio.request.obt/ | ||
cp contracts/fio.tpid/fio.tpid.abi build/contracts/fio.tpid/ | ||
cp contracts/fio.treasury/fio.treasury.abi build/contracts/fio.treasury/ | ||
cp contracts/fio.escrow/fio.escrow.abi build/contracts/fio.escrow/ | ||
cp contracts/fio.staking/fio.staking.abi build/contracts/fio.staking/ | ||
cp contracts/fio.oracle/fio.oracle.abi build/contracts/fio.oracle/ | ||
cp contracts/fio.perms/fio.perms.abi build/contracts/fio.perms/ | ||
pushd build | ||
|
||
${CMAKE} ../ | ||
make -j${JOBS} | ||
popd | ||
|
||
printf "\t=========== Copying FIO Contracts ABIs ===========\n\n" | ||
|
||
execute cp contracts/fio.address/fio.address.abi build/contracts/fio.address/ | ||
execute cp contracts/fio.fee/fio.fee.abi build/contracts/fio.fee/ | ||
execute cp contracts/fio.request.obt/fio.request.obt.abi build/contracts/fio.request.obt/ | ||
execute cp contracts/fio.tpid/fio.tpid.abi build/contracts/fio.tpid/ | ||
execute cp contracts/fio.treasury/fio.treasury.abi build/contracts/fio.treasury/ | ||
execute cp contracts/fio.escrow/fio.escrow.abi build/contracts/fio.escrow/ | ||
execute cp contracts/fio.staking/fio.staking.abi build/contracts/fio.staking/ | ||
execute cp contracts/fio.oracle/fio.oracle.abi build/contracts/fio.oracle/ | ||
execute cp contracts/fio.perms/fio.perms.abi build/contracts/fio.perms/ | ||
echo | ||
printf "\t=========== FIO Contracts Build Complete ===========\n\n" | ||
echo | ||
printf "${bldred}\n" | ||
printf " ___ ___ \n" | ||
printf " /\\__\\ /\\ \\ \n" | ||
printf " /:/ _/_ ___ /::\\ \\ \n" | ||
printf " /:/ /\\__\\ /\\__\\ /:/\\:\\ \\ \n" | ||
printf " /:/ /:/ / /:/__/ /:/ \\:\\ \\ \n" | ||
printf " /:/_/:/ / /::\\ \\ /:/__/ \\:\\__\\ \n" | ||
printf " \\:\\/:/ / \\/\\:\\ \\__ \\:\\ \\ /:/ / \n" | ||
printf " \\::/__/ \\:\\/\\__\\ \\:\\ /:/ / \n" | ||
printf " \\:\\ \\ \\::/ / \\:\\/:/ / \n" | ||
printf " \\:\\__\\ /:/ / \\::/ / \n" | ||
printf " \\/__/ \\/__/ \\/__/ \n\n${txtrst}" | ||
|
||
printf "\\tFor more information:\\n" | ||
printf "\\tFIO website: https://fio.net\\n" |
Oops, something went wrong.