eosio_build_centos.sh 실행 프로세스

77430 단어
먼저 시스템 정보를 인쇄합니다. 이 정보는 eosiobuild.sh에서 export를 통해 환경 변수에 설정되었습니다. 위에서 아래로 시스템 이름, 시스템 버전, CPU 코어 수, 메모리, 디스크 총 공간, 디스크 사용 가능한 공간입니다.
echo "OS name: ${NAME}"
echo "OS Version: ${VERSION_ID}"
echo "CPU cores: ${CPU_CORES}"
echo "Physical Memory: ${MEM_GIG}G"
echo "Disk space total: ${DISK_TOTAL}G"
echo "Disk space available: ${DISK_AVAIL}G"

다음은 시스템 설정 요구:centos 버전은 7 이상이어야 하고 메모리는 7G 미만이어야 하며 디스크 공간은 5G 미만이어야 한다
( [[ $NAME == "CentOS Linux" ]] && [[ "$(echo ${VERSION} | sed 's/ .*//g')" < 7 ]] ) && echo " - You must be running Centos 7 or higher to install EOSIO." && exit 1

[[ $MEM_GIG -lt 7 ]] && echo "Your system must have 7 or more Gigabytes of physical memory installed." && exit 1
[[ "${DISK_AVAIL}" -lt "${DISK_MIN}" ]] && echo " - You must have at least ${DISK_MIN}GB of available storage to install EOSIO." && exit 1

echo ""

다음은 ensure-scl 방법을 실행하는 방법입니다. 이 방법 코드는 다음과 같습니다.
 1 function ensure-scl() {
 2     echo "${COLOR_CYAN}[Ensuring installation of Centos Software Collections Repository]${COLOR_NC}" # Needed for rh-python36
 3     SCL=$( rpm -qa | grep -E 'centos-release-scl-[0-9].*' || true )
 4     if [[ -z "${SCL}" ]]; then
 5         while true; do
 6             [[ $NONINTERACTIVE == false ]] && read -p "${COLOR_YELLOW}Do you wish to install and enable the Centos Software Collections Repository? (y/n)?${COLOR_NC} " PROCEED
 7             echo ""
 8             case $PROCEED in
 9                 "" ) echo "What would you like to do?";;
10                 0 | true | [Yy]* ) install-package centos-release-scl "--enablerepo=extras"; break;;
11                 1 | false | [Nn]* ) echo " - User aborted installation of required Centos Software Collections Repository."; exit 1;;
12                 * ) echo "Please type 'y' for yes or 'n' for no.";;
13             esac
14         done
15     else
16         echo " - ${SCL} found."
17     fi
18 }

세 번째 줄을 보면 이 줄은centos-release-scl 시스템 소프트웨어가 설치되어 있는지 검증한다.설치하면 scl 이름을 되돌려줍니다. 그렇지 않으면 비어 있습니다.
4행은 scl에 대해 판단하고 설치하지 않으면 설치를 알려주고 그 다음에 10행으로 넘어가 설치를 진행한다.
그래서 이 방법은centos의 scl 파일이 반드시 존재해야 한다는 것을 확보하기 위해서입니다.centos-release-cl의 역할에 관하여 CentOS에서 소프트웨어 집합을 어떻게 사용하는지 보십시오. 여기에 메모를 간단하게 소개합니다.
SCL (소프트웨어 집합) 은 전체 시스템의 설치 패키지에 영향을 주지 않고 같은 운영체제에 여러 버전의 소프트웨어를 설치하고 사용할 수 있게 한다.
SCL의 창설은 RHEL/CentOS 사용자에게 편리하고 안전하게 응용 프로그램과 실행할 때 환경의 여러 버전(또는 업데이트될 수 있는) 버전을 설치하고 사용하는 방식을 제공하며 시스템을 어지럽히지 않도록 하기 위한 것이다.
다음에 ensure-devtoolset 메서드를 실행하고 메서드 소스 코드를 다음과 같이 변경합니다.
function ensure-devtoolset() {
    echo "${COLOR_CYAN}[Ensuring installation of devtoolset-8]${COLOR_NC}"
    DEVTOOLSET=$( rpm -qa | grep -E 'devtoolset-8-[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;;
                * ) echo "Please type 'y' for yes or 'n' for no.";;
            esac
        done
    else
        echo " - ${DEVTOOLSET} found."
    fi
}

