Skip to content

Commit

Permalink
Container image build fixes: (#229)
Browse files Browse the repository at this point in the history
- Error on failure to install any package into the container image.
- Don't use an empty array as a command (for older Bash versions).
  • Loading branch information
kirkrodrigues authored Jan 12, 2024
1 parent 8f58c5e commit 4dd351c
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/env bash

# Exit on any error
set -e

# Error on undefined variable
set -u

script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

"$script_dir"/install-prebuilt-packages.sh
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
#!/usr/bin/env bash

# Exit on any error
set -e

# Enable gcc 10
source /opt/rh/devtoolset-10/enable

# Enable git
source /opt/rh/rh-git227/enable

# Error on undefined variable
# NOTE: We enable this *after* sourcing the scripts above since we can't guarantee they won't have
# unbound variables in them.
set -u

# 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/env bash

# Exit on any error
set -e

# Error on undefined variable
set -u

yum install -y \
bzip2 \
centos-release-scl \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/env bash

# Exit on any error
set -e

# Error on undefined variable
set -u

brew update
brew install \
boost \
Expand Down
14 changes: 10 additions & 4 deletions components/core/tools/scripts/lib_install/mongoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ if [ $installed -eq 0 ] ; then
fi

echo "Checking for elevated privileges..."
install_command_prefix_args=()
install_cmd_args=()
if [ ${EUID:-$(id -u)} -ne 0 ] ; then
sudo echo "Script can elevate privileges."
install_command_prefix_args+=("sudo")
install_cmd_args+=("sudo")
fi

# Download
Expand Down Expand Up @@ -84,7 +84,7 @@ set -e

# Install
if [ $checkinstall_installed -eq 0 ] ; then
install_command_prefix_args+=(
install_cmd_args+=(
checkinstall
--pkgname "${package_name}"
--pkgversion "${version}"
Expand All @@ -94,7 +94,13 @@ if [ $checkinstall_installed -eq 0 ] ; then
--pakdir "${deb_output_dir}"
)
fi
"${install_command_prefix_args[@]}" cmake --build . --target install --parallel
install_cmd_args+=(
cmake
--build .
--target install
--parallel
)
"${install_cmd_args[@]}"

# Clean up
rm -rf "$temp_dir"
14 changes: 10 additions & 4 deletions components/core/tools/scripts/lib_install/mongocxx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ if [ $installed -eq 0 ] ; then
fi

echo "Checking for elevated privileges..."
install_command_prefix_args=()
install_cmd_args=()
if [ ${EUID:-$(id -u)} -ne 0 ] ; then
sudo echo "Script can elevate privileges."
install_command_prefix_args+=("sudo")
install_cmd_args+=("sudo")
fi

# Download
Expand Down Expand Up @@ -86,7 +86,7 @@ set -e

# Install
if [ $checkinstall_installed -eq 0 ] ; then
install_command_prefix_args+=(
install_cmd_args+=(
checkinstall
--pkgname "${package_name}"
--pkgversion "${version}"
Expand All @@ -96,7 +96,13 @@ if [ $checkinstall_installed -eq 0 ] ; then
--pakdir "${deb_output_dir}"
)
fi
"${install_command_prefix_args[@]}" cmake --build . --target install --parallel
install_cmd_args+=(
cmake
--build .
--target install
--parallel
)
"${install_cmd_args[@]}"

# Clean up
rm -rf "$temp_dir"
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/env bash

# Exit on any error
set -e

# Error on undefined variable
set -u

script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

"$script_dir"/install-prebuilt-packages.sh
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/env bash

# Exit on any error
set -e

# Error on undefined variable
set -u

./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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/env bash

# Exit on any error
set -e

# Error on undefined variable
set -u

apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y \
ca-certificates \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/env bash

# Exit on any error
set -e

# Error on undefined variable
set -u

script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

"$script_dir"/install-prebuilt-packages.sh
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/env bash

# Exit on any error
set -e

# Error on undefined variable
set -u

./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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/env bash

# Exit on any error
set -e

# Error on undefined variable
set -u

apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y \
ca-certificates \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/bin/bash

# Exit on any error
set -e

# Error on undefined variable
set -u

apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y \
checkinstall \
Expand Down

0 comments on commit 4dd351c

Please sign in to comment.