blob: 17e2443c174a6d7bfa7891756d854c5394b07684 [file] [log] [blame]
Jeremy Mordkoff03156e32017-09-30 21:42:44 -04001#!/usr/bin/env bash
2#
3# Copyright 2016,2017 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 OSM SO or UI
25#
26# Arguments and options: use -h or --help
27#
28# dependencies -- requires sudo rights
29
30MODULE=UI
31
32# Defensive bash programming flags
33set -o errexit # Exit on any error
34trap 'echo ERROR: Command failed: \"$BASH_COMMAND\"' ERR
35set -o nounset # Expanding an unset variable is an error. Variables must be
36 # set before they can be used.
37
38###############################################################################
39# Options and arguments
40
41# There
42params="$(getopt -o h -l install,help --name "$0" -- "$@")"
43if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
44
45eval set -- $params
46
47installFromPackages=false
48
49while true; do
50 case "$1" in
51 --install) installFromPackages=true; shift;;
52 -h|--help)
53 echo
54 echo "NAME:"
55 echo " $0"
56 echo
57 echo "SYNOPSIS:"
58 echo " $0 -h|--help"
Jeremy Mordkoffba6e51c2017-12-12 19:18:01 -050059 echo " $0 [--install] [PLATFORM_VERSION]"
Jeremy Mordkoff03156e32017-09-30 21:42:44 -040060 echo
61 echo "DESCRIPTION:"
62 echo " Prepare current system to run $MODULE. By default, the system"
63 echo " is set up to support building $MODULE; optionally, "
64 echo " $MODULE can be installed from a Debian package repository."
65 echo
66 echo " --install: install $MODULE from package"
Jeremy Mordkoff03156e32017-09-30 21:42:44 -040067 echo " PLATFORM_VERSION (optional): version of the platform packages to be installed."
68 echo
69 exit 0;;
70 --) shift; break;;
71 *) echo "Not implemented: $1" >&2; exit 1;;
72 esac
73done
74
75# Turn this on after handling options, so the output doesn't get cluttered.
76set -x # Print commands before executing them
77
78###############################################################################
79# Set up repo and version
80
Jeremy Mordkoffba6e51c2017-12-12 19:18:01 -050081PLATFORM_VERSION=${1:-5.2.0.3.73627}
Jeremy Mordkoff03156e32017-09-30 21:42:44 -040082
83###############################################################################
84# Main block
85
86# must be run from the top of a workspace
87cd $(dirname $0)
88
89# enable the right repos
90curl http://repos.riftio.com/public/xenial-riftware-public-key | sudo apt-key add -
91
92# always use the same file name so that updates will overwrite rather than enable a second repo
Jeremy Mordkoff03156e32017-09-30 21:42:44 -040093sudo apt-get update
Jeremy Mordkoff602d66b2017-12-12 19:15:20 -050094echo "deb https://artifactory.riftio.com/debian-OSM xenial main" >/etc/apt/source.list.d/rift.list
Jeremy Mordkoff03156e32017-09-30 21:42:44 -040095
96sudo apt install -y --allow-downgrades rw.tools-container-tools=${PLATFORM_VERSION} rw.tools-scripts=${PLATFORM_VERSION}
97
98if $installFromPackages; then
99
100 # Install module and platform from packages
Jeremy Mordkoff602d66b2017-12-12 19:15:20 -0500101 sudo -H /usr/rift/container_tools/mkcontainer --modes $MODULE --rw-version ${PLATFORM_VERSION}
Jeremy Mordkoff03156e32017-09-30 21:42:44 -0400102
103else
104
105 # Install environment to build module
Jeremy Mordkoff602d66b2017-12-12 19:15:20 -0500106 sudo -H /usr/rift/container_tools/mkcontainer --modes $MODULE-dev --rw-version ${PLATFORM_VERSION}
Jeremy Mordkoff03156e32017-09-30 21:42:44 -0400107
108 # Build and install module
109 make -j16
110 sudo make install
Jeremy Mordkoff03156e32017-09-30 21:42:44 -0400111
112fi
113
114if [[ $MODULE == SO ]]; then
115 echo "Creating Service ...."
116 sudo /usr/rift/bin/create_launchpad_service
117fi
118
119