forked from CiscoDevNet/ydk-py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdependencies_xenial.sh
executable file
·81 lines (70 loc) · 2.48 KB
/
dependencies_xenial.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
function print_msg {
echo -e "$MSG_COLOR*** $(date): dependencies_xenial.sh | $@ $NOCOLOR"
}
function run_cmd {
print_msg "Running command: $@"
$@
local status=$?
if [ $status -ne 0 ]; then
MSG_COLOR=$RED
print_msg "Exiting '$@' with status=$status"
exit $status
fi
return $status
}
function check_install_gcc {
print_msg "Checking g++ installation"
which g++
local status=$?
if [[ $status == 0 ]]
then
gpp_version=$(echo $(g++ --version) | awk '{ print $3 }' | cut -d '-' -f 1)
print_msg "Current g++ version is $gpp_version"
else
print_msg "The g++ is not installed"
gpp_version="4.0"
fi
if [[ $(echo $gpp_version | cut -d '.' -f 1) < 5 ]]
then
print_msg "Upgrading gcc/g++ to version 5"
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt-get update > /dev/null
sudo apt-get install gcc-5 g++-5 -y > /dev/null
sudo ln -fs /usr/bin/g++-5 /usr/bin/c++
sudo ln -fs /usr/bin/gcc-5 /usr/bin/cc
gcc_version=$(echo $(gcc --version) | awk '{ print $3 }' | cut -d '-' -f 1)
print_msg "Installed gcc version is $gcc_version"
gpp_version=$(echo $(g++ --version) | awk '{ print $3 }' | cut -d '-' -f 1)
print_msg "Installed g++ version is $gpp_version"
fi
}
function install_ydk_core {
print_msg "Installing YDK core and gNMI service libraries"
if [[ $os_info == *"xenial"* ]]; then
run_cmd wget https://devhub.cisco.com/artifactory/debian-ydk/0.8.3/xenial/libydk-0.8.3-1.amd64.deb
run_cmd wget https://devhub.cisco.com/artifactory/debian-ydk/0.8.3/xenial/libydk_gnmi-0.4.0-2.amd64.deb
elif [[ $os_info == *"bionic"* ]]; then
run_cmd wget https://devhub.cisco.com/artifactory/debian-ydk/0.8.3/bionic/libydk-0.8.3-1.amd64.deb
run_cmd wget https://devhub.cisco.com/artifactory/debian-ydk/0.8.3/bionic/libydk_gnmi-0.4.0-2.amd64.deb
else
MSG_COLOR=$RED
print_msg "There are no pre-compiled YDK libraries for this Linux distribution"
exit 1
fi
gdebi -n libydk-0.8.3-1.amd64.deb
gdebi -n libydk_gnmi-0.4.0-2.amd64.deb
}
# Terminal colors
RED="\033[0;31m"
NOCOLOR="\033[0m"
YELLOW='\033[1;33m'
MSG_COLOR=$YELLOW
os_info=$(cat /etc/*-release)
print_msg "OS info: $os_info"
apt-get update -y > /dev/null
apt-get install gdebi-core python-dev python-pip python3-dev python3-pip libtool-bin wget sudo unzip git -y
apt-get install libpcre3-dev libpcre++-dev libssh-dev libxml2-dev libxslt1-dev -y
check_install_gcc
./dependencies_gnmi.sh
install_ydk_core