Add options to fc20 BUILD.sh to install prebuilt SO and UI
[osm/SO.git] / BUILD.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, Lezz Giles
18 # Creation Date: 08/29/2016
19 #
20 #
21
22 # BUILD.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 [-s] [-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 " -s|--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 PLATFORM_REPOSITORY=${1:-OSM} # change to OSM when published
84 PLATFORM_VERSION=${2:-4.3.1.0.49553-1}
85
86 ###############################################################################
87 # Main block
88
89 # Turn these on after handling options, so the output doesn't get cluttered.
90 set -o errexit # Exit on any error
91 set -x # Print commands before executing them
92
93 # must be run from the top of a workspace
94 cd $(dirname $0)
95
96
97
98
99 # inside RIFT.io this is an NFS mount
100 # so just to be safe
101 test -h /usr/rift && sudo rm -f /usr/rift
102
103 # get the container tools from the correct repository
104 sudo rm -f /etc/yum.repos.d/private.repo
105 sudo curl -o /etc/yum.repos.d/${PLATFORM_REPOSITORY}.repo \
106 http://buildtracker.riftio.com/repo_file/fc20/${PLATFORM_REPOSITORY}/
107 sudo yum install --assumeyes rw.tools-container-tools rw.tools-scripts
108
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 /usr/rift/container_tools/mkcontainer --modes build --modes ext --repo ${PLATFORM_REPOSITORY}
115
116 temp=$(mktemp -d /tmp/rw.XXX)
117 pushd $temp
118
119 # yum does not accept the --nodeps and --replacefiles options so we
120 # download first and then install
121 yumdownloader rw.toolchain-rwbase-${PLATFORM_VERSION} \
122 rw.toolchain-rwtoolchain-${PLATFORM_VERSION} \
123 rw.core.mgmt-mgmt-${PLATFORM_VERSION} \
124 rw.core.util-util-${PLATFORM_VERSION} \
125 rw.core.rwvx-rwvx-${PLATFORM_VERSION} \
126 rw.core.rwvx-rwha-1.0-${PLATFORM_VERSION} \
127 rw.core.rwvx-rwdts-${PLATFORM_VERSION} \
128 rw.automation.core-RWAUTO-${PLATFORM_VERSION}
129
130 sudo rpm -i --replacefiles --nodeps *rpm
131 popd
132 rm -rf $temp
133
134 # this file gets in the way of the one generated by the build
135 sudo rm -f /usr/rift/usr/lib/libmano_yang_gen.so
136
137
138 sudo chmod 777 /usr/rift /usr/rift/usr/share
139
140 if $installSO; then
141 sudo apt-get install -y \
142 rw.core.mc-\*-${PLATFORM_VERSION}
143 fi
144
145 if $installUI; then
146 sudo apt-get install -y \
147 rw.ui-about-${PLATFORM_VERSION} \
148 rw.ui-logging-${PLATFORM_VERSION} \
149 rw.ui-skyquake-${PLATFORM_VERSION} \
150 rw.ui-accounts-${PLATFORM_VERSION} \
151 rw.ui-composer-${PLATFORM_VERSION} \
152 rw.ui-launchpad-${PLATFORM_VERSION} \
153 rw.ui-debug-${PLATFORM_VERSION} \
154 rw.ui-config-${PLATFORM_VERSION} \
155 rw.ui-dummy_component-${PLATFORM_VERSION}
156 fi
157
158 # install some base files used to create VNFs
159 test -d /usr/rift/images || mkdir /usr/rift/images
160 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
161 test -f /usr/rift/images/$file || curl -o /usr/rift/images/$file http://repo.riftio.com/releases/open.riftio.com/4.3.1/$file
162 done
163
164 # If you are re-building SO, you just need to run
165 # these two steps
166 if ! $installSO; then
167 make -j16
168 sudo make install
169 fi
170
171 if [[ $UIPathToBuild ]]; then
172 make -C $UIPathToBuild -j16
173 sudo make -C $UIPathToBuild install
174 fi
175
176 echo "To run SO with UI please run:"
177 echo 'sudo -H /usr/rift/rift-shell -r -i /usr/rift -a /usr/rift/.artifacts -- ./demos/launchpad.py --use-xml-mode'
178 echo
179 echo "To run SO without UI please run:"
180 echo 'sudo -H /usr/rift/rift-shell -r -i /usr/rift -a /usr/rift/.artifacts -- ./demos/launchpad.py --use-xml-mode --no-ui'