summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Shchatko <mikhail.shchatko@mongodb.com>2022-01-03 18:40:24 +0300
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-01-06 13:57:47 +0000
commit78673096b6886abe4c5761da81a9b121372f98ad (patch)
tree2fc68cabbdfa916dc8e9b0aeafb20a6edd80cdec
parentdd60de3fdb94df895288aee74b617c2715bb379a (diff)
downloadmongo-78673096b6886abe4c5761da81a9b121372f98ad.tar.gz
SERVER-49015 Automatically install db-contrib-tool
-rw-r--r--.gitignore36
-rwxr-xr-xbuildscripts/auto_install_db_contrib_tool.sh76
2 files changed, 95 insertions, 17 deletions
diff --git a/.gitignore b/.gitignore
index 8a5cc56e361..33cf47812e8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -76,25 +76,27 @@ docs/latex
docs/doxygen
32bit
scratch
+/multiversion_binaries
# binaries
-/docgen
-/loadgen
-/mongo
-/mongobridge
-/mongocryptd
-/mongod
-/mongoed
-/mongogrid
-/mongokerberos
-/mongoldap
-/mongoperf
-/mongos
-/mongoshim
-/mongosniff
-/mongotmock
-/mongotrafficreader
-/wt
+/docgen*
+/loadgen*
+/mongo*
+/mongobridge*
+/mongocryptd*
+/mongod*
+/mongoed*
+/mongogrid*
+/mongokerberos*
+/mongoldap*
+/mongoperf*
+/mongos*
+/mongoshim*
+/mongosniff*
+/mongotmock*
+/mongotrafficreader*
+/mqlrun*
+/wt*
*.tgz
*.zip
diff --git a/buildscripts/auto_install_db_contrib_tool.sh b/buildscripts/auto_install_db_contrib_tool.sh
new file mode 100755
index 00000000000..1ba77c12460
--- /dev/null
+++ b/buildscripts/auto_install_db_contrib_tool.sh
@@ -0,0 +1,76 @@
+#!/bin/bash
+
+set -o errexit
+
+echo "+-----------------------------------------------------------------------------------------------------------+"
+echo "| Running a script to automatically install db-contrib-tool (https://github.com/10gen/db-contrib-tool). |"
+echo "+-----------------------------------------------------------------------------------------------------------+"
+echo
+
+if [[ -d "/opt/mongodbtoolchain/v3/bin" ]]; then
+ export PATH="/opt/mongodbtoolchain/v3/bin:$PATH"
+fi
+
+rc_file=""
+if [[ -f "$HOME/.bashrc" ]]; then
+ rc_file="$HOME/.bashrc"
+fi
+
+if [[ -f "$HOME/.zshrc" ]]; then
+ rc_file="$HOME/.zshrc"
+fi
+
+if ! command -v db-contrib-tool &> /dev/null; then
+ if ! python3 -c "import sys; sys.exit(sys.version_info < (3, 7))" &> /dev/null; then
+ actual_version=$(python3 -c 'import sys; print(sys.version)')
+ echo "You must have python3.7+ installed. Detected version $actual_version."
+ echo "To avoid unexpected issues, python3.7+ will not be automatically installed."
+ echo "Please, do it yourself."
+ echo
+ echo "On macOS you can run:"
+ echo
+ echo " brew install python3"
+ echo
+ exit 1
+ fi
+
+ if command -v pipx &> /dev/null; then
+ echo "Found pipx: $(command -v pipx)."
+ echo "Using it to install 'db-contrib-tool'."
+ echo
+
+ pipx ensurepath &> /dev/null
+ if [[ -f "$rc_file" ]]; then
+ source "$rc_file"
+ fi
+
+ pipx install db-contrib-tool --python $(command -v python3) --force
+ echo
+ else
+ if ! python3 -m pipx --version &> /dev/null; then
+ echo "Couldn't find pipx. Installing it as python3 module:"
+ echo " $(command -v python3) -m pip install pipx"
+ echo
+ python3 -m pip install pipx
+ echo
+ else
+ echo "Found pipx installed as python3 module:"
+ echo " $(command -v python3) -m pipx --version"
+ echo "Using it to install 'db-contrib-tool'."
+ echo
+ fi
+
+ python3 -m pipx ensurepath &> /dev/null
+ if [[ -f "$rc_file" ]]; then
+ source "$rc_file"
+ fi
+
+ python3 -m pipx install db-contrib-tool --force
+ echo
+ fi
+fi
+
+echo "Please, open a new shell or run:"
+echo
+echo " source $rc_file"
+echo