-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbazel.sh
executable file
·50 lines (40 loc) · 1.68 KB
/
bazel.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
#!/usr/bin/env bash
# Exit on error
set -e
sudo -v
JAVA_CHECK="$(java -version 2>&1)"
if [[ "$JAVA_CHECK" == *"Java(TM) SE Runtime Environment"* ]]; then
echo -n "Installing BazelBuild ..."
else
Distribution_ID="$(lsb_release -is)"
Codename="$(lsb_release -cs)"
if [ "$(Distribution_ID)" == "Debian" ]; then
Codename="xenial"
Distribution_ID="debian"
else
Distribution_ID="ubuntu"
fi
# Add webupd8team java package
sudo sh -c "echo 'deb [arch=amd64] http://ppa.launchpad.net/webupd8team/java/ubuntu ${Codename} main' > /etc/apt/sources.list.d/webupd8team-${Distribution_ID}-java-${Codename}.list"
sudo sh -c "echo 'deb [arch=amd64] http://ppa.launchpad.net/webupd8team/java/ubuntu ${Codename} main' > /etc/apt/sources.list.d/webupd8team-${Distribution_ID}-java-${Codename}.list.save"
# Add gpg key
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 7B2C3B0889BF5709A105D03AC2518248EEA14886 >/dev/null 2>&1
# Installing JAVA(Default is JAVA8)
sudo apt-get update >/dev/null
sudo apt-get -y install oracle-java8-installer >/dev/null
fi
# Adding Bazel distribution URI as a package source
echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list >/dev/null
curl -sSL https://bazel.build/bazel-release.pub.gpg | sudo apt-key add - >/dev/null 2>&1
# Update packages and Installs Bazel latest version
sudo apt-get update >/dev/null
sudo apt-get install bazel -y >/dev/null 2>&1
# Verify and exit installation
BAZEL_CHECK="$(bazel version)"
if [[ "$BAZEL_CHECK" == *"Build label"* ]]; then
echo -e "\\033[0;32m[OK]\\033[0m"
exit 0
else
echo -e "\\033[0;31m[FAILED]\\033[0m"
exit 1
fi