forked from yugabyte/yugabyte-db
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: set shell vars in cli wrapper scripts (yugabyte#3930)
Summary: Running `cqlsh` or `redis-cli` from development environments doesn't work, complaining about unset `YB_THIRDPARTY_DIR`. Create `build-support/common-cli-env.sh` to get common shell variables, namely `YB_BUILD_ROOT`, and have `cqlsh`, `redis-cli`, and `yb-ctl` source it. Then, have each wrapper script get further variables as needed. These changes should not affect the `cqlsh`, `redis-cli`, and `yb-ctl` of releases because `yb_release_manifest.json` uses separate files, not those in `bin`. Close: yugabyte#3930 Test Plan: ```sh ./yb_build.sh asan ./bin/yb-ctl wipe_restart ./bin/cqlsh --execute "SHOW VERSION" ./bin/redis-cli "INFO" YB_THIRDPARTY_DIR=/does/not/exist ./bin/cqlsh # should fail ``` Reviewers: bogdan, rahuldesirazu, mikhail Reviewed By: mikhail Subscribers: ybase Differential Revision: https://phabricator.dev.yugabyte.com/D8129
- Loading branch information
Showing
6 changed files
with
99 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#@IgnoreInspection BashAddShebang | ||
|
||
# Copyright (c) YugaByte, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
# in compliance with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software distributed under the License | ||
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
# or implied. See the License for the specific language governing permissions and limitations under | ||
# the License. | ||
# | ||
|
||
# Common bash code for CLIs (e.g. cqlsh, yb-ctl). | ||
|
||
set -euo pipefail | ||
|
||
if [[ ${BASH_SOURCE[0]} == "$0" ]]; then | ||
echo "${BASH_SOURCE[0]} must be sourced, not executed" >&2 | ||
exit 1 | ||
fi | ||
|
||
# Guard against multiple inclusions. | ||
if [[ -n ${YB_COMMON_CLI_ENV_SOURCED:-} ]]; then | ||
# Return to the executing script. | ||
return | ||
fi | ||
|
||
readonly YB_COMMON_CLI_ENV_SOURCED=1 | ||
|
||
# shellcheck source=../build-support/common-build-env.sh | ||
. "${BASH_SOURCE%/*}/common-build-env.sh" | ||
|
||
# Get variable BUILD_ROOT if it is empty. | ||
set_build_root_from_latest_if_unset() { | ||
expect_num_args 0 "$@" | ||
if [[ -z ${BUILD_ROOT:-} ]]; then | ||
pushd "$YB_SRC_ROOT"/build/latest | ||
cd -P . | ||
handle_build_root_from_current_dir | ||
popd | ||
set_build_root | ||
else | ||
predefined_build_root=$BUILD_ROOT | ||
handle_predefined_build_root | ||
fi | ||
} | ||
|
||
# Get variable YB_THIRDPARTY_DIR if it is empty. | ||
set_yb_thirdparty_dir_if_unset() { | ||
expect_num_args 0 "$@" | ||
expect_vars_to_be_set BUILD_ROOT | ||
if [[ -z ${YB_THIRDPARTY_DIR:-} ]]; then | ||
find_or_download_thirdparty | ||
fi | ||
} | ||
|
||
set_build_root_from_latest_if_unset | ||
set_yb_thirdparty_dir_if_unset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters