BUILD_UB.sh changes to pick up new platform 93/393/1
authorKIRAN KASHALKAR <kiran.kashalkar@riftio.com>
Mon, 26 Sep 2016 17:17:52 +0000 (13:17 -0400)
committerKIRAN KASHALKAR <kiran.kashalkar@riftio.com>
Mon, 26 Sep 2016 17:17:52 +0000 (13:17 -0400)
Signed-off-by: KIRAN KASHALKAR <kiran.kashalkar@riftio.com>
BUILD_UB.sh

index 3f8d3cb..2ddf782 100755 (executable)
@@ -1,3 +1,4 @@
+#!/usr/bin/env bash
 # 
 #   Copyright 2016 RIFT.IO Inc
 #
 #
 # This is a top-level build script for RIFT.io
 #
-# args none
+# Arguments and options: use -h or --help
 #
 # dependencies -- requires sudo rights
 
+###############################################################################
+# Options and arguments
+
+params="$(getopt -o suhb: -l install-so,install-ui,build-ui:,help --name "$0" -- "$@")"
+if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
+
+eval set -- $params
+
+installSO=false
+installUI=false
+UIPathToBuild=
+
+while true; do
+    case "$1" in
+       -s|--install-so) installSO=true; shift;;
+       -u|--install-ui) installUI=true; shift;;
+       -b|--build-ui) shift; UIPathToBuild=$1; shift;;
+       -h|--help)
+           echo
+           echo "NAME:"
+           echo "  $0"
+           echo
+           echo "SYNOPSIS:"
+           echo "  $0 -h|--help"
+           echo "  $0 [-o] [-u|-b PATH-TO-UI-REPO] [PLATFORM_REPOSITORY] [PLATFORM_VERSION]"
+           echo
+           echo "DESCRIPTION:"
+           echo "  Prepare current system to run SO and UI.  By default, the system"
+           echo "  is set up to support building SO and UI; optionally, either or"
+           echo "  both SO and UI can be installed from a Debian package repository."
+           echo
+           echo "  -o|--install-so:  install SO from package"
+           echo "  -u|--install-ui:  install UI from package"
+           echo "  -b|--build-ui PATH-TO-UI-REPO:  build the UI in the specified repo"
+           echo "  PLATFORM_REPOSITORY (optional): name of the RIFT.ware repository."
+           echo "  PLATFORM_VERSION (optional): version of the platform packages to be installed."
+           echo
+           exit 0;;
+       --) shift; break;;
+       *) echo "Not implemented: $1" >&2; exit 1;;
+    esac
+done
+
+if $installUI && [[ $UIPathToBuild ]]; then
+    echo "Cannot both install and build the UI!"
+    exit 1
+fi
 
-# ARGS
+if [[ $UIPathToBuild && ! -d $UIPathToBuild ]]; then
+    echo "Not a directory: $UIPathToBuild"
+    exit 1
+fi
+       
 
 PLATFORM_REPOSITORY=${1:-OSM}
-PLATFORM_VERSION=${2:-4.3.1.0.49164}
+PLATFORM_VERSION=${2:-4.3.1.0.49556}
+
+###############################################################################
+# Main block
+
+# Turn these on after handling options, so the output doesn't get cluttered.
+set -o errexit    # Exit on any error
+set -x             # Print commands before executing them
 
 # must be run from the top of a workspace
 cd $(dirname $0)
@@ -57,10 +116,7 @@ sudo -H /usr/rift/container_tools/mkcontainer --modes build --modes ext --repo $
 
 
 # install the RIFT platform code:
-temp=$(mktemp -d /tmp/rw.XXX)
-pushd $temp
-
-apt-get download rw.toolchain-rwbase=${PLATFORM_VERSION} \
+sudo apt-get install -y rw.toolchain-rwbase=${PLATFORM_VERSION} \
                        rw.toolchain-rwtoolchain=${PLATFORM_VERSION} \
                        rw.core.mgmt-mgmt=${PLATFORM_VERSION} \
                        rw.core.util-util=${PLATFORM_VERSION} \
@@ -69,30 +125,46 @@ apt-get download rw.toolchain-rwbase=${PLATFORM_VERSION} \
                        rw.automation.core-RWAUTO=${PLATFORM_VERSION} \
             rw.core.rwvx-rwha-1.0=${PLATFORM_VERSION}
 
-sudo dpkg -i --force-overwrite *deb
-
-
-popd
-rm -rf $temp
-
-# this file gets in the way of the one generated by the build
-sudo rm -f /usr/rift/usr/lib/libmano_yang_gen.so
-
-
 sudo chmod 777 /usr/rift /usr/rift/usr/share
 
+if $installSO; then
+    sudo apt-get install -y \
+        rw.core.mc-\*=${PLATFORM_VERSION}
+fi
+
+if $installUI; then
+    sudo apt-get install -y \
+        rw.ui-about=${PLATFORM_VERSION} \
+        rw.ui-logging=${PLATFORM_VERSION} \
+        rw.ui-skyquake=${PLATFORM_VERSION} \
+        rw.ui-accounts=${PLATFORM_VERSION} \
+        rw.ui-composer=${PLATFORM_VERSION} \
+        rw.ui-launchpad=${PLATFORM_VERSION} \
+        rw.ui-debug=${PLATFORM_VERSION} \
+        rw.ui-config=${PLATFORM_VERSION} \
+        rw.ui-dummy_component=${PLATFORM_VERSION}
+fi
+
 # install some base files used to create VNFs
 test -d /usr/rift/images || mkdir /usr/rift/images
 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
     test -f /usr/rift/images/$file || curl -o /usr/rift/images/$file http://repo.riftio.com/releases/open.riftio.com/4.3.1/$file 
 done
 
-####### If you are re-building, you just need to run
+# If you are re-building SO, you just need to run
 # these two steps
-make -j16 
-sudo make install
-
-# you can now clone and build the UI using just make && sudo make install 
-# or you can run without the UI, e.g. 
-# note to start the RIFT.io UI please run
+if ! $installSO; then
+    make -j16 
+    sudo make install
+fi    
+
+if [[ $UIPathToBuild ]]; then
+    make -C $UIPathToBuild -j16
+    sudo make -C $UIPathToBuild install
+fi
+
+echo "To run SO with UI please run:"
+echo 'sudo -H /usr/rift/rift-shell -r -i /usr/rift -a /usr/rift/.artifacts -- ./demos/launchpad.py --use-xml-mode'
+echo
+echo "To run SO without UI please run:"
 echo 'sudo -H /usr/rift/rift-shell -r -i /usr/rift -a /usr/rift/.artifacts -- ./demos/launchpad.py --use-xml-mode --no-ui'