그 코드 기능은 전체적으로 ensure-scl와 거의 같고 devtoolset-8 도구 모음을 설치하는 것으로 바뀔 뿐입니다. devtoolset-8 도구 모음 기능과 관련하여 참고: Developer Toolset 8, 그 주요 기능은
CentOS 또는 Red Hat Enterprise Linux 플랫폼에서 작업하는 개발자를 위해 설계되었습니다.그것은 최신 버전의 GNU 컴파일러 집합, GNU 디버거 및 기타 개발, 디버깅, 성능 감시 도구를 제공한다.
다음에 devtoolset-8 도구 모음을 사용합니다. 원본 코드는 다음과 같습니다.
if [[ -d /opt/rh/devtoolset-8 ]]; then
    echo "${COLOR_CYAN}[Enabling Centos devtoolset-8 (so we can use GCC 8)]${COLOR_NC}"
    execute-always source /opt/rh/devtoolset-8/enable
    echo " - ${COLOR_GREEN}Centos devtoolset-8 successfully enabled!${COLOR_NC}"
fi

다음 방법은 비교적 복잡하다. 원본 코드는 다음과 같다.
# Ensure packages exist
ensure-yum-packages "${REPO_ROOT}/scripts/eosio_build_centos7_deps"

여기에 두 가지 내용이 있는데 그 중에서 ensure-yum-packages는 의존 패키지가 존재하는지 확인하고 존재하지 않는 의존 패키지를 설치하는 과정이다. 원본 코드는 다음과 같다.
function ensure-yum-packages() {
# ( [[
-z "${1}" ]] || [[ ! -f "${1}" ]] ) && echo "\$1 must be the location of your dependency file!" && exit 1 #
DEPS_FILE
="${TEMP_DIR}/$(basename ${1})" # Create temp file so we can add to it cat $1 > $DEPS_FILE
# , DEPS_FILE
if [[ ! -z "${2}" ]]; then # Handle EXTRA_DEPS passed in and add them to temp DEPS_FILE printf "
" >> $DEPS_FILE # Avoid needing a new line at the end of deps files OLDIFS="$IFS"; IFS=$'' _2=("$(echo $2 | sed 's/-qa /-qa
/g')
") for ((i = 0; i < ${#_2[@]}; i++)); do echo "${_2[$i]}
" | sed 's/-qa\
/-qa/g
' >> $DEPS_FILE; done fi

# yum while true; do [[ $NONINTERACTIVE == false ]] && printf "${COLOR_YELLOW}Do you wish to update YUM repositories? (y/n)?${COLOR_NC}" && read -p " " PROCEED echo "" case $PROCEED in "" ) echo "What would you like to do?";; 0 | true | [Yy]* ) execute eval $( [[ $CURRENT_USER == "root" ]] || echo $SUDO_LOCATION -E ) $YUM -y update; break;; 1 | false | [Nn]* ) echo " - Proceeding without update!"; break;; * ) echo "Please type 'y' for yes or 'n' for no.";; esac done echo "${COLOR_CYAN}[Ensuring package dependencies]${COLOR_NC}" OLDIFS="$IFS"; IFS=$',' # || [[ -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}ok${COLOR_NC}" else DEPS=$DEPS"${testee} " echo " - ${testee} ${COLOR_RED}NOT${COLOR_NC} found!" (( COUNT+=1 )) fi done < $DEPS_FILE IFS=$OLDIFS OLDIFS="$IFS"; IFS=$' ' echo "" if [[ $COUNT > 0 ]]; then while true; do [[ $NONINTERACTIVE == false ]] && printf "${COLOR_YELLOW}Do you wish to install missing dependencies? (y/n)?${COLOR_NC}" && read -p " " PROCEED echo "" case $PROCEED in "" ) echo "What would you like to do?";; 0 | true | [Yy]* ) for DEP in $DEPS; do

# install-package $DEP done break;; 1 | false | [Nn]* ) echo " ${COLOR_RED}- User aborted installation of required dependencies.${COLOR_NC}"; exit;; * ) echo "Please type 'y' for yes or 'n' for no.";; esac done echo "" else echo "${COLOR_GREEN} - No required package dependencies to install.${COLOR_NC}" echo "" fi IFS=$OLDIFS }

설치해야 하는 업데이트 패키지는 ${REPO ROOT}/scripts/eosiobuild_centos7_deps의 내용은 다음과 같습니다.
git,rpm -qa
autoconf,rpm -qa
automake,rpm -qa
libtool,rpm -qa
make,rpm -qa
bzip2,rpm -qa
doxygen,rpm -qa
graphviz,rpm -qa
bzip2-devel,rpm -qa
openssl-devel,rpm -qa
gmp-devel,rpm -qa
ocaml,rpm -qa
libicu-devel,rpm -qa
python,rpm -qa
python-devel,rpm -qa
rh-python36,rpm -qa
gettext-devel,rpm -qa
file,rpm -qa
libusbx-devel,rpm -qa
libcurl-devel,rpm -qa
patch,rpm -qa

python 설치 확인 3.버전 6, rh-python36
export PYTHON3PATH="/opt/rh/rh-python36"
if $DRYRUN || [ -d $PYTHON3PATH ]; then
    echo "${COLOR_CYAN}[Enabling python36]${COLOR_NC}"
    execute source $PYTHON3PATH/enable
    echo " ${COLOR_GREEN}- Python36 successfully enabled!${COLOR_NC}"
    echo ""
fi

다음은 기본 소프트웨어 설치
# Handle clang/compiler
ensure-compiler
# CMAKE Installation
ensure-cmake
# CLANG Installation
build-clang
# LLVM Installation
ensure-llvm
# BOOST Installation
ensure-boost

ensure-compiler 소스는 다음과 같습니다.
 1 function ensure-compiler() {
 2     # Support build-essentials on ubuntu
 3     if [[ $NAME == "CentOS Linux" ]] || [[ $VERSION_ID == "16.04" ]] || ( $PIN_COMPILER && [[ $VERSION_ID == "18.04" ]] ); then
 4         export CXX=${CXX:-'g++'}
 5         export CC=${CC:-'gcc'}
 6     fi
 7     export CXX=${CXX:-'clang++'}
 8     export CC=${CC:-'clang'}
 9     if $PIN_COMPILER || [[ -f $CLANG_ROOT/bin/clang++ ]]; then
10         export PIN_COMPILER=true
11         export BUILD_CLANG=true
12         export CPP_COMP=$CLANG_ROOT/bin/clang++
13         export CC_COMP=$CLANG_ROOT/bin/clang
14         export PATH=$CLANG_ROOT/bin:$PATH
15     elif [[ $PIN_COMPILER == false ]]; then
16         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 )
17         # readlink on mac differs from linux readlink (mac doesn't have -f)
18         [[ $ARCH == "Linux" ]] && READLINK_COMMAND="readlink -f" || READLINK_COMMAND="readlink"
19         COMPILER_TYPE=$( eval $READLINK_COMMAND $(which $CXX) || true )
20         if [[ $CXX =~ "clang" ]] || [[ $COMPILER_TYPE =~ "clang" ]]; then
21             if [[ $ARCH == "Darwin" ]]; then
22                 ### Check for apple clang version 10 or higher
23                 [[ $( $(which $CXX) --version | cut -d ' ' -f 4 | cut -d '.' -f 1 | head -n 1 ) -lt 10 ]] && export NO_CPP17=true
24             else
25                 if [[ $( $(which $CXX) --version | cut -d ' ' -f 3 | head -n 1 | cut -d '.' -f1) =~ ^[0-9]+$ ]]; then # Check if the version message cut returns an integer
26                     [[ $( $(which $CXX) --version | cut -d ' ' -f 3 | head -n 1 | cut -d '.' -f1) < 6 ]] && export NO_CPP17=true
27                 elif [[ $(clang --version | cut -d ' ' -f 4 | head -n 1 | cut -d '.' -f1) =~ ^[0-9]+$ ]]; then # Check if the version message cut returns an integer
28                     [[ $( $(which $CXX) --version | cut -d ' ' -f 4 | cut -d '.' -f 1 | head -n 1 ) < 6 ]] && export NO_CPP17=true
29                 fi
30             fi
31         else
32             ## Check for c++ version 7 or higher
33             [[ $( $(which $CXX) -dumpversion | cut -d '.' -f 1 ) -lt 7 ]] && export NO_CPP17=true
34             if [[ $NO_CPP17 == false ]]; then # https://github.com/EOSIO/eos/issues/7402
35                 while true; do
36                     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}"
37                     [[ $NONINTERACTIVE == false ]] && printf "${COLOR_YELLOW}Do you wish to proceed anyway? (y/n)?${COLOR_NC}" && read -p " " PROCEED
38                     case $PROCEED in
39                         "" ) echo "What would you like to do?";;
40                         0 | true | [Yy]* ) break;;
41                         1 | false | [Nn]* ) exit 1;;
42                         * ) echo "Please type 'y' for yes or 'n' for no.";;
43                     esac
44                 done
45             fi
46         fi
47     fi
48     if $NO_CPP17; then
49         while true; do
50             echo "${COLOR_YELLOW}Unable to find C++17 support in ${CXX}!${COLOR_NC}"
51             echo "If you already have a C++17 compiler installed or would like to install your own, export CXX to point to the compiler of your choosing."
52             [[ $NONINTERACTIVE == false ]] && printf "${COLOR_YELLOW}Do you wish to download and build C++17? (y/n)?${COLOR_NC}" && read -p " " PROCEED
53             case $PROCEED in
54                 "" ) echo "What would you like to do?";;
55                 0 | true | [Yy]* )
56                     export PIN_COMPILER=true
57                     export BUILD_CLANG=true
58                     export CPP_COMP=$CLANG_ROOT/bin/clang++
59                     export CC_COMP=$CLANG_ROOT/bin/clang
60                     export PATH=$CLANG_ROOT/bin:$PATH
61                 break;;
62                 1 | false | [Nn]* ) echo "${COLOR_RED} - User aborted C++17 installation!${COLOR_NC}"; exit 1;;
63                 * ) echo "Please type 'y' for yes or 'n' for no.";;
64             esac
65         done
66     fi
67     $BUILD_CLANG && export PINNED_TOOLCHAIN="-DCMAKE_TOOLCHAIN_FILE='${BUILD_DIR}/pinned_toolchain.cmake'"
68     echo ""
69 }

