blob: 763ad1272cbb5bb530fad364a1690e7e74615307 [file] [log] [blame]
Leslie Giles1a1c87e2016-09-27 09:51:56 -04001#!/usr/bin/env bash
Jeremy Mordkoff6f07e6f2016-09-07 18:56:51 -04002#
3# Copyright 2016 RIFT.IO Inc
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
Leslie Giles1a1c87e2016-09-27 09:51:56 -040017# Author(s): Jeremy Mordkoff, Lezz Giles
Jeremy Mordkoff6f07e6f2016-09-07 18:56:51 -040018# Creation Date: 08/29/2016
19#
20#
21
22# BUILD.sh
23#
24# This is a top-level build script for RIFT.io
25#
Leslie Giles1a1c87e2016-09-27 09:51:56 -040026# Arguments and options: use -h or --help
Jeremy Mordkoff6f07e6f2016-09-07 18:56:51 -040027#
28# dependencies -- requires sudo rights
29
Leslie Giles202103e2016-09-27 13:23:40 -040030# Defensive bash programming flags
31set -o errexit # Exit on any error
32trap 'echo ERROR: Command failed: \"$BASH_COMMAND\"' ERR
33set -o nounset # Expanding an unset variable is an error. Variables must be
34 # set before they can be used.
35
Leslie Giles1a1c87e2016-09-27 09:51:56 -040036###############################################################################
37# Options and arguments
Jeremy Mordkoff6f07e6f2016-09-07 18:56:51 -040038
Leslie Giles202103e2016-09-27 13:23:40 -040039# There
40params="$(getopt -o suhb: -l install-so,install-ui,no-mkcontainer,build-ui:,help --name "$0" -- "$@")"
Leslie Giles1a1c87e2016-09-27 09:51:56 -040041if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
42
43eval set -- $params
44
45installSO=false
46installUI=false
Leslie Giles202103e2016-09-27 13:23:40 -040047runMkcontainer=true
Leslie Giles1a1c87e2016-09-27 09:51:56 -040048UIPathToBuild=
49
50while true; do
51 case "$1" in
52 -s|--install-so) installSO=true; shift;;
53 -u|--install-ui) installUI=true; shift;;
54 -b|--build-ui) shift; UIPathToBuild=$1; shift;;
Leslie Giles202103e2016-09-27 13:23:40 -040055 --no-mkcontainer) runMkcontainer=false; shift;;
Leslie Giles1a1c87e2016-09-27 09:51:56 -040056 -h|--help)
57 echo
58 echo "NAME:"
59 echo " $0"
60 echo
61 echo "SYNOPSIS:"
62 echo " $0 -h|--help"
63 echo " $0 [-s] [-u|-b PATH-TO-UI-REPO] [PLATFORM_REPOSITORY] [PLATFORM_VERSION]"
64 echo
65 echo "DESCRIPTION:"
66 echo " Prepare current system to run SO and UI. By default, the system"
67 echo " is set up to support building SO and UI; optionally, either or"
68 echo " both SO and UI can be installed from a Debian package repository."
69 echo
70 echo " -s|--install-so: install SO from package"
71 echo " -u|--install-ui: install UI from package"
72 echo " -b|--build-ui PATH-TO-UI-REPO: build the UI in the specified repo"
Leslie Giles202103e2016-09-27 13:23:40 -040073 echo " --no-mkcontainer: do not run mkcontainer, used for debugging script"
Leslie Giles1a1c87e2016-09-27 09:51:56 -040074 echo " PLATFORM_REPOSITORY (optional): name of the RIFT.ware repository."
75 echo " PLATFORM_VERSION (optional): version of the platform packages to be installed."
76 echo
77 exit 0;;
78 --) shift; break;;
79 *) echo "Not implemented: $1" >&2; exit 1;;
80 esac
81done
82
83if $installUI && [[ $UIPathToBuild ]]; then
84 echo "Cannot both install and build the UI!"
85 exit 1
86fi
87
88if [[ $UIPathToBuild && ! -d $UIPathToBuild ]]; then
89 echo "Not a directory: $UIPathToBuild"
90 exit 1
91fi
Jeremy Mordkoff6f07e6f2016-09-07 18:56:51 -040092
Leslie Giles202103e2016-09-27 13:23:40 -040093# Turn this on after handling options, so the output doesn't get cluttered.
94set -x # Print commands before executing them
95
96###############################################################################
97# Find the platform
Philip Josephf22a6842016-10-01 12:41:03 +053098PYTHON=python
99if [[ ! -f /usr/bin/python ]]; then
100 PYTHON=python3
101fi
102
103if $PYTHON -mplatform | grep -qi fedora; then
Leslie Giles202103e2016-09-27 13:23:40 -0400104 PLATFORM=fc20
Philip Josephf22a6842016-10-01 12:41:03 +0530105elif $PYTHON -mplatform | grep -qi ubuntu; then
Leslie Giles202103e2016-09-27 13:23:40 -0400106 PLATFORM=ub16
107else
108 echo "Unknown platform"
109 exit 1
110fi
111
112###############################################################################
113# Set up repo and version
114
115if [[ $PLATFORM == ub16 ]]; then
116 PLATFORM_REPOSITORY=${1:-OSM}
Jeremy Mordkoffa62b0362016-12-23 16:16:49 -0500117 PLATFORM_VERSION=${2:-4.3.1.0.53704}
Leslie Giles202103e2016-09-27 13:23:40 -0400118elif [[ $PLATFORM == fc20 ]]; then
119 PLATFORM_REPOSITORY=${1:-OSM} # change to OSM when published
Jeremy Mordkoffa62b0362016-12-23 16:16:49 -0500120 PLATFORM_VERSION=${2:-4.3.1.0.53705}
Leslie Giles202103e2016-09-27 13:23:40 -0400121else
122 echo "Internal error: unknown platform $PLATFORM"
123 exit 1
124fi
Jeremy Mordkoff6f07e6f2016-09-07 18:56:51 -0400125
Leslie Giles1a1c87e2016-09-27 09:51:56 -0400126###############################################################################
127# Main block
128
velandy839b5132016-12-15 22:09:55 +0000129# Disable apt-daily.service and apt-daily.timer
130
131DAILY_TIMER='apt-daily.timer'
132DAILY_SERVICE='apt-daily.service'
133if [ $(systemctl is-active $DAILY_TIMER) = "active" ]
134then
135 systemctl stop $DAILY_TIMER
136 systemctl disable $DAILY_TIMER
137 systemctl disable $DAILY_SERVICE
138fi
139
Jeremy Mordkoff6f07e6f2016-09-07 18:56:51 -0400140# must be run from the top of a workspace
141cd $(dirname $0)
142
Jeremy Mordkoff6f07e6f2016-09-07 18:56:51 -0400143# inside RIFT.io this is an NFS mount
144# so just to be safe
145test -h /usr/rift && sudo rm -f /usr/rift
146
Leslie Giles202103e2016-09-27 13:23:40 -0400147if [[ $PLATFORM == ub16 ]]; then
148 # enable the right repos
149 curl http://repos.riftio.com/public/xenial-riftware-public-key | sudo apt-key add -
Jeremy Mordkoff5adf16f2016-12-23 14:45:27 -0500150 # the old mkcontainer always enabled release which can be bad
151 # so remove it
152 sudo rm -f /etc/apt/sources.list.d/release
Leslie Giles202103e2016-09-27 13:23:40 -0400153 sudo curl -o /etc/apt/sources.list.d/${PLATFORM_REPOSITORY}.list http://buildtracker.riftio.com/repo_file/ub16/${PLATFORM_REPOSITORY}/
154 sudo apt-get update
155
156 # and install the tools
157 sudo apt remove -y rw.toolchain-rwbase tcpdump
Jeremy Mordkoff102d3682016-12-23 15:11:56 -0500158 sudo apt-get install -y --allow-downgrades rw.tools-container-tools=${PLATFORM_VERSION} rw.tools-scripts=${PLATFORM_VERSION} python
Leslie Giles202103e2016-09-27 13:23:40 -0400159elif [[ $PLATFORM == fc20 ]]; then
160 # get the container tools from the correct repository
161 sudo rm -f /etc/yum.repos.d/private.repo
162 sudo curl -o /etc/yum.repos.d/${PLATFORM_REPOSITORY}.repo \
163 http://buildtracker.riftio.com/repo_file/fc20/${PLATFORM_REPOSITORY}/
164 sudo yum install --assumeyes rw.tools-container-tools rw.tools-scripts
165else
166 echo "Internal error: unknown platform $PLATFORM"
167 exit 1
168fi
Jeremy Mordkoff6f07e6f2016-09-07 18:56:51 -0400169
170# enable the OSM repository hosted by RIFT.io
171# this contains the RIFT platform code and tools
172# and install of the packages required to build and run
173# this module
Leslie Giles202103e2016-09-27 13:23:40 -0400174if $runMkcontainer; then
Philip Joseph21fa51b2017-01-12 09:16:22 +0000175 if [[ $PLATFORM == ub16 ]]; then
176 sudo apt-get install -y libxml2-dev libxslt-dev python3-crypto
177 elif [[ $PLATFORM == fc20 ]]; then
178 sudo yum-install --assumeyes libxml2-devel libxslt-devel python3-crypto
179 fi
Philip Joseph23f42552016-12-13 11:29:53 +0530180 sudo /usr/rift/container_tools/mkcontainer --modes build --modes ext --repo ${PLATFORM_REPOSITORY}
Jeremy Mordkoff7f1ad762016-12-23 14:02:00 -0500181 sudo pip3 install lxml==3.4.0
Leslie Giles1a1c87e2016-09-27 09:51:56 -0400182fi
183
Leslie Giles202103e2016-09-27 13:23:40 -0400184
185if [[ $PLATFORM == ub16 ]]; then
186 # install the RIFT platform code:
Jeremy Mordkoffca8c6972016-11-18 11:30:28 -0500187 sudo apt-get install -y --allow-downgrades rw.toolchain-rwbase=${PLATFORM_VERSION} \
Leslie Giles202103e2016-09-27 13:23:40 -0400188 rw.toolchain-rwtoolchain=${PLATFORM_VERSION} \
189 rw.core.mgmt-mgmt=${PLATFORM_VERSION} \
190 rw.core.util-util=${PLATFORM_VERSION} \
191 rw.core.rwvx-rwvx=${PLATFORM_VERSION} \
192 rw.core.rwvx-rwdts=${PLATFORM_VERSION} \
193 rw.automation.core-RWAUTO=${PLATFORM_VERSION} \
194 rw.core.rwvx-rwha-1.0=${PLATFORM_VERSION}
chamarty867ed1d2016-12-15 15:38:49 +0000195
196 sudo apt-get install python-cinderclient
Leslie Giles202103e2016-09-27 13:23:40 -0400197
198 sudo chmod 777 /usr/rift /usr/rift/usr/share
199
200 if $installSO; then
201 sudo apt-get install -y \
Philip Josephc2ce5582017-02-07 17:02:46 -0500202 rw.core.mano-rwcal_yang_ylib-1.0 \
203 rw.core.mano-rwconfig_agent_yang_ylib-1.0 \
204 rw.core.mano-rwlaunchpad_yang_ylib-1.0 \
205 rw.core.mano-mano_yang_ylib-1.0 \
206 rw.core.mano-common-1.0 \
207 rw.core.mano-rwsdn_yang_ylib-1.0 \
208 rw.core.mano-mano-types_yang_ylib-1.0 \
209 rw.core.mano-rwcal-cloudsim-1.0 \
210 rw.core.mano-rwcal-1.0 \
211 rw.core.mano-rw_conman_yang_ylib-1.0 \
212 rw.core.mano-rwcalproxytasklet-1.0 \
213 rw.core.mano-rwlaunchpad-1.0 \
214 rw.core.mano-rwcal-openmano-vimconnector-1.0 \
215 rw.core.mano-rwcal-propcloud1-1.0 \
216 rw.core.mano-lpmocklet_yang_ylib-1.0 \
217 rw.core.mano-rwmon-1.0 \
218 rw.core.mano-rwcloud_yang_ylib-1.0 \
219 rw.core.mano-rwcal-openstack-1.0 \
220 rw.core.mano-rw.core.mano_foss \
221 rw.core.mano-rwmon_yang_ylib-1.0 \
222 rw.core.mano-rwcm-1.0 \
223 rw.core.mano-rwcal-mock-1.0 \
224 rw.core.mano-rwmano_examples-1.0 \
225 rw.core.mano-rwcal-cloudsimproxy-1.0 \
226 rw.core.mano-models-1.0 \
227 rw.core.mano-rwcal-aws-1.0
Leslie Giles202103e2016-09-27 13:23:40 -0400228 fi
229
230 if $installUI; then
231 sudo apt-get install -y \
Philip Josephc2ce5582017-02-07 17:02:46 -0500232 rw.ui-about \
233 rw.ui-logging \
234 rw.ui-skyquake \
235 rw.ui-accounts \
236 rw.ui-composer \
237 rw.ui-launchpad \
238 rw.ui-debug \
239 rw.ui-config \
240 rw.ui-dummy_component
Leslie Giles202103e2016-09-27 13:23:40 -0400241 fi
242elif [[ $PLATFORM == fc20 ]]; then
243
244 temp=$(mktemp -d /tmp/rw.XXX)
245 pushd $temp
246
247 # yum does not accept the --nodeps and --replacefiles options so we
248 # download first and then install
249 yumdownloader rw.toolchain-rwbase-${PLATFORM_VERSION} \
250 rw.toolchain-rwtoolchain-${PLATFORM_VERSION} \
251 rw.core.mgmt-mgmt-${PLATFORM_VERSION} \
252 rw.core.util-util-${PLATFORM_VERSION} \
253 rw.core.rwvx-rwvx-${PLATFORM_VERSION} \
254 rw.core.rwvx-rwha-1.0-${PLATFORM_VERSION} \
255 rw.core.rwvx-rwdts-${PLATFORM_VERSION} \
256 rw.automation.core-RWAUTO-${PLATFORM_VERSION}
257
258 # Install one at a time so that pre-installed packages will not cause a failure
259 for pkg in *rpm; do
260 # Check to see if the package is already installed; do not try to install
261 # it again if it does, since this causes rpm -i to return failure.
262 if rpm -q $(rpm -q -p $pkg) >/dev/null; then
263 echo "WARNING: package already installed: $pkg"
264 else
265 sudo rpm -i --replacefiles --nodeps $pkg
266 fi
267 done
268
269 popd
270 rm -rf $temp
271
272 # this file gets in the way of the one generated by the build
273 sudo rm -f /usr/rift/usr/lib/libmano_yang_gen.so
274
275
276 sudo chmod 777 /usr/rift /usr/rift/usr/share
277
278 if $installSO; then
279 sudo apt-get install -y \
280 rw.core.mc-\*-${PLATFORM_VERSION}
281 fi
282
283 if $installUI; then
284 sudo apt-get install -y \
285 rw.ui-about-${PLATFORM_VERSION} \
286 rw.ui-logging-${PLATFORM_VERSION} \
287 rw.ui-skyquake-${PLATFORM_VERSION} \
288 rw.ui-accounts-${PLATFORM_VERSION} \
289 rw.ui-composer-${PLATFORM_VERSION} \
290 rw.ui-launchpad-${PLATFORM_VERSION} \
291 rw.ui-debug-${PLATFORM_VERSION} \
292 rw.ui-config-${PLATFORM_VERSION} \
293 rw.ui-dummy_component-${PLATFORM_VERSION}
294 fi
295
296else
297 echo "Internal error: unknown platform $PLATFORM"
298 exit 1
Leslie Giles1a1c87e2016-09-27 09:51:56 -0400299fi
300
Jeremy Mordkoff6f07e6f2016-09-07 18:56:51 -0400301# install some base files used to create VNFs
302test -d /usr/rift/images || mkdir /usr/rift/images
303for file in Fedora-x86_64-20-20131211.1-sda-ping.qcow2 Fedora-x86_64-20-20131211.1-sda-pong.qcow2 Fedora-x86_64-20-20131211.1-sda.qcow2; do
304 test -f /usr/rift/images/$file || curl -o /usr/rift/images/$file http://repo.riftio.com/releases/open.riftio.com/4.3.1/$file
305done
306
Leslie Giles1a1c87e2016-09-27 09:51:56 -0400307# If you are re-building SO, you just need to run
Jeremy Mordkoff6f07e6f2016-09-07 18:56:51 -0400308# these two steps
Leslie Giles1a1c87e2016-09-27 09:51:56 -0400309if ! $installSO; then
310 make -j16
311 sudo make install
312fi
Jeremy Mordkoff6f07e6f2016-09-07 18:56:51 -0400313
Leslie Giles1a1c87e2016-09-27 09:51:56 -0400314if [[ $UIPathToBuild ]]; then
315 make -C $UIPathToBuild -j16
316 sudo make -C $UIPathToBuild install
317fi
318
Jeremy Mordkoffe4f094b2016-12-02 16:39:37 -0500319echo "Creating Service ...."
320sudo $(dirname $0)/create_launchpad_service
321