Skip to content

CXX-2988 Use Bash and shebangs whenever able #1179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 26, 2024
Merged
3 changes: 2 additions & 1 deletion .evergreen/build_example_projects.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash

set -o errexit
set -o pipefail

Expand Down
2 changes: 1 addition & 1 deletion .evergreen/build_snapshot_rpm.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -o errexit

Expand Down
2 changes: 1 addition & 1 deletion .evergreen/compile.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Runs cmake and compiles the standard build targets (all, install, examples). Any arguments passed
# to this script will be forwarded on as flags passed to cmake.
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/connect.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -o errexit
set -o pipefail
Expand Down
Empty file modified .evergreen/debian_package_build.sh
100644 → 100755
Empty file.
3 changes: 2 additions & 1 deletion .evergreen/find_cmake.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
#!/usr/bin/env bash

set -o errexit # Exit the script with error if any of the commands fail

find_cmake ()
Expand Down
3 changes: 2 additions & 1 deletion .evergreen/uninstall_check.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
#!/usr/bin/env bash

set -o errexit # Exit the script with error if any of the commands fail

BUILD_DIR=$(pwd)/build
Expand Down
52 changes: 16 additions & 36 deletions .mci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ functions:
type: setup
params:
binary: bash
args: [mongo-cxx-driver/.evergreen/abi-compliance-check-setup.sh]
args: [-c, mongo-cxx-driver/.evergreen/abi-compliance-check-setup.sh]
- command: subprocess.exec
type: test
params:
binary: bash
args: [mongo-cxx-driver/.evergreen/abi-compliance-check-test.sh]
args: [-c, mongo-cxx-driver/.evergreen/abi-compliance-check-test.sh]
- command: s3.put
type: system
params:
Expand Down Expand Up @@ -117,12 +117,12 @@ functions:
type: setup
params:
binary: bash
args: [mongo-cxx-driver/.evergreen/abidiff-setup.sh]
args: [-c, mongo-cxx-driver/.evergreen/abidiff-setup.sh]
- command: subprocess.exec
type: test
params:
binary: bash
args: [mongo-cxx-driver/.evergreen/abidiff-test.sh]
args: [-c, mongo-cxx-driver/.evergreen/abidiff-test.sh]
- command: s3.put
type: system
params:
Expand Down Expand Up @@ -151,7 +151,7 @@ functions:
type: test
params:
binary: bash
args: [mongo-cxx-driver/.evergreen/abi-prohibited-symbols-test.sh]
args: [-c, mongo-cxx-driver/.evergreen/abi-prohibited-symbols-test.sh]

"setup":
- command: shell.exec
Expand Down Expand Up @@ -193,7 +193,7 @@ functions:
cd drivers-evergreen-tools
export DRIVERS_TOOLS=$(pwd)

bash .evergreen/atlas_data_lake/pull-mongohouse-image.sh
.evergreen/atlas_data_lake/pull-mongohouse-image.sh

"run_mongohouse":
command: shell.exec
Expand All @@ -203,7 +203,7 @@ functions:
cd drivers-evergreen-tools
export DRIVERS_TOOLS=$(pwd)

bash .evergreen/atlas_data_lake/run-mongohouse-image.sh
.evergreen/atlas_data_lake/run-mongohouse-image.sh

"test_mongohouse":
command: shell.exec
Expand Down Expand Up @@ -338,7 +338,6 @@ functions:
command: subprocess.exec
params:
binary: bash
working_dir: "."
args:
- -c
- |
Expand Down Expand Up @@ -583,7 +582,6 @@ functions:
"upload mongo orchestration artifacts":
- command: subprocess.exec
params:
working_dir: "."
binary: bash
args:
- -c
Expand Down Expand Up @@ -659,9 +657,7 @@ functions:
working_dir: "mongo-cxx-driver"
add_expansions_to_env: true
redirect_standard_error_to_output: true
args:
- -c
- .evergreen/compile-scan-build.sh
args: [-c, .evergreen/compile-scan-build.sh]

"upload scan artifacts":
- command: subprocess.exec
Expand Down Expand Up @@ -711,9 +707,7 @@ functions:
- ARTIFACTORY_PASSWORD
- SILK_CLIENT_ID
- SILK_CLIENT_SECRET
args:
- -c
- .evergreen/check-augmented-sbom.sh
args: [-c, .evergreen/check-augmented-sbom.sh]

