-
Notifications
You must be signed in to change notification settings - Fork 1
/
update_dependencies.sh
executable file
·66 lines (54 loc) · 2.13 KB
/
update_dependencies.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
echo -ne "\033[0;32m"
echo 'Updating bazel dependencies. This will take about five minutes.'
echo -ne "\033[0m"
set -e
if [ "$(uname -s)" == "Linux" ]; then
BAZEL_DEPS_URL=https://github.com/bazeltools/bazel-deps/releases/download/v0.1-38/bazel-deps-linux
BAZEL_DEPS_SHA256=273b5186b949b70369ba83c3ab85276eb1f8ac2087c0f3631e49c300e6e40d5e
elif [ "$(uname -s)" == "Darwin" ]; then
BAZEL_DEPS_URL=https://github.com/bazeltools/bazel-deps/releases/download/v0.1-38/bazel-deps-macos
BAZEL_DEPS_SHA256=ad38ecc1da37da32894e1b31df37da72d376c1fd1244f6f88acc2ebf4ca5fe89
else
echo "Your platform '$(uname -s)' is unsupported, sorry"
exit 1
fi
# This is some bash snippet designed to find the location of the script.
# we operate under the presumption this script is checked into the repo being operated on
# so we goto the script location, then use git to find the repo root.
SCRIPT_LOCATION="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $SCRIPT_LOCATION
REPO_ROOT=$(git rev-parse --show-toplevel)
BAZEL_DEPS_DIR="$HOME/.bazel-deps-cache"
BAZEL_DEPS_PATH="${BAZEL_DEPS_DIR}/v0.1-38"
if [ ! -f ${BAZEL_DEPS_PATH} ]; then
( # Opens a subshell
set -e
echo "Fetching bazel deps."
curl -L -o /tmp/bazel-deps-bin $BAZEL_DEPS_URL
GENERATED_SHA_256=$(shasum -a 256 /tmp/bazel-deps-bin | awk '{print $1}')
if [ "$GENERATED_SHA_256" != "$BAZEL_DEPS_SHA256" ]; then
echo "Sha 256 does not match, expected: $BAZEL_DEPS_SHA256"
echo "But found $GENERATED_SHA_256"
echo "You may need to update the sha in this script, or the download was corrupted."
exit 1
fi
chmod +x /tmp/bazel-deps-bin
mkdir -p ${BAZEL_DEPS_DIR}
mv /tmp/bazel-deps-bin ${BAZEL_DEPS_PATH}
)
fi
cd $REPO_ROOT
set +e
$BAZEL_DEPS_PATH generate -r $REPO_ROOT -s 3rdparty/workspace.bzl -d dependencies.yaml --target-file 3rdparty/target_file.bzl
RET_CODE=$?
set -e
if [ $RET_CODE == 0 ]; then
echo "Success, going to format files"
else
echo "Failure, checking out 3rdparty/jvm"
cd $REPO_ROOT
git checkout 3rdparty/jvm 3rdparty/workspace.bzl
exit $RET_CODE
fi
$BAZEL_DEPS_PATH format-deps -d $REPO_ROOT/dependencies.yaml -o