이 방법은 어떻게 보면 정말 많고 분석하기도 어렵지만 사실 핵심 내용은 세 가지이다.
1. clang이 설치되었는지 확인하고 설치 버전이 10+이어야 합니다
2.버전 7 이상에 gcc 설치
3. c++ 17 호환
그 다음은 ensure-cmake입니다. 원본은 다음과 같습니다.
function ensure-cmake() {
    echo "${COLOR_CYAN}[Ensuring CMAKE installation]${COLOR_NC}"
    if [[ ! -e "${CMAKE}" ]]; then
        execute bash -c "cd $SRC_DIR && \
        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=${EOSIO_INSTALL_DIR} \
        && make -j${JOBS} \
        && make install \
        && cd .. \
        && rm -f cmake-${CMAKE_VERSION}.tar.gz"
        [[ -z "${CMAKE}" ]] && export CMAKE="${BIN_DIR}/cmake"
        echo " - CMAKE successfully installed @ ${CMAKE}"
        echo ""
    else
        echo " - CMAKE found @ ${CMAKE}."
        echo ""
    fi
}

핵심 내용도 요구에 부합되는 cmake만 설치하고 그 다음의 ensure-llvm, ensure-boost도 거의 이렇다. 여기에 원본 코드를 붙인다.
 1 function ensure-boost() {
 2     [[ $ARCH == "Darwin" ]] && export CPATH="$(python-config --includes | awk '{print $1}' | cut -dI -f2):$CPATH" # Boost has trouble finding pyconfig.h
 3     echo "${COLOR_CYAN}[Ensuring Boost $( echo $BOOST_VERSION | sed 's/_/./g' ) library installation]${COLOR_NC}"
 4     BOOSTVERSION=$( grep "#define BOOST_VERSION" "$BOOST_ROOT/include/boost/version.hpp" 2>/dev/null | tail -1 | tr -s ' ' | cut -d\  -f3 || true )
 5     if [[ "${BOOSTVERSION}" != "${BOOST_VERSION_MAJOR}0${BOOST_VERSION_MINOR}0${BOOST_VERSION_PATCH}" ]]; then
 6         B2_FLAGS="-q -j${JOBS} --with-iostreams --with-date_time --with-filesystem --with-system --with-program_options --with-chrono --with-test install"
 7         BOOTSTRAP_FLAGS=""
 8         if [[ $ARCH == "Linux" ]] && $PIN_COMPILER; then
 9             B2_FLAGS="toolset=clang cxxflags='-stdlib=libc++ -D__STRICT_ANSI__ -nostdinc++ -I${CLANG_ROOT}/include/c++/v1' linkflags='-stdlib=libc++' link=static threading=multi --with-iostreams --with-date_time --with-filesystem --with-system --with-program_options --with-chrono --with-test -q -j${JOBS} install"
10             BOOTSTRAP_FLAGS="--with-toolset=clang"
11         fi
12         execute bash -c "cd $SRC_DIR && \
13         curl -LO https://dl.bintray.com/boostorg/release/$BOOST_VERSION_MAJOR.$BOOST_VERSION_MINOR.$BOOST_VERSION_PATCH/source/boost_$BOOST_VERSION.tar.bz2 \
14         && tar -xjf boost_$BOOST_VERSION.tar.bz2 \
15         && cd $BOOST_ROOT \
16         && ./bootstrap.sh ${BOOTSTRAP_FLAGS} --prefix=$BOOST_ROOT \
17         && ./b2 ${B2_FLAGS} \
18         && cd .. \
19         && rm -f boost_$BOOST_VERSION.tar.bz2 \
20         && rm -rf $BOOST_LINK_LOCATION"        
21         echo " - Boost library successfully installed @ ${BOOST_ROOT}"
22         echo ""
23     else
24         echo " - Boost library found with correct version @ ${BOOST_ROOT}"
25         echo ""
26     fi
27 }
28 
29 function ensure-llvm() {
30     echo "${COLOR_CYAN}[Ensuring LLVM 4 support]${COLOR_NC}"
31     if [[ ! -d $LLVM_ROOT ]]; then
32         if [[ $ARCH == "Darwin" ]]; then # Handle brew installed llvm@4
33             execute ln -s /usr/local/opt/llvm@4 $LLVM_ROOT
34             echo " - LLVM successfully linked from /usr/local/opt/llvm@4 to ${LLVM_ROOT}"
35         else
36             if $PIN_COMPILER || $BUILD_CLANG; then
37                 CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX='${LLVM_ROOT}' -DLLVM_TARGETS_TO_BUILD=host -DLLVM_BUILD_TOOLS=false -DLLVM_ENABLE_RTTI=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE='${BUILD_DIR}/pinned_toolchain.cmake' .."
38             else
39                 if [[ $NAME == "Ubuntu" ]]; then
40                     execute ln -s /usr/lib/llvm-4.0 $LLVM_ROOT
41                     echo " - LLVM successfully linked from /usr/lib/llvm-4.0 to ${LLVM_ROOT}"
42                     return 0
43                 fi
44                 CMAKE_FLAGS="-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 .."
45             fi
46             execute bash -c "cd ${OPT_DIR} \
47             && git clone --depth 1 --single-branch --branch $LLVM_VERSION https://github.com/llvm-mirror/llvm.git llvm && cd llvm \
48             && mkdir build \
49             && cd build \
50             && ${CMAKE} ${CMAKE_FLAGS} \
51             && make -j${JOBS} \
52             && make install"
53             echo " - LLVM successfully installed @ ${LLVM_ROOT}"
54             echo ""
55         fi
56     else
57         echo " - LLVM found @ ${LLVM_ROOT}."
58         echo ""
59     fi
60 }

