-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mongocxx dependencies to all dev environments. (#218)
- Loading branch information
1 parent
2ae14de
commit efc34ae
Showing
7 changed files
with
210 additions
and
0 deletions.
There are no files selected for viewing
Empty file modified
0
components/core/tools/docker-images/clp-env-base-ubuntu-focal/build.sh
100644 → 100755
Empty file.
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
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,99 @@ | ||
#!/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 | ||
|
||
# Exit on any error | ||
set -e | ||
|
||
# Error on undefined variable | ||
set -u | ||
|
||
cUsage="Usage: ${BASH_SOURCE[0]} <version>[ <.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..." | ||
install_command_prefix_args=() | ||
if [ ${EUID:-$(id -u)} -ne 0 ] ; then | ||
sudo echo "Script can elevate privileges." | ||
install_command_prefix_args+=("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 | ||
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}" | ||
) | ||
fi | ||
"${install_command_prefix_args[@]}" cmake --build . --target install --parallel | ||
|
||
# Clean up | ||
rm -rf "$temp_dir" |
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,101 @@ | ||
#!/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 | ||
|
||
# Exit on any error | ||
set -e | ||
|
||
# Error on undefined variable | ||
set -u | ||
|
||
cUsage="Usage: ${BASH_SOURCE[0]} <version>[ <.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..." | ||
install_command_prefix_args=() | ||
if [ ${EUID:-$(id -u)} -ne 0 ] ; then | ||
sudo echo "Script can elevate privileges." | ||
install_command_prefix_args+=("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), | ||
# 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 | ||
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}" | ||
) | ||
fi | ||
"${install_command_prefix_args[@]}" cmake --build . --target install --parallel | ||
|
||
# Clean up | ||
rm -rf "$temp_dir" |
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