Skip to content

Commit

Permalink
dev.env: Fix all shellcheck linter errors.
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Berlin <mberlin@google.com>
  • Loading branch information
michael-berlin committed Apr 9, 2018
1 parent 3718458 commit 9a6f21e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 45 deletions.
91 changes: 46 additions & 45 deletions dev.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -14,14 +16,16 @@

# Import prepend_path function.
dir="$(dirname "${BASH_SOURCE[0]}")"
source "${dir}/tools/shell_functions.inc"
if [ $? -ne 0 ]; then
# shellcheck source=tools/shell_functions.inc
if ! source "${dir}/tools/shell_functions.inc"; then
echo "failed to load tools/shell_functions.inc"
return 1
fi

export VTTOP=$(pwd)
export VTROOT="${VTROOT:-${VTTOP/\/src\/vitess.io\/vitess/}}"
VTTOP=$(pwd)
export VTTOP
VTROOT="${VTROOT:-${VTTOP/\/src\/vitess.io\/vitess/}}"
export VTROOT
# VTTOP sanity check
if [[ "$VTTOP" == "${VTTOP/\/src\/vitess.io\/vitess/}" ]]; then
echo "WARNING: VTTOP($VTTOP) does not contain src/vitess.io/vitess"
Expand All @@ -30,53 +34,52 @@ export GOTOP=$VTTOP/go
export PYTOP=$VTTOP/py

export VTDATAROOT="${VTDATAROOT:-${VTROOT}/vtdataroot}"
mkdir -p $VTDATAROOT
mkdir -p "$VTDATAROOT"

export VTPORTSTART=15000

for pypath in $(find $VTROOT/dist -name site-packages -or -name dist-packages | grep -v src/python/grpcio/.tox/py27/lib/python2.7/site-packages)
do
export PYTHONPATH=$(prepend_path "$PYTHONPATH" "$pypath")
done

export PYTHONPATH=$(prepend_path "$PYTHONPATH" "$VTROOT/py-vtdb")
export PYTHONPATH=$(prepend_path "$PYTHONPATH" "$VTTOP/test")
export PYTHONPATH=$(prepend_path "$PYTHONPATH" "$VTTOP/test/cluster/sandbox")

# Ensure bootstrap and install_grpc use python2 on systems which default to python3
# Add all site-packages or dist-packages directories below $VTROOT/dist to $PYTHONPATH.
while IFS= read -r -d '' pypath; do
PYTHONPATH=$(prepend_path "$PYTHONPATH" "$pypath")
# Note that the escaped ( ) around the -or expression are important.
# Otherwise, the -print0 would match *all* files.
done < <(find "$VTROOT/dist" \( -name site-packages -or -name dist-packages \) -print0)
PYTHONPATH=$(prepend_path "$PYTHONPATH" "$VTROOT/py-vtdb")
PYTHONPATH=$(prepend_path "$PYTHONPATH" "$VTROOT/dist/selenium")
PYTHONPATH=$(prepend_path "$PYTHONPATH" "$VTTOP/test")
PYTHONPATH=$(prepend_path "$PYTHONPATH" "$VTTOP/test/cluster/sandbox")
export PYTHONPATH

# Ensure bootstrap.sh uses python2 on systems which default to python3.
command -v python2 >/dev/null && PYTHON=python2 || PYTHON=python
export PYTHON
command -v pip2 >/dev/null && PIP=pip2 || PIP=pip
export PIP
command -v virtualenv2 >/dev/null && VIRTUALENV=virtualenv2 || VIRTUALENV=virtualenv
export VIRTUALENV

selenium_dist=$VTROOT/dist/selenium
export PYTHONPATH=$(prepend_path "$PYTHONPATH" "$selenium_dist")

# Add the current GOBIN
if [ "$GOBIN" ]; then
export PATH=$(prepend_path "$PATH" "$GOBIN")
PATH=$(prepend_path "$PATH" "$GOBIN")
fi