그리고build-clang 방법을 보십시오. 원본 코드는 다음과 같습니다.
function build-clang() {
    if $BUILD_CLANG; then
        echo "${COLOR_CYAN}[Ensuring Clang support]${COLOR_NC}"
        if [[ ! -d $CLANG_ROOT ]]; then
            execute bash -c "cd ${TEMP_DIR} \
            && rm -rf clang8 \
            && git clone --single-branch --branch $PINNED_COMPILER_BRANCH https://git.llvm.org/git/llvm.git clang8 \
            && cd clang8 && git checkout $PINNED_COMPILER_LLVM_COMMIT \
            && cd tools \
            && git clone --single-branch --branch $PINNED_COMPILER_BRANCH https://git.llvm.org/git/lld.git \
            && cd lld && git checkout $PINNED_COMPILER_LLD_COMMIT && cd ../ \
            && git clone --single-branch --branch $PINNED_COMPILER_BRANCH https://git.llvm.org/git/polly.git \
            && cd polly && git checkout $PINNED_COMPILER_POLLY_COMMIT && cd ../ \
            && git clone --single-branch --branch $PINNED_COMPILER_BRANCH https://git.llvm.org/git/clang.git clang && cd clang \
            && git checkout $PINNED_COMPILER_CLANG_COMMIT \
            && patch -p2 < \"$REPO_ROOT/scripts/clang-devtoolset8-support.patch\" \
            && cd tools && mkdir extra && cd extra \
            && git clone --single-branch --branch $PINNED_COMPILER_BRANCH https://git.llvm.org/git/clang-tools-extra.git \
            && cd clang-tools-extra && git checkout $PINNED_COMPILER_CLANG_TOOLS_EXTRA_COMMIT && cd .. \
            && cd ../../../../projects \
            && git clone --single-branch --branch $PINNED_COMPILER_BRANCH https://git.llvm.org/git/libcxx.git \
            && cd libcxx && git checkout $PINNED_COMPILER_LIBCXX_COMMIT && cd ../ \
            && git clone --single-branch --branch $PINNED_COMPILER_BRANCH https://git.llvm.org/git/libcxxabi.git \
            && cd libcxxabi && git checkout $PINNED_COMPILER_LIBCXXABI_COMMIT && cd ../ \
            && git clone --single-branch --branch $PINNED_COMPILER_BRANCH https://git.llvm.org/git/libunwind.git \
            && cd libunwind && git checkout $PINNED_COMPILER_LIBUNWIND_COMMIT && cd ../ \
            && git clone --single-branch --branch $PINNED_COMPILER_BRANCH https://git.llvm.org/git/compiler-rt.git \
            && cd compiler-rt && git checkout $PINNED_COMPILER_COMPILER_RT_COMMIT && cd ../ \
            && cd ${TEMP_DIR}/clang8 \
            && mkdir build && cd build \
            && ${CMAKE} -G 'Unix Makefiles' -DCMAKE_INSTALL_PREFIX='${CLANG_ROOT}' -DLLVM_BUILD_EXTERNAL_COMPILER_RT=ON -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_ENABLE_LIBCXX=ON -DLLVM_ENABLE_RTTI=ON -DLLVM_INCLUDE_DOCS=OFF -DLLVM_OPTIMIZED_TABLEGEN=ON -DLLVM_TARGETS_TO_BUILD=all -DCMAKE_BUILD_TYPE=Release .. \
            && make -j${JOBS} \
            && make install \
            && rm -rf ${TEMP_DIR}/clang8"
            echo " - Clang 8 successfully installed @ ${CLANG_ROOT}"
            echo ""
        else
            echo " - Clang 8 found @ ${CLANG_ROOT}"
            echo ""
        fi
        export CXX=$CPP_COMP
        export CC=$CC_COMP
    fi
}

