3 # Copyright 2016 RIFT.IO Inc
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 # Author(s): Jeremy Mordkoff, Lezz Giles
18 # Creation Date: 08/29/2016
24 # This is a top-level build script for RIFT.io
26 # Arguments and options: use -h or --help
28 # dependencies -- requires sudo rights
30 # Defensive bash programming flags
31 set -o errexit
# Exit on any error
32 trap 'echo ERROR: Command failed: \"$BASH_COMMAND\"' ERR
33 set -o nounset
# Expanding an unset variable is an error. Variables must be
34 # set before they can be used.
36 ###############################################################################
37 # Options and arguments
40 params
="$(getopt -o suhb: -l install-so,install-ui,no-mkcontainer,build-ui:,help --name "$0" -- "$@
")"
41 if [ $?
!= 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
52 -s|
--install-so) installSO
=true
; shift;;
53 -u|
--install-ui) installUI
=true
; shift;;
54 -b|
--build-ui) shift; UIPathToBuild
=$1; shift;;
55 --no-mkcontainer) runMkcontainer
=false
; shift;;
63 echo " $0 [-s] [-u|-b PATH-TO-UI-REPO] [PLATFORM_REPOSITORY] [PLATFORM_VERSION]"
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."
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"
73 echo " --no-mkcontainer: do not run mkcontainer, used for debugging script"
74 echo " PLATFORM_REPOSITORY (optional): name of the RIFT.ware repository."
75 echo " PLATFORM_VERSION (optional): version of the platform packages to be installed."
79 *) echo "Not implemented: $1" >&2; exit 1;;
83 if $installUI && [[ $UIPathToBuild ]]; then
84 echo "Cannot both install and build the UI!"
88 if [[ $UIPathToBuild && ! -d $UIPathToBuild ]]; then
89 echo "Not a directory: $UIPathToBuild"
93 # Turn this on after handling options, so the output doesn't get cluttered.
94 set -x # Print commands before executing them
96 ###############################################################################
99 if [[ ! -f /usr
/bin
/python
]]; then
103 if $PYTHON -mplatform |
grep -qi fedora
; then
105 elif $PYTHON -mplatform |
grep -qi ubuntu
; then
108 echo "Unknown platform"
112 ###############################################################################
113 # Set up repo and version
115 if [[ $PLATFORM == ub16
]]; then
116 PLATFORM_REPOSITORY
=${1:-OSM}
117 PLATFORM_VERSION
=${2:-4.4.0.0.57702}
118 elif [[ $PLATFORM == fc20
]]; then
119 PLATFORM_REPOSITORY
=${1:-OSM} # change to OSM when published
120 PLATFORM_VERSION
=${2:-4.3.1.0.53705}
122 echo "Internal error: unknown platform $PLATFORM"
126 ###############################################################################
129 # Disable apt-daily.service and apt-daily.timer
131 DAILY_TIMER
='apt-daily.timer'
132 DAILY_SERVICE
='apt-daily.service'
133 if [ $
(systemctl is-active
$DAILY_TIMER) = "active" ]
135 systemctl stop
$DAILY_TIMER
136 systemctl disable
$DAILY_TIMER
137 systemctl disable
$DAILY_SERVICE
140 # must be run from the top of a workspace
143 # inside RIFT.io this is an NFS mount
145 test -h /usr
/rift
&& sudo
rm -f /usr
/rift
147 if [[ $PLATFORM == ub16
]]; then
148 # enable the right repos
149 curl http
://repos.riftio.com
/public
/xenial-riftware-public-key | sudo apt-key add
-
150 # the old mkcontainer always enabled release which can be bad
152 sudo
rm -f /etc
/apt
/sources.list.d
/release.list
/etc
/apt
/sources.list.d
/rbac.list
/etc
/apt
/sources.list.d
/OSM.list
153 # always use the same file name so that updates will overwrite rather than enable a second repo
154 sudo curl
-o /etc
/apt
/sources.list.d
/RIFT.list http
://buildtracker.riftio.com
/repo_file
/ub16
/${PLATFORM_REPOSITORY}/
157 # and install the tools
158 sudo apt remove
-y rw.toolchain-rwbase tcpdump
159 sudo apt-get
install -y --allow-downgrades rw.tools-container-tools
=${PLATFORM_VERSION} rw.tools-scripts
=${PLATFORM_VERSION} python
160 elif [[ $PLATFORM == fc20
]]; then
161 # get the container tools from the correct repository
162 sudo
rm -f /etc
/yum.repos.d
/private.repo
163 sudo curl
-o /etc
/yum.repos.d
/${PLATFORM_REPOSITORY}.repo \
164 http
://buildtracker.riftio.com
/repo_file
/fc20
/${PLATFORM_REPOSITORY}/
165 sudo yum
install --assumeyes rw.tools-container-tools rw.tools-scripts
167 echo "Internal error: unknown platform $PLATFORM"
171 # enable the OSM repository hosted by RIFT.io
172 # this contains the RIFT platform code and tools
173 # and install of the packages required to build and run
175 if $runMkcontainer; then
176 sudo apt-get
install -y libxml2-dev libxslt-dev
177 sudo
/usr
/rift
/container_tools
/mkcontainer
--modes build
--modes ext
--repo ${PLATFORM_REPOSITORY}
178 sudo pip3
install lxml
==3.4.0
182 if [[ $PLATFORM == ub16
]]; then
183 # install the RIFT platform code:
184 # remove these packages since some files moved from one to the other, and one was obsoleted
187 PACKAGES
="rw.toolchain-rwbase rw.toolchain-rwtoolchain rw.core.mgmt-mgmt rw.core.util-util \
188 rw.core.rwvx-rwvx rw.core.rwvx-rwdts rw.automation.core-RWAUTO"
189 # this package is obsolete.
190 OLD_PACKAGES
="rw.core.rwvx-rwha-1.0"
191 for package
in $PACKAGES $OLD_PACKAGES; do
192 sudo apt remove
-y $package || true
196 for package
in $PACKAGES; do
197 packages
="$packages $package=${PLATFORM_VERSION}"
199 sudo apt-get
install -y --allow-downgrades $packages
201 sudo apt-get
install python-cinderclient
203 sudo
chmod 777 /usr
/rift
/usr
/rift
/usr
/share
206 sudo apt-get
install -y \
207 rw.core.mano-rwcal_yang_ylib-1.0 \
208 rw.core.mano-rwconfig_agent_yang_ylib-1.0 \
209 rw.core.mano-rwlaunchpad_yang_ylib-1.0 \
210 rw.core.mano-mano_yang_ylib-1.0 \
211 rw.core.mano-common-1.0 \
212 rw.core.mano-rwsdn_yang_ylib-1.0 \
213 rw.core.mano-mano-types_yang_ylib-1.0 \
214 rw.core.mano-rwcal-cloudsim-1.0 \
215 rw.core.mano-rwcal-1.0 \
216 rw.core.mano-rw_conman_yang_ylib-1.0 \
217 rw.core.mano-rwcalproxytasklet-1.0 \
218 rw.core.mano-rwlaunchpad-1.0 \
219 rw.core.mano-rwcal-openmano-vimconnector-1.0 \
220 rw.core.mano-rwcal-propcloud1-1.0 \
221 rw.core.mano-lpmocklet_yang_ylib-1.0 \
222 rw.core.mano-rwmon-1.0 \
223 rw.core.mano-rwcloud_yang_ylib-1.0 \
224 rw.core.mano-rwcal-openstack-1.0 \
225 rw.core.mano-rw.core.mano_foss \
226 rw.core.mano-rwmon_yang_ylib-1.0 \
227 rw.core.mano-rwcm-1.0 \
228 rw.core.mano-rwcal-mock-1.0 \
229 rw.core.mano-rwmano_examples-1.0 \
230 rw.core.mano-rwcal-cloudsimproxy-1.0 \
231 rw.core.mano-models-1.0 \
232 rw.core.mano-rwcal-aws-1.0
236 sudo apt-get
install -y \
245 rw.ui-dummy_component
247 elif [[ $PLATFORM == fc20
]]; then
249 temp
=$
(mktemp
-d /tmp
/rw.XXX
)
252 # yum does not accept the --nodeps and --replacefiles options so we
253 # download first and then install
254 yumdownloader rw.toolchain-rwbase-
${PLATFORM_VERSION} \
255 rw.toolchain-rwtoolchain-
${PLATFORM_VERSION} \
256 rw.core.mgmt-mgmt-
${PLATFORM_VERSION} \
257 rw.core.util-util-
${PLATFORM_VERSION} \
258 rw.core.rwvx-rwvx-
${PLATFORM_VERSION} \
259 rw.core.rwvx-rwha-1.0
-${PLATFORM_VERSION} \
260 rw.core.rwvx-rwdts-
${PLATFORM_VERSION} \
261 rw.automation.core-RWAUTO-
${PLATFORM_VERSION}
263 # Install one at a time so that pre-installed packages will not cause a failure
265 # Check to see if the package is already installed; do not try to install
266 # it again if it does, since this causes rpm -i to return failure.
267 if rpm
-q $
(rpm
-q -p $pkg) >/dev
/null
; then
268 echo "WARNING: package already installed: $pkg"
270 sudo rpm
-i --replacefiles --nodeps $pkg
277 # this file gets in the way of the one generated by the build
278 sudo
rm -f /usr
/rift
/usr
/lib
/libmano_yang_gen.so
281 sudo
chmod 777 /usr
/rift
/usr
/rift
/usr
/share
284 sudo apt-get
install -y \
285 rw.core.mc-\
*-${PLATFORM_VERSION}
289 sudo apt-get
install -y \
290 rw.ui-about-
${PLATFORM_VERSION} \
291 rw.ui-logging-
${PLATFORM_VERSION} \
292 rw.ui-skyquake-
${PLATFORM_VERSION} \
293 rw.ui-accounts-
${PLATFORM_VERSION} \
294 rw.ui-composer-
${PLATFORM_VERSION} \
295 rw.ui-launchpad-
${PLATFORM_VERSION} \
296 rw.ui-debug-
${PLATFORM_VERSION} \
297 rw.ui-config-
${PLATFORM_VERSION} \
298 rw.ui-dummy_component-
${PLATFORM_VERSION}
302 echo "Internal error: unknown platform $PLATFORM"
306 # install some base files used to create VNFs
307 test -d /usr
/rift
/images || mkdir
/usr
/rift
/images
308 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
309 test -f /usr
/rift
/images
/$file || curl
-o /usr
/rift
/images
/$file http
://repo.riftio.com
/releases
/open.riftio.com
/4.3.1/$file
312 # If you are re-building SO, you just need to run
314 if ! $installSO; then
319 if [[ $UIPathToBuild ]]; then
320 make -C $UIPathToBuild -j16
321 sudo
make -C $UIPathToBuild install
324 echo "Creating Service ...."
325 sudo $
(dirname $0)/create_launchpad_service