# Many tests rely on "go install" and assume GOBIN is really $VTROOT/bin.
# Make sure these take precedence.
export GOBIN=$VTROOT/bin
export PATH=$(prepend_path "$PATH" "$GOBIN")
GOBIN=$VTROOT/bin
export GOBIN
PATH=$(prepend_path "$PATH" "$GOBIN")

# If we have a custom built mysql, prefer it over the default installation.
export PATH=$(prepend_path "$PATH" "$VTROOT/dist/mysql/bin")
# Add chromedriver to path for Selenium tests.
PATH=$(prepend_path "$PATH" "$VTROOT/dist/chromedriver")

# Add chromedriver to path for selenium tests
export PATH=$(prepend_path "$PATH" "$VTROOT/dist/chromedriver")

# Node path
export PATH=$(prepend_path "$PATH" "$VTROOT/dist/node/bin")
# Node path.
PATH=$(prepend_path "$PATH" "$VTROOT/dist/node/bin")
export PATH

# GOROOT sanity
go_bin=`which go`
go_env=`go env | grep GOROOT | cut -f 2 -d\"`
if [ "$go_bin" -a "$go_bin" != "$go_env/bin/go" ]; then
go_bin=$(which go)
go_env=$(go env | grep GOROOT | cut -f 2 -d\")
if [[ "$go_bin" != "" && "$go_bin" != "$go_env/bin/go" ]]; then
echo "WARNING: \$GOROOT may not be compatible with the used go binary"
echo "Please make sure 'go' comes from \$GOROOT/bin"
echo "go_env: $go_env"
Expand All @@ -90,30 +93,28 @@ if [[ "$VT_MYSQL_ROOT" == "" ]]; then
if [[ "$(which mysql)" == "" ]]; then
echo "WARNING: VT_MYSQL_ROOT unset because mysql not found. Did you install a client package?"
else
export VT_MYSQL_ROOT=$(dirname $(dirname $(which mysql)))
VT_MYSQL_ROOT=$(dirname "$(dirname "$(which mysql)")")
export VT_MYSQL_ROOT
fi
fi

# restore MYSQL_FLAVOR, saved by bootstrap.sh
if [ -r $VTROOT/dist/MYSQL_FLAVOR ]; then
export MYSQL_FLAVOR=`cat $VTROOT/dist/MYSQL_FLAVOR`
if [ -r "$VTROOT/dist/MYSQL_FLAVOR" ]; then
MYSQL_FLAVOR=$(cat "$VTROOT/dist/MYSQL_FLAVOR")
export MYSQL_FLAVOR
fi

# mysql cgo library config
if [ -z "$MYSQL_FLAVOR" ]; then
export MYSQL_FLAVOR=MariaDB
fi
export PKG_CONFIG_PATH=$(prepend_path "$PKG_CONFIG_PATH" "$VTROOT/lib")

# needed to correctly import grpc if it's not installed globally
grpc_dist=$VTROOT/dist/grpc
if [ -f $grpc_dist/.build_finished ]; then
export LD_LIBRARY_PATH=$(prepend_path "$LD_LIBRARY_PATH" "$grpc_dist/usr/local/lib")
fi
PKG_CONFIG_PATH=$(prepend_path "$PKG_CONFIG_PATH" "$VTROOT/lib")
export PKG_CONFIG_PATH

export GOPATH=$(prepend_path "$GOPATH" "$VTROOT")
GOPATH=$(prepend_path "$GOPATH" "$VTROOT")
export GOPATH

# Useful aliases. Remove if inconvenient.
alias gt="cd $GOTOP"
alias pt="cd $PYTOP"
alias vt="cd $VTTOP"
alias gt='cd $GOTOP'
alias pt='cd $PYTOP'
alias vt='cd $VTTOP'
2 changes: 2 additions & 0 deletions tools/shell_functions.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down

0 comments on commit 9a6f21e

Please sign in to comment.