From b82450d576c2e6d6cfe2a880e7502559302351d7 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Wed, 20 Nov 2019 07:38:14 -0800 Subject: [PATCH] [build] fix opam_retry Summary: Not sure what's going on but even though `set -e` is passed, `install_opam_deps` was seen as succeeding even when the `opam install` command failed. This prevented `opam_retry` from getting triggered (and the error was also silently ignored). Also get rid of a couple of useless subshells in `opam_retry`. Reviewed By: jberdine Differential Revision: D18615860 fbshipit-source-id: 360232623 --- build-infer.sh | 6 +++--- scripts/opam_utils.sh | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/build-infer.sh b/build-infer.sh index 678559266..d6b8cc848 100755 --- a/build-infer.sh +++ b/build-infer.sh @@ -122,8 +122,8 @@ if [ "$INTERACTIVE" == "no" ] || [ "$USER_OPAM_SWITCH" == "no" ]; then fi setup_opam () { - opam var root 1>/dev/null 2>/dev/null || opam init --reinit --bare --no-setup - opam_switch_create_if_needed "$INFER_OPAM_SWITCH" "$INFER_OPAM_COMPILER" + opam var root 1>/dev/null 2>/dev/null || opam init --reinit --bare --no-setup && + opam_switch_create_if_needed "$INFER_OPAM_SWITCH" "$INFER_OPAM_COMPILER" && opam switch set "$INFER_OPAM_SWITCH" } @@ -132,7 +132,7 @@ install_opam_deps () { if [ "$USE_OPAM_LOCK" == yes ]; then locked=--locked fi - opam install --deps-only infer "$INFER_ROOT" $locked + opam install --deps-only infer "$INFER_ROOT" $locked && if [ -n "$SANDCASTLE" ]; then opam pin list | grep yojson || opam pin add yojson "${DEPENDENCIES_DIR}/yojson-1.7.0fix" fi diff --git a/scripts/opam_utils.sh b/scripts/opam_utils.sh index 07b26be50..5dcc421a8 100644 --- a/scripts/opam_utils.sh +++ b/scripts/opam_utils.sh @@ -7,17 +7,17 @@ # source this script to import its utility functions opam_retry () { - "$@" || ( \ - echo >&2; \ - printf '*** `%s` failed\n' "$*" >&2; \ - echo '*** Updating opam then retrying' >&2; \ - opam update && \ - "$@" || ( \ - echo >&2; \ - printf '*** ERROR: `%s` failed\n' "$*" >&2; \ - exit 1 \ - ) \ - ) + "$@" || { + echo >&2; + printf '*** `%s` failed\n' "$*" >&2; + echo '*** Updating opam then retrying' >&2; + opam update && + "$@" || { + echo >&2; + printf '*** ERROR: `%s` failed\n' "$*" >&2; + exit 1 + } + } } opam_failed () {