Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion nix/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ in pkgs.mkShell {
# will erase `-march=native` because this introduces impurity in the build.
# For the purposes of compiling Nimbus, this behavior is not desired:
export NIX_ENFORCE_NO_NATIVE=0
export USE_SYSTEM_GETOPT=1
export MAKEFLAGS="-j$NIX_BUILD_CORES"

figlet "Welcome to Nimbus-eth2"
Expand Down
20 changes: 20 additions & 0 deletions scripts/getopt-wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
# scripts/getopt-wrapper.sh - exec GNU getopt on any platform.
set -eu

if [ "$(uname)" != "Darwin" ]; then
exec getopt "$@"
fi

# macOS: prefer getopt in PATH if it's GNU (exit 4 from --test), else Homebrew.
getopt --test > /dev/null 2>&1 && rc=0 || rc=$?
if [ "$rc" -eq 4 ]; then
exec getopt "$@"
fi

for c in /opt/homebrew/opt/gnu-getopt/bin/getopt /usr/local/opt/gnu-getopt/bin/getopt; do
[ -x "$c" ] && exec "$c" "$@"
done

echo "GNU getopt not installed. Install via 'brew install gnu-getopt'." >&2
exit 1
8 changes: 1 addition & 7 deletions scripts/launch_local_testnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,7 @@ PIDS_TO_WAIT=""
# argument parsing #
####################

USE_SYSTEM_GETOPT="${USE_SYSTEM_GETOPT:-0}"
GETOPT_BINARY="getopt"
if [[ "${OS}" == "macos" && "$USE_SYSTEM_GETOPT" != "1" ]]; then
# Without the head -n1 constraint, it gets confused by multiple matches
GETOPT_BINARY=$(find /opt/homebrew/opt/gnu-getopt/bin/getopt /usr/local/opt/gnu-getopt/bin/getopt 2> /dev/null | head -n1 || true)
[[ -f "$GETOPT_BINARY" ]] || { echo "GNU getopt not installed. Please run 'brew install gnu-getopt'. Aborting."; exit 1; }
fi
GETOPT_BINARY="${SCRIPTS_DIR}/getopt-wrapper.sh"

! ${GETOPT_BINARY} --test > /dev/null
if [[ ${PIPESTATUS[0]} != 4 ]]; then
Expand Down
9 changes: 3 additions & 6 deletions scripts/make_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@

set -e

SCRIPTS_DIR="$(dirname "${BASH_SOURCE[0]}")"

####################
# argument parsing #
####################

GETOPT_BINARY="getopt"
if uname | grep -qi darwin; then
# macOS
GETOPT_BINARY=$(find /opt/homebrew/opt/gnu-getopt/bin/getopt /usr/local/opt/gnu-getopt/bin/getopt 2> /dev/null || true)
[[ -f "$GETOPT_BINARY" ]] || { echo "GNU getopt not installed. Please run 'brew install gnu-getopt'. Aborting."; exit 1; }
fi
GETOPT_BINARY="${SCRIPTS_DIR}/getopt-wrapper.sh"

! ${GETOPT_BINARY} --test > /dev/null
if [ ${PIPESTATUS[0]} != 4 ]; then
Expand Down
14 changes: 5 additions & 9 deletions scripts/make_prometheus_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,18 @@

set -e

SCRIPTS_DIR="$(dirname "${BASH_SOURCE[0]}")"

####################
# argument parsing #
####################

GETOPT_BINARY="getopt"
if uname | grep -qi darwin; then
# macOS
# Without the head -n1 constraint, it gets confused by multiple matches
GETOPT_BINARY=$(find /opt/homebrew/opt/gnu-getopt/bin/getopt /usr/local/opt/gnu-getopt/bin/getopt 2> /dev/null | head -n1 || true)
[[ -f "$GETOPT_BINARY" ]] || { echo "GNU getopt not installed. Please run 'brew install gnu-getopt'. Aborting."; exit 1; }
fi
GETOPT_BINARY="${SCRIPTS_DIR}/getopt-wrapper.sh"

! ${GETOPT_BINARY} --test > /dev/null
if [ ${PIPESTATUS[0]} != 4 ]; then
echo '`getopt --test` failed in this environment.'
exit 1
echo '`getopt --test` failed in this environment.'
exit 1
fi

OPTS="h"
Expand Down
19 changes: 10 additions & 9 deletions scripts/start_nimbus_el_nodes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ wait_for_port() {
done
}

if [ -d /opt/homebrew/lib ]; then
# BEWARE
# The recent versions of homebrew/macOS can't add the libraries
# installed by Homebrew in the system's library search path, so
# Nimbus will fail to load RocksDB on start-up. THe new rules in
# macOS make it very difficult for the user to solve the problem
# in their profile, so we add an override here as the lessed evil:
export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH:-}:/opt/homebrew/lib"
# See https://github.com/Homebrew/brew/issues/13481 for more details
if uname | grep -qi darwin; then
# Ensure dynamically linked libraries (e.g. RocksDB) can be found at runtime.
# Check Nix paths first, then fall back to Homebrew.
# See https://github.com/Homebrew/brew/issues/13481 for more details.
for libdir in /run/current-system/sw/lib /opt/homebrew/lib /usr/local/lib; do
if [ -d "$libdir" ]; then
DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH:+$DYLD_LIBRARY_PATH:}$libdir"
fi
done
export DYLD_LIBRARY_PATH
fi

for NIMBUS_ETH1_NODE_IDX in $(seq 0 $NIMBUS_ETH1_LAST_NODE_IDX); do
Expand Down
11 changes: 4 additions & 7 deletions tests/simulation/restapi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@ RESTTEST_DELAY="30"
TEST_DIRNAME="resttest0_data"
KILL_OLD_PROCESSES="0"

REPO_ROOT="$(git rev-parse --show-toplevel)"
SCRIPTS_DIR="${REPO_ROOT}/scripts"

####################
# argument parsing #
####################

GETOPT_BINARY="getopt"
if uname | grep -qi darwin; then
# macOS
# Without the head -n1 constraint, it gets confused by multiple matches
GETOPT_BINARY=$(find /opt/homebrew/opt/gnu-getopt/bin/getopt /usr/local/opt/gnu-getopt/bin/getopt 2> /dev/null | head -n1 || true)
[[ -f "$GETOPT_BINARY" ]] || { echo "GNU getopt not installed. Please run 'brew install gnu-getopt'. Aborting."; exit 1; }
fi
GETOPT_BINARY="${SCRIPTS_DIR}/getopt-wrapper.sh"

! ${GETOPT_BINARY} --test > /dev/null
if [ ${PIPESTATUS[0]} != 4 ]; then
Expand Down
Loading