From 169ad0d00b06b2a98c87b4409be0c8f9f3540182 Mon Sep 17 00:00:00 2001 From: gibber9809 Date: Fri, 5 Jan 2024 16:44:21 -0500 Subject: [PATCH 1/7] Make ubuntu focal env build script executable --- .../core/tools/docker-images/clp-env-base-ubuntu-focal/build.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 components/core/tools/docker-images/clp-env-base-ubuntu-focal/build.sh diff --git a/components/core/tools/docker-images/clp-env-base-ubuntu-focal/build.sh b/components/core/tools/docker-images/clp-env-base-ubuntu-focal/build.sh old mode 100644 new mode 100755 From bb7cffa9487f1649d5533cc78028123800b43ad3 Mon Sep 17 00:00:00 2001 From: gibber9809 Date: Fri, 5 Jan 2024 18:40:11 -0500 Subject: [PATCH 2/7] Add mongocxx dependency to all dev environments --- .../centos7.4/install-packages-from-source.sh | 5 ++ .../lib_install/macos-12/install-all.sh | 1 + .../core/tools/scripts/lib_install/mongoc.sh | 85 ++++++++++++++++++ .../tools/scripts/lib_install/mongocxx.sh | 88 +++++++++++++++++++ .../install-packages-from-source.sh | 2 + .../install-packages-from-source.sh | 2 + 6 files changed, 183 insertions(+) create mode 100755 components/core/tools/scripts/lib_install/mongoc.sh create mode 100755 components/core/tools/scripts/lib_install/mongocxx.sh diff --git a/components/core/tools/scripts/lib_install/centos7.4/install-packages-from-source.sh b/components/core/tools/scripts/lib_install/centos7.4/install-packages-from-source.sh index daeef06be..58d5cb38e 100755 --- a/components/core/tools/scripts/lib_install/centos7.4/install-packages-from-source.sh +++ b/components/core/tools/scripts/lib_install/centos7.4/install-packages-from-source.sh @@ -3,6 +3,9 @@ # Enable gcc 10 source /opt/rh/devtoolset-10/enable +# Enable git +source /opt/rh/rh-git227/enable + # NOTE: cmake and boost must be installed first since the remaining packages depend on them ./tools/scripts/lib_install/install-cmake.sh 3.21.2 ./tools/scripts/lib_install/install-boost.sh 1.76.0 @@ -11,6 +14,8 @@ source /opt/rh/devtoolset-10/enable ./tools/scripts/lib_install/libarchive.sh 3.5.1 ./tools/scripts/lib_install/lz4.sh 1.8.2 ./tools/scripts/lib_install/mariadb-connector-c.sh 3.2.3 +./tools/scripts/lib_install/mongoc.sh 1.24.4 +./tools/scripts/lib_install/mongocxx.sh 3.8.0 ./tools/scripts/lib_install/msgpack.sh 6.0.0 ./tools/scripts/lib_install/spdlog.sh 1.9.2 ./tools/scripts/lib_install/zstandard.sh 1.4.9 diff --git a/components/core/tools/scripts/lib_install/macos-12/install-all.sh b/components/core/tools/scripts/lib_install/macos-12/install-all.sh index 17f7a4d71..748b78958 100755 --- a/components/core/tools/scripts/lib_install/macos-12/install-all.sh +++ b/components/core/tools/scripts/lib_install/macos-12/install-all.sh @@ -9,6 +9,7 @@ brew install \ libarchive \ lz4 \ mariadb-connector-c \ + mongocxx-driver \ msgpack-cxx \ spdlog \ pkg-config \ diff --git a/components/core/tools/scripts/lib_install/mongoc.sh b/components/core/tools/scripts/lib_install/mongoc.sh new file mode 100755 index 000000000..c3d8c2056 --- /dev/null +++ b/components/core/tools/scripts/lib_install/mongoc.sh @@ -0,0 +1,85 @@ +#!/bin/bash + +# Dependencies: +# - cmake +# - curl +# - git +# - g++ +# NOTE: Dependencies should be installed outside the script to allow the script to be largely distro-agnostic + +# Exit on any error +set -e + +cUsage="Usage: ${BASH_SOURCE[0]} [ <.deb output directory>]" +if [ "$#" -lt 1 ] ; then + echo $cUsage + exit +fi +version=$1 + +package_name=libmongoc-dev +temp_dir=/tmp/${package_name}-installation +deb_output_dir=${temp_dir} +if [[ "$#" -gt 1 ]] ; then + deb_output_dir="$(readlink -f "$2")" + if [ ! -d ${deb_output_dir} ] ; then + echo "${deb_output_dir} does not exist or is not a directory" + exit + fi +fi + +# Check if already installed +set +e +dpkg -l ${package_name} | grep ${version} +installed=$? +set -e +if [ $installed -eq 0 ] ; then + # Nothing to do + exit +fi + +echo "Checking for elevated privileges..." +privileged_command_prefix="" +if [ ${EUID:-$(id -u)} -ne 0 ] ; then + sudo echo "Script can elevate privileges." + privileged_command_prefix="${privileged_command_prefix} sudo" +fi + +# Download +mkdir -p $temp_dir +cd $temp_dir +extracted_dir=${temp_dir}/mongo-c-driver-${version} +if [ ! -e ${extracted_dir} ] ; then + tar_filename=mongo-c-driver-${version}.tar.gz + if [ ! -e ${tar_filename} ] ; then + curl -fsSL https://github.com/mongodb/mongo-c-driver/releases/download/${version}/${tar_filename} -o ${tar_filename} + fi + + tar -xf ${tar_filename} +fi + +# Set up +cd ${extracted_dir} +mkdir -p build +cd build +cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF \ + -DENABLE_TESTS=OFF \ + .. + +# Check if checkinstall is installed +set +e +command -v checkinstall +checkinstall_installed=$? +set -e + +# Install +install_command_prefix="${privileged_command_prefix}" +if [ $checkinstall_installed -eq 0 ] ; then + install_command_prefix="${install_command_prefix} checkinstall --pkgname '${package_name}' --pkgversion '${version}' --provides '${package_name}' --nodoc -y --pakdir \"${deb_output_dir}\"" +fi +${install_command_prefix} cmake --build . --target install + +# Clean up +rm -rf $temp_dir diff --git a/components/core/tools/scripts/lib_install/mongocxx.sh b/components/core/tools/scripts/lib_install/mongocxx.sh new file mode 100755 index 000000000..676d57875 --- /dev/null +++ b/components/core/tools/scripts/lib_install/mongocxx.sh @@ -0,0 +1,88 @@ +#!/bin/bash + +# Dependencies: +# - cmake +# - curl +# - git +# - g++ +# NOTE: Dependencies should be installed outside the script to allow the script to be largely distro-agnostic + +# Exit on any error +set -e + +cUsage="Usage: ${BASH_SOURCE[0]} [ <.deb output directory>]" +if [ "$#" -lt 1 ] ; then + echo $cUsage + exit +fi +version=$1 + +package_name=libmongocxx-dev +temp_dir=/tmp/${package_name}-installation +deb_output_dir=${temp_dir} +if [[ "$#" -gt 1 ]] ; then + deb_output_dir="$(readlink -f "$2")" + if [ ! -d ${deb_output_dir} ] ; then + echo "${deb_output_dir} does not exist or is not a directory" + exit + fi +fi + +# Check if already installed +set +e +dpkg -l ${package_name} | grep ${version} +installed=$? +set -e +if [ $installed -eq 0 ] ; then + # Nothing to do + exit +fi + +echo "Checking for elevated privileges..." +privileged_command_prefix="" +if [ ${EUID:-$(id -u)} -ne 0 ] ; then + sudo echo "Script can elevate privileges." + privileged_command_prefix="${privileged_command_prefix} sudo" +fi + +# Download +mkdir -p $temp_dir +cd $temp_dir +extracted_dir=${temp_dir}/mongo-cxx-driver-r${version} +if [ ! -e ${extracted_dir} ] ; then + tar_filename=mongo-cxx-driver-r${version}.tar.gz + if [ ! -e ${tar_filename} ] ; then + curl -fsSL https://github.com/mongodb/mongo-cxx-driver/releases/download/r${version}/${tar_filename} -o ${tar_filename} + fi + + tar -xf ${tar_filename} +fi + +# Set up +cd ${extracted_dir}/build +# NOTE: Although the mongocxx docs indicate we should use +# '-DMONGOCXX_OVERRIDE_DEFAULT_INSTALL_PREFIX=OFF' to install to the default +# location (/usr/local) but this doesn't seem to work, so we specify +# CMAKE_INSTALL_PREFIX here +cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=/usr/local \ + -DBUILD_SHARED_AND_STATIC_LIBS=ON \ + -DENABLE_TESTS=OFF \ + .. + +# Check if checkinstall is installed +set +e +command -v checkinstall +checkinstall_installed=$? +set -e + +# Install +install_command_prefix="${privileged_command_prefix}" +if [ $checkinstall_installed -eq 0 ] ; then + install_command_prefix="${install_command_prefix} checkinstall --pkgname '${package_name}' --pkgversion '${version}' --provides '${package_name}' --nodoc -y --pakdir \"${deb_output_dir}\"" +fi +${install_command_prefix} cmake --build . --target install + +# Clean up +rm -rf $temp_dir diff --git a/components/core/tools/scripts/lib_install/ubuntu-focal/install-packages-from-source.sh b/components/core/tools/scripts/lib_install/ubuntu-focal/install-packages-from-source.sh index ccbae9230..bdfa5c97c 100755 --- a/components/core/tools/scripts/lib_install/ubuntu-focal/install-packages-from-source.sh +++ b/components/core/tools/scripts/lib_install/ubuntu-focal/install-packages-from-source.sh @@ -3,6 +3,8 @@ ./tools/scripts/lib_install/fmtlib.sh 8.0.1 ./tools/scripts/lib_install/libarchive.sh 3.5.1 ./tools/scripts/lib_install/lz4.sh 1.8.2 +./tools/scripts/lib_install/mongoc.sh 1.24.4 +./tools/scripts/lib_install/mongocxx.sh 3.8.0 ./tools/scripts/lib_install/msgpack.sh 6.0.0 ./tools/scripts/lib_install/spdlog.sh 1.9.2 ./tools/scripts/lib_install/zstandard.sh 1.4.9 diff --git a/components/core/tools/scripts/lib_install/ubuntu-jammy/install-packages-from-source.sh b/components/core/tools/scripts/lib_install/ubuntu-jammy/install-packages-from-source.sh index ccbae9230..bdfa5c97c 100755 --- a/components/core/tools/scripts/lib_install/ubuntu-jammy/install-packages-from-source.sh +++ b/components/core/tools/scripts/lib_install/ubuntu-jammy/install-packages-from-source.sh @@ -3,6 +3,8 @@ ./tools/scripts/lib_install/fmtlib.sh 8.0.1 ./tools/scripts/lib_install/libarchive.sh 3.5.1 ./tools/scripts/lib_install/lz4.sh 1.8.2 +./tools/scripts/lib_install/mongoc.sh 1.24.4 +./tools/scripts/lib_install/mongocxx.sh 3.8.0 ./tools/scripts/lib_install/msgpack.sh 6.0.0 ./tools/scripts/lib_install/spdlog.sh 1.9.2 ./tools/scripts/lib_install/zstandard.sh 1.4.9 From bf1502a55ccb8cb735b3922b3d30f3f12abb9555 Mon Sep 17 00:00:00 2001 From: gibber9809 Date: Fri, 5 Jan 2024 18:59:46 -0500 Subject: [PATCH 3/7] Fix brew install formula for mongo-cxx-driver --- .../core/tools/scripts/lib_install/macos-12/install-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/core/tools/scripts/lib_install/macos-12/install-all.sh b/components/core/tools/scripts/lib_install/macos-12/install-all.sh index 748b78958..d49b6ee7a 100755 --- a/components/core/tools/scripts/lib_install/macos-12/install-all.sh +++ b/components/core/tools/scripts/lib_install/macos-12/install-all.sh @@ -9,7 +9,7 @@ brew install \ libarchive \ lz4 \ mariadb-connector-c \ - mongocxx-driver \ + mongo-cxx-driver \ msgpack-cxx \ spdlog \ pkg-config \ From 7aac6409140c96d5dff0e92d997b89867ca980e4 Mon Sep 17 00:00:00 2001 From: gibber9809 Date: Sun, 7 Jan 2024 14:38:24 -0500 Subject: [PATCH 4/7] Address review comments --- .../core/tools/scripts/lib_install/mongoc.sh | 57 +++++++++++------ .../tools/scripts/lib_install/mongocxx.sh | 61 ++++++++++++------- 2 files changed, 78 insertions(+), 40 deletions(-) diff --git a/components/core/tools/scripts/lib_install/mongoc.sh b/components/core/tools/scripts/lib_install/mongoc.sh index c3d8c2056..ed389d3cc 100755 --- a/components/core/tools/scripts/lib_install/mongoc.sh +++ b/components/core/tools/scripts/lib_install/mongoc.sh @@ -1,25 +1,29 @@ -#!/bin/bash +#!/usr/bin/env bash # Dependencies: # - cmake # - curl # - git # - g++ -# NOTE: Dependencies should be installed outside the script to allow the script to be largely distro-agnostic +# NOTE: Dependencies should be installed outside the script to allow the script to be +# largely distro-agnostic # Exit on any error set -e +# Error on undefined variable +set -u + cUsage="Usage: ${BASH_SOURCE[0]} [ <.deb output directory>]" if [ "$#" -lt 1 ] ; then - echo $cUsage + echo "$cUsage" exit fi version=$1 package_name=libmongoc-dev -temp_dir=/tmp/${package_name}-installation -deb_output_dir=${temp_dir} +temp_dir="/tmp/${package_name}-installation" +deb_output_dir="${temp_dir}" if [[ "$#" -gt 1 ]] ; then deb_output_dir="$(readlink -f "$2")" if [ ! -d ${deb_output_dir} ] ; then @@ -42,24 +46,28 @@ echo "Checking for elevated privileges..." privileged_command_prefix="" if [ ${EUID:-$(id -u)} -ne 0 ] ; then sudo echo "Script can elevate privileges." - privileged_command_prefix="${privileged_command_prefix} sudo" + privileged_command_prefix="sudo" fi # Download -mkdir -p $temp_dir -cd $temp_dir -extracted_dir=${temp_dir}/mongo-c-driver-${version} -if [ ! -e ${extracted_dir} ] ; then - tar_filename=mongo-c-driver-${version}.tar.gz - if [ ! -e ${tar_filename} ] ; then - curl -fsSL https://github.com/mongodb/mongo-c-driver/releases/download/${version}/${tar_filename} -o ${tar_filename} +mkdir -p "$temp_dir" +cd "$temp_dir" +extracted_dir="${temp_dir}/mongo-c-driver-${version}" +if [ ! -e "${extracted_dir}" ] ; then + tar_filename="mongo-c-driver-${version}.tar.gz" + if [ ! -e "${tar_filename}" ] ; then + curl \ + -fsSL \ + "https://github.com/mongodb/mongo-c-driver/releases/download/${version}/${tar_filename}" \ + -o \ + "${tar_filename}" fi - tar -xf ${tar_filename} + tar -xf "${tar_filename}" fi # Set up -cd ${extracted_dir} +cd "${extracted_dir}" mkdir -p build cd build cmake \ @@ -75,11 +83,22 @@ checkinstall_installed=$? set -e # Install -install_command_prefix="${privileged_command_prefix}" +install_command_prefix_args=() +if ! [ -z "${privileged_command_prefix}" ]; then + install_command_prefix_args=(${privileged_command_prefix}) +fi if [ $checkinstall_installed -eq 0 ] ; then - install_command_prefix="${install_command_prefix} checkinstall --pkgname '${package_name}' --pkgversion '${version}' --provides '${package_name}' --nodoc -y --pakdir \"${deb_output_dir}\"" + install_command_prefix_args+=( \ + checkinstall \ + --pkgname "${package_name}" \ + --pkgversion "${version}" \ + --provides "${package_name}" \ + --nodoc \ + -y \ + --pakdir "${deb_output_dir}" \ + ) fi -${install_command_prefix} cmake --build . --target install +"${install_command_prefix_args[@]}" cmake --build . --target install # Clean up -rm -rf $temp_dir +rm -rf "$temp_dir" diff --git a/components/core/tools/scripts/lib_install/mongocxx.sh b/components/core/tools/scripts/lib_install/mongocxx.sh index 676d57875..25dbd3030 100755 --- a/components/core/tools/scripts/lib_install/mongocxx.sh +++ b/components/core/tools/scripts/lib_install/mongocxx.sh @@ -1,28 +1,32 @@ -#!/bin/bash +#!/usr/bin/env bash # Dependencies: # - cmake # - curl # - git # - g++ -# NOTE: Dependencies should be installed outside the script to allow the script to be largely distro-agnostic +# NOTE: Dependencies should be installed outside the script to allow the script to be +# largely distro-agnostic # Exit on any error set -e +# Error on undefined variable +set -u + cUsage="Usage: ${BASH_SOURCE[0]} [ <.deb output directory>]" if [ "$#" -lt 1 ] ; then - echo $cUsage + echo "$cUsage" exit fi version=$1 package_name=libmongocxx-dev -temp_dir=/tmp/${package_name}-installation -deb_output_dir=${temp_dir} +temp_dir="/tmp/${package_name}-installation" +deb_output_dir="${temp_dir}" if [[ "$#" -gt 1 ]] ; then deb_output_dir="$(readlink -f "$2")" - if [ ! -d ${deb_output_dir} ] ; then + if [ ! -d "${deb_output_dir}" ] ; then echo "${deb_output_dir} does not exist or is not a directory" exit fi @@ -30,7 +34,7 @@ fi # Check if already installed set +e -dpkg -l ${package_name} | grep ${version} +dpkg -l "${package_name}" | grep "${version}" installed=$? set -e if [ $installed -eq 0 ] ; then @@ -42,24 +46,28 @@ echo "Checking for elevated privileges..." privileged_command_prefix="" if [ ${EUID:-$(id -u)} -ne 0 ] ; then sudo echo "Script can elevate privileges." - privileged_command_prefix="${privileged_command_prefix} sudo" + privileged_command_prefix="sudo" fi # Download -mkdir -p $temp_dir -cd $temp_dir -extracted_dir=${temp_dir}/mongo-cxx-driver-r${version} -if [ ! -e ${extracted_dir} ] ; then - tar_filename=mongo-cxx-driver-r${version}.tar.gz - if [ ! -e ${tar_filename} ] ; then - curl -fsSL https://github.com/mongodb/mongo-cxx-driver/releases/download/r${version}/${tar_filename} -o ${tar_filename} +mkdir -p "$temp_dir" +cd "$temp_dir" +extracted_dir="${temp_dir}/mongo-cxx-driver-r${version}" +if [ ! -e "${extracted_dir}" ] ; then + tar_filename="mongo-cxx-driver-r${version}.tar.gz" + if [ ! -e "${tar_filename}" ] ; then + curl \ + -fsSL \ + "https://github.com/mongodb/mongo-cxx-driver/releases/download/r${version}/${tar_filename}" \ + -o \ + "${tar_filename}" fi - tar -xf ${tar_filename} + tar -xf "${tar_filename}" fi # Set up -cd ${extracted_dir}/build +cd "${extracted_dir}/build" # NOTE: Although the mongocxx docs indicate we should use # '-DMONGOCXX_OVERRIDE_DEFAULT_INSTALL_PREFIX=OFF' to install to the default # location (/usr/local) but this doesn't seem to work, so we specify @@ -78,11 +86,22 @@ checkinstall_installed=$? set -e # Install -install_command_prefix="${privileged_command_prefix}" +install_command_prefix_args=() +if ! [ -z "${privileged_command_prefix}" ]; then + install_command_prefix_args=(${privileged_command_prefix}) +fi if [ $checkinstall_installed -eq 0 ] ; then - install_command_prefix="${install_command_prefix} checkinstall --pkgname '${package_name}' --pkgversion '${version}' --provides '${package_name}' --nodoc -y --pakdir \"${deb_output_dir}\"" + install_command_prefix_args+=( \ + checkinstall \ + --pkgname "${package_name}" \ + --pkgversion "${version}" \ + --provides "${package_name}" \ + --nodoc \ + -y \ + --pakdir "${deb_output_dir}" \ + ) fi -${install_command_prefix} cmake --build . --target install +"${install_command_prefix_args[@]}" cmake --build . --target install # Clean up -rm -rf $temp_dir +rm -rf "$temp_dir" From e0b49ea919cc69b9988c3b45432c0b8cd5c1901a Mon Sep 17 00:00:00 2001 From: gibber9809 Date: Sun, 7 Jan 2024 14:41:27 -0500 Subject: [PATCH 5/7] Address review comments --- components/core/tools/scripts/lib_install/mongoc.sh | 8 ++------ components/core/tools/scripts/lib_install/mongocxx.sh | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/components/core/tools/scripts/lib_install/mongoc.sh b/components/core/tools/scripts/lib_install/mongoc.sh index ed389d3cc..183fb8622 100755 --- a/components/core/tools/scripts/lib_install/mongoc.sh +++ b/components/core/tools/scripts/lib_install/mongoc.sh @@ -43,10 +43,10 @@ if [ $installed -eq 0 ] ; then fi echo "Checking for elevated privileges..." -privileged_command_prefix="" +install_command_prefix_args=() if [ ${EUID:-$(id -u)} -ne 0 ] ; then sudo echo "Script can elevate privileges." - privileged_command_prefix="sudo" + install_command_prefix_args=("sudo") fi # Download @@ -83,10 +83,6 @@ checkinstall_installed=$? set -e # Install -install_command_prefix_args=() -if ! [ -z "${privileged_command_prefix}" ]; then - install_command_prefix_args=(${privileged_command_prefix}) -fi if [ $checkinstall_installed -eq 0 ] ; then install_command_prefix_args+=( \ checkinstall \ diff --git a/components/core/tools/scripts/lib_install/mongocxx.sh b/components/core/tools/scripts/lib_install/mongocxx.sh index 25dbd3030..6cfbd0946 100755 --- a/components/core/tools/scripts/lib_install/mongocxx.sh +++ b/components/core/tools/scripts/lib_install/mongocxx.sh @@ -43,10 +43,10 @@ if [ $installed -eq 0 ] ; then fi echo "Checking for elevated privileges..." -privileged_command_prefix="" +install_command_prefix_args=() if [ ${EUID:-$(id -u)} -ne 0 ] ; then sudo echo "Script can elevate privileges." - privileged_command_prefix="sudo" + install_command_prefix_args=("sudo") fi # Download @@ -86,10 +86,6 @@ checkinstall_installed=$? set -e # Install -install_command_prefix_args=() -if ! [ -z "${privileged_command_prefix}" ]; then - install_command_prefix_args=(${privileged_command_prefix}) -fi if [ $checkinstall_installed -eq 0 ] ; then install_command_prefix_args+=( \ checkinstall \ From babfee942ebc1e7f015ac2f73ed07edc016cd7eb Mon Sep 17 00:00:00 2001 From: gibber9809 Date: Sun, 7 Jan 2024 18:21:35 -0500 Subject: [PATCH 6/7] Make mongoc and mongocxx dependency builds parallel --- components/core/tools/scripts/lib_install/mongoc.sh | 2 +- components/core/tools/scripts/lib_install/mongocxx.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/core/tools/scripts/lib_install/mongoc.sh b/components/core/tools/scripts/lib_install/mongoc.sh index 183fb8622..877a60344 100755 --- a/components/core/tools/scripts/lib_install/mongoc.sh +++ b/components/core/tools/scripts/lib_install/mongoc.sh @@ -94,7 +94,7 @@ if [ $checkinstall_installed -eq 0 ] ; then --pakdir "${deb_output_dir}" \ ) fi -"${install_command_prefix_args[@]}" cmake --build . --target install +"${install_command_prefix_args[@]}" cmake --build . --target install --parallel # Clean up rm -rf "$temp_dir" diff --git a/components/core/tools/scripts/lib_install/mongocxx.sh b/components/core/tools/scripts/lib_install/mongocxx.sh index 6cfbd0946..c73c2565f 100755 --- a/components/core/tools/scripts/lib_install/mongocxx.sh +++ b/components/core/tools/scripts/lib_install/mongocxx.sh @@ -97,7 +97,7 @@ if [ $checkinstall_installed -eq 0 ] ; then --pakdir "${deb_output_dir}" \ ) fi -"${install_command_prefix_args[@]}" cmake --build . --target install +"${install_command_prefix_args[@]}" cmake --build . --target install --parallel # Clean up rm -rf "$temp_dir" From 872c6047cd585f157501f516a6ba4a398f194e1e Mon Sep 17 00:00:00 2001 From: Kirk Rodrigues <2454684+kirkrodrigues@users.noreply.github.com> Date: Sun, 7 Jan 2024 21:16:16 -0500 Subject: [PATCH 7/7] Minor refactoring. --- .../core/tools/scripts/lib_install/mongoc.sh | 29 +++++++++--------- .../tools/scripts/lib_install/mongocxx.sh | 30 +++++++++---------- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/components/core/tools/scripts/lib_install/mongoc.sh b/components/core/tools/scripts/lib_install/mongoc.sh index 877a60344..016ac52e7 100755 --- a/components/core/tools/scripts/lib_install/mongoc.sh +++ b/components/core/tools/scripts/lib_install/mongoc.sh @@ -5,8 +5,8 @@ # - curl # - git # - g++ -# NOTE: Dependencies should be installed outside the script to allow the script to be -# largely distro-agnostic +# NOTE: Dependencies should be installed outside the script to allow the script to be largely +# distro-agnostic # Exit on any error set -e @@ -26,7 +26,7 @@ temp_dir="/tmp/${package_name}-installation" deb_output_dir="${temp_dir}" if [[ "$#" -gt 1 ]] ; then deb_output_dir="$(readlink -f "$2")" - if [ ! -d ${deb_output_dir} ] ; then + if [ ! -d "${deb_output_dir}" ] ; then echo "${deb_output_dir} does not exist or is not a directory" exit fi @@ -34,7 +34,7 @@ fi # Check if already installed set +e -dpkg -l ${package_name} | grep ${version} +dpkg -l "${package_name}" | grep "${version}" installed=$? set -e if [ $installed -eq 0 ] ; then @@ -46,7 +46,7 @@ echo "Checking for elevated privileges..." install_command_prefix_args=() if [ ${EUID:-$(id -u)} -ne 0 ] ; then sudo echo "Script can elevate privileges." - install_command_prefix_args=("sudo") + install_command_prefix_args+=("sudo") fi # Download @@ -59,8 +59,7 @@ if [ ! -e "${extracted_dir}" ] ; then curl \ -fsSL \ "https://github.com/mongodb/mongo-c-driver/releases/download/${version}/${tar_filename}" \ - -o \ - "${tar_filename}" + -o "${tar_filename}" fi tar -xf "${tar_filename}" @@ -84,14 +83,14 @@ set -e # Install if [ $checkinstall_installed -eq 0 ] ; then - install_command_prefix_args+=( \ - checkinstall \ - --pkgname "${package_name}" \ - --pkgversion "${version}" \ - --provides "${package_name}" \ - --nodoc \ - -y \ - --pakdir "${deb_output_dir}" \ + install_command_prefix_args+=( + checkinstall + --pkgname "${package_name}" + --pkgversion "${version}" + --provides "${package_name}" + --nodoc + -y + --pakdir "${deb_output_dir}" ) fi "${install_command_prefix_args[@]}" cmake --build . --target install --parallel diff --git a/components/core/tools/scripts/lib_install/mongocxx.sh b/components/core/tools/scripts/lib_install/mongocxx.sh index c73c2565f..a8c688606 100755 --- a/components/core/tools/scripts/lib_install/mongocxx.sh +++ b/components/core/tools/scripts/lib_install/mongocxx.sh @@ -5,8 +5,8 @@ # - curl # - git # - g++ -# NOTE: Dependencies should be installed outside the script to allow the script to be -# largely distro-agnostic +# NOTE: Dependencies should be installed outside the script to allow the script to be largely +# distro-agnostic # Exit on any error set -e @@ -46,7 +46,7 @@ echo "Checking for elevated privileges..." install_command_prefix_args=() if [ ${EUID:-$(id -u)} -ne 0 ] ; then sudo echo "Script can elevate privileges." - install_command_prefix_args=("sudo") + install_command_prefix_args+=("sudo") fi # Download @@ -59,8 +59,7 @@ if [ ! -e "${extracted_dir}" ] ; then curl \ -fsSL \ "https://github.com/mongodb/mongo-cxx-driver/releases/download/r${version}/${tar_filename}" \ - -o \ - "${tar_filename}" + -o "${tar_filename}" fi tar -xf "${tar_filename}" @@ -69,9 +68,8 @@ fi # Set up cd "${extracted_dir}/build" # NOTE: Although the mongocxx docs indicate we should use -# '-DMONGOCXX_OVERRIDE_DEFAULT_INSTALL_PREFIX=OFF' to install to the default -# location (/usr/local) but this doesn't seem to work, so we specify -# CMAKE_INSTALL_PREFIX here +# '-DMONGOCXX_OVERRIDE_DEFAULT_INSTALL_PREFIX=OFF' to install to the default location (/usr/local), +# this doesn't seem to work, so we specify CMAKE_INSTALL_PREFIX here cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr/local \ @@ -87,14 +85,14 @@ set -e # Install if [ $checkinstall_installed -eq 0 ] ; then - install_command_prefix_args+=( \ - checkinstall \ - --pkgname "${package_name}" \ - --pkgversion "${version}" \ - --provides "${package_name}" \ - --nodoc \ - -y \ - --pakdir "${deb_output_dir}" \ + install_command_prefix_args+=( + checkinstall + --pkgname "${package_name}" + --pkgversion "${version}" + --provides "${package_name}" + --nodoc + -y + --pakdir "${deb_output_dir}" ) fi "${install_command_prefix_args[@]}" cmake --build . --target install --parallel