"upload augmented sbom":
- command: s3.put
Expand Down Expand Up @@ -991,39 +985,27 @@ tasks:
- func: "setup"
- func: "fetch_c_driver_source"
- func: "compile"
- command: expansions.update
params:
updates:
- key: mongocxx_version_finder_sh
value: $(sed -nE 's/^#define MONGOCXX_VERSION_STRING "([^"]+)".*/\1/p' build/src/mongocxx/config/version.hpp)
- command: shell.exec
type: test
params:
shell: bash
working_dir: "mongo-cxx-driver"
script: |-
set -o errexit
export INSTALL_VERSION=${mongocxx_version_finder_sh}
sh ./.evergreen/uninstall_check.sh
./.evergreen/uninstall_check.sh

- name: uninstall_check_windows
commands:
- func: "setup"
- func: "fetch_c_driver_source"
- func: "compile"
- command: expansions.update
params:
updates:
- key: mongocxx_version_finder_sh
value: $(sed -nE 's/^#define MONGOCXX_VERSION_STRING "([^"]+)".*/\1/p' build/src/mongocxx/config/version.hpp)
- command: shell.exec
type: test
params:
shell: bash
working_dir: "mongo-cxx-driver"
script: |-
set -o errexit
export INSTALL_VERSION=${mongocxx_version_finder_sh}
cmd.exe /c .\\.evergreen\\uninstall_check_windows.cmd

- name: build_example_with_add_subdirectory
Expand Down Expand Up @@ -1075,7 +1057,7 @@ tasks:
script: |-
set -o errexit
export IS_PATCH="${is_patch}"
sh .evergreen/debian_package_build.sh
.evergreen/debian_package_build.sh
- command: s3.put
params:
aws_key: ${aws_key}
Expand All @@ -1100,7 +1082,7 @@ tasks:
set -o errexit
export IS_PATCH="${is_patch}"
export DEB_BUILD_PROFILES="pkg.mongo-cxx-driver.mnmlstc"
sh .evergreen/debian_package_build.sh
.evergreen/debian_package_build.sh
- command: s3.put
params:
aws_key: ${aws_key}
Expand All @@ -1123,7 +1105,7 @@ tasks:
shell: bash
script: |-
set -o errexit
sh .evergreen/build_snapshot_rpm.sh
.evergreen/build_snapshot_rpm.sh
- command: s3.put
params:
aws_key: ${aws_key}
Expand Down Expand Up @@ -1287,7 +1269,7 @@ task_groups:
- command: subprocess.exec
params:
binary: bash
args: [mongo-cxx-driver/.evergreen/abi-stability-setup.sh]
args: [-c, mongo-cxx-driver/.evergreen/abi-stability-setup.sh]
include_expansions_in_env: [cxx_standard]
tasks: [".abi-stability"]
teardown_task_can_fail_task: true
Expand All @@ -1308,8 +1290,7 @@ task_groups:
add_expansions_to_env: true
env:
MONGODB_VERSION: '7.0'
args:
- ${DRIVERS_TOOLS}/.evergreen/atlas/setup-atlas-cluster.sh
args: [-c, "${DRIVERS_TOOLS}/.evergreen/atlas/setup-atlas-cluster.sh"]
- command: expansions.update
# Expected to set MONGODB_URI expansion.
params:
Expand All @@ -1320,8 +1301,7 @@ task_groups:
working_dir: mongo-cxx-driver
binary: bash
add_expansions_to_env: true
args:
- ${DRIVERS_TOOLS}/.evergreen/atlas/teardown-atlas-cluster.sh
args: [-c, "${DRIVERS_TOOLS}/.evergreen/atlas/teardown-atlas-cluster.sh"]
setup_group_can_fail_task: true
setup_group_timeout_secs: 1800
tasks:
Expand Down
3 changes: 2 additions & 1 deletion etc/calc_release_version_selftest.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash
#
# calc_release_version_selftest.sh is used to test output of calc_release_version.py.
# run with:
# cd etc
Expand Down
2 changes: 1 addition & 1 deletion etc/generate-uninstall.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ set prefix=%prefix:"=%
echo.@echo off
echo.
echo.REM MongoDB C++ Driver uninstall program, generated with CMake
echo.
echo.REM
echo.REM Copyright 2009-present MongoDB, Inc.
echo.REM
echo.REM Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
7 changes: 4 additions & 3 deletions etc/generate-uninstall.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env sh

# Copyright 2009-present MongoDB, Inc.
#
Expand Down Expand Up @@ -60,9 +60,10 @@ if [ "${DESTDIR}" ]; then
fi


printf "#!/bin/sh\n"
printf "#!/usr/bin/env bash\n"
printf "#\n"
printf "# MongoDB C++ Driver uninstall program, generated with CMake"
printf "\n"
printf "#\n"
printf "# Copyright 2009-present MongoDB, Inc.\n"
printf "#\n"
printf "# Licensed under the Apache License, Version 2.0 (the \"License\");\n"
Expand Down
3 changes: 2 additions & 1 deletion examples/projects/bsoncxx/cmake/shared/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash

set -o errexit
set -o pipefail

