diff --git a/scripts/install_dependency_ubuntu2404.sh b/scripts/install_dependency_ubuntu2404.sh index 8d85ab81..b69a54e3 100755 --- a/scripts/install_dependency_ubuntu2404.sh +++ b/scripts/install_dependency_ubuntu2404.sh @@ -16,6 +16,16 @@ kernel_ge() { (( major > need_major || (major == need_major && minor >= need_minor) )) } +# arg 1: Library name (for display) +# arg 2: Detection command (to check whether the core header file or library file exists) +is_installed() { + if eval "$2" >/dev/null 2>&1; then + echo "--- [SKIP] $1 is already installed. ---" + return 0 + fi + return 1 +} + if ! kernel_ge 6 6; then echo "Kernel $(uname -r) < 6.6, exit." >&2 exit 1 @@ -52,22 +62,27 @@ DEBIAN_FRONTEND=noninteractive sudo apt-get install -y --no-install-recommends \ libjsoncpp-dev libleveldb-dev libsnappy-dev zlib1g-dev lcov # Install glog -git clone https://github.com/eloqdata/glog.git glog -cd glog -cmake -S . -B build -G "Unix Makefiles" -cmake --build build -j$(nproc) -sudo cmake --build build --target install -cd ../ && rm -rf glog +if ! is_installed "glog" "ls /usr/local/lib/libglog.so"; then + git clone https://github.com/eloqdata/glog.git glog + cd glog + cmake -S . -B build -G "Unix Makefiles" + cmake --build build -j$(nproc) + sudo cmake --build build --target install + cd ../ && rm -rf glog +fi # Install liburing -git clone https://github.com/axboe/liburing.git liburing -cd liburing -git checkout tags/liburing-2.6 -./configure --cc=gcc --cxx=g++ -make -j$(nproc) && sudo make install -cd .. && rm -rf liburing +if ! is_installed "liburing" "ls /usr/lib/liburing.so.2.6"; then + git clone https://github.com/axboe/liburing.git liburing + cd liburing + git checkout tags/liburing-2.6 + ./configure --cc=gcc --cxx=g++ + make -j$(nproc) && sudo make install + cd .. && rm -rf liburing +fi # Install brpc +if ! is_installed "brpc" "ls /usr/lib/libbrpc.so"; then git clone https://github.com/eloqdata/brpc.git brpc cd brpc mkdir build && cd build @@ -79,35 +94,42 @@ cmake --build . -j$(nproc) sudo cp -r ./output/include/* /usr/include/ sudo cp ./output/lib/* /usr/lib/ cd ../../ && rm -rf brpc +fi # Install AWSSDK -git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp.git aws -cd aws -git checkout tags/1.11.446 -mkdir bld && cd bld -cmake .. \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DCMAKE_INSTALL_PREFIX=./output/ \ - -DENABLE_TESTING=OFF \ - -DBUILD_SHARED_LIBS=ON \ - -DFORCE_SHARED_CRT=OFF \ - -DBUILD_ONLY="s3" -cmake --build . --config RelWithDebInfo -j$(nproc) -cmake --install . --config RelWithDebInfo -sudo cp -r ./output/include/* /usr/include/ -sudo cp -r ./output/lib/* /usr/lib/ -cd ../../ && rm -rf aws +AWS_SDK_CHECK_CMD="grep -q 'AWS_SDK_VERSION_MAJOR 1' /usr/include/aws/core/VersionConfig.h 2>/dev/null && \ + grep -q 'AWS_SDK_VERSION_MINOR 11' /usr/include/aws/core/VersionConfig.h 2>/dev/null && \ + grep -q 'AWS_SDK_VERSION_PATCH 446' /usr/include/aws/core/VersionConfig.h 2>/dev/null" +if ! is_installed "AWS SDK (S3)" "$AWS_SDK_CHECK_CMD"; then + git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp.git aws + cd aws + git checkout tags/1.11.446 + mkdir bld && cd bld + cmake .. \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCMAKE_INSTALL_PREFIX=./output/ \ + -DENABLE_TESTING=OFF \ + -DBUILD_SHARED_LIBS=ON \ + -DFORCE_SHARED_CRT=OFF \ + -DBUILD_ONLY="s3" + cmake --build . --config RelWithDebInfo -j$(nproc) + cmake --install . --config RelWithDebInfo + sudo cp -r ./output/include/* /usr/include/ + sudo cp -r ./output/lib/* /usr/lib/ + cd ../../ && rm -rf aws +fi # Install Catch2 -git clone -b v3.3.2 https://github.com/catchorg/Catch2.git -cd Catch2 && mkdir bld && cd bld -cmake .. \ - -DCMAKE_INSTALL_PREFIX=/usr/ \ - -DCATCH_BUILD_EXAMPLES=OFF \ - -DBUILD_TESTING=OFF -cmake --build . -j4 -sudo cmake --install . -cd ../../ && rm -rf Catch2 - +if ! is_installed "Catch2" "pkg-config --exact-version=3.3.2 catch2-with-main"; then + git clone -b v3.3.2 https://github.com/catchorg/Catch2.git + cd Catch2 && mkdir bld && cd bld + cmake .. \ + -DCMAKE_INSTALL_PREFIX=/usr/ \ + -DCATCH_BUILD_EXAMPLES=OFF \ + -DBUILD_TESTING=OFF + cmake --build . -j4 + sudo cmake --install . + cd ../../ && rm -rf Catch2 +fi echo "All dependencies have been installed successfully!"