Skip to content

Commit efc34ae

Browse files
authored
Add mongocxx dependencies to all dev environments. (#218)
1 parent 2ae14de commit efc34ae

File tree

7 files changed

+210
-0
lines changed

7 files changed

+210
-0
lines changed

components/core/tools/docker-images/clp-env-base-ubuntu-focal/build.sh

100644100755
File mode changed.

components/core/tools/scripts/lib_install/centos7.4/install-packages-from-source.sh

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
# Enable gcc 10
44
source /opt/rh/devtoolset-10/enable
55

6+
# Enable git
7+
source /opt/rh/rh-git227/enable
8+
69
# NOTE: cmake and boost must be installed first since the remaining packages depend on them
710
./tools/scripts/lib_install/install-cmake.sh 3.21.2
811
./tools/scripts/lib_install/install-boost.sh 1.76.0
@@ -11,6 +14,8 @@ source /opt/rh/devtoolset-10/enable
1114
./tools/scripts/lib_install/libarchive.sh 3.5.1
1215
./tools/scripts/lib_install/lz4.sh 1.8.2
1316
./tools/scripts/lib_install/mariadb-connector-c.sh 3.2.3
17+
./tools/scripts/lib_install/mongoc.sh 1.24.4
18+
./tools/scripts/lib_install/mongocxx.sh 3.8.0
1419
./tools/scripts/lib_install/msgpack.sh 6.0.0
1520
./tools/scripts/lib_install/spdlog.sh 1.9.2
1621
./tools/scripts/lib_install/zstandard.sh 1.4.9

components/core/tools/scripts/lib_install/macos-12/install-all.sh

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ brew install \
99
libarchive \
1010
lz4 \
1111
mariadb-connector-c \
12+
mongo-cxx-driver \
1213
msgpack-cxx \
1314
spdlog \
1415
pkg-config \
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/usr/bin/env bash
2+
3+
# Dependencies:
4+
# - cmake
5+
# - curl
6+
# - git
7+
# - g++
8+
# NOTE: Dependencies should be installed outside the script to allow the script to be largely
9+
# distro-agnostic
10+
11+
# Exit on any error
12+
set -e
13+
14+
# Error on undefined variable
15+
set -u
16+
17+
cUsage="Usage: ${BASH_SOURCE[0]} <version>[ <.deb output directory>]"
18+
if [ "$#" -lt 1 ] ; then
19+
echo "$cUsage"
20+
exit
21+
fi
22+
version=$1
23+
24+
package_name=libmongoc-dev
25+
temp_dir="/tmp/${package_name}-installation"
26+
deb_output_dir="${temp_dir}"
27+
if [[ "$#" -gt 1 ]] ; then
28+
deb_output_dir="$(readlink -f "$2")"
29+
if [ ! -d "${deb_output_dir}" ] ; then
30+
echo "${deb_output_dir} does not exist or is not a directory"
31+
exit
32+
fi
33+
fi
34+
35+
# Check if already installed
36+
set +e
37+
dpkg -l "${package_name}" | grep "${version}"
38+
installed=$?
39+
set -e
40+
if [ $installed -eq 0 ] ; then
41+
# Nothing to do
42+
exit
43+
fi
44+
45+
echo "Checking for elevated privileges..."
46+
install_command_prefix_args=()
47+
if [ ${EUID:-$(id -u)} -ne 0 ] ; then
48+
sudo echo "Script can elevate privileges."
49+
install_command_prefix_args+=("sudo")
50+
fi
51+
52+
# Download
53+
mkdir -p "$temp_dir"
54+
cd "$temp_dir"
55+
extracted_dir="${temp_dir}/mongo-c-driver-${version}"
56+
if [ ! -e "${extracted_dir}" ] ; then
57+
tar_filename="mongo-c-driver-${version}.tar.gz"
58+
if [ ! -e "${tar_filename}" ] ; then
59+
curl \
60+
-fsSL \
61+
"https://github.com/mongodb/mongo-c-driver/releases/download/${version}/${tar_filename}" \
62+
-o "${tar_filename}"
63+
fi
64+
65+
tar -xf "${tar_filename}"
66+
fi
67+
68+
# Set up
69+
cd "${extracted_dir}"
70+
mkdir -p build
71+
cd build
72+
cmake \
73+
-DCMAKE_BUILD_TYPE=Release \
74+
-DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF \
75+
-DENABLE_TESTS=OFF \
76+
..
77+
78+
# Check if checkinstall is installed
79+
set +e
80+
command -v checkinstall
81+
checkinstall_installed=$?
82+
set -e
83+
84+
# Install
85+
if [ $checkinstall_installed -eq 0 ] ; then
86+
install_command_prefix_args+=(
87+
checkinstall
88+
--pkgname "${package_name}"
89+
--pkgversion "${version}"
90+
--provides "${package_name}"
91+
--nodoc
92+
-y
93+
--pakdir "${deb_output_dir}"
94+
)
95+
fi
96+
"${install_command_prefix_args[@]}" cmake --build . --target install --parallel
97+
98+
# Clean up
99+
rm -rf "$temp_dir"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#!/usr/bin/env bash
2+
3+
# Dependencies:
4+
# - cmake
5+
# - curl
6+
# - git
7+
# - g++
8+
# NOTE: Dependencies should be installed outside the script to allow the script to be largely
9+
# distro-agnostic
10+
11+
# Exit on any error
12+
set -e
13+
14+
# Error on undefined variable
15+
set -u
16+
17+
cUsage="Usage: ${BASH_SOURCE[0]} <version>[ <.deb output directory>]"
18+
if [ "$#" -lt 1 ] ; then
19+
echo "$cUsage"
20+
exit
21+
fi
22+
version=$1
23+
24+
package_name=libmongocxx-dev
25+
temp_dir="/tmp/${package_name}-installation"
26+
deb_output_dir="${temp_dir}"
27+
if [[ "$#" -gt 1 ]] ; then
28+
deb_output_dir="$(readlink -f "$2")"
29+
if [ ! -d "${deb_output_dir}" ] ; then
30+
echo "${deb_output_dir} does not exist or is not a directory"
31+
exit
32+
fi
33+
fi
34+
35+
# Check if already installed
36+
set +e
37+
dpkg -l "${package_name}" | grep "${version}"
38+
installed=$?
39+
set -e
40+
if [ $installed -eq 0 ] ; then
41+
# Nothing to do
42+
exit
43+
fi
44+
45+
echo "Checking for elevated privileges..."
46+
install_command_prefix_args=()
47+
if [ ${EUID:-$(id -u)} -ne 0 ] ; then
48+
sudo echo "Script can elevate privileges."
49+
install_command_prefix_args+=("sudo")
50+
fi
51+
52+
# Download
53+
mkdir -p "$temp_dir"
54+
cd "$temp_dir"
55+
extracted_dir="${temp_dir}/mongo-cxx-driver-r${version}"
56+
if [ ! -e "${extracted_dir}" ] ; then
57+
tar_filename="mongo-cxx-driver-r${version}.tar.gz"
58+
if [ ! -e "${tar_filename}" ] ; then
59+
curl \
60+
-fsSL \
61+
"https://github.com/mongodb/mongo-cxx-driver/releases/download/r${version}/${tar_filename}" \
62+
-o "${tar_filename}"
63+
fi
64+
65+
tar -xf "${tar_filename}"
66+
fi
67+
68+
# Set up
69+
cd "${extracted_dir}/build"
70+
# NOTE: Although the mongocxx docs indicate we should use
71+
# '-DMONGOCXX_OVERRIDE_DEFAULT_INSTALL_PREFIX=OFF' to install to the default location (/usr/local),
72+
# this doesn't seem to work, so we specify CMAKE_INSTALL_PREFIX here
73+
cmake \
74+
-DCMAKE_BUILD_TYPE=Release \
75+
-DCMAKE_INSTALL_PREFIX=/usr/local \
76+
-DBUILD_SHARED_AND_STATIC_LIBS=ON \
77+
-DENABLE_TESTS=OFF \
78+
..
79+
80+
# Check if checkinstall is installed
81+
set +e
82+
command -v checkinstall
83+
checkinstall_installed=$?
84+
set -e
85+
86+
# Install
87+
if [ $checkinstall_installed -eq 0 ] ; then
88+
install_command_prefix_args+=(
89+
checkinstall
90+
--pkgname "${package_name}"
91+
--pkgversion "${version}"
92+
--provides "${package_name}"
93+
--nodoc
94+
-y
95+
--pakdir "${deb_output_dir}"
96+
)
97+
fi
98+
"${install_command_prefix_args[@]}" cmake --build . --target install --parallel
99+
100+
# Clean up
101+
rm -rf "$temp_dir"

components/core/tools/scripts/lib_install/ubuntu-focal/install-packages-from-source.sh

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
./tools/scripts/lib_install/fmtlib.sh 8.0.1
44
./tools/scripts/lib_install/libarchive.sh 3.5.1
55
./tools/scripts/lib_install/lz4.sh 1.8.2
6+
./tools/scripts/lib_install/mongoc.sh 1.24.4
7+
./tools/scripts/lib_install/mongocxx.sh 3.8.0
68
./tools/scripts/lib_install/msgpack.sh 6.0.0
79
./tools/scripts/lib_install/spdlog.sh 1.9.2
810
./tools/scripts/lib_install/zstandard.sh 1.4.9

components/core/tools/scripts/lib_install/ubuntu-jammy/install-packages-from-source.sh

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
./tools/scripts/lib_install/fmtlib.sh 8.0.1
44
./tools/scripts/lib_install/libarchive.sh 3.5.1
55
./tools/scripts/lib_install/lz4.sh 1.8.2
6+
./tools/scripts/lib_install/mongoc.sh 1.24.4
7+
./tools/scripts/lib_install/mongocxx.sh 3.8.0
68
./tools/scripts/lib_install/msgpack.sh 6.0.0
79
./tools/scripts/lib_install/spdlog.sh 1.9.2
810
./tools/scripts/lib_install/zstandard.sh 1.4.9

0 commit comments

Comments
 (0)