모든 설치 의존 패키지를make로 설치합니다.
위 코드에서 알 수 있듯이 eos가 의존하는 LLVM은 이미 여기에 설치되어 있다
다음은 mongo DB의 설치입니다. 소스는 다음과 같습니다.
if $INSTALL_MONGO; then

    echo "${COLOR_CYAN}[Ensuring MongoDB installation]${COLOR_NC}"
    if [[ ! -d $MONGODB_ROOT ]]; then
        execute bash -c "cd $SRC_DIR && \
        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_DIR/mongodb-linux-x86_64-amazon-$MONGODB_VERSION $MONGODB_ROOT \
        && touch $MONGODB_LOG_DIR/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_DIR \
        && rm -rf $MONGODB_LINK_DIR \
        && rm -rf $BIN_DIR/mongod \
        && ln -s $MONGODB_ROOT $MONGODB_LINK_DIR \
        && ln -s $MONGODB_LINK_DIR/bin/mongod $BIN_DIR/mongod"
        echo " - MongoDB successfully installed @ ${MONGODB_ROOT}."
    else
        echo " - MongoDB found with correct version @ ${MONGODB_ROOT}."
    fi
    echo "${COLOR_CYAN}[Ensuring MongoDB C driver installation]${COLOR_NC}"
    if [[ ! -d $MONGO_C_DRIVER_ROOT ]]; then
        execute bash -c "cd $SRC_DIR && \
        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=$EOSIO_INSTALL_DIR -DENABLE_BSON=ON -DENABLE_SSL=OPENSSL -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_STATIC=ON -DENABLE_ICU=OFF -DENABLE_SNAPPY=OFF $PINNED_TOOLCHAIN .. \
        && make -j${JOBS} \
        && make install \
        && cd ../.. \
        && rm mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz"
        echo " - MongoDB C driver successfully installed @ ${MONGO_C_DRIVER_ROOT}."
    else
        echo " - MongoDB C driver found with correct version @ ${MONGO_C_DRIVER_ROOT}."
    fi
    echo "${COLOR_CYAN}[Ensuring MongoDB CXX driver installation]${COLOR_NC}"
    if [[ ! -d $MONGO_CXX_DRIVER_ROOT ]]; then
        execute bash -c "cd $SRC_DIR && \
        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 \
        && sed -i 's/\"maxAwaitTimeMS\", count/\"maxAwaitTimeMS\", static_cast(count)/' src/mongocxx/options/change_stream.cpp \
        && sed -i 's/add_subdirectory(test)//' src/mongocxx/CMakeLists.txt src/bsoncxx/CMakeLists.txt \
        && cd build \
        && $CMAKE -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$EOSIO_INSTALL_DIR -DCMAKE_PREFIX_PATH=$EOSIO_INSTALL_DIR $PINNED_TOOLCHAIN .. \
        && make -j${JOBS} VERBOSE=1 \
        && make install \
        && cd ../.. \
        && rm -f mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz"
        echo " - MongoDB C++ driver successfully installed @ ${MONGO_CXX_DRIVER_ROOT}."
    else
        echo " - MongoDB C++ driver found with correct version @ ${MONGO_CXX_DRIVER_ROOT}."
    fi
fi

여기서는 상세한 분석을 하지 않겠습니다.전체 centos7 eos 기반의build 프로세스는 이미 다른 시스템의build 스크립트를 완성했습니다. 대체적으로 이와 같습니다. 여기서 특정한 분석을 하지 않고 다음은eosioinstall.sh의 실행 과정입니다.

좋은 웹페이지 즐겨찾기