Expand Down
3 changes: 2 additions & 1 deletion examples/projects/bsoncxx/cmake/static/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash

set -o errexit
set -o pipefail

Expand Down
3 changes: 2 additions & 1 deletion examples/projects/bsoncxx/pkg-config/shared/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash

set -o errexit
set -o pipefail

Expand Down
3 changes: 2 additions & 1 deletion examples/projects/bsoncxx/pkg-config/static/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash

set -o errexit
set -o pipefail

Expand Down
3 changes: 2 additions & 1 deletion examples/projects/mongocxx/cmake/shared/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash

set -o errexit
set -o pipefail

Expand Down
3 changes: 2 additions & 1 deletion examples/projects/mongocxx/cmake/static/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash

set -o errexit
set -o pipefail

Expand Down
3 changes: 2 additions & 1 deletion examples/projects/mongocxx/pkg-config/shared/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash

set -o errexit
set -o pipefail

Expand Down
3 changes: 2 additions & 1 deletion examples/projects/mongocxx/pkg-config/static/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash

set -o errexit
set -o pipefail

Expand Down
36 changes: 29 additions & 7 deletions generate_uninstall/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ if (WIN32)
"${CMAKE_INSTALL_PREFIX}"
)
install (CODE "
string(REPLACE \";\" \"\\n\" MONGOCXX_INSTALL_MANIFEST_CONTENT
string (REPLACE \";\" \"\\n\" MONGOCXX_INSTALL_MANIFEST_CONTENT
\"\${CMAKE_INSTALL_MANIFEST_FILES}\")
string(REPLACE \"/\" \"\\\\\" MONGOCXX_INSTALL_MANIFEST_CONTENT_WIN32
string (REPLACE \"/\" \"\\\\\" MONGOCXX_INSTALL_MANIFEST_CONTENT_WIN32
\"\${MONGOCXX_INSTALL_MANIFEST_CONTENT}\")
file(WRITE \"mongocxx_install_manifest.txt\"
file (WRITE \"mongocxx_install_manifest.txt\"
\"\${MONGOCXX_INSTALL_MANIFEST_CONTENT_WIN32}\")
execute_process (
COMMAND
Expand All @@ -47,13 +47,13 @@ if (WIN32)
install (FILES "${CMAKE_CURRENT_BINARY_DIR}/${UNINSTALL_PROG}" DESTINATION "${UNINSTALL_PROG_DIR}" PERMISSIONS ${UNINSTALL_PERMISSIONS})

add_custom_target (uninstall
COMMAND call "${CMAKE_CURRENT_BINARY_DIR}/${UNINSTALL_PROG}"
COMMAND "${CMAKE_CURRENT_BINARY_DIR}/${UNINSTALL_PROG}"
)
else ()
install (CODE "
string(REPLACE \";\" \"\\n\" MONGOCXX_INSTALL_MANIFEST_CONTENT
string (REPLACE \";\" \"\\n\" MONGOCXX_INSTALL_MANIFEST_CONTENT
\"\${CMAKE_INSTALL_MANIFEST_FILES}\")
file(WRITE \"mongocxx_install_manifest.txt\"
file (WRITE \"mongocxx_install_manifest.txt\"
\"\${MONGOCXX_INSTALL_MANIFEST_CONTENT}\")
execute_process (
COMMAND
Expand All @@ -68,10 +68,32 @@ else ()
OUTPUT_FILE
\"${CMAKE_CURRENT_BINARY_DIR}/${UNINSTALL_PROG}\"
)

# Ensure generated uninstall script has executable permissions.
if (\"${CMAKE_VERSION}\" VERSION_GREATER_EQUAL \"3.19.0\")
file (
CHMOD \"${CMAKE_CURRENT_BINARY_DIR}/${UNINSTALL_PROG}\"
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
else ()
# Workaround lack of file(CHMOD).
file (
COPY \"${CMAKE_CURRENT_BINARY_DIR}/${UNINSTALL_PROG}\"
DESTINATION \"${UNINSTALL_PROG}.d\"
FILE_PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
file (RENAME \"${UNINSTALL_PROG}.d/${UNINSTALL_PROG}\" \"${UNINSTALL_PROG}\")
endif ()
")
install (FILES "${CMAKE_CURRENT_BINARY_DIR}/${UNINSTALL_PROG}" DESTINATION "${UNINSTALL_PROG_DIR}" PERMISSIONS ${UNINSTALL_PERMISSIONS})

add_custom_target (uninstall
COMMAND sh "${CMAKE_CURRENT_BINARY_DIR}/${UNINSTALL_PROG}"
COMMAND "${CMAKE_CURRENT_BINARY_DIR}/${UNINSTALL_PROG}"
)
endif ()