Fix version of libevel code used for vgmux
[demo.git] / vnfs / vCPE / scripts / v_gmux_build.sh
1 #!/bin/bash
2
3
4 VPP_SOURCE_REPO_URL=$(cat /opt/config/vpp_source_repo_url.txt)
5 VPP_SOURCE_REPO_RELEASE_TAG=$(cat /opt/config/vpp_source_repo_release_tag.txt)
6 VPP_PATCH_URL=$(cat /opt/config/vpp_patch_url.txt)
7 HC2VPP_SOURCE_REPO_URL=$(cat /opt/config/hc2vpp_source_repo_url.txt)
8 HC2VPP_SOURCE_REPO_RELEASE_TAG=$(cat /opt/config/hc2vpp_source_repo_release_tag.txt)
9 HC2VPP_PATCH_URL=$(cat /opt/config/hc2vpp_patch_url.txt)
10 LIBEVEL_PATCH_URL=$(cat /opt/config/libevel_patch_url.txt)
11 CLOUD_ENV=$(cat /opt/config/cloud_env.txt)
12 ERROR_MESSAGE="Execution of vG-MUX build script failed. Reason"
13
14 # Download required dependencies
15 echo "deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >>  /etc/apt/sources.list.d/java.list
16 echo "deb-src http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >>  /etc/apt/sources.list.d/java.list
17 apt-get update
18 apt-get install --allow-unauthenticated -y wget openjdk-8-jdk apt-transport-https ca-certificates g++ libcurl4-gnutls-dev
19 sleep 1
20
21 # Install the tools required for download codes
22 apt-get install -y expect git patch make linux-image-extra-`uname -r`
23
24 #Download and build the VPP codes
25 cd /opt
26 git clone ${VPP_SOURCE_REPO_URL} -b ${VPP_SOURCE_REPO_RELEASE_TAG} vpp
27 wget -O Vpp-Add-VES-agent-for-vG-MUX.patch ${VPP_PATCH_URL} 
28
29 cd vpp
30 patch -p1 < ../Vpp-Add-VES-agent-for-vG-MUX.patch
31 yes Y | make install-dep
32
33 # Check vpp build status
34 if [ $? -ne 0 ];
35 then
36     echo '$ERROR_MESSAGE VPP build failed' > /opt/script_status.txt 
37     exit
38 fi
39
40 # Install the evel-library first since we need the lib
41 cd /opt
42 apt-get install -y libcurl4-openssl-dev
43 git clone http://gerrit.onap.org/r/demo
44 wget -O vCPE-vG-MUX-libevel-fixup.patch ${LIBEVEL_PATCH_URL} 
45 cd demo
46 git checkout 3234c8ffab9faf85fd3bccfa720a3869ba39d13c
47 patch -p1 < ../vCPE-vG-MUX-libevel-fixup.patch
48 cd vnfs/VES5.0/evel/evel-library/bldjobs 
49 make
50
51 # Check eval-library installation status
52 if [ $? -ne 0 ];
53 then
54     echo '$ERROR_MESSAGE Installation of eval-library failed' > /opt/script_status.txt 
55     exit
56 fi
57
58
59 cp ../libs/x86_64/libevel.so /usr/lib
60 ldconfig
61
62 cd /opt/vpp/build-root
63 ./bootstrap.sh
64 make V=0 PLATFORM=vpp TAG=vpp install-deb
65
66 # Check vpp/build-root build status
67 if [ $? -ne 0 ];
68 then
69     echo '$ERROR_MESSAGE VPP/build-root build failed' > /opt/script_status.txt 
70     exit
71 fi
72
73 # Install the VPP package
74 apt install -y python-ply-lex-3.5 python-ply-yacc-3.5 python-pycparser python-cffi
75 dpkg -i *.deb
76
77 # Check VPP package installation status
78 if [ $? -ne 0 ];
79 then
80     echo '$ERROR_MESSAGE Installation of VPP package failed' > /opt/script_status.txt 
81     exit
82 fi
83 systemctl stop vpp
84
85
86 # Download and install HC2VPP from source
87 cd /opt
88 git clone ${HC2VPP_SOURCE_REPO_URL} -b ${HC2VPP_SOURCE_REPO_RELEASE_TAG} hc2vpp
89 wget -O Hc2vpp-Add-VES-agent-for-vG-MUX.patch ${HC2VPP_PATCH_URL}
90
91 apt-get install -y maven
92 mkdir -p ~/.m2
93 cat > ~/.m2/settings.xml << EOF
94 <?xml version="1.0" encoding="UTF-8"?>
95 <!-- vi: set et smarttab sw=2 tabstop=2: -->
96 <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
97   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
98   xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
99
100   <profiles>
101     <profile>
102       <id>fd.io-release</id>
103       <repositories>
104         <repository>
105           <id>fd.io-mirror</id>
106           <name>fd.io-mirror</name>
107           <url>https://nexus.fd.io/content/groups/public/</url>
108           <releases>
109             <enabled>true</enabled>
110             <updatePolicy>never</updatePolicy>
111           </releases>
112           <snapshots>
113             <enabled>false</enabled>
114           </snapshots>
115         </repository>
116       </repositories>
117       <pluginRepositories>
118         <pluginRepository>
119           <id>fd.io-mirror</id>
120           <name>fd.io-mirror</name>
121           <url>https://nexus.fd.io/content/repositories/public/</url>
122           <releases>
123             <enabled>true</enabled>
124             <updatePolicy>never</updatePolicy>
125           </releases>
126           <snapshots>
127             <enabled>false</enabled>
128           </snapshots>
129         </pluginRepository>
130       </pluginRepositories>
131     </profile>
132
133     <profile>
134       <id>fd.io-snapshots</id>
135       <repositories>
136         <repository>
137           <id>fd.io-snapshot</id>
138           <name>fd.io-snapshot</name>
139           <url>https://nexus.fd.io/content/repositories/fd.io.snapshot/</url>
140           <releases>
141             <enabled>false</enabled>
142           </releases>
143           <snapshots>
144             <enabled>true</enabled>
145           </snapshots>
146         </repository>
147       </repositories>
148       <pluginRepositories>
149         <pluginRepository>
150           <id>fd.io-snapshot</id>
151           <name>fd.io-snapshot</name>
152           <url>https://nexus.fd.io/content/repositories/fd.io.snapshot/</url>
153           <releases>
154             <enabled>false</enabled>
155           </releases>
156           <snapshots>
157             <enabled>true</enabled>
158           </snapshots>
159         </pluginRepository>
160       </pluginRepositories>
161     </profile>
162     <profile>
163       <id>opendaylight-snapshots</id>
164       <repositories>
165         <repository>
166           <id>opendaylight-snapshot</id>
167           <name>opendaylight-snapshot</name>
168           <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
169           <releases>
170             <enabled>false</enabled>
171           </releases>
172           <snapshots>
173             <enabled>true</enabled>
174           </snapshots>
175         </repository>
176       </repositories>
177       <pluginRepositories>
178         <pluginRepository>
179           <id>opendaylight-shapshot</id>
180           <name>opendaylight-snapshot</name>
181           <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
182           <releases>
183             <enabled>false</enabled>
184           </releases>
185           <snapshots>
186             <enabled>true</enabled>
187           </snapshots>
188         </pluginRepository>
189       </pluginRepositories>
190     </profile>
191   </profiles>
192
193   <activeProfiles>
194     <activeProfile>fd.io-release</activeProfile>
195     <activeProfile>fd.io-snapshots</activeProfile>
196     <activeProfile>opendaylight-snapshots</activeProfile>
197   </activeProfiles>
198 </settings>
199 EOF
200
201 cd hc2vpp
202 patch -p1 < ../Hc2vpp-Add-VES-agent-for-vG-MUX.patch
203 p_version_snap=$(cat ves/ves-impl/pom.xml | grep -A 1 "jvpp-ves" | tail -1)
204 p_version_snap=$(echo "${p_version_snap%<*}")
205 p_version_snap=$(echo "${p_version_snap#*>}")
206 p_version=$(echo "${p_version_snap%-*}")
207 mkdir -p  ~/.m2/repository/io/fd/vpp/jvpp-ves/${p_version_snap}
208 mvn install:install-file -Dfile=/usr/share/java/jvpp-ves-${p_version}.jar -DgroupId=io.fd.vpp -DartifactId=jvpp-ves -Dversion=${p_version_snap} -Dpackaging=jar
209 mvn clean install -nsu -DskipTests=true
210
211 # Check hc2vpp installation status
212 if [ $? -ne 0 ];
213 then
214     echo '$ERROR_MESSAGE Installation of hc2vpp failed' > /opt/script_status.txt 
215     exit
216 fi
217
218 l_version=$(cat pom.xml | grep "<version>" | head -1)
219 l_version=$(echo "${l_version%<*}")
220 l_version=$(echo "${l_version#*>}")
221 mv vpp-integration/minimal-distribution/target/vpp-integration-distribution-${l_version}-hc/vpp-integration-distribution-${l_version} /opt/honeycomb
222 sed -i 's/127.0.0.1/0.0.0.0/g' /opt/honeycomb/config/honeycomb.json
223
224 # Disable automatic upgrades
225 if [[ $CLOUD_ENV != "rackspace" ]]
226 then
227     echo "APT::Periodic::Unattended-Upgrade \"0\";" >> /etc/apt/apt.conf.d/10periodic
228     sed -i 's/\(APT::Periodic::Unattended-Upgrade\) "1"/\1 "0"/' /etc/apt/apt.conf.d/20auto-upgrades
229 fi
230
231 echo 'Execution of vG-MUX build script completed' > /opt/script_status.txt
232