BUILD_UB.sh changes to pick up new platform
[osm/SO.git] / BUILD_UB.sh
1 #!/usr/bin/env bash
2 #
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 #
17 # Author(s): Jeremy Mordkoff
18 # Creation Date: 8 Sep 2016 -- cloned from BUILD.sh and adapated for Ubuntu
19 #
20 #
21
22 # BUILD_UB.sh
23 #
24 # This is a top-level build script for RIFT.io
25 #
26 # Arguments and options: use -h or --help
27 #
28 # dependencies -- requires sudo rights
29
30 ###############################################################################
31 # Options and arguments
32
33 params="$(getopt -o suhb: -l install-so,install-ui,build-ui:,help --name "$0" -- "$@")"
34 if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
35
36 eval set -- $params
37
38 installSO=false
39 installUI=false
40 UIPathToBuild=
41
42 while true; do
43 case "$1" in
44 -s|--install-so) installSO=true; shift;;
45 -u|--install-ui) installUI=true; shift;;
46 -b|--build-ui) shift; UIPathToBuild=$1; shift;;
47 -h|--help)
48 echo
49 echo "NAME:"
50 echo " $0"
51 echo
52 echo "SYNOPSIS:"
53 echo " $0 -h|--help"
54 echo " $0 [-o] [-u|-b PATH-TO-UI-REPO] [PLATFORM_REPOSITORY] [PLATFORM_VERSION]"
55 echo
56 echo "DESCRIPTION:"
57 echo " Prepare current system to run SO and UI. By default, the system"
58 echo " is set up to support building SO and UI; optionally, either or"
59 echo " both SO and UI can be installed from a Debian package repository."
60 echo
61 echo " -o|--install-so: install SO from package"
62 echo " -u|--install-ui: install UI from package"
63 echo " -b|--build-ui PATH-TO-UI-REPO: build the UI in the specified repo"
64 echo " PLATFORM_REPOSITORY (optional): name of the RIFT.ware repository."
65 echo " PLATFORM_VERSION (optional): version of the platform packages to be installed."
66 echo
67 exit 0;;
68 --) shift; break;;
69 *) echo "Not implemented: $1" >&2; exit 1;;
70 esac
71 done
72
73 if $installUI && [[ $UIPathToBuild ]]; then
74 echo "Cannot both install and build the UI!"
75 exit 1
76 fi
77
78 if [[ $UIPathToBuild && ! -d $UIPathToBuild ]]; then
79 echo "Not a directory: $UIPathToBuild"
80 exit 1
81 fi
82
83
84 PLATFORM_REPOSITORY=${1:-OSM}
85 PLATFORM_VERSION=${2:-4.3.1.0.49556}
86
87 ###############################################################################
88 # Main block
89
90 # Turn these on after handling options, so the output doesn't get cluttered.
91 set -o errexit # Exit on any error
92 set -x # Print commands before executing them
93
94 # must be run from the top of a workspace
95 cd $(dirname $0)
96
97 # inside RIFT.io this is an NFS mount
98 # so just to be safe
99 test -h /usr/rift && sudo rm -f /usr/rift
100
101 # enable the right repos
102 curl http://repos.riftio.com/public/xenial-riftware-public-key | sudo apt-key add -
103 sudo curl -o /etc/apt/sources.list.d/${PLATFORM_REPOSITORY}.list http://buildtracker.riftio.com/repo_file/ub16/${PLATFORM_REPOSITORY}/
104 sudo apt-get update
105
106 # and install the tools
107 sudo apt remove -y rw.toolchain-rwbase tcpdump
108 sudo apt-get install -y rw.tools-container-tools rw.tools-scripts python
109
110 # enable the OSM repository hosted by RIFT.io
111 # this contains the RIFT platform code and tools
112 # and install of the packages required to build and run
113 # this module
114 sudo -H /usr/rift/container_tools/mkcontainer --modes build --modes ext --repo ${PLATFORM_REPOSITORY}
115
116
117
118 # install the RIFT platform code:
119 sudo apt-get install -y rw.toolchain-rwbase=${PLATFORM_VERSION} \
120 rw.toolchain-rwtoolchain=${PLATFORM_VERSION} \
121 rw.core.mgmt-mgmt=${PLATFORM_VERSION} \
122 rw.core.util-util=${PLATFORM_VERSION} \
123 rw.core.rwvx-rwvx=${PLATFORM_VERSION} \
124 rw.core.rwvx-rwdts=${PLATFORM_VERSION} \
125 rw.automation.core-RWAUTO=${PLATFORM_VERSION} \
126 rw.core.rwvx-rwha-1.0=${PLATFORM_VERSION}
127
128 sudo chmod 777 /usr/rift /usr/rift/usr/share
129
130 if $installSO; then
131 sudo apt-get install -y \
132 rw.core.mc-\*=${PLATFORM_VERSION}
133 fi
134
135 if $installUI; then
136 sudo apt-get install -y \
137 rw.ui-about=${PLATFORM_VERSION} \
138 rw.ui-logging=${PLATFORM_VERSION} \
139 rw.ui-skyquake=${PLATFORM_VERSION} \
140 rw.ui-accounts=${PLATFORM_VERSION} \
141 rw.ui-composer=${PLATFORM_VERSION} \
142 rw.ui-launchpad=${PLATFORM_VERSION} \
143 rw.ui-debug=${PLATFORM_VERSION} \
144 rw.ui-config=${PLATFORM_VERSION} \
145 rw.ui-dummy_component=${PLATFORM_VERSION}
146 fi
147
148 # install some base files used to create VNFs
149 test -d /usr/rift/images || mkdir /usr/rift/images
150 for 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
151 test -f /usr/rift/images/$file || curl -o /usr/rift/images/$file http://repo.riftio.com/releases/open.riftio.com/4.3.1/$file
152 done
153
154 # If you are re-building SO, you just need to run
155 # these two steps
156 if ! $installSO; then
157 make -j16
158 sudo make install
159 fi
160
161 if [[ $UIPathToBuild ]]; then
162 make -C $UIPathToBuild -j16
163 sudo make -C $UIPathToBuild install
164 fi
165
166 echo "To run SO with UI please run:"
167 echo 'sudo -H /usr/rift/rift-shell -r -i /usr/rift -a /usr/rift/.artifacts -- ./demos/launchpad.py --use-xml-mode'
168 echo
169 echo "To run SO without UI please run:"
170 echo 'sudo -H /usr/rift/rift-shell -r -i /usr/rift -a /usr/rift/.artifacts -- ./demos/launchpad.py --use-xml-mode --no-ui'