forked from scionproto/scion
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch.sh
More file actions
executable file
·55 lines (47 loc) · 1.33 KB
/
fetch.sh
File metadata and controls
executable file
·55 lines (47 loc) · 1.33 KB
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
#!/bin/bash
# This script will create a fake BUILD.bazel file that
# can be used to fetch all external dependencies.
# After the file is generated and stored along the WORKSPACE
# do "bazel fetch //:fetch" to actually dowload the repos.
set -e
ROOTDIR=$(dirname "$0")/..
# Add any bazel packages to prefetch to the beginning of the following block.
cat <<EOF
load("@com_github_jmhodges_bazel_gomock//:gomock.bzl", "gomock")
load("@io_bazel_rules_go//go:def.bzl", "nogo")
nogo(
name = "nogo",
visibility = ["//visibility:public"],
)
genrule(
name = "fetch",
outs = ["dummy"],
cmd = "touch dummy",
tools = [
"@debian_stretch//file:Packages.json",
"@package_bundle//file:packages.bzl",
EOF
cat $ROOTDIR/WORKSPACE \
| sed -n -e '/# Dependencies/,$p' \
| grep -E "name|importpath" \
| sed 'N;s/\n/ /' \
| grep -v com_github_jmhodges_bazel_gomock \
| while IFS=" " read -r LINE
do
if [[ $LINE =~ \"(.*)\".*\".*\" ]]; then
NAME=${BASH_REMATCH[1]}
else
echo "External dependency name not found: $LINE"
exit 1
fi
if [[ $LINE =~ \#[[:blank:]]*(.*) ]]; then
NAME=$NAME//${BASH_REMATCH[1]}
else
NAME=$NAME//
fi
echo " \"@$NAME:go_default_library\","
done
cat <<EOF
]